several monster_attack fixes.

1. do not try to attack other monsters.
2. monsters outside of a building can attack units outside of buildings.
3. dragons can guard without weapons.
This commit is contained in:
Enno Rehling 2015-08-16 16:18:59 +02:00
parent 09dc31f986
commit b50c1720cf
5 changed files with 13 additions and 21 deletions

View File

@ -430,7 +430,7 @@
<attack type="1" damage="1d4"/> <attack type="1" damage="1d4"/>
<attack type="2" damage="2d20"/> <attack type="2" damage="2d20"/>
</race> </race>
<race name="songdragon" magres="0.990000" maxaura="1.000000" regaura="1.000000" recruitcost="50" weight="1000" capacity="600" speed="1.500000" hp="40" ac="1" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" fly="yes" walk="yes" teach="no" getitem="yes"> <race name="songdragon" magres="0.990000" maxaura="1.000000" regaura="1.000000" recruitcost="50" weight="1000" capacity="600" speed="1.500000" hp="40" ac="1" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" fly="yes" walk="yes" teach="no" getitem="yes" unarmedguard="yes">
<ai splitsize="9999"/> <ai splitsize="9999"/>
<function name="initfamiliar" value="oldfamiliars"/> <function name="initfamiliar" value="oldfamiliars"/>
<skill name="alchemy" modifier="-99"/> <skill name="alchemy" modifier="-99"/>
@ -733,7 +733,7 @@
<attack type="4" damage="2d12"/> <attack type="4" damage="2d12"/>
<attack type="4" damage="2d12"/> <attack type="4" damage="2d12"/>
</race> </race>
<race name="wyrm" magres="0.900000" maxaura="1.000000" regaura="3.000000" recruitcost="250000" weight="18000" capacity="1000000" speed="1.000000" hp="2700" ac="8" damage="2d60" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes"> <race name="wyrm" magres="0.900000" maxaura="1.000000" regaura="3.000000" recruitcost="250000" weight="18000" capacity="1000000" speed="1.000000" hp="2700" ac="8" damage="2d60" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes">
<ai splitsize="1" killpeasants="yes" learn="yes"/> <ai splitsize="1" killpeasants="yes" learn="yes"/>
<function name="name" value="namedragon"/> <function name="name" value="namedragon"/>
<function name="move" value="movedragon"/> <function name="move" value="movedragon"/>
@ -745,7 +745,7 @@
<attack type="4" damage="5d30"/> <attack type="4" damage="5d30"/>
<attack type="6" spell="powerful_dragonbreath" level="12" /> <attack type="6" spell="powerful_dragonbreath" level="12" />
</race> </race>
<race name="dragon" magres="0.700000" maxaura="1.000000" regaura="2.000000" recruitcost="50000" weight="10000" capacity="1000000" speed="1.500000" hp="900" ac="6" damage="2d30" unarmedattack="0" unarmeddefense="0" attackmodifier="7" defensemodifier="7" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes"> <race name="dragon" magres="0.700000" maxaura="1.000000" regaura="2.000000" recruitcost="50000" weight="10000" capacity="1000000" speed="1.500000" hp="900" ac="6" damage="2d30" unarmedattack="0" unarmeddefense="0" attackmodifier="7" defensemodifier="7" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes">
<ai splitsize="2" killpeasants="yes" learn="yes"/> <ai splitsize="2" killpeasants="yes" learn="yes"/>
<function name="name" value="namedragon"/> <function name="name" value="namedragon"/>
<function name="age" value="agedragon"/> <function name="age" value="agedragon"/>
@ -758,7 +758,7 @@
<attack type="4" damage="3d30"/> <attack type="4" damage="3d30"/>
<attack type="6" spell="icy_dragonbreath" level="6" /> <attack type="6" spell="icy_dragonbreath" level="6" />
</race> </race>
<race name="youngdragon" magres="0.500000" maxaura="1.000000" regaura="1.000000" recruitcost="10000" weight="20000" capacity="10000" speed="1.000000" hp="300" ac="4" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes"> <race name="youngdragon" magres="0.500000" maxaura="1.000000" regaura="1.000000" recruitcost="10000" weight="20000" capacity="10000" speed="1.000000" hp="300" ac="4" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes">
<ai splitsize="6" killpeasants="yes" learn="yes"/> <ai splitsize="6" killpeasants="yes" learn="yes"/>
<function name="name" value="namedragon"/> <function name="name" value="namedragon"/>
<function name="age" value="agefiredragon"/> <function name="age" value="agefiredragon"/>
@ -1170,7 +1170,7 @@
<function name="name" value="namegeneric"/> <function name="name" value="namegeneric"/>
<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"> <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"/>
<function name="name" value="namegeneric"/> <function name="name" value="namegeneric"/>
<function name="move" value="moveswimming"/> <function name="move" value="moveswimming"/>

View File

@ -175,8 +175,6 @@ race *rc_get_or_create(const char *zName)
assert(zName); assert(zName);
rc = rc_find_i(zName); rc = rc_find_i(zName);
if (!rc) { if (!rc) {
char zBuffer[80];
rc = (race *)calloc(sizeof(race), 1); rc = (race *)calloc(sizeof(race), 1);
rc->hitpoints = 1; rc->hitpoints = 1;
rc->weight = PERSON_WEIGHT; rc->weight = PERSON_WEIGHT;
@ -189,8 +187,7 @@ race *rc_get_or_create(const char *zName)
log_error("race '%s' has an invalid name. remove spaces\n", zName); log_error("race '%s' has an invalid name. remove spaces\n", zName);
assert(strchr(zName, ' ') == NULL); assert(strchr(zName, ' ') == NULL);
} }
strcpy(zBuffer, zName); rc->_name = _strdup(zName);
rc->_name = _strdup(zBuffer);
rc->precombatspell = NULL; rc->precombatspell = NULL;
rc->attack[0].type = AT_COMBATSPELL; rc->attack[0].type = AT_COMBATSPELL;

View File

@ -146,10 +146,8 @@ static void reduce_weight(unit * u)
static order *monster_attack(unit * u, const unit * target) static order *monster_attack(unit * u, const unit * target)
{ {
if (u->region != target->region) assert(u->region == target->region);
return NULL; assert(u->faction != target->faction);
if (u->faction == target->faction)
return NULL;
if (!cansee(u->faction, u->region, target, 0)) if (!cansee(u->faction, u->region, target, 0))
return NULL; return NULL;
if (monster_is_waiting(u)) if (monster_is_waiting(u))
@ -167,7 +165,7 @@ static order *get_money_for_dragon(region * r, unit * u, int wanted)
if (attack_chance > 0.0 && is_guard(u, GUARD_TAX)) { if (attack_chance > 0.0 && is_guard(u, GUARD_TAX)) {
/* attackiere bewachende Einheiten nur wenn wir selbst schon bewachen */ /* attackiere bewachende Einheiten nur wenn wir selbst schon bewachen */
for (u2 = r->units; u2; u2 = u2->next) { for (u2 = r->units; u2; u2 = u2->next) {
if (u2 != u && is_guard(u2, GUARD_TAX)) { if (u2 != u && is_guard(u2, GUARD_TAX) && u->faction!=u2->faction) {
/*In E3 + E4 etwas problematisch, da der Regionsbesitzer immer bewacht. Der Drache greift also immer die Burg an!*/ /*In E3 + E4 etwas problematisch, da der Regionsbesitzer immer bewacht. Der Drache greift also immer die Burg an!*/
order *ord = monster_attack(u, u2); order *ord = monster_attack(u, u2);
if (ord) if (ord)
@ -557,8 +555,7 @@ static void monster_attacks(unit * u)
unit *u2; unit *u2;
for (u2 = r->units; u2; u2 = u2->next) { for (u2 = r->units; u2; u2 = u2->next) {
if (cansee(u->faction, r, u2, 0) && u2->faction != u->faction && inside_building(u2) != u->building if (u2->faction != u->faction && cansee(u->faction, r, u2, 0) && !inside_building(u2)) {
&& chance(0.75)) {
order *ord = monster_attack(u, u2); order *ord = monster_attack(u, u2);
if (ord) if (ord)
addlist(&u->orders, ord); addlist(&u->orders, ord);

View File

@ -970,9 +970,7 @@ static bool is_guardian_r(const unit * guard)
if ((guard->flags & UFL_GUARD) == 0) if ((guard->flags & UFL_GUARD) == 0)
return false; return false;
if (!armedmen(guard, true) && !fval(u_race(guard), RCF_UNARMEDGUARD)) return armedmen(guard, true) > 0 || fval(u_race(guard), RCF_UNARMEDGUARD);
return false;
return true;
} }
bool is_guard(const struct unit * u, unsigned int mask) bool is_guard(const struct unit * u, unsigned int mask)

View File

@ -6564,14 +6564,14 @@ static spelldata spell_functions[] = {
{ "analysedream", sp_analysedream, 0 }, { "analysedream", sp_analysedream, 0 },
{ "disturbingdreams", sp_disturbingdreams, 0 }, { "disturbingdreams", sp_disturbingdreams, 0 },
{ "sleep", sp_sleep, 0 }, { "sleep", sp_sleep, 0 },
{ "wisps", 0, 0 }, /* this spell is gone */ { "wisps", 0, 0 }, /* TODO: this spell is gone */
{ "gooddreams", sp_gooddreams, 0 }, { "gooddreams", sp_gooddreams, 0 },
{ "illaundestroymagic", sp_destroy_magic, 0 }, { "illaundestroymagic", sp_destroy_magic, 0 },
{ "clone", sp_clonecopy, 0 }, { "clone", sp_clonecopy, 0 },
{ "bad_dreams", sp_baddreams, 0 }, { "bad_dreams", sp_baddreams, 0 },
{ "mindblast", sp_mindblast_temp, 0 }, { "mindblast", sp_mindblast_temp, 0 },
{ "orkdream", sp_sweetdreams, 0 }, { "orkdream", sp_sweetdreams, 0 },
{ "summon_alp", sp_summon_alp, 0 }, { "summon_alp", sp_summon_alp, 0 }, // TODO: this spell is disabled everywhere
/* M_CERDDOR */ /* M_CERDDOR */
{ "appeasement", sp_denyattack, 0 }, { "appeasement", sp_denyattack, 0 },
{ "song_of_healing", sp_healing, 0 }, { "song_of_healing", sp_healing, 0 },