• 🏆 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] Walkability Check, Spell not working

Status
Not open for further replies.
Level 3
Joined
Apr 4, 2020
Messages
31
Hello,

im currently working on a spell that works like the forcestaff item in dota including a dmg part.
If my hero has another spell learned (Charged) he is supposed to dmg every unit he passes.
Since i dont want the player to use it over cliffs etc, im using @PurgeandFire Walkability Check.
Without the check it works fine but if i'm turning it on, i'm not casting the spell anymore.

This is the config:

  • Updraft
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Updraft (Force)
    • Actions
      • Set VariableSet Updraft_User = (Triggering unit)
      • Animation - Change (Triggering unit) turn speed to 0.01
      • Unit - Turn collision for (Triggering unit) Off.
      • Set VariableSet Updraft_Distance = 750.00
      • Trigger - Turn on Updraft Loop <gen>
And this is the loop
  • Updraft Loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Trigger - Run Check Walkability <gen> (ignoring conditions)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • Updraft_Distance Less than or equal to 0.00
        • Then - Actions
          • Animation - Change Updraft_User turn speed to (Default turn speed of Updraft_User)
          • Unit - Turn collision for Updraft_User On.
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Charged for Updraft_User) Greater than or equal to 1
            • Then - Actions
              • Set VariableSet Updraft_Pos = (Position of Updraft_User)
              • Set VariableSet Updraft_Pos_Off = (Updraft_Pos offset by 50.00 towards (Facing of Updraft_User) degrees.)
              • Destructible - Pick every destructible within 150.00 of Updraft_Pos and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Destructible-type of (Picked destructible)) Equal to Eschental, Baumwand
                          • (Destructible-type of (Picked destructible)) Equal to Eschental, Baldachinbaum
                    • Then - Actions
                      • Destructible - Kill (Picked destructible)
                    • Else - Actions
              • Unit - Move Updraft_User instantly to Updraft_Pos_Off
              • Special Effect - Create a special effect attached to the origin of Updraft_User using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set VariableSet Updraft_Distance = (Updraft_Distance - 50.00)
              • Unit - Create 1 Dummy for (Owner of Updraft_User) at (Position of Updraft_User) facing Default building facing degrees
              • Unit - Add Updraft (Damage) to (Last created unit)
              • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap.
              • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
              • Custom script: call RemoveLocation(udg_Updraft_Pos)
              • Custom script: call RemoveLocation(udg_Updraft_Pos_Off)
            • Else - Actions
              • Set VariableSet Updraft_Pos = (Position of Updraft_User)
              • Set VariableSet Updraft_Pos_Off = (Updraft_Pos offset by 75.00 towards (Facing of Updraft_User) degrees.)
              • Destructible - Pick every destructible within 150.00 of Updraft_Pos and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Destructible-type of (Picked destructible)) Equal to Eschental, Baumwand
                          • (Destructible-type of (Picked destructible)) Equal to Eschental, Baldachinbaum
                    • Then - Actions
                      • Destructible - Kill (Picked destructible)
                    • Else - Actions
              • Unit - Move Updraft_User instantly to Updraft_Pos_Off
              • Special Effect - Destroy (Last created special effect)
              • Special Effect - Create a special effect attached to the origin of Updraft_User using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
              • Set VariableSet Updraft_Distance = (Updraft_Distance - 75.00)
              • Custom script: call RemoveLocation(udg_Updraft_Pos_Off)
              • Custom script: call RemoveLocation(udg_Updraft_Pos)
And this is the walkabilty check which i just copied Check Walkability

Since im still unexperienced with custom spell making i'm using existing spells that are similar to what i'm planning and changing/adding everything as needed.
Now here is the weird part. I tested it on a map with just the walkability check and my spell. The check failed but i could use the spell (Meaning i could use it over cliffs and even outside the map boundaries)
On my original map, i can't use the spell at all. Even if nothing blocks me or im in the open terrain.
I added the spell including the check in the attached map.
What am i missing here or doing wrong?
 

Attachments

  • Updraft_Spell.w3m
    51.5 KB · Views: 14

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Alright, so I modified your trigger to be a bit more optimized and fixed the bugs.

1) You weren't using the Check Walkability system properly. To use the system, you set CP_Point = where you want to check the pathing, then you run the system. The system then determines if that Point is/isn't pathable, and sets the Boolean
CP_PointIsWalkable to True/False depending on this. You can then check the value of this Boolean, if CP_PointIsWalkable is equal to True, the point is pathable, if it's False, the point is NOT pathable.

2) I'm no longer using Move Updraft_User instantly to Updraft_Pos_Off to move our Hero, instead I'm using this custom script:
  • Custom script: call SetUnitX(udg_Updraft_User, GetLocationX(udg_CP_Point))
  • Custom script: call SetUnitY(udg_Updraft_User, GetLocationY(udg_CP_Point))
This ignores pathing checks and basically gives your unit "No Collision". Plus it's faster and more efficient than using Move Unit Instantly.
Notice that I'm referencing CP_Point as well, this is because we need to set CP_Point to where we plan on moving our unit anyway, so it already worked like Updraft_Pos_Off. I replaced Updraft_Pos_Off with CP_Point throughout the trigger.

3) If Holy Light is leveled, I create our Thunderclap Dummy when we first cast the spell. We will re-use this Dummy for the duration of the spell. This is a lot more efficient than creating a new Dummy over and over again.
Because of this you can now increase the Cooldown of your Dummy ability to prevent it from casting Thunderclap every 0.03 seconds. The timing might not sync up perfectly so you may have to mess around with the Cooldown value to get it just right.

4) I use this new function: Custom script: call BlzPauseUnitEx(udg_Updraft_User, true). This acts as a triggered Stun, preventing us from controlling our unit during the Updraft BUT not Pausing it.

5) I made other minor optimizations here and there, you'll notice a new variable Updraft_Angle which will make your unit always move in the correct direction, as well as being more efficient than checking the unit's current facing angle over and over again.

  • Updraft
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Updraft (Force)
    • Actions
      • Set VariableSet Updraft_User = (Triggering unit)
      • Set VariableSet Updraft_Distance = 750.00
      • Set VariableSet Updraft_Pos = (Position of Updraft_User)
      • Set VariableSet Updraft_Pos2 = (Target point of ability being cast)
      • Set VariableSet Updraft_Angle = (Angle from Updraft_Pos to Updraft_Pos2)
      • -------- --------
      • -------- Create our Updraft Dummy (Holy Light) --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Holy Light for Updraft_User) Greater than 0
        • Then - Actions
          • Unit - Create 1 Dummy for (Triggering player) at Updraft_Pos facing Default building facing degrees
          • Unit - Add Updraft (Damage) to (Last created unit)
          • Set VariableSet Updraft_Dummy = (Last created unit)
        • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation(udg_Updraft_Pos)
      • Custom script: call RemoveLocation(udg_Updraft_Pos2)
      • -------- --------
      • Trigger - Turn on Updraft Loop <gen>
      • Custom script: call BlzPauseUnitEx(udg_Updraft_User, true)
  • Updraft Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • Updraft_Distance Less than or equal to 0.00
              • (Updraft_User is alive) Equal to False
              • (Updraft_User is hidden) Equal to True
        • Then - Actions
          • Unit - Remove Updraft_Dummy from the game
          • Custom script: call BlzPauseUnitEx(udg_Updraft_User, false)
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Holy Light for Updraft_User) Equal to 0
            • Then - Actions
              • -------- Default Updraft --------
              • Set VariableSet Updraft_Pos = (Position of Updraft_User)
              • Set VariableSet CP_Point = (Updraft_Pos offset by 50.00 towards Updraft_Angle degrees.)
              • -------- --------
              • -------- Check if the Point you're about to move to is Walkable (CP_Point) --------
              • Trigger - Run Check Walkability <gen> (ignoring conditions)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CP_PointIsWalkable Equal to False
                • Then - Actions
                  • Unit - Remove Updraft_Dummy from the game
                  • Custom script: call BlzPauseUnitEx(udg_Updraft_User, false)
                  • Custom script: call RemoveLocation(udg_Updraft_Pos)
                  • Custom script: call RemoveLocation(udg_CP_Point)
                  • Trigger - Turn off (This trigger)
                • Else - Actions
                  • Destructible - Pick every destructible within 150.00 of Updraft_Pos and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
                        • Then - Actions
                          • Destructible - Kill (Picked destructible)
                        • Else - Actions
                  • -------- --------
                  • -------- Move Unit --------
                  • Set VariableSet Updraft_Distance = (Updraft_Distance - 50.00)
                  • Custom script: call SetUnitX(udg_Updraft_User, GetLocationX(udg_CP_Point))
                  • Custom script: call SetUnitY(udg_Updraft_User, GetLocationY(udg_CP_Point))
                  • -------- --------
                  • Special Effect - Destroy (Last created special effect)
                  • Special Effect - Create a special effect attached to the origin of Updraft_User using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
                  • -------- --------
                  • Custom script: call RemoveLocation(udg_CP_Point)
                  • Custom script: call RemoveLocation(udg_Updraft_Pos)
            • Else - Actions
              • -------- Holy Light Bonus --------
              • Set VariableSet Updraft_Pos = (Position of Updraft_User)
              • Set VariableSet CP_Point = (Updraft_Pos offset by 50.00 towards Updraft_Angle degrees.)
              • -------- --------
              • -------- Check if the Point you're about to move to is Walkable (CP_Point) --------
              • Trigger - Run Check Walkability <gen> (ignoring conditions)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CP_PointIsWalkable Equal to False
                • Then - Actions
                  • Unit - Remove Updraft_Dummy from the game
                  • Custom script: call BlzPauseUnitEx(udg_Updraft_User, false)
                  • Custom script: call RemoveLocation(udg_Updraft_Pos)
                  • Custom script: call RemoveLocation(udg_CP_Point)
                  • Trigger - Turn off (This trigger)
                • Else - Actions
                  • Destructible - Pick every destructible within 150.00 of Updraft_Pos and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
                        • Then - Actions
                          • Destructible - Kill (Picked destructible)
                        • Else - Actions
                  • -------- --------
                  • -------- Move Unit --------
                  • Set VariableSet Updraft_Distance = (Updraft_Distance - 50.00)
                  • Custom script: call SetUnitX(udg_Updraft_User, GetLocationX(udg_CP_Point))
                  • Custom script: call SetUnitY(udg_Updraft_User, GetLocationY(udg_CP_Point))
                  • -------- --------
                  • -------- Move Dummy / Cast Dummy Spell --> It's okay to use the normal Move Unit Instantly function for the Dummy --------
                  • Unit - Move Updraft_Dummy instantly to CP_Point
                  • Unit - Order Updraft_Dummy to Human Mountain King - Thunder Clap.
                  • -------- --------
                  • Special Effect - Create a special effect attached to the origin of Updraft_User using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • -------- --------
                  • Custom script: call RemoveLocation(udg_CP_Point)
                  • Custom script: call RemoveLocation(udg_Updraft_Pos)
 

Attachments

  • Updraft_Spell Uncle 1.w3m
    52.4 KB · Views: 13
Last edited:
Level 3
Joined
Apr 4, 2020
Messages
31
Wow thank you so much! Thats a huge improvement to what i did. Yeah spawning serveral dummies sometimes made it not cast at the right point and looking pretty messy overall.
Thanks for taking the time for not only improving it but also explaining what you improved and how. +rep
 
Level 3
Joined
Apr 4, 2020
Messages
31
3) If Holy Light is leveled, I create our Thunderclap Dummy when we first cast the spell. We will re-use this Dummy for the duration of the spell. This is a lot more efficient than creating a new Dummy over and over again.
Because of this you can now increase the Cooldown of your Dummy ability to prevent it from casting Thunderclap every 0.03 seconds. The timing might not sync up perfectly so you may have to mess around with the Cooldown value to get it just right.
Is there anything you can do like completely wrong by copy pasting? I mean i obv. changed the abilities in my map to match aswell as the dummy but i cant get the dummy effect to work. Do any of your custom scripts require sth i could have possibly missed?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
I edited the Dummy and the Thunderclap ability, maybe you forgot to adjust those.

And the biggest issues when copy n pasting triggers is that the ability id's and other Object Editor data can be different between maps. What was Updraft in one map could be some other custom ability in the other map.

I'm sure it's something small that you overlooked.
 
Level 3
Joined
Apr 4, 2020
Messages
31
Yeah i failed with the anim backswing of my dummy. Just found out because i was using a real unit and saw his attempt to cast the ability but he was too slow. All is good and well now =)
 
Status
Not open for further replies.
Top