Changes in what a 2.6 rule set can do

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
cazfi
Elite
Posts: 3077
Joined: Tue Jan 29, 2013 6:54 pm

Re: Changes in what a 2.6 rule set can do

Post by cazfi »

More configurable Fortify.

Ability to Fortify can now be set per-unittype granularity with new "Cant_Fortify" flag that makes single unittype exception of the classes ability to fortify: patch #5072
Even units with flag "Settlers" respect the new setup, so it's possible to create units that can both build fortresses and fortify. To support this, key bindings have been changed so that bases are built with Shift+f & Shift+e: patch #5074
Hardcoded rule that units can fortify on land terrains and cannot fortify on oceanic terrain changed to ruleset controlled terrain flag: patch #5075
sveinung
Elite
Posts: 548
Joined: Wed Feb 20, 2013 4:50 pm

Re: Changes in what a 2.6 rule set can do

Post by sveinung »

Changed in Freeciv 2.6/trunk: The restriction that the target unit of the action Sabotage Unit must have more than 1 hit point left is now moved to the ruleset. If a unit with 1 hit point is successfully sabotaged it dies. See patch #5147
sveinung
Elite
Posts: 548
Joined: Wed Feb 20, 2013 4:50 pm

Re: Changes in what a 2.6 rule set can do

Post by sveinung »

Changed in Freeciv 2.6/trunk: The rule that the target unit of the spy actions Sabotage Unit and Bribe Unit must be alone at its tile is now moved to the ruleset. See patch #5148

If spy actions against units that share a tile with others are allowed and the player targets a tile with more than one unit the server will select a target unit. This will change to letting the player select the target if patch #5206 lands.
sveinung
Elite
Posts: 548
Joined: Wed Feb 20, 2013 4:50 pm

Re: Changes in what a 2.6 rule set can do

Post by sveinung »

Changed in Freeciv 2.6/trunk: A signal is now emitted to Lua right before an action enabler controlled action is executed but after it is known to be legal. See patch #5240

The signal's name starts with action_started_, then the actor kind, then another _ and in the end the target kind. At the moment the only kinds of action enabler controlled actions are unit vs city and unit vs unit. The signals you currently can use are therefore action_started_unit_city and action_started_unit_unit.

The signal has three parameters. The first parameter is the action that is about to get started. The second is the actor. The third parameter is the target. The parameters of action_started_unit_city is therefore action, actor_unit and finally target city.

To get the rule name of an action, that is the name used in action enablers, you can use the method rule_name(). To get a translated name that is nice to show to players use name_translation().

The following Lua code will log all actions done by any unit to a city or to another unit:

Code: Select all

function action_started_callback(action, actor, target)
  log.normal(_("%s (rule name: %s) performed by %s on %s"),
             action:name_translation(),
             action:rule_name(),
             actor.owner.nation:plural_translation(),
             target.owner.nation:plural_translation())
end

signal.connect("action_started_unit_city", "action_started_callback")
signal.connect("action_started_unit_unit", "action_started_callback")
The following Lua code will make a player that poisons the population of cities risk civil war:

Code: Select all

function action_started_callback(action, actor, target)
  if action:rule_name() == "Poison City" then
     edit.civil_war(actor.owner, 5);
  end
end

signal.connect("action_started_unit_city", "action_started_callback")
cazfi
Elite
Posts: 3077
Joined: Tue Jan 29, 2013 6:54 pm

Re: Changes in what a 2.6 rule set can do

Post by cazfi »

Calendar fragments support added. Ruleset can define number of fragments each year is divided to, and to make time advancement in fragments instead of full years (patch #5249)

Further patches in the series (already in review) will make the fragments visible in the user interface, and to add support for naming the fragments in the ruleset - for example as "Jan", "Feb", "Mar"...
sveinung
Elite
Posts: 548
Joined: Wed Feb 20, 2013 4:50 pm

Re: Changes in what a 2.6 rule set can do

Post by sveinung »

Changed in Freeciv 2.6/trunk: The new spy unit action "Steal Gold" is now available. See patch #5274

Steal gold will take some of the city owner's gold and give most of it to the actor unit's owner. The action may be stopped by defending diplomats. The action may fail even if no diplomatic defenders are present (see the diplchance setting). A random amount not larger than 5% of the victim's gold is stolen. (Should become effect controlled) 1% of it will disappear before reaching the player that ordered it stolen. (Should become effect controlled)

The following action enabler will let any unit with the Diplomat flag steal gold from foreign capitals once Banking is discovered:

Code: Select all

[actionenabler_steal_gold]
action = "Steal Gold"
actor_reqs    =
    { "type",   "name", "range", "present"
      "UnitFlag", "Diplomat", "Local", TRUE
      "UnitState", "TransportDependent", "Local", FALSE
      "MinMoveFrags", "1", "Local", TRUE
      "Tech", "Banking", "Player", TRUE
    }
target_reqs  =
    { "type",   "name", "range", "present"
      "Building", "Palace", "City", TRUE
    }
sveinung
Elite
Posts: 548
Joined: Wed Feb 20, 2013 4:50 pm

Re: Changes in what a 2.6 rule set can do

Post by sveinung »

Changed in Freeciv 2.6/trunk: It is now possible to customize the "Steal Gold" action via effects. See patch #5293

The new effect Max_Stolen_Gold_Pct controls the upper limit on the percentage of the players gold that may be stolen by a unit doing the "Steal Gold" action. Evaluated against the city stolen from. This means that any Gov requirements here is on the victim player.

The new effect Thiefs_Share_Pct controls the percentage of the gold stolen by a unit doing the "Steal Gold" action that is lost before it reaches the player ordering it. Evaluated against the actor unit. This means that any Gov requirements here is on the acting player.

The effects below sets up the following rules:
  • Max 5% of a victim player's gold can be stolen in non capital cities (and in capitals during Anarchy).
  • Max 30% of the victim player's gold can be stolen in the capital when the victim's government isn't Communism or Anarchy.
  • 50% of the victim player's gold can be stolen in the capital when the victim's government is Communism.
  • 1% of the stolen gold won't reach the player doing the theft when a Diplomat steals it.
  • 2% of the stolen gold won't reach the player doing the theft when a Spy steals it. (Useful if allowing the Spy to steal places a Diplomat can't steal)

Code: Select all

[effect_steal_gold_base]
type	= "Max_Stolen_Gold_Pct"
value	= 5

[effect_steal_gold_capital]
type	= "Max_Stolen_Gold_Pct"
value	= 25
reqs	=
{ "type", "name", "range", "present"
  "Building", "Palace", "City", TRUE
  "Gov", "Anarchy", "Player", FALSE
}

[effect_central_planning_committee]
type	= "Max_Stolen_Gold_Pct"
value	= 20
reqs	=
{ "type", "name", "range"
  "Building", "Palace", "City"
  "Gov", "Communism", "Player"
}

[effect_thiefs_share_base]
type	= "Thiefs_Share_Pct"
value	= 1

[effect_company_share]
type    = "Thiefs_Share_Pct"
value   = 1
reqs    =
{ "type", "name", "range"
  "UnitType", "Spy", "Local"
}
cazfi
Elite
Posts: 3077
Joined: Tue Jan 29, 2013 6:54 pm

Re: Changes in what a 2.6 rule set can do

Post by cazfi »

Further improvement to how tile extra building/removal time is defined. There has been no way to make two different extras using the same terrain specific variable (base_time, road_time, irrigation_time, mine_time) to have different build time from each other. Now the extras have build_time_factor and removal_time_factor. patch #5325

Now it's possible to have an extra to either take constant build time regardless of the terrain (defined as extra build_time), or terrain specific time multiplied by extra specific value.
cazfi
Elite
Posts: 3077
Joined: Tue Jan 29, 2013 6:54 pm

Re: Changes in what a 2.6 rule set can do

Post by cazfi »

- New requirement type "Age", can be checked from both units and cities patch #5305
- New effect "Retire_Pct" to control how likely unit is to spontaneously disappear at turn change patch #5316

Above features are used together to unhardcode barbarian unit disappearance. patch #5317
Supplied rulesets have behavior similar to old hardcoded one (Once barbarian unit has reached age of 5 turns, it has 10% retiring chance every turn), but custom rulesets can define these rules what ever way they want. The Barbarian Leader's chance to escape once it reaches coastal tile is still hardcoded to the freeciv engine.
sveinung
Elite
Posts: 548
Joined: Wed Feb 20, 2013 4:50 pm

Re: Changes in what a 2.6 rule set can do

Post by sveinung »

Changed in Freeciv 2.6/trunk: The caravan actions "Establish Trade Route" and "Enter Marketplace" can now be controlled by action enablers. See patch #5464

"Establish Trade Route" establishes a trade route and give a one time bonus. "Enter Marketplace" only give a one time bonus.

At the moment all the action enabler control can do is to disable its action totally or to add new restrictions on top of those that already exist. Since the actions are independent from each other they can have different rules. The requirement that the acting unit must have the "TradeRoute" unit type flag is still hard coded.

An example: Allow a unit on native terrain to enter the marketplace of any city that has a Marketplace. Allow a unit on native terrain to establish a trade route to any city that has a Marketplace but only if both its owner and the city's owner aren't at war with anyone.

Code: Select all

[actionenabler_marketplace]
action = "Enter Marketplace"
actor_reqs    =
    { "type",   "name", "range", "present"
      "UnitState", "TransportDependent", "Local", FALSE
    }
target_reqs    =
    { "type",   "name", "range", "present"
      "Building", "Marketplace", "City", TRUE
    }

[actionenabler_traderoute]
action = "Establish Trade Route"
actor_reqs    =
    { "type",   "name", "range", "present"
      "UnitState", "TransportDependent", "Local", FALSE
      "DiplRel", "War", "Player", FALSE
    }
target_reqs    =
    { "type",   "name", "range", "present"
      "DiplRel", "War", "Player", FALSE
      "Building", "Marketplace", "City", TRUE
    }
Post Reply