SCAR ERROR Callstack:
Lua city_centre_2.scar"] Ln 438 (_BonusObjective_Civs_Timer)
23:32:53.48 GameObj:nFatalScarError: [[string "DATAcenarios\city_centre_2.scar"]:438: attempt to call global 'Entity_kill' (a nil value)]
Here's my current code (note: I removed the SGroup_IsUnderAttack, but receive the same error with Entity_Kill):
function _BonusObjective_Civs_Init()
-- Start civilian rescue bonus objective
Objective_Start(OBJ_Bonus_Civilians)
-- Set up up encounters
Rule_AddDelayedInterval(BONUS_CIVS_Encounters_Init, 1.5, 1)
end
function BONUS_CIVS_Encounters_Init()
if Objective_IsStarted(OBJ_Bonus_Civilians) then
Rule_RemoveMe()
--World_IncreaseInteractionStage()
sg_bonus_civs_e_all = SGroup_CreateIfNotFound("sg_bonus_civs_e_all")
BONUS_CIVS_Enemy_01()
BONUS_CIVS_Enemy_02()
EGroup_SetSelectable(eg_bonus_civs_building, true)
-- Spawn the units
sg_bonus_civs_a_all = SGroup_CreateIfNotFound("sg_bonus_civs_a_all")
Util_CreateSquads(player3, sg_bonus_civs_a_all, SBP.SOVIET.BASE_CONSCRIPT_SQUAD, eg_bonus_civs_building)
Util_CreateSquads(player3, sg_bonus_civs_a_all, SBP.SOVIET.BASE_CONSCRIPT_SQUAD, eg_bonus_civs_building)
--Util_CreateSquads(player3, sg_bonus_civs_a_all, SBP.SOVIET.BASE_CONSCRIPT_SQUAD, eg_bonus_civs_building)
Modify_WeaponDamage(sg_bonus_civs_a_all, "hardpoint_01", 0)
EGroup_EnableUIDecorator(eg_bonus_civs_building, false)
SGroup_SetInvulnerable(sg_bonus_civs_a_all, true)
--Event_GroupLeftAlive(_Bonus_Civs_Retreat_Enemies, nil, sg_bonus_civs_e_all, 3)
end
end
function _BonusObjective_Civs_Timer()
-- Check if both enemy groups are dead
if SGroup_TotalMembersCount(sg_bonus_civs_e_01) <= 0 and SGroup_TotalMembersCount(sg_bonus_civs_e_02) <= 0 then
Rule_RemoveMe()
return
end
-- first check to see if the timer is active
if Timer_Exists(tmr_bonus) then
-- Check the remaining time and check if any civilians have been under attack within the next 3 seconds
if Timer_GetRemaining(tmr_bonus) <= 0 then
-- -- select a random civlian squad
local sid = SGroup_GetRandomSpawnedSquad(sg_bonus_civs_a_all)
-- count remaining civilians in chosen squad
local count = Squad_Count(sid)
-- returns a random integer between 1 and the remaining civilians in the chosen squad
local index = World_GetRand(1, count)
-- select the random integer of civilians minus 1 to kill
local eid = Squad_EntityAt(sid, (index-1))
-- kill selected civilians from randomly chosen civilian squad
Entity_kill(eid)
--SGroup_Kill(sid)
-- Update the Objective_SetCounter
Objective_SetCounter(OBJ_Bonus_Civs_Loss, SGroup_TotalMembersCount(sg_bonus_civs_a_all))
Timer_End(tmr_bonus)
end
-- Rule if the timer is inactive
elseif Timer_Exists(tmr_bonus) == false then
-- check if all civilians are dead
if SGroup_TotalMembersCount(sg_bonus_civs_a_all) <= 0 then
Rule_RemoveMe()
Rule_Remove(_BonusObjective_Civs_Rescued)
-- enemies are victorious. They retreat back to the city centre
-- Cmd_Retreat(sg_bonus_civs_e_01, mkr_bonus_civs_e_retreat, mkr_bonus_civs_e_retreat)
-- Cmd_Retreat(sg_bonus_civs_e_02, mkr_bonus_civs_e_retreat, mkr_bonus_civs_e_retreat)
-- all civilians are dead, the objective is failed
Objective_Fail(OBJ_Bonus_Civilians)
return
end
-- restart the timer
Timer_Start(tmr_bonus, t_difficulty.death_rate)
end
end
I know that the SGroup is valid throughout this function because if I remove Entity_Kill the counter updates correctly with the number of troops in the SGroup "sg_bonus_civs_a_all", so I'm not sure why I'm receiving the nil value.
Any help would be greatly appreciated!
Thank you.