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

How can I detect if a unit collides with a terrain or trees?

Status
Not open for further replies.
Level 2
Joined
Apr 24, 2019
Messages
15
So basically, I wanted to create a simple dash spell but I want the caster to pass through units but not through trees and cliffs.

Is there a way to do that in GUI?
 
Level 24
Joined
Feb 9, 2009
Messages
1,787
I check pathability in my resource Teeth so that each projectile doesn't continue if it collides with trees, ravines, cliffs, or destructibles.

upload_2020-11-14_20-26-52.png

And for destructibles
upload_2020-11-14_20-27-16.png
 
Level 2
Joined
Apr 24, 2019
Messages
15
I check pathability in my resource Teeth so that each projectile doesn't continue if it collides with trees, ravines, cliffs, or destructibles.

View attachment 368146
And for destructibles
View attachment 368147

Thanks, I got it now.

One more thing, what should I do once the caster collides with a terrain or destructable? I'm fairly new to making things in MUI and I've only done those generic MUI dash where I just turn the collision off and on but this one is kind of confusing me Should I just de-index right away?
 
Level 24
Joined
Feb 9, 2009
Messages
1,787
@Nastyan >One more thing, what should I do once the caster collides with a terrain or destructible?
Limit is your imagination, make some fiery explosion or polymorph nearby enemies.

>I'm fairly new to making things in MUI and I've only done those generic MUI dash where I just turn the collision off and on but this one is kind of confusing me Should I just de-index right away?
I do not understand, perhaps posting your trigger would be more direct.
 
Level 2
Joined
Apr 24, 2019
Messages
15
@Nastyan
I do not understand, perhaps posting your trigger would be more direct.

Sorry about that, and I apologize if I took long to respond, I've had a headache The whole day yesterday and I had to rest (Its 5AM here)

SO anyways here are the triggers.

The Caster dashes to the target point, phasing through units only but instantly stops when colliding with destructables and cliffs or ravines.

Init
  • Bruiser Init
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set BruiserW_index = 0
      • Set BruiserW_dash_speed = 40.00
      • Set BruiserW_dash_collision = 32.00
Cast
  • BruiserW Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Dash
    • Actions
      • Set BruiserW_index = (BruiserW_index + 1)
      • Set BruiserW_dash_caster[BruiserW_index] = (Triggering unit)
      • Set BruiserW_dash_targetpoint[BruiserW_index] = (Target point of ability being cast)
      • Set BruiserW_dash_casterpos[BruiserW_index] = (Position of BruiserW_dash_caster[BruiserW_index])
      • Set BruiserW_dash_angle[BruiserW_index] = (Angle from BruiserW_dash_casterpos[BruiserW_index] to BruiserW_dash_targetpoint[BruiserW_index])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BruiserW_index Equal to 1
        • Then - Actions
          • Custom script: call EnableTrigger(gg_trg_BruiserW_Travel)
        • Else - Actions

I'm not really good at this but here's the looping.

  • BruiserW Travel
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer BruiserW_loopteger) from 1 to BruiserW_index, 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
                  • (BruiserW_dash_caster[BruiserW_loopteger] is dead) Equal to True
            • Then - Actions
              • Set BruiserW_dash_caster[BruiserW_loopteger] = BruiserW_dash_caster[BruiserW_index]
              • Set BruiserW_index = (BruiserW_index - 1)
              • Set BruiserW_loopteger = (BruiserW_loopteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • BruiserW_index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • -------- ------------------------------------------------------ --------
              • -------- Dashing through a structure is allowed --------
              • -------- ------------------------------------------------------ --------
              • Set BruiserW_dash_casterpos[BruiserW_loopteger] = (Position of BruiserW_dash_caster[BruiserW_loopteger])
              • Set BruiserW_dash_moveloop[BruiserW_loopteger] = (BruiserW_dash_casterpos[BruiserW_loopteger] offset by BruiserW_dash_speed towards BruiserW_dash_angle[BruiserW_loopteger] degrees)
              • Unit - Move BruiserW_dash_caster[BruiserW_loopteger] instantly to BruiserW_dash_moveloop[BruiserW_loopteger], facing BruiserW_dash_angle[BruiserW_loopteger] degrees
              • Set BruiserW_dash_Distance[BruiserW_loopteger] = (Distance between BruiserW_dash_casterpos[BruiserW_loopteger] and BruiserW_dash_targetpoint[BruiserW_loopteger])
              • Destructible - Pick every destructible within BruiserW_dash_collision of BruiserW_dash_moveloop[BruiserW_loopteger] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Last created destructible) is invulnerable) Equal to True
                    • Then - Actions
                      • Set BruiserW_dash_caster[BruiserW_loopteger] = BruiserW_dash_caster[BruiserW_index]
                      • Set BruiserW_index = (BruiserW_index - 1)
                      • Set BruiserW_loopteger = (BruiserW_loopteger - 1)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • BruiserW_index Equal to 0
                        • Then - Actions
                          • Trigger - Turn off (This trigger)
                        • 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
                      • BruiserW_dash_Distance[BruiserW_loopteger] Less than or equal to 0.00
                      • (Terrain pathing at BruiserW_dash_moveloop[BruiserW_loopteger] of type Walkability is off) Equal to True
                • Then - Actions
                  • Set BruiserW_dash_caster[BruiserW_loopteger] = BruiserW_dash_caster[BruiserW_index]
                  • Set BruiserW_index = (BruiserW_index - 1)
                  • Set BruiserW_loopteger = (BruiserW_loopteger - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • BruiserW_index Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
              • Custom script: call RemoveLocation(udg_BruiserW_dash_casterpos[udg_BruiserW_loopteger])
              • Custom script: call RemoveLocation(udg_BruiserW_dash_moveloop[udg_BruiserW_loopteger])
 
Level 24
Joined
Feb 9, 2009
Messages
1,787
@Nastyan
>Sorry about that, and I apologize if I took long to respond, I've had a headache The whole day yesterday and I had to rest (Its 5AM here)
How dare you have a life you ungrateful wretch, I demand instant responses from my vietnamese basket weaving forum peers.

In your periodic try and make the conditions for a "dead-end", i.e. when the spell is going to fail and de-index, try to use only instance.
If you must use an additional "if then" block then use a variable that can act as a flag for de-indexing, in my Teeth resource I do this with the variable called TeNe_distance, if the projectile hits a tree I set the distance to 0.00 instead of adding another de-indexing block, because when the loop fires a second time the de-index condition will catch that distance is 0.00 and know to de-index that instance.

The result allows your trigger to be readable, not only to others but yourself, and that leads to a cleaner thought process.
  • Example
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
  • For each (Integer Your_Loop) from 1 to Your_Index, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Your_Unit_Variable is dead) Equal to False
          • Your_distance_Variable Greater than 0.00
          • (Terrain pathing at Your_Point_Variable of type Walkability is off) Equal to False
        • Then - Actions
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- Your actions --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • Destructible - Pick every destructible within Your_Collision_Variable of Your_Point_Variable and do (Actions)
            • Loop - Actions
              • Set VariableSet Your_distance_Variable = 0.00
        • Else - Actions
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- De-Index block --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------

Also if you haven't, check out this tutorial.
 
Level 2
Joined
Apr 24, 2019
Messages
15
In your periodic try and make the conditions for a "dead-end", i.e. when the spell is going to fail and de-index, try to use only instance.
If you must use an additional "if then" block then use a variable that can act as a flag for de-indexing, in my Teeth resource I do this with the variable called TeNe_distance, if the projectile hits a tree I set the distance to 0.00 instead of adding another de-indexing block, because when the loop fires a second time the de-index condition will catch that distance is 0.00 and know to de-index that instance.

The result allows your trigger to be readable, not only to others but yourself, and that leads to a cleaner thought process.
  • Example
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
  • For each (Integer Your_Loop) from 1 to Your_Index, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Your_Unit_Variable is dead) Equal to False
          • Your_distance_Variable Greater than 0.00
          • (Terrain pathing at Your_Point_Variable of type Walkability is off) Equal to False
        • Then - Actions
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- Your actions --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • Destructible - Pick every destructible within Your_Collision_Variable of Your_Point_Variable and do (Actions)
            • Loop - Actions
              • Set VariableSet Your_distance_Variable = 0.00
        • Else - Actions
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------
          • -------- De-Index block --------
          • -------- -- --------
          • -------- -- --------
          • -------- -- --------

Also if you haven't, check out this tutorial.

Thank you, it does look cleaner and more readable, i think I get it now and also i will be checking the link you posted.

Examination week is nearly over I would resume what I was doing after the exams are finally over. Ill be back here if things doesnt really right thanks
 
Status
Not open for further replies.
Top