• 🏆 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!

[Trigger] How can I make this spell do the kill go to the caster?

Status
Not open for further replies.
Level 14
Joined
Jul 19, 2007
Messages
772
Hi there. I have a problem with a sleep spell which should cause an enemy unit to lose the level of the spell % it's maximum helath but the problem is that the kill does not go the the caster if the enemy unit dies of it. Is there any way to do it? Here is the triggers for the spell.

  • Sleep
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Sleep (Grima)
    • Actions
      • Hashtable - Save ((Level of Sleep (Grima) for (Casting unit)) x 5) as 0 of (Key (Target unit of ability being cast)) in Sleep_hashtable
      • Unit Group - Add (Target unit of ability being cast) to Sleeping_units
      • Set Sleep_damage = (((Level of (Ability being cast) for (Triggering unit)) x (Integer((Max life of (Target unit of ability being cast))))) / 100)
      • Set Sleep_caster = (Triggering unit)
  • Sleep Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Sleeping_units and do (Actions)
        • Loop - Actions
          • Set Sleep_time = (Load 0 of (Key (Picked unit)) from Sleep_hashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Sleep_time Greater than 0
            • Then - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (Real(Sleep_damage)))
              • Hashtable - Save (Sleep_time - 1) as 0 of (Key (Picked unit)) in Sleep_hashtable
            • Else - Actions
              • Unit Group - Remove (Picked unit) from Sleeping_units
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Sleep_hashtable
              • Unit - Cause Sleep_caster to damage (Picked unit), dealing 0.01 damage of attack type Spells and damage type Normal
 
Level 7
Joined
Nov 4, 2006
Messages
153
  • Unit - Cause Sleep_caster to damage (Picked unit), dealing 0.01 damage of attack type Spells and damage type Normal
Can't you do the same in place of your Set unit life function, just replace the .01 with Sleep_damage?

You can also do:
  • If - Conditions
    • Sleep_time Greater than 0
  • Then - Actions
    • If - Conditions
      • (Life of (Picked unit)) Greater than Sleep_damage
    • Then - Actions
      • Set Unit life to...
    • Else - Actions
      • Unit - Cause Sleep_caster to damage (Picked unit), dealing (Sleep_damage) damage of attack type Spells and damage type Normal
  • Else - Actions
I also suggest you strore your damage and caster into the hashtable. Else, if some other unit owned by someone else casts the same spell, the damage will change to the level of the ability for that unit and that unit will be the one to get credit for anytime the spell kills a unit.
 
Level 14
Joined
Jul 19, 2007
Messages
772
  • Unit - Cause Sleep_caster to damage (Picked unit), dealing 0.01 damage of attack type Spells and damage type Normal
Can't you do the same in place of your Set unit life function, just replace the .01 with Sleep_damage?

You can also do:
  • If - Conditions
    • Sleep_time Greater than 0
  • Then - Actions
    • If - Conditions
      • (Life of (Picked unit)) Greater than Sleep_damage
    • Then - Actions
      • Set Unit life to...
    • Else - Actions
      • Unit - Cause Sleep_caster to damage (Picked unit), dealing (Sleep_damage) damage of attack type Spells and damage type Normal
  • Else - Actions
I also suggest you strore your damage and caster into the hashtable. Else, if some other unit owned by someone else casts the same spell, the damage will change to the level of the ability for that unit and that unit will be the one to get credit for anytime the spell kills a unit.
Well could u please fix this to me? I really suck with triggering. There also one more problem with this spell. It still makes the target lose it's hit point a period after the sleep buff is gone :/
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Save Sleep_Damage as (Key damage) for (Target unit of ability being cast) in Sleep_hashtable
  • Save (Triggering unit) as (Key caster) for (Target unit of ability being cast) in Sleep_hashtable
When you want to deal damage, then load that "damage" from the hashtable. Also load "caster".

I use String ID's rather than Handle ID's for saving things. Like "Save *something* as (Key damage)... rather than "Save *something* as 0 ...
 
Status
Not open for further replies.
Top