version 1.88 | | version 1.89 |
---|
| | |
/* | | /* |
* static char *rcsid_spell_effect_c = | | * static char *rcsid_spell_effect_c = |
* "$Id: spell_effect.c,v 1.88 2002/12/28 06:35:23 garbled Exp $"; | | * "$Id: spell_effect.c,v 1.89 2003/01/05 23:50:15 mwedel Exp $"; |
*/ | | */ |
| | |
| | |
| | |
free_object(obj); | | free_object(obj); |
} | | } |
| | |
static void update_map(object *op, int small_nuggets, int large_nuggets, | | static void update_map(object *op, mapstruct *m, int small_nuggets, int large_nuggets, |
int x, int y) | | int x, int y) |
{ | | { |
object *tmp; | | object *tmp; |
| | |
/* Put any nuggets below the player, but we can only pass this | | /* Put any nuggets below the player, but we can only pass this |
* flag if we are on the same space as the player | | * flag if we are on the same space as the player |
*/ | | */ |
if (x == op->x && y == op->y) flag = INS_BELOW_ORIGINATOR; | | if (x == op->x && y == op->y && op->map == m) flag = INS_BELOW_ORIGINATOR; |
| | |
if (small_nuggets) { | | if (small_nuggets) { |
tmp = get_object(); | | tmp = get_object(); |
| | |
tmp-> nrof = small_nuggets; | | tmp-> nrof = small_nuggets; |
tmp->x = x; | | tmp->x = x; |
tmp->y = y; | | tmp->y = y; |
insert_ob_in_map(tmp, op->map, op, flag); | | insert_ob_in_map(tmp, m, op, flag); |
} | | } |
if (large_nuggets) { | | if (large_nuggets) { |
tmp = get_object(); | | tmp = get_object(); |
| | |
tmp-> nrof = large_nuggets; | | tmp-> nrof = large_nuggets; |
tmp->x = x; | | tmp->x = x; |
tmp->y = y; | | tmp->y = y; |
insert_ob_in_map(tmp, op->map, op, flag); | | insert_ob_in_map(tmp, m, op, flag); |
} | | } |
} | | } |
| | |
int alchemy(object *op) | | int alchemy(object *op) |
{ | | { |
int x,y,weight=0,weight_max,large_nuggets,small_nuggets; | | int x,y,weight=0,weight_max,large_nuggets,small_nuggets, nx, ny; |
object *next,*tmp; | | object *next,*tmp; |
| | mapstruct *mp; |
| | |
if(op->type!=PLAYER) | | if(op->type!=PLAYER) |
return 0; | | return 0; |
| | |
| | |
for(y= op->y-1;y<=op->y+1;y++) { | | for(y= op->y-1;y<=op->y+1;y++) { |
for(x= op->x-1;x<=op->x+1;x++) { | | for(x= op->x-1;x<=op->x+1;x++) { |
if(out_of_map(op->map,x,y) || wall(op->map,x,y) || | | nx = x; |
blocks_view(op->map,x,y)) | | ny = y; |
| | |
| | mp = get_map_from_coord(op->map, &nx, &ny); |
| | |
| | /* wall checks out of map for us */ |
| | if(wall(mp,nx,ny) || blocks_magic(mp, nx, ny)) |
continue; | | continue; |
| | |
small_nuggets=0; | | small_nuggets=0; |
large_nuggets=0; | | large_nuggets=0; |
| | |
for(tmp=get_map_ob(op->map,x,y);tmp!=NULL;tmp=next) { | | for(tmp=get_map_ob(mp,nx,ny);tmp!=NULL;tmp=next) { |
next=tmp->above; | | next=tmp->above; |
if (tmp->weight>0 && !QUERY_FLAG(tmp, FLAG_NO_PICK) && | | if (tmp->weight>0 && !QUERY_FLAG(tmp, FLAG_NO_PICK) && |
!QUERY_FLAG(tmp, FLAG_ALIVE) && | | !QUERY_FLAG(tmp, FLAG_ALIVE) && |
| | |
alchemy_object(tmp, &small_nuggets, &large_nuggets, &weight); | | alchemy_object(tmp, &small_nuggets, &large_nuggets, &weight); |
| | |
if (weight>weight_max) { | | if (weight>weight_max) { |
update_map(op, small_nuggets, large_nuggets, x, y); | | update_map(op, mp, small_nuggets, large_nuggets, nx, ny); |
free_object(large); | | free_object(large); |
free_object(small); | | free_object(small); |
return 1; | | return 1; |
| | |
* it also prevents us from alcheming nuggets that were just created | | * it also prevents us from alcheming nuggets that were just created |
* with this spell. | | * with this spell. |
*/ | | */ |
update_map(op, small_nuggets, large_nuggets, x, y); | | update_map(op, mp, small_nuggets, large_nuggets, nx, ny); |
} | | } |
} | | } |
free_object(large); | | free_object(large); |