forked from github/server
make monsters scaring peasants a per-race configuration.
reduce the number of old_race calls that monster.c makes.
This commit is contained in:
parent
ff83d5108a
commit
ac4f8d6e7b
7 changed files with 49 additions and 30 deletions
|
@ -1,6 +1,8 @@
|
|||
<race name="dragon" magres="0.700000" maxaura="1.0" regaura="2.000000" 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" dragon="yes">
|
||||
<ai splitsize="2" killpeasants="yes" learn="yes"/>
|
||||
"6" damage="2d30" unarmedattack="0" unarmeddefense="0"
|
||||
attackmodifier="7" defensemodifier="7" scarepeasants="yes" fly="yes"
|
||||
walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes">
|
||||
<ai splitsize="2" killpeasants="yes" learn="yes" scare="400"/>
|
||||
<function name="name" value="namedragon"/>
|
||||
<function name="age" value="agedragon"/>
|
||||
<function name="move" value="movedragon"/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<race name="wyrm" magres="0.900000" maxaura="1.0" regaura="3.000000" weight="18000" capacity="1000000" speed="1.0" 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" dragon="yes">
|
||||
<ai splitsize="1" killpeasants="yes" learn="yes"/>
|
||||
<ai splitsize="1" killpeasants="yes" learn="yes" scare="1000"/>
|
||||
<function name="name" value="namedragon"/>
|
||||
<function name="move" value="movedragon"/>
|
||||
<skill name="magic" modifier="12"/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<race name="youngdragon" magres="0.500000" maxaura="1.0" regaura="1.0" weight="8000" capacity="10000" speed="1.0" 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" dragon="yes">
|
||||
<ai splitsize="6" killpeasants="yes" learn="yes"/>
|
||||
<ai splitsize="6" killpeasants="yes" learn="yes" scare="160"/>
|
||||
<function name="name" value="namedragon"/>
|
||||
<function name="age" value="agefiredragon"/>
|
||||
<function name="move" value="movedragon"/>
|
||||
|
|
|
@ -61,6 +61,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
#include <storage.h>
|
||||
|
||||
attrib_type at_scare = { // monster scares peasants
|
||||
"scare", NULL, NULL, NULL, a_writeint, a_readint
|
||||
};
|
||||
|
||||
attrib_type at_unitdissolve = {
|
||||
"unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars
|
||||
};
|
||||
|
@ -77,6 +81,7 @@ static int read_ext(attrib * a, void *owner, gamedata *data)
|
|||
void register_attributes(void)
|
||||
{
|
||||
/* Alle speicherbaren Attribute müssen hier registriert werden */
|
||||
at_register(&at_scare);
|
||||
at_register(&at_shiptrail);
|
||||
at_register(&at_familiar);
|
||||
at_register(&at_familiarmage);
|
||||
|
|
|
@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct attrib_type;
|
||||
extern struct attrib_type at_scare;
|
||||
extern void register_attributes(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -33,6 +33,7 @@ without prior permission by the authors of Eressea.
|
|||
#include "vortex.h"
|
||||
|
||||
#include <modules/score.h>
|
||||
#include <attributes/attributes.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
|
@ -1605,6 +1606,14 @@ static void parse_param(struct param **params, xmlNodePtr node)
|
|||
|
||||
static void parse_ai(race * rc, xmlNodePtr node)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = xml_ivalue(node, "scare", 0);
|
||||
if (n>0) {
|
||||
attrib *a = a_new(&at_scare);
|
||||
a->data.i = n;
|
||||
a_add(&rc->attribs, a);
|
||||
}
|
||||
rc->splitsize = xml_ivalue(node, "splitsize", 0);
|
||||
rc->aggression = (float)xml_fvalue(node, "aggression", 0.04);
|
||||
if (xml_bvalue(node, "killpeasants", false))
|
||||
|
|
|
@ -28,6 +28,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
/* attributes includes */
|
||||
#include <attributes/targetregion.h>
|
||||
#include <attributes/hate.h>
|
||||
#include <attributes/attributes.h>
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/build.h>
|
||||
|
@ -79,22 +80,17 @@ static void eaten_by_monster(unit * u)
|
|||
int n = 0;
|
||||
int horse = -1;
|
||||
const resource_type *rhorse = get_resourcetype(R_HORSE);
|
||||
const race *rc = u_race(u);
|
||||
attrib *a;
|
||||
|
||||
if (multi == 0.0) {
|
||||
multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0;
|
||||
}
|
||||
|
||||
// TODO: do not hard-code, make it a race property or callback? it's already RCF_KILLPEASANTS
|
||||
switch (old_race(u_race(u))) {
|
||||
case RC_FIREDRAGON:
|
||||
n = rng_int() % 80 * u->number;
|
||||
break;
|
||||
case RC_DRAGON:
|
||||
n = rng_int() % 200 * u->number;
|
||||
break;
|
||||
case RC_WYRM:
|
||||
n = rng_int() % 500 * u->number;
|
||||
break;
|
||||
default:
|
||||
a = a_find(rc->attribs, &at_scare);
|
||||
if (a) {
|
||||
n = rng_int() & a->data.i * u->number;
|
||||
} else {
|
||||
n = rng_int() % (u->number / 20 + 1);
|
||||
horse = 0;
|
||||
}
|
||||
|
@ -168,21 +164,26 @@ static int scareaway(region * r, int anzahl)
|
|||
static void scared_by_monster(unit * u)
|
||||
{
|
||||
int n;
|
||||
|
||||
switch (old_race(u_race(u))) {
|
||||
case RC_FIREDRAGON:
|
||||
n = rng_int() % 160 * u->number;
|
||||
break;
|
||||
case RC_DRAGON:
|
||||
n = rng_int() % 400 * u->number;
|
||||
break;
|
||||
case RC_WYRM:
|
||||
n = rng_int() % 1000 * u->number;
|
||||
break;
|
||||
default:
|
||||
n = rng_int() % (u->number / 4 + 1);
|
||||
const race *rc = u_race(u);
|
||||
attrib *a;
|
||||
a = a_find(rc->attribs, &at_scare);
|
||||
if (a) {
|
||||
n = rng_int() & a->data.i * u->number;
|
||||
} else {
|
||||
switch (old_race(u_race(u))) {
|
||||
case RC_FIREDRAGON:
|
||||
n = rng_int() % 160 * u->number;
|
||||
break;
|
||||
case RC_DRAGON:
|
||||
n = rng_int() % 400 * u->number;
|
||||
break;
|
||||
case RC_WYRM:
|
||||
n = rng_int() % 1000 * u->number;
|
||||
break;
|
||||
default:
|
||||
n = rng_int() % (u->number / 4 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
n = lovar(n);
|
||||
n = _min(rpeasants(u->region), n);
|
||||
|
|
Loading…
Reference in a new issue