You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Optional Features/#1. (Choose From This Folder First)/No Enemy Map Spots/gamedata/scripts/sim_squad_generic.script
+13-10Lines changed: 13 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@ local monster_num_by_resource = {
23
23
24
24
local math_random = math.random
25
25
local math_ceil = math.ceil
26
+
local table_remove = table.remove
26
27
27
28
class "sim_squad_generic"
28
29
@@ -542,25 +543,27 @@ local function pave_way_off_smart(board, front, archive)
542
543
local num_front = #front
543
544
for i = 1, num_front do
544
545
local front_smart = front[i]
546
+
local front_smart_owner = front_smart.owner
545
547
for neighbor_smart_id, neighbor_smart in pairs (board:get_nearest_smarts(front_smart.smart)) do
546
-
if archive[neighbor_smart_id] == nil and sim_board.is_point_avail(neighbor_smart, front_smart.owner) then
548
+
if front_smart_owner ~= "none" and archive[neighbor_smart_id] == nil and sim_board.is_point_avail(neighbor_smart, front_smart_owner) then
547
549
archive[neighbor_smart_id] = true
548
550
local neighbor_smart_owner = neighbor_smart.player_name
549
551
local friends_at_neighbor
550
-
if neighbor_smart_owner == "none" or game_relations.is_factions_enemies(front_smart.owner, neighbor_smart_owner) then
-- dbglog("Booting squad '%s' from smart '%s' with population %d, friendly movers %d, and sim_avail [%s] to smart '%s' with population %d and friendly movers %d", step_squad.squad_id, smart_names.get_smart_terrain_name(step.smart), board:get_smart_population(step.smart), board:get_smart_squad_quantity(step.smart, board.players[step_squad.player_id]), tostring(step.smart.sim_avail), smart_names.get_smart_terrain_name(step_target), board:get_smart_population(step_target), board:get_smart_squad_quantity(step_target, board.players[step_squad.player_id]))
563
-
step.smart.sim_avail = {{section = "false", infop_check = {}, infop_set = {}}} -- pseudo-hack to temporarily make the smart left by step_squad unavailable for unwanted visitors in case a race condition would otherwise send them there
-- dbglog("Booting squad '%s' from smart '%s' with population %d, friendly movers %d, and sim_avail [%s] to smart '%s' with population %d and friendly movers %d", step_squad.squad_id, smart_names.get_smart_terrain_name(step_smart), board:get_smart_population(step_smart), board:get_smart_squad_quantity(step_smart, board.players[step_squad.player_id]), tostring(step_smart.sim_avail), smart_names.get_smart_terrain_name(step_target), board:get_smart_population(step_target), board:get_smart_squad_quantity(step_target, board.players[step_squad.player_id]))
566
+
step_smart.sim_avail = {{section = "false", infop_check = {}, infop_set = {}}} -- pseudo-hack to temporarily make the smart left by step_squad unavailable for unwanted visitors in case a race condition would otherwise send them there
564
567
--[[
565
568
-- TODO: Is this necessary? Maybe e.g. if step_squad is in combat when booted off their smart...
566
569
-- Update: Nope. Combat manager unregistration is done in sim_attack_point:make() if necessary, and step_squad.current_action is guaranteed to be nil or sim_stay_point, which doesn't need finalization. TODO: Check: Also, not necessary to set current_action to nil from sim_stay_point.
@@ -574,7 +577,7 @@ local function pave_way_off_smart(board, front, archive)
Copy file name to clipboardExpand all lines: Optional Features/#2. (Choose From This Folder Last)/Show Only Ally Map Spots/gamedata/scripts/sim_squad_generic.script
+15-11Lines changed: 15 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,8 @@ local monster_num_by_resource = {
23
23
24
24
local math_random = math.random
25
25
local math_ceil = math.ceil
26
+
local string_sub = string.sub
27
+
local table_remove = table.remove
26
28
27
29
class "sim_squad_generic"
28
30
@@ -542,25 +544,27 @@ local function pave_way_off_smart(board, front, archive)
542
544
local num_front = #front
543
545
for i = 1, num_front do
544
546
local front_smart = front[i]
547
+
local front_smart_owner = front_smart.owner
545
548
for neighbor_smart_id, neighbor_smart in pairs (board:get_nearest_smarts(front_smart.smart)) do
546
-
if archive[neighbor_smart_id] == nil and sim_board.is_point_avail(neighbor_smart, front_smart.owner) then
549
+
if front_smart_owner ~= "none" and archive[neighbor_smart_id] == nil and sim_board.is_point_avail(neighbor_smart, front_smart_owner) then
547
550
archive[neighbor_smart_id] = true
548
551
local neighbor_smart_owner = neighbor_smart.player_name
549
552
local friends_at_neighbor
550
-
if neighbor_smart_owner == "none" or game_relations.is_factions_enemies(front_smart.owner, neighbor_smart_owner) then
-- dbglog("Booting squad '%s' from smart '%s' with population %d, friendly movers %d, and sim_avail [%s] to smart '%s' with population %d and friendly movers %d", step_squad.squad_id, smart_names.get_smart_terrain_name(step.smart), board:get_smart_population(step.smart), board:get_smart_squad_quantity(step.smart, board.players[step_squad.player_id]), tostring(step.smart.sim_avail), smart_names.get_smart_terrain_name(step_target), board:get_smart_population(step_target), board:get_smart_squad_quantity(step_target, board.players[step_squad.player_id]))
563
-
step.smart.sim_avail = {{section = "false", infop_check = {}, infop_set = {}}} -- pseudo-hack to temporarily make the smart left by step_squad unavailable for unwanted visitors in case a race condition would otherwise send them there
-- dbglog("Booting squad '%s' from smart '%s' with population %d, friendly movers %d, and sim_avail [%s] to smart '%s' with population %d and friendly movers %d", step_squad.squad_id, smart_names.get_smart_terrain_name(step_smart), board:get_smart_population(step_smart), board:get_smart_squad_quantity(step_smart, board.players[step_squad.player_id]), tostring(step_smart.sim_avail), smart_names.get_smart_terrain_name(step_target), board:get_smart_population(step_target), board:get_smart_squad_quantity(step_target, board.players[step_squad.player_id]))
567
+
step_smart.sim_avail = {{section = "false", infop_check = {}, infop_set = {}}} -- pseudo-hack to temporarily make the smart left by step_squad unavailable for unwanted visitors in case a race condition would otherwise send them there
564
568
--[[
565
569
-- TODO: Is this necessary? Maybe e.g. if step_squad is in combat when booted off their smart...
566
570
-- Update: Nope. Combat manager unregistration is done in sim_attack_point:make() if necessary, and step_squad.current_action is guaranteed to be nil or sim_stay_point, which doesn't need finalization. TODO: Check: Also, not necessary to set current_action to nil from sim_stay_point.
@@ -574,7 +578,7 @@ local function pave_way_off_smart(board, front, archive)
-- dbglog("Reinstating sim_avail setting for smart '%s' to [%s]", smart_names.get_smart_terrain_name(smart_data[1]), tostring(smart_data[2]))
@@ -593,7 +597,7 @@ local function pave_way_off_smart(board, front, archive)
593
597
end
594
598
end
595
599
for i = 1, num_front do
596
-
table.remove(front, 1)
600
+
table_remove(front, 1)
597
601
end
598
602
if #front == 0 then
599
603
-- dbglog("Algorithm failed to unblock faction war!")
@@ -1314,7 +1318,7 @@ function sim_squad_generic:refresh()
1314
1318
return
1315
1319
end
1316
1320
local actor = db.actor
1317
-
local actor_faction = string.sub(actor and actor:character_community() or alife():actor():community(), 7)-- actor faction always named 'actor_*', so to match '*', get sub-string from index 7
1321
+
local actor_faction = string_sub(actor and actor:character_community() or alife():actor():community(), 7)-- actor faction always named 'actor_*', so to match '*', get sub-string from index 7
-- dbglog("Booting squad '%s' from smart '%s' with population %d, friendly movers %d, and sim_avail [%s] to smart '%s' with population %d and friendly movers %d", step_squad.squad_id, smart_names.get_smart_terrain_name(step.smart), board:get_smart_population(step.smart), board:get_smart_squad_quantity(step.smart, board.players[step_squad.player_id]), tostring(step.smart.sim_avail), smart_names.get_smart_terrain_name(step_target), board:get_smart_population(step_target), board:get_smart_squad_quantity(step_target, board.players[step_squad.player_id]))
565
-
step.smart.sim_avail = {{section = "false", infop_check = {}, infop_set = {}}} -- pseudo-hack to temporarily make the smart left by step_squad unavailable for unwanted visitors in case a race condition would otherwise send them there
-- dbglog("Booting squad '%s' from smart '%s' with population %d, friendly movers %d, and sim_avail [%s] to smart '%s' with population %d and friendly movers %d", step_squad.squad_id, smart_names.get_smart_terrain_name(step_smart), board:get_smart_population(step_smart), board:get_smart_squad_quantity(step_smart, board.players[step_squad.player_id]), tostring(step_smart.sim_avail), smart_names.get_smart_terrain_name(step_target), board:get_smart_population(step_target), board:get_smart_squad_quantity(step_target, board.players[step_squad.player_id]))
568
+
step_smart.sim_avail = {{section = "false", infop_check = {}, infop_set = {}}} -- pseudo-hack to temporarily make the smart left by step_squad unavailable for unwanted visitors in case a race condition would otherwise send them there
566
569
--[[
567
570
-- TODO: Is this necessary? Maybe e.g. if step_squad is in combat when booted off their smart...
568
571
-- Update: Nope. Combat manager unregistration is done in sim_attack_point:make() if necessary, and step_squad.current_action is guaranteed to be nil or sim_stay_point, which doesn't need finalization. TODO: Check: Also, not necessary to set current_action to nil from sim_stay_point.
@@ -576,7 +579,7 @@ local function pave_way_off_smart(board, front, archive)
0 commit comments