Decane / SRP

Sky Reclamation Project for S.T.A.L.K.E.R.: Clear Sky
http://www.moddb.com/mods/srp
124 stars 20 forks source link

Crash because of "Insufficient smart terrain jobs for NPC" #143

Closed HeavyLiquid closed 2 years ago

HeavyLiquid commented 2 years ago

I have been using SRP version 1.1.3 and have experienced no issues so far until I decided to go back to Dark Valley.

FATAL ERROR

[error]Expression : fatal error [error]Function : CScriptEngine::lua_error [error]File : E:\priquel\sources\engine\xrServerEntities\script_engine.cpp [error]Line : 180 [error]Description : [error]Arguments : LUA error: ...lker clear sky\gamedata\scripts\smart_terrain.script:457: [se_smart_terrain:update_npc_jobs]: >Insufficient smart terrain jobs for NPC '13494' on smart 'val_smart_terrain_9_6'.

I tried waiting and going to another area and then go back to Garbage>Dark Valley in the hopes that the NPC would have moved to another place but to no avail. Also tried to find the "XRayEngine_error_report" .zip file but couldn't locate despite Clear Sky being installed on my main drive. Here's the X-Ray Log: xray_gustavo.log .

Decane commented 2 years ago

@HeavyLiquid Thanks for posting your crashlog. Can you also upload a save from which the crash can be reproduced?

There are 14 generic stalker jobs on val_smart_terrain_9_6 of which 11 are reserved by NPCs in your game. The 12th NPC on that smart terrain is unable to reserve one of the remaining three available jobs:

[5] =
{
  ['_precondition_function'] = <function: 3ADE0C68>,
  ['_precondition_params'] =
  {
    ['changing_job'] = 'logic@val_smart_terrain_9_6_guard_1_walk',
  },
  ['job_id'] = 84,
  ['_prior'] = 24,
},
[6] =
{
  ['_precondition_function'] = <function: 3ADE0C68>,
  ['_precondition_params'] =
  {
    ['changing_job'] = 'logic@val_smart_terrain_9_6_guard_2_walk',
  },
  ['job_id'] = 85,
  ['_prior'] = 24,
},
[7] =
{
  ['_precondition_function'] = <function: 3ADE0C68>,
  ['_precondition_params'] =
  {
    ['changing_job'] = 'logic@val_smart_terrain_9_6_guard_3_walk',
  },
  ['job_id'] = 86,
  ['_prior'] = 24,
},

These are all guard shift switch jobs, where an NPC takes over the guard role from another NPC.

Considering that the squad capacity of the smart terrain is only 2, there should be a maximum of 2 * 5 = 10 NPCs stationed there, not 12 as in your game. Hopefully your save will shed some light on how so many NPCs ended up there.

HeavyLiquid commented 2 years ago

Oh my bad, I completely forgot about the save.

Clear Sky save.zip

Decane commented 2 years ago

Thanks for the save.

I see what's going on: configs\scripts\darkvalley\val_space_restrictor_2_2_freedom.ltx spawns val_smart_terrain_2_2_freedom at val_smart_terrain_9_6 without first ensuring there is 'room' for them there.

To make matters worse, there's another logic script that pointlessly duplicates this functionality: val_space_restrictor_squad_2_2_exist.ltx.

The fix is to edit the aforementioned scripts to have the following contents:

[sr_idle@start] on_info = nil

[sr_idle@timer] on_game_timer = 50 | nil

[sr_idle] on_info = nil

- val_space_restrictor_2_2_freedom.ltx

[logic] active = sr_idle

[sr_idle] on_info = {+val_destroy_killer_base_done} nil on_info2 = {+val_killer_base_is_no_more} nil on_info3 = {+val_killer_1_3_dead} nil %=clear_smart_terrain(val_smart_terrain_9_6) =create_squad(val_smart_terrain_2_2_freedom:val_smart_terrain_9_6)%

HeavyLiquid commented 2 years ago

Oh my god it worked with my save just fine! Thank you so much for your help @Decane ! This whole thing made me learn more about how STALKER files behave and are structured.

Decane commented 2 years ago

Fixed in https://github.com/Decane/SRP/commit/6ee4738bce3aeb92e2a259730c10e94323104f6a.