forked from github/server
fix seaserpents
seaserpents could not do piracy seaserpents should be able to attack after move
This commit is contained in:
parent
2a569635df
commit
742a30cc39
|
@ -883,7 +883,7 @@
|
|||
</race>
|
||||
|
||||
<race name="seaserpent" magres="0.500000" maxaura="1.0" regaura="1.0" weight="20000" capacity="5000" speed="1.0" hp="600" ac="3" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" swim="yes" teach="no" getitem="yes" resistbash="yes">
|
||||
<ai splitsize="6" killpeasants="yes" moverandom="yes" learn="yes"/>
|
||||
<ai splitsize="6" killpeasants="yes" moverandom="yes" learn="yes" moveattack="yes"/>
|
||||
<function name="name" value="namegeneric"/>
|
||||
<function name="move" value="moveswimming"/>
|
||||
<skill name="tactics" modifier="4"/>
|
||||
|
|
|
@ -1171,7 +1171,7 @@
|
|||
<attack type="1" damage="1d1"/>
|
||||
</race>
|
||||
<race name="seaserpent" magres="0.500000" maxaura="1.000000" regaura="1.000000" recruitcost="5000" weight="20000" capacity="5000" speed="1.000000" hp="600" ac="3" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" swim="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes">
|
||||
<ai splitsize="6" killpeasants="yes" moverandom="yes" learn="yes"/>
|
||||
<ai splitsize="6" killpeasants="yes" moverandom="yes" learn="yes" moveattack="yes"/>
|
||||
<function name="name" value="namegeneric"/>
|
||||
<function name="move" value="moveswimming"/>
|
||||
<skill name="tactics" modifier="4"/>
|
||||
|
|
|
@ -214,6 +214,7 @@ extern "C" {
|
|||
#define RCF_SHIPSPEED (1<<26) /* race gets +1 on shipspeed */
|
||||
#define RCF_STONEGOLEM (1<<27) /* race gets stonegolem properties */
|
||||
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
|
||||
#define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */
|
||||
|
||||
/* Economic flags */
|
||||
#define ECF_KEEP_ITEM (1<<1) /* gibt Gegenstände weg */
|
||||
|
|
|
@ -1604,6 +1604,8 @@ static void parse_ai(race * rc, xmlNodePtr node)
|
|||
rc->flags |= RCF_MOVERANDOM;
|
||||
if (xml_bvalue(node, "learn", false))
|
||||
rc->flags |= RCF_LEARN;
|
||||
if (xml_bvalue(node, "moveattack", false))
|
||||
rc->flags |= RCF_ATTACK_MOVED;
|
||||
}
|
||||
|
||||
static int parse_races(xmlDocPtr doc)
|
||||
|
|
|
@ -69,7 +69,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
bool monster_is_waiting(const unit * u)
|
||||
{
|
||||
if (fval(u, UFL_ISNEW | UFL_MOVED))
|
||||
int test = fval(u_race(u), RCF_ATTACK_MOVED) ? UFL_ISNEW : UFL_ISNEW | UFL_MOVED;
|
||||
if (fval(u, test))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <kernel/faction.h>
|
||||
#include <kernel/messages.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/terrain.h>
|
||||
|
@ -64,6 +65,8 @@ static attrib *mk_piracy(const faction * pirate, const faction * target,
|
|||
}
|
||||
|
||||
static bool validate_pirate(unit *u, order *ord) {
|
||||
if (fval(u_race(u), RCF_SWIM | RCF_FLY))
|
||||
return true;
|
||||
if (!u->ship) {
|
||||
cmistake(u, ord, 144, MSG_MOVE);
|
||||
return false;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <kernel/terrain.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/race.h>
|
||||
|
||||
#include <util/base36.h>
|
||||
#include <util/language.h>
|
||||
|
@ -66,6 +67,7 @@ static void test_piracy_cmd(CuTest * tc) {
|
|||
}
|
||||
|
||||
static void test_piracy_cmd_errors(CuTest * tc) {
|
||||
race *r;
|
||||
faction *f;
|
||||
unit *u, *u2;
|
||||
order *ord;
|
||||
|
@ -73,7 +75,8 @@ static void test_piracy_cmd_errors(CuTest * tc) {
|
|||
|
||||
setup_piracy();
|
||||
st_boat = st_get_or_create("boat");
|
||||
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, get_or_create_terrain("ocean")));
|
||||
r = test_create_race("pirates");
|
||||
u = test_create_unit(f = test_create_faction(r), test_create_region(0, 0, get_or_create_terrain("ocean")));
|
||||
f->locale = get_or_create_locale("de");
|
||||
ord = create_order(K_PIRACY, f->locale, "");
|
||||
assert(u && ord);
|
||||
|
@ -81,6 +84,17 @@ static void test_piracy_cmd_errors(CuTest * tc) {
|
|||
piracy_cmd(u, ord);
|
||||
CuAssertPtrNotNullMsg(tc, "must be on a ship for PIRACY", test_find_messagetype(f->msgs, "error144"));
|
||||
|
||||
test_clear_messages(f);
|
||||
fset(r, RCF_SWIM);
|
||||
piracy_cmd(u, ord);
|
||||
CuAssertPtrEquals_Msg(tc, "swimmers are pirates", 0, test_find_messagetype(f->msgs, "error144"));
|
||||
CuAssertPtrEquals_Msg(tc, "swimmers are pirates", 0, test_find_messagetype(f->msgs, "error146"));
|
||||
freset(r, RCF_SWIM);
|
||||
fset(r, RCF_FLY);
|
||||
CuAssertPtrEquals_Msg(tc, "flyers are pirates", 0, test_find_messagetype(f->msgs, "error144"));
|
||||
freset(r, RCF_FLY);
|
||||
test_clear_messages(f);
|
||||
|
||||
u_set_ship(u, test_create_ship(u->region, st_boat));
|
||||
|
||||
u2 = test_create_unit(u->faction, u->region);
|
||||
|
|
Loading…
Reference in New Issue