mistletoe as curse (bad idea)

This commit is contained in:
Enno Rehling 2018-01-11 17:38:32 +01:00
parent d383abb625
commit d38582360a
5 changed files with 33 additions and 22 deletions

View file

@ -19,12 +19,15 @@ function disable_test_mistletoe_okay()
u:add_item('mistletoe', 2)
u:clear_orders()
u:add_order("BENUTZEN 1 Mistelzweig")
assert_false(u:has_attrib('fleechance'))
assert_nil(u:get_curse('fleechance'))
turn_process()
assert_true(u:has_attrib('fleechance'))
assert_not_nil(u:get_curse('fleechance'))
assert_equal(1, u:get_item('mistletoe'))
assert_equal(1, f:count_msg_type('use_item'))
turn_end()
init_reports()
print("reports", get_turn(), f)
write_report(f)
end
function disable_test_mistletoe_fail()
@ -35,10 +38,10 @@ function disable_test_mistletoe_fail()
u:add_item('mistletoe', 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Mistelzweig")
assert_false(u:has_attrib('fleechance'))
assert_nil(u:get_curse('fleechance'))
u.number = 2
turn_process()
assert_false(u:has_attrib('fleechance'))
assert_nil(u:get_curse('fleechance'))
assert_equal(1, u:get_item('mistletoe'))
assert_equal(1, f:count_msg_type('use_singleperson'))
turn_end()

View file

@ -2328,29 +2328,29 @@ static double horse_fleeing_bonus(const unit * u)
double fleechance(unit * u)
{
double c = 0.20; /* Fluchtwahrscheinlichkeit in % */
double p = 0.20; /* Fluchtwahrscheinlichkeit in % */
/* Einheit u versucht, dem Get<65>mmel zu entkommen */
c += (effskill(u, SK_STEALTH, 0) * 0.05);
c += horse_fleeing_bonus(u);
p += (effskill(u, SK_STEALTH, 0) * 0.05);
p += horse_fleeing_bonus(u);
if (u_race(u) == get_race(RC_HALFLING)) {
c += 0.20;
c = fmin(c, 0.90);
}
else {
c = fmin(c, 0.75);
p += 0.20;
if (p > 0.9) {
p = 0.9;
}
}
#if 0
/* TODO: mistletoe */
if (a) {
c += a->data.flt;
c = get_curse(u->attribs, &ct_fleechance);
if (c) {
p += c->effect;
}
#endif
return c;
return p;
}
/** add a new army to the conflict
/** add a new army to the conflict.
* beware: armies need to be added _at the beginning_ of the list because
* otherwise join_allies() will get into trouble */
side *make_side(battle * b, const faction * f, const group * g,
@ -3358,7 +3358,7 @@ fighter * get_fighter(battle * b, const struct unit * u)
static int join_battle(battle * b, unit * u, bool attack, fighter ** cp)
{
side *s;
fighter *c = NULL;
fighter *fc = NULL;
if (!attack) {
#if 0
@ -3378,7 +3378,7 @@ static int join_battle(battle * b, unit * u, bool attack, fighter ** cp)
if (s->faction == u->faction) {
for (fig = s->fighters; fig; fig = fig->next) {
if (fig->unit == u) {
c = fig;
fc = fig;
if (attack) {
set_attacker(fig);
}
@ -3387,11 +3387,11 @@ static int join_battle(battle * b, unit * u, bool attack, fighter ** cp)
}
}
}
if (!c) {
if (!fc) {
*cp = make_fighter(b, u, NULL, attack);
return *cp != NULL;
}
*cp = c;
*cp = fc;
return false;
}

View file

@ -953,10 +953,10 @@ struct message *msg_curse(const struct curse *c, const void *obj, objtype_t typ,
{ "unit_unknown", "region_unknown", "building_unknown",
"ship_unknown" };
msg = msg_message(mkname("curseinfo", unknown[typ]), "id", c->no);
log_error("no curseinfo function for %s and no fallback either.\n", c->type->cname);
log_warning("no curseinfo function for %s and no fallback either.\n", c->type->cname);
}
else {
log_error("no curseinfo function for %s, using cinfo_simple fallback.\n", c->type->cname);
log_debug("no curseinfo function for %s, using cinfo_simple fallback.\n", c->type->cname);
}
return msg;
}

View file

@ -345,9 +345,16 @@ const struct curse_type ct_skillmod = {
NULL, read_skill, write_skill
};
const struct curse_type ct_fleechance = {
"fleechance",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
NULL, NULL, NULL, NULL, NULL
};
/* ------------------------------------------------------------- */
void register_unitcurse(void)
{
ct_register(&ct_fleechance);
ct_register(&ct_auraboost);
ct_register(&ct_magicboost);
ct_register(&ct_slavery);

View file

@ -23,6 +23,7 @@ extern "C" {
struct curse_type;
struct message;
extern const struct curse_type ct_fleechance;
extern const struct curse_type ct_slavery;
extern const struct curse_type ct_calmmonster;
extern const struct curse_type ct_speed;