• 🏆 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] Error message not working :S

Status
Not open for further replies.
Level 16
Joined
Jun 24, 2009
Messages
1,409
I'm using this simple system to generate error messages and to stop the units from casting the abilities at wrong locations or enemies.
Sometimes it works. Sometimes not. Whenever it tries to stop the unit, the unit restarts casting the spell if it's a local area one.
What's the problem here? :S

JASS:
function DebugError takes player ForPlayer, string msg returns nothing
    local sound error=CreateSoundFromLabel("InterfaceError",false,false,false,10,10)
    if (GetLocalPlayer() == ForPlayer) then
        if (msg!="") and (msg!=null) then
            call ClearTextMessages()
            call DisplayTimedTextToPlayer(ForPlayer, 0.85, 0., 2.00, "|cffffcc00"+msg+"|r")
        endif
        call StartSound(error)
    endif
    call KillSoundWhenDone(error)
    set error=null
endfunction
  • Debug Error
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Taste of Death
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Triggering unit)) Less than or equal to ((Max life of (Triggering unit)) x 0.11)
            • Then - Actions
              • Unit - Order (Triggering unit) to Stop
              • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "You're too weak.")
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Water Vortex
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at (Target point of ability being cast) of type Walkability is off) Equal to True
                • Then - Actions
                  • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "Invalid target.")
                  • Unit - Order (Triggering unit) to Stop
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Ability being cast) Equal to Steal
                      • (Ability being cast) Equal to Pickpocket
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Unit-type of (Target unit of ability being cast)) Equal to Footman
                    • Then - Actions
                    • Else - Actions
                      • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "What the hell do you want to steal from an animal?")
                      • Unit - Order (Triggering unit) to Stop
                      • Skip remaining actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Ability being cast) Equal to Pickpocket
                      • (Ability being cast) Equal to Throat Cut
                      • (Ability being cast) Equal to Assassinate
                      • (Ability being cast) Equal to Steal
                • Then - Actions
                  • Set TempLoc = (Position of (Triggering unit))
                  • Set TempLoc2 = (Position of (Target unit of ability being cast))
                  • Unit - Create 1 Dummy for Neutral Passive at TempLoc facing TempLoc2
                  • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
                  • Set TempReal = (Facing of (Last created unit))
                  • Set TempReal2 = (Facing of (Target unit of ability being cast))
                  • Custom script: call RemoveLocation (udg_TempLoc)
                  • Custom script: call RemoveLocation (udg_TempLoc2)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • And - All (Conditions) are true
                        • Conditions
                          • TempReal Greater than or equal to (TempReal2 - 50.00)
                          • TempReal Less than or equal to (TempReal2 + 50.00)
                    • Then - Actions
                    • Else - Actions
                      • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "You must behind your target!")
                      • Unit - Order (Triggering unit) to Stop
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Ability being cast) Equal to Material Realm
                    • Then - Actions
                      • Set TempLoc = (Position of (Triggering unit))
                      • Set TempGroup = (Units within 500.00 of TempLoc matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is Magic Immune) Equal to False) and (((Matching unit) is dead) Equal to True))))
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of units in TempGroup) Equal to 0
                        • Then - Actions
                          • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "There are no corpses nearby.")
                          • Unit - Order (Triggering unit) to Stop
                        • Else - Actions
                      • Custom script: call RemoveLocation (udg_TempLoc)
                      • Custom script: call DestroyGroup (udg_TempGroup)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Ability being cast) Equal to Spirit Dance
                        • Then - Actions
                          • Set TempLoc = (Position of (Triggering unit))
                          • Set TempLoc2 = (Position of (Target unit of ability being cast))
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Distance between TempLoc and TempLoc2) Less than or equal to 400.00
                            • Then - Actions
                              • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "Target is inside minimum range.")
                              • Unit - Order (Triggering unit) to Stop
                            • Else - Actions
                          • Custom script: call RemoveLocation (udg_TempLoc)
                          • Custom script: call RemoveLocation (udg_TempLoc2)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Ability being cast) Equal to Drown
                            • Then - Actions
                              • For each (Integer A) from 0 to DMax, do (Actions)
                                • Loop - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • DHas[(Integer A)] Equal to True
                                    • Then - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • (Target unit of ability being cast) Equal to DTarget[(Integer A)]
                                        • Then - Actions
                                          • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "This unit is already drowning.")
                                          • Unit - Order (Triggering unit) to Stop
                                        • Else - Actions
                                    • Else - Actions
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • Or - Any (Conditions) are true
                                    • Conditions
                                      • (Ability being cast) Equal to Ressurrection
                                      • (Ability being cast) Equal to Lesser Ressurrection
                                • Then - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Unit-type of (Target unit of ability being cast)) Not equal to Grave
                                    • Then - Actions
                                      • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "Must target a grave.")
                                      • Unit - Order (Triggering unit) to Stop
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • Or - Any (Conditions) are true
                                            • Conditions
                                              • ((Target unit of ability being cast) is in QRRevGroup) Equal to True
                                              • ((Target unit of ability being cast) is in ZLRRevGroup) Equal to True
                                        • Then - Actions
                                          • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "This unit is already ressurrecting.")
                                          • Unit - Order (Triggering unit) to Stop
                                        • Else - Actions
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Unit-type of (Target unit of ability being cast)) Equal to Grave
                                    • Then - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • Or - Any (Conditions) are true
                                            • Conditions
                                              • (Ability being cast) Equal to Ressurrection
                                              • (Ability being cast) Equal to Lesser Ressurrection
                                        • Then - Actions
                                        • Else - Actions
                                          • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "Only ressurrection can be cast on graves..")
                                          • Unit - Order (Triggering unit) to Stop
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • Or - Any (Conditions) are true
                                            • Conditions
                                              • (Ability being cast) Equal to Death Essence
                                              • (Ability being cast) Equal to Unholy Frenzy
                                        • Then - Actions
                                          • Set TempInt = (Player number of (Triggering player))
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • (NecroMinionGroup[TempInt] is empty) Equal to True
                                            • Then - Actions
                                              • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "You don't have minions alive.")
                                              • Unit - Order (Triggering unit) to Stop
                                            • Else - Actions
                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                • If - Conditions
                                                  • (Ability being cast) Equal to Death Essence
                                                • Then - Actions
                                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    • If - Conditions
                                                      • (Life of (Triggering unit)) Less than or equal to ((Max life of (Triggering unit)) x 0.20)
                                                    • Then - Actions
                                                      • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "You're too weak.")
                                                      • Unit - Order (Triggering unit) to Stop
                                                    • Else - Actions
                                                • Else - Actions
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • (Ability being cast) Equal to Raise Skeleton
                                            • Then - Actions
                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                • If - Conditions
                                                  • (Life of (Triggering unit)) Less than or equal to ((Max life of (Triggering unit)) x 0.10)
                                                • Then - Actions
                                                  • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "You're too weak.")
                                                  • Unit - Order (Triggering unit) to Stop
                                                • Else - Actions
                                            • Else - Actions
                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                • If - Conditions
                                                  • (Ability being cast) Equal to Soul Exchange
                                                • Then - Actions
                                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    • If - Conditions
                                                      • (Life of (Triggering unit)) Less than or equal to 99.00
                                                      • ((Target unit of ability being cast) belongs to an enemy of (Triggering player)) Equal to False
                                                    • Then - Actions
                                                      • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "You're too weak.")
                                                      • Unit - Order (Triggering unit) to Stop
                                                    • Else - Actions
                                                • Else - Actions
                                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    • If - Conditions
                                                      • (Ability being cast) Equal to Pentagram
                                                    • Then - Actions
                                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                        • If - Conditions
                                                          • (Life of (Triggering unit)) Less than or equal to ((Max life of (Triggering unit)) x 0.15)
                                                        • Then - Actions
                                                          • Custom script: call DebugError ( GetOwningPlayer(GetTriggerUnit()), "You're too weak.")
                                                          • Unit - Order (Triggering unit) to Stop
                                                        • Else - Actions
                                                    • Else - Actions
 
Level 16
Joined
Jun 24, 2009
Messages
1,409
So something like this?
  • Untitled Trigger 001
    • Events
      • Time - Every 0.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Group and do (Unit - Order (Picked unit) to Stop)
      • Trigger - Turn off (This trigger)
I just have to call the trigger and add the unit to the group?
 
Status
Not open for further replies.
Top