• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Trigger] Ability with trigger error

Status
Not open for further replies.
Level 6
Joined
Nov 24, 2012
Messages
198
I make a ability with trigger like this:
  • Defend
    • Events
      • Unit - Footman 0000 <gen> Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Defend
    • Actions
      • Set DefendCaster = (Triggering unit)
      • Set DefendLife = (Life of DefendCaster)
      • Set DefendChance = (Random integer number between 1 and 5)
      • Trigger - Turn on Damage Taken <gen>
      • Wait 1.00 seconds
      • Trigger - Turn off Damage Taken <gen>
  • Damage Taken
    • Events
      • Unit - Footman 0000 <gen> Takes damage
    • Conditions
    • Actions
      • Set DefendSource = (Integer((Damage taken)))
      • Set DefendAttacker = (Damage source)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DefendChance Equal to 1
        • Then - Actions
          • Set DefendSource = (DefendSource - 15)
          • Unit - Cause DefendAttacker to damage DefendCaster, dealing (Real(DefendSource)) damage of attack type Normal and damage type Normal
          • Floating Text - Create floating text that reads ((String((DefendSource - 15))) + (Name of Defend )) above DefendCaster with Z offset 0.00, using font size 15.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Wait 1.00 seconds
          • Floating Text - Change the color of (Last created floating text) to (100.00%, 0.00%, 0.00%) with 50.00% transparency
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DefendChance Equal to 2
        • Then - Actions
          • Set DefendSource = (DefendSource - 20)
          • Unit - Cause DefendAttacker to damage DefendCaster, dealing (Real(DefendSource)) damage of attack type Normal and damage type Normal
          • Floating Text - Create floating text that reads ((String((DefendSource - 20))) + (Name of Defend )) above DefendCaster with Z offset 0.00, using font size 15.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Wait 1.00 seconds
          • Floating Text - Change the color of (Last created floating text) to (100.00%, 0.00%, 0.00%) with 50.00% transparency
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DefendChance Equal to 3
        • Then - Actions
          • Set DefendSource = (DefendSource - 1000000000)
          • Unit - Cause DefendAttacker to damage DefendCaster, dealing (Real(DefendSource)) damage of attack type Normal and damage type Normal
          • Floating Text - Create floating text that reads (Blocked + (Name of Defend )) above DefendCaster with Z offset 0.00, using font size 15.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Wait 1.00 seconds
          • Floating Text - Change the color of (Last created floating text) to (100.00%, 0.00%, 0.00%) with 50.00% transparency
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DefendChance Equal to 4
        • Then - Actions
          • Set DefendSource = (DefendSource - 25)
          • Unit - Cause DefendAttacker to damage DefendCaster, dealing (Real(DefendSource)) damage of attack type Normal and damage type Normal
          • Floating Text - Create floating text that reads ((String((DefendSource - 25))) + (Name of Defend )) above DefendCaster with Z offset 0.00, using font size 15.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Wait 1.00 seconds
          • Floating Text - Change the color of (Last created floating text) to (100.00%, 0.00%, 0.00%) with 50.00% transparency
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DefendChance Equal to 5
        • Then - Actions
          • Set DefendSource = (DefendSource - 10)
          • Unit - Cause DefendAttacker to damage DefendCaster, dealing (Real(DefendSource)) damage of attack type Normal and damage type Normal
          • Floating Text - Create floating text that reads ((String((DefendSource - 10))) + (Name of Defend )) above DefendCaster with Z offset 0.00, using font size 15.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Wait 1.00 seconds
          • Floating Text - Change the color of (Last created floating text) to (100.00%, 0.00%, 0.00%) with 50.00% transparency
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
but why if i cast the spell and enemy unit is attack to caster suddenly my Warcraft exit by itself can anyone know how to fix it??
 
Because you have a logic issue in your trigger, let me write it in pseudocode:

*when unit x casts defend, do for 5 seconds:
*if x takes damage do:
*cause damageSource to deal damage to x

This is causing an inifinte loop because when the defending unit takes damage, the trigger runs (and causes damge to it, running the trigger)

You can fix this by swapping DefendAttacker and DefendCaster in these lines:
  • Unit - Cause DefendAttacker to damage DefendCaster, dealing (Real(DefendSource)) damage of attack type Normal and damage type Normal
 
Status
Not open for further replies.
Top