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

GUI/JASS: Polled Wait in Escape Map death

Status
Not open for further replies.
Level 10
Joined
Jan 28, 2009
Messages
442
My problem concerns the use of polled wait after a player dies and before it respawns. Note: The trigger and function below are working apparently without bugs - they are only displayed here for reference.

To manage the players' movement in my escape map, I use this trigger:

  • O pt O 3
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Missiles and do (Actions)
        • Loop - Actions
          • Set loc = (Position of (Picked unit))
          • Set loc2 = (loc offset by 18.00 towards (Facing of (Picked unit)) degrees)
          • Custom script: call RemoveLocation(udg_loc)
          • Unit - Move (Picked unit) instantly to loc2
          • Set group = (Units within Collision of loc2 matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
          • Unit Group - Pick every unit in group and do (Actions)
            • Loop - Actions
              • Set loc = (Position of (Picked unit))
              • Special Effect - Create a special effect at loc using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Custom script: call RemoveLocation(udg_loc)
              • Custom script: call myFailPlayer(GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit())))
          • Custom script: call DestroyGroup(udg_group)
          • Custom script: call RemoveLocation(udg_loc2)
      • Unit Group - Pick every unit in Enemies and do (Actions)
        • Loop - Actions
          • Set loc2 = (Position of (Picked unit))
          • Set group = (Units within Collision of loc2 matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
          • Unit Group - Pick every unit in group and do (Actions)
            • Loop - Actions
              • Set loc = (Position of (Picked unit))
              • Special Effect - Create a special effect at loc using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Custom script: call RemoveLocation(udg_loc)
              • Custom script: call myFailPlayer(GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit())))
          • Custom script: call DestroyGroup(udg_group)
          • Custom script: call RemoveLocation(udg_loc2)
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Yoshi[(Integer A)] Not equal to No unit
            • Then - Actions
              • Set loc = (Position of Yoshi[(Integer A)])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at loc) Equal to Sunken Ruins - Sand
                • Then - Actions
                  • Special Effect - Create a special effect at loc using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: call myFailPlayer(GetForLoopIndexA())
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain type at loc) Equal to Dungeon - Lava Cracks
                      • (Current order of Yoshi[(Integer A)]) Not equal to (Order(smart))
                      • (Current order of Yoshi[(Integer A)]) Not equal to (Order(move))
                    • Then - Actions
                      • Special Effect - Create a special effect at loc using Abilities\Weapons\DemolisherFireMissile\DemolisherFireMissile.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Custom script: call myFailPlayer(GetForLoopIndexA())
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Terrain type at loc) Equal to Barrens - Desert Cliff
                        • Then - Actions
                          • Set loc2 = (loc offset by TracksandSpeed towards (Facing of Yoshi[(Integer A)]) degrees)
                          • Unit - Move Yoshi[(Integer A)] instantly to loc2
                          • Custom script: call RemoveLocation(udg_loc2)
                        • Else - Actions
              • Custom script: call RemoveLocation(udg_loc)
            • Else - Actions
function myFailPlayer (called in the trigger above) is the one that moves the Yoshis back to their save points, which are the positions of the units in the udg_Egg[11] array and subtract lives when they die.
Parts were converted from GUI. Maybe there's a better way of writing it that someone might like to tell me about.

JASS:
function myFailPlayer takes integer pl_i returns nothing
 //pl_i is supposed to be a GUI player number, where Player 1's number is 1.
 local boolean b = false

 if udg_ExtraLives[pl_i] > 0 then
  set udg_ExtraLives[pl_i] = ( udg_ExtraLives[pl_i] - 1 )
 else
  if udg_ExtraLives[pl_i] > -1 then //When ExtraLives==-1 it's beginner mode
   set b = true
  endif
 endif

 if b == false then
  set udg_loc = GetUnitLoc(udg_Egg[pl_i])
  call SetUnitPositionLoc( udg_Yoshi[pl_i], udg_loc )
  call RemoveLocation(udg_loc)

 else //Player is out of lives (unimportant)
  call RemoveUnit( udg_Yoshi[pl_i] )
  call KillUnit( udg_Egg[pl_i] )
  set udg_Egg[pl_i] = null
  call CustomDefeatBJ( ConvertedPlayer(pl_i), "GAME OVER" )
 endif

endfunction


This system works, but it's a not fully satisfying work-around I made. I really wanted to hide the "dying" Yoshi, insert a polled wait, move it back on its egg (save point), and finally unhide it and pan the camera for the owning player.
The problem is how to make the polled wait work. When I tried using it, nothing happened after the wait.


I'd be very, very grateful if someone could rewrite a few lines or write me an alternative myFailPlayer function using my variables and including a hide unit -> wait -> resolve -> ((move and unhide unit)), because it is bothering me much that I can't have the polled wait atm. Thank you.


Vars that do not begin with a capital letter after udg_ - for example udg_int - are temporary variables, like some would write like udg_TempInt.

udg_...
int as integer (temp)
loc as point (temp)
Collision as real
TracksandSpeed as real
Egg(11) as unit ... 1 array element per player
Yoshi(11) as unit ... 1 array element per player
Enemies as unit group
group as unit group (temp)
Missiles as unit group



Edit: If you detect leaks/have suggestions, please post :)
 
Last edited:
Status
Not open for further replies.
Top