HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Need help making a unit spawn trigger

10-11-2008, 09:09 PM#1
Zenislev
Hello there, thanks in advance for your time, I appreciate it . It's been a while since I've done mapping for Warcraft 3, so I'm just getting back into it. Currently, I'm making an "Enfo's" type map (everyone is on the same team however trying to defeat the enemy computer's big base). So, of course, the main part of the map is having a spawn system that spawns loads of enemy units and sends them attacking the players' collective base. To accomplish that task, I wrote the following trigger:

Trigger:
FrWaSpawn1
Collapse Events
Time - Every (0.60 + (Random real number between 0.00 and 1.00)) seconds of game time
Conditions
Collapse Actions
Unit - Create 1 Skeleton Warrior for Player 12 (Brown) at (Center of Front Spawn 1 <gen>) facing Default building facing (270.0) degrees
Special Effect - Create a special effect attached to the overhead of (Last created unit) using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
Unit - Order (Last created unit) to Attack-Move To (Center of WP A1 <gen>)

There are two of these spawn triggers for each mob type (and three mob types). This is because there are two paths the enemies take to get to the players' base. To get to the players' base that they defend, the enemy mobs must navigate a series of waypoints that brings them through the layout of the map. Here is the trigger for the waypoints:

Trigger:
WayA1
Collapse Events
Unit - A unit enters WP A1 <gen>
Collapse Conditions
(Owner of (Entering unit)) Equal to Player 12 (Brown)
Collapse Actions
Unit - Order (Entering unit) to Attack-Move To (Center of WP A2 <gen>)

These triggers seem simple enough, but there is a problem. The game runs smoothly for about a minute or two, spawning mobs and sending them on their way. However, in a few minutes the units that are spawned start having a delay before they move out of the spawn, and pretty soon all of the computer player's units on the map that have been ordered to move somewhere are twitching in place with each additional unit that is spawned. So my question is, how can I fix this problem without reducing the number of units that I spawn? Because the point of the map is that you're fighting an epic number of units. Anyway, thanks again for your time; I look forward to reading your responses .

Edited to add trigger tags.
10-12-2008, 01:27 AM#2
Anopob
1. Use [trigger] tags. They help.
Trigger:
FrWaSpawn1
Collapse Events
Time - Every (0.60 + (Random real number between 0.00 and 1.00)) seconds of game time
Conditions
Collapse Actions
Unit - Create 1 Skeleton Warrior for Player 12 (Brown) at (Center of Front Spawn 1 <gen>) facing Default building facing (270.0) degrees
Special Effect - Create a special effect attached to the overhead of (Last created unit) using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
Unit - Order (Last created unit) to Attack-Move To (Center of WP A1 <gen>)
Trigger:
WayA1
Collapse Events
Unit - A unit enters WP A1 <gen>
Collapse Conditions
(Owner of (Entering unit)) Equal to Player 12 (Brown)
Collapse Actions
Unit - Order (Entering unit) to Attack-Move To (Center of WP A2 <gen>)
2. You're creating HUGE amounts of units, and I understand you want an epic number (but that's more like spam, anyway), but you need to cut them short. The other alternative is knowing how to remove memory leaks. Basically, make a point type-variable and assign it to the trigger. In other words when you create the skeleton, do "create unit at X VARIABLE" instead of that thing. Look in the tutorial section for more info on memory leaks, can't explain everything here. After that, use custom script to remove the location.

Also, remember to remove your special effects. From what I understand your problem isn't lag but you're creating many units and effects so it could have a problem with that and the trigger's actions don't have enough time to register.

Hope that helped in the way I think it did. Good luck!
10-12-2008, 01:33 AM#3
Kino
Like Anobop said you need a point variable, and need to unleak it later
Set YourVariable = Point in YourRegion
Create 1 YourUnit at YourVariable facing blablahblah point/degrees.
The custom script would be "call RemoveLocation(udg_YourVariable)
10-12-2008, 02:48 AM#4
Zenislev
Thank you very much for the replies, it's good to know that there may be a way to keep it so that there's loads of enemy units attacking. I'll look into those suggestions that you both gave. I assumed it had something to do with the volume of units it was creating but didn't know whether it could be fixed. I'll reply again with the results of trying this method out.
10-12-2008, 12:53 PM#5
Bobo_The_Kodo
If theres too many units moving owned by a player, they will all only move every little while, and they get stuck and stuff.

Either make the units owned by random people on the team, or don't create that many units
10-13-2008, 12:29 AM#6
Zenislev
Alright, I consulted this tutorial, and the problem seems to have ceased. Thanks again for your help . Here's the current version of the trigger:

Trigger:
FrWaSpawn1
Collapse Events
Time - Every (0.60 + (Random real number between 0.00 and 1.00)) seconds of game time
Collapse Conditions
(Number of units in (Units owned by Player 12 (Brown))) Less than 150
Collapse Actions
Set spawn_frontleft = (Center of Front Spawn 1 <gen>)
Set WayA1 = (Center of WP A1 <gen>)
Unit - Create 1 Skeleton Warrior for Player 12 (Brown) at spawn_frontleft facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Attack-Move To WayA1
Custom script: call RemoveLocation (udg_spawn_frontleft)
Custom script: call RemoveLocation (udg_WayA1)

Everything seems to be running smoothly now, but I'll reply to this thread if I encounter any more problems. I'll also be checking this thread periodically to see if anyone has posted tips or anything like that. Seeya for now though