| 02-01-2012, 02:01 AM | #1 |
I need to method in which I can respawn all monsters in an area. - Occurs when all players die - Respawns exact same creatures - Only respawns those that are dead, monsters that are not cleared remain untouched Im not looking for a specific trigger, just the steps to be taken in order to acheive this. |
| 02-01-2012, 06:11 AM | #2 |
When monster dies you save it's stats: For each dead monster save units type GetUnitTypeId, Units x, units y and units facing. The death trigger for this is registered for every unit in monster area, so at the map initialization group monsters in monster area and add them to monster onDeath-saveStats trigger. Make a struct for monster stats you need, than make an array for those structs. When some event happens (all players die) go through whole array and respawn monsters using stats. Delete stats for each monster you respawn. |
| 02-01-2012, 06:18 AM | #3 | |
Quote:
I have the stat bit covered. What irks me however what would be the most effecien method of checking what monsters need to respawned and which are still alive. Ignore that, I re read what you said and kinda get what youre getting at. If theres anymore problems ill just keep updating this. |
| 02-01-2012, 06:21 AM | #4 |
I already explained that. On map init register death events to monsters in monster area. Those that did not fire a death trigger are probably still alive ![]() (Those are specific unit events, not player unit events) |
| 02-01-2012, 07:10 AM | #5 |
Ok, I need to make them respawn at their original location. Hence i need to save their location somehow at the game start? |
| 02-01-2012, 07:18 AM | #6 |
I presume the units are preplaced and that this is for some RPG monster area? You are having problems with this because you are doing GUI. This is like 2 min of work in jass. And if you have multiple monster areas this is practically nightmare to do in GUI. |
| 02-01-2012, 07:34 AM | #7 | |
Quote:
Yes the units are preplaced. Basically the problem I ran into is that I cant seem to register their initial starting points, everything else works. But since you said this is 2 mins of JASS work, provide with me some basic code. I can sort myself out from there. |
| 02-01-2012, 07:51 AM | #8 |
JASS:library Respawner private struct Data real x real y real face integer unitId endstruct //=============================================================== // called on map startup for each unit that needs to respawn //=============================================================== public function addUnit takes unit u returns nothing local Data data = Data.create() set data.x = GetUnitX(u) set data.y = GetUnitY(u) set data.face = GetUnitFacing(u) set data.unitId = GetUnitTypeId(u) call SetUnitUserData(u, data) endfunction //=============================================================== // called by on-death trigger for each neutral hostile unit? //=============================================================== public function respawnUnit takes unit u returns nothing local Data data = GetUnitUserData(u) local unit respawn call TriggerSleepAction(RESPAWN_TIME) set respawn = CreateUnit(NH_PLAYER, data.unitId, data.x, data.y, data.face) call SetUnitUserData(respawn, data) set respawn = null endfunction endlibrary |
| 12-30-2013, 07:32 PM | #9 | |
Quote:
Stop. Stop what you are doing. JASS is not necessary for this. This can be done as easy as pie in GUI with no memory leaks. Let me walk you through it (I won't bother with the triggers) First off, call up every creature you have preplaced (I assume they are all of the same player control) Then you need to set each individual creatures position to a variable(x), the specific coordinates create the value Then you need to set each individual creature to another variable(x) of the same number as their position variable AND set their custom value to said number Then create a death trigger thats goes something like "When a creature dies (condition: creature is owned by player CREEP), WAIT until (a trigger which states all players are dead fires) and respawn variable(x) custom value and variable(x) coordinates You can do this with all sorts of changes but this is the general gist |
