Decane / SRP

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

Scripts may lose track of 'capture' tasks taken via dialogue in corner case #152

Closed Decane closed 1 year ago

Decane commented 1 year ago

This Steam thread alerted me to the possibility that a squad's random_tasks table may, under some very specific circumstances, erroneously be cleared of in-progress 'capture' tasks assigned to the player via dialogue, which can cause the logic that should fail the 'capture' task upon the squad perishing:

https://github.com/Decane/SRP/blob/4b4a2b132bc71884d58d10e61190eef1d6b18abd/gamedata/scripts/sim_board.script#L438-L442

... to be erroneously skipped, leaving the task active indefinitely with no possibility of completion.

E.g. suppose the player asks a CS squad stationed at the Machine Yard for work while another CS squad is also stationed there. While the dialogue window is open, a 'defend' task targeting the Machine Yard is auto-received. But the player has already been offered a list of tasks in the open dialogue window, and one of them happens to be a 'capture' task targeting the 'Encampment near truck'. The player accepts. But the task giver squad cannot start moving toward the truck, since the Machine Yard is the target of a defend task:

https://github.com/Decane/SRP/blob/4b4a2b132bc71884d58d10e61190eef1d6b18abd/gamedata/scripts/sim_squad_generic.script#L598

And since the squad is still idle:

https://github.com/Decane/SRP/blob/4b4a2b132bc71884d58d10e61190eef1d6b18abd/gamedata/scripts/task_dialogs.script#L27

... the player can still ask the squad leader for work. So he does. And this causes that squad's random_tasks table to be cleared:

https://github.com/Decane/SRP/blob/4b4a2b132bc71884d58d10e61190eef1d6b18abd/gamedata/scripts/sim_squad_generic.script#L765-L766

But crucially, it does so without immediately repopulating it with already-given 'capture' tasks again, because of this line:

https://github.com/Decane/SRP/blob/4b4a2b132bc71884d58d10e61190eef1d6b18abd/gamedata/scripts/sim_squad_generic.script#L769

... which demands that no combat task is active against the smart terrain the squad is stationed on.

Decane commented 1 year ago

Fixed in https://github.com/Decane/SRP/commit/7d89f093a237cfe6df629e0fe8b7fccbf0f83fbb.