shielding from a specific damage source - CUTs and WOUNDs

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
MisiuPysiu
Archmage
Posts: 379
Joined: Tue Nov 11, 2003 10:54 am
Location: Wroclaw/Poland

shielding from a specific damage source - CUTs and WOUNDs

#1 Post by MisiuPysiu »

Hi there,

I want to create a talent, which will shield the actor from damage from a specific source like cuts, so if the target is bleeding, only the bleeding damage is absorbed by the shield.

I tried to bind the Actor:takeHit hook:


Code: Select all

	class:bindHook("Actor:takeHit", function(self, data)	

if self:hasEffect(self.EFF_FURY_OF_BLOOD) and (data.subtype.wound or data.subtype.cut) then
		local eff = self:hasEffect(self.EFF_FURY_OF_BLOOD)
		data.value = self.tempeffect_def[self.EFF_FURY_OF_BLOOD].do_onTakeHit(self, eff, value)
	end
end)
of course this doesnt work, data.subtype doesnt return the value I need. Is there any other possibility of making such a check?

Cheers

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

Re: shielding from a specific damage source - CUTs and WOUND

#2 Post by HousePet »

Maybe add your check to the on_timeout function for all the bleeding effects?

I haven't looked into the possibility of checking if a damage hit comes from a timed effect properly.
My feedback meter decays into coding. Give me feedback and I make mods.

Hachem_Muche
Uruivellas
Posts: 744
Joined: Thu Nov 18, 2010 6:42 pm

Re: shielding from a specific damage source - CUTs and WOUND

#3 Post by Hachem_Muche »

For 1.0.5 there's a new variable that you can use to see how damage is being done.
Timed effects (like bleeding), projectiles, and other sources that don't come directly from an actor will set the src.__project_source variable. This points to the data table (not definition) for the damage vehicle. (src is the actor that originated the effect.)

So, if you're using the "DamageProjector:final" hook (triggered in damage_types.lua), to test for bleeding (EFF_CUT), use src and src.__projector_source to find the information on the effect. In this case src.__projector_source.effect_id will let you look up the effect definition in engine.interface.ActorTemporaryEffects[id] to let you determine if it's a bleeding effect (or whatever you're looking for). You can then take appropriate action (probably reducing the dam variable, see damage_types.lua).
Author of the Infinite 500 and PlenumTooltip addons, and the joys of Scaling in ToME.

MisiuPysiu
Archmage
Posts: 379
Joined: Tue Nov 11, 2003 10:54 am
Location: Wroclaw/Poland

Re: shielding from a specific damage source - CUTs and WOUND

#4 Post by MisiuPysiu »

Hey Hachem_Muche,

I will look into that. I'm working in the latest beta (or git version) so the solution you proposed can work. I will try it out.
Thanks a lot!

Cheers :)

MisiuPysiu
Archmage
Posts: 379
Joined: Tue Nov 11, 2003 10:54 am
Location: Wroclaw/Poland

Re: shielding from a specific damage source - CUTs and WOUND

#5 Post by MisiuPysiu »

Ha!

its working!

Code: Select all

	game.logPlayer(self, "DamageProjector test...")
	-- damage type
	if data.src.__project_source then
		game.logPlayer(self, "DamageProjector. __project_source.effect_id: %s", data.src.__project_source.effect_id)
		if data.src.__project_source.effect_id == data.src.EFF_CUT then
			game.logPlayer(self, "DamageProjector. __project_source.effect_id: ITS a CUT!!!!!")
		end
	end 
Cheers :)

Hachem_Muche
Uruivellas
Posts: 744
Joined: Thu Nov 18, 2010 6:42 pm

Re: shielding from a specific damage source - CUTs and WOUND

#6 Post by Hachem_Muche »

Good Deal! :)
Author of the Infinite 500 and PlenumTooltip addons, and the joys of Scaling in ToME.

Post Reply