• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Not if it leaks or not?

Status
Not open for further replies.
Level 9
Joined
May 31, 2010
Messages
366
Not sure if it leaks or not?

hey, i want to use this system in my map: http://www.hiveworkshop.com/forums/...-138658/?prev=search=raise%20dead&d=list&r=20
i don't care about the raise dead spell.
i'm after the respawn system and i'm afraid that it would leak or cause any oher errors.
i'm planning to create an rpg map and want the enemys to respawn, could this system cause any errors when it respawned to many units? i mean you could propably spend 4 hours on the map just killing enemys and i'm afraid that it could crash the game? i don't know that much about leaks so just want to minimize errors where i can :D
also i'm bothered that the system has a maximum number of units it can detect on initializing for respawn (lets say there is a maximum for an array of 8192) would it crash the map if there is 1 more unit on the map?
 
Last edited:
Level 9
Joined
May 31, 2010
Messages
366
i cant use jass, i mean i'm not able to make a written jass system fitting my needs (i have absolutly no understanding of jass) so i need a gui version

also have another question:
  • Set MovePoint = (Center of Portal 1 Out <gen>)
  • Custom script: call RemoveLocation(udg_MovePoint)
would this leak? i mean i use the center of region function anyways when i set the variable?
 
i cant use jass, i mean i'm not able to make a written jass system fitting my needs (i have absolutly no understanding of jass) so i need a gui version
You can use it without GUI knowledge. Just use custom script:

  • Set TempUnit = Unit
  • Custom Script: call UnitEnableRevive(udg_TempUnit, true)
Create a GUI variable called "TempUnit" and set it to a unit before using this script to register it to the system.

In the system, you can set the revive time of units in this line:
private constant real DURATION = 30 // default respawn time
 
Last edited:
Level 14
Joined
Aug 30, 2004
Messages
909
I can't use JASS either. Could you give some more detail on what you want? Here are some options I have in mind, if you like one I could help you with more details. Do they respawn where they die or somewhere else? Does it have to be the same unit, or can it just be a unit of the same unit-type (i.e. do these units gain abilities, levels, or other traits you want to preserve?)

1. This is complicated, but you could make a trigger that fires whenever a unit dies. Check to see if the unit is in "respawnImmediately" unit group. If it is in that unit group, respawn, show it immediately and remove it from the unitgroup. (this will make sense in a minute). If it's not in that unit group, create a respawn unit wherever you want the unit to respawn. Then hide this unit and attach a generic expiration timer set to the time it should respawn.

In theory it should work like this. A footman dies. He is not in "respawnImmediately". Your trigger then creates a new footman at the point where he will respawn, hides this new unit, and attaches an expiration timer. When that timer runs out, the hidden footman dies...and because it's in the "respawnImmediately" group, it will be created and revealed at the new location.

This is complicated because you want to avoid using a giant Timer array variable, or using a custom timers system.

2. You could create an invisible unit with the resurrect ability (set to a very low range) and having a very long cast time. When a unit dies, this invisible unit pops up and starts casting resurrect...but because the cast time is so long it will be delayed. This obviously only works if they need to respawn at the location of their death.

3. You could store the spawned units in a unit group (a different unit group for every type of spawn...e.g. maybe one for the northern monsters). Every few seconds, check the unitgroup for dead units, remove them and revive as needed.

4. You could give them all the reincarnate ability with a very low cooldown. Detect it's casting with a trigger and move them.
 
Level 9
Joined
May 31, 2010
Messages
366
they shall respawn after 60 seconds, on the point where i placed them in the editor, it can be a new unit, i need a system that don't leaks so i avoid using unitgroups - not sure if that matters in this case

the system i posted does exactly what i wanted it to do, but when it causes huge leaks i'm not sure if i want to use it - at least when i try to upload the map here on hive it would be deleted cuz of huge leaks i belive

i tried some respawn by my self but never had any effort when i tried to get it work :D

reincarnation ability won't work cuz when you "kill" a unit that has reincarnate it wont give you exp or bounty
 
i don't really get it, but i will try :D
What exactly did you not understand about my post? Just use the two trigger lines I posted and it will work.

  • Set TempUnit = Unit
  • Custom Script: call UnitEnableRevive(udg_TempUnit, true)
Do this for every unit you want to revive. Done.
 
Level 14
Joined
Aug 30, 2004
Messages
909
Here it is:

http://www.hiveworkshop.com/forums/pastebin_data/8k11fz/_files/respawn system.w3x

There are three triggers, you'll need them all. Basically, make regions for all the places you want to spawn enemies. Number them for convenience. Then make a point array variable: spawnPoints. Set these points to the center of all the regions you want to spawn in, so that spawnPoints[1] = center of region1. Then set the custom value of all the units you have to the number of the region they should respawn in.

Be sure to put in extra conditions to the triggers to make sure the right units do what they're supposed to do (i.e. if the player walks a unit into one of those regions it will tell it to attack the paladin). You can also add a special effect on the unit after you unhide it; just be sure to destroy the special effect so it doesn't leak.
 
Level 9
Joined
May 31, 2010
Messages
366
Here it is:

http://www.hiveworkshop.com/forums/pastebin_data/8k11fz/_files/respawn system.w3x

There are three triggers, you'll need them all. Basically, make regions for all the places you want to spawn enemies. Number them for convenience. Then make a point array variable: spawnPoints. Set these points to the center of all the regions you want to spawn in, so that spawnPoints[1] = center of region1. Then set the custom value of all the units you have to the number of the region they should respawn in.

Be sure to put in extra conditions to the triggers to make sure the right units do what they're supposed to do (i.e. if the player walks a unit into one of those regions it will tell it to attack the paladin). You can also add a special effect on the unit after you unhide it; just be sure to destroy the special effect so it doesn't leak.


that will be a lot of work doing this manually but okay i will see if i can handle this system :D thx!


i will also try the option Zwiebelchen mentioned, i will let you guys know on monday what i did and if it worked :D
 
while using the jass system or while using the gui system i posted?
i just copy the system into my map, select all 3.000 units one by one with the two triggers and it's done?
You can also just pick every unit owned by player neutral hostile and place this inside the loop:
  • Custom Script: call UnitEnableRevive(GetEnumUnit(), true)
 
Level 14
Joined
Aug 30, 2004
Messages
909
Zweibelchen, he wants them to respawn where they first appeared. Your command wouldn't do that, I don't believe.

Cryze666, I recommend just looking at what I did and you should get a sense of how it works. The key elements are:
- regions where the units spawn
- a point array variable that stores the center of all of those regions
- setting the unit's custom value to integer corresponding to the region you want them to respawn in.

The way my system works, as soon as a unit dies, it respawns but I hide it immediately. It then waits 30 seconds and unhides.
 
Zweibelchen, he wants them to respawn where they first appeared. Your command wouldn't do that, I don't believe.
True that.

Meh, here's a very quickly written respawn system that does everything automaticly and uses the original X,Y and Facing values of preplaced units:

Just drop it in your map and you're done. Respawn timer is 60 seconds by default. Enjoy!

JASS:
library respawn initializer init

globals
  //Configurable
  private constant real RESPAWN_TIME = 60

  private constant hashtable HASH = InitHashtable()
endglobals

private function register takes unit u returns nothing
  call SaveInteger(HASH, GetHandleId(u), 0, GetUnitTypeId(u))
  call SaveReal(HASH, GetHandleId(u), 1, GetUnitX(u))
  call SaveReal(HASH, GetHandleId(u), 2, GetUnitY(u))  
  call SaveReal(HASH, GetHandleId(u), 3, GetUnitFacing(u))
endfunction

private function callback takes nothing returns nothing
  local timer t = GetExpiredTimer()
  local integer id = LoadInteger(HASH, GetHandleId(t), 0)
  call register(CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), LoadInteger(HASH, id, 0), LoadReal(HASH, id, 1), LoadReal(HASH, id, 2), LoadReal(HASH, id, 3)))
  call FlushChildHashtable(HASH, GetHandleId(t))
  call FlushChildHashtable(HASH, id)
  call DestroyTimer(t)
  set t = null
endfunction

private function onDeath takes nothing returns boolean
  local timer t = CreateTimer()
  local integer id = GetHandleId(GetTriggerUnit())
  if HaveSavedInteger(HASH, GetHandleId(GetTriggerUnit()), 0) then
    //only revive registered units
    call SaveInteger(HASH, GetHandleId(t), 0, id)
    call TimerStart(t, RESPAWN_TIME, function callback)
  endif
  set t = null
  return false
endfunction

private function init takes nothing returns nothing
  local group g = CreateGroup()
  local trigger t = CreateTrigger()
  local unit u = 0
  call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_AGGRESSIVE), null)
  loop
    set u = FirstOfGroup()
    exitwhen u == null
    call register(u)
    call GroupRemoveUnit(g, u)
  endloop
  call DestroyGroup(g)
  call TriggerRegisterPlayerUnitEvent(t, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH, null)
  call TriggerAddCondition(t, Condition(function onDeath))
  set t = null
  set g = null
endfunction

endlibrary
 
Status
Not open for further replies.
Top