BUG 2405: use mistletoe to create effect, use effect to flee from battle.

This commit is contained in:
Enno Rehling 2018-01-21 18:07:49 +01:00
parent 6eae363487
commit 1eaa1e6d84
5 changed files with 26 additions and 49 deletions

View file

@ -6815,19 +6815,10 @@
<type>
<arg name="unit" type="unit"/>
<arg name="item" type="resource"/>
<arg name="amount" type="int"/>
</type>
<text locale="de">"$unit($unit) benutzt ein $resource($item,1)."</text>
<text locale="en">"$unit($unit) uses a $resource($item,1)."</text>
</message>
<message name="use_singleperson" section="errors">
<type>
<arg name="unit" type="unit"/>
<arg name="item" type="resource"/>
<arg name="region" type="region"/>
<arg name="command" type="order"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - $resource($item,0) können nur von Ein-Personen Einheiten benutzt werden."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - $resource($item,0) can only be used by single-person units."</text>
<text locale="de">"$unit($unit) benutzt $amount $resource($item,$amount)."</text>
<text locale="en">"$unit($unit) uses $amount $resource($item,$amount)."</text>
</message>
<message name="no_attack_after_advance" section="errors">
<type>

View file

@ -11,15 +11,15 @@ function setup()
eressea.settings.set("magic.regeneration.enable", "0")
end
function disable_test_use_mistletoe()
function test_use_mistletoe()
local r = region.create(0, 0, "plain")
local f = faction.create("human")
local u = unit.create(f, r, 1)
u.name = 'Miraculix'
u:add_item('mistletoe', 2)
u:add_order("BENUTZEN 1 Mistelzweig")
u:add_item('mistletoe', 3)
u:add_order("BENUTZEN 2 Mistelzweig")
process_orders()
assert_equal(1, u:effect('mistletoe'))
assert_equal(2, u:effect('mistletoe'))
assert_equal(1, u:get_item('mistletoe'))
assert_equal(1, f:count_msg_type('use_item'))
end

View file

@ -2340,13 +2340,6 @@ double fleechance(unit * u)
p = 0.9;
}
}
#if 0
/* TODO: mistletoe */
c = get_curse(u->attribs, &ct_fleechance);
if (c) {
p += c->effect;
}
#endif
return p;
}
@ -3360,17 +3353,16 @@ static int join_battle(battle * b, unit * u, bool attack, fighter ** cp)
side *s;
fighter *fc = NULL;
if (!attack) {
#if 0
/* TODO: mistletoe */
attrib *a = a_find(u->attribs, &at_fleechance);
if (a != NULL) {
if (rng_double() <= a->data.flt) {
if (!attack && u->attribs) {
const item_type *itype = it_find("mistletoe");
if (itype) {
int effect = get_effect(u, itype);
if (effect >= u->number) {
change_effect(u, itype, -u->number);
*cp = NULL;
return false;
}
}
#endif
}
for (s = b->sides; s != b->sides + b->nsides; ++s) {

View file

@ -374,24 +374,18 @@ static int
use_mistletoe(struct unit *user, const struct item_type *itype, int amount,
struct order *ord)
{
int mtoes =
get_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK,
user->number);
if (user->number > mtoes) {
ADDMSG(&user->faction->msgs, msg_message("use_singleperson",
"unit item region command", user, itype->rtype, user->region, ord));
return -1;
int mtoes = get_pooled(user, itype->rtype,
GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, amount);
if (mtoes < amount) {
amount = mtoes;
}
if (amount > 0) {
use_pooled(user, itype->rtype,
GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, amount);
change_effect(user, itype, amount);
ADDMSG(&user->faction->msgs,
msg_message("use_item", "unit amount item", user, amount, itype->rtype));
}
use_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK,
user->number);
#if 0
/* TODO: mistletoe */
a_add(&user->attribs, make_fleechance((float)1.0));
#endif
ADDMSG(&user->faction->msgs,
msg_message("use_item", "unit item", user, itype->rtype));
return 0;
}

View file

@ -460,7 +460,7 @@ static void use_key1(connection *b, void *data) {
if (b->type == &bt_questportal) {
const struct item_type *itype = it_find("questkey1");
ADDMSG(&u->faction->msgs,
msg_message("use_item", "unit item", u, itype->rtype));
msg_message("use_item", "unit amount item", u, 1, itype->rtype));
b->data.i &= 0xFE;
}
}
@ -470,7 +470,7 @@ static void use_key2(connection *b, void *data) {
if (b->type == &bt_questportal) {
const struct item_type *itype = it_find("questkey2");
ADDMSG(&u->faction->msgs,
msg_message("use_item", "unit item", u, itype->rtype));
msg_message("use_item", "unit amount item", u, 1, itype->rtype));
b->data.i &= 0xFD;
}
}