Login

russian armor

Nil value on SGroup_IsUnderAttack and Entity_Kill()

14 May 2019, 07:10 AM
#1
avatar of jcbarth

Posts: 24

I'm trying to recreate the Civilian Rescue objective from the first mission of the campaign. I've extracted the .scar file from the mission and have been following how it was set up for the game, however, when I try to run a SGroup_IsUnderAttack check on my civilian SGroup or try to kill some members of the squad using Entity_Kill I receive the following error message:

SCAR ERROR Callstack: 
Lua city_centre_2.scar"] Ln 438 (_BonusObjective_Civs_Timer)
23:32:53.48 GameObj::OnFatalScarError: [[string "DATA:Scenarios\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.
14 May 2019, 14:05 PM
#2
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

It's actually right there in the error:

attempt to call global 'Entity_kill' (a nil value)

The k in Entity_Kill should be upper case. So, the nil value refers to the fact that Entity_kill does not exist.
14 May 2019, 16:02 PM
#3
avatar of jcbarth

Posts: 24

Oh my god. Thank you! I can't believe I didn't see that. Really appreciate your help.
14 May 2019, 16:16 PM
#4
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

Sometimes it's the simplest thing. :)

Glad to be of help.
1 user is browsing this thread: 1 guest

SHOUT IT OUT!

No ProfanityNumber of ShoutsRefresh Shout Box
Willy Pete: @Rosbone not dead yet. when that happens the font will switch to Papyrus :*(
Today, 00:16 AM
dasheepeh: it was an honor guys :guyokay:
Yesterday, 20:34 PM
aerafield: yeah I already prepared my "Can't believe there's comic mode for the 10 daily visitors even on this April 1st" :guyokay:
Yesterday, 20:29 PM
Rosbone: @dasheepeh I guess that means this site is officially dead :guyokay:
Yesterday, 20:19 PM
dasheepeh: no comic sans font for april 1st this year?
Yesterday, 19:56 PM
Willy Pete: @Lady Xenarra this you? https://i.imgflip.com/3e4thi.jpg
Yesterday, 02:53 AM
Lady Xenarra: Does anyone else think that USF needs buffs? It feels like they’re on life support sometimes
Yesterday, 02:36 AM
Willy Pete: @Rosbone Ahh I missed that memo. I still think its a bad decision though. Adds frustration for players and isnt gonna make them that much money
Last Thursday, 15:46 PM
Rosbone: It is also good they left it free until after the free to play weekend. Points for that.
Last Thursday, 09:34 AM
Rosbone: But I agree, the cost to get a full decent Coh game pushing $115 US is not the best idea. Especially when it needs so much more work for casuals.
Last Thursday, 09:32 AM
Rosbone: To be fair, it was a thank you to early fans right? They said it was not free for long and it would become a pay DLC at some point.
Last Thursday, 09:30 AM
Willy Pete: Re-releasing free DLC so they can charge new players money for it. Brilliant marketing strategy :clap:
Last Thursday, 04:31 AM
Soheil: Coh2 still broken server ?
25 Mar 2025, 18:27 PM
Rosbone: Congrats to Relic. Looks like Coh3 has finally usurped Coh2 s the popular Coh. You smell terrific. :snfQuinn:.
24 Mar 2025, 02:46 AM
Nickbn: and again someone else replies. I mean come on guys. Give @adamírcz a chance
22 Mar 2025, 14:00 PM
Willy Pete: @Nickbn you didn't ask a question, and this is a chat box...
20 Mar 2025, 13:11 PM
Nickbn: @Rosbone it's incredibly rude to speak on someone elses behalf, especially when a question is directly adressed to them. I understand your passion for the subject at hand but I want to hear from him.
20 Mar 2025, 10:16 AM
Rosbone: @Nickbn No, I am just saying people should not be using any Relic owned forum since they have proven they ban anyone who says true things about Coh3.
18 Mar 2025, 19:01 PM
Nickbn: @Rosbone do you speak on his behalf? I didn't know. In that case keep us updated please.
18 Mar 2025, 16:47 PM
Rosbone: #RelicModdedEchoChamber
16 Mar 2025, 17:54 PM

Livestreams

unknown 0
unknown 12
Russian Federation 6

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

287 users are online: 287 guests
1 post in the last 24h
11 posts in the last week
81 posts in the last month
Registered members: 53137
Welcome our newest member, DJ Dingbat
Most online: 2043 users on 29 Oct 2023, 01:04 AM