• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Linking 2 units (some kind of damage share)

Status
Not open for further replies.
Level 6
Joined
Feb 27, 2008
Messages
222
Well, i'm trying to make a spell which links the caster to another unit. Any damage the caster takes is transfered to the target unit.

Now, I think i know how to make part of the trigger. Conditions will determine what kind of unit has been damaged, in actions i create variables which depend on the player number, so they are MUI and probably MPI, and then heals the caster by the amount of damage taken, and damages the target of ability by the amount healed to the caster.

What i have problem is the event. I don't want the spell to damage only from normal attacks. And i can't find an event that suits the situation - there is "A unit is attacked", but what about spells?
There is also the "Life" Event, but i can't choose a unit, and it says i don't have any variables of that type.

So, how can i make such a spell? If it's JASS, then don't bother, i'd rather think of a new spell cause i don't know a thing about JASS.

Edit : I've been thinking of making it a spirit link spell, but i'm not sure how it works, so if anyone can explain it, then i might do something about it
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
So you want to isolate attack damage and only have the attack damage distributed to the "target unit". I think one of the only ways to isolate attack damage is by using an orb effect. When the unit takes damage, check to see if it has the buff associated with the orb effect.

Every single unit in the map would have to have this ability though. You're pretty much looking for a Damage Detection system. I'm sure there is at least one in GUI.

Pharaoh_ said:
There:
Link Damage.w3x

This doesn't isolate attack damage It also doesn't restore the caster's health, so instead of just the target unit taking damage they both take damage. Your code also won't give necessary gold/experience to the "killing" unit, since you just use "Unit - Set life".
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here you go.

You could still add some dummy buff to the units and create some special effects when damage is transferred. You can also apply/modify the damage modifier I have saved to the hashtable. I'm not using it currently to modify the amount of damage that is transferred.

Also you may need to think what you want to happen when the damage taken is greater than the health of the unit that is originally hit. It will die, you may need to instantly revive it. Also, what happens when the original unit tries to transfer more damage than what the linked unit has health?
 

Attachments

  • Damage_Link.w3x
    20.6 KB · Views: 65
Level 18
Joined
Jan 21, 2006
Messages
2,552
If you instantly revive the unit then the killing unit(s) will be given undeserved gold/experience.

If the damage dealt exceeds the unit's current life (which I will refer to as lethal damage, or damage that is intended to cause a fatality) then you're going to need to find a way of keeping the unit alive while not breaking any continuity in game-flow.

In this case, you're going to need to detect when a unit takes damage and the damage dealt exceeds the unit's current life points. Now, make 2 global integer variables. One of these variables is to reference the unit's current life points, while the other is to reference its maximum life points.

When a unit takes damage, the event reacts a split second before the damage is actually dealt, allowing us to manipulate the unit before it dies. With this privilege, we can change the units maximum life (and current life, too) to something that will allow him to live through the lethal damage. There are systems available on the internet that allow you to modify a unit's maximum life points because it is not one of the features of the "Unit - Set state" function.

Once you have stored the original life/max life points of the damaged unit, and granted him immunity to death, you'll have to run a timer that expires in 0 seconds. The point of this is to have the actions executed in a new thread (where the damage will have been dealt).

I forgot to mention that you'll need to store the unit itself as a variable (so that it is reference-able in the timer callback). Now that your unit has had the damage dealt to it you can reset its life-point values using the stored amounts. Once you have reset the unit's life the unit will have successfully evaded death without any damage.
 
Level 6
Joined
Feb 27, 2008
Messages
222
Here you go.

You could still add some dummy buff to the units and create some special effects when damage is transferred. You can also apply/modify the damage modifier I have saved to the hashtable. I'm not using it currently to modify the amount of damage that is transferred.

Also you may need to think what you want to happen when the damage taken is greater than the health of the unit that is originally hit. It will die, you may need to instantly revive it. Also, what happens when the original unit tries to transfer more damage than what the linked unit has health?

this looks better. Think i will use that.

And if the caster's hp is lower than the dmg , then the caster should die, while the victim can die from the damage.
 
Status
Not open for further replies.
Top