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

Enemies Spawning

Status
Not open for further replies.
Level 5
Joined
Dec 11, 2010
Messages
101
Hello!

I seem to be running into a problem. What the problem is, is that I have <Region 1> spawns units randomly in the region.

But what i am aiming for is to make enemies spawn globally, except for certain regions.

If this is unclear, I can provide some pictures.
Thanks :D!
 
First of. Always use "If/Then/Else, Multiple Functions". It gives you much more control and is a LOT easier to edit.

Anyway you are doing it right in the first picture. But instead of "Random point in region" use the Temp_Point variable.

Edit:
Oh. Temp_Point is a Point variable NOT a region variable.

Edit2:

Under actions, first set the Temp_Point to a Fx. random point in playable area.
Then add the If/Then/Else, Multiple Functions action.
 
Ah. Remove the lower case p so it looks like this:
Custom script: call RemoveLocation (udg_Temp_Point)
The p was just a remnant from my own trigger.

Edit:
Btw. Post your triggers as triggers instead of pictures. Pretty please.

Edit2:
After looking at the picture it is clear that the trigger will not work.
Can you figure out why?
 
Level 5
Joined
Dec 11, 2010
Messages
101
Ah, just remembered how to do that :p

However, when i try to testrun the map it closes out of warcraft 3 and leaves no saying why.

Zombie Spawn Test
Events
Player - Player 1 (Red) types a chat message containing -coop as A substring
Conditions
Actions

Set Temp_Point = (Random point in Dont Spawn Enemies <gen>)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Dont Spawn Enemies <gen> contains Temp_Point) Equal to True
Then - Actions
Custom script: call RemoveLocation (udg_Temp_Point)
Trigger - Run (This trigger) (checking conditions)
Else - Actions
Unit - Create 1 Zombie 1 for Player 5 (Yellow) at (Random point in Whole Map <gen>) facing (Center of Whole Map <gen>)

Edit - "After looking at the picture it is clear that the trigger will not work.
Can you figure out why?" -nope i'm not so familiar with this :/ trying to be though
 
Sort of.
You place the Temp_Point in the region where units are not allowed to spawn.
Yet you check in the IF - condition that if the point is in that same region you run the trigger again. And thus is will loop indefinitely and crash the game.
The Temp_Point must be placed a random point all the playable area (meaning where you want units to spawn).
The reason for the if/then/else is to check if the point is within one of those non-spawn zones. If it is you want to remove the point and set a new.

Since you didn't specify whether or not the whole of the map is able for spawn I just assumed it is.
If not. Then the trigger will not be as simple as it is right now.
 
Level 5
Joined
Dec 11, 2010
Messages
101
Wait, so You place the Temp_Point in the region where units are not allowed to spawn.

but

The Temp_Point must be placed a random point all the playable area (meaning where you want units to spawn).

Im a bit confused, sorry :x

Note: Messed with it a bit, i got units to spawn, but they still spawned in non-spawning areas
 
Wait, so You place the Temp_Point in the region where units are not allowed to spawn.
No. However in your trigger YOU do.

The reason for the If/Then/Else is to see if the Temp_Point is located in the Don't Spawn Region. IF it is, then the trigger is run again.

Perhaps you should specify your needs better. We might be talking past each other and that's why is harder to understand.
Fx. Can the units spawn ANYWHERE besides the Don't Spawn Region in your map?
 
Level 5
Joined
Dec 11, 2010
Messages
101
  • Zombie Spawn Test
    • Events
      • Player - Player 1 (Red) types a chat message containing -coop as A substring
    • Conditions
    • Actions
      • Set Temp_Point = (Random point in Whole Map <gen>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Dont Spawn Enemies <gen> contains Temp_Point) Equal to True
        • Then - Actions
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
          • Unit - Create 1 Zombie 1 for Player 5 (Yellow) at (Random point in Whole Map <gen>) facing (Center of Whole Map <gen>)
I removed a bunch of the "create units" to make it shorter

edit: (Dont Spawn Enemies <gen> contains Temp_Point) Equal to True <-- im noob but it seems fishy
 
Yup. I said this some posts ago.
This action:
Unit - Create 1 Zombie 1 for Player 5 (Yellow) at (Random point in Whole Map <gen>) facing (Center of Whole Map <gen>)

You want the unit to spawn at Temp_Point. Because the whole reason (well one of them) for setting the Temp_Point is to know if it is inside the Don't Spawn Region.
Therefore you must create the unit a the point you set, which means Temp_Point.

It should look like this:
Unit - Create 1 Zombie 1 for Player 5 (Yellow) at (Temp_Point) facing (Center of Whole Map <gen>)

Also.
If it is not important then don't make the unit face a point. Just leave it as it was.
The reason for this is that you will need to set a second point "Center of Whole Map" otherwise it will also cause a point leak.

Speaking of leaks. Read this until you understand it:
http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=27219

Lastly. In the very end of your trigger you also need to do a point removal. Right know you only remove it if the point you set is in the Don't Spawn Region.
So at the end (outside the If/Then/else) do:
Custom script: call RemoveLocation (udg_Temp_Point)
 
Level 5
Joined
Dec 11, 2010
Messages
101
Okay so it works for the most part. Small question, what if I want them to spawn (for example) 1 by 1, and not spawn as a group?
i need Each zombie spawns somewhere different on the map except the non-spawn area, not together

  • Zombie Spawn Test
    • Events
      • Player - Player 1 (Red) types a chat message containing -coop as A substring
    • Conditions
    • Actions
      • Set Temp_Point = (Random point in Whole Map <gen>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Dont Spawn Enemies <gen> contains Temp_Point) Equal to True
        • Then - Actions
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
          • Unit - Create 1 Zombie 1 for Player 5 (Yellow) at Temp_Point facing Default building facing degrees
          • Unit - Create 1 Zombie 1 for Player 5 (Yellow) at Temp_Point facing Default building facing degrees
          • Unit - Create 1 Zombie 1 for Player 5 (Yellow) at Temp_Point facing Default building facing degrees
I usually just copy/paste the create units and it works, but now they spawn in (this case) a group of 3.

i do have the call RemoveLocation (udg_Temp_Point) in there, forgot to add it

big thanks so far :)
 
Last edited:
Alright. Try this:

  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing -coop as An exact match
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Spawn_Integer Greater than 5
        • Then - Actions
          • Set Temp_Point = (Random point in (Playable map area))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Dont Spawn Enemies <gen> contains Temp_Point) Equal to True
            • Then - Actions
              • Custom script: call RemoveLocation (udg_Temp_Point)
              • Trigger - Run (This trigger) (checking conditions)
            • Else - Actions
              • Unit - Create 1 Zombie for Player 5 (Yellow) at Temp_Point facing Default building facing degrees
              • Set Spawn_Integer = (Spawn_Integer + 1)
              • Custom script: call RemoveLocation (udg_Temp_Point)
              • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
          • Set Spawn_Integer = 0
Spawn_Integer is an Integer variable
Temp_Point is a Point variable


If you want to spawn more (or less) than 5 units, then just change the "5" in:
"Spawn_Integer Greater than 5"
To whatever amount you need.
 
Level 5
Joined
Dec 11, 2010
Messages
101
  • Zombie Spawn Test
    • Events
      • Player - Player 1 (Red) types a chat message containing -coop as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Spawn_Integer Greater than 3
        • Then - Actions
          • Set Temp_Point = (Random point in (Playable map area))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Dont Spawn Enemies <gen> contains Temp_Point) Equal to True
            • Then - Actions
              • Custom script: call RemoveLocation (udg_Temp_Point)
              • Trigger - Run (This trigger) (checking conditions)
            • Else - Actions
              • Unit - Create 3 Zombie 1 for Player 5 (Yellow) at Temp_Point facing Default building facing degrees
              • Set Spawn_Integer = (Spawn_Integer + 1)
              • Custom script: call RemoveLocation (udg_Temp_Point)
              • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
          • Set Spawn_Integer = 0
For Set Spawn_Integer = (Spawn_Integer + 1) , i used arithmatic

However, no enemies spawn on the map at all.
 
Status
Not open for further replies.
Top