fix seaserpents

seaserpents could not do piracy
seaserpents should be able to attack after move
This commit is contained in:
Steffen Mecke 2015-11-17 11:25:58 +01:00
parent 2a569635df
commit 742a30cc39
7 changed files with 25 additions and 4 deletions

View File

@ -883,7 +883,7 @@
</race> </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"> <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="name" value="namegeneric"/>
<function name="move" value="moveswimming"/> <function name="move" value="moveswimming"/>
<skill name="tactics" modifier="4"/> <skill name="tactics" modifier="4"/>

View File

@ -1171,7 +1171,7 @@
<attack type="1" damage="1d1"/> <attack type="1" damage="1d1"/>
</race> </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"> <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="name" value="namegeneric"/>
<function name="move" value="moveswimming"/> <function name="move" value="moveswimming"/>
<skill name="tactics" modifier="4"/> <skill name="tactics" modifier="4"/>

View File

@ -214,6 +214,7 @@ extern "C" {
#define RCF_SHIPSPEED (1<<26) /* race gets +1 on shipspeed */ #define RCF_SHIPSPEED (1<<26) /* race gets +1 on shipspeed */
#define RCF_STONEGOLEM (1<<27) /* race gets stonegolem properties */ #define RCF_STONEGOLEM (1<<27) /* race gets stonegolem properties */
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */ #define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
#define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */
/* Economic flags */ /* Economic flags */
#define ECF_KEEP_ITEM (1<<1) /* gibt Gegenstände weg */ #define ECF_KEEP_ITEM (1<<1) /* gibt Gegenstände weg */

View File

@ -1604,6 +1604,8 @@ static void parse_ai(race * rc, xmlNodePtr node)
rc->flags |= RCF_MOVERANDOM; rc->flags |= RCF_MOVERANDOM;
if (xml_bvalue(node, "learn", false)) if (xml_bvalue(node, "learn", false))
rc->flags |= RCF_LEARN; rc->flags |= RCF_LEARN;
if (xml_bvalue(node, "moveattack", false))
rc->flags |= RCF_ATTACK_MOVED;
} }
static int parse_races(xmlDocPtr doc) static int parse_races(xmlDocPtr doc)

View File

@ -69,7 +69,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
bool monster_is_waiting(const unit * u) 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 true;
return false; return false;
} }

View File

@ -9,6 +9,7 @@
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/race.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/ship.h> #include <kernel/ship.h>
#include <kernel/terrain.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) { static bool validate_pirate(unit *u, order *ord) {
if (fval(u_race(u), RCF_SWIM | RCF_FLY))
return true;
if (!u->ship) { if (!u->ship) {
cmistake(u, ord, 144, MSG_MOVE); cmistake(u, ord, 144, MSG_MOVE);
return false; return false;

View File

@ -8,6 +8,7 @@
#include <kernel/terrain.h> #include <kernel/terrain.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/race.h>
#include <util/base36.h> #include <util/base36.h>
#include <util/language.h> #include <util/language.h>
@ -66,6 +67,7 @@ static void test_piracy_cmd(CuTest * tc) {
} }
static void test_piracy_cmd_errors(CuTest * tc) { static void test_piracy_cmd_errors(CuTest * tc) {
race *r;
faction *f; faction *f;
unit *u, *u2; unit *u, *u2;
order *ord; order *ord;
@ -73,7 +75,8 @@ static void test_piracy_cmd_errors(CuTest * tc) {
setup_piracy(); setup_piracy();
st_boat = st_get_or_create("boat"); 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"); f->locale = get_or_create_locale("de");
ord = create_order(K_PIRACY, f->locale, ""); ord = create_order(K_PIRACY, f->locale, "");
assert(u && ord); assert(u && ord);
@ -81,6 +84,17 @@ static void test_piracy_cmd_errors(CuTest * tc) {
piracy_cmd(u, ord); piracy_cmd(u, ord);
CuAssertPtrNotNullMsg(tc, "must be on a ship for PIRACY", test_find_messagetype(f->msgs, "error144")); 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)); u_set_ship(u, test_create_ship(u->region, st_boat));
u2 = test_create_unit(u->faction, u->region); u2 = test_create_unit(u->faction, u->region);