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

Trouble with Magic Raise

Status
Not open for further replies.
Level 6
Joined
Aug 5, 2017
Messages
251
I gave the Spell Breaker the Magic Raise ability, which allows the Spell Breaker to increase attack damage of friendly units by 20% and to reduce their defense by 3, at the cost of 160 hit points of the Spell Breaker. The caster will regain the hit points in 20 seconds, the same seconds the effect needs. The problem is that when the Spell Breaker has no health left, instead of dying, he turns into a spirit and then fades away. Is there a way to fix this? Code below:
  • The bad news
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Magic Raise
    • Actions
      • Set Spell_Breaker = (Random unit from (Units of type Spell Breaker))
      • Unit - Set life of Spell_Breaker to ((Life of Spell_Breaker) - 160.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Life of Spell_Breaker) - 160.00) Greater than or equal to 0.00
        • Then - Actions
          • Special Effect - Create a special effect attached to the overhead of Spell_Breaker using war3mapImported\RedSadEmoji.mdx
          • Wait 20.00 seconds
        • Else - Actions
          • Unit - Kill Spell_Breaker
      • Unit - Set life of Spell_Breaker to ((Life of Spell_Breaker) + 160.00)
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect attached to the origin of Spell_Breaker using Abilities\Spells\Human\DispelMagic\DispelMagicTarget.mdl
Variable Spell_Breaker = Unit
Guess who made the code?
That's right! I did! This is pretty good for my first try, when it comes to easy.
 
Level 13
Joined
Jul 15, 2007
Messages
763
This code looks... very... weird.

Let me understand this code:

  1. Spellbreaker "begins casting" Magic Raise
  2. Spell_Breaker = a random Spell Breaker on your map...
  3. IF Spell_Breaker has more than 160 HP,
    1. THEN make an effect on him and wait 20 secs
    2. ELSE kill him
  4. Give him his HP back (even if hes dead)
  5. Destroy the effect and make a new one

This code will only work (in a very broken way) if there is only ONE Spell Breaker in your map.

When you say he turns into a Spirit and then fades away, what do you mean? Is he a Hero?

If you have multiple Spell Breakers in your map, chances are your trigger wont be interacting with the proper spell breaker.
 
Level 6
Joined
Aug 5, 2017
Messages
251
I should have replaced Spell_Breaker with (Casting Unit), but even then, he also turns into a spirit and fades away.
I set Spell_Breaker = (Casting Unit)
And changed the former event option to:
A unit Finishes casting an ability.
Now it works, but the spirit issue is still there and the Spirit Breaker is no hero.
 
Last edited:
Status
Not open for further replies.
Top