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

Why doesnt this make units attack move to, my units wont attack

Status
Not open for further replies.
Level 3
Joined
Mar 29, 2009
Messages
23
  • Events
  • Unit - Unit enters WalkRed2 <gen>
  • Condition
  • Owner of (Entering Unit) Equal to Player 9 (Gray) or Owner of (Entering Unit) Equal to Player 10 (Light Blue) or Owner of (Entering Unit) Equal to Player 12 (Brown)
  • Actions
  • Custom script: local unit u = GetEnteringUnit()
  • Set Temp_Point_TURNS = (Center of WalkRed3() <gen>)
  • If (All conditions are true) then do (Then Actions) else do (Else actions)
  • If - Conditions
  • Unit type of (Triggering Unit) Not Equal to Red Drake
  • Unit type of (Triggering Unit) Not Equal to Skeleton Archer
  • Unit type of (Triggering Unit) Not Equal to Harpy Scout
  • Then - Actions
  • Unit - Set the custom value of (Entering Unit) to 2
  • Unit - Order (Entering Unit) to Move To Temp_Point_TURNS
  • Else - Actions
  • Unit - Set the custom value of (Entering Unit) to 2
  • Unit - Order (Entering Unit) to Attack-Move to Temp_Point_TURNS
  • End If
  • Custom Script: call RemoveLocation(Temp_Point_TURNS)
  • Custom Script: set u = null
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
For me this works just fine:

  • Untitled Trigger 107
    • Events
      • Unit - A unit enters Region 016 <gen>
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
    • Actions
      • Set Temp_Loc_1 = (Center of Region 015 <gen>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Not equal to Footman
          • (Unit-type of (Triggering unit)) Not equal to Knight
        • Then - Actions
          • Unit - Order (Triggering unit) to Move To Temp_Loc_1
        • Else - Actions
          • Unit - Order (Triggering unit) to Attack-Move To Temp_Loc_1
      • Unit - Set the custom value of (Triggering unit) to 2
      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
 
Level 35
Joined
Feb 5, 2009
Messages
4,560
I'm thinking it's a leak with your conditions for what unit it is. When you say 'if - not equal to X' and 'if - not equal to Y', then if it's Y, it's not equal to X, and vice versa. Change those conditions to an 'and' condition with multiple entries and transfer them into it. Should work. Although I'm surprised that Maker's code works for him... very interesting....
 
Level 35
Joined
Feb 5, 2009
Messages
4,560
Well, the thing that surprises me is the way it's set out actually works. No offense to you Maker, but the if condition seems somewhat temperemental to me.

After doing Java for a bit, one thing I became proficient in was 'and' and 'or' commands. Initially, that should be an 'or' command judging from the way it's set out. That means if the triggering unit isn't a Footman or a Knight, it won't Attack Move. That means if a Knight enters, in theory, the Knight is not a footman and therefore the code shouldn't work.

However, if you had an 'and' command there, it would theoretically do something completely different. That is, if a Knight entered the region, it is not a Footman, but it is a Knight, and therefore it will skip the 'then' action and go straight to the 'else' action.

But seeing as how setting it out like that works for you, that therefore proves the folly of theoretical thinking. However, I'm just not sure if Ghostman had the same luck. Perhaps your code somehow counts that condition as an 'and' command, while Ghostman's counts his as an 'or' command? Maybe the extra unit in the condition statement makes the change? It's as little confusing atm :/
 
Level 14
Joined
Aug 31, 2009
Messages
775
By Maker's If Statement, it works perfectly fine in my opinion.

Should a knight be the entering unit then the conditions will be:
Conditions - ALL MUST BE TRUE
Unit Type is NOT a Knight - This Condition is FALSE
Unit Type is NOT a Footman - This Condition is TRUE

Final Result: The Overall Condition is FALSE - carry out the "Else" actions (Attack Move).
The same would happen in the case of a Footman entering.

Now, say if a Peasant enters, then the conditions would be:
Conditions - ALL MUST BE TRUE
Unit Type is NOT a Footman - This Condition is TRUE
Unit Type is NOT a Knight - This Condition is TRUE

Final Result: The Overall Condition is TRUE - carry out the "Then" actions (Move).


Both conditions must be true, so it is actually an AND link for the conditions, as both must return a TRUE in order to issue the Move command, otherwise it will issue an Attack move. The other alternative is to reverse the Else and Then actions and change the conditions to "(Unit Type of (Triggering Unit) equal to Footman) OR (Unit Type of (Triggering Unit) equal to Knight)".
 
Level 14
Joined
Aug 31, 2009
Messages
775
No need to use Local Variables for things like Triggering Unit.

For general use, just clear up Groups, Points, Special effects and Floating Text. Those are the primary sources of leaks, and as long as you remove them, you're generally OK. There are other very minor sources of leaks such as Player Groups, but it's rare that you'd use them enough for it to be a problem anyway.
 
Status
Not open for further replies.
Top