version 1.81 | | version 1.82 |
---|
| | |
/* | | /* |
* static char *rcsid_time_c = | | * static char *rcsid_time_c = |
* "$Id: time.c,v 1.81 2005/12/01 08:25:45 mwedel Exp $"; | | * "$Id: time.c,v 1.82 2005/12/05 22:58:35 akirschbaum Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
* outside of the map which would cause the server to crash | | * outside of the map which would cause the server to crash |
*/ | | */ |
| | |
void move_creator(object *op) { | | void move_creator(object *creator) { |
object *tmp,*head=NULL,*prev=NULL; | | object *new_ob; |
archetype *at=op->other_arch; | | |
| | |
op->stats.hp--; | | if(!QUERY_FLAG(creator, FLAG_LIFESAVE) && --creator->stats.hp < 0) { |
if(op->stats.hp < 0 && !QUERY_FLAG(op,FLAG_LIFESAVE)) { | | creator->stats.hp=-1; |
op->stats.hp=-1; | | |
return; | | return; |
} | | } |
if (!at) { | | |
LOG(llevError,"move_creator: Creator doesn't have other arch set: %s (%s, %d, %d)\n", | | if (creator->inv != NULL) { |
op->name?op->name:"(null)", op->map->path, op->x, op->y); | | object *ob; |
return; | | int i; |
| | object *ob_to_copy; |
| | |
| | /* select random object from inventory to copy */ |
| | ob_to_copy = creator->inv; |
| | for (ob = creator->inv->below, i = 1; ob != NULL; ob = ob->below, i++) { |
| | if (rndm(0, i) == 0) { |
| | ob_to_copy = ob; |
} | | } |
/* Make sure this multipart object fits */ | | } |
if (at->more && ob_blocked(&at->clone, op->map, op->x, op->y)) | | new_ob = object_create_clone(ob_to_copy); |
| | CLEAR_FLAG(new_ob, FLAG_IS_A_TEMPLATE); |
| | unflag_inv(new_ob, FLAG_IS_A_TEMPLATE); |
| | } else { |
| | if (creator->other_arch == NULL) { |
| | LOG(llevError,"move_creator: Creator doesn't have other arch set: %s (%s, %d, %d)\n", creator->name ? creator->name : "(null)", creator->map->path, creator->x, creator->y); |
return; | | return; |
| | } |
| | |
while(at!=NULL) { | | new_ob = object_create_arch(creator->other_arch); |
tmp=arch_to_object(at); | | fix_generated_item(new_ob, creator, 0, 0, GT_MINIMAL); |
tmp->x=op->x+at->clone.x; | | } |
tmp->y=op->y+at->clone.y; | | |
tmp->map=op->map; | | |
tmp->level=op->level; | | |
| | |
if(head!=NULL) | | |
tmp->head=head,prev->more=tmp; | | |
| | |
insert_ob_in_map(tmp,op->map,op,0); | | /* Make sure this multipart object fits */ |
if (QUERY_FLAG(tmp, FLAG_FREED)) return; | | if (new_ob->arch->more && ob_blocked(new_ob, creator->map, creator->x, creator->y)) { |
| | free_object(new_ob); |
| | return; |
| | } |
| | |
if(head==NULL) | | insert_ob_in_map_at(new_ob, creator->map, creator, 0, creator->x, creator->y); |
head=tmp; | | if (QUERY_FLAG(new_ob, FLAG_FREED)) |
prev=tmp; | | return; |
at=at->more; | | |
| | |
if(op->slaying) { | | if (creator->slaying) { |
if (tmp->name) free_string (tmp->name); | | FREE_AND_COPY(new_ob->name, creator->slaying); |
if (tmp->title) free_string (tmp->title); | | FREE_AND_COPY(new_ob->title, creator->slaying); |
tmp->name = add_string(op->slaying); | | |
tmp->title = add_string(op->slaying); | | |
} | | |
} | | } |
} | | } |
| | |
| | |
} | | } |
| | |
int process_object(object *op) { | | int process_object(object *op) { |
| | if (QUERY_FLAG(op, FLAG_IS_A_TEMPLATE)) |
| | return 0; |
| | |
if(QUERY_FLAG(op, FLAG_MONSTER)) | | if(QUERY_FLAG(op, FLAG_MONSTER)) |
if(move_monster(op) || QUERY_FLAG(op, FLAG_FREED)) | | if(move_monster(op) || QUERY_FLAG(op, FLAG_FREED)) |