forked from github/server
More horsing around with I_HORSE
This commit is contained in:
parent
637486d95e
commit
93dbfa0cec
|
@ -594,40 +594,40 @@ monster_attacks(unit * u)
|
||||||
static void
|
static void
|
||||||
eaten_by_monster(unit * u)
|
eaten_by_monster(unit * u)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int horse = 0;
|
int horse = 0;
|
||||||
|
|
||||||
switch (old_race(u->race)) {
|
switch (old_race(u->race)) {
|
||||||
case RC_FIREDRAGON:
|
case RC_FIREDRAGON:
|
||||||
n = rng_int()%80 * u->number;
|
n = rng_int()%80 * u->number;
|
||||||
horse = get_item(u, I_HORSE);
|
horse = get_item(u, I_HORSE);
|
||||||
break;
|
break;
|
||||||
case RC_DRAGON:
|
case RC_DRAGON:
|
||||||
n = rng_int()%200 * u->number;
|
n = rng_int()%200 * u->number;
|
||||||
horse = get_item(u, I_HORSE);
|
horse = get_item(u, I_HORSE);
|
||||||
break;
|
break;
|
||||||
case RC_WYRM:
|
case RC_WYRM:
|
||||||
n = rng_int()%500 * u->number;
|
n = rng_int()%500 * u->number;
|
||||||
horse = get_item(u, I_HORSE);
|
horse = get_item(u, I_HORSE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
n = rng_int()%(u->number/20+1);
|
n = rng_int()%(u->number/20+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
n = lovar(n);
|
n = lovar(n);
|
||||||
n = MIN(rpeasants(u->region), n);
|
n = MIN(rpeasants(u->region), n);
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
deathcounts(u->region, n);
|
deathcounts(u->region, n);
|
||||||
rsetpeasants(u->region, rpeasants(u->region) - n);
|
rsetpeasants(u->region, rpeasants(u->region) - n);
|
||||||
ADDMSG(&u->region->msgs, msg_message("eatpeasants", "unit amount", u, n));
|
ADDMSG(&u->region->msgs, msg_message("eatpeasants", "unit amount", u, n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (horse > 0) {
|
if (horse > 0) {
|
||||||
set_item(u, I_HORSE, 0);
|
set_item(u, I_HORSE, 0);
|
||||||
ADDMSG(&u->region->msgs, msg_message("eathorse", "unit amount", u, horse));
|
ADDMSG(&u->region->msgs, msg_message("eathorse", "unit amount", u, horse));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -1124,7 +1124,7 @@ leave_cmd(unit * u, struct order * ord)
|
||||||
cmistake(u, ord, 11, MSG_MOVE);
|
cmistake(u, ord, 11, MSG_MOVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(get_item(u, I_HORSE)) {
|
if (has_horses(u)) {
|
||||||
cmistake(u, ord, 231, MSG_MOVE);
|
cmistake(u, ord, 231, MSG_MOVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2504,6 +2504,15 @@ lifestyle(const unit * u)
|
||||||
return need;
|
return need;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean has_horses(const struct unit * u)
|
||||||
|
{
|
||||||
|
item * itm = u->items;
|
||||||
|
for (;itm;itm=itm->next) {
|
||||||
|
if (itm->type->flags&ITF_ANIMAL) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
hunger(int number, unit * u)
|
hunger(int number, unit * u)
|
||||||
{
|
{
|
||||||
|
|
|
@ -335,6 +335,7 @@ extern boolean hunger(int number, struct unit * u);
|
||||||
extern int lifestyle(const struct unit*);
|
extern int lifestyle(const struct unit*);
|
||||||
extern int besieged(const struct unit * u);
|
extern int besieged(const struct unit * u);
|
||||||
extern int maxworkingpeasants(const struct region * r);
|
extern int maxworkingpeasants(const struct region * r);
|
||||||
|
extern boolean has_horses(const struct unit * u);
|
||||||
|
|
||||||
extern int wage(const struct region *r, const struct faction *f, const struct race * rc);
|
extern int wage(const struct region *r, const struct faction *f, const struct race * rc);
|
||||||
extern int maintenance_cost(const struct unit * u);
|
extern int maintenance_cost(const struct unit * u);
|
||||||
|
|
|
@ -288,6 +288,7 @@ destroyfaction(faction * f)
|
||||||
if ((rc->ec_flags & ECF_REC_ETHEREAL)==0) {
|
if ((rc->ec_flags & ECF_REC_ETHEREAL)==0) {
|
||||||
int p = rpeasants(u->region);
|
int p = rpeasants(u->region);
|
||||||
int h = rhorses(u->region);
|
int h = rhorses(u->region);
|
||||||
|
item * itm;
|
||||||
|
|
||||||
/* Personen gehen nur an die Bauern, wenn sie auch von dort
|
/* Personen gehen nur an die Bauern, wenn sie auch von dort
|
||||||
* stammen */
|
* stammen */
|
||||||
|
@ -298,7 +299,11 @@ destroyfaction(faction * f)
|
||||||
} else {
|
} else {
|
||||||
p += u->number;
|
p += u->number;
|
||||||
}
|
}
|
||||||
h += get_item(u, I_HORSE);
|
for (itm=u->items;itm;itm=itm->next) {
|
||||||
|
if (itm->type->flags&ITF_ANIMAL) {
|
||||||
|
h += itm->number;
|
||||||
|
}
|
||||||
|
}
|
||||||
rsetpeasants(r, p);
|
rsetpeasants(r, p);
|
||||||
rsethorses(r, h);
|
rsethorses(r, h);
|
||||||
}
|
}
|
||||||
|
|
|
@ -416,22 +416,38 @@ canswim(unit *u)
|
||||||
static int
|
static int
|
||||||
canride(unit * u)
|
canride(unit * u)
|
||||||
{
|
{
|
||||||
int pferde, maxpferde, unicorns, maxunicorns;
|
int horses = 0, maxhorses, unicorns = 0, maxunicorns;
|
||||||
int skill = effskill(u, SK_RIDING);
|
int skill = effskill(u, SK_RIDING);
|
||||||
|
item * itm;
|
||||||
|
static const item_type * it_horse = 0;
|
||||||
|
static const item_type * it_elvenhorse = 0;
|
||||||
|
static const item_type * it_charger = 0;
|
||||||
|
|
||||||
|
if (it_horse==0) {
|
||||||
|
it_horse = it_find("horse");
|
||||||
|
it_elvenhorse = it_find("elvenhorse");
|
||||||
|
it_charger = it_find("charger");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (itm=u->items;itm;itm=itm->next) {
|
||||||
|
if (itm->type==it_horse || itm->type==it_charger) {
|
||||||
|
horses += itm->number;
|
||||||
|
} else if (itm->type==it_elvenhorse) {
|
||||||
|
unicorns += itm->number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unicorns = get_item(u, I_ELVENHORSE);
|
|
||||||
pferde = get_item(u, I_HORSE);
|
|
||||||
maxunicorns = (skill/5) * u->number;
|
maxunicorns = (skill/5) * u->number;
|
||||||
maxpferde = skill * u->number * 2;
|
maxhorses = skill * u->number * 2;
|
||||||
|
|
||||||
if(!(u->race->flags & RCF_HORSE)
|
if(!(u->race->flags & RCF_HORSE)
|
||||||
&& ((pferde == 0 && unicorns == 0)
|
&& ((horses == 0 && unicorns == 0)
|
||||||
|| pferde > maxpferde || unicorns > maxunicorns)) {
|
|| horses > maxhorses || unicorns > maxunicorns)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ridingcapacity(u) - eff_weight(u) >= 0) {
|
if (ridingcapacity(u) - eff_weight(u) >= 0) {
|
||||||
if(pferde == 0 && unicorns >= u->number && !(u->race->flags & RCF_HORSE)) {
|
if (horses == 0 && unicorns >= u->number && !(u->race->flags & RCF_HORSE)) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1403,7 +1419,7 @@ travel_route(unit * u, const region_list * route_begin, const region_list * rout
|
||||||
|
|
||||||
if (fval(current->terrain, SEA_REGION) || fval(next->terrain, SEA_REGION)) {
|
if (fval(current->terrain, SEA_REGION) || fval(next->terrain, SEA_REGION)) {
|
||||||
/* trying to enter or exit ocean with horses, are we? */
|
/* trying to enter or exit ocean with horses, are we? */
|
||||||
if (get_item(u, I_HORSE) > 0 || get_item(u, I_ELVENHORSE) > 0) {
|
if (has_horses(u)) {
|
||||||
/* tries to do it with horses */
|
/* tries to do it with horses */
|
||||||
if (ord!=NULL) cmistake(u, ord, 67, MSG_MOVE);
|
if (ord!=NULL) cmistake(u, ord, 67, MSG_MOVE);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -827,7 +827,7 @@ can_survive(const unit *u, const region *r)
|
||||||
{
|
{
|
||||||
static const curse_type * ctype = NULL;
|
static const curse_type * ctype = NULL;
|
||||||
|
|
||||||
if (get_item(u, I_HORSE) && !fval(r->terrain, WALK_INTO))
|
if (has_horses(u) && !fval(r->terrain, WALK_INTO))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!ctype) ctype = ct_find("holyground");
|
if (!ctype) ctype = ct_find("holyground");
|
||||||
|
|
|
@ -669,7 +669,6 @@ gm_addfaction(const char * email, plane * p, region * r)
|
||||||
{
|
{
|
||||||
attrib * a;
|
attrib * a;
|
||||||
unit * u;
|
unit * u;
|
||||||
int i;
|
|
||||||
faction * f = calloc(1, sizeof(faction));
|
faction * f = calloc(1, sizeof(faction));
|
||||||
|
|
||||||
assert(p!=NULL);
|
assert(p!=NULL);
|
||||||
|
@ -713,9 +712,6 @@ gm_addfaction(const char * email, plane * p, region * r)
|
||||||
}
|
}
|
||||||
a_add(&ap, make_atgmcreate(resource2item(r_silver)));
|
a_add(&ap, make_atgmcreate(resource2item(r_silver)));
|
||||||
|
|
||||||
for (i=0;i<=I_HORSE;++i) {
|
|
||||||
a_add(&ap, make_atgmcreate(olditemtype[i]));
|
|
||||||
}
|
|
||||||
a->data.v = ap;
|
a->data.v = ap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -357,7 +357,7 @@ use_museumticket(unit *u, const struct item_type *itype, int amount, order * ord
|
||||||
cmistake(u, ord, 267, MSG_MAGIC);
|
cmistake(u, ord, 267, MSG_MAGIC);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(get_item(u, I_HORSE)) {
|
if (has_horses(u)) {
|
||||||
cmistake(u, ord, 272, MSG_MAGIC);
|
cmistake(u, ord, 272, MSG_MAGIC);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource name="horse" limited="yes">
|
<resource name="horse" limited="yes">
|
||||||
<item big="yes" weight="5000" score="10" capacity="7000" animal="yes">
|
<item big="yes" weight="5000" score="10" capacity="7000" animal="yes" ride="yes">
|
||||||
<construction skill="training" minskill="1" reqsize="1"/>
|
<construction skill="training" minskill="1" reqsize="1"/>
|
||||||
<function name="give" value="givehorses"/>
|
<function name="give" value="givehorses"/>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in New Issue