From 6468f9647b1f455387697d7d9fdb8a002f4f07e2 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Tue, 2 Feb 2021 19:46:11 +0100 Subject: [PATCH] sandbox: autogame castle storming. Work around that the AI won't build Castles by placing castles at the start of the game so "Capture Extras" gets autogame testing. See osdn Ticket #41434 --- data/sandbox/script.lua | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/data/sandbox/script.lua b/data/sandbox/script.lua index a54ec0a846..9ee34aef8b 100644 --- a/data/sandbox/script.lua +++ b/data/sandbox/script.lua @@ -374,7 +374,34 @@ function place_map_labels() return false end -signal.connect("map_generated", "place_map_labels") +-- Add random castles at mountain tops. +function place_ancient_castle_ruins() + -- Test castle storming in autogames even if the AI won't build them. + -- Narrative excuse: The game starts in 4000 BC. The builders of the + -- castles must have drowned - taking their advanced technology with them. + + for place in whole_map_iterate() do + local terr = place.terrain + local tname = terr:rule_name() + + if (tname == "Mountains") and (random(1, 100) <= 5) then + place:create_extra("Fort") + place:create_extra("Fortress") + place:create_extra("Castle") + end + end + + return false +end + +-- Modify the generated map +function modify_generated_map() + place_map_labels() + place_ancient_castle_ruins() + return false +end + +signal.connect("map_generated", "modify_generated_map") -- Only notifications needs Lua function notify_unit_unit(action, actor, target) -- 2.20.1