• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Unit Spawn trigger

Status
Not open for further replies.
Level 2
Joined
Jul 9, 2011
Messages
10
Hi, i made this wave trigger to spawn some units, set a variable for them and set its rally point

the probem is that no rally point is set, even if the unit has the rally ability did i do something wrong?

  • Waves 1 to 5
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • (Count non-structure units controlled by Player 12 (Brown) (Exclude incomplete units)) Less than 1
      • Level Less than or equal to 3
    • Actions
      • Set i_Wave_Creating = 0
      • For each (Integer i_Waves[0]) from 1 to WavesAmmount[Level], do (Actions)
        • Loop - Actions
          • For each (Integer i_Waves[1]) from 1 to CreepsAmmount[Level], do (Actions)
            • Loop - Actions
              • Unit - Create 1 Creeps[Level] for Player 12 (Brown) at (Center of (Playable map area)) facing 180.00 degrees
              • Set Unit_Array[i_Wave_Creating] = (Last created unit)
              • Unit - Set Rally-Point for Unit_Array[i_Wave_Creating] to Waypoints_West[0]
              • Game - Display to (All players) the text: ((String((X of Unit_Rally_Point[i_Wave_Creating]))) + (, + (String((Y of Unit_Rally_Point[i_Wave_Creating])))))
              • Set i_Wave_Creating = (i_Wave_Creating + 1)
          • Wait WavesCooldown[Level] game-time seconds
      • Set Level = (Level + 1)
 
Level 2
Joined
Jul 9, 2011
Messages
10
Better use action Unit - Issue Order Targetting a Point, and do:
  • Unit - Order (Last created unit) to Move to Waypoints_West[0]
i need to store the destination of the unit for another trigger, i decided to use a new point variable for each unit "Unit_Rally_Point" array

Unit - Create 1 Creeps[Level] for Player 12 (Brown) at (Center of (Playable map area)) facing 180.00 degrees

Do you intend to create them in the middle of the map all the time?
no, that was only for testing. i have added the new starting locations

Also you leak locations
You want to do something like this;
  • Set Temp_Point = (Center of (Playable map area))
  • Unit - Create 1 Creeps[Level for Player 12 (Brown) at Temp_Point facing 180.00 degrees
  • Custom script: call RemoveLocation(udg_Temp_Point)
That will help improve trigger capability, so that game stays stable.
thx for the warning! i changed to a variable location initialized with the map because it is used all the time. if im right now i don't need to destroy it?

  • Set Spawn_Points[2] = ((Center of (Playable map area)) offset by (-350.00, 0.00))
  • Waves 1 to 5
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • (Count non-structure units controlled by Player 12 (Brown) (Exclude incomplete units)) Less than 1
      • Level Less than or equal to 3
    • Actions
      • Set i_Wave_Creating = 0
      • For each (Integer i_Waves[0]) from 1 to WavesAmmount[Level], do (Actions)
        • Loop - Actions
          • For each (Integer i_Waves[1]) from 1 to CreepsAmmount[Level], do (Actions)
            • Loop - Actions
              • Unit - Create 1 Creeps[Level] for Player 12 (Brown) at Spawn_Points[2] facing 180.00 degrees
              • Set Unit_Array[i_Wave_Creating] = (Last created unit)
              • Set Unit_Rally_Point[i_Wave_Creating] = Waypoints_West[0]
              • Set i_Wave_Creating = (i_Wave_Creating + 1)
          • Wait WavesCooldown[Level] game-time seconds
      • Set Level = (Level + 1)
 
Level 2
Joined
Jul 9, 2011
Messages
10
Well you stilll leak a location
the ( offset by ) causes a new leak
you would need to do it like this
  • Set Spawn_Points[1] = ((Center of (Playable map area))
  • set Spawn_Points[2] = ((Spawn_Points[1]) offset by (-350.00, 0.00))
thx fixed that.
  • Set Point_Center = (Center of (Playable map area))
  • Set Spawn_Points[0] = (Point_Center offset by (350.00, 0.00))
Man, discribe what your problem is about, I though that your units do not head to destination point.
the problem was with the units rally-point, the line would not work even if the unit had rally ability:
  • Unit - Set Rally-Point for Unit_Array[i_Wave_Creating] to Waypoints_West[0]
i gave up using rally point and now i store the destination on a point variable, i think its even better than using rally point to store destination.
 
Level 2
Joined
Jul 9, 2011
Messages
10
when the unit is created i don't want to move it, just set its first destination.

on another trigger i use the move action:
  • Unit - Order Unit_Array[For_West[0]] to Move To Unit_Rally_Point[For_West[0]]
the reason i don't want it to move just after it is created is because depending on some info like what the player is doing, what the units current destination is and dificuly level, the destination will change.

the trigger is working fine now
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Rally points only work with units that train units. You are creating units via triggers thus it is impossible to have them go to a rally point as there is no training unit.

To use a rally point...
1. Make a unit that can train units. Eg a Baracks for footman units.
2. Set the training unit's rally point somewhere. Eg a Baracks to middle of map.
3. Order the training unit to train a unit. Eg a Baracks to train a footman.
4. Wait for training to complete and watch the unit go to rally point automatically.

Be aware that units made in this manner likly still leak when removed in anyway possible. Also be aware that to train a unit, the nescescary resources must be available to support the process.
 
Status
Not open for further replies.
Top