can i use a modable tile with a sustain?

All development conversation and discussion takes place here

Moderator: Moderator

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

can i use a modable tile with a sustain?

#1 Post 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?

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: can i use a modable tile with a sustain?

#2 Post by HousePet »

Does Psiblades do similar to what you are after?
My feedback meter decays into coding. Give me feedback and I make mods.

Pigslayer
Halfling
Posts: 94
Joined: Mon Jan 21, 2013 1:51 am

Re: can i use a modable tile with a sustain?

#3 Post by Pigslayer »

Edit: Nevermind. It wasn't what you're looking for.

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

Re: can i use a modable tile with a sustain?

#4 Post 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,
}


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

Re: can i use a modable tile with a sustain?

#5 Post 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.

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

Re: can i use a modable tile with a sustain?

#6 Post 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!

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

Re: can i use a modable tile with a sustain?

#7 Post 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.

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: can i use a modable tile with a sustain?

#8 Post by HousePet »

Yeah, ret becomes p.
My feedback meter decays into coding. Give me feedback and I make mods.

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

Re: can i use a modable tile with a sustain?

#9 Post 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. :oops:

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!

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

Re: can i use a modable tile with a sustain?

#10 Post 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.

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

Re: can i use a modable tile with a sustain?

#11 Post by daftigod »

Working 100%

Thanks dude :mrgreen:

magelike
Halfling
Posts: 109
Joined: Mon Sep 26, 2011 4:31 am

Re: can i use a modable tile with a sustain?

#12 Post by magelike »

This class better have grappling.

And a cooking talent. Any enemies who smell what you're cooking are dazed.

Post Reply