forked from github/server
BUG 2405: use mistletoe to create effect, use effect to flee from battle.
This commit is contained in:
parent
6eae363487
commit
1eaa1e6d84
5 changed files with 26 additions and 49 deletions
|
@ -6815,19 +6815,10 @@
|
||||||
<type>
|
<type>
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
<arg name="item" type="resource"/>
|
<arg name="item" type="resource"/>
|
||||||
|
<arg name="amount" type="int"/>
|
||||||
</type>
|
</type>
|
||||||
<text locale="de">"$unit($unit) benutzt ein $resource($item,1)."</text>
|
<text locale="de">"$unit($unit) benutzt $amount $resource($item,$amount)."</text>
|
||||||
<text locale="en">"$unit($unit) uses a $resource($item,1)."</text>
|
<text locale="en">"$unit($unit) uses $amount $resource($item,$amount)."</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>
|
|
||||||
</message>
|
</message>
|
||||||
<message name="no_attack_after_advance" section="errors">
|
<message name="no_attack_after_advance" section="errors">
|
||||||
<type>
|
<type>
|
||||||
|
|
|
@ -11,15 +11,15 @@ function setup()
|
||||||
eressea.settings.set("magic.regeneration.enable", "0")
|
eressea.settings.set("magic.regeneration.enable", "0")
|
||||||
end
|
end
|
||||||
|
|
||||||
function disable_test_use_mistletoe()
|
function test_use_mistletoe()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local f = faction.create("human")
|
local f = faction.create("human")
|
||||||
local u = unit.create(f, r, 1)
|
local u = unit.create(f, r, 1)
|
||||||
u.name = 'Miraculix'
|
u.name = 'Miraculix'
|
||||||
u:add_item('mistletoe', 2)
|
u:add_item('mistletoe', 3)
|
||||||
u:add_order("BENUTZEN 1 Mistelzweig")
|
u:add_order("BENUTZEN 2 Mistelzweig")
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal(1, u:effect('mistletoe'))
|
assert_equal(2, u:effect('mistletoe'))
|
||||||
assert_equal(1, u:get_item('mistletoe'))
|
assert_equal(1, u:get_item('mistletoe'))
|
||||||
assert_equal(1, f:count_msg_type('use_item'))
|
assert_equal(1, f:count_msg_type('use_item'))
|
||||||
end
|
end
|
||||||
|
|
20
src/battle.c
20
src/battle.c
|
@ -2340,13 +2340,6 @@ double fleechance(unit * u)
|
||||||
p = 0.9;
|
p = 0.9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
/* TODO: mistletoe */
|
|
||||||
c = get_curse(u->attribs, &ct_fleechance);
|
|
||||||
if (c) {
|
|
||||||
p += c->effect;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3360,17 +3353,16 @@ static int join_battle(battle * b, unit * u, bool attack, fighter ** cp)
|
||||||
side *s;
|
side *s;
|
||||||
fighter *fc = NULL;
|
fighter *fc = NULL;
|
||||||
|
|
||||||
if (!attack) {
|
if (!attack && u->attribs) {
|
||||||
#if 0
|
const item_type *itype = it_find("mistletoe");
|
||||||
/* TODO: mistletoe */
|
if (itype) {
|
||||||
attrib *a = a_find(u->attribs, &at_fleechance);
|
int effect = get_effect(u, itype);
|
||||||
if (a != NULL) {
|
if (effect >= u->number) {
|
||||||
if (rng_double() <= a->data.flt) {
|
change_effect(u, itype, -u->number);
|
||||||
*cp = NULL;
|
*cp = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||||
|
|
26
src/items.c
26
src/items.c
|
@ -374,24 +374,18 @@ static int
|
||||||
use_mistletoe(struct unit *user, const struct item_type *itype, int amount,
|
use_mistletoe(struct unit *user, const struct item_type *itype, int amount,
|
||||||
struct order *ord)
|
struct order *ord)
|
||||||
{
|
{
|
||||||
int mtoes =
|
int mtoes = get_pooled(user, itype->rtype,
|
||||||
get_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK,
|
GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, amount);
|
||||||
user->number);
|
if (mtoes < amount) {
|
||||||
|
amount = mtoes;
|
||||||
if (user->number > mtoes) {
|
|
||||||
ADDMSG(&user->faction->msgs, msg_message("use_singleperson",
|
|
||||||
"unit item region command", user, itype->rtype, user->region, ord));
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
use_pooled(user, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK,
|
if (amount > 0) {
|
||||||
user->number);
|
use_pooled(user, itype->rtype,
|
||||||
#if 0
|
GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, amount);
|
||||||
/* TODO: mistletoe */
|
change_effect(user, itype, amount);
|
||||||
a_add(&user->attribs, make_fleechance((float)1.0));
|
|
||||||
#endif
|
|
||||||
ADDMSG(&user->faction->msgs,
|
ADDMSG(&user->faction->msgs,
|
||||||
msg_message("use_item", "unit item", user, itype->rtype));
|
msg_message("use_item", "unit amount item", user, amount, itype->rtype));
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -460,7 +460,7 @@ static void use_key1(connection *b, void *data) {
|
||||||
if (b->type == &bt_questportal) {
|
if (b->type == &bt_questportal) {
|
||||||
const struct item_type *itype = it_find("questkey1");
|
const struct item_type *itype = it_find("questkey1");
|
||||||
ADDMSG(&u->faction->msgs,
|
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;
|
b->data.i &= 0xFE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -470,7 +470,7 @@ static void use_key2(connection *b, void *data) {
|
||||||
if (b->type == &bt_questportal) {
|
if (b->type == &bt_questportal) {
|
||||||
const struct item_type *itype = it_find("questkey2");
|
const struct item_type *itype = it_find("questkey2");
|
||||||
ADDMSG(&u->faction->msgs,
|
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;
|
b->data.i &= 0xFD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue