… | |
… | |
47 | if (owner = pet->owner) |
47 | if (owner = pet->owner) |
48 | { |
48 | { |
49 | /* If the owner has turned on the pet, make the pet |
49 | /* If the owner has turned on the pet, make the pet |
50 | * unfriendly. |
50 | * unfriendly. |
51 | */ |
51 | */ |
52 | if ((check_enemy (owner, rv)) == pet) |
52 | if (check_enemy (owner, rv) == pet) |
53 | { |
53 | { |
54 | CLEAR_FLAG (pet, FLAG_FRIENDLY); |
|
|
55 | remove_friendly_object (pet); |
54 | remove_friendly_object (pet); |
56 | pet->attack_movement &= ~PETMOVE; |
55 | pet->attack_movement &= ~PETMOVE; |
57 | return owner; |
56 | return owner; |
58 | } |
57 | } |
59 | } |
58 | } |
60 | else |
59 | else |
61 | { |
60 | { |
62 | /* else the owner is no longer around, so the |
61 | /* else the owner is no longer around, so the |
63 | * pet no longer needs to be friendly. |
62 | * pet no longer needs to be friendly. |
64 | */ |
63 | */ |
65 | CLEAR_FLAG (pet, FLAG_FRIENDLY); |
|
|
66 | remove_friendly_object (pet); |
64 | remove_friendly_object (pet); |
67 | pet->attack_movement &= ~PETMOVE; |
65 | pet->attack_movement &= ~PETMOVE; |
68 | return 0; |
66 | return 0; |
69 | } |
67 | } |
|
|
68 | |
70 | /* If they are not on the same map, the pet won't be agressive */ |
69 | /* If they are not on the same map, the pet won't be agressive */ |
71 | //if (!on_same_map (pet, owner)) |
70 | //if (!on_same_map (pet, owner)) |
72 | // return 0; |
71 | // return 0; |
73 | |
72 | |
74 | /* See if the pet has an existing enemy. If so, don't start a new one */ |
73 | /* See if the pet has an existing enemy. If so, don't start a new one */ |
… | |
… | |
249 | void |
248 | void |
250 | terminate_all_pets (object *owner) |
249 | terminate_all_pets (object *owner) |
251 | { |
250 | { |
252 | objectlink *obl, *next; |
251 | objectlink *obl, *next; |
253 | |
252 | |
254 | for (obl = first_friendly_object; obl != NULL; obl = next) |
253 | for (obl = first_friendly_object; obl; obl = next) |
255 | { |
254 | { |
256 | object *ob = obl->ob; |
255 | object *ob = obl->ob; |
257 | |
|
|
258 | next = obl->next; |
256 | next = obl->next; |
|
|
257 | |
259 | if (ob->owner == owner) |
258 | if (ob->owner == owner) |
260 | { |
|
|
261 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
|
|
262 | ob->remove (); |
|
|
263 | remove_friendly_object (ob); |
|
|
264 | ob->destroy (); |
259 | ob->destroy (); |
265 | } |
|
|
266 | } |
260 | } |
267 | } |
261 | } |
268 | |
262 | |
269 | /* |
263 | /* |
270 | * Unfortunately, sometimes, the owner of a pet is in the |
264 | * Unfortunately, sometimes, the owner of a pet is in the |
… | |
… | |
330 | maptile *m; |
324 | maptile *m; |
331 | |
325 | |
332 | /* Check to see if player pulled out */ |
326 | /* Check to see if player pulled out */ |
333 | if ((owner = ob->owner) == NULL) |
327 | if ((owner = ob->owner) == NULL) |
334 | { |
328 | { |
335 | ob->remove (); /* Will be freed when returning */ |
|
|
336 | remove_friendly_object (ob); |
|
|
337 | ob->destroy (); |
329 | ob->destroy (); |
338 | LOG (llevMonster, "Pet: no owner, leaving.\n"); |
330 | LOG (llevMonster, "Pet: no owner, leaving.\n"); |
339 | return; |
331 | return; |
340 | } |
332 | } |
341 | |
333 | |
… | |
… | |
537 | object *tmp; |
529 | object *tmp; |
538 | |
530 | |
539 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
531 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
540 | return; /* Has already been moved */ |
532 | return; /* Has already been moved */ |
541 | |
533 | |
542 | if (op->owner == NULL) |
534 | if (!op->owner) |
543 | { |
535 | { |
544 | LOG (llevDebug, "Golem without owner destructed.\n"); |
536 | LOG (llevDebug, "Golem without owner destructed.\n"); |
545 | op->remove (); |
537 | op->remove (); |
546 | op->destroy (); |
538 | op->destroy (); |
547 | return; |
539 | return; |
… | |
… | |
555 | if (--op->stats.hp < 0) |
547 | if (--op->stats.hp < 0) |
556 | { |
548 | { |
557 | if (op->msg) |
549 | if (op->msg) |
558 | new_draw_info (NDI_UNIQUE, 0, op->owner, op->msg); |
550 | new_draw_info (NDI_UNIQUE, 0, op->owner, op->msg); |
559 | |
551 | |
560 | op->owner->contr->ranges[range_golem] = 0; |
|
|
561 | remove_friendly_object (op); |
|
|
562 | op->remove (); |
|
|
563 | op->destroy (); |
552 | op->destroy (); |
564 | return; |
553 | return; |
565 | } |
554 | } |
566 | |
555 | |
567 | /* Do golem attacks/movement for single & multisq golems. |
556 | /* Do golem attacks/movement for single & multisq golems. |
… | |
… | |
599 | * but since we are not trying to dereferance that pointer, |
588 | * but since we are not trying to dereferance that pointer, |
600 | * that isn't a problem. |
589 | * that isn't a problem. |
601 | */ |
590 | */ |
602 | if (victim && victim != op && victim->head != op) |
591 | if (victim && victim != op && victim->head != op) |
603 | { |
592 | { |
604 | |
|
|
605 | /* for golems with race fields, we don't attack |
593 | /* for golems with race fields, we don't attack |
606 | * aligned races |
594 | * aligned races |
607 | */ |
595 | */ |
608 | |
596 | |
609 | if (victim->race && op->race && strstr (op->race, victim->race)) |
597 | if (victim->race && op->race && strstr (op->race, victim->race)) |
… | |
… | |
708 | |
696 | |
709 | if (op->type == PLAYER) |
697 | if (op->type == PLAYER) |
710 | { |
698 | { |
711 | tmp->type = GOLEM; |
699 | tmp->type = GOLEM; |
712 | tmp->set_owner (op); |
700 | tmp->set_owner (op); |
713 | set_spell_skill (op, caster, spob, tmp); |
|
|
714 | op->contr->ranges[range_golem] = tmp; |
701 | op->contr->ranges[range_golem] = tmp; |
715 | /* give the player control of the golem */ |
702 | /* give the player control of the golem */ |
716 | op->contr->shoottype = range_golem; |
703 | op->contr->shoottype = range_golem; |
|
|
704 | set_spell_skill (op, caster, spob, tmp); |
717 | } |
705 | } |
718 | else |
706 | else |
719 | { |
707 | { |
720 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
708 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
721 | { |
709 | { |
… | |
… | |
1116 | return 0; |
1104 | return 0; |
1117 | |
1105 | |
1118 | /* get the owners of itself and the target, this is to deal with pets of |
1106 | /* get the owners of itself and the target, this is to deal with pets of |
1119 | pets */ |
1107 | pets */ |
1120 | rowner = get_real_owner (owner); |
1108 | rowner = get_real_owner (owner); |
1121 | if (target->type != PLAYER) |
1109 | towner = target->type == PLAYER ? 0 : get_real_owner (target); |
1122 | { |
|
|
1123 | towner = get_real_owner (target); |
|
|
1124 | } |
|
|
1125 | else |
|
|
1126 | { |
|
|
1127 | towner = 0; |
|
|
1128 | } |
|
|
1129 | |
1110 | |
1130 | /* if the pet has now owner, exit with error */ |
1111 | /* if the pet has now owner, exit with error */ |
1131 | if (rowner == NULL) |
1112 | if (!rowner) |
1132 | { |
1113 | { |
1133 | LOG (llevError, "Pet has no owner.\n"); |
1114 | LOG (llevError, "Pet has no owner.\n"); |
1134 | return 0; |
1115 | return 0; |
1135 | } |
1116 | } |
1136 | |
1117 | |