version 1.138 | | version 1.139 |
---|
| | |
/* | | /* |
* static char *rcsid_object_c = | | * static char *rcsid_object_c = |
* "$Id: object.c,v 1.138 2006/08/19 20:22:21 ryo_saeba Exp $"; | | * "$Id: object.c,v 1.139 2006/08/20 01:23:08 qal21 Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
/* Handle for plugin destroy event */ | | /* Handle for plugin destroy event */ |
execute_event(ob, EVENT_DESTROY,NULL,NULL,NULL,SCRIPT_FIX_NOTHING); | | execute_event(ob, EVENT_DESTROY,NULL,NULL,NULL,SCRIPT_FIX_NOTHING); |
| | |
if(ob->more!=NULL) { | | |
free_object2(ob->more, free_inventory); | | |
ob->more=NULL; | | |
} | | |
if (ob->inv) { | | if (ob->inv) { |
/* Only if the space blocks everything do we not process - | | /* Only if the space blocks everything do we not process - |
* if some form of movemnt is allowed, let objects | | * if some form of movemnt is allowed, let objects |
| | |
op->type==RUNE || op->type==TRAP || QUERY_FLAG(op,FLAG_IS_A_TEMPLATE)) | | op->type==RUNE || op->type==TRAP || QUERY_FLAG(op,FLAG_IS_A_TEMPLATE)) |
free_object(op); | | free_object(op); |
else { | | else { |
| | object *part; |
| | /* If it's a multi-tile object, scatter dropped items randomly */ |
| | if (ob->more) { |
| | int partcount = 0; |
| | /* Get the number of non-head parts */ |
| | for(part = ob; part; part = part->more) { |
| | partcount++; |
| | } |
| | /* Select a random part */ |
| | partcount = RANDOM()%partcount; |
| | for(part = ob; partcount>0; partcount--) { |
| | part = part->more; |
| | } |
| | } else { |
| | part = ob; |
| | } |
| | |
if ( QUERY_FLAG(op,FLAG_ALIVE) ) { | | if ( QUERY_FLAG(op,FLAG_ALIVE) ) { |
int pos = find_free_spot(op,ob->map,ob->x, ob->y, 0, SIZEOFFREE); | | int pos; |
| | |
| | pos = find_free_spot(op,part->map,part->x, part->y, 0, SIZEOFFREE); |
if ( pos == -1 ) | | if ( pos == -1 ) |
free_object(op); | | free_object(op); |
else { | | else { |
op->x=ob->x + freearr_x[ pos ]; | | op->x=part->x + freearr_x[ pos ]; |
op->y=ob->y + freearr_y[ pos ]; | | op->y=part->y + freearr_y[ pos ]; |
insert_ob_in_map(op,ob->map,NULL,0); /* Insert in same map as the envir */ | | insert_ob_in_map(op,part->map,NULL,0); /* Insert in same map as the envir */ |
} | | } |
} | | } |
else { | | else { |
op->x=ob->x; | | op->x=part->x; |
op->y=ob->y; | | op->y=part->y; |
insert_ob_in_map(op,ob->map,NULL,0); /* Insert in same map as the envir */ | | insert_ob_in_map(op,part->map,NULL,0); /* Insert in same map as the envir */ |
} | | } |
} | | } |
op=tmp; | | op=tmp; |
} | | } |
} | | } |
} | | } |
| | |
| | if(ob->more!=NULL) { |
| | free_object2(ob->more, free_inventory); |
| | ob->more=NULL; |
| | } |
| | |
/* Remove object from the active list */ | | /* Remove object from the active list */ |
ob->speed = 0; | | ob->speed = 0; |
update_ob_speed(ob); | | update_ob_speed(ob); |