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

[Trigger] Spawn System

Status
Not open for further replies.
Level 6
Joined
May 13, 2013
Messages
111
  • Spawn
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Set RandomAnimals = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomAnimals Less than or equal to 30
        • Then - Actions
          • Unit - Create 1 Deer for Player 12 (Brown) at (Random point in (Playable map area)) facing Default building facing degrees
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomAnimals Less than or equal to 60
            • Then - Actions
              • Unit - Create 1 Rabbit for Player 12 (Brown) at (Random point in (Playable map area)) facing Default building facing degrees
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RandomAnimals Less than or equal to 100
                • Then - Actions
                  • Unit - Create 1 Sheep for Player 12 (Brown) at (Random point in (Playable map area)) facing Default building facing degrees
                • Else - Actions
Sometimes they spawn in the water. How can I fix it?
 
If you check if walkability at this point if true, they should not spawn in deep water anymore

  • Set Point = (Random point in (Playable map area))
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • IF - Conditions
      • (Terrain pathing at Point of type Walkability is off) Equals False
    • Then - Actions
      • Unit - Create YourUnir for Player at Point facing 0 degrees
    • Else - Actions
  • Custom script: call RemoveLocation (udg_Point)
Or if it's maybe a single rect (your water), you can create a region where you don't want to spawn your units and then check ..
  • ((Region) contains Point) Equalse False
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Also, you may Set Variable - Point instead of using Random Point in Playable Map Area. Work with variables everytime it is possible.

This is partially true.

You should use a variable whenever the action is repeated twice or more.

In the case with random point though you need to use a variable as random point leaks if not removed.
 
Level 4
Joined
Jan 27, 2009
Messages
57
This is partially true.

You should use a variable whenever the action is repeated twice or more.

In the case with random point though you need to use a variable as random point leaks if not removed.

Yeah! That`s what I mean. His trigger will spawn a critter each 10 seconds in a random point of the map. This represents 6 leaks per minute for each player!!
So Points Variables are must here.
 
Level 6
Joined
May 13, 2013
Messages
111
So how about this?

  • Spawn
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Set RandomAnimals = (Random integer number between 1 and 100)
      • Set SpawnPoint = (Random point in (Playable map area))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomAnimals Less than or equal to 40
          • (Terrain pathing at SpawnPoint of type Walkability is off) Equal to False
        • Then - Actions
          • Unit - Create 1 Deer for Player 12 (Brown) at SpawnPoint facing Default building facing degrees
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomAnimals Less than or equal to 80
              • (Terrain pathing at SpawnPoint of type Walkability is off) Equal to False
            • Then - Actions
              • Unit - Create 1 Rabbit for Player 12 (Brown) at SpawnPoint facing Default building facing degrees
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RandomAnimals Less than or equal to 20
                  • (Terrain pathing at SpawnPoint of type Walkability is off) Equal to False
                • Then - Actions
                  • Unit - Create 1 Sheep for Player 12 (Brown) at SpawnPoint facing Default building facing degrees
                • Else - Actions
      • Custom script: call RemoveLocation(udg_SpawnPoint)
 
Level 4
Joined
Jan 27, 2009
Messages
57
Your trigger is wrong. In that case, BOTH CONDITIONS may be true to create the Deer. If both are not true (and note if you random a number less then 40 but the point arrives on an unpathable area, it will disconsider the deer and jump to next phase verification. That would be false too, because the number you sorted still less then 80 and the point is still in the same unpathable place. And, at last, your third filter is having the same behavior, so it will lead to the last
  • Else - Actions
that is empty. So nothing happens when the point is unpathable.

So the best to do is to create two triggers.
One will occur every ten seconds of the game and will random a point and a number and, then, run the second one (that will have no event on the heading).
The second one will contain your ITE (If - Then - Else) that select the correct unit/pathable point to spawn the critter. But, you need to add another IF inside each previous THEN. So ity may be like:

  • If - Conditions
    • RandomAnimals Less than or equal to 40
    • Then - Actions
      • If - Conditions
        • (Terrain pathing at SpawnPoint of type Walkability is off) Equal to False
      • Then - Actions
        • Unit - Create 1 Deer for Player 12 (Brown) at SpawnPoint facing Default building facing degrees
      • Else - Actions
        • Set SpawnPoint = (Random point in (Playable map area))
        • Run (This Trigger).
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
The trigger could be structured like this
  • Untitled Trigger 004
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at (Center of (Playable map area)) of type Walkability is off) Equal to True
        • Then - Actions
          • Set i = (Random integer number between 1 and 10)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • i Less than 41
            • Then - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • i Less than 81
                • Then - Actions
                • Else - Actions
 
Level 4
Joined
Jan 27, 2009
Messages
57
  • (Terrain pathing at SpawnPoint of type Walkability is off) Equal to False
This should be true instead of false

No, friend, it shouldnt be true because you checking:

IF terrain pathing at point of type WALKABILITY is OFF = false

Means that you should do THEN - ACTIONS if the terrain at the point is walkable. If not walkable, the ELSE - ACTIONS should run.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
To clarify

  • Untitled Trigger 001
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Set p = (Position of u)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at p of type Floatability is off) Equal to False
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain pathing at p of type Walkability is off) Equal to True
            • Then - Actions
              • Game - Display to Player Group - Player 1 (Red) the text: deep water
            • Else - Actions
              • Game - Display to Player Group - Player 1 (Red) the text: shallow water
        • Else - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: not water
 
No, friend, it shouldnt be true because you checking:

IF terrain pathing at point of type WALKABILITY is OFF = false

Means that you should do THEN - ACTIONS if the terrain at the point is walkable. If not walkable, the ELSE - ACTIONS should run.

Seems I misunderstood then, never mind.
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
dude, you need a "respawn" unit or "spawn" unit system? respawn for me is reviving death unit.. wait, sorry I didn't follow the comments..

I suggest you to use something I call "repeater". repeater is a looping integer that never ends until the matching conditions are met.
for example:

  • for loop integer A from 0 to 2
  • actions
  • set integer A = 0
  • set point = (random point in map)
  • if (point walkability is on equal to true)
    • set integer A = 3 //this will ends the loop
  • else
    • destroy point
in that trigger, the system will always find a new point until the condition(point walkability blablabla) is met. I will explain more if you dont get clear enough..
 
Level 4
Joined
Jan 27, 2009
Messages
57
dude, you need a "respawn" unit or "spawn" unit system? respawn for me is reviving death unit.. wait, sorry I didn't follow the comments..

I suggest you to use something I call "repeater". repeater is a looping integer that never ends until the matching conditions are met.
for example:

  • for loop integer A from 0 to 2
  • actions
  • set integer A = 0
  • set point = (random point in map)
  • if (point walkability is on equal to true)
    • set integer A = 3 //this will ends the loop
  • else
    • destroy point
in that trigger, the system will always find a new point until the condition(point walkability blablabla) is met. I will explain more if you dont get clear enough..

I don't like this type of work. Kinda consume too much memory while infinitely looping.. Better check the previous suggestions, they're kinda better.
 
Status
Not open for further replies.
Top