Malice-
Endlessly Known
- Reaction score
- 38
I found a good JASS Code by Vex from wc3sear.ch, only thing is, I'm not sure how to call it. I got the variables you need down, and I know the event is map initilization, but what is the action to call the code?
This may serve no purpose, but here is the code:
This may serve no purpose, but here is the code:
Code:
function CreepRespawn_CampLength takes nothing returns real
return 500.0
endfunction
function CreepRespawn_WaitTime takes nothing returns real
return 60.0
endfunction
function CreepRespawn takes nothing returns gamecache
if (udg_creepcamps==null) then
set udg_creepcamps=InitGameCache("creepcamps.c")
endif
return udg_creepcamps
endfunction
function CreepRespawn_H2I takes handle h returns integer
return h
return 0
endfunction
function CreepRespawn_GetCamp takes gamecache g, string k returns group
return GetStoredInteger(g,k,"camp")
return null
endfunction
function RespawnCreepCamp takes nothing returns nothing
local unit u=GetTriggerUnit()
local string k=I2S(CreepRespawn_H2I(u))
local integer typeid = GetUnitTypeId(u)
local gamecache g=CreepRespawn()
local group camp=CreepRespawn_GetCamp(g,k)
local real x=GetStoredReal(g,k,"sx")
local real y=GetStoredReal(g,k,"sy")
local real f=GetStoredReal(g,k,"sf")
local rect r=bj_mapInitialPlayableArea
if not( HaveStoredReal(g,k,"sx") ) then
else
call GroupRemoveUnit(camp,u)
loop
exitwhen FirstOfGroup(camp)==null
call TriggerSleepAction(1)
endloop
call PolledWait(CreepRespawn_WaitTime())
if IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) then
call SetUnitOwner( u, Player(1), false)
call ReviveHero( u, x, y, true)
call SetUnitOwner( u, Player(12), false)
call GroupAddUnit(camp,u)
else
call FlushStoredMission(g,k)
set u=CreateUnit( Player(12), typeid, x,y,f )
set k=I2S(CreepRespawn_H2I(u))
call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl", u, "origin"))
call StoreReal( g ,k,"sx", x )
call StoreReal( g ,k,"sy", y )
call StoreReal( g ,k,"sf", f )
call StoreInteger(g,k,"camp",CreepRespawn_H2I(camp) )
call GroupAddUnit(camp,u)
endif
endif
set camp=null
set u=null
set g=null
set r=null
endfunction
function StartCreepCampRespawn_Filter takes nothing returns boolean
return IsUnitOwnedByPlayer( GetFilterUnit(), Player(12) ) and IsUnitInGroup(GetFilterUnit(),bj_groupRemoveGroupDest)
endfunction
function StartCreepCampRespawn takes nothing returns trigger
local trigger t = CreateTrigger()
local gamecache g=CreepRespawn()
local boolexpr B=Condition(function StartCreepCampRespawn_Filter)
local group r=CreateGroup()
local group aux=CreateGroup()
local group aux2=CreateGroup()
local group c
local unit u
local string k
call GroupEnumUnitsOfPlayer(r,Player(12), null)
set bj_groupRemoveGroupDest=r
loop
set u=FirstOfGroup(r)
exitwhen u==null
call GroupRemoveUnit(r,u)
set c=CreateGroup()
set bj_groupAddGroupDest=c
call GroupClear(aux)
loop
call GroupClear(aux2)
call GroupEnumUnitsInRange(aux2,GetUnitX(u),GetUnitY(u),CreepRespawn_CampLength(),B)
call GroupAddGroup(aux2,aux)
call GroupRemoveUnit(aux,u)
call GroupRemoveUnit(r,u)
call GroupAddUnit(c,u)
set k=I2S(CreepRespawn_H2I(u))
call StoreReal( g ,k,"sx", GetUnitX(u) )
call StoreReal( g ,k,"sy", GetUnitY(u) )
call StoreReal( g ,k,"sf", GetUnitFacing(u) )
call StoreInteger(g,k,"camp",CreepRespawn_H2I(c) )
set u=FirstOfGroup(aux)
exitwhen u==null
endloop
endloop
call DestroyGroup(r)
call DestroyGroup(aux)
call DestroyGroup(aux2)
call DestroyBoolExpr(B)
set B=null
set r=null
set aux=null
set aux2=null
call TriggerRegisterPlayerUnitEvent( t, Player(12), EVENT_PLAYER_UNIT_DEATH,null )
call TriggerAddAction( t, function RespawnCreepCamp )
return t
endfunction


