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

spawn building if no units are near

Status
Not open for further replies.
Level 4
Joined
Jan 24, 2012
Messages
55
Hi there,

I'm working on this:
Two Teams fight each other. On each side, every Team has as example 4 Towers.

If a unit Group of Team 1 attack Team 2 and destroys a Tower, nothing should happens. But if the attacking Group is dead or retreats (leaving the "Team 2 Area"), all Towers should respawn after 60 seconds.

I made several triggers for that, but I have the Problem that the Tower respawn no matter if there are Team 1 Units in "Team 2 Area" or not.

Whats wrong? Any idea to do this?

Here my not really working triggers:

Add Team 1 Units to Team 1 Units Group if they enter Team 2 Area
  • GebietTower1
    • Ereignisse
      • Einheit - A unit enters Tower1 <gen>
    • Bedingungen
      • ((Owner of (Triggering unit)) Gleich Spieler 4 (Lila)) or ((Owner of (Triggering unit)) Gleich Spieler 11 (Dunkelgrün))
    • Aktionen
      • Einheitengruppe - Add (Triggering unit) to TowerGrp
Remove Team 1 Units if they leave Team 2 Area
  • GebietTower1Rckzug
    • Ereignisse
      • Einheit - A unit leaves Tower1 <gen>
    • Bedingungen
      • ((Owner of (Triggering unit)) Gleich Spieler 4 (Lila)) or ((Owner of (Triggering unit)) Gleich Spieler 11 (Dunkelgrün))
    • Aktionen
      • Einheitengruppe - Remove (Triggering unit) from TowerGrp
Removes Team 1 Units from the Team 1 Group if they die
  • GebietTowerTod
    • Ereignisse
      • Einheit - A unit Stirbt
    • Bedingungen
      • ((Triggering unit) is in TowerGrp) Gleich True
    • Aktionen
      • Einheitengruppe - Remove (Triggering unit) from TowerGrp
Starts the Trigger to respawm the Tower if the initial Tower is destroyes
  • BuildNewTower1
    • Ereignisse
      • Einheit - A unit Stirbt
    • Bedingungen
      • (Triggering unit) Gleich UdTower[1]
    • Aktionen
      • Auslöser - Turn off (This trigger)
      • Auslöser - Turn on BuildNewTower1Periodic <gen>
checks all 60 seconds if the Team 1 Group is empty (all Units in the Team 2 area are dead or has left the area) and respawns the Tower if it's true.
  • BuildNewTower1Periodic
    • Ereignisse
      • Zeit - Every 60.00 seconds of game time
    • Bedingungen
    • Aktionen
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Bedingungen
          • ((TowerGrp is empty) Gleich True) or ((All units of TowerGrp are dead) Gleich True)
        • 'THEN'-Aktionen
          • Auslöser - Turn off (This trigger)
          • Einheit - Create 1 Geisterturm for Spieler 5 (Gelb) at (Center of UdTower1 <gen>) facing (Center of HUTower3 <gen>)
          • Set UdTower[1] = (Last created unit)
          • Auslöser - Turn on BuildNewTower1 <gen>
        • 'ELSE'-Aktionen
          • Do nothing

Big Problem: The Tower respawns every 60 seconds no matter if there is a Team 1 Units in the Team 2 Area or not.
 
Level 39
Joined
Feb 27, 2007
Messages
5,013
The second half of your condition (all units of TowerGrp are dead) is completely unnecessary since you remove units from the group when they die. However, when the game engine checks to see if each unit is dead the empty group 'passes' that check because UnitAlive(null) returns false. Remove the OR... part and I bet it will work properly.

My second guess is that somewhere along the line you did a call DestroyGroup(udg_TowerGrp) in another trigger you didn't post. If the group is destroyed then it will always 'be' empty because effectively no units can be added to it.

If that is not the case, I would suggest adding some debug messages to your all the triggers you posted that count and display the number of units in TowerGrp every time they fire. That way you will know if the group is being detected as empty or not.
 
Level 4
Joined
Jan 24, 2012
Messages
55
Thanks for youre Reply! I don't really what you mean with "when the game engine checks to see if each unit is dead the empty group 'passes' that check because UnitAlive(null) returns false", but I will try what will happen without the "all units of TowerGrp are dead".

"call DestotyGrouo(udg_TowerGrp)" is nowhere in use. That cannot be the problem :)

About the debug messange - I thought about this before I posted here, but I never used debug Messages. How could I add this? I have absolute no idea xD
 
Thanks for youre Reply! I don't really what you mean with "when the game engine checks to see if each unit is dead the empty group 'passes' that check because UnitAlive(null) returns false", but I will try what will happen without the "all units of TowerGrp are dead".

"call DestotyGrouo(udg_TowerGrp)" is nowhere in use. That cannot be the problem :)

About the debug messange - I thought about this before I posted here, but I never used debug Messages. How could I add this? I have absolute no idea xD

You can use custom script. This is what the code looks like

call BJDebugMsg("<enter your string here>")
 
Status
Not open for further replies.
Top