Author: cazfi
Date: Mon Mar 16 22:21:31 2015
New Revision: 28568

URL: http://svn.gna.org/viewcvs/freeciv?rev=28568&view=rev
Log:
Alien ruleset uses its own script for hut_enter signal. It's copy of the 
default one with user
visible messages changed to match the world of alien ruleset. Also removed the 
chance of getting
"mercenary" units.

See patch #5896

Modified:
    branches/S2_5/data/alien/script.lua

Modified: branches/S2_5/data/alien/script.lua
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/data/alien/script.lua?rev=28568&r1=28567&r2=28568&view=diff
==============================================================================
--- branches/S2_5/data/alien/script.lua (original)
+++ branches/S2_5/data/alien/script.lua Mon Mar 16 22:21:31 2015
@@ -8,6 +8,110 @@
 --   but WITHOUT ANY WARRANTY; without even the implied warranty of
 --   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 --   GNU General Public License for more details.
+
+-- default.lua callback overrides
+
+-- Get gold from entering a hut.
+function alien_hut_get_gold(unit, gold)
+  local owner = unit.owner
+
+  notify.event(owner, unit.tile, E.HUT_GOLD, PL_("It was a safe containing %d 
gold.",
+                                                 "It was a safe containing %d 
gold.", gold),
+               gold)
+  owner:change_gold(gold)
+end
+
+-- Get a tech from entering a hut.
+function alien_hut_get_tech(unit)
+  local owner = unit.owner
+  local tech = owner:give_technology(nil, "hut")
+
+  if tech then
+    notify.event(owner, unit.tile, E.HUT_TECH,
+                 _("There was a datapod containing research info about %s."),
+                 tech:name_translation())
+    notify.embassies(owner, unit.tile, E.HUT_TECH,
+                 _("The %s have acquired %s from Space Capsule they found."),
+                 owner.nation:plural_translation(),
+                 tech:name_translation())
+    return true
+  else
+    return false
+  end
+end
+
+-- Get new city from hut
+function alien_hut_get_city(unit)
+  local owner = unit.owner
+
+  if unit:is_on_possible_city_tile() then
+    owner:create_city(unit.tile, "")
+    notify.event(owner, unit.tile, E.HUT_CITY,
+                 _("You found a base starting kit."))
+    return true
+  else
+    return false
+  end
+end
+
+-- Get barbarians from hut, unless close to a city, king enters, or
+-- barbarians are disabled
+-- Unit may die: returns true if unit is alive
+function alien_hut_get_barbarians(unit)
+  local tile = unit.tile
+  local type = unit.utype
+  local owner = unit.owner
+
+  if server.setting.get("barbarians") == "DISABLED"
+    or unit.tile:city_exists_within_max_city_map(true)
+    or type:has_flag('Gameloss') then
+      notify.event(owner, unit.tile, E.HUT_BARB_CITY_NEAR,
+                   _("The Space Capsule was already scavenged by someone."))
+    return true
+  end
+  
+  local alive = tile:unleash_barbarians()
+  if alive then
+    notify.event(owner, tile, E.HUT_BARB,
+                  _("It was a trap! Set by the outcasts."));
+  else
+    notify.event(owner, tile, E.HUT_BARB_KILLED,
+                  _("Your %s has been killed by outcasts!"),
+                  type:name_translation());
+  end
+  return alive
+end
+
+-- Randomly choose a hut event
+function alien_hut_enter_callback(unit)
+  local chance = random(0, 11)
+  local alive = true
+
+  if chance == 0 then
+    alien_hut_get_gold(unit, 25)
+  elseif chance == 1 or chance == 2 or chance == 3 then
+    alien_hut_get_gold(unit, 50)
+  elseif chance == 4 then
+    alien_hut_get_gold(unit, 100)
+  elseif chance == 5 or chance == 6 or chance == 7 then
+    alien_hut_get_tech(unit)
+  elseif chance == 8 or chance == 9 then
+    alien_hut_get_gold(unit, 25)
+  elseif chance == 10 then
+    alive = alien_hut_get_barbarians(unit)
+  elseif chance == 11 then
+    if not alien_hut_get_city(unit) then
+      alien_hut_get_gold(unit, 50)
+    end
+  end
+
+  -- do not process default.lua
+  return true
+end
+
+signal.connect("hut_enter", "alien_hut_enter_callback")
+
+-- Alien ruleset specific callbacks
 
 -- Show a pop up telling the beginning of the story when the game starts.
 function turn_callback(turn, year)


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to