Need a little talent coding help

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
SageAcrin
Sher'Tul Godslayer
Posts: 1884
Joined: Tue Apr 10, 2012 6:52 pm

Need a little talent coding help

#1 Post by SageAcrin »

I'm currently trying to make Archlich's Majesty(see the Prodigy Ideas topic on the Ideas forum, though the code I'm about to post probably gives the idea).

The problem is, it's reacting very weirdly and in ways I can't trace due to inadequate or lacking errors. I think I'm just running into the walls of my knowledge here, so I figure this is probably a simple fix that I just don't know the answer to-but there's nothing I can really glean from just staring at the code farther, I think, so I'm hoping someone will help. :)

Problem 1: The code is supposed to change your tile to that of a Lich...but doesn't. No error is given. Note that the subrace descriptor works right.

Problem 2: For some reason, changing base speed on the Ghoul->Ghoulking transition doesn't seem to actually change speed. Again, no error given.

Problem 3: "player.inc_damage.all = player.inc_damage.all + 10" does actually spring an error...the problem is, I'm not sure what to replace it with to properly increase alldamage. That's the only code I know for it.

Problem 4: The Weakness/etc. Talents do work for the player...but for some reason, using them springs "(player name) diseases unknown" every time. I don't think anything I'm doing is causing that. Maybe it's an error in the source ability?

These are the two pieces of code. (Also, note, I'm doing this in add-on form, if this matters. Superloading the prodigy talent and overloading the chat.)

In talents/uber/mag.lua:

Code: Select all

local _M = loadPrevious(...)

uberTalent{
	name = "Archlich's Majesty",
	mode = "passive",
	on_learn = function(self, t, kind)
		local Chat = require "engine.Chat"
		local chat = Chat.new("archlich", {name="Archlich's Majesty"}, self)
		chat:invoke()
	end,
	info = function(self, t)
		return ([[Obtain the amazing power of the lords of the undead.
		All that use this secret art will be infused with the dark energies of the lich, and liches that use it into the incredible Archlich.
		All liches gain the following intrinsics, if they did not already posess them:
		- Poison, cut, fear immunity
		- Disease resistance 50%%
		- Stun resistance 50%%
		- Cold and darkness resistance 20%%
		- No need to breathe
		- Infusions do not work
		-The living using recieve +5 Magic and Willpower, +2 life rating (not retroactive), +10 spell and mental saves, all resistance caps raised by 10%%, Celestial/Star Fury category (0.9) and 0.5 negative energy regeneration.
		-Skeletons become stronger Liches, gaining +6 Magic, Willpower and Cunning, +3 life rating (not retroactive), +15 spell and mental saves, all resistance caps raised by 15%%, Celestial/Star Fury category (1.1) and 1.0 negative energies regeneration, instead of the weaker bonuses the living gain.
		-Ghouls may become Liches, like Skeletons, or become Ghoulkings, gaining +4 Life Modifier, +10 Strength, Constutition and Cunning, +10 Armor, +15 Spell and Mental Saves, +10%% Global Speed, +.2 to their Ghoul racial category, and +5%% to all resistance caps.
		-Liches that use this become Archliches, raising their Magic, their Willpower and their Cunning by 10, granting them 10%% extra All Damage, 5%% extra Spell Critical rate, raising their Celestial/Star Fury category rating by +.2(Or unlocking it, if they did not have it before), unlocking the Cursed/Shadows tree at 1.1 Category Rating, and granting 1.0 Hate regeneration. ]])
		:format()
	end,
}
And in data/chats/archlich.lua:

Code: Select all

-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011, 2012 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org

local DamageType = require "engine.DamageType"
local Stats = require "engine.interface.ActorStats"

newChat{ id="archlich-fleshy",
	text = [[You can feel the negative energy suffuse you...]],
	answers = {
		{"#LIGHT_GREEN# [Give your flesh up, and become something more.]", action=function(npc, player)
			player.descriptor.race = "Undead"
			player.descriptor.subrace = "Lich"
			player.moddable_tile = "skeleton"
			player.moddable_tile_nude = true
			player.moddable_tile_base = "base_lich_01.png"
			player.moddable_tile_ornament = nil
			player.blood_color = colors.GREY
			player:attr("poison_immune", 1)
			player:attr("disease_immune", 0.5)
			player:attr("stun_immune", 0.5)
			player:attr("cut_immune", 1)
			player:attr("fear_immune", 1)
			player:attr("no_breath", 1)
			player:attr("undead", 1)
			player.resists[DamageType.COLD] = (player.resists[DamageType.COLD] or 0) + 20
			player.resists[DamageType.DARKNESS] = (player.resists[DamageType.DARKNESS] or 0) + 20
			player.inscription_restrictions = player.inscription_restrictions or {}
			player.inscription_restrictions["inscriptions/runes"] = true
			player.inscription_restrictions["inscriptions/taints"] = true
			player:incIncStat("mag", 5) player:incIncStat("wil", 5)
			player:attr("combat_spellresist", 10) player:attr("combat_mentalresist", 10)
			player.resists_cap.all = (player.resists_cap.all or 0) + 10
			player.life_rating = player.life_rating + 2
			player:learnTalentType("celestial/star-fury", true)
			player:setTalentTypeMastery("celestial/star-fury", 0.9)
			player.negative_regen = player.negative_regen + 0.2 + 0.5
			game.logPlayer(player, "You have become a lich!")
			player:updateModdableTile()
			game.level.map:particleEmitter(player.x, player.y, 1, "demon_teleport")
				if player:attr("blood_life") then
					player.blood_life = nil
					game.log("#GREY#As you turn into a powerful undead you feel your body violently rejecting the Blood of Life.")
				end
		end},
	}
}

newChat{ id="archlich-boney",
	text = [[You can feel the negative energy suffuse you...]],
	answers = {
	{"#LIGHT_GREEN# [Breathe deep of the darkness.]", action=function(npc, player)
			player.descriptor.race = "Undead"
			player.descriptor.subrace = "Lich"
			player.moddable_tile = "skeleton"
			player.moddable_tile_nude = true
			player.moddable_tile_base = "base_lich_01.png"
			player.moddable_tile_ornament = nil
			player.blood_color = colors.GREY
			player:attr("poison_immune", 1)
			player:attr("disease_immune", 0.5)
			player:attr("stun_immune", 0.5)
			player:attr("cut_immune", 1)
			player:attr("fear_immune", 1)
			player:attr("no_breath", 1)
			player:attr("undead", 1)
			player.resists[DamageType.COLD] = (player.resists[DamageType.COLD] or 0) + 20
			player.resists[DamageType.DARKNESS] = (player.resists[DamageType.DARKNESS] or 0) + 20
			player.inscription_restrictions = player.inscription_restrictions or {}
			player.inscription_restrictions["inscriptions/runes"] = true
			player.inscription_restrictions["inscriptions/taints"] = true
			player:incIncStat("mag", 6) player:incIncStat("wil", 6) player:incIncStat("cun", 6)
			player:attr("combat_spellresist", 15) player:attr("combat_mentalresist", 15)
			player.resists_cap.all = (player.resists_cap.all or 0) + 15
			player.life_rating = player.life_rating + 3
			player:learnTalentType("celestial/star-fury", true)
			player:setTalentTypeMastery("celestial/star-fury", 1.1)
			player.negative_regen = player.negative_regen + 0.2 + 1
			game.logPlayer(player, "You have become a lich!")
			player:updateModdableTile()
			game.level.map:particleEmitter(player.x, player.y, 1, "demon_teleport")
		end},
	}
}

newChat{ id="archlich-squishy",
	text = [[You can feel the negative energy suffuse you...]],
	answers = {
	{"#LIGHT_GREEN# [Breathe deep of the darkness, and let it transform you into a Lich.]", action=function(npc, player)
			player.descriptor.race = "Undead"
			player.descriptor.subrace = "Lich"
			player.moddable_tile = "skeleton"
			player.moddable_tile_nude = true
			player.moddable_tile_base = "base_lich_01.png"
			player.moddable_tile_ornament = nil
			player.blood_color = colors.GREY
			player:attr("poison_immune", 1)
			player:attr("disease_immune", 0.5)
			player:attr("stun_immune", 0.5)
			player:attr("cut_immune", 1)
			player:attr("fear_immune", 1)
			player:attr("no_breath", 1)
			player:attr("undead", 1)
			player.resists[DamageType.COLD] = (player.resists[DamageType.COLD] or 0) + 20
			player.resists[DamageType.DARKNESS] = (player.resists[DamageType.DARKNESS] or 0) + 20
			player.inscription_restrictions = player.inscription_restrictions or {}
			player.inscription_restrictions["inscriptions/runes"] = true
			player.inscription_restrictions["inscriptions/taints"] = true
			player:incIncStat("mag", 6) player:incIncStat("wil", 6) player:incIncStat("cun", 6)
			player:attr("combat_spellresist", 15) player:attr("combat_mentalresist", 15)
			player.resists_cap.all = (player.resists_cap.all or 0) + 15
			player.life_rating = player.life_rating + 3
			player:learnTalentType("celestial/star-fury", true)
			player:setTalentTypeMastery("celestial/star-fury", 1.1)
			player.negative_regen = player.negative_regen + 0.2 + 1
			game.logPlayer(player, "You have become a lich!")
			player:updateModdableTile()
			game.level.map:particleEmitter(player.x, player.y, 1, "demon_teleport")
		end},
		{"#LIGHT_GREEN# [Take control of the dark energy, and make it your own, becoming a Ghoulking.]", action=function(npc, player)
			player.descriptor.subrace = "Ghoulking"
			player.life_rating = player.life_rating + 4
			player.combat_armor = player.combat_armor + 10
			player.global_speed_base = player.global_speed_base + 0.1
			player:recomputeGlobalSpeed()
			player:incIncStat("str", 10) player:incIncStat("con", 10) player:incIncStat("cun", 10)
			player:attr("combat_spellresist", 15) player:attr("combat_mentalresist", 15)
			player:setTalentTypeMastery("undead/ghoul", player:getTalentTypeMastery("undead/ghoul") + 0.2)
			player.resists_cap.all = (player.resists_cap.all or 0) + 5
--			player:learnTalent(player.T_ROTTING_DISEASE, true, 5, {no_unlearn=true})
--			player:learnTalent(player.T_DECREPITUDE_DISEASE, true, 5, {no_unlearn=true})
--			player:learnTalent(player.T_WEAKNESS_DISEASE, true, 5, {no_unlearn=true})
			game.level.map:particleEmitter(player.x, player.y, 1, "demon_teleport")
			game.logPlayer(player, "You feel more...royal.")
		end},
	}
}

newChat{ id="archlich-lichey",
	text = [[You can feel the negative energy suffuse you...]],
	answers = {
		{"#LIGHT_GREEN# [Drink deeply of the darkness, and realize your true power!]", action=function(npc, player)
			player.descriptor.subrace = "Archlich"
			player:incIncStat("mag", 10) player:incIncStat("wil", 10) player:incIncStat("cun", 10)
			player.inc_damage.all = (player.inc_damage.all or 0) + 10
			player.hate_regen = player.hate_regen + 1
			player.combat_spellcrit = player.combat_spellcrit + 5
				if player:knowTalentType("celestial/star-fury") then
					player:setTalentTypeMastery("celestial/star-fury", player:getTalentTypeMastery("celestial/star-fury") + 0.2)
				else
					player:learnTalentType("celestial/star-fury", true)
					player:setTalentTypeMastery("celestial/star-fury", 1.3)
				end
				if player:knowTalentType("cursed/shadows") then
					player:setTalentTypeMastery("cursed/shadows", player:getTalentTypeMastery("cursed/shadows") + 0.2)
				else
					player:learnTalentType("cursed/shadows", true)
					player:setTalentTypeMastery("cursed/shadows", 1.1)
				end
			game.level.map:particleEmitter(player.x, player.y, 1, "demon_teleport")
			game.logPlayer(player, "You have completed your ascension, and become an Archlich!")
		end},
	}
}

return (game.party:findMember{main=true}.descriptor.subrace == "Skeleton") and "archlich-boney" or (game.party:findMember{main=true}.descriptor.subrace == "Ghoul") and "archlich-squishy" or (game.party:findMember{main=true}.descriptor.subrace == "Lich") and "archlich-lichey" or "archlich-fleshy" 
(Yes, the description is extremely wordy. I'm trying to trim it down some, but it's quite hard. Lichform does a lot! And this adds alternative effects to it!)
Last edited by SageAcrin on Sat Dec 15, 2012 5:24 am, edited 2 times in total.

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Need a little talent coding help

#2 Post by darkgod »

1) Add

Code: Select all

		self:removeAllMOs()
		game.level.map:updateMap(self.x, self.y)
After changing the tile

2) After changing the global speed, you msut call

Code: Select all

self:recomputeGlobalSpeed()
3) inc_damage.all may or may not exist, to make it foolproof use:

Code: Select all

player.inc_damage.all = (player.inc_damage.all or 0) + 10
4) not sure
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

SageAcrin
Sher'Tul Godslayer
Posts: 1884
Joined: Tue Apr 10, 2012 6:52 pm

Re: Need a little talent coding help

#3 Post by SageAcrin »

3 works now, and I feel silly for making that mistake.

1/2 tell me that removeAllMOs and recomputeGlobalSpeed respectively are nil values.

Am I missing a necessary require or something?

(Hehe, the Archlich is pretty fun, honestly.)

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Need a little talent coding help

#4 Post by darkgod »

Well it's obviously not "self" but in this context "player" sorry :)
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

SageAcrin
Sher'Tul Godslayer
Posts: 1884
Joined: Tue Apr 10, 2012 6:52 pm

Re: Need a little talent coding help

#5 Post by SageAcrin »

I did try that, but it's still not immediately updating.

Feels like I'm pretty close though, since it does update after I swap weapons.

Also, that does work for the speed, which I must not have thought to check that for.

So the only real problem(considering that I can always just shrug and dummy out the diseases) is the first one. I still don't get why it's not instantly updating the model, but it does work after doing anything that would update the model.

Also, I think the Diseases are doing that because it brings up the message before it even has a target yet, when a player uses it.

Edit: Hachem_Muche's suggestion of using player:updateModdableTile() seems to do the trick, though. The code up there should be the new version, which seems to fully work, outside of Diseases being a little funny(I'll probably just comment that part, though it is neat. [Edit 2: Commented out, replaced with a small bonus to allrescap. Everything currently should work perfectly, after meticulously checking all the values.]). :) Thanks, DarkGod and Hachem (and everyone else that gave suggestions, even if they didn't all work, I still appreciate the help! :) )

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Need a little talent coding help

#6 Post by darkgod »

Ah yes updateModdableTile obviously, forgot about it :<
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Post Reply