Barbarian
Posted: Sat Jul 25, 2015 7:38 am
I follow this guide: http://svn.gna.org/viewcvs/freeciv?view ... sion=29241
I can find UTYF_BARBARIAN_ONLY:
client/helpdata.c
common/unittype.c
common/unittype.h
Ok, let's rewrite... I delete "functions" in client/helpdata.c and common/unittype.h, but I edit function in common/unittype.c.
common/unittype.c
Now I add:
common/actions.h
common/actions.c
and
and
About common/actions.c, where I put "/* ??? */", what I have to write? It's ATK_CITY, ATK_UNITS or ATK_TILES? It's target_tile? Is there a rule? And it's TRUE or FALSE? Is there another rule? I don't know if I have the skills to complete/code this, but I think it's very useful if it's possible define a rule to identify if it's CITY, UNITS or TILES.
The main question is useful vs. pointless.
I can find UTYF_BARBARIAN_ONLY:
client/helpdata.c
Code: Select all
if (utype_has_flag(utype, UTYF_BARBARIAN_ONLY)) {
CATLSTR(buf, bufsz, _("* Only barbarians may build this.\n"));
}
Code: Select all
if (utype_has_flag(punittype, UTYF_BARBARIAN_ONLY)
&& !is_barbarian(p)) {
/* Unit can be built by barbarians only and this player is
* not barbarian */
return FALSE;
}
Code: Select all
/* Only barbarians can build this unit */
#define SPECENUM_VALUE27 UTYF_BARBARIAN_ONLY
#define SPECENUM_VALUE27NAME N_("?unitflag:BarbarianOnly")
common/unittype.c
Code: Select all
if (utype_can_do_action(punittype, ACTION_BARBARIAN_ONLY)
&& !is_barbarian(p)) {
/* Unit can be built by barbarians only and this player is
* not barbarian */
return FALSE;
}
common/actions.h
Code: Select all
#define SPECENUM_VALUE21 ACTION_BARBARIAN_ONLY
#define SPECENUM_VALUE21NAME N_("I don't know... maybe Barbarian_only?")
Code: Select all
actions[ACTION_BARBARIAN_ONLY] =
action_new(ACTION_BARBARIAN_ONLY,
ATK_UNITS,
FALSE);
Code: Select all
if (wanted_action == ACTION_BARBARIAN_ONLY) {
/* Reason: The Freeciv code assumes that I don't know. */
if (unit_tile(actor_unit) != target_tile) {
return FALSE;
}
/* TODO: Move more individual requirements to the action enabler. */
if (!is_barbarian(actor_player)) {
return FALSE;
}
}
Code: Select all
case ACTION_BARBARIAN_ONLY:
chance = 200;
break;
The main question is useful vs. pointless.