• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Follow the player spawn system?

Status
Not open for further replies.
Level 9
Joined
Sep 6, 2008
Messages
477
Hey everyone, i've been absent for some time now but i've come back for a while.
Anyways iv got an epic game in mind but i need some assistance with a certain part.
I'm not sure how to make enemies spawn and then start going towards the player once they spawn.
Basically what i want is the monsters to spawn and then start moving toward the player so the player
is always fighting and the enemies dont just stand around in the middle of no where.
The attachment is a diagram of what i meen.

diagram.jpg

Thanks,
-Bane
 
Level 10
Joined
Sep 6, 2008
Messages
423
Here you have a small example.
  • Follow on spawn
    • Events
      • Time - Elapsed game time is 60.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to (How many enemies you want to have), do (Actions)
        • Loop - Actions
          • Unit - Create 1 (Your Unit) for (Enemy ai) at (spawn place) facing Default building facing degrees
          • Unit - Order (Last created unit) to (Your Hero) <gen>
 
Level 8
Joined
Feb 20, 2007
Messages
338
What may be just an interesting 'aside here'.

I discovered, much to my amazement, that player units (team units like footmen, knights, etc) will automatically run to the player start location using the Melee AI.

Meaning if you place the player start location of your enemy in the middle of the camp of your player, and spawn just footmen, knights, and other melee units - they will run to the camp.


  • Creep Spawn Alpha Copy
    • Events
    • Conditions
    • Actions
      • Set Creep_Spawn = (region, position of a destructible, position of a unit - wherever they are coming from. )
      • Set Point = (Region, position of... where ever you want them to go
        • For each (Integer A) from 1 to Number_of_Creeps, do (Actions)
          • Loop - Actions
            • Unit - Create 1 Random_Creep for Player 10 (Light Blue) at Creep_Spawn facing Default building facing degrees
            • Unit - Order (Last created unit) to Attack-Move To Point
            • Wait 2.00 seconds
        • Custom script: call RemoveLocation( udg_Creep_Spawn )
        • Custom script: call RemoveLocation( udg_Point )

Variables:

Creep_Spawn is a point variable, set to any location you desire, be it the position of a unit, the center of a region, blah.
Point is a point variable, again set to where ever you want.

Number_of_Creeps is an integer - you can use a number. If you set it as a variable you can manipulate that integer in other triggers - by using something like so:


  • Set Number_of_Creeps= (Number_of_Creeps+ 1)
Custom script there removes the point leaks created each time you run the trigger or create a unit at a point.

As an aside, or a foot note, if you have a lot of loops (For each integer) you can make variables for those
  • For each (Integer Dawn) from 1 to 250, do (Actions)
    • Loop - Actions
"Dawn" is a variable an is set using 'for each integer variable' This way if you have several things looping at the same time, or are sending enemies from more than one point, this will allow you better control of how many times a particular trigger loops.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Servus @ all

I found an solution you just need 2 trigger and one rect.

You create a rect, where the [Attacking Units] can spawn. ( A small, normal or big one - what ever you want). [[I named this Rect SPAWN]]

Then you need the first trigger:
  • Run Spawn and Attack
    • Events
      • Unit - (here what ever the Hero is doing to run this trigger)
    • Conditions
    • Actions
      • Trigger - Turn on [SpawnUnits (the 2nd trigger)] <gen>
      • Wait 1.00 seconds
      • Trigger - Turn off [SpawnUnits (the 2nd trigger)] <gen>
      • Wait - Wait 0.25 seconds
      • Unit Group - Pick every unit in (Units in SPAWN <gen>) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to (Your Unit!)
            • Then - Actions
              • Unit - Order (Picked unit) to Attack (Your Hero!) <gen>
            • Else - Actions
And here comes the spawning Trigger:
  • SpawnUnits
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 1 (Your Unit!) for (What Player?) at (Random point in SPAWN <gen>) facing (Position of (Your Hero!))
If you create the 2nd trigger, than Dismark "Initially On"

In the 2nd trigger i choose 0.10 seconds in the event - so there are 10 Units spawned in the "Wait - Wait 1.00 second before the trigger tuned off ... you can choose it for yourself)

I testet it and it works fine have fun =)

MfG
Dr. Boom
 
Level 7
Joined
Oct 14, 2008
Messages
340
A more efficient system would make periodic checks i would think, so that bugs don't occur where units are stuck, just standing still.. I got the impression he wanted units to be spawning all over the map, not in one fixed region. There's a lot of ways this could be done.. depending on how smart you want your creeps to be, like, if you wanted them to have a bit of AI and form groups before attacking, this would be much more work :p

And on a side note... 3OH!3 ftw
 
Level 19
Joined
Sep 4, 2007
Messages
2,826
The best method would be to make the players' units visible to the computer and make their acquisition range huge via the Object Editor. That way they'll always hunt their prey. But to prevent bugs you'll have to reset their orders sometimes.
 
Status
Not open for further replies.
Top