version 1.87 | | version 1.88 |
---|
| | |
/* | | /* |
* static char *rcsid_spell_effect_c = | | * static char *rcsid_spell_effect_c = |
* "$Id: spell_effect.c,v 1.87 2002/12/21 08:02:34 mwedel Exp $"; | | * "$Id: spell_effect.c,v 1.88 2002/12/28 06:35:23 garbled Exp $"; |
*/ | | */ |
| | |
| | |
| | |
int summon_pet(object *op, int dir, SpellTypeFrom item) { | | int summon_pet(object *op, int dir, SpellTypeFrom item) { |
int level, number, i; | | int level, number, i; |
treasurelist *trlist = NULL; | | treasurelist *trlist = NULL; |
treasure *tr, *prevtr = NULL; | | treasure *tr = NULL; |
| | |
level = ((op->head?op->head->level:SK_level(op)) / 4); | | level = ((op->head?op->head->level:SK_level(op)) / 4); |
| | |
| | |
if (trlist == NULL) | | if (trlist == NULL) |
return 0; | | return 0; |
| | |
for (i=0, tr=trlist->items; tr != NULL && i < level-1; | | for (i=0, tr=trlist->items; tr != NULL && i < level && |
prevtr = tr, tr = tr->next, i++); | | tr->next != NULL && tr->next->item != NULL; tr = tr->next, i++); |
| | |
if(prevtr == NULL || prevtr->item == NULL) { | | if(tr == NULL || tr->item == NULL) { |
LOG(llevError,"Treasurelist Found NULL in summon_pet_monster()\n"); | | LOG(llevError,"Treasurelist Found NULL in summon_pet_monster()\n"); |
return 0; | | return 0; |
} | | } |
| | |
number = prevtr->nrof; | | number = tr->nrof; |
| | |
if (!dir) | | if (!dir) |
dir = find_free_spot(prevtr->item, op->map, op->x, op->y, 1, SIZEOFFREE); | | dir = find_free_spot(tr->item, op->map, op->x, op->y, 1, SIZEOFFREE); |
| | |
if ((dir==-1) || arch_blocked(prevtr->item, op->map, | | if ((dir==-1) || arch_blocked(tr->item, op->map, |
op->x + freearr_x[dir], op->y+freearr_y[dir])) { | | op->x + freearr_x[dir], op->y+freearr_y[dir])) { |
new_draw_info(NDI_UNIQUE, 0, op, "There is something in the way."); | | new_draw_info(NDI_UNIQUE, 0, op, "There is something in the way."); |
return 0; | | return 0; |
| | |
archetype *atmp; | | archetype *atmp; |
object *prev = NULL, *head = NULL; /* We want to summon dragons *grin* */ | | object *prev = NULL, *head = NULL; /* We want to summon dragons *grin* */ |
| | |
for(atmp = prevtr->item; atmp!=NULL; atmp = atmp->more) { | | for(atmp = tr->item; atmp!=NULL; atmp = atmp->more) { |
object *tmp; | | object *tmp; |
tmp = arch_to_object(atmp); | | tmp = arch_to_object(atmp); |
| | |
/* if this is the head, set owner/friendly as needed */ | | /* if this is the head, set owner/friendly as needed */ |
if (atmp == prevtr->item) { | | if (atmp == tr->item) { |
set_owner(tmp, op); | | set_owner(tmp, op); |
SET_FLAG(tmp, FLAG_MONSTER); | | SET_FLAG(tmp, FLAG_MONSTER); |
if (op->type == PLAYER) { | | if (op->type == PLAYER) { |
| | |
SET_FLAG(tmp, FLAG_NO_DROP); | | SET_FLAG(tmp, FLAG_NO_DROP); |
} | | } |
dir = absdir(dir + 1); | | dir = absdir(dir + 1); |
if (arch_blocked(prevtr->item, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir])) { | | if (arch_blocked(tr->item, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir])) { |
if (i < number) { | | if (i < number) { |
new_draw_info(NDI_UNIQUE, 0,op, "There is something in the way,"); | | new_draw_info(NDI_UNIQUE, 0,op, "There is something in the way,"); |
new_draw_info(NDI_UNIQUE, 0,op, "no more pets for this casting."); | | new_draw_info(NDI_UNIQUE, 0,op, "no more pets for this casting."); |