From 161fae4531155995a209b7b304d53cce438ef8c5 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Thu, 11 Feb 2021 19:56:03 +0100 Subject: [PATCH] sandbox: test Unit:teleport() via a user action. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the user action "Use Ancient Transportation Network", the extra "Ancient Transport Hub" and the small wonder "Amêzârâkian Mysteries" to sandbox. "Ancient Transport Hub" are placed on the map before the game starts. A unit can do "Use Ancient Transportation Network" when located at a tile with an "Ancient Transport Hub" and targeting a tile with an "Ancient Transport Hub" if its player has "Amêzârâkian Mysteries". An "Ancient Transport Hub" becomes visible when Polytheism is discovered. It becomes possible to pillage an "Ancient Hub" after that. It becomes possible to use it once the player builds the small wonder "Amêzârâkian Mysteries". "Amêzârâkian Mysteries" requires Polytheism to build. The action has unlimited max range. It isn't possible to reverse engineer and build an "Ancient Transport Hub". Targeting unseen tiles A target tile without an "Ancient Transport Hub" will lose the unit hit points - potentially killing it. A target tile with an "Ancient Hub" the unit can't exist on - say a land unit ending up in the sea or a ship ending up on land - kills the unit. See osdn #41557 --- data/sandbox/README.sandbox | 5 ++++ data/sandbox/buildings.ruleset | 26 ++++++++++++++++ data/sandbox/effects.ruleset | 10 +++++++ data/sandbox/game.ruleset | 21 +++++++++++++ data/sandbox/script.lua | 55 ++++++++++++++++++++++++++++++++++ data/sandbox/terrain.ruleset | 26 ++++++++++++++++ 6 files changed, 143 insertions(+) diff --git a/data/sandbox/README.sandbox b/data/sandbox/README.sandbox index 29210c15d0..ae2d02501c 100644 --- a/data/sandbox/README.sandbox +++ b/data/sandbox/README.sandbox @@ -161,6 +161,11 @@ Some units can disrupt the supply lines of enemy units. This removes 1 MP from the target unit at the cost of one move fragment for the unit doing the disrupting. +Ancient Transportation Network +You may find an Ancient Transport Hub on the map. If you find another and +build the small wonder "Amêzârâkian Mysteries" you will be able to move from +one of them to the other for free. + Casus belli Starting to do Pillage to a tile gives the tile owner (not the extra owner) a casus belli against you. diff --git a/data/sandbox/buildings.ruleset b/data/sandbox/buildings.ruleset index 32af4d3921..e99d1ab12f 100644 --- a/data/sandbox/buildings.ruleset +++ b/data/sandbox/buildings.ruleset @@ -826,6 +826,32 @@ Under Despotism the city containing the palace gains a +75% \ gold bonus, and under Monarchy a +50% gold bonus.\ ") +; "Amêzârâk taught all the conjurers and root-cutters," Book of Enok 8:3a +; (The Book of Enok is probably not found in your Bible unless you are a +; member of the Ethiopian or Eritrean Orthodox Tewahedo Church) +[building_mystery_school] +name = _("Amêzârâkian Mysteries") +rule_name = "Mysteries" +genus = "SmallWonder" +reqs = + { "type", "name", "range" + "Tech", "Polytheism", "Player" + } +graphic = "b.mystery_school" +graphic_alt = "b.temple" +obsolete_by = + { "type", "name", "range" + } +build_cost = 200 +upkeep = 0 +sabotage = 0 +sound = "b_mystery_school" +sound_alt = "b_temple" +helptext = _("\ +Initiates of The School of Amêzârâk knows how to operate an \ +Ancient Transport Hub.\ +") + [building_police_station] name = _("Police Station") genus = "Improvement" diff --git a/data/sandbox/effects.ruleset b/data/sandbox/effects.ruleset index 3e123f54ac..a939a3e445 100644 --- a/data/sandbox/effects.ruleset +++ b/data/sandbox/effects.ruleset @@ -4475,6 +4475,16 @@ reqs = "Action", "User Action 1", "Local", TRUE } +; The initiates of The School of Amêzârâk refuses to state where they got +; their knowledge, from who or what was expected in return. +[effect_action_illegal_use_ancient_transportation_network] +type = "Illegal_Action_HP_Cost" +value = 10 +reqs = + { "type", "name", "range", "present" + "Action", "User Action 2", "Local", TRUE + } + [effect_action_success_move_cost_bombard] type = "Action_Success_Actor_Move_Cost" value = 65535 diff --git a/data/sandbox/game.ruleset b/data/sandbox/game.ruleset index b53643f33b..120537f175 100644 --- a/data/sandbox/game.ruleset +++ b/data/sandbox/game.ruleset @@ -599,6 +599,13 @@ user_action_1_min_range = 1 user_action_1_max_range = 3 user_action_1_actor_consuming_always = FALSE +; /* TRANS: "Use Ancient Transportation Network"_ (100% chance of success). */ +ui_name_user_action_2 = _("%sUse Ancient Transportation Network%s") +user_action_2_target_kind = "tiles" +user_action_2_min_range = 1 +user_action_2_max_range = "unlimited" +user_action_2_actor_consuming_always = FALSE + ; Suppress automatic help text generation about what enables and/or ; disables the following actions. ; @@ -668,6 +675,20 @@ target_reqs = "UnitClass", "Missile", "Local", FALSE } +; Use Ancient Transportation Network +[actionenabler_ancient_transport_hub] +action = "User Action 2" +actor_reqs = + { "type", "name", "range", "present" + "Building", "Mysteries", "Player", TRUE + "Extra", "Ancient Transport Hub", "Local", TRUE + } +target_reqs = + { "type", "name", "range", "present" + "Extra", "Ancient Transport Hub", "Local", TRUE + "MaxUnitsOnTile", 0, "Local", TRUE + } + [actionenabler_sabotage_city] action = "Sabotage City" actor_reqs = diff --git a/data/sandbox/script.lua b/data/sandbox/script.lua index b8a33e2483..3f4e394eb0 100644 --- a/data/sandbox/script.lua +++ b/data/sandbox/script.lua @@ -395,10 +395,31 @@ function place_ancient_castle_ruins() return false end +-- Add random Ancient Transport Hub +function place_ancient_transport_hub() + -- Narrative excuse: The game starts in 4000 BC. Who knows what came + -- before the dark, formless void? + + for place in whole_map_iterate() do + local terr = place.terrain + local tname = terr:rule_name() + + if (tname == "Glacier") and (random(1, 1000) <= 9) then + -- adds up to 1% with the throw below + place:create_extra("Ancient Transport Hub") + elseif (not (tname == "Inaccessible")) and (random(1, 1000) <= 1) then + place:create_extra("Ancient Transport Hub") + end + end + + return false +end + -- Modify the generated map function modify_generated_map() place_map_labels() place_ancient_castle_ruins() + place_ancient_transport_hub() return false end @@ -436,3 +457,37 @@ function action_started_unit_unit_callback(action, actor, target) end signal.connect("action_started_unit_unit", "action_started_unit_unit_callback") + +-- Use Ancient Transportation Network +function transport_network(action, actor, target) + local actor_name = actor.utype:name_translation() + local survived = actor:teleport(target) + + if not survived then + notify.event(actor.owner, target, + E.UNIT_ACTION_ACTOR_FAILURE, + -- /* TRANS: Your Marines didn't survive doing + -- * Use Ancient Transportation Network. */ + _("Your %s didn't survive doing %s."), + actor_name, + action:name_translation()) + notify.event(actor.owner, target, + E.UNIT_ACTION_ACTOR_FAILURE, + _("Be more careful the next time you select a target.")) + -- Kept out to keep the game family friendly: + -- Sounds similar to those heard during their spring sacrifices are + -- rumored to have been coming from the closed chamber of the + -- Amêzârâkian Mysteries at the time of the accident. + end +end + +-- Handle tile targeted unit action start +function action_started_unit_tile_callback(action, actor, target) + if action:rule_name() == "User Action 2" then + -- Use Ancient Transportation Network + transport_network(action, actor, target) + end +end + +signal.connect("action_started_unit_tile", +"action_started_unit_tile_callback") diff --git a/data/sandbox/terrain.ruleset b/data/sandbox/terrain.ruleset index 292ab7aee8..c51f9526cc 100644 --- a/data/sandbox/terrain.ruleset +++ b/data/sandbox/terrain.ruleset @@ -1746,6 +1746,32 @@ Ruins mark the former site of a city that was destroyed or abandoned. \ They have no effect on gameplay.\ ") +[extra_transport_hub] +name = _("Ancient Transport Hub") +category = "Bonus" +rmcauses = "Pillage" +rmreqs = + { "type", "name", "range", "present", "quiet" + "Tech", "Polytheism", "Player", TRUE, FALSE + } +rmact_gfx = "None" +rmact_gfx_alt = "-" +graphic = "extra.transport_hub" +graphic_alt = "extra.ruins" +activity_gfx = "None" +visibility_req = "Polytheism" +; Can't be reverse engineered and built by players. +buildable = FALSE +removal_time = 3 +helptext = _("\ +An Ancient Transport Hub can transport units to any other Ancient Transport \ +Hub on the map.\ +"), _("\ +Using an Ancient Transport Hub to move to an Ancient Transport Hub known \ +to exist, to be free from non allied units and on native terrain should be \ +reasonably safe.\ +") + [extra_road] name = _("Road") category = "Infra" -- 2.20.1