• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Units not attack-moving to location

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2011
Messages
527
so, i have a trigger that sets off a timer and runs triggers (set to an array variable) that spawns units at random intervals and another trigger that makes them attack move either a player-owned building or a town (1/5 chance of happening).

  • wave timer
    • Events
      • Time - t expires
    • Conditions
    • Actions
      • Set r = (Random real number between 45.00 and 55.00)
      • Countdown Timer - Start t as a One-shot timer that will expire in r seconds
      • Set currentwave = (currentwave + 1)
      • Trigger - Run wavetrigger[currentwave] (ignoring conditions)
      • Trigger - Run wave attack <gen> (ignoring conditions)
however, when the attack trigger is run, it doesn't work most of the time. randomly it works, though.

  • wave attack
    • Events
    • Conditions
    • Actions
      • Set g[1] = (Units in dragonspawn <gen>)
      • Set i = (Random integer number between 1 and 5)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Less than or equal to 4
        • Then - Actions
          • Set i = (Random integer number between 1 and maxplayers)
          • Set g[2] = (Units owned by (Player(i)) matching (((Matching unit) is A structure) Equal to True))
          • Set attacktarget = (Random unit from g[2])
          • Set attack[0] = (Position of attacktarget)
          • Unit Group - Order g[1] to Attack-Move To attack[0]
          • Custom script: call RemoveLocation(udg_attack[0])
          • Custom script: call DestroyGroup(udg_g[2])
        • Else - Actions
          • Set i = (Random integer number between 1 and towns)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • i Equal to 1
            • Then - Actions
              • Unit Group - Order g[1] to Attack-Move To attack[1]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • i Equal to 2
                • Then - Actions
                  • Unit Group - Order g[1] to Attack-Move To attack[2]
                • Else - Actions
      • Custom script: call DestroyGroup(udg_g[1])
variables needed to be set up are set in map initialization. units spawned in tested waves contain less than 12 units.
hopefully i explained everything that i need.
 
Last edited:
Level 21
Joined
Nov 4, 2013
Messages
2,017
In the Else functions, the attack[0] is not set to anything. Only in the Then part you set attack[0] yet if the Else actions run, this variable will be set to nothing.
Since there are probabilities, then clearly it will not work everytime. Only when the conditions will be satisfied will the trigger work.
 
Level 9
Joined
Apr 23, 2011
Messages
527
okay, changed it, but it still doesn't work.
attack[1] and [2] are set to the centers of regions.
towns integer is by default set to 1 as there is only one town discovered at the start of the game.

i can't help but think that the Then action is the one that's not working.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Just put some messages in there, display number of units in g1, display coordinates of point attack0, display the value of integer i, display all.
 
Level 9
Joined
Apr 23, 2011
Messages
527
so i put the debug messages and found out that g[2] and attacktarget are not properly being set. after some fiddling, i found out that there was a problem with setting the maxplayers variable in map initialization.

  • For each (Integer loop) from 1 to 8, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player(loop)) controller) Equal to User
          • ((Player(loop)) slot status) Equal to Is playing
        • Then - Actions
          • Set maxplayers = (maxplayers + 1)
the condition ((Player(loop)) slot status) Equal to Is playing was put there to fix the problem. i'm not sure why ((Player(loop)) controller) Equal to User isn't working (it included all the players even though i'm the only one playing, i'm using the Test Map button in the editor), i might need some clarification.

thanks Shadow Fury and Ceday! +rep
 
Status
Not open for further replies.
Top