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

Problem with my Spell

Status
Not open for further replies.
Level 7
Joined
Jul 20, 2009
Messages
295
As said in the Title, I am having a problem with my spell.
My spell is about:
-When someone casts "StoneSkin" he receives 0 damage what so ever until after 30 seconds or the sheild has been destroyed as it has a life of, 40 x Lvl of StoneSkin Spell.

My problem is:
-Everything works fine, except that when the caster has a full Life and casts "StoneSkin", he takes damage until the caster's Life is less than 100%, then the system would work fine. I do not want this to happen, I want the spell to absorb all damages even if the caster's life is at 100%. I also tried to check and see if it's only for the first hit that spell does not get to work, by letting the unit's Life gets to 100% when I press Esc... still the same, when at 100% Life of the unit the spell does not work correctly.

Here are the Triggers:
  • StoneSkin Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to StoneSkin Spell <gen> the event (Unit - (Picked unit) Takes damage)
  • StoneSskin Setup2
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to StoneSkin Spell <gen> the event (Unit - (Triggering unit) Takes damage)
  • StoneSkinStartup
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to StoneSkin (Hero)
    • Actions
      • Set StoneSkin[(Player number of (Owner of (Triggering unit)))] = (40 x (Level of StoneSkin (Hero) for (Triggering unit)))
  • StoneSkin Spell
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacked unit) has buff StoneSkin (Hero)) Equal to True
        • Then - Actions
          • Set Dmg_Array = (Dmg_Array + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StoneSkin[(Player number of (Owner of (Attacked unit)))] Greater than or equal to (Integer((Damage taken)))
            • Then - Actions
              • Set StoneSkin[(Player number of (Owner of (Attacked unit)))] = (StoneSkin[(Player number of (Owner of (Attacked unit)))] - (Integer((Damage taken))))
              • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + (Damage taken))
              • Floating Text - Create floating text that reads 0 at ((Position of (Attacked unit)) offset by 0.00 towards (Real(Dmg_Position[Dmg_Array])) degrees) with Z offset 0.00, using font size 8.00, color (100.00%, 100.00%, 0.00%), and 25.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 50.00 towards (Real(Dmg_Position[Dmg_Array])) degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
            • Else - Actions
              • Unit - Remove StoneSkin (Hero) buff from (Attacked unit)
              • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + (Real(StoneSkin[(Player number of (Owner of (Attacked unit)))])))
              • Floating Text - Create floating text that reads (String(((Integer((Damage taken))) - StoneSkin[(Player number of (Owner of (Attacked unit)))]))) at ((Position of (Attacked unit)) offset by 0.00 towards (Real(Dmg_Position[Dmg_Array])) degrees) with Z offset 0.00, using font size 8.00, color (100.00%, 100.00%, 0.00%), and 25.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 50.00 towards (Real(Dmg_Position[Dmg_Array])) degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
              • Set StoneSkin[(Player number of (Owner of (Attacked unit)))] = 0
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Dmg_Array Greater than or equal to 4
            • Then - Actions
              • Set Dmg_Array = 0
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Attacked unit) has buff StoneSkin (Hero)) Equal to False
            • Then - Actions
              • Set Dmg_Array = (Dmg_Array + 1)
              • Floating Text - Create floating text that reads (String((Integer((Damage taken))))) at ((Position of (Attacked unit)) offset by 0.00 towards (Real(Dmg_Position[Dmg_Array])) degrees) with Z offset 0.00, using font size 8.00, color (100.00%, 100.00%, 0.00%), and 25.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 50.00 towards (Real(Dmg_Position[Dmg_Array])) degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Dmg_Array Greater than or equal to 4
                • Then - Actions
                  • Set Dmg_Array = 0
                • Else - Actions
            • Else - Actions
Thats all. :p
+Rep for the helper/fixer.
 
Last edited:
Level 10
Joined
Oct 31, 2009
Messages
352
I am still looking through your triggers but a few things:

  • StoneSkin Setup
  • Events
  • Time - Elapsed game time is 0.01 seconds
  • Conditions
  • Actions
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
  • Loop - Actions
  • Trigger - Add to StoneSkin Spell <gen> the event (Unit - (Picked unit) Takes damage)
You leaking a unit group here



  • If - Conditions
  • ((Attacked unit) has buff StoneSkin (Hero)) Equal to False
Since this is the negative of the first condition it is unnecessary to have it.


As for your actual problem, what spell are you basing this off?
 
Yes, it's because the damage still overrides the health regeneration. To do what you want, you will need a dummy unit with an expiration timer of 0.01. You will save the caster to the dummy via hashtables and the dummy to the owner of the unit (As far as I can see it is MPI). You have made errors though. Attacking unit and Attacked unit respond to the "Unit - A unit is attacked event", not "Unit - Unit takes damage" event. To refer to the respective units, Attacking unit is Damage Source and Attacked unit is Triggering unit. I have made a similar spell as a request. Look how it works with hashtables. It restores the life normally, even if it's full. I will, however, make this the MPI way you want
  • Trigger0
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Hashtable - Create a hashtable
    • Set Hashtable = (Last created hashtable)
  • Trigger
  • Actions
    • If - Conditions
      • ((Triggering unit) has buff StoneSkin (Hero)) Equal to True
    • Then - Actions
      • Set Dmg_Array = (Dmg_Array + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • StoneSkin[(Player number of (Owner of (Triggering unit)))] Greater than or equal to (Integer((Damage taken)))
        • Then - Actions
          • Set Point1 = (Position of (Triggering unit))
          • Unit - Create 1 dummy for (Owner of (Triggering unit)) at Point1 facing default building degrees
          • Hashtable - Save Handle of (Triggering unit) as 0 of (Key(Last created unit)) in Hashtable //Hashtable - Save Unit
          • Unit - Add a 0.01 Generic expiration timer to (Last created unit)
          • Hashtable - Save (Damage taken) as 1 of (Key(Last created unit)) in Hashtable //Hashtable - Save Real
          • Set StoneSkin[(Player number of (Owner of (Triggering unit)))] = (StoneSkin[(Player number of (Owner of (Triggering unit)))] - (Integer((Damage taken))))
          • Floating Text - Create floating text above (Triggering unit) that reads 0 offset by 0.00 towards (Real(Dmg_Position[Dmg_Array])) degrees) with Z offset 0.00, using font size 8.00, color (100.00%, 100.00%, 0.00%), and 25.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 50.00 towards (Real(Dmg_Position[Dmg_Array])) degrees
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
          • Custom script: call RemoveLocation (udg_Point1)
  • Trigger
  • Events
    • Unit - A unit dies
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to Dummy
  • Actions
    • Set Real1 = (Load 1 of (Key(Triggering unit)) in Hashtable) //Real variable
    • Set Unit1 = (Load 0 of (Key(Triggering unit)) in Hashtable) //Unit variable
    • Unit - Set life of Unit1 to ((Life of Unit1) + Real1)
    • Hashtable - Clear all child hashtables of (Key(Triggering unit)) in Hashtable

References:
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/
• (The spell I made): http://www.hiveworkshop.com/forums/world-editor-help-zone-98/damage-absorb-gui-163494/#post1536790
 
Level 7
Joined
Jul 20, 2009
Messages
295
Is it okay if I create the dummy at the position of the triggering unit instead of making a variable, create the dummy at that variable point and then removing the variable?

+Rep for Pharaoh's help and for N1ghthawk for poiting out a leak and an uneeded function. ^^
 
Status
Not open for further replies.
Top