forked from github/server
indentation rules, strictly applied
This commit is contained in:
parent
6286c3212d
commit
347a888b67
|
@ -10,28 +10,34 @@
|
|||
|
||||
#include <tolua.h>
|
||||
|
||||
static int
|
||||
tolua_levitate_ship(lua_State * L)
|
||||
static int tolua_levitate_ship(lua_State * L)
|
||||
{
|
||||
ship * sh = (ship *)tolua_tousertype(L, 1, 0);
|
||||
unit * mage = (unit *)tolua_tousertype(L, 2, 0);
|
||||
ship *sh = (ship *) tolua_tousertype(L, 1, 0);
|
||||
|
||||
unit *mage = (unit *) tolua_tousertype(L, 2, 0);
|
||||
|
||||
double power = (double)tolua_tonumber(L, 3, 0);
|
||||
|
||||
int duration = (int)tolua_tonumber(L, 4, 0);
|
||||
|
||||
int cno = levitate_ship(sh, mage, power, duration);
|
||||
tolua_pushnumber(L, (lua_Number)cno);
|
||||
|
||||
tolua_pushnumber(L, (lua_Number) cno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
extern void spawn_undead(void);
|
||||
|
||||
extern void spawn_dragons(void);
|
||||
extern void plan_monsters(struct faction * f);
|
||||
|
||||
extern void plan_monsters(struct faction *f);
|
||||
|
||||
|
||||
static int
|
||||
tolua_planmonsters(lua_State * L)
|
||||
static int tolua_planmonsters(lua_State * L)
|
||||
{
|
||||
faction * f = (faction *)tolua_tousertype(L, 1, get_monsters());
|
||||
faction *f = (faction *) tolua_tousertype(L, 1, get_monsters());
|
||||
|
||||
if (f) {
|
||||
plan_monsters(f);
|
||||
}
|
||||
|
@ -39,31 +45,32 @@ tolua_planmonsters(lua_State * L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tolua_spawn_dragons(lua_State * L)
|
||||
static int tolua_spawn_dragons(lua_State * L)
|
||||
{
|
||||
spawn_dragons();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tolua_spawn_undead(lua_State * L)
|
||||
static int tolua_spawn_undead(lua_State * L)
|
||||
{
|
||||
spawn_undead();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
fix_familiars(struct lua_State * L)
|
||||
static int fix_familiars(struct lua_State *L)
|
||||
{
|
||||
faction * f;
|
||||
for (f=factions;f;f=f->next) {
|
||||
unit * u;
|
||||
for (u=f->units;u;u=u->nextF) {
|
||||
struct sc_mage * mage = get_mage(u);
|
||||
faction *f;
|
||||
|
||||
for (f = factions; f; f = f->next) {
|
||||
unit *u;
|
||||
|
||||
for (u = f->units; u; u = u->nextF) {
|
||||
struct sc_mage *mage = get_mage(u);
|
||||
|
||||
if (mage && is_familiar(u)) {
|
||||
if (mage->spells && mage->magietyp==M_GRAY) {
|
||||
equipment * eq;
|
||||
if (mage->spells && mage->magietyp == M_GRAY) {
|
||||
equipment *eq;
|
||||
|
||||
char buffer[64];
|
||||
|
||||
ql_free(mage->spells);
|
||||
|
@ -80,8 +87,7 @@ fix_familiars(struct lua_State * L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
bind_eressea(struct lua_State * L)
|
||||
void bind_eressea(struct lua_State *L)
|
||||
{
|
||||
tolua_module(L, NULL, 0);
|
||||
tolua_beginmodule(L, NULL);
|
||||
|
@ -94,4 +100,3 @@ bind_eressea(struct lua_State * L)
|
|||
}
|
||||
tolua_endmodule(L);
|
||||
}
|
||||
|
||||
|
|
252
src/curses.c
252
src/curses.c
|
@ -29,38 +29,42 @@
|
|||
#include <assert.h>
|
||||
|
||||
typedef struct wallcurse {
|
||||
curse * buddy;
|
||||
connection * wall;
|
||||
curse *buddy;
|
||||
connection *wall;
|
||||
} wallcurse;
|
||||
|
||||
void
|
||||
cw_init(attrib * a) {
|
||||
curse * c;
|
||||
void cw_init(attrib * a)
|
||||
{
|
||||
curse *c;
|
||||
|
||||
curse_init(a);
|
||||
c = (curse*)a->data.v;
|
||||
c = (curse *) a->data.v;
|
||||
c->data.v = calloc(sizeof(wallcurse), 1);
|
||||
}
|
||||
|
||||
void
|
||||
cw_write(const attrib * a, const void * target, storage * store) {
|
||||
connection * b = ((wallcurse*)((curse*)a->data.v)->data.v)->wall;
|
||||
void cw_write(const attrib * a, const void *target, storage * store)
|
||||
{
|
||||
connection *b = ((wallcurse *) ((curse *) a->data.v)->data.v)->wall;
|
||||
|
||||
curse_write(a, target, store);
|
||||
store->w_int(store, b->id);
|
||||
}
|
||||
|
||||
typedef struct bresvole {
|
||||
unsigned int id;
|
||||
curse * self;
|
||||
curse *self;
|
||||
} bresolve;
|
||||
|
||||
static int resolve_buddy(variant data, void * addr);
|
||||
static int resolve_buddy(variant data, void *addr);
|
||||
|
||||
static int
|
||||
cw_read(attrib * a, void * target, storage * store)
|
||||
static int cw_read(attrib * a, void *target, storage * store)
|
||||
{
|
||||
bresolve * br = calloc(sizeof(bresolve), 1);
|
||||
curse * c = (curse*)a->data.v;
|
||||
wallcurse * wc = (wallcurse*)c->data.v;
|
||||
bresolve *br = calloc(sizeof(bresolve), 1);
|
||||
|
||||
curse *c = (curse *) a->data.v;
|
||||
|
||||
wallcurse *wc = (wallcurse *) c->data.v;
|
||||
|
||||
variant var;
|
||||
|
||||
curse_read(a, store, target);
|
||||
|
@ -75,8 +79,7 @@ cw_read(attrib * a, void * target, storage * store)
|
|||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
attrib_type at_cursewall =
|
||||
{
|
||||
attrib_type at_cursewall = {
|
||||
"cursewall",
|
||||
cw_init,
|
||||
curse_done,
|
||||
|
@ -87,69 +90,77 @@ attrib_type at_cursewall =
|
|||
};
|
||||
|
||||
|
||||
static int
|
||||
resolve_buddy(variant data, void * addr)
|
||||
static int resolve_buddy(variant data, void *addr)
|
||||
{
|
||||
curse * result = NULL;
|
||||
bresolve * br = (bresolve*)data.v;
|
||||
curse *result = NULL;
|
||||
|
||||
if (br->id>=0) {
|
||||
connection * b = find_border(br->id);
|
||||
bresolve *br = (bresolve *) data.v;
|
||||
|
||||
if (br->id >= 0) {
|
||||
connection *b = find_border(br->id);
|
||||
|
||||
if (b && b->from && b->to) {
|
||||
attrib * a = a_find(b->from->attribs, &at_cursewall);
|
||||
while (a && a->data.v!=br->self) {
|
||||
curse * c = (curse*)a->data.v;
|
||||
wallcurse * wc = (wallcurse*)c->data.v;
|
||||
if (wc->wall->id==br->id) break;
|
||||
attrib *a = a_find(b->from->attribs, &at_cursewall);
|
||||
|
||||
while (a && a->data.v != br->self) {
|
||||
curse *c = (curse *) a->data.v;
|
||||
|
||||
wallcurse *wc = (wallcurse *) c->data.v;
|
||||
|
||||
if (wc->wall->id == br->id)
|
||||
break;
|
||||
a = a->next;
|
||||
}
|
||||
if (!a || a->type!=&at_cursewall) {
|
||||
if (!a || a->type != &at_cursewall) {
|
||||
a = a_find(b->to->attribs, &at_cursewall);
|
||||
while (a && a->type==&at_cursewall && a->data.v!=br->self) {
|
||||
curse * c = (curse*)a->data.v;
|
||||
wallcurse * wc = (wallcurse*)c->data.v;
|
||||
if (wc->wall->id==br->id) break;
|
||||
while (a && a->type == &at_cursewall && a->data.v != br->self) {
|
||||
curse *c = (curse *) a->data.v;
|
||||
|
||||
wallcurse *wc = (wallcurse *) c->data.v;
|
||||
|
||||
if (wc->wall->id == br->id)
|
||||
break;
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
if (a && a->type==&at_cursewall) {
|
||||
curse * c = (curse*)a->data.v;
|
||||
if (a && a->type == &at_cursewall) {
|
||||
curse *c = (curse *) a->data.v;
|
||||
|
||||
free(br);
|
||||
result = c;
|
||||
}
|
||||
} else {
|
||||
/* fail, object does not exist (but if you're still loading then
|
||||
* you may want to try again later) */
|
||||
*(curse**)addr = NULL;
|
||||
* you may want to try again later) */
|
||||
*(curse **) addr = NULL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
*(curse**)addr = result;
|
||||
*(curse **) addr = result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
wall_init(connection * b)
|
||||
static void wall_init(connection * b)
|
||||
{
|
||||
wall_data * fd = (wall_data*)calloc(sizeof(wall_data), 1);
|
||||
fd->countdown = -1; /* infinite */
|
||||
wall_data *fd = (wall_data *) calloc(sizeof(wall_data), 1);
|
||||
|
||||
fd->countdown = -1; /* infinite */
|
||||
b->data.v = fd;
|
||||
}
|
||||
|
||||
static void
|
||||
wall_destroy(connection * b)
|
||||
static void wall_destroy(connection * b)
|
||||
{
|
||||
free(b->data.v);
|
||||
}
|
||||
|
||||
static void
|
||||
wall_read(connection * b, storage * store)
|
||||
static void wall_read(connection * b, storage * store)
|
||||
{
|
||||
wall_data * fd = (wall_data*)b->data.v;
|
||||
wall_data *fd = (wall_data *) b->data.v;
|
||||
|
||||
variant mno;
|
||||
|
||||
assert(fd);
|
||||
if (store->version<STORAGE_VERSION) {
|
||||
if (store->version < STORAGE_VERSION) {
|
||||
mno.i = store->r_int(store);
|
||||
fd->mage = findunit(mno.i);
|
||||
if (!fd->mage) {
|
||||
|
@ -159,43 +170,46 @@ wall_read(connection * b, storage * store)
|
|||
read_reference(&fd->mage, store, read_unit_reference, resolve_unit);
|
||||
}
|
||||
fd->force = store->r_int(store);
|
||||
if (store->version>=NOBORDERATTRIBS_VERSION) {
|
||||
if (store->version >= NOBORDERATTRIBS_VERSION) {
|
||||
fd->countdown = store->r_int(store);
|
||||
}
|
||||
fd->active = true;
|
||||
}
|
||||
|
||||
static void
|
||||
wall_write(const connection * b, storage * store)
|
||||
static void wall_write(const connection * b, storage * store)
|
||||
{
|
||||
wall_data * fd = (wall_data*)b->data.v;
|
||||
wall_data *fd = (wall_data *) b->data.v;
|
||||
|
||||
write_unit_reference(fd->mage, store);
|
||||
store->w_int(store, fd->force);
|
||||
store->w_int(store, fd->countdown);
|
||||
}
|
||||
|
||||
static int
|
||||
wall_age(connection * b)
|
||||
static int wall_age(connection * b)
|
||||
{
|
||||
wall_data * fd = (wall_data*)b->data.v;
|
||||
wall_data *fd = (wall_data *) b->data.v;
|
||||
|
||||
--fd->countdown;
|
||||
return (fd->countdown>0)?AT_AGE_KEEP:AT_AGE_REMOVE;
|
||||
return (fd->countdown > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE;
|
||||
}
|
||||
|
||||
static region *
|
||||
wall_move(const connection * b, struct unit * u, struct region * from, struct region * to, boolean routing)
|
||||
static region *wall_move(const connection * b, struct unit *u,
|
||||
struct region *from, struct region *to, boolean routing)
|
||||
{
|
||||
wall_data * fd = (wall_data*)b->data.v;
|
||||
wall_data *fd = (wall_data *) b->data.v;
|
||||
|
||||
if (!routing && fd->active) {
|
||||
int hp = dice(3, fd->force) * u->number;
|
||||
|
||||
hp = MIN(u->hp, hp);
|
||||
u->hp -= hp;
|
||||
if (u->hp) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("firewall_damage",
|
||||
"region unit", from, u));
|
||||
}
|
||||
else ADDMSG(&u->faction->msgs, msg_message("firewall_death", "region unit", from, u));
|
||||
if (u->number>u->hp) {
|
||||
"region unit", from, u));
|
||||
} else
|
||||
ADDMSG(&u->faction->msgs, msg_message("firewall_death", "region unit",
|
||||
from, u));
|
||||
if (u->number > u->hp) {
|
||||
scale_number(u, u->hp);
|
||||
u->hp = u->number;
|
||||
}
|
||||
|
@ -203,32 +217,36 @@ wall_move(const connection * b, struct unit * u, struct region * from, struct re
|
|||
return to;
|
||||
}
|
||||
|
||||
static const char *
|
||||
b_namefirewall(const connection * b, const region * r, const faction * f, int gflags)
|
||||
static const char *b_namefirewall(const connection * b, const region * r,
|
||||
const faction * f, int gflags)
|
||||
{
|
||||
const char * bname;
|
||||
const char *bname;
|
||||
|
||||
unused(f);
|
||||
unused(r);
|
||||
unused(b);
|
||||
if (gflags & GF_ARTICLE) bname = "a_firewall";
|
||||
else bname = "firewall";
|
||||
if (gflags & GF_ARTICLE)
|
||||
bname = "a_firewall";
|
||||
else
|
||||
bname = "firewall";
|
||||
|
||||
if (gflags & GF_PURE) return bname;
|
||||
if (gflags & GF_PURE)
|
||||
return bname;
|
||||
return LOC(f->locale, mkname("border", bname));
|
||||
}
|
||||
|
||||
border_type bt_firewall = {
|
||||
"firewall", VAR_VOIDPTR,
|
||||
b_transparent, /* transparent */
|
||||
wall_init, /* init */
|
||||
wall_destroy, /* destroy */
|
||||
wall_read, /* read */
|
||||
wall_write, /* write */
|
||||
b_blocknone, /* block */
|
||||
b_namefirewall, /* name */
|
||||
b_rvisible, /* rvisible */
|
||||
b_finvisible, /* fvisible */
|
||||
b_uinvisible, /* uvisible */
|
||||
b_transparent, /* transparent */
|
||||
wall_init, /* init */
|
||||
wall_destroy, /* destroy */
|
||||
wall_read, /* read */
|
||||
wall_write, /* write */
|
||||
b_blocknone, /* block */
|
||||
b_namefirewall, /* name */
|
||||
b_rvisible, /* rvisible */
|
||||
b_finvisible, /* fvisible */
|
||||
b_uinvisible, /* uvisible */
|
||||
NULL,
|
||||
wall_move,
|
||||
wall_age
|
||||
|
@ -237,17 +255,19 @@ border_type bt_firewall = {
|
|||
void convert_firewall_timeouts(connection * b, attrib * a)
|
||||
{
|
||||
while (a) {
|
||||
if (b->type==&bt_firewall && a->type==&at_countdown) {
|
||||
wall_data * fd = (wall_data *)b->data.v;
|
||||
if (b->type == &bt_firewall && a->type == &at_countdown) {
|
||||
wall_data *fd = (wall_data *) b->data.v;
|
||||
|
||||
fd->countdown = a->data.i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
wisps_name(const connection * b, const region * r, const faction * f, int gflags)
|
||||
static const char *wisps_name(const connection * b, const region * r,
|
||||
const faction * f, int gflags)
|
||||
{
|
||||
const char * bname;
|
||||
const char *bname;
|
||||
|
||||
unused(f);
|
||||
unused(r);
|
||||
unused(b);
|
||||
|
@ -256,7 +276,8 @@ wisps_name(const connection * b, const region * r, const faction * f, int gflags
|
|||
} else {
|
||||
bname = "wisps";
|
||||
}
|
||||
if (gflags & GF_PURE) return bname;
|
||||
if (gflags & GF_PURE)
|
||||
return bname;
|
||||
return LOC(f->locale, mkname("border", bname));
|
||||
}
|
||||
|
||||
|
@ -265,31 +286,39 @@ typedef struct wisps_data {
|
|||
int rnd;
|
||||
} wisps_data;
|
||||
|
||||
static region *
|
||||
wisps_move(const connection * b, struct unit * u, struct region * from, struct region * next, boolean routing)
|
||||
static region *wisps_move(const connection * b, struct unit *u,
|
||||
struct region *from, struct region *next, boolean routing)
|
||||
{
|
||||
direction_t reldir = reldirection(from, next);
|
||||
wisps_data * wd = (wisps_data*)b->data.v;
|
||||
assert(reldir!=D_SPECIAL);
|
||||
|
||||
wisps_data *wd = (wisps_data *) b->data.v;
|
||||
|
||||
assert(reldir != D_SPECIAL);
|
||||
|
||||
if (routing && wd->wall.active) {
|
||||
region * rl = rconnect(from, (direction_t)((reldir+MAXDIRECTIONS-1)%MAXDIRECTIONS));
|
||||
region * rr = rconnect(from, (direction_t)((reldir+1)%MAXDIRECTIONS));
|
||||
region *rl =
|
||||
rconnect(from,
|
||||
(direction_t) ((reldir + MAXDIRECTIONS - 1) % MAXDIRECTIONS));
|
||||
region *rr = rconnect(from, (direction_t) ((reldir + 1) % MAXDIRECTIONS));
|
||||
|
||||
/* pick left and right region: */
|
||||
if (wd->rnd<0) {
|
||||
if (wd->rnd < 0) {
|
||||
wd->rnd = rng_int() % 3;
|
||||
}
|
||||
|
||||
if (wd->rnd == 1 && rl && fval(rl->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rl;
|
||||
if (wd->rnd == 2 && rr && fval(rr->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rr;
|
||||
if (wd->rnd == 1 && rl
|
||||
&& fval(rl->terrain, LAND_REGION) == fval(next, LAND_REGION))
|
||||
return rl;
|
||||
if (wd->rnd == 2 && rr
|
||||
&& fval(rr->terrain, LAND_REGION) == fval(next, LAND_REGION))
|
||||
return rr;
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
static void
|
||||
wisps_init(connection * b)
|
||||
static void wisps_init(connection * b)
|
||||
{
|
||||
wisps_data * wd = (wisps_data*)calloc(sizeof(wisps_data), 1);
|
||||
wisps_data *wd = (wisps_data *) calloc(sizeof(wisps_data), 1);
|
||||
|
||||
b->data.v = wd;
|
||||
wd->rnd = -1;
|
||||
|
@ -297,22 +326,21 @@ wisps_init(connection * b)
|
|||
|
||||
border_type bt_wisps = {
|
||||
"wisps", VAR_VOIDPTR,
|
||||
b_transparent, /* transparent */
|
||||
wisps_init, /* init */
|
||||
wall_destroy, /* destroy */
|
||||
wall_read, /* read */
|
||||
wall_write, /* write */
|
||||
b_blocknone, /* block */
|
||||
wisps_name, /* name */
|
||||
b_rvisible, /* rvisible */
|
||||
b_fvisible, /* fvisible */
|
||||
b_uvisible, /* uvisible */
|
||||
NULL, /* visible */
|
||||
b_transparent, /* transparent */
|
||||
wisps_init, /* init */
|
||||
wall_destroy, /* destroy */
|
||||
wall_read, /* read */
|
||||
wall_write, /* write */
|
||||
b_blocknone, /* block */
|
||||
wisps_name, /* name */
|
||||
b_rvisible, /* rvisible */
|
||||
b_fvisible, /* fvisible */
|
||||
b_uvisible, /* uvisible */
|
||||
NULL, /* visible */
|
||||
wisps_move
|
||||
};
|
||||
|
||||
void
|
||||
register_curses(void)
|
||||
void register_curses(void)
|
||||
{
|
||||
border_convert_cb = &convert_firewall_timeouts;
|
||||
at_register(&at_cursewall);
|
||||
|
@ -320,7 +348,7 @@ register_curses(void)
|
|||
register_bordertype(&bt_firewall);
|
||||
register_bordertype(&bt_wisps);
|
||||
register_bordertype(&bt_chaosgate);
|
||||
|
||||
|
||||
register_unitcurse();
|
||||
register_regioncurse();
|
||||
register_shipcurse();
|
||||
|
|
|
@ -7,14 +7,14 @@ extern "C" {
|
|||
extern void register_curses(void);
|
||||
|
||||
/* für Feuerwände: in movement muß das noch explizit getestet werden.
|
||||
** besser wäre eine blcok_type::move() routine, die den effekt
|
||||
** der Bewegung auf eine struct unit anwendet.
|
||||
**/
|
||||
** besser wäre eine blcok_type::move() routine, die den effekt
|
||||
** der Bewegung auf eine struct unit anwendet.
|
||||
**/
|
||||
extern struct border_type bt_chaosgate;
|
||||
extern struct border_type bt_firewall;
|
||||
|
||||
typedef struct wall_data {
|
||||
struct unit * mage;
|
||||
struct unit *mage;
|
||||
int force;
|
||||
boolean active;
|
||||
int countdown;
|
||||
|
|
201
src/main.c
201
src/main.c
|
@ -14,14 +14,18 @@
|
|||
|
||||
#include <tests.h>
|
||||
|
||||
static const char * luafile = "setup.lua";
|
||||
static const char * entry_point = NULL;
|
||||
static const char * inifile = "eressea.ini";
|
||||
static const char *luafile = "setup.lua";
|
||||
|
||||
static const char *entry_point = NULL;
|
||||
|
||||
static const char *inifile = "eressea.ini";
|
||||
|
||||
static int memdebug = 0;
|
||||
|
||||
static void parse_config(const char * filename)
|
||||
static void parse_config(const char *filename)
|
||||
{
|
||||
dictionary * d = iniparser_new(filename);
|
||||
dictionary *d = iniparser_new(filename);
|
||||
|
||||
if (d) {
|
||||
load_inifile(d);
|
||||
|
||||
|
@ -38,8 +42,7 @@ static void parse_config(const char * filename)
|
|||
global.inifile = d;
|
||||
}
|
||||
|
||||
static int
|
||||
usage(const char * prog, const char * arg)
|
||||
static int usage(const char *prog, const char *arg)
|
||||
{
|
||||
if (arg) {
|
||||
fprintf(stderr, "unknown argument: %s\n\n", arg);
|
||||
|
@ -50,64 +53,61 @@ usage(const char * prog, const char * arg)
|
|||
"-v <level> : verbosity level\n"
|
||||
"-C : run in interactive mode\n"
|
||||
"--color : force curses to use colors even when not detected\n"
|
||||
"--tests : run testsuite\n"
|
||||
"--help : help\n", prog);
|
||||
"--tests : run testsuite\n" "--help : help\n", prog);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
parse_args(int argc, char **argv, int *exitcode)
|
||||
static int parse_args(int argc, char **argv, int *exitcode)
|
||||
{
|
||||
int i;
|
||||
|
||||
int run_tests = 0;
|
||||
|
||||
for (i=1;i!=argc;++i) {
|
||||
if (argv[i][0]!='-') {
|
||||
for (i = 1; i != argc; ++i) {
|
||||
if (argv[i][0] != '-') {
|
||||
return usage(argv[0], argv[i]);
|
||||
} else if (argv[i][1]=='-') { /* long format */
|
||||
if (strcmp(argv[i]+2, "version")==0) {
|
||||
} else if (argv[i][1] == '-') { /* long format */
|
||||
if (strcmp(argv[i] + 2, "version") == 0) {
|
||||
printf("\n%s PBEM host\n"
|
||||
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
|
||||
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n", global.gamename, version());
|
||||
}
|
||||
else if (strcmp(argv[i]+2, "color")==0) {
|
||||
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n",
|
||||
global.gamename, version());
|
||||
} else if (strcmp(argv[i] + 2, "color") == 0) {
|
||||
/* force the editor to have colors */
|
||||
force_color = 1;
|
||||
}
|
||||
else if (strcmp(argv[i]+2, "tests")==0) {
|
||||
} else if (strcmp(argv[i] + 2, "tests") == 0) {
|
||||
/* force the editor to have colors */
|
||||
run_tests = 1;
|
||||
}
|
||||
else if (strcmp(argv[i]+2, "help")==0) {
|
||||
} else if (strcmp(argv[i] + 2, "help") == 0) {
|
||||
return usage(argv[0], NULL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return usage(argv[0], argv[i]);
|
||||
}
|
||||
} else switch(argv[i][1]) {
|
||||
case 'C':
|
||||
entry_point = NULL;
|
||||
break;
|
||||
case 'e':
|
||||
entry_point = argv[++i];
|
||||
break;
|
||||
case 't':
|
||||
turn = atoi(argv[++i]);
|
||||
break;
|
||||
case 'q':
|
||||
verbosity = 0;
|
||||
break;
|
||||
case 'v':
|
||||
verbosity = atoi(argv[++i]);
|
||||
break;
|
||||
case 'h':
|
||||
usage(argv[0], NULL);
|
||||
return 1;
|
||||
default:
|
||||
*exitcode = -1;
|
||||
usage(argv[0], argv[i]);
|
||||
return 1;
|
||||
}
|
||||
} else
|
||||
switch (argv[i][1]) {
|
||||
case 'C':
|
||||
entry_point = NULL;
|
||||
break;
|
||||
case 'e':
|
||||
entry_point = argv[++i];
|
||||
break;
|
||||
case 't':
|
||||
turn = atoi(argv[++i]);
|
||||
break;
|
||||
case 'q':
|
||||
verbosity = 0;
|
||||
break;
|
||||
case 'v':
|
||||
verbosity = atoi(argv[++i]);
|
||||
break;
|
||||
case 'h':
|
||||
usage(argv[0], NULL);
|
||||
return 1;
|
||||
default:
|
||||
*exitcode = -1;
|
||||
usage(argv[0], argv[i]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (run_tests) {
|
||||
|
@ -122,11 +122,12 @@ parse_args(int argc, char **argv, int *exitcode)
|
|||
#include <execinfo.h>
|
||||
#include <signal.h>
|
||||
|
||||
static void
|
||||
report_segfault(int signo, siginfo_t * sinf, void * arg)
|
||||
static void report_segfault(int signo, siginfo_t * sinf, void *arg)
|
||||
{
|
||||
void * btrace[50];
|
||||
void *btrace[50];
|
||||
|
||||
size_t size;
|
||||
|
||||
int fd = fileno(stderr);
|
||||
|
||||
fflush(stdout);
|
||||
|
@ -136,8 +137,7 @@ report_segfault(int signo, siginfo_t * sinf, void * arg)
|
|||
abort();
|
||||
}
|
||||
|
||||
static int
|
||||
setup_signal_handler(void)
|
||||
static int setup_signal_handler(void)
|
||||
{
|
||||
struct sigaction act;
|
||||
|
||||
|
@ -147,8 +147,7 @@ setup_signal_handler(void)
|
|||
return sigaction(SIGSEGV, &act, NULL);
|
||||
}
|
||||
#else
|
||||
static int
|
||||
setup_signal_handler(void)
|
||||
static int setup_signal_handler(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -157,19 +156,19 @@ setup_signal_handler(void)
|
|||
#undef CRTDBG
|
||||
#ifdef CRTDBG
|
||||
#include <crtdbg.h>
|
||||
void
|
||||
init_crtdbg(void)
|
||||
void init_crtdbg(void)
|
||||
{
|
||||
#if (defined(_MSC_VER))
|
||||
int flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
|
||||
if (memdebug==1) {
|
||||
flags |= _CRTDBG_CHECK_ALWAYS_DF; /* expensive */
|
||||
} else if (memdebug==2) {
|
||||
flags = (flags&0x0000FFFF) | _CRTDBG_CHECK_EVERY_16_DF;
|
||||
} else if (memdebug==3) {
|
||||
flags = (flags&0x0000FFFF) | _CRTDBG_CHECK_EVERY_128_DF;
|
||||
} else if (memdebug==4) {
|
||||
flags = (flags&0x0000FFFF) | _CRTDBG_CHECK_EVERY_1024_DF;
|
||||
|
||||
if (memdebug == 1) {
|
||||
flags |= _CRTDBG_CHECK_ALWAYS_DF; /* expensive */
|
||||
} else if (memdebug == 2) {
|
||||
flags = (flags & 0x0000FFFF) | _CRTDBG_CHECK_EVERY_16_DF;
|
||||
} else if (memdebug == 3) {
|
||||
flags = (flags & 0x0000FFFF) | _CRTDBG_CHECK_EVERY_128_DF;
|
||||
} else if (memdebug == 4) {
|
||||
flags = (flags & 0x0000FFFF) | _CRTDBG_CHECK_EVERY_1024_DF;
|
||||
}
|
||||
_CrtSetDbgFlag(flags);
|
||||
#endif
|
||||
|
@ -177,51 +176,63 @@ init_crtdbg(void)
|
|||
#endif
|
||||
|
||||
|
||||
static void
|
||||
dump_spells(void)
|
||||
static void dump_spells(void)
|
||||
{
|
||||
struct locale * loc = find_locale("de");
|
||||
FILE * F = fopen("spells.csv", "w");
|
||||
quicklist * ql;
|
||||
struct locale *loc = find_locale("de");
|
||||
|
||||
FILE *F = fopen("spells.csv", "w");
|
||||
|
||||
quicklist *ql;
|
||||
|
||||
int qi;
|
||||
|
||||
for (ql=spells,qi=0;ql;ql_advance(&ql, &qi, 1)) {
|
||||
spell * sp = (spell *)ql_get(ql, qi);
|
||||
spell_component * spc = sp->components;
|
||||
for (ql = spells, qi = 0; ql; ql_advance(&ql, &qi, 1)) {
|
||||
spell *sp = (spell *) ql_get(ql, qi);
|
||||
|
||||
spell_component *spc = sp->components;
|
||||
|
||||
char components[128];
|
||||
components[0]=0;
|
||||
for (;spc->type;++spc) {
|
||||
|
||||
components[0] = 0;
|
||||
for (; spc->type; ++spc) {
|
||||
strcat(components, LOC(loc, spc->type->_name[0]));
|
||||
strcat(components, ",");
|
||||
}
|
||||
fprintf(F, "%s;%d;%s;%s\n", LOC(loc, mkname("spell", sp->sname)), sp->level, LOC(loc, mkname("school", magic_school[sp->magietyp])), components);
|
||||
fprintf(F, "%s;%d;%s;%s\n", LOC(loc, mkname("spell", sp->sname)), sp->level,
|
||||
LOC(loc, mkname("school", magic_school[sp->magietyp])), components);
|
||||
}
|
||||
fclose(F);
|
||||
}
|
||||
|
||||
static void
|
||||
dump_skills(void)
|
||||
static void dump_skills(void)
|
||||
{
|
||||
struct locale * loc = find_locale("de");
|
||||
FILE * F = fopen("skills.csv", "w");
|
||||
race * rc;
|
||||
struct locale *loc = find_locale("de");
|
||||
|
||||
FILE *F = fopen("skills.csv", "w");
|
||||
|
||||
race *rc;
|
||||
|
||||
skill_t sk;
|
||||
|
||||
fputs("\"Rasse\",", F);
|
||||
for (rc=races;rc;rc = rc->next) {
|
||||
for (rc = races; rc; rc = rc->next) {
|
||||
if (playerrace(rc)) {
|
||||
fprintf(F, "\"%s\",", LOC(loc, mkname("race", rc->_name[0])));
|
||||
}
|
||||
}
|
||||
fputc('\n', F);
|
||||
|
||||
for (sk=0;sk!=MAXSKILLS;++sk) {
|
||||
const char * str = skillname(sk, loc);
|
||||
for (sk = 0; sk != MAXSKILLS; ++sk) {
|
||||
const char *str = skillname(sk, loc);
|
||||
|
||||
if (str) {
|
||||
fprintf(F, "\"%s\",", str);
|
||||
for (rc=races;rc;rc = rc->next) {
|
||||
for (rc = races; rc; rc = rc->next) {
|
||||
if (playerrace(rc)) {
|
||||
if (rc->bonus[sk]) fprintf(F, "%d,", rc->bonus[sk]);
|
||||
else fputc(',', F);
|
||||
if (rc->bonus[sk])
|
||||
fprintf(F, "%d,", rc->bonus[sk]);
|
||||
else
|
||||
fputc(',', F);
|
||||
}
|
||||
}
|
||||
fputc('\n', F);
|
||||
|
@ -234,16 +245,19 @@ void locale_init(void)
|
|||
{
|
||||
setlocale(LC_CTYPE, "");
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
if (towlower(0xC4)!=0xE4) { /* Ä => ä */
|
||||
log_error(("Umlaut conversion is not working properly. Wrong locale? LANG=%s\n", getenv("LANG")));
|
||||
if (towlower(0xC4) != 0xE4) { /* Ä => ä */
|
||||
log_error(
|
||||
("Umlaut conversion is not working properly. Wrong locale? LANG=%s\n",
|
||||
getenv("LANG")));
|
||||
}
|
||||
}
|
||||
|
||||
extern void bind_eressea(struct lua_State * L);
|
||||
extern void bind_eressea(struct lua_State *L);
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static int write_csv = 0;
|
||||
|
||||
int err, result = 0;
|
||||
|
||||
setup_signal_handler();
|
||||
|
@ -282,13 +296,14 @@ int main(int argc, char ** argv)
|
|||
log_error(("server execution failed with code %d\n", err));
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef MSPACES
|
||||
malloc_stats();
|
||||
#endif
|
||||
|
||||
eressea_done();
|
||||
log_close();
|
||||
if (global.inifile) iniparser_free(global.inifile);
|
||||
if (global.inifile)
|
||||
iniparser_free(global.inifile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
947
src/monsters.c
947
src/monsters.c
File diff suppressed because it is too large
Load Diff
|
@ -27,26 +27,25 @@
|
|||
#define DRAGONAGE 27
|
||||
#define WYRMAGE 68
|
||||
|
||||
void
|
||||
age_firedragon(unit *u)
|
||||
void age_firedragon(unit * u)
|
||||
{
|
||||
if (u->number>0 && rng_int()%100 < age_chance(u->age, DRAGONAGE, 1)) {
|
||||
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
|
||||
if (u->number > 0 && rng_int() % 100 < age_chance(u->age, DRAGONAGE, 1)) {
|
||||
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
|
||||
|
||||
u->race = new_race[RC_DRAGON];
|
||||
u->irace = NULL;
|
||||
scale_number(u,1);
|
||||
u->hp = (int) (unit_max_hp(u) * u->number * q);
|
||||
scale_number(u, 1);
|
||||
u->hp = (int)(unit_max_hp(u) * u->number * q);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
age_dragon(unit *u)
|
||||
void age_dragon(unit * u)
|
||||
{
|
||||
if (u->number>0 && rng_int()%100 < age_chance(u->age, WYRMAGE, 1)) {
|
||||
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
|
||||
if (u->number > 0 && rng_int() % 100 < age_chance(u->age, WYRMAGE, 1)) {
|
||||
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
|
||||
|
||||
u->race = new_race[RC_WYRM];
|
||||
u->irace = NULL;
|
||||
u->hp = (int) (unit_max_hp(u) * u->number * q);
|
||||
u->hp = (int)(unit_max_hp(u) * u->number * q);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,13 +26,11 @@
|
|||
|
||||
#define ILLUSIONMAX 6
|
||||
|
||||
void
|
||||
age_illusion(unit *u)
|
||||
void age_illusion(unit * u)
|
||||
{
|
||||
if (u->faction->race!=new_race[RC_ILLUSION]) {
|
||||
if (u->faction->race != new_race[RC_ILLUSION]) {
|
||||
if (u->age == ILLUSIONMAX) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("warnillusiondissolve",
|
||||
"unit", u));
|
||||
ADDMSG(&u->faction->msgs, msg_message("warnillusiondissolve", "unit", u));
|
||||
} else if (u->age > ILLUSIONMAX) {
|
||||
set_number(u, 0);
|
||||
ADDMSG(&u->faction->msgs, msg_message("illusiondissolve", "unit", u));
|
||||
|
|
|
@ -28,97 +28,104 @@
|
|||
#include <util/rng.h>
|
||||
|
||||
void age_firedragon(struct unit *u);
|
||||
|
||||
void age_dragon(struct unit *u);
|
||||
|
||||
void age_illusion(struct unit *u);
|
||||
|
||||
void age_undead(struct unit *u);
|
||||
|
||||
void age_skeleton(struct unit *u);
|
||||
|
||||
void age_zombie(struct unit *u);
|
||||
|
||||
void age_ghoul(struct unit *u);
|
||||
|
||||
static void
|
||||
oldfamiliars(unit * u)
|
||||
static void oldfamiliars(unit * u)
|
||||
{
|
||||
char fname[64];
|
||||
|
||||
/* these familiars have no special skills.
|
||||
*/
|
||||
*/
|
||||
snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]);
|
||||
create_mage(u, M_GRAY);
|
||||
equip_unit(u, get_equipment(fname));
|
||||
}
|
||||
|
||||
static void
|
||||
set_show_item(faction *f, item_t i)
|
||||
static void set_show_item(faction * f, item_t i)
|
||||
{
|
||||
attrib *a = a_add(&f->attribs, a_new(&at_showitem));
|
||||
a->data.v = (void*)olditemtype[i];
|
||||
|
||||
a->data.v = (void *)olditemtype[i];
|
||||
}
|
||||
|
||||
static void
|
||||
equip_newunits(const struct equipment * eq, struct unit *u)
|
||||
static void equip_newunits(const struct equipment *eq, struct unit *u)
|
||||
{
|
||||
struct region *r = u->region;
|
||||
|
||||
switch (old_race(u->race)) {
|
||||
case RC_ELF:
|
||||
set_show_item(u->faction, I_FEENSTIEFEL);
|
||||
break;
|
||||
case RC_GOBLIN:
|
||||
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
|
||||
set_number(u, 10);
|
||||
break;
|
||||
case RC_HUMAN:
|
||||
if (u->building==NULL) {
|
||||
const building_type * btype = bt_find("castle");
|
||||
if (btype!=NULL) {
|
||||
building *b = new_building(btype, r, u->faction->locale);
|
||||
b->size = 10;
|
||||
u->building = b;
|
||||
fset(u, UFL_OWNER);
|
||||
case RC_ELF:
|
||||
set_show_item(u->faction, I_FEENSTIEFEL);
|
||||
break;
|
||||
case RC_GOBLIN:
|
||||
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
|
||||
set_number(u, 10);
|
||||
break;
|
||||
case RC_HUMAN:
|
||||
if (u->building == NULL) {
|
||||
const building_type *btype = bt_find("castle");
|
||||
|
||||
if (btype != NULL) {
|
||||
building *b = new_building(btype, r, u->faction->locale);
|
||||
|
||||
b->size = 10;
|
||||
u->building = b;
|
||||
fset(u, UFL_OWNER);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RC_CAT:
|
||||
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
|
||||
break;
|
||||
case RC_AQUARIAN:
|
||||
break;
|
||||
case RC_CAT:
|
||||
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
|
||||
break;
|
||||
case RC_AQUARIAN:
|
||||
{
|
||||
ship *sh = new_ship(st_find("boat"), u->faction->locale, r);
|
||||
|
||||
sh->size = sh->type->construction->maxsize;
|
||||
u->ship = sh;
|
||||
fset(u, UFL_OWNER);
|
||||
}
|
||||
break;
|
||||
case RC_CENTAUR:
|
||||
rsethorses(r, 250+rng_int()%51+rng_int()%51);
|
||||
break;
|
||||
break;
|
||||
case RC_CENTAUR:
|
||||
rsethorses(r, 250 + rng_int() % 51 + rng_int() % 51);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Die Funktionen werden über den hier registrierten Namen in races.xml
|
||||
* in die jeweilige Rassendefiniton eingebunden */
|
||||
void
|
||||
register_races(void)
|
||||
void register_races(void)
|
||||
{
|
||||
/* function initfamiliar */
|
||||
register_function((pf_generic)oldfamiliars, "oldfamiliars");
|
||||
register_function((pf_generic) oldfamiliars, "oldfamiliars");
|
||||
|
||||
register_function((pf_generic)allowed_dragon, "movedragon");
|
||||
register_function((pf_generic) allowed_dragon, "movedragon");
|
||||
|
||||
register_function((pf_generic)allowed_swim, "moveswimming");
|
||||
register_function((pf_generic)allowed_fly, "moveflying");
|
||||
register_function((pf_generic)allowed_walk, "movewalking");
|
||||
register_function((pf_generic) allowed_swim, "moveswimming");
|
||||
register_function((pf_generic) allowed_fly, "moveflying");
|
||||
register_function((pf_generic) allowed_walk, "movewalking");
|
||||
|
||||
/* function age for race->age() */
|
||||
register_function((pf_generic)age_undead, "ageundead");
|
||||
register_function((pf_generic)age_illusion, "ageillusion");
|
||||
register_function((pf_generic)age_skeleton, "ageskeleton");
|
||||
register_function((pf_generic)age_zombie, "agezombie");
|
||||
register_function((pf_generic)age_ghoul, "ageghoul");
|
||||
register_function((pf_generic)age_dragon, "agedragon");
|
||||
register_function((pf_generic)age_firedragon, "agefiredragon");
|
||||
register_function((pf_generic) age_undead, "ageundead");
|
||||
register_function((pf_generic) age_illusion, "ageillusion");
|
||||
register_function((pf_generic) age_skeleton, "ageskeleton");
|
||||
register_function((pf_generic) age_zombie, "agezombie");
|
||||
register_function((pf_generic) age_ghoul, "ageghoul");
|
||||
register_function((pf_generic) age_dragon, "agedragon");
|
||||
register_function((pf_generic) age_firedragon, "agefiredragon");
|
||||
|
||||
/* function itemdrop
|
||||
* to generate battle spoils
|
||||
* race->itemdrop() */
|
||||
register_function((pf_generic)equip_newunits, "equip_newunits");
|
||||
* to generate battle spoils
|
||||
* race->itemdrop() */
|
||||
register_function((pf_generic) equip_newunits, "equip_newunits");
|
||||
}
|
||||
|
|
|
@ -20,6 +20,4 @@ extern "C" {
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -26,29 +26,32 @@
|
|||
/* libc includes */
|
||||
#include <stdlib.h>
|
||||
|
||||
#define UNDEAD_MIN 90 /* mind. zahl vor weg gehen */
|
||||
#define UNDEAD_BREAKUP 25 /* chance dafuer */
|
||||
#define UNDEAD_BREAKUP_FRACTION (25+rng_int()%70) /* anteil der weg geht */
|
||||
#define UNDEAD_MIN 90 /* mind. zahl vor weg gehen */
|
||||
#define UNDEAD_BREAKUP 25 /* chance dafuer */
|
||||
#define UNDEAD_BREAKUP_FRACTION (25+rng_int()%70) /* anteil der weg geht */
|
||||
|
||||
#define age_chance(a,b,p) (MAX(0,a-b)*p)
|
||||
|
||||
void
|
||||
age_undead(unit *u)
|
||||
void age_undead(unit * u)
|
||||
{
|
||||
region *r = u->region;
|
||||
|
||||
int n = 0;
|
||||
|
||||
/* untote, die einer partei angehoeren, koennen sich
|
||||
* absplitten, anstatt sich zu vermehren. monster
|
||||
* untote vermehren sich nur noch */
|
||||
* absplitten, anstatt sich zu vermehren. monster
|
||||
* untote vermehren sich nur noch */
|
||||
|
||||
if (u->number > UNDEAD_MIN && !is_monsters(u->faction) && rng_int() % 100 < UNDEAD_BREAKUP) {
|
||||
if (u->number > UNDEAD_MIN && !is_monsters(u->faction)
|
||||
&& rng_int() % 100 < UNDEAD_BREAKUP) {
|
||||
int m;
|
||||
|
||||
unit *u2;
|
||||
|
||||
n = 0;
|
||||
for (m = u->number; m; m--) {
|
||||
if (rng_int() % 100 < UNDEAD_BREAKUP_FRACTION) ++n;
|
||||
if (rng_int() % 100 < UNDEAD_BREAKUP_FRACTION)
|
||||
++n;
|
||||
}
|
||||
u2 = create_unit(r, get_monsters(), 0, new_race[RC_UNDEAD], 0, NULL, u);
|
||||
make_undead_unit(u2);
|
||||
|
@ -56,42 +59,44 @@ age_undead(unit *u)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
age_skeleton(unit *u)
|
||||
void age_skeleton(unit * u)
|
||||
{
|
||||
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) {
|
||||
int n = MAX(1,u->number/2);
|
||||
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
|
||||
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
|
||||
int n = MAX(1, u->number / 2);
|
||||
|
||||
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
|
||||
|
||||
u->race = new_race[RC_SKELETON_LORD];
|
||||
u->irace = NULL;
|
||||
scale_number(u,n);
|
||||
u->hp = (int) (unit_max_hp(u) * u->number * q);
|
||||
scale_number(u, n);
|
||||
u->hp = (int)(unit_max_hp(u) * u->number * q);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
age_zombie(unit *u)
|
||||
void age_zombie(unit * u)
|
||||
{
|
||||
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) {
|
||||
int n = MAX(1,u->number/2);
|
||||
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
|
||||
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
|
||||
int n = MAX(1, u->number / 2);
|
||||
|
||||
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
|
||||
|
||||
u->race = new_race[RC_ZOMBIE_LORD];
|
||||
u->irace = NULL;
|
||||
scale_number(u,n);
|
||||
u->hp = (int) (unit_max_hp(u) * u->number * q);
|
||||
scale_number(u, n);
|
||||
u->hp = (int)(unit_max_hp(u) * u->number * q);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
age_ghoul(unit *u)
|
||||
void age_ghoul(unit * u)
|
||||
{
|
||||
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) {
|
||||
int n = MAX(1,u->number/2);
|
||||
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
|
||||
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
|
||||
int n = MAX(1, u->number / 2);
|
||||
|
||||
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
|
||||
|
||||
u->race = new_race[RC_GHOUL_LORD];
|
||||
u->irace = NULL;
|
||||
scale_number(u,n);
|
||||
u->hp = (int) (unit_max_hp(u) * u->number * q);
|
||||
scale_number(u, n);
|
||||
u->hp = (int)(unit_max_hp(u) * u->number * q);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
146
src/spells/alp.c
146
src/spells/alp.c
|
@ -44,94 +44,104 @@
|
|||
extern const char *directions[];
|
||||
|
||||
typedef struct alp_data {
|
||||
unit * mage;
|
||||
unit * target;
|
||||
unit *mage;
|
||||
unit *target;
|
||||
} alp_data;
|
||||
|
||||
static void
|
||||
alp_init(attrib * a)
|
||||
static void alp_init(attrib * a)
|
||||
{
|
||||
a->data.v = calloc(sizeof(alp_data), 1);
|
||||
a->data.v = calloc(sizeof(alp_data), 1);
|
||||
}
|
||||
|
||||
static void
|
||||
alp_done(attrib * a)
|
||||
static void alp_done(attrib * a)
|
||||
{
|
||||
free(a->data.v);
|
||||
free(a->data.v);
|
||||
}
|
||||
|
||||
static int
|
||||
alp_verify(attrib * a)
|
||||
static int alp_verify(attrib * a)
|
||||
{
|
||||
alp_data * ad = (alp_data*)a->data.v;
|
||||
if (ad->mage && ad->target) return 1;
|
||||
return 0; /* remove the attribute */
|
||||
alp_data *ad = (alp_data *) a->data.v;
|
||||
|
||||
if (ad->mage && ad->target)
|
||||
return 1;
|
||||
return 0; /* remove the attribute */
|
||||
}
|
||||
|
||||
static void
|
||||
alp_write(const attrib * a, const void * owner, struct storage * store)
|
||||
alp_write(const attrib * a, const void *owner, struct storage *store)
|
||||
{
|
||||
alp_data * ad = (alp_data*)a->data.v;
|
||||
alp_data *ad = (alp_data *) a->data.v;
|
||||
|
||||
write_unit_reference(ad->mage, store);
|
||||
write_unit_reference(ad->target, store);
|
||||
}
|
||||
|
||||
static int
|
||||
alp_read(attrib * a, void * owner, struct storage * store)
|
||||
static int alp_read(attrib * a, void *owner, struct storage *store)
|
||||
{
|
||||
alp_data * ad = (alp_data*)a->data.v;
|
||||
alp_data *ad = (alp_data *) a->data.v;
|
||||
|
||||
int rm = read_reference(&ad->mage, store, read_unit_reference, resolve_unit);
|
||||
int rt = read_reference(&ad->target, store, read_unit_reference, resolve_unit);
|
||||
if (rt==0 && rm==0 && (!ad->target || !ad->mage)) {
|
||||
|
||||
int rt =
|
||||
read_reference(&ad->target, store, read_unit_reference, resolve_unit);
|
||||
if (rt == 0 && rm == 0 && (!ad->target || !ad->mage)) {
|
||||
/* the target or mage disappeared. */
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
static attrib_type at_alp = {
|
||||
"alp",
|
||||
alp_init,
|
||||
alp_done,
|
||||
alp_verify,
|
||||
alp_write,
|
||||
static attrib_type at_alp = {
|
||||
"alp",
|
||||
alp_init,
|
||||
alp_done,
|
||||
alp_verify,
|
||||
alp_write,
|
||||
alp_read,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
int
|
||||
sp_summon_alp(struct castorder *co)
|
||||
int sp_summon_alp(struct castorder *co)
|
||||
{
|
||||
unit *alp, *opfer;
|
||||
|
||||
region *r = co->rt;
|
||||
|
||||
unit *mage = co->magician.u;
|
||||
|
||||
int cast_level = co->level;
|
||||
|
||||
spellparameter *pa = co->par;
|
||||
const struct race * rc = new_race[RC_ALP];
|
||||
struct faction * f = get_monsters();
|
||||
struct message * msg;
|
||||
|
||||
const struct race *rc = new_race[RC_ALP];
|
||||
|
||||
struct faction *f = get_monsters();
|
||||
|
||||
struct message *msg;
|
||||
|
||||
opfer = pa->param[0]->data.u;
|
||||
|
||||
/* Der Alp gehört den Monstern, darum erhält der Magier auch keine
|
||||
* Regionsberichte von ihm. Er erhält aber später eine Mitteilung,
|
||||
* sobald der Alp sein Opfer erreicht hat.
|
||||
*/
|
||||
* Regionsberichte von ihm. Er erhält aber später eine Mitteilung,
|
||||
* sobald der Alp sein Opfer erreicht hat.
|
||||
*/
|
||||
alp = create_unit(r, f, 1, rc, 0, NULL, NULL);
|
||||
set_level(alp, SK_STEALTH, 7);
|
||||
setstatus(alp, ST_FLEE); /* flieht */
|
||||
setstatus(alp, ST_FLEE); /* flieht */
|
||||
|
||||
{
|
||||
attrib * a = a_add(&alp->attribs, a_new(&at_alp));
|
||||
alp_data * ad = (alp_data*) a->data.v;
|
||||
attrib *a = a_add(&alp->attribs, a_new(&at_alp));
|
||||
|
||||
alp_data *ad = (alp_data *) a->data.v;
|
||||
|
||||
ad->mage = mage;
|
||||
ad->target = opfer;
|
||||
}
|
||||
|
||||
{
|
||||
/* Wenn der Alp stirbt, den Magier nachrichtigen */
|
||||
add_trigger(&alp->attribs, "destroy", trigger_unitmessage(mage,
|
||||
"trigger_alp_destroy", MSG_EVENT, ML_INFO));
|
||||
add_trigger(&alp->attribs, "destroy", trigger_unitmessage(mage,
|
||||
"trigger_alp_destroy", MSG_EVENT, ML_INFO));
|
||||
/* Wenn Opfer oder Magier nicht mehr existieren, dann stirbt der Alp */
|
||||
add_trigger(&mage->attribs, "destroy", trigger_killunit(alp));
|
||||
add_trigger(&opfer->attribs, "destroy", trigger_killunit(alp));
|
||||
|
@ -144,16 +154,21 @@ sp_summon_alp(struct castorder *co)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
alp_findet_opfer(unit *alp, region *r)
|
||||
void alp_findet_opfer(unit * alp, region * r)
|
||||
{
|
||||
curse * c;
|
||||
attrib * a = a_find(alp->attribs, &at_alp);
|
||||
alp_data * ad = (alp_data*)a->data.v;
|
||||
curse *c;
|
||||
|
||||
attrib *a = a_find(alp->attribs, &at_alp);
|
||||
|
||||
alp_data *ad = (alp_data *) a->data.v;
|
||||
|
||||
unit *mage = ad->mage;
|
||||
|
||||
unit *opfer = ad->target;
|
||||
|
||||
double effect;
|
||||
message * msg;
|
||||
|
||||
message *msg;
|
||||
|
||||
assert(opfer);
|
||||
assert(mage);
|
||||
|
@ -165,41 +180,42 @@ alp_findet_opfer(unit *alp, region *r)
|
|||
msg_release(msg);
|
||||
|
||||
/* Relations werden in destroy_unit(alp) automatisch gelöscht.
|
||||
* Die Aktionen, die beim Tod des Alps ausgelöst werden sollen,
|
||||
* müssen jetzt aber deaktiviert werden, sonst werden sie gleich
|
||||
* beim destroy_unit(alp) ausgelöst.
|
||||
*/
|
||||
* Die Aktionen, die beim Tod des Alps ausgelöst werden sollen,
|
||||
* müssen jetzt aber deaktiviert werden, sonst werden sie gleich
|
||||
* beim destroy_unit(alp) ausgelöst.
|
||||
*/
|
||||
a_removeall(&alp->attribs, &at_eventhandler);
|
||||
|
||||
/* Alp umwandeln in Curse */
|
||||
effect = -2;
|
||||
c = create_curse(mage, &opfer->attribs, ct_find("worse"), 2, 2, effect, opfer->number);
|
||||
c =
|
||||
create_curse(mage, &opfer->attribs, ct_find("worse"), 2, 2, effect,
|
||||
opfer->number);
|
||||
/* solange es noch keine spezielle alp-Antimagie gibt, reagiert der
|
||||
* auch auf normale */
|
||||
* auch auf normale */
|
||||
set_number(alp, 0);
|
||||
|
||||
/* wenn der Magier stirbt, wird der Curse wieder vom Opfer genommen */
|
||||
add_trigger(&mage->attribs, "destroy", trigger_removecurse(c, opfer));
|
||||
}
|
||||
|
||||
void
|
||||
register_alp(void)
|
||||
void register_alp(void)
|
||||
{
|
||||
at_register(&at_alp);
|
||||
at_register(&at_alp);
|
||||
}
|
||||
|
||||
unit *
|
||||
alp_target(unit *alp)
|
||||
unit *alp_target(unit * alp)
|
||||
{
|
||||
alp_data* ad;
|
||||
unit * target = NULL;
|
||||
alp_data *ad;
|
||||
|
||||
attrib * a = a_find(alp->attribs, &at_alp);
|
||||
|
||||
if (a) {
|
||||
ad = (alp_data*) a->data.v;
|
||||
target = ad->target;
|
||||
}
|
||||
return target;
|
||||
unit *target = NULL;
|
||||
|
||||
attrib *a = a_find(alp->attribs, &at_alp);
|
||||
|
||||
if (a) {
|
||||
ad = (alp_data *) a->data.v;
|
||||
target = ad->target;
|
||||
}
|
||||
return target;
|
||||
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct castorder;
|
||||
struct region;
|
||||
struct unit;
|
||||
struct castorder;
|
||||
struct region;
|
||||
struct unit;
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Name: Alp
|
||||
* Stufe: 15
|
||||
|
@ -41,11 +41,11 @@ struct unit;
|
|||
* (UNITSPELL | SEARCHGLOBAL | TESTRESISTANCE)
|
||||
*/
|
||||
|
||||
extern int sp_summon_alp(struct castorder *co);
|
||||
extern void register_alp(void);
|
||||
extern int sp_summon_alp(struct castorder *co);
|
||||
extern void register_alp(void);
|
||||
|
||||
struct unit* alp_target(struct unit *alp);
|
||||
void alp_findet_opfer(struct unit *alp, struct region *r);
|
||||
struct unit *alp_target(struct unit *alp);
|
||||
void alp_findet_opfer(struct unit *alp, struct region *r);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -34,41 +34,46 @@
|
|||
#include <assert.h>
|
||||
|
||||
|
||||
static message *
|
||||
cinfo_building(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_building(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
unused(typ);
|
||||
assert(typ == TYP_BUILDING);
|
||||
|
||||
if (self != 0){ /* owner or inside */
|
||||
if (self != 0) { /* owner or inside */
|
||||
return msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
|
||||
}
|
||||
}
|
||||
return msg_message(mkname("curseinfo", "buildingunknown"), "id", c->no);
|
||||
}
|
||||
|
||||
/* CurseInfo mit Spezialabfragen */
|
||||
|
||||
/* C_MAGICWALLS*/
|
||||
static message *
|
||||
cinfo_magicrunes(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_magicrunes(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
message * msg = NULL;
|
||||
if (typ == TYP_BUILDING){
|
||||
building * b;
|
||||
b = (building*)obj;
|
||||
message *msg = NULL;
|
||||
|
||||
if (typ == TYP_BUILDING) {
|
||||
building *b;
|
||||
|
||||
b = (building *) obj;
|
||||
if (self != 0) {
|
||||
msg = msg_message("curseinfo::magicrunes_building", "building id", b, c->no);
|
||||
msg =
|
||||
msg_message("curseinfo::magicrunes_building", "building id", b, c->no);
|
||||
}
|
||||
} else if (typ == TYP_SHIP) {
|
||||
ship *sh;
|
||||
sh = (ship*)obj;
|
||||
if (self != 0){
|
||||
|
||||
sh = (ship *) obj;
|
||||
if (self != 0) {
|
||||
msg = msg_message("curseinfo::magicrunes_ship", "ship id", sh, c->no);
|
||||
}
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
static struct curse_type ct_magicrunes = { "magicrunes",
|
||||
CURSETYP_NORM, 0, M_SUMEFFECT, cinfo_magicrunes
|
||||
};
|
||||
|
@ -85,12 +90,11 @@ static struct curse_type ct_strongwall = { "strongwall",
|
|||
|
||||
/* Ewige Mauern-Zauber */
|
||||
static struct curse_type ct_nocostbuilding = { "nocostbuilding",
|
||||
CURSETYP_NORM, CURSE_NOAGE|CURSE_ONLYONE, NO_MERGE, cinfo_building
|
||||
CURSETYP_NORM, CURSE_NOAGE | CURSE_ONLYONE, NO_MERGE, cinfo_building
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
register_buildingcurse(void)
|
||||
void register_buildingcurse(void)
|
||||
{
|
||||
ct_register(&ct_magicwalls);
|
||||
ct_register(&ct_strongwall);
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct locale;
|
||||
struct curse;
|
||||
struct locale;
|
||||
struct curse;
|
||||
|
||||
extern void register_buildingcurse(void);
|
||||
extern void register_buildingcurse(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _BCURSE_H */
|
||||
#endif /* _BCURSE_H */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,36 +20,66 @@ extern "C" {
|
|||
struct fighter;
|
||||
|
||||
/* Kampfzauber */
|
||||
extern int sp_fumbleshield(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_shadowknights(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_combatrosthauch(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_kampfzauber(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_healing(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_keeploot(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_reanimate(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_chaosrow(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_flee(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_berserk(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_tiredsoldiers(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_reeling_arrows(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_denyattack(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_sleep(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_windshield(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_strong_wall(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_petrify(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_hero(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_frighten(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_mindblast(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_mindblast_temp(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_speed(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_wolfhowl(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_dragonodem(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_reduceshield(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_armorshield(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_stun(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_undeadhero(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_shadowcall(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_immolation(struct fighter * fi, int level, double power, struct spell * sp);
|
||||
extern int sp_fumbleshield(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_shadowknights(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_combatrosthauch(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_kampfzauber(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_healing(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_keeploot(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_reanimate(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_chaosrow(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_flee(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_berserk(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_tiredsoldiers(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_reeling_arrows(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_denyattack(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_sleep(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_windshield(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_strong_wall(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_petrify(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_hero(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_frighten(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_mindblast(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_mindblast_temp(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_speed(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_wolfhowl(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_dragonodem(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_reduceshield(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_armorshield(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_stun(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_undeadhero(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_shadowcall(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
extern int sp_immolation(struct fighter *fi, int level, double power,
|
||||
struct spell *sp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -41,15 +41,15 @@
|
|||
/*
|
||||
* godcursezone
|
||||
*/
|
||||
static message *
|
||||
cinfo_cursed_by_the_gods(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_cursed_by_the_gods(const void *obj, typ_t typ,
|
||||
const curse * c, int self)
|
||||
{
|
||||
region *r = (region *)obj;
|
||||
region *r = (region *) obj;
|
||||
|
||||
unused(typ);
|
||||
unused(self);
|
||||
assert(typ == TYP_REGION);
|
||||
|
||||
|
||||
if (fval(r->terrain, SEA_REGION)) {
|
||||
return msg_message("curseinfo::godcurseocean", "id", c->no);
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ cinfo_cursed_by_the_gods(const void * obj, typ_t typ, const curse *c, int self)
|
|||
|
||||
static struct curse_type ct_godcursezone = {
|
||||
"godcursezone",
|
||||
CURSETYP_NORM, CURSE_IMMUNE|CURSE_ISNEW, (NO_MERGE), cinfo_cursed_by_the_gods,
|
||||
CURSETYP_NORM, CURSE_IMMUNE | CURSE_ISNEW, (NO_MERGE),
|
||||
cinfo_cursed_by_the_gods,
|
||||
};
|
||||
|
||||
|
||||
|
@ -66,8 +67,8 @@ static struct curse_type ct_godcursezone = {
|
|||
/*
|
||||
* C_GBDREAM
|
||||
*/
|
||||
static message *
|
||||
cinfo_dreamcurse(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_dreamcurse(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
unused(self);
|
||||
unused(typ);
|
||||
|
@ -80,7 +81,7 @@ cinfo_dreamcurse(const void * obj, typ_t typ, const curse *c, int self)
|
|||
return msg_message("curseinfo::baddream", "id", c->no);
|
||||
}
|
||||
|
||||
static struct curse_type ct_gbdream = {
|
||||
static struct curse_type ct_gbdream = {
|
||||
"gbdream",
|
||||
CURSETYP_NORM, CURSE_ISNEW, (NO_MERGE), cinfo_dreamcurse
|
||||
};
|
||||
|
@ -90,8 +91,8 @@ static struct curse_type ct_gbdream = {
|
|||
* C_MAGICSTREET
|
||||
* erzeugt Straßennetz
|
||||
*/
|
||||
static message *
|
||||
cinfo_magicstreet(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_magicstreet(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
unused(typ);
|
||||
unused(self);
|
||||
|
@ -113,8 +114,8 @@ static struct curse_type ct_magicstreet = {
|
|||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
static message *
|
||||
cinfo_antimagiczone(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_antimagiczone(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
unused(typ);
|
||||
unused(self);
|
||||
|
@ -131,38 +132,42 @@ cinfo_antimagiczone(const void * obj, typ_t typ, const curse *c, int self)
|
|||
|
||||
/* alle Magier können eine Antimagiezone wahrnehmen */
|
||||
static int
|
||||
cansee_antimagiczone(const struct faction *viewer, const void * obj, typ_t typ, const curse *c, int self)
|
||||
cansee_antimagiczone(const struct faction *viewer, const void *obj, typ_t typ,
|
||||
const curse * c, int self)
|
||||
{
|
||||
region *r;
|
||||
|
||||
unit *u = NULL;
|
||||
|
||||
unit *mage = c->magician;
|
||||
|
||||
unused(typ);
|
||||
|
||||
assert(typ == TYP_REGION);
|
||||
r = (region *)obj;
|
||||
r = (region *) obj;
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u->faction==viewer) {
|
||||
if (u==mage) {
|
||||
if (u->faction == viewer) {
|
||||
if (u == mage) {
|
||||
self = 2;
|
||||
break;
|
||||
}
|
||||
if (is_mage(u)) {
|
||||
self = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static struct curse_type ct_antimagiczone = {
|
||||
|
||||
static struct curse_type ct_antimagiczone = {
|
||||
"antimagiczone",
|
||||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
||||
cinfo_antimagiczone, NULL, NULL, NULL, cansee_antimagiczone
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
static message *
|
||||
cinfo_farvision(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_farvision(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
unused(typ);
|
||||
unused(obj);
|
||||
|
@ -177,7 +182,7 @@ cinfo_farvision(const void * obj, typ_t typ, const curse *c, int self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct curse_type ct_farvision = {
|
||||
static struct curse_type ct_farvision = {
|
||||
"farvision",
|
||||
CURSETYP_NORM, 0, (NO_MERGE),
|
||||
cinfo_farvision
|
||||
|
@ -191,6 +196,7 @@ static struct curse_type ct_fogtrap = {
|
|||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
static struct curse_type ct_maelstrom = {
|
||||
"maelstrom",
|
||||
CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR),
|
||||
|
@ -199,24 +205,26 @@ static struct curse_type ct_maelstrom = {
|
|||
|
||||
static struct curse_type ct_blessedharvest = {
|
||||
"blessedharvest",
|
||||
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ),
|
||||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
static struct curse_type ct_drought = {
|
||||
"drought",
|
||||
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ),
|
||||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
static struct curse_type ct_badlearn = {
|
||||
"badlearn",
|
||||
CURSETYP_NORM, CURSE_ISNEW, ( M_DURATION | M_VIGOUR ),
|
||||
CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR),
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
/* Trübsal-Zauber */
|
||||
static struct curse_type ct_depression = {
|
||||
"depression",
|
||||
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ),
|
||||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
|
@ -226,18 +234,21 @@ static struct curse_type ct_astralblock = {
|
|||
CURSETYP_NORM, 0, NO_MERGE,
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
/* Unterhaltungsanteil vermehren */
|
||||
static struct curse_type ct_generous = {
|
||||
"generous",
|
||||
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR | M_MAXEFFECT ),
|
||||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR | M_MAXEFFECT),
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
/* verhindert Attackiere regional */
|
||||
static struct curse_type ct_peacezone = {
|
||||
"peacezone",
|
||||
CURSETYP_NORM, 0, NO_MERGE,
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
/* erniedigt Magieresistenz von nicht-aliierten Einheiten, wirkt nur 1x
|
||||
* pro Einheit */
|
||||
static struct curse_type ct_badmagicresistancezone = {
|
||||
|
@ -245,6 +256,7 @@ static struct curse_type ct_badmagicresistancezone = {
|
|||
CURSETYP_NORM, 0, NO_MERGE,
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
/* erhöht Magieresistenz von aliierten Einheiten, wirkt nur 1x pro
|
||||
* Einheit */
|
||||
static struct curse_type ct_goodmagicresistancezone = {
|
||||
|
@ -252,16 +264,19 @@ static struct curse_type ct_goodmagicresistancezone = {
|
|||
CURSETYP_NORM, 0, NO_MERGE,
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
static struct curse_type ct_riotzone = {
|
||||
"riotzone",
|
||||
CURSETYP_NORM, 0, (M_DURATION),
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
static struct curse_type ct_holyground = {
|
||||
"holyground",
|
||||
CURSETYP_NORM, CURSE_NOAGE, (M_VIGOUR_ADD),
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
static struct curse_type ct_healing = {
|
||||
"healingzone",
|
||||
CURSETYP_NORM, 0, (M_VIGOUR | M_DURATION),
|
||||
|
@ -269,8 +284,7 @@ static struct curse_type ct_healing = {
|
|||
};
|
||||
|
||||
|
||||
void
|
||||
register_regioncurse(void)
|
||||
void register_regioncurse(void)
|
||||
{
|
||||
ct_register(&ct_fogtrap);
|
||||
ct_register(&ct_antimagiczone);
|
||||
|
@ -292,5 +306,3 @@ register_regioncurse(void)
|
|||
ct_register(&ct_holyground);
|
||||
ct_register(&ct_healing);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct curse;
|
||||
struct locale;
|
||||
struct curse;
|
||||
struct locale;
|
||||
|
||||
extern void register_regioncurse(void);
|
||||
extern void register_regioncurse(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _RCURSE_H */
|
||||
#endif /* _RCURSE_H */
|
||||
|
|
|
@ -35,21 +35,20 @@
|
|||
#include <assert.h>
|
||||
|
||||
|
||||
message *
|
||||
cinfo_ship(const void * obj, typ_t typ, const curse *c, int self)
|
||||
message *cinfo_ship(const void *obj, typ_t typ, const curse * c, int self)
|
||||
{
|
||||
message * msg;
|
||||
message *msg;
|
||||
|
||||
unused(typ);
|
||||
unused(obj);
|
||||
assert(typ == TYP_SHIP);
|
||||
|
||||
if (self != 0) { /* owner or inside */
|
||||
if (self != 0) { /* owner or inside */
|
||||
msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
|
||||
} else {
|
||||
msg = msg_message("curseinfo::ship_unknown", "id", c->no);
|
||||
}
|
||||
if (msg==NULL) {
|
||||
if (msg == NULL) {
|
||||
log_error(("There is no curseinfo for %s.\n", c->type->cname));
|
||||
}
|
||||
return msg;
|
||||
|
@ -58,16 +57,17 @@ cinfo_ship(const void * obj, typ_t typ, const curse *c, int self)
|
|||
/* CurseInfo mit Spezialabfragen */
|
||||
|
||||
/* C_SHIP_NODRIFT */
|
||||
static message *
|
||||
cinfo_shipnodrift(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_shipnodrift(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
ship * sh = (ship *)obj;
|
||||
ship *sh = (ship *) obj;
|
||||
|
||||
unused(typ);
|
||||
assert(typ == TYP_SHIP);
|
||||
|
||||
if (self != 0) {
|
||||
return msg_message("curseinfo::shipnodrift_1", "ship duration id", sh, c->duration, c->no);
|
||||
return msg_message("curseinfo::shipnodrift_1", "ship duration id", sh,
|
||||
c->duration, c->no);
|
||||
}
|
||||
return msg_message("curseinfo::shipnodrift_0", "ship id", sh, c->no);
|
||||
}
|
||||
|
@ -76,26 +76,33 @@ static struct curse_type ct_stormwind = { "stormwind",
|
|||
CURSETYP_NORM, 0, NO_MERGE, cinfo_ship
|
||||
};
|
||||
|
||||
static int flyingship_read(storage * store, curse * c, void * target) {
|
||||
ship * sh = (ship *)target;
|
||||
static int flyingship_read(storage * store, curse * c, void *target)
|
||||
{
|
||||
ship *sh = (ship *) target;
|
||||
|
||||
c->data.v = sh;
|
||||
if (store->version<FOSS_VERSION) {
|
||||
if (store->version < FOSS_VERSION) {
|
||||
sh->flags |= SF_FLYING;
|
||||
return 0;
|
||||
}
|
||||
assert(sh->flags&SF_FLYING);
|
||||
assert(sh->flags & SF_FLYING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int flyingship_write(storage * store, const curse * c, const void * target) {
|
||||
const ship * sh = (const ship *)target;
|
||||
assert(sh->flags&SF_FLYING);
|
||||
static int flyingship_write(storage * store, const curse * c,
|
||||
const void *target)
|
||||
{
|
||||
const ship *sh = (const ship *)target;
|
||||
|
||||
assert(sh->flags & SF_FLYING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int flyingship_age(curse * c) {
|
||||
ship * sh = (ship *)c->data.v;
|
||||
if (sh && c->duration==1) {
|
||||
static int flyingship_age(curse * c)
|
||||
{
|
||||
ship *sh = (ship *) c->data.v;
|
||||
|
||||
if (sh && c->duration == 1) {
|
||||
freset(sh, SF_FLYING);
|
||||
return 1;
|
||||
}
|
||||
|
@ -103,19 +110,22 @@ static int flyingship_age(curse * c) {
|
|||
}
|
||||
|
||||
static struct curse_type ct_flyingship = { "flyingship",
|
||||
CURSETYP_NORM, 0, NO_MERGE, cinfo_ship, NULL, flyingship_read, flyingship_write, NULL, flyingship_age
|
||||
CURSETYP_NORM, 0, NO_MERGE, cinfo_ship, NULL, flyingship_read,
|
||||
flyingship_write, NULL, flyingship_age
|
||||
};
|
||||
|
||||
static struct curse_type ct_nodrift = { "nodrift",
|
||||
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ), cinfo_shipnodrift
|
||||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR), cinfo_shipnodrift
|
||||
};
|
||||
|
||||
static struct curse_type ct_shipspeedup = { "shipspeedup",
|
||||
CURSETYP_NORM, 0, 0, cinfo_ship
|
||||
};
|
||||
|
||||
curse *
|
||||
shipcurse_flyingship(ship* sh, unit * mage, double power, int duration)
|
||||
curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration)
|
||||
{
|
||||
static const curse_type * ct_flyingship = NULL;
|
||||
static const curse_type *ct_flyingship = NULL;
|
||||
|
||||
if (!ct_flyingship) {
|
||||
ct_flyingship = ct_find("flyingship");
|
||||
assert(ct_flyingship);
|
||||
|
@ -126,31 +136,30 @@ shipcurse_flyingship(ship* sh, unit * mage, double power, int duration)
|
|||
return NULL;
|
||||
} else {
|
||||
/* mit C_SHIP_NODRIFT haben wir kein Problem */
|
||||
curse * c = create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0);
|
||||
curse *c =
|
||||
create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0);
|
||||
c->data.v = sh;
|
||||
if (c && c->duration>0) {
|
||||
if (c && c->duration > 0) {
|
||||
sh->flags |= SF_FLYING;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
levitate_ship(ship * sh, unit * mage, double power, int duration)
|
||||
int levitate_ship(ship * sh, unit * mage, double power, int duration)
|
||||
{
|
||||
curse * c = shipcurse_flyingship(sh, mage, power, duration);
|
||||
curse *c = shipcurse_flyingship(sh, mage, power, duration);
|
||||
|
||||
if (c) {
|
||||
return c->no;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
register_shipcurse(void)
|
||||
void register_shipcurse(void)
|
||||
{
|
||||
ct_register(&ct_stormwind);
|
||||
ct_register(&ct_flyingship);
|
||||
ct_register(&ct_nodrift);
|
||||
ct_register(&ct_shipspeedup);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,14 +17,17 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct locale;
|
||||
struct message;
|
||||
extern struct message * cinfo_ship(const void * obj, typ_t typ, const struct curse *c, int self);
|
||||
extern void register_shipcurse(void);
|
||||
extern struct curse * shipcurse_flyingship(struct ship* sh, struct unit * mage, double power, int duration);
|
||||
int levitate_ship(struct ship * sh, struct unit * mage, double power, int duration);
|
||||
|
||||
struct locale;
|
||||
struct message;
|
||||
extern struct message *cinfo_ship(const void *obj, typ_t typ,
|
||||
const struct curse *c, int self);
|
||||
extern void register_shipcurse(void);
|
||||
extern struct curse *shipcurse_flyingship(struct ship *sh, struct unit *mage,
|
||||
double power, int duration);
|
||||
int levitate_ship(struct ship *sh, struct unit *mage, double power,
|
||||
int duration);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _SCURSE_H */
|
||||
#endif /* _SCURSE_H */
|
||||
|
|
4510
src/spells/spells.c
4510
src/spells/spells.c
File diff suppressed because it is too large
Load Diff
|
@ -24,7 +24,7 @@ extern "C" {
|
|||
|
||||
extern void register_spells(void);
|
||||
|
||||
void set_spelldata(struct spell * sp);
|
||||
void set_spelldata(struct spell *sp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -43,15 +43,16 @@
|
|||
* C_AURA
|
||||
*/
|
||||
/* erhöht/senkt regeneration und maxaura um effect% */
|
||||
static message *
|
||||
cinfo_auraboost(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_auraboost(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
struct unit *u = (struct unit *)obj;
|
||||
|
||||
unused(typ);
|
||||
assert(typ == TYP_UNIT);
|
||||
|
||||
if (self != 0){
|
||||
if (curse_geteffect(c) > 100){
|
||||
if (self != 0) {
|
||||
if (curse_geteffect(c) > 100) {
|
||||
return msg_message("curseinfo::auraboost_0", "unit id", u, c->no);
|
||||
} else {
|
||||
return msg_message("curseinfo::auraboost_1", "unit id", u, c->no);
|
||||
|
@ -59,6 +60,7 @@ cinfo_auraboost(const void * obj, typ_t typ, const curse *c, int self)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct curse_type ct_auraboost = {
|
||||
"auraboost",
|
||||
CURSETYP_NORM, CURSE_SPREADMODULO, (NO_MERGE),
|
||||
|
@ -68,27 +70,30 @@ static struct curse_type ct_auraboost = {
|
|||
/* Magic Boost - Gabe des Chaos */
|
||||
static struct curse_type ct_magicboost = {
|
||||
"magicboost",
|
||||
CURSETYP_UNIT, CURSE_SPREADMODULO|CURSE_IMMUNE, M_MEN, cinfo_simple
|
||||
CURSETYP_UNIT, CURSE_SPREADMODULO | CURSE_IMMUNE, M_MEN, cinfo_simple
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/*
|
||||
* C_SLAVE
|
||||
*/
|
||||
static message *
|
||||
cinfo_slave(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_slave(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
unit *u;
|
||||
|
||||
unused(typ);
|
||||
|
||||
assert(typ == TYP_UNIT);
|
||||
u = (unit *)obj;
|
||||
u = (unit *) obj;
|
||||
|
||||
if (self != 0){
|
||||
return msg_message("curseinfo::slave_1", "unit duration id", u, c->duration, c->no);
|
||||
if (self != 0) {
|
||||
return msg_message("curseinfo::slave_1", "unit duration id", u, c->duration,
|
||||
c->no);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct curse_type ct_slavery = { "slavery",
|
||||
CURSETYP_NORM, 0, NO_MERGE,
|
||||
cinfo_slave
|
||||
|
@ -98,18 +103,20 @@ static struct curse_type ct_slavery = { "slavery",
|
|||
/*
|
||||
* C_CALM
|
||||
*/
|
||||
static message *
|
||||
cinfo_calm(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_calm(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
unused(typ);
|
||||
assert(typ == TYP_UNIT);
|
||||
|
||||
|
||||
if (c->magician && c->magician->faction) {
|
||||
faction *f = c->magician->faction;
|
||||
unit *u = (unit *)obj;
|
||||
|
||||
if (f==NULL || self == 0) {
|
||||
const struct race * rc = u_irace(c->magician);
|
||||
unit *u = (unit *) obj;
|
||||
|
||||
if (f == NULL || self == 0) {
|
||||
const struct race *rc = u_irace(c->magician);
|
||||
|
||||
return msg_message("curseinfo::calm_0", "unit race id", u, rc, c->no);
|
||||
}
|
||||
return msg_message("curseinfo::calm_1", "unit faction id", u, f, c->no);
|
||||
|
@ -119,7 +126,7 @@ cinfo_calm(const void * obj, typ_t typ, const curse *c, int self)
|
|||
|
||||
static struct curse_type ct_calmmonster = {
|
||||
"calmmonster",
|
||||
CURSETYP_NORM, CURSE_SPREADNEVER|CURSE_ONLYONE, NO_MERGE,
|
||||
CURSETYP_NORM, CURSE_SPREADNEVER | CURSE_ONLYONE, NO_MERGE,
|
||||
cinfo_calm
|
||||
};
|
||||
|
||||
|
@ -127,18 +134,21 @@ static struct curse_type ct_calmmonster = {
|
|||
/*
|
||||
* C_SPEED
|
||||
*/
|
||||
static message *
|
||||
cinfo_speed(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_speed(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
unused(typ);
|
||||
assert(typ == TYP_UNIT);
|
||||
|
||||
if (self != 0){
|
||||
unit *u = (unit *)obj;
|
||||
return msg_message("curseinfo::speed_1", "unit number duration id", u, c->data.i, c->duration, c->no);
|
||||
if (self != 0) {
|
||||
unit *u = (unit *) obj;
|
||||
|
||||
return msg_message("curseinfo::speed_1", "unit number duration id", u,
|
||||
c->data.i, c->duration, c->no);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct curse_type ct_speed = {
|
||||
"speed",
|
||||
CURSETYP_UNIT, CURSE_SPREADNEVER, M_MEN,
|
||||
|
@ -149,22 +159,23 @@ static struct curse_type ct_speed = {
|
|||
/*
|
||||
* C_ORC
|
||||
*/
|
||||
message *
|
||||
cinfo_unit(const void * obj, typ_t typ, const curse *c, int self)
|
||||
message *cinfo_unit(const void *obj, typ_t typ, const curse * c, int self)
|
||||
{
|
||||
unused(typ);
|
||||
assert(typ == TYP_UNIT);
|
||||
|
||||
if (self != 0){
|
||||
unit * u = (unit *)obj;
|
||||
return msg_message(mkname("curseinfo", c->type->cname), "unit id", u, c->no);
|
||||
if (self != 0) {
|
||||
unit *u = (unit *) obj;
|
||||
|
||||
return msg_message(mkname("curseinfo", c->type->cname), "unit id", u,
|
||||
c->no);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct curse_type ct_orcish = {
|
||||
"orcish",
|
||||
CURSETYP_UNIT, CURSE_SPREADMODULO|CURSE_ISNEW, M_MEN,
|
||||
CURSETYP_UNIT, CURSE_SPREADMODULO | CURSE_ISNEW, M_MEN,
|
||||
cinfo_unit
|
||||
};
|
||||
|
||||
|
@ -172,21 +183,24 @@ static struct curse_type ct_orcish = {
|
|||
/*
|
||||
* C_KAELTESCHUTZ
|
||||
*/
|
||||
static message *
|
||||
cinfo_kaelteschutz(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_kaelteschutz(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
unused(typ);
|
||||
assert(typ == TYP_UNIT);
|
||||
|
||||
if (self != 0) {
|
||||
unit * u = (unit *)obj;
|
||||
return msg_message("curseinfo::warmth_1", "unit number id", u, get_cursedmen(u, c), c->no);
|
||||
unit *u = (unit *) obj;
|
||||
|
||||
return msg_message("curseinfo::warmth_1", "unit number id", u,
|
||||
get_cursedmen(u, c), c->no);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct curse_type ct_insectfur = {
|
||||
"insectfur",
|
||||
CURSETYP_UNIT, CURSE_SPREADMODULO, ( M_MEN | M_DURATION ),
|
||||
CURSETYP_UNIT, CURSE_SPREADMODULO, (M_MEN | M_DURATION),
|
||||
cinfo_kaelteschutz
|
||||
};
|
||||
|
||||
|
@ -194,60 +208,68 @@ static struct curse_type ct_insectfur = {
|
|||
/*
|
||||
* C_SPARKLE
|
||||
*/
|
||||
static message *
|
||||
cinfo_sparkle(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_sparkle(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
const char * effects[] = {
|
||||
NULL, /* end grau*/
|
||||
const char *effects[] = {
|
||||
NULL, /* end grau */
|
||||
"sparkle_1",
|
||||
"sparkle_2",
|
||||
NULL, /* end traum */
|
||||
NULL, /* end traum */
|
||||
"sparkle_3",
|
||||
"sparkle_4",
|
||||
NULL, /* end tybied */
|
||||
NULL, /* end tybied */
|
||||
"sparkle_5",
|
||||
"sparkle_6",
|
||||
"sparkle_7",
|
||||
"sparkle_8",
|
||||
NULL, /* end cerrdor */
|
||||
NULL, /* end cerrdor */
|
||||
"sparkle_9",
|
||||
"sparkle_10",
|
||||
"sparkle_11",
|
||||
"sparkle_12",
|
||||
NULL, /* end gwyrrd */
|
||||
NULL, /* end gwyrrd */
|
||||
"sparkle_13",
|
||||
"sparkle_14",
|
||||
"sparkle_15",
|
||||
"sparkle_16",
|
||||
"sparkle_17",
|
||||
"sparkle_18",
|
||||
NULL, /* end draig */
|
||||
NULL, /* end draig */
|
||||
};
|
||||
int m, begin=0, end=0;
|
||||
int m, begin = 0, end = 0;
|
||||
|
||||
unit *u;
|
||||
|
||||
unused(typ);
|
||||
|
||||
assert(typ == TYP_UNIT);
|
||||
u = (unit *)obj;
|
||||
u = (unit *) obj;
|
||||
|
||||
if (!c->magician || !c->magician->faction) return NULL;
|
||||
if (!c->magician || !c->magician->faction)
|
||||
return NULL;
|
||||
|
||||
for (m=0;m!=c->magician->faction->magiegebiet;++m) {
|
||||
while (effects[end]!=NULL) ++end;
|
||||
begin = end+1;
|
||||
for (m = 0; m != c->magician->faction->magiegebiet; ++m) {
|
||||
while (effects[end] != NULL)
|
||||
++end;
|
||||
begin = end + 1;
|
||||
end = begin;
|
||||
}
|
||||
|
||||
while (effects[end]!=NULL) ++end;
|
||||
if (end==begin) return NULL;
|
||||
while (effects[end] != NULL)
|
||||
++end;
|
||||
if (end == begin)
|
||||
return NULL;
|
||||
else {
|
||||
int index = begin + curse_geteffect_int(c) % (end-begin);
|
||||
return msg_message(mkname("curseinfo", effects[index]), "unit id", u, c->no);
|
||||
int index = begin + curse_geteffect_int(c) % (end - begin);
|
||||
|
||||
return msg_message(mkname("curseinfo", effects[index]), "unit id", u,
|
||||
c->no);
|
||||
}
|
||||
}
|
||||
|
||||
static struct curse_type ct_sparkle = { "sparkle",
|
||||
CURSETYP_UNIT, CURSE_SPREADMODULO, ( M_MEN | M_DURATION ), cinfo_sparkle
|
||||
CURSETYP_UNIT, CURSE_SPREADMODULO, (M_MEN | M_DURATION), cinfo_sparkle
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
@ -263,7 +285,7 @@ static struct curse_type ct_strength = { "strength",
|
|||
* C_ALLSKILLS (Alp)
|
||||
*/
|
||||
static struct curse_type ct_worse = {
|
||||
"worse", CURSETYP_UNIT, CURSE_SPREADMODULO|CURSE_NOAGE, M_MEN, cinfo_unit
|
||||
"worse", CURSETYP_UNIT, CURSE_SPREADMODULO | CURSE_NOAGE, M_MEN, cinfo_unit
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
@ -274,11 +296,14 @@ static struct curse_type ct_worse = {
|
|||
static struct curse_type ct_itemcloak = {
|
||||
"itemcloak", CURSETYP_UNIT, CURSE_SPREADNEVER, M_DURATION, cinfo_unit
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static struct curse_type ct_fumble = {
|
||||
"fumble", CURSETYP_NORM, CURSE_SPREADNEVER|CURSE_ONLYONE, NO_MERGE, cinfo_unit
|
||||
"fumble", CURSETYP_NORM, CURSE_SPREADNEVER | CURSE_ONLYONE, NO_MERGE,
|
||||
cinfo_unit
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
@ -296,12 +321,13 @@ static struct curse_type ct_magicresistance = {
|
|||
* C_SKILL
|
||||
*/
|
||||
|
||||
static int
|
||||
read_skill(struct storage * store, curse * c, void * target)
|
||||
static int read_skill(struct storage *store, curse * c, void *target)
|
||||
{
|
||||
int skill;
|
||||
if (store->version<CURSETYPE_VERSION) {
|
||||
|
||||
if (store->version < CURSETYPE_VERSION) {
|
||||
int men;
|
||||
|
||||
skill = store->r_int(store);
|
||||
men = store->r_int(store);
|
||||
} else {
|
||||
|
@ -312,23 +338,25 @@ read_skill(struct storage * store, curse * c, void * target)
|
|||
}
|
||||
|
||||
static int
|
||||
write_skill(struct storage * store, const curse * c, const void * target)
|
||||
write_skill(struct storage *store, const curse * c, const void *target)
|
||||
{
|
||||
store->w_int(store, c->data.i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static message *
|
||||
cinfo_skillmod(const void * obj, typ_t typ, const curse *c, int self)
|
||||
static message *cinfo_skillmod(const void *obj, typ_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
unused(typ);
|
||||
|
||||
if (self != 0) {
|
||||
unit *u = (unit *)obj;
|
||||
unit *u = (unit *) obj;
|
||||
|
||||
int sk = c->data.i;
|
||||
if (c->effect>0) {
|
||||
|
||||
if (c->effect > 0) {
|
||||
return msg_message("curseinfo::skill_1", "unit skill id", u, sk, c->no);
|
||||
} else if (c->effect<0) {
|
||||
} else if (c->effect < 0) {
|
||||
return msg_message("curseinfo::skill_2", "unit skill id", u, sk, c->no);
|
||||
}
|
||||
}
|
||||
|
@ -341,8 +369,7 @@ static struct curse_type ct_skillmod = {
|
|||
};
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
void
|
||||
register_unitcurse(void)
|
||||
void register_unitcurse(void)
|
||||
{
|
||||
ct_register(&ct_auraboost);
|
||||
ct_register(&ct_magicboost);
|
||||
|
@ -360,4 +387,3 @@ register_unitcurse(void)
|
|||
ct_register(&ct_oldrace);
|
||||
ct_register(&ct_magicresistance);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct curse;
|
||||
struct message;
|
||||
extern struct message * cinfo_unit(const void * obj, typ_t typ, const struct curse *c, int self);
|
||||
struct curse;
|
||||
struct message;
|
||||
extern struct message *cinfo_unit(const void *obj, typ_t typ,
|
||||
const struct curse *c, int self);
|
||||
|
||||
extern void register_unitcurse(void);
|
||||
extern void register_unitcurse(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _UCURSE_H */
|
||||
#endif /* _UCURSE_H */
|
||||
|
|
Loading…
Reference in New Issue