version 1.5 | | version 1.6 |
---|
| | |
/* | | /* |
* static char *rcsid_spells_c = | | * static char *rcsid_spells_c = |
* "$Id: spell_util.c,v 1.5 1999/09/18 07:08:32 damn Exp $"; | | * "$Id: spell_util.c,v 1.6 2000/04/05 04:43:26 cvs Exp $"; |
*/ | | */ |
| | |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
Copyright (C) 1994 Mark Wedel | | Copyright (C) 2000 Mark Wedel |
Copyright (C) 1992 Frank Tore Johansen | | Copyright (C) 1992 Frank Tore Johansen |
| | |
This program is free software; you can redistribute it and/or modify | | This program is free software; you can redistribute it and/or modify |
| | |
along with this program; if not, write to the Free Software | | along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| | |
The author can be reached via e-mail to master@rahul.net | | The author can be reached via e-mail to mwedel@scruz.net |
*/ | | */ |
| | |
#include <global.h> | | #include <global.h> |
| | |
n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + | | n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + |
SP_level_strength_adjust(op,caster, type); | | SP_level_strength_adjust(op,caster, type); |
success = 1; | | success = 1; |
fire_swarm(op,dir,spellarch[type],SP_METEOR,n); | | fire_swarm(op,dir,spellarch[type],SP_METEOR,n,0); |
break; | | break; |
} | | } |
case SP_BULLET_SWARM: { | | case SP_BULLET_SWARM: { |
| | |
n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + | | n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + |
SP_level_strength_adjust(op,caster, type); | | SP_level_strength_adjust(op,caster, type); |
success = 1; | | success = 1; |
fire_swarm(op,dir,spellarch[type],SP_BULLET,n); | | fire_swarm(op,dir,spellarch[type],SP_BULLET,n,1); |
break; | | break; |
} | | } |
case SP_BULLET_STORM: { | | case SP_BULLET_STORM: { |
| | |
n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + | | n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + |
SP_level_strength_adjust(op,caster, type); | | SP_level_strength_adjust(op,caster, type); |
success = 1; | | success = 1; |
fire_swarm(op,dir,spellarch[type],SP_LARGE_BULLET,n); | | fire_swarm(op,dir,spellarch[type],SP_LARGE_BULLET,n,1); |
break; | | break; |
} | | } |
case SP_CAUSE_MANY: { | | case SP_CAUSE_MANY: { |
| | |
n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + | | n=RANDOM()%3 + RANDOM()%3 + RANDOM()%3 +3 + |
SP_level_strength_adjust(op,caster, type); | | SP_level_strength_adjust(op,caster, type); |
success = 1; | | success = 1; |
fire_swarm(op,dir,spellarch[type],SP_CAUSE_HEAVY,n); | | fire_swarm(op,dir,spellarch[type],SP_CAUSE_HEAVY,n,1); |
break; | | break; |
} | | } |
case SP_METEOR: | | case SP_METEOR: |
| | |
* casting object. | | * casting object. |
*/ | | */ |
| | |
int fire_arch(object *op,object *caster,int dir,archetype *at, int type, int magic) { | | int fire_arch (object *op, object *caster, int dir, archetype *at, int type, |
| | int magic) |
| | { |
| | return fire_arch_from_position (op, caster, op->x, op->y, dir, at, |
| | type, magic); |
| | } |
| | |
| | int fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, |
| | int dir, archetype *at, int type, int magic) |
| | { |
object *tmp, *env; | | object *tmp, *env; |
| | |
if(at==NULL) | | if(at==NULL) |
| | |
tmp->stats.sp=type; | | tmp->stats.sp=type; |
tmp->stats.dam=SP_PARAMETERS[type].bdam+SP_level_dam_adjust(op,caster,type); | | tmp->stats.dam=SP_PARAMETERS[type].bdam+SP_level_dam_adjust(op,caster,type); |
tmp->stats.hp=SP_PARAMETERS[type].bdur+SP_level_strength_adjust(op,caster,type); | | tmp->stats.hp=SP_PARAMETERS[type].bdur+SP_level_strength_adjust(op,caster,type); |
tmp->x=op->x,tmp->y=op->y; | | tmp->x=x, tmp->y=y; |
tmp->direction=dir; | | tmp->direction=dir; |
set_owner(tmp,op); | | set_owner(tmp,op); |
#ifdef MULTIPLE_GODS /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ | | #ifdef MULTIPLE_GODS /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ |
| | |
from a set of squares surrounding the caster, in a given direction. */ | | from a set of squares surrounding the caster, in a given direction. */ |
| | |
void move_swarm_spell(object *op) | | void move_swarm_spell(object *op) |
{ int x,y; int di; | | { |
if(!(op->stats.hp--)||get_owner(op)==NULL) { | | sint16 x,y; |
| | int di; |
| | object *owner = get_owner (op); |
| | |
| | if(op->stats.hp == 0 || owner == NULL) { |
remove_ob(op); | | remove_ob(op); |
free_object(op); | | free_object(op); |
return; | | return; |
} | | } |
x=op->x; y=op->y; /* save original location of swarm object */ | | op->stats.hp--; |
| | |
| | if(op->stats.hp) |
| | di=RANDOM()%7-3; /* get a random number of -3->3 */ |
| | else |
| | di=0; /* fire the last one from forward. */ |
| | x = op->x + freearr_x[absdir(op->direction +di)]; |
| | y = op->y + freearr_y[absdir(op->direction +di)]; |
| | |
if(op->stats.hp) di=RANDOM()%7-3; /* get a random number of -3->3 */ | | |
else di=0; /* fire the last one from forward. */ | | |
op->x+=freearr_x[absdir(op->direction +di)]; | | |
op->y+=freearr_y[absdir(op->direction +di)]; | | |
/* for level dependence, we need to know what spell is fired. */ | | /* for level dependence, we need to know what spell is fired. */ |
/* that's stored in op->stats.sp by fire_swarm */ | | /* that's stored in op->stats.sp by fire_swarm */ |
if(!wall(op->map,op->x,op->y)) | | if ( ! wall (op->map, x, y)) |
fire_arch(op,op,op->direction,op->other_arch,op->stats.sp,0); | | fire_arch_from_position (owner, op, x, y, op->direction, op->other_arch, |
op->x=x; op->y=y; /* reset original location */ | | op->stats.sp, op->magic); |
| | |
} | | } |
| | |
| | |
| | |
| | |
/* fire_swarm: peterm */ | | /* fire_swarm: peterm */ |
/* The following routine creates a swarm of objects. It actually | | /* The following routine creates a swarm of objects. It actually |
sets up a specific swarm object, which then fires off all | | sets up a specific swarm object, which then fires off all |
| | |
*/ | | */ |
| | |
| | |
void fire_swarm(object *op,int dir,archetype *swarm_type,int spell_type,int n) | | void fire_swarm (object *op, int dir, archetype *swarm_type, int spell_type, |
| | int n, int magic) |
{ | | { |
object *tmp; | | object *tmp; |
tmp=arch_to_object(find_archetype("swarm_spell")); | | tmp=arch_to_object(find_archetype("swarm_spell")); |
| | |
set_owner(tmp,op); /* needed so that if swarm elements kill, caster gets xp.*/ | | set_owner(tmp,op); /* needed so that if swarm elements kill, caster gets xp.*/ |
tmp->level=op->level; /*needed later, to get level dep. right.*/ | | tmp->level=op->level; /*needed later, to get level dep. right.*/ |
tmp->stats.sp=spell_type; /* needed later, see move_swarm_spell */ | | tmp->stats.sp=spell_type; /* needed later, see move_swarm_spell */ |
| | tmp->magic = magic; |
tmp->stats.hp=n; /* n in swarm*/ | | tmp->stats.hp=n; /* n in swarm*/ |
tmp->other_arch=swarm_type; /* the archetype of the things to be fired*/ | | tmp->other_arch=swarm_type; /* the archetype of the things to be fired*/ |
tmp->direction=dir; | | tmp->direction=dir; |