Skip to content

Commit 7d89f09

Browse files
committed
Fixed game sometimes losing track of 'capture' task giver
1 parent 4b4a2b1 commit 7d89f09

4 files changed

Lines changed: 115 additions & 60 deletions

File tree

Optional Features/#1. (Choose From This Folder First)/No Enemy Map Spots/gamedata/scripts/sim_squad_generic.script

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ function sim_squad_generic:init_squad_task()
754754
local tm = task_manager.get_task_manager()
755755
local squad_faction_name = self.player_id
756756
local random_tasks = self.random_tasks
757+
local old_capture_task_1 = random_tasks[1]
758+
local old_capture_task_2 = random_tasks[2]
757759
local recover_task = random_tasks[3]
758760
local squad_smart_id = self.smart_id
759761
local squad_smart = board.smarts[squad_smart_id].smrt
@@ -763,26 +765,42 @@ function sim_squad_generic:init_squad_task()
763765
random_tasks = {}
764766
self.random_tasks = random_tasks
765767

766-
if board:get_smart_population(squad_smart) > 1 or (board_factions[squad_faction_name].precondition_targets[squad_smart_id] == nil and smart_under_attack(squad_faction_name, board_factions, squad_smart_id) == false) then
767-
if self:get_script_target() == nil and not tm:get_tasks_by_smart(squad_smart_id) then
768-
local level_cluster = sim_board.sim_level_cluster
769-
local squad_smart_cluster = level_cluster[squad_smart.smart_level]
770-
for neighbor_smart_id, neighbor_smart in pairs (board:get_nearest_smarts(squad_smart)) do
771-
if level_cluster[neighbor_smart.smart_level] == squad_smart_cluster then
772-
if sim_board.is_point_avail(neighbor_smart, squad_faction_name) then
773-
local neighbor_faction_name = neighbor_smart.player_name
774-
if neighbor_faction_name ~= "none" then
775-
if game_relations.is_factions_enemies(squad_faction_name, neighbor_faction_name) then
776-
if smart_under_attack(neighbor_faction_name, board_factions, neighbor_smart_id) == false then
777-
local neighbor_smart_task = tm:get_tasks_by_smart(neighbor_smart_id)
778-
if not neighbor_smart_task or neighbor_smart_task.base_prior <= 1 then -- only permits replacing 'generic' eliminate tasks with capture tasks
779-
task = tm:select_task("capture_smart", neighbor_smart, squad_faction_name)
780-
task.src_obj = self.squad_id
781-
if random_tasks[1] == nil then
782-
random_tasks[1] = task.entity_id
783-
elseif random_tasks[2] == nil then
784-
random_tasks[2] = task.entity_id
785-
break
768+
if old_capture_task_1 ~= nil then
769+
task = tm:get_task_by_entity_id(old_capture_task_1)
770+
if task and task.status == "selected" then
771+
random_tasks[1] = old_capture_task_1
772+
end
773+
end
774+
775+
if old_capture_task_2 ~= nil then
776+
task = tm:get_task_by_entity_id(old_capture_task_2)
777+
if task and task.status == "selected" then
778+
random_tasks[#random_tasks + 1] = old_capture_task_2
779+
end
780+
end
781+
782+
if random_tasks[2] == nil then
783+
if board:get_smart_population(squad_smart) > 1 or (board_factions[squad_faction_name].precondition_targets[squad_smart_id] == nil and smart_under_attack(squad_faction_name, board_factions, squad_smart_id) == false) then
784+
if self:get_script_target() == nil and not tm:get_tasks_by_smart(squad_smart_id) then
785+
local level_cluster = sim_board.sim_level_cluster
786+
local squad_smart_cluster = level_cluster[squad_smart.smart_level]
787+
for neighbor_smart_id, neighbor_smart in pairs (board:get_nearest_smarts(squad_smart)) do
788+
if level_cluster[neighbor_smart.smart_level] == squad_smart_cluster then
789+
if sim_board.is_point_avail(neighbor_smart, squad_faction_name) then
790+
local neighbor_faction_name = neighbor_smart.player_name
791+
if neighbor_faction_name ~= "none" then
792+
if game_relations.is_factions_enemies(squad_faction_name, neighbor_faction_name) then
793+
if smart_under_attack(neighbor_faction_name, board_factions, neighbor_smart_id) == false then
794+
local neighbor_smart_task = tm:get_tasks_by_smart(neighbor_smart_id)
795+
if not neighbor_smart_task or neighbor_smart_task.base_prior <= 1 then -- only permits replacing 'generic' eliminate tasks with capture tasks
796+
task = tm:select_task("capture_smart", neighbor_smart, squad_faction_name)
797+
task.src_obj = self.squad_id
798+
if random_tasks[1] == nil then
799+
random_tasks[1] = task.entity_id
800+
else
801+
random_tasks[2] = task.entity_id
802+
break
803+
end
786804
end
787805
end
788806
end

Optional Features/#2. (Choose From This Folder Last)/Show Only Ally Map Spots/gamedata/scripts/sim_squad_generic.script

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,8 @@ function sim_squad_generic:init_squad_task()
756756
local tm = task_manager.get_task_manager()
757757
local squad_faction_name = self.player_id
758758
local random_tasks = self.random_tasks
759+
local old_capture_task_1 = random_tasks[1]
760+
local old_capture_task_2 = random_tasks[2]
759761
local recover_task = random_tasks[3]
760762
local squad_smart_id = self.smart_id
761763
local squad_smart = board.smarts[squad_smart_id].smrt
@@ -765,26 +767,42 @@ function sim_squad_generic:init_squad_task()
765767
random_tasks = {}
766768
self.random_tasks = random_tasks
767769

768-
if board:get_smart_population(squad_smart) > 1 or (board_factions[squad_faction_name].precondition_targets[squad_smart_id] == nil and smart_under_attack(squad_faction_name, board_factions, squad_smart_id) == false) then
769-
if self:get_script_target() == nil and not tm:get_tasks_by_smart(squad_smart_id) then
770-
local level_cluster = sim_board.sim_level_cluster
771-
local squad_smart_cluster = level_cluster[squad_smart.smart_level]
772-
for neighbor_smart_id, neighbor_smart in pairs (board:get_nearest_smarts(squad_smart)) do
773-
if level_cluster[neighbor_smart.smart_level] == squad_smart_cluster then
774-
if sim_board.is_point_avail(neighbor_smart, squad_faction_name) then
775-
local neighbor_faction_name = neighbor_smart.player_name
776-
if neighbor_faction_name ~= "none" then
777-
if game_relations.is_factions_enemies(squad_faction_name, neighbor_faction_name) then
778-
if smart_under_attack(neighbor_faction_name, board_factions, neighbor_smart_id) == false then
779-
local neighbor_smart_task = tm:get_tasks_by_smart(neighbor_smart_id)
780-
if not neighbor_smart_task or neighbor_smart_task.base_prior <= 1 then -- only permits replacing 'generic' eliminate tasks with capture tasks
781-
task = tm:select_task("capture_smart", neighbor_smart, squad_faction_name)
782-
task.src_obj = self.squad_id
783-
if random_tasks[1] == nil then
784-
random_tasks[1] = task.entity_id
785-
elseif random_tasks[2] == nil then
786-
random_tasks[2] = task.entity_id
787-
break
770+
if old_capture_task_1 ~= nil then
771+
task = tm:get_task_by_entity_id(old_capture_task_1)
772+
if task and task.status == "selected" then
773+
random_tasks[1] = old_capture_task_1
774+
end
775+
end
776+
777+
if old_capture_task_2 ~= nil then
778+
task = tm:get_task_by_entity_id(old_capture_task_2)
779+
if task and task.status == "selected" then
780+
random_tasks[#random_tasks + 1] = old_capture_task_2
781+
end
782+
end
783+
784+
if random_tasks[2] == nil then
785+
if board:get_smart_population(squad_smart) > 1 or (board_factions[squad_faction_name].precondition_targets[squad_smart_id] == nil and smart_under_attack(squad_faction_name, board_factions, squad_smart_id) == false) then
786+
if self:get_script_target() == nil and not tm:get_tasks_by_smart(squad_smart_id) then
787+
local level_cluster = sim_board.sim_level_cluster
788+
local squad_smart_cluster = level_cluster[squad_smart.smart_level]
789+
for neighbor_smart_id, neighbor_smart in pairs (board:get_nearest_smarts(squad_smart)) do
790+
if level_cluster[neighbor_smart.smart_level] == squad_smart_cluster then
791+
if sim_board.is_point_avail(neighbor_smart, squad_faction_name) then
792+
local neighbor_faction_name = neighbor_smart.player_name
793+
if neighbor_faction_name ~= "none" then
794+
if game_relations.is_factions_enemies(squad_faction_name, neighbor_faction_name) then
795+
if smart_under_attack(neighbor_faction_name, board_factions, neighbor_smart_id) == false then
796+
local neighbor_smart_task = tm:get_tasks_by_smart(neighbor_smart_id)
797+
if not neighbor_smart_task or neighbor_smart_task.base_prior <= 1 then -- only permits replacing 'generic' eliminate tasks with capture tasks
798+
task = tm:select_task("capture_smart", neighbor_smart, squad_faction_name)
799+
task.src_obj = self.squad_id
800+
if random_tasks[1] == nil then
801+
random_tasks[1] = task.entity_id
802+
else
803+
random_tasks[2] = task.entity_id
804+
break
805+
end
788806
end
789807
end
790808
end

SRP v1.1.4 - Version History.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ v1.1.4
1616
+ Fixed the issue where the player would be rejected from playing the shooting minigame if their money precisely matches the entry fee instead of exceeding it. - Decane
1717
+ Fixed an SRP v1.1.3 (or v1.0.2 with the optional 'No NPC Weapon Tossing Upon Death' feature) regression that prevented killed NPCs from ever dropping a grenade. - Decane
1818
+ Fixed an SRP v1.1.3 regression that caused some NPCs to keep repeating their goodbye phrase ad nauseum until the player faces away from them after closing their dialogue window. - Decane
19+
+ Fixed an SRP v1.1.1 regression that caused the game to forget the squad from which the player accepted a 'capture' task via dialogue under certain circumstances. - Decane
1920
+ Fixed an SRP v1.0.4 regression that caused several dialogue options to be erroneously unavailable when speaking to generic mercenary NPCs, including Hog's subordinates at the Army Warehouses and Leshiy's subordinates at the Red Forest. - Decane
2021
+ Fixed an SRP v1.0.3 regression that caused Yoga's walkie-talkie transmissions to the player to sound as if Yoga were speaking to the player in person rather than over walkie-talkie. - Decane
2122
+ Worked around an SRP v1.0.3 regression introduced by the Dunin Ammo Aggregation mod that caused ammo unloaded from a weapon to disappear under certain circumstances. - Decane, Alex Rinic

gamedata/scripts/sim_squad_generic.script

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,8 @@ function sim_squad_generic:init_squad_task()
756756
local tm = task_manager.get_task_manager()
757757
local squad_faction_name = self.player_id
758758
local random_tasks = self.random_tasks
759+
local old_capture_task_1 = random_tasks[1]
760+
local old_capture_task_2 = random_tasks[2]
759761
local recover_task = random_tasks[3]
760762
local squad_smart_id = self.smart_id
761763
local squad_smart = board.smarts[squad_smart_id].smrt
@@ -765,26 +767,42 @@ function sim_squad_generic:init_squad_task()
765767
random_tasks = {}
766768
self.random_tasks = random_tasks
767769

768-
if board:get_smart_population(squad_smart) > 1 or (board_factions[squad_faction_name].precondition_targets[squad_smart_id] == nil and smart_under_attack(squad_faction_name, board_factions, squad_smart_id) == false) then
769-
if self:get_script_target() == nil and not tm:get_tasks_by_smart(squad_smart_id) then
770-
local level_cluster = sim_board.sim_level_cluster
771-
local squad_smart_cluster = level_cluster[squad_smart.smart_level]
772-
for neighbor_smart_id, neighbor_smart in pairs (board:get_nearest_smarts(squad_smart)) do
773-
if level_cluster[neighbor_smart.smart_level] == squad_smart_cluster then
774-
if sim_board.is_point_avail(neighbor_smart, squad_faction_name) then
775-
local neighbor_faction_name = neighbor_smart.player_name
776-
if neighbor_faction_name ~= "none" then
777-
if game_relations.is_factions_enemies(squad_faction_name, neighbor_faction_name) then
778-
if smart_under_attack(neighbor_faction_name, board_factions, neighbor_smart_id) == false then
779-
local neighbor_smart_task = tm:get_tasks_by_smart(neighbor_smart_id)
780-
if not neighbor_smart_task or neighbor_smart_task.base_prior <= 1 then -- only permits replacing 'generic' eliminate tasks with capture tasks
781-
task = tm:select_task("capture_smart", neighbor_smart, squad_faction_name)
782-
task.src_obj = self.squad_id
783-
if random_tasks[1] == nil then
784-
random_tasks[1] = task.entity_id
785-
elseif random_tasks[2] == nil then
786-
random_tasks[2] = task.entity_id
787-
break
770+
if old_capture_task_1 ~= nil then
771+
task = tm:get_task_by_entity_id(old_capture_task_1)
772+
if task and task.status == "selected" then
773+
random_tasks[1] = old_capture_task_1
774+
end
775+
end
776+
777+
if old_capture_task_2 ~= nil then
778+
task = tm:get_task_by_entity_id(old_capture_task_2)
779+
if task and task.status == "selected" then
780+
random_tasks[#random_tasks + 1] = old_capture_task_2
781+
end
782+
end
783+
784+
if random_tasks[2] == nil then
785+
if board:get_smart_population(squad_smart) > 1 or (board_factions[squad_faction_name].precondition_targets[squad_smart_id] == nil and smart_under_attack(squad_faction_name, board_factions, squad_smart_id) == false) then
786+
if self:get_script_target() == nil and not tm:get_tasks_by_smart(squad_smart_id) then
787+
local level_cluster = sim_board.sim_level_cluster
788+
local squad_smart_cluster = level_cluster[squad_smart.smart_level]
789+
for neighbor_smart_id, neighbor_smart in pairs (board:get_nearest_smarts(squad_smart)) do
790+
if level_cluster[neighbor_smart.smart_level] == squad_smart_cluster then
791+
if sim_board.is_point_avail(neighbor_smart, squad_faction_name) then
792+
local neighbor_faction_name = neighbor_smart.player_name
793+
if neighbor_faction_name ~= "none" then
794+
if game_relations.is_factions_enemies(squad_faction_name, neighbor_faction_name) then
795+
if smart_under_attack(neighbor_faction_name, board_factions, neighbor_smart_id) == false then
796+
local neighbor_smart_task = tm:get_tasks_by_smart(neighbor_smart_id)
797+
if not neighbor_smart_task or neighbor_smart_task.base_prior <= 1 then -- only permits replacing 'generic' eliminate tasks with capture tasks
798+
task = tm:select_task("capture_smart", neighbor_smart, squad_faction_name)
799+
task.src_obj = self.squad_id
800+
if random_tasks[1] == nil then
801+
random_tasks[1] = task.entity_id
802+
else
803+
random_tasks[2] = task.entity_id
804+
break
805+
end
788806
end
789807
end
790808
end

0 commit comments

Comments
 (0)