Damage types that apply status effects vs. straight Effects

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Kaballah
Cornac
Posts: 32
Joined: Sun Jul 22, 2012 10:36 pm

Damage types that apply status effects vs. straight Effects

#1 Post by Kaballah »

If I'm reading this correctly, it looks to me that when a talent applies a status effect directly via target:setEffect() is never resisted by saving throws. The "right way" to apply status effects by a damage type isn't it? E.g. instead of how Rushing Claws is done (straight setEffect X rounds of pin) you should use the damage type "pinning"? The more I think about this the more I realize yeah it's pretty obvious you shouldn't ever use setEffect() directly, duh feel free to correct me thanks.

Is it possible to modify the power parameter:

target:setEffect(target.EFF_PINNED, dam.dur, {apply_power=src:combatPhysicalpower()})

E.g. I'm writing a talent that makes this effect (and others like it) harder to resist, and I want to make that power parameter larger. This looks like I can't?

e: this is probably pretty specific to the PINNED effect, looking at the other effects they generally take "power" into account

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: Damage types that apply status effects vs. straight Effe

#2 Post by edge2054 »

I'm not sure what's going on with Rushing Claws seems like a bug/oversight that it can't be resisted but I didn't code it so I don't know what the intent was.

You can modify the apply_power parameter. Really you can put anything in there as long as it's a number.

If you're trying to build a talent that modifies say the power of *all* pins then yeah, it's going to take a lot of work because there's no central 'pin' damage type. If you're just doing it for one group of new talents that you're adding it shouldn't be too difficult though.

lukep
Sher'Tul Godslayer
Posts: 1712
Joined: Mon Mar 14, 2011 10:32 am
Location: Canada

Re: Damage types that apply status effects vs. straight Effe

#3 Post by lukep »

You can avoid using the pin damage type by placing it in the action of the talent, eg. like in Rush:

Code: Select all

			if self:attackTarget(target, nil, 1.2, true) and target:canBe("stun") then
				-- Daze, no save
				target:setEffect(target.EFF_DAZED, 3, {})
			end
All that is needed is to add something like apply_power=t.getPower(self, t) to the setEffect, and something like getPower(self, t)= self:combatPhysicalPower() * self:getTalentLevel(t) in the talent itself.
Some of my tools for helping make talents:
Melee Talent Creator
Annotated Talent Code (incomplete)

Kaballah
Cornac
Posts: 32
Joined: Sun Jul 22, 2012 10:36 pm

Re: Damage types that apply status effects vs. straight Effe

#4 Post by Kaballah »

I've been looking around in code and I can see that setEffect is used in a lot of places with pinning and power is being set as a parameter - like in the rogue bear trap - and I'm pretty sure it can be resisted correctly after all, I just don't see why it works. It doesn't look like it ought to work but it does. Never mind I guess!

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: Damage types that apply status effects vs. straight Effe

#5 Post by edge2054 »

It gets passed into a function in actor.

Kaballah
Cornac
Posts: 32
Joined: Sun Jul 22, 2012 10:36 pm

Re: Damage types that apply status effects vs. straight Effe

#6 Post by Kaballah »

Oh, okay, it looks like this function in actor.lua?

function _M:on_set_temporary_effect(eff_id, e, p)

where p is the effect's power? I don't see where p is passed in if it isn't explicitly given when you call it but I can see that it works anyway, that's fine. Thanks!

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: Damage types that apply status effects vs. straight Effe

#7 Post by edge2054 »

p is the parameter table for the effect.

So when you assign {apply_power = self:combatPhysicalPower()} you're adding to this line...

Code: Select all

-- From the cut timed effect
parameters = { power=1 },
So afterwords it would look like this...

Code: Select all

parameters = { power = 1, apply_power = 25 }
Assuming your physical power is 25 anyway ;)

Kaballah
Cornac
Posts: 32
Joined: Sun Jul 22, 2012 10:36 pm

Re: Damage types that apply status effects vs. straight Effe

#8 Post by Kaballah »

Okay, does this look like it will work? The idea is to throw a projectile, and have it a) pin on impact, assuming target actor fails save; and b) leave a map effect that will also try to pin on subsequent turns if the target stays in it.

e: I want it to affect self if you happen to step into the puddle of glue, so I think tg.selffire is the right setting?

update: this syntax loads, yay

Code: Select all

newTalent{
	name = "Glue Grenade",
	type = {"cunning/grenades", 1},
	points = 1,
	stamina = 10,
	cooldown = 15,
	direct_hit = true,
	requires_target = true,
	tactical = { DISABLE = { pin = 3 } },
	range = function(self, t)
		return math.ceil(5 + self:getDex(6))  -- SAME AS ALCHEMIST BOMB RANGE
	end,
	radius = function(self, t)
		if self:getTalentLevel(t) < 4 then
			return 0
		else
			return 1
		end
	end,
	power = function(self, t) 
		local base = self:combatPhysicalPower()
		if self:knowTalent(self.T_SECRET_INGREDIENT) then
			local bonus = self:getTalentLevel(self.T_SECRET_INGREDIENT) * 5
			return base * (1 + (bonus/100))
		else
			return base
		end
	end,
	effDuration = function(self, t)  -- DURATION OF EFFECT ON HIT
		local base = 1 + math.ceil(self:getTalentLevelRaw(t))
		if self:knowTalent(self.T_SECRET_INGREDIENT) then
			return base + math.max(1, self:getTalentLevel(self.T_SECRET_INGREDIENT) / 2)
		else
			return base
		end
	end,  
	cloudDuration = function(self, t)  -- DURATION OF THE CLOUD MAP EFFECT
		local base = 1 + math.ceil(self:getTalentLevelRaw(t) / 2)
		if self:knowTalent(self.T_SECRET_INGREDIENT) then
			return base + math.max(1, self:getTalentLevel(self.T_SECRET_INGREDIENT) / 2)
		else
			return base
		end
	end,
	target = function(self, t)
		return {type="ball", range=self:getTalentRange(t), radius=self:getTalentRadius(t), talent=t}
	end,
	action = function(self, t)
		local tg = self:getTalentTarget(t)
		local x, y = self:getTarget(tg)
		if not x or not y then return nil end
		self:project(tg, x, y, function(tx, ty)
			local target = game.level.map(tx, ty, Map.ACTOR)
			if not target then return end
				if target:canBe("pin") then
					target:setEffect(target.EFF_PINNED, t.effDuration(self, t), {apply_power=t.power(self, t)})
				else
					game.logSeen(target, "%s resists!", target.name:capitalize())
				end
			-- Add a lasting map effect
			game.level.map:addEffect(self,
				self.x, self.y, cloudDuration(self, t),
				--  DamageType.PINNING syntax was giving me problems!
				DamageType.PINNING, {dam=0, dur = t.effDuration(self, t), apply_power = t.power(self, t)},
				self:getTalentRadius(t),
				5, nil,
				engine.Entity.new{alpha=100, display='', color_br=30, color_bg=180, color_bb=60},
				nil, tg.selffire
			)
			game:playSoundNear(self, "talents/slime")
			return true, true
			end
		)
	return true
	end,
	info = function(self, t)
		return ([[Throws a small pot of sticky glue that splatters on your foe, pinning it to the ground for %d turns.
		A lingering puddle of glue remains on the floor for %d turns.
		At level 4, radius becomes 1.]]):
		format(t.effDuration(self, t), t.cloudDuration(self, t))
	end,
}

Kaballah
Cornac
Posts: 32
Joined: Sun Jul 22, 2012 10:36 pm

Re: Damage types that apply status effects vs. straight Effe

#9 Post by Kaballah »

Why does this blow up when I try to execute the talent?

Code: Select all

	power = function(self, t) 
		local base = self:combatPhysicalPower()  -- THIS LINE BLOWS UP
		if self:knowTalent(self.T_SECRET_INGREDIENT) then
			local bonus = self:getTalentLevel(self.T_SECRET_INGREDIENT) * 5
			return base * (1 + (bonus/100))
		else
			return base
		end
	end,
attempt to call method 'combatPhysicalPower' (a nil value)

grayswandir
Uruivellas
Posts: 708
Joined: Wed Apr 30, 2008 5:55 pm

Re: Damage types that apply status effects vs. straight Effe

#10 Post by grayswandir »

It's combatPhysicalpower, I believe. Lowercase power.
Addons: Arcane Blade Tweaks, Fallen Race, Monk Class, Weapons Pack
Currently working on Elementals. It's a big project, so any help would be appreciated. :)

Kaballah
Cornac
Posts: 32
Joined: Sun Jul 22, 2012 10:36 pm

Re: Damage types that apply status effects vs. straight Effe

#11 Post by Kaballah »

duh so it is
that's what I get for programming at 4am thanks :mrgreen:

Kaballah
Cornac
Posts: 32
Joined: Sun Jul 22, 2012 10:36 pm

Re: Damage types that apply status effects vs. straight Effe

#12 Post by Kaballah »

Okay I actually have this working as I want it to - the first bolt hit applies a pin, and a lingering map effect also applies a pin, and they're being saved against correctly as far as I can tell. Now though, if you're sitting in the puddle of glue and on the previous turn you had failed (and you're pinned for X turns), on the next round you make a save, the previously existing pin is removed. That seems kinda wrong!

Code: Select all

			game.level.map:addEffect(self,
				x,y, t.cloudDuration(self, t),
				DamageType.PINNING, {dam=0, dur = t.effDuration(self, t), apply_power = t.power(self, t)},
				t.radius(self, t),
				5, nil,
				engine.Entity.new{alpha=100, display='', color_br=30, color_bg=120, color_bb=60},
				nil, tg.selffire
			)
What I had hoped for was, when you make a save, you don't get a fresh re-application of the pin, but you shouldn't have last round's pinning effect removed. I think this is coded correctly, and this is just how DamageType.PINNING and saves work? If so, then maybe this damage type needs to be looked at. I guess I could write a custom damage type that checks to see if you're already pinned and stop?

e: yeah I think that's what I'm gonna have to do, I don't see a way to get this behavior otherwise. I think I'll also be having this problem with other status effects applied by game.level.map:addEffect()

Kaballah
Cornac
Posts: 32
Joined: Sun Jul 22, 2012 10:36 pm

Re: Damage types that apply status effects vs. straight Effe

#13 Post by Kaballah »

This seems to work:

Code: Select all

newDamageType{
	name = "glue", type = "GLUE",
	projector = function(src, x, y, type, dam)
		DamageType:get(DamageType.PHYSICAL).projector(src, x, y, DamageType.PHYSICAL, dam.dam)
		local target = game.level.map(x, y, Map.ACTOR)
		local reapplied = false
		if target then
			-- silence the apply message if the target already has the effect
			for eff_id, p in pairs(target.tmp) do
				local e = target.tempeffect_def[eff_id]
				if e.desc == "Pinned to the ground" then
					reapplied = true
				end
			end
			if target:canBe("pin") and not target:attr("never_move") then
				target:setEffect(target.EFF_PINNED, dam.dur, {apply_power=src:combatPhysicalpower()}, reapplied)
			else
				game.logSeen(target, "%s resists!", target.name:capitalize())
			end
		end
	end,
}
although for neatness I'm gonna remove the damage portion, it shouldn't be reporting 0 damage (it's just glue)
thanks to Edge for the coding advice

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: Damage types that apply status effects vs. straight Effe

#14 Post by edge2054 »

Code: Select all

 DamageType:get(DamageType.PHYSICAL).projector(src, x, y, DamageType.PHYSICAL, dam.dam)
You can remove that line to get rid of the damage report.

Kaballah
Cornac
Posts: 32
Joined: Sun Jul 22, 2012 10:36 pm

Re: Damage types that apply status effects vs. straight Effe

#15 Post by Kaballah »

thanks!

Post Reply