• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] How to transfer life lost from one unit to another?

Status
Not open for further replies.
Level 14
Joined
Jul 1, 2008
Messages
1,314
you can trigger this yourself.

You just have to add the "Special Unit"-Event "Unit takes damage" to your trigger, where you add the summoned units, when summoned.

Now you just insert your action in this trigger. You give the health lost by the Summon to your hero.

So after all you need 2 Triggers for this to run.

Greets
 
Level 6
Joined
Sep 5, 2007
Messages
264
In the actions function of a damage detection trigger, just use:
JASS:
// This example is for 50% damage returned to caster.
local real damage = GetEventDamage()
local unit target = GetTriggerUnit()
local unit owner = <Owner of summoned unit>

local real target_life = GetUnitState(target, UNIT_STATE_LIFE)
local real owner_life = GetUnitState(owner, UNIT_STATE_LIFE)

set target_life = target_life + (damage * 0.5)
set owner_life = owner_life - (damage * 0.5)

call SetUnitState(target, UNIT_STATE_LIFE, target_life)
call SetUnitState(owner, UNIT_STATE_LIFE, owner_life)

Now, for getting the owner of the unit, you can use several methods, I don't really wanna get into them at the moment. You'd also have to have an if or a condition in there somewhere to check if it's a summoned unit. :thumbs_up:
 
Level 22
Joined
Feb 4, 2005
Messages
3,971
Remember that Damage Taken needs a unit to be selected on the map and in my case the summoned unit that cannot be selected on the map for triggers,must transfer the life it loses to the caster.

Sry Lord BoNes but somehow it doesn't wrk. If you do it for me I'll rep you. The ability is DL ulti- Infernal and the summoned unit is also infernal. Elselike I may need to see it as GUI to make it myself.
 
Level 6
Joined
Sep 5, 2007
Messages
264
Sorry for the long reply time... I've been away on work.

Now, a couple of questions... Does the infernal take reduced damage, get half of it's health back? Does the caster of the infernal get anything?

Just a debug option here:
JASS:
call DisplayTextToPlayer(GetLocalPlayer(),0,0,R2S(damage))
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"|"+GetUnitName(target)+"|")
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"|"+GetUnitName(owner)+"|")
// The reason for the "|" is incase of a null unit... it prints "||" instead of nothing.
Let me know what these text lines respond with... :thumbs_up:
 
Level 22
Joined
Feb 4, 2005
Messages
3,971
You know, thank you for your time but I made it with vampiric aura of the infernal with selected targets in the data so that only the caster can gain life when the infernal steals life. It's not gonna be the life lost of the infernal to go to the caster, it is the life stolen by infernal is gained only by the caster. Just changed the nature of the ability I wanted to have, no triggers, no trouble.
 
Status
Not open for further replies.
Top