• 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.

Unit spawn help :(

Status
Not open for further replies.
Level 4
Joined
Dec 28, 2008
Messages
58
The problem is that i dont know how to make this trigger system

eg:A peasant builds 3 barracks.Every 5 secconds 1 footman is spawned infrond of each barrack

Thats what i need
 
Level 4
Joined
Dec 28, 2008
Messages
58
I appriciate ur help but i was accually forgot to mention


evey 2 secs a unit is spawned from the barracks.

eg.Peasant builds 3 barracks and they all spawn the same time 1 footman.

Its like civilization wars if know it.Same triger
 
Level 4
Joined
Dec 28, 2008
Messages
58
A test map is attached

I appriciate ur help but i was accually forgot to mention


evey 2 secs a unit is spawned from the barracks.

eg.Peasant builds 3 barracks and they all spawn the same time 1 footman.

Its like civilization wars if know it.Same triger
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
That's even easier to do.

I uploaded a test-map based on defskull's one.
(And added a blacksmith, as I'm afraid you'd do terrible things if I didn't show you another example of the modulo-function).

I know, it could've been done easier for you, but I'd prefer this instead of an automated variable-system.
If you want to add something else, go to "Add Structures", copy/paste the last if/then/else and change the variables.
Then go to "Timer" and do... basically the same thing. Timer mod X = 0 means that a unit will spawn every X seconds.
 

Attachments

  • Simplified Auto Spawn Unit System.w3x
    13.7 KB · Views: 294
Level 4
Joined
Dec 28, 2008
Messages
58
I only dont understand just what is this script : call RemoveLocation(udg_BarrackLoc) (im not good with the scripts.What is its purpose? :/
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I only dont understand just what is this script : call RemoveLocation(udg_BarrackLoc) (im not good with the scripts.What is its purpose? :/

Well, you see.
Every time you use a location, like "Create unit at Center of Region", Warcraft will store "Center of region" in its database.
Now if you create a new unit with the same location, Warcraft will NOT restore the location you already created, instead: it will create another location!

So now Warcraft remembers:
Center of Region
Center of Region

If Warcraft has to remember too much, the game will lag.
This also happens when you create special effects, unit groups, player groups (EXCEPT "All Players").

To avoid lag, we remove the location (hence "RemoveLocation").
We must store the location somewhere first though (that's what the "set variable" is for).
To remove special effects from Warcraft's database, there is a GUI action called "Destroy special effect", you should use that when you don't need a special effect anymore.
 
Ok, stop right there.

Try this one out (one bug in it, but will be solved)
it's super, super, super simple.

http://www.hiveworkshop.com/forums/submissions-414/system-simplespawn-195557/

So if you want to create a spawn, collect the unit type id of the thing that spawns. For example, human barracks is 'hbar'. You can collect these by going into the object editor and hitting CTRL+D. Then get the thing to be spawned, like 'hfoo' for footman. Then put in how often it should spawn and you are set to go.

Automatically pauses spawns while upgrading
Handles upgrades
Supports spawn counts
And again, super simple

If you enable the DYNAMIC mode, then you can use an ability like chaos and the spawn will be updated O-o. Only use DYNAMIC mode if you plan on using the ability stuff =P.

i think that's about as simple as it gets =), simpler than even doing it in GUI and way more optimal.

Also, the spawns are started at the correct period. You know sometimes when you upgrade a building in some maps and the thing instantly spawns? That's because all of the spawns are running on a single timer. In this, it's running on what's called a timer queue, which is like a timer that is split up into lots of little timers. This means that all of the spawns will spawn at the right time ^)^.

And if you don't believe me on just how easy it is to use, this will do exactly what you want
JASS:
struct BarracksFoot extends array
    private static constant real INTERVAL = 5           //5 second interval spawn time
    private static constant integer ORIGIN = 'hbar'     //barracks
    private static constant integer SPAWN = 'hfoo'      //footman
    private static constant integer COUNT = 1           //count
    implement LightSpawn
endstruct

That easy. Just replace the title with w/e you want to name it as, like TownhallRifleman or CastleKnight or w/e. From there, change the ORIGIN to the type of building and SPAWN to the type of unit, COUNT to how many to spawn and INTERVAL to how often to spawn.

The great thing is that this will always spawn right at the building! You could have units moving around and the spawns will still pop up at them =).

What about spawning multiple units? You can do that too, check this out
JASS:
struct BarracksFoot extends array
    private static constant real INTERVAL = 6           //6 interval spawn time
    private static constant integer ORIGIN = 'hbar'     //barracks
    private static constant integer SPAWN = 'hfoo'      //footman
    private static constant integer COUNT = 1           //count
    implement LightSpawn
endstruct
struct BarracksRif extends array
    private static constant real INTERVAL = 9           //9 interval spawn time
    private static constant integer ORIGIN = 'hbar'     //barracks
    private static constant integer SPAWN = 'hrif'      //footman
    private static constant integer COUNT = 1           //count
    implement LightSpawn
endstruct

Now barracks spawns 1 rifleman every 9 seconds and 1 footman every 5 seconds.

This is for super simple spawns only, like those you find in your typical footmen wars map =P.

This increases the map by 3kb per spawn because of the amount of code that is generated in the background, but that code is required to have the fastest spawns possible.

Again, the code is self managing, so you can just make a trigger and put all of your spawns into it and away you go =P. You don't have to understand the vjass code, just change the fields like I stated =P.

JASS:
struct SpawnName extends array
    private static constant real INTERVAL = 5           //how often to spawn, in this case every 5 seconds
    private static constant integer ORIGIN = 'hbar'     //unit type to spawn for, in this case human barracks
    private static constant integer SPAWN = 'hfoo'      //unit type to spawn, in this case footman
    private static constant integer COUNT = 1           //how many to spawn, in this case 1
    implement LightSpawn
endstruct

You can make the SpawnName w/e you like.


So if you upgrade a unit via upgrade, it still still spawn the right thing and at the right time. If you have DYNAMIC enabled and add an ability like chaos, it will still spawn the right thing : O (not quite at the right time tho sadly).

edit
Just realized that 2 things need to be fixed-
spawns shouldn't spawn at dead units (will fix this)
and the previous bug that Bribe actually brought up in an im ^)^ (Dynamic mode only)
It will take me like 5 mins to fix them, will start in prob 5 mins o-o.

Also, this does require vjass
http://www.hiveworkshop.com/forums/...ing-up-newgen-we-intro-trigger-editor-188349/
 
Status
Not open for further replies.
Top