- Joined
- Feb 26, 2005
- Messages
- 210
I'm makeing a creep respawn system for my map, Lost Temple Advanced. It should work in two triggers, but the problem is the actual respawning. Look here:
The second trigger is in JASS:
What this is supposed to do is check every x seconds after a unit dies for any "Pests". "Pests" being units within a y-size radius which meet the following conditions:
a) Not controlled by Neutral Hostile.
b) Not dead.
c) Not a Sentry Ward (Sentry Wards are exluded since they can more-than-easily prevent creep respawning).
If the number of Pests is 0, then the creep respawns at its original location with the old unit's facing angle and aqusitation range.
However, this is not working when more than one unit is dead at the same time. How do I solve the problem?
-
Load Creep Locations
-
Events
- Map initialization
- Conditions
-
Actions
- Set G = (Units owned by Neutral Hostile)
-
Unit Group - Pick every unit in G and do (Actions)
-
Loop - Actions
- Set V = (V + 1)
- Unit - Set the custom value of (Picked unit) to V
- Set CreepLoc[(Custom value of (Picked unit))] = (Position of (Picked unit))
- Set CreepAngle[(Custom value of (Picked unit))] = (Facing of (Picked unit))
- Set CreepRange[(Custom value of (Picked unit))] = (Current acquisition range of (Picked unit))
-
Loop - Actions
-
Events
The second trigger is in JASS:
JASS:
function IsCreep takes nothing returns boolean
if GetOwningPlayer(GetDyingUnit()) == Player(12) and IsUnitType(GetDyingUnit(), UNIT_TYPE_SUMMONED) == false then
return true
else
return false
endif
endfunction
function IsPest takes nothing returns boolean
if GetOwningPlayer(GetFilterUnit()) != Player(12) and IsUnitAliveBJ(GetFilterUnit()) == true and GetUnitTypeId(GetFilterUnit()) != 'oeye' then
return true
else
return false
endif
endfunction
function RespawnCreep takes nothing returns nothing
local integer i = GetUnitUserData(GetDyingUnit())
local group g
local boolexpr b = Condition(function IsPest)
set udg_CreepDead[i] = true
loop
exitwhen (udg_CreepDead[i] == false)
call TriggerSleepAction(5.00)
set g = GetUnitsInRangeOfLocMatching(500.00, udg_CreepLoc[i], b)
if CountUnitsInGroup(g) == 0 then
call CreateNUnitsAtLoc(1, GetUnitTypeId(GetDyingUnit()), Player(12), udg_CreepLoc[i], udg_CreepAngle[i])
call SetUnitAcquireRangeBJ(GetLastCreatedUnit(), udg_CreepRange[i])
call SetUnitUserData(GetLastCreatedUnit(), GetUnitUserData(GetDyingUnit()))
set udg_CreepDead[GetUnitUserData(GetDyingUnit())] = false
endif
set g = null
endloop
endfunction
//===========================================================================
function InitTrig_Creep_Respawn takes nothing returns nothing
set gg_trg_Creep_Respawn = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Creep_Respawn, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Creep_Respawn, Condition( function IsCreep ) )
call TriggerAddAction( gg_trg_Creep_Respawn, function RespawnCreep )
endfunction
a) Not controlled by Neutral Hostile.
b) Not dead.
c) Not a Sentry Ward (Sentry Wards are exluded since they can more-than-easily prevent creep respawning).
If the number of Pests is 0, then the creep respawns at its original location with the old unit's facing angle and aqusitation range.
However, this is not working when more than one unit is dead at the same time. How do I solve the problem?