| 04-07-2003, 02:37 PM | #1 |
This may have been asked before. I am making a map which needs to restore the creeps (all the original ones) of the map in one single instant. Preferbly when each creep is recreated I can attach a special effect to it. How do I go about doing this? Do I use unit groups? |
| 04-07-2003, 04:04 PM | #2 |
1 way is to make a unit array, and set each unit to a spot in the array. You would also need to create regions of the starting spots of the creeps. Not at the editor so i cant look up exact triggers, but it should be possable to create a region on the fly and store the coords in a array also. Then you would need to run a loop to create 1 type of unit in Unit[X] at Location[X]. Creating mass units at the same time does result in game lag (stop and go while the units are created) |
| 04-08-2003, 01:00 AM | #3 |
Thanks for helping. I'll see what can be done about it, during my holidays that is...examinations are around the corner. I went to look at the available triggers and realised that it would become very tedious to manually store every creep's location in the array, I don't have a lot of time to slowly get that done now. ://// |
| 04-08-2003, 01:27 AM | #4 |
Just had an idea that may make this easier... Not sure if it will work though. Create a trigger with the event that a unit owned by neutral hostile (creeps) dies. Then have an integer variable (initially 0) that store your location. For the actions save the location of the unit to an array (using the integer). Next save the unit-type to another array (not sure how to do this - maybe use an array of unit types) then save that in a second array. increment the index. Then use a periodic trigger to cycle through the arrays and restore the units : For example: (not sure on the accuracy of the triggers as I dont have the editor open - just to give a basic idea) Event: unit owned by neutral hostile dies Action: location_array[i] = location of dying unit creep_array[i] = unit-type of dying unit i = i +1 trigger 2: Event: every 60 seconds action: for all a in 0 to (i-1) //use i-1 because i is one past the end of the array (i=i+1 at the end) do action create 1 unit of creep_array(a) at location_array(a) Not sure if this works, but its something to think about. Hope this helps, SheepOfDoom |
| 04-08-2003, 01:40 AM | #5 |
donno if you would want to revive it at the spot the unit died at, probably best to mark its origin spot |
| 04-08-2003, 01:51 AM | #6 |
Dakan is right, if you are creeping and you start running, then eventually kill the unit a little ways away it might look awkward when it is respawned. Because after it is respawned it won't know to move back to it's original spot. Unless you make a trigger that moves them periodically, but that's more effort than needed. |
| 04-08-2003, 02:47 AM | #7 |
Yeah good point. Not sure how you could save the origin of the creep though.. The best way I can think of is to create general origin regions around each creep group, and then assigning all units in the region to that unit group (using the unit group add unit group trigger). Then when a creep dies you can check which unit group it was in and hence store the origin. Ie: (example triggers - not sure of exact commands) if (dying unit) is a member of unitgroup origin 1 then location[i] = origin_1 if (dying unit) is a member of unitgroup origin 2 then location[i] = origin_2. etc This should work to set the origins of each group of creeps. You may also like to use an action to make the newly created creeps face the correct direction. Hope this helps, SheepOfDoom |
| 04-08-2003, 03:14 AM | #8 |
heres somthing even more simple that you could do: first create a Point Array variable (called CreepPos[] here) create a Unit-Type Array variable (CreepType[]) create a Integer variable (CreepIndex) (you'll have to conert to custom text to get the multipule actions in the PickEveryUnit(...) ) Code:
Events:
- Elpased Time is 2 seconds
Condtions:
- None
Actions:
- Set CreepIndex = 0
- PickEveryUnit OwnedBy (Neutral Hostile) AndDo
- Set CreepPos[CreepIndex] = PositionOf(PickedUnit)
- Set CreepType[CreepIndex] = UnitTypeOf(PickedUnit)
- Set CreepIndex = CreepIndex + 1then when you want to bring them back just do: Code:
for(0 to CreepIndex) do
- CreateUnitFacingAngle(1,CreepType[IndexA], (Neutral Hostile), CreepPos[IndexA],0)if you want to add special effects just run another for loop from 0 to CreepIndex. |
| 04-08-2003, 05:05 AM | #9 |
If a creep hasn't been killed in the time period won't it create an identical creep next to it? This is because all the creeps are stored in the array, not just the dead ones. To use that method you will need to do a check to see if the unit is dead before replacing it. ie: put an if unit is dead condition in the second trigger. Hope this helps, SheepOfDoom |
| 04-08-2003, 05:11 AM | #10 |
1 if to add, since the unit array should contain the creep its self, If(unit[i] == dead (dont know the exact code off hand, its part of the boolean checks) then perform the create new at the origin point, and set the new unit in the array = to that last created unit. else do nothing |
| 04-08-2003, 09:23 AM | #11 |
Wow these are all very helpful! My sincere thanks to all! First allow me to explain the purpose of restoring the creeps. I am making this map which i call "Be the Creeps!" At the start of the map, a player may choose to be the "Creep Master" by volunteering to be it, if no one volunteers at the end of the time-out, the game becomes a standard melee. The creep master will have a creep tech tree and is should be considered neutral hostile. He is every player's enemy but cannot be defeated because his main town hall is invulnerable. When the creep master has teched high enough, he gets to build the "Creep Rally Horn" which when activated allows him to control all the creeps on the map for 100 secs. The creep master may expand his army by defeating the creeps on the map as per normal. Every creep he defeats will cause that creep to join him. Creep heroes cannot be revived and will drop all items when they are killed. Basically the idea of this map is to put a brain behind the neutral hostile. After playing this map with friends for a few rounds, I realised that the Creep Rally Horn becomes useless when the players kills off all the creeps on the map. Therefore I am thinking of changing the horn's effect to restoring all the slain creeps. Any comments on improvements to this concept is completely welcomed! |
| 04-09-2003, 08:06 AM | #12 |
Ok, I've decided to implement the following: When a creep dies, it will be added to a queue and a timer of 60 secs will start. When the timer expires the first creep of the queue will be dequeued and created at it's original location. Currently I've used a point array and a unit type array, storing the position of the dying unit in the former and the dying unit type in the latter. It turned out that storing the position of the unit's death is not a good idea because the unit will be created at the point of it's death, and this is often not at it's original location. I've thought of using 2 more arrays for reference, one will store the original locations while the other stores the unit itself. When a creep dies, do a search in the unit array to get the index and use this index to look up the original location. This seems very inefficient though. Is there a more efficient way to make the creeps spawn back at their original locations? |
| 04-10-2003, 10:37 PM | #13 |
Any suggestions? Please? :bgrun: |
| 04-20-2003, 10:52 AM | #14 |
I've did what was adviced, having an array of units and an array of points to store the creeps and their locations respectively. I did not convert to text but used this instead for the Pick every unit trigger Unit Group - Pick every unit in (units owned by Neutral Hostile) and run trigger Log Creep Location In trigger Log Creep Location: Actions: Set CreepLog(CreepIndex) = Picked Unit Set CreepLocation(CreepIndex) = Location of Picked Unit Set CreepIndex = CreepIndex + 1 When I wanted to revive the dead ones: For each integer A From 0 to CreepIndex do run trigger Revive 1 Dead Creep, check conditions In trigger Revive 1 Dead Creep: Condition - CreepLog(integer A) is alive = false Action - - Create 1 Unit Type of CreepLog(integer A) for Neutral Hostile in CreepLocation((integer A) - Remove CreepLog(integer A) from the game - Set CreepLog(integer A) = Last Created Unit - Create special effects on the last created unit I now face a problem, sometimes the units do not get created even though they are dead. I made a trigger to display the name of the unit created in the trigger "Revive 1 dead creep" and got something like this: Gnoll Poacher created. Gnoll Poacher created. created. created. created. Gnoll Overseer created. Gnoll Overseer created. etc. It seems as though the unit creation of some of them was attempted but what ever the program saw in the array wasn't unit data at all. I am confused as I do not see any logical error with the triggering. Also, when the point where the creep was supposed to be created was blocked, it appeared that no unit was created in that spot. Does this count as that unit that is supposed to be created is alive or dead? |
| 04-20-2003, 11:13 AM | #15 |
Guest | There is an easier way to restore all of the units. Just use this in a JASS script Code:
call CreateNeutralHostile() |
