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

few questions!

Status
Not open for further replies.
Level 5
Joined
Apr 26, 2009
Messages
92
Ok my first question is about the following trigger, why doesn't it work? (Its supposed to spawn units in a 'pit' wait until they're dead, spawn a boss, wait until that's dead then move the hero out of the pit)

  • Pit 1
    • Events
    • Conditions
    • Actions
      • Set Round = (Round + 1)
      • Game - Display to (All players) the text: ((Wave + (String(Round))) + (: 24 + (String(creep[Round]))))
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units in Pit[(Integer A)])) Equal to 1
            • Then - Actions
              • Set temppoint = (Center of Pit[(Integer A)])
              • Unit - Create 24 creep[Round] for Neutral Hostile at temppoint facing Default building facing degrees
              • Set wave[(Integer A)] = (Last created unit group)
              • Wait until ((wave[(Integer A)] is empty) Equal to True), checking every 1.00 seconds
              • Game - Display to (Player group((Player((Integer A))))) the text: (Boss + ((String(Round)) + (: 1 + (String(boss[Round])))))
              • Unit - Create 1 boss[Round] for Neutral Hostile at temppoint facing Default building facing degrees
              • Set boss2[(Integer A)] = (Last created unit)
              • Custom script: call RemoveLocation(udg_temppoint)
              • Wait until ((boss2[(Integer A)] is dead) Equal to True), checking every 1.00 seconds
              • Unit - Move hero[(Integer A)] instantly to (Center of Spawn <gen>)
            • Else - Actions
My second question is: Is it possible to make is so Conversion String-UnitType will return the units name not its raw data code?

Thanks a bunch :grin:
 
  • Set wave[(Integer A)] = (Last created unit group)
To claim that you have (Last created unit group), you need an action through the Unit Group category, not the Unit category. You simply created a Unit, you didn't create a Unit Group. So, change the wave[] variable into a Unit variable, instead of the current Unit Group and use
  • Wait until ((wave[(Integer A)] is dead) Equal to True), checking every 1.00 seconds
(Unit - Unit is dead)

For your second question
Is it possible to make is so Conversion String-UnitType will return the units name not its raw data code?
You don't have to make a conversion of Unit-type, you just need the "Unit - Unit name" function. When it asks you to add a string (in the Strings window, e.g. "Game - Display to All players the text: Text"), scroll to Unit - Unit name. Example:
  • Game - Display to (All players) the text: (Name of (Triggering unit))
Jass way:

JASS:
GetUnitName(GetTriggerUnit())
 
Level 5
Joined
Apr 26, 2009
Messages
92
Actually in my trigger its creating 24 units, and if you read Blizzard's disruption of 'create unit' it says use 'last created unit group to refer to these units.

And are you sure because the 'creep' variable I use in the trigger is a unit-type variable not a unit one. I'd need to create that type of unit or something.

I think it has to do with the wait causing a bug in the loop but I can't figure out a workaround
 
Level 4
Joined
May 4, 2008
Messages
113
I'm afraid you are mistaken. If you create 24 units at once, you can't use Last created unit group to refer to all of them, without setting them into an actual unit group.

Code:
For each Integer B from 1 to 24 do:
 Loop (Actions):
  Unit - Create 1 creep[Round] for Neutral Hostile at temppoint facing Default building facing degrees
  Unit Group - Add (Last created unit) to CreepGroup[Integer A]

CreepGroup is a unit group variable, obviously.

Also, I'm assuming you have twelve players, and thus twelve pits?

If you have waits inside those loops, what is going to happen is that the units spawn for player 1, then when he kills them all, the boss spawns, he kills that boss, then the units will spawn for player 2. This will go in a cycle until it reaches the 12th player, and then come back to player 1 again. It will take forever.

The answer is to basically not use waits.

The other problem you have with what you have done is that a unit is not actually removed from the unit group automatically when it dies. You have to do that yourself.

I'd suggest using custom values or something to identify which unit belongs to which Player's pit (you could also use a "Unit is in region" condition) and then remove them from the unit group when they die, and ALSO check if there are no units left in that group.

So after you spawn them, do "Unit - Set Custom Value of (Last created unit) to Integer A"

You'll also need to set each player's region to a region array variable, say "Spawn_Region"

Code:
Events
 A unit dies

Conditions
 Owner of (Triggering unit) Equal to Neutral Hostile

Actions
 For each Integer A from 1 to 12, do:
  Loop - (Actions):
   If (Triggering unit) is in CreepGroup[Integer A] then do:
    Remove (Triggering unit) from CreepGroup[Integer A]
    If (Number of units in CreepGroup[Integer A]) Less than or equal to 0 then:
    Set Temp_Point = Centre of Spawn_Region[Integer A]
    Create 1 boss[round] for Neutral Hostile at Temp_Point facing Default building facing degrees
    call RemoveLocation(udg_Temp_Point)

And whatever else you need to do.

Sorry if you don't actually need the last bit, but you almost definitely do need to get rid of that wait!
 
Level 5
Joined
Apr 26, 2009
Messages
92
Ok so the main problem is solved, i just separated the waits into 3 different triggers.

  • Pit 1
    • Events
    • Conditions
    • Actions
      • Set Round = (Round + 1)
      • Game - Display to (All players) the text: ((Wave + (String(Round))) + (: 24 + (String(creep[Round]))))
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units in Pit[(Integer A)])) Equal to 1
            • Then - Actions
              • Set temppoint = (Center of Pit[(Integer A)])
              • Unit - Create 24 creep[Round] for Neutral Hostile at temppoint facing Default building facing degrees
              • Set wave[(Integer A)] = (Last created unit group)
            • Else - Actions
      • Wait 2.00 seconds
      • Trigger - Turn on Pit 1 Copy 2 <gen>
  • Pit 1 Copy 2
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (All units of wave[(Integer A)] are dead) Equal to True
              • (Pit[(Integer A)] contains hero[(Integer A)]) Equal to True
              • Boss_spawn[(Integer A)] Equal to False
            • Then - Actions
              • Set temppoint = (Center of Pit[(Integer A)])
              • Game - Display to (Player group((Player((Integer A))))) the text: (Boss + ((String(Round)) + (: 1 + (String(boss[Round])))))
              • Unit - Create 1 boss[Round] for Neutral Hostile at temppoint facing Default building facing degrees
              • Set boss2[(Integer A)] = (Last created unit)
              • Set Boss_spawn[(Integer A)] = True
              • Custom script: call DestroyGroup(udg_wave[GetForLoopIndexA()])
              • Custom script: call RemoveLocation(udg_temppoint)
            • Else - Actions
      • Wait 2.00 seconds
      • Trigger - Turn on Pit 1 Copy 2 Copy <gen>
  • Pit 1 Copy 2 Copy
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • pit_players Equal to pit_players_Copy
              • Pit_active Equal to True
            • Then - Actions
              • Trigger - Turn off Pit 1 Copy 2 <gen>
              • Trigger - Turn off Pit 1 <gen>
              • Trigger - Turn off (This trigger)
              • Game - Display to (All players) the text: Well done, wave com...
              • Countdown Timer - Start Break_timer as a One-shot timer that will expire in 60.00 seconds
              • Countdown Timer - Create a timer window for (Last started timer) with title Break Time
              • Set Pit_active = False
              • Hero - Instantly revive hero[(Integer A)] at (Center of Spawn <gen>), Show revival graphics
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (boss2[(Integer A)] is dead) Equal to True
              • Boss_spawn[(Integer A)] Equal to True
              • (Pit[(Integer A)] contains hero[(Integer A)]) Equal to True
            • Then - Actions
              • Unit - Move hero[(Integer A)] instantly to (Center of Spawn <gen>)
              • Camera - Set the camera bounds for (Player((Integer A))) to (Initial camera bounds)
              • Camera - Pan camera for (Player((Integer A))) to (Center of (Playable map area)) over 0.00 seconds
              • Game - Display to (Player group((Player((Integer A))))) the text: (Well done. You have completed wave + ((String(Round)) + . Please wait until all other players are finished))
              • Set pit_players_Copy = (pit_players_Copy + 1)
            • Else - Actions
Thanks for your help =D
P.S if last created group doesnt work then why does this
  • Melee Initialization
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Unit - Create 24 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Set Unit_group_var = (Last created unit group)
      • Wait 2.00 seconds
      • Unit Group - Pick every unit in Unit_group_var and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
 
Status
Not open for further replies.
Top