Page 1 of 1
can i use a modable tile with a sustain?
Posted: Sat Feb 02, 2013 11:19 pm
by daftigod
Hi, I'm trying to make a sustain that changes the player tile when it's active, like Lichform or Deeprock Form. I'd also like to use a modable tile with it's own folder for armors, called mutant. When the sustain is deactivated, the player tile is switched back to default.
How would i go about doing this?
Re: can i use a modable tile with a sustain?
Posted: Sun Feb 03, 2013 4:31 am
by HousePet
Does Psiblades do similar to what you are after?
Re: can i use a modable tile with a sustain?
Posted: Sun Feb 03, 2013 7:26 pm
by Pigslayer
Edit: Nevermind. It wasn't what you're looking for.
Re: can i use a modable tile with a sustain?
Posted: Thu Feb 07, 2013 6:34 am
by daftigod
The psiblades code helped alot actually! Thanks
The only thing that doesn't work is switching back to the default player sprite when deactivating the sustain. I probably shouldn't be trying to nil the value for self.moddable_tile, and should figure out how to write an if/then statement to call the default birth descriptor and base tile. But this is way over my head!
I wish I could add a mutant_female also, but lack the intelligence to even write "if female then self.moddable_tile = mutant female" in Lua or anything else for that matter and this is very frustrating. I should have learned how to write basic code a very, very long time ago. If someone could take a look at what I have so far and point me in the right direction I'd really appreciate it!
Code: Select all
newTalent{
name = "Mutant",
type = {"wild-gift/mutations", 1},
mode = "sustained",
points = 5,
require = barbgift_req1,
cooldown = 20,
sustain_stamina = 80,
tactical = { BUFF = 2 },
activate = function(self, t)
self.moddable_tile = "mutant"
self.moddable_tile_nude = true
self.moddable_tile_base = "base_mutant_01.png"
self.moddable_tile_ornament = nil
self.blood_color = colors.GREEN
self:updateModdableTile()
local t = self:getTalentFromId(self.T_MUTANT)
return {
size = self:addTemporaryValue("size_category", 0.5 * self:getTalentLevel(t)),
dam = self:addTemporaryValue("combat_dam", 20 * self:getTalentLevel(t)),
atk = self:addTemporaryValue("combat_atk", 0.04 * self:getTalentLevel(t)),
movespeed = self:addTemporaryValue("movement_speed", - 0.04 * self:getTalentLevel(t)),
liferegen = self:addTemporaryValue("life_regen", 1.5 * self:getTalentLevel(t)),
stamregen = self:addTemporaryValue("stamina_regen", - 1 * self:getTalentLevel(t)),
}
end,
deactivate = function(self, t, p)
self.moddable_tile = nil
self.moddable_tile_nude = true
self.moddable_tile_base = nil
self.moddable_tile_ornament = nil
self.blood_color = colors.RED
self:updateModdableTile()
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 ([[You better say your prayers and take you vitamins brotha, cause Hulkamania is gonna run wild on you! Greatly increase your size, strength, and health regen. But, due to your massive increases in bulk and power, you rapidly lose your stamina, accuracy, and movement speed.
*Gain 1 size category for every two points in the skill. (First huge, then gargntuan)
+%d Physical Power
+%0.2f Health per turn
-%0.2f Stamina per turn
-%d%% Accuracy
-%d%% Movement Speed]]):format(20 * self:getTalentLevel(t), 1.5 * self:getTalentLevel(t), 0.75 * self:getTalentLevel(t), 4 * self:getTalentLevel(t), 4 * self:getTalentLevel(t))
end,
}
Re: can i use a modable tile with a sustain?
Posted: Fri Feb 08, 2013 12:36 am
by aardvark
Here's a few changes:
Code: Select all
activate = function(self, t)
local ret = {}
ret.moddable_tile = self.moddable_tile
ret.moddable_tile_nude = self.moddable_tile_nude
ret.moddable_tile_base = self.moddable_tile_base
ret.moddable_tile_ornament = self.moddable_tile_ornament
ret.blood_color = self.blood_color
self.moddable_tile = "mutant"
self.moddable_tile_nude = true
self.moddable_tile_base = "base_mutant_01.png"
self.moddable_tile_ornament = nil
self.blood_color = colors.GREEN
self:updateModdableTile()
local t = self:getTalentFromId(self.T_MUTANT)
self:talentTemporaryValue(ret, "size_category", 0.5 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "combat_dam", 20 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "combat_atk", 0.04 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "movement_speed", - 0.04 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "life_regen", 1.5 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "stamina_regen", - 1 * self:getTalentLevel(t)),
return ret
end,
deactivate = function(self, t, p)
self.moddable_tile = p.moddable_tile
self.moddable_tile_nude = p.moddable_tile_nude
self.moddable_tile_base = p.moddable_tile_base
self.moddable_tile_ornament = p.moddable_tile_ornament
self.blood_color = p.blood_color
self:updateModdableTile()
return true
end,
I changed the
addTemporaryValue() calls to
talentTemporaryValue() calls and stored the old moddable tile settings.
talentTemporaryValue() causes the engine to automatically remove the temps so you don't have to do it manually in
deactivate(). Saving the moddable tile settings in
activate() and restoring them in
deactivate() should solve the switching back problem. If you want to change the tile by sex you could do something like:
Code: Select all
self.moddable_tile = self.male and "mutant_male" or "mutant_female"
self.moddable_tile_nude = true
self.moddable_tile_base = self.male and "base_mutant_male01.png" or "base_mutant_female01.png"
self.moddable_tile_ornament = nil
self.blood_color = colors.GREEN
self:updateModdableTile()
Hopefully, that's the sort of thing you wanted.
Re: can i use a modable tile with a sustain?
Posted: Fri Feb 08, 2013 1:28 am
by daftigod
Yeahh aardvark! Thanks!!
Your code works, with a couple of very minor fixes. On deactivate, p.modable.tile (etc) should be ret.modable.tile (etc) as defined in your new ret code. And you need to call ret in the deactivate = function(self, t, p, ret) part. With those two small changes, it worked flawlessly! Thank you so much for taking your time with this!
New barbarian addon coming soon!
Re: can i use a modable tile with a sustain?
Posted: Fri Feb 08, 2013 2:25 am
by aardvark
You shouldn't need any changes. Unless I'm not looking in the right place (engine.interface.ActorTalents:useTalent()), then p and ret are one and the same. ret is a table that activate() populates and returns. That same table is passed to deactivate() as p. Adding a ret parameter to deactivate() should just result in a nil value.
Put another way, ret and p are just two different names for the same table. Unless I'm very wrong, it should work as posted without any extra effort to overload or superload other files or functions.
Re: can i use a modable tile with a sustain?
Posted: Fri Feb 08, 2013 2:49 am
by HousePet
Yeah, ret becomes p.
Re: can i use a modable tile with a sustain?
Posted: Fri Feb 08, 2013 2:57 am
by daftigod
I honestly don't know about any of that stuff man, all I did was paste your code over mine! ToME hangs at 100% after clicking on new player from the main menu, with your code added. So I tried to troubleshoot your code by removing things to see if I could get it working. I know very little about the basic engine stuff, and zero about tables. I just derp my way through things and get lucky sometimes.
So... the first thing I tried was removing the temporary value stuff to see if I could just get the tile switching to load. At this point, I tried to load a previous barbarian character with the mutant talent enabled. And ToME hung again. What I should have done at this point instead is tried to create a new character, because without the temporary values, your code does indeed work flawlessly!
When I made my last post, I had gone to the edit hammer again and mistankenly thought I should make more changes. My apologies for the confusion!! My last post is in error.
But, the game does hang because of something in here, and I'm not comprehending computer code fast enough to find it:
Code: Select all
local t = self:getTalentFromId(self.T_MUTANT)
self:talentTemporaryValue(ret, "size_category", 0.5 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "combat_dam", 20 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "combat_atk", 0.04 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "movement_speed", - 0.04 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "life_regen", 1.5 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "stamina_regen", - 1 * self:getTalentLevel(t)),
Again, sorry about the miscommunication. Thanks for the help, and I hope my previous post didn't offend because I didn't mean to come at you with a correction like that!
Re: can i use a modable tile with a sustain?
Posted: Fri Feb 08, 2013 3:19 am
by aardvark
Oops. Of course it would crash since I forgot to remove the commas at the ends of the
talentTemporaryValue() calls. I just modified your
addTemporaryValue() calls, which were inside a table declaration, and missed that part.
Code: Select all
self:talentTemporaryValue(ret, "size_category", 0.5 * self:getTalentLevel(t))
self:talentTemporaryValue(ret, "combat_dam", 20 * self:getTalentLevel(t))
self:talentTemporaryValue(ret, "combat_atk", 0.04 * self:getTalentLevel(t))
self:talentTemporaryValue(ret, "movement_speed", - 0.04 * self:getTalentLevel(t))
self:talentTemporaryValue(ret, "life_regen", 1.5 * self:getTalentLevel(t))
self:talentTemporaryValue(ret, "stamina_regen", - 1 * self:getTalentLevel(t))
Sorry about that.
And I'm not offended. I do make mistakes. Obviously.
P.S. This line could probably be deleted:
Code: Select all
local t = self:getTalentFromId(self.T_MUTANT)
t is already passed as an argument to
activate() and doesn't need be gotten again.
Re: can i use a modable tile with a sustain?
Posted: Fri Feb 08, 2013 3:28 am
by daftigod
Working 100%
Thanks dude

Re: can i use a modable tile with a sustain?
Posted: Sat Feb 09, 2013 3:02 am
by magelike
This class better have grappling.
And a cooking talent. Any enemies who smell what you're cooking are dazed.