Changed in Freeciv 2.6/trunk: Creating unit types that both can attack and can do action enabler controlled actions is now possible. See
bug #23077
The example below adds a new unit type called Viking. It is able to attack another unit, steal tech, steal gold (up to 5%) and establish a trade route both from land and from a ship. Note that this only is an example. You should probably balance it (and maybe also adjust it for historical accuracy) before adding it to a ruleset used in a "serious" games.
Add the unit it self by adding the following to units.ruleset:
Code: Select all
[unit_vikings]
name = _("Vikings")
class = "Land"
tech_req = "Iron Working"
obsolete_by = "Marines"
graphic = "u.vikings"
graphic_alt = "u.pikemen"
sound_move = "m_vikings"
sound_move_alt = "m_generic"
sound_fight = "f_vikings"
sound_fight_alt = "f_generic"
build_cost = 20
pop_cost = 0
attack = 3
defense = 1
hitpoints = 10
firepower = 1
move_rate = 1
vision_radius_sq = 2
transport_cap = 0
fuel = 0
uk_happy = 1
uk_shield = 1
uk_food = 0
uk_gold = 0
flags = "Marines", "TradeRoute"
roles = "DefendOk", "BarbarianSeaTech"
helptext = _("\
Vikings can trade, steal or kill.\
")
Allow the unit to establish trade routes, to steal gold and to steal techs by adding the following to game.ruleset:
Code: Select all
[actionenabler_viking_traderoute]
action = "Establish Trade Route"
actor_reqs =
{ "type", "name", "range", "present"
"UnitType", "Vikings", "Local", TRUE
"MinMoveFrags", "1", "Local", TRUE
}
[actionenabler_viking_steal_gold]
action = "Steal Gold"
actor_reqs =
{ "type", "name", "range", "present"
"UnitType", "Vikings", "Local", TRUE
"MinMoveFrags", "1", "Local", TRUE
}
[actionenabler_viking_steal_tech]
action = "Steal Tech"
actor_reqs =
{ "type", "name", "range", "present"
"UnitType", "Vikings", "Local", TRUE
"MinMoveFrags", "1", "Local", TRUE
}
Let the viking (and other gold stealing units) to steal up to 5% of the victim's treasury.
Code: Select all
[effect_base_steal_gold]
type = "Max_Stolen_Gold_Pct"
value = 5