Need help coding a talent!

A place to post your add ons and ideas for them

Moderator: Moderator

Post Reply
Message
Author
daftigod
Archmage
Posts: 300
Joined: Fri Feb 18, 2011 6:15 am

Need help coding a talent!

#1 Post by daftigod »

hey guys, i really suck at coding and need some help. the talent shouldn't be all that difficult to get working, and i have most of it in place, but it just doesn't work. there are a couple of things i think i'm doing wrong, but i just can't figure out exactly what is the proper format to put stuff in. everything i've done so far has been figured out by editing the standard lua files, and i'm just at the point where i'm over my head

it is a sustain
it is supposed to modify a number of basic attributes; size_category, physpower, and health regen positively. movement speed, accuracy, and stamina regen negatively.
if possible, i'd like it to trigger itself to activate on any bleed damage
(it will probably also get a +20 cut immunity per level but this is not important for now)
(it will also get its own player sprite when active, but i can get that code from lichform)

i've tried to keep it simple in the way it modifies stats, and tried to keep it contained in just the mutations.lua file without using actor.lua or combat.lua . this hasn't worked so far

here's what i have so far:

Code: Select all

newTalent{
	name = "Hulk Mode",
	type = {"wild-gift/mutations", 3},
	mode = "sustained",
	points = 5,
	require = barbgift_highreq1,
	cooldown = 30,
	sustain_stamina = 50,
	tactical = { BUFF = 2 },
	activate = function(self, t)

		return {
			size = self:addTemporaryValue("size_category", 0.5 * self:getTalentLevel(t)),
			dam = self:addTemporaryValue("combat_dam", 15 * self:getTalentLevel(t)),
			atk = self:addTemporaryValue("combat_atk", - 0.05 * self:getTalentLevel(t)),
			movespeed = self:addTemporaryValue("movement_speed", - 0.05 * self:getTalentLevel(t)),
			liferegen = self:addTemporaryValue("life_regen", 2 * self:getTalentLevel(t)),
			stamregen = self:addTemporaryValue("stamina_regen", - 1 * self:getTalentLevel(t)),		
		}
	end,
	deactivate = function(self, t, p)
		self:removeTemporaryValue("size_category", p.size)
		self:removeTemporaryValue("combat_dam", p.dam)
		self:removeTemporaryValue("combat_atk", p.atk)
		self:removeTemporaryValue("movement_speed", p.movespeed)
		self:removeTemporaryValue("life_regen", p.liferegen)
		self:removeTemporaryValue("stamina_regen", p.stamregen)

		return true
	end,
	info = function(self, t)
		return ([[Turn into the Hulk. Greatly increase your size, strength, health regen, and cut immunity. Lose some accuracy, global speed, and drain stamina while active due to your massive bulk.
		
		*Gain 1 size category for every two points in the skill. (First huge, then gargntuan)
		
		+%d Physical Power
		+%d Health Regeneration
		
		-%d Stamina Regeneration
		-%d Accuracy
		-%d Movement Speed]]):format(15 * self:getTalentLevel(t), 2 * self:getTalentLevel(t), self:getTalentLevel(t), 5 * self:getTalentLevel, 5 * self:getTalentLevel(t))
	end,
}
now i've just recently noticed that some of these basic stats use self, like self.movement_speed or self.combat_atk. others use t, like r t.health_regen and t.stamina_regen. i don't know what this means. i have a feeling this is why my talent won't work though.

can someone point me in the right direction? thanks in advance!

BDota
Higher
Posts: 62
Joined: Fri Oct 01, 2010 11:15 pm

Re: Need help coding a talent!

#2 Post by BDota »

Code: Select all

format(15 * self:getTalentLevel(t), 2 * self:getTalentLevel(t), self:getTalentLevel(t), 5 * self:getTalentLevel, 5 * self:getTalentLevel(t))
Should be:

Code: Select all

format(15 * self:getTalentLevel(t), 2 * self:getTalentLevel(t), self:getTalentLevel(t), 5 * self:getTalentLevel(t), 5 * self:getTalentLevel(t))
I didn't test it extensively, but aside from that it seemed to work. One thing I'm not sure about is how ToME handles size categories. If you want to make sure the size category is an integer you could do:

Code: Select all

size = self:addTemporaryValue("size_category", math.floor(0.5 * self:getTalentLevel(t))),

daftigod
Archmage
Posts: 300
Joined: Fri Feb 18, 2011 6:15 am

Re: Need help coding a talent!

#3 Post by daftigod »

thank you BDota!

aardvark
Wyrmic
Posts: 200
Joined: Wed Aug 22, 2012 12:16 am

Re: Need help coding a talent!

#4 Post by aardvark »

While it won't make things any more likely to work, changing your addTemporaryValue() calls to talentTemporaryValue() calls will make the engine clean up after you, simplifying your talent definition, like so (w/BDota's suggestions integrated):

Code: Select all

newTalent{
	name = "Hulk Mode",
	type = {"wild-gift/mutations", 3},
	mode = "sustained",
	points = 5,
	require = barbgift_highreq1,
	cooldown = 30,
	sustain_stamina = 50,
	tactical = { BUFF = 2 },
	activate = function(self, t)
		self:talentTemporaryValue("size_category", 0.5 * math.floor(0.5 * self:getTalentLevel(t))),
		self:talentTemporaryValue("combat_dam", 15 * self:getTalentLevel(t)),
		self:talentTemporaryValue("combat_atk", - 0.05 * self:getTalentLevel(t)),
		self:talentTemporaryValue("movement_speed", - 0.05 * self:getTalentLevel(t)),
		self:talentTemporaryValue("life_regen", 2 * self:getTalentLevel(t)),
		self:talentTemporaryValue("stamina_regen", - 1 * self:getTalentLevel(t)),      
	end,
	deactivate = function(self, t, p)
		return true
	end,
	info = function(self, t)
		return ([[Turn into the Hulk. Greatly increase your size, strength, health regen, and cut immunity. Lose some accuracy, global speed, and drain stamina while active due to your massive bulk.
      
      *Gain 1 size category for every two points in the skill. (First huge, then gargantuan)
      
      +%d Physical Power
      +%d Health Regeneration
      
      -%d Stamina Regeneration
      -%d Accuracy
      -%d Movement Speed]]):format(15 * self:getTalentLevel(t), 2 * self:getTalentLevel(t), self:getTalentLevel(t), 5 * self:getTalentLevel, 5 * self:getTalentLevel(t))
	end,
}

Post Reply