… | |
… | |
44 | int mflags; |
44 | int mflags; |
45 | |
45 | |
46 | attacker = pet->attacked_by; /*pointer to attacking enemy */ |
46 | attacker = pet->attacked_by; /*pointer to attacking enemy */ |
47 | pet->attacked_by = NULL; /*clear this, since we are dealing with it */ |
47 | pet->attacked_by = NULL; /*clear this, since we are dealing with it */ |
48 | |
48 | |
49 | if ((owner = get_owner (pet)) != NULL) |
49 | if ((owner = pet->owner) != NULL) |
50 | { |
50 | { |
51 | /* If the owner has turned on the pet, make the pet |
51 | /* If the owner has turned on the pet, make the pet |
52 | * unfriendly. |
52 | * unfriendly. |
53 | */ |
53 | */ |
54 | if ((check_enemy (owner, rv)) == pet) |
54 | if ((check_enemy (owner, rv)) == pet) |
… | |
… | |
243 | for (obl = first_friendly_object; obl != NULL; obl = next) |
243 | for (obl = first_friendly_object; obl != NULL; obl = next) |
244 | { |
244 | { |
245 | object *ob = obl->ob; |
245 | object *ob = obl->ob; |
246 | |
246 | |
247 | next = obl->next; |
247 | next = obl->next; |
248 | if (get_owner (ob) == owner) |
248 | if (ob->owner == owner) |
249 | { |
249 | { |
250 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
250 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
251 | ob->remove (); |
251 | ob->remove (); |
252 | remove_friendly_object (ob); |
252 | remove_friendly_object (ob); |
253 | ob->destroy (); |
253 | ob->destroy (); |
… | |
… | |
272 | |
272 | |
273 | for (obl = first_friendly_object; obl != NULL; obl = next) |
273 | for (obl = first_friendly_object; obl != NULL; obl = next) |
274 | { |
274 | { |
275 | next = obl->next; |
275 | next = obl->next; |
276 | if (obl->ob->type != PLAYER && QUERY_FLAG (obl->ob, FLAG_FRIENDLY) && |
276 | if (obl->ob->type != PLAYER && QUERY_FLAG (obl->ob, FLAG_FRIENDLY) && |
277 | (owner = get_owner (obl->ob)) != NULL && !on_same_map (owner, obl->ob)) |
277 | (owner = obl->ob->owner) != NULL && !on_same_map (owner, obl->ob)) |
278 | { |
278 | { |
279 | /* follow owner checks map status for us */ |
279 | /* follow owner checks map status for us */ |
280 | follow_owner (obl->ob, owner); |
280 | follow_owner (obl->ob, owner); |
281 | } |
281 | } |
282 | } |
282 | } |
… | |
… | |
339 | sint16 dx, dy; |
339 | sint16 dx, dy; |
340 | object *ob2, *owner; |
340 | object *ob2, *owner; |
341 | maptile *m; |
341 | maptile *m; |
342 | |
342 | |
343 | /* Check to see if player pulled out */ |
343 | /* Check to see if player pulled out */ |
344 | if ((owner = get_owner (ob)) == NULL) |
344 | if ((owner = ob->owner) == NULL) |
345 | { |
345 | { |
346 | ob->remove (); /* Will be freed when returning */ |
346 | ob->remove (); /* Will be freed when returning */ |
347 | remove_friendly_object (ob); |
347 | remove_friendly_object (ob); |
348 | ob->destroy (); |
348 | ob->destroy (); |
349 | LOG (llevMonster, "Pet: no owner, leaving.\n"); |
349 | LOG (llevMonster, "Pet: no owner, leaving.\n"); |
… | |
… | |
409 | new_ob = ob2->head ? ob2->head : ob2; |
409 | new_ob = ob2->head ? ob2->head : ob2; |
410 | if (new_ob == ob) |
410 | if (new_ob == ob) |
411 | break; |
411 | break; |
412 | if (new_ob == ob->owner) |
412 | if (new_ob == ob->owner) |
413 | return; |
413 | return; |
414 | if (get_owner (new_ob) == ob->owner) |
414 | if (new_ob->owner == ob->owner) |
415 | break; |
415 | break; |
416 | |
416 | |
417 | /* Hmm. Did we try to move into an enemy monster? If so, |
417 | /* Hmm. Did we try to move into an enemy monster? If so, |
418 | * make it our enemy. |
418 | * make it our enemy. |
419 | */ |
419 | */ |
… | |
… | |
463 | tmp = arch_to_object (atmp); |
463 | tmp = arch_to_object (atmp); |
464 | if (atmp == at) |
464 | if (atmp == at) |
465 | { |
465 | { |
466 | if (!is_golem) |
466 | if (!is_golem) |
467 | SET_FLAG (tmp, FLAG_MONSTER); |
467 | SET_FLAG (tmp, FLAG_MONSTER); |
468 | set_owner (tmp, op); |
468 | tmp->set_owner (op); |
469 | if (op->type == PLAYER) |
469 | if (op->type == PLAYER) |
470 | { |
470 | { |
471 | tmp->stats.exp = 0; |
471 | tmp->stats.exp = 0; |
472 | add_friendly_object (tmp); |
472 | add_friendly_object (tmp); |
473 | SET_FLAG (tmp, FLAG_FRIENDLY); |
473 | SET_FLAG (tmp, FLAG_FRIENDLY); |
… | |
… | |
476 | } |
476 | } |
477 | else |
477 | else |
478 | { |
478 | { |
479 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
479 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
480 | { |
480 | { |
481 | object *owner = get_owner (op); |
481 | object *owner = op->owner; |
482 | |
482 | |
483 | if (owner != NULL) |
483 | if (owner != NULL) |
484 | { /* For now, we transfer ownership */ |
484 | { /* For now, we transfer ownership */ |
485 | set_owner (tmp, owner); |
485 | tmp->set_owner (owner); |
486 | tmp->attack_movement = PETMOVE; |
486 | tmp->attack_movement = PETMOVE; |
487 | add_friendly_object (tmp); |
487 | add_friendly_object (tmp); |
488 | SET_FLAG (tmp, FLAG_FRIENDLY); |
488 | SET_FLAG (tmp, FLAG_FRIENDLY); |
489 | } |
489 | } |
490 | } |
490 | } |
… | |
… | |
541 | object *tmp; |
541 | object *tmp; |
542 | |
542 | |
543 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
543 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
544 | return; /* Has already been moved */ |
544 | return; /* Has already been moved */ |
545 | |
545 | |
546 | if (get_owner (op) == NULL) |
546 | if (op->owner == NULL) |
547 | { |
547 | { |
548 | LOG (llevDebug, "Golem without owner destructed.\n"); |
548 | LOG (llevDebug, "Golem without owner destructed.\n"); |
549 | op->remove (); |
549 | op->remove (); |
550 | op->destroy (); |
550 | op->destroy (); |
551 | return; |
551 | return; |
… | |
… | |
709 | } |
709 | } |
710 | |
710 | |
711 | if (op->type == PLAYER) |
711 | if (op->type == PLAYER) |
712 | { |
712 | { |
713 | tmp->type = GOLEM; |
713 | tmp->type = GOLEM; |
714 | set_owner (tmp, op); |
714 | tmp->set_owner (op); |
715 | set_spell_skill (op, caster, spob, tmp); |
715 | set_spell_skill (op, caster, spob, tmp); |
716 | op->contr->ranges[range_golem] = tmp; |
716 | op->contr->ranges[range_golem] = tmp; |
717 | /* give the player control of the golem */ |
717 | /* give the player control of the golem */ |
718 | op->contr->shoottype = range_golem; |
718 | op->contr->shoottype = range_golem; |
719 | } |
719 | } |
720 | else |
720 | else |
721 | { |
721 | { |
722 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
722 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
723 | { |
723 | { |
724 | object *owner = get_owner (op); |
724 | object *owner = op->owner; |
725 | |
725 | |
726 | if (owner != NULL) |
726 | if (owner != NULL) |
727 | { /* For now, we transfer ownership */ |
727 | { /* For now, we transfer ownership */ |
728 | set_owner (tmp, owner); |
728 | tmp->set_owner (owner); |
729 | tmp->attack_movement = PETMOVE; |
729 | tmp->attack_movement = PETMOVE; |
730 | add_friendly_object (tmp); |
730 | add_friendly_object (tmp); |
731 | SET_FLAG (tmp, FLAG_FRIENDLY); |
731 | SET_FLAG (tmp, FLAG_FRIENDLY); |
732 | } |
732 | } |
733 | } |
733 | } |
… | |
… | |
932 | else if (spell_ob->race && !strcmp (spell_ob->race, "GODCULTMON")) |
932 | else if (spell_ob->race && !strcmp (spell_ob->race, "GODCULTMON")) |
933 | { |
933 | { |
934 | object *god = find_god (determine_god (op)), *mon, *owner; |
934 | object *god = find_god (determine_god (op)), *mon, *owner; |
935 | int summon_level, tries; |
935 | int summon_level, tries; |
936 | |
936 | |
937 | if (!god && ((owner = get_owner (op)) != NULL)) |
937 | if (!god && ((owner = op->owner) != NULL)) |
938 | god = find_god (determine_god (owner)); |
938 | god = find_god (determine_god (owner)); |
939 | |
939 | |
940 | /* If we can't find a god, can't get what monster to summon */ |
940 | /* If we can't find a god, can't get what monster to summon */ |
941 | if (!god) |
941 | if (!god) |
942 | return 0; |
942 | return 0; |
… | |
… | |
1031 | tmp = arch_to_object (atmp); |
1031 | tmp = arch_to_object (atmp); |
1032 | if (atmp == summon_arch) |
1032 | if (atmp == summon_arch) |
1033 | { |
1033 | { |
1034 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1034 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1035 | { |
1035 | { |
1036 | set_owner (tmp, op); |
1036 | tmp->set_owner (op); |
1037 | set_spell_skill (op, caster, spell_ob, tmp); |
1037 | set_spell_skill (op, caster, spell_ob, tmp); |
1038 | tmp->enemy = op->enemy; |
1038 | tmp->enemy = op->enemy; |
1039 | tmp->type = 0; |
1039 | tmp->type = 0; |
1040 | CLEAR_FLAG (tmp, FLAG_SLEEP); |
1040 | CLEAR_FLAG (tmp, FLAG_SLEEP); |
1041 | |
1041 | |
… | |
… | |
1049 | tmp->stats.exp = 0; |
1049 | tmp->stats.exp = 0; |
1050 | |
1050 | |
1051 | if (spell_ob->attack_movement) |
1051 | if (spell_ob->attack_movement) |
1052 | tmp->attack_movement = spell_ob->attack_movement; |
1052 | tmp->attack_movement = spell_ob->attack_movement; |
1053 | |
1053 | |
1054 | if (get_owner (op)) |
1054 | if (op->owner) |
1055 | set_owner (tmp, get_owner (op)); |
1055 | tmp->set_owner (op->owner); |
1056 | } |
1056 | } |
1057 | } |
1057 | } |
1058 | } |
1058 | } |
1059 | |
1059 | |
1060 | if (tmp->speed > MIN_ACTIVE_SPEED) |
1060 | if (tmp->speed > MIN_ACTIVE_SPEED) |
… | |
… | |
1101 | object *realowner = ob; |
1101 | object *realowner = ob; |
1102 | |
1102 | |
1103 | if (realowner == NULL) |
1103 | if (realowner == NULL) |
1104 | return NULL; |
1104 | return NULL; |
1105 | |
1105 | |
1106 | while (get_owner (realowner) != NULL) |
1106 | while (realowner->owner != NULL) |
1107 | { |
1107 | { |
1108 | realowner = get_owner (realowner); |
1108 | realowner = realowner->owner; |
1109 | } |
1109 | } |
1110 | return realowner; |
1110 | return realowner; |
1111 | } |
1111 | } |
1112 | |
1112 | |
1113 | /* determines if checks so pets don't attack players or other pets should be |
1113 | /* determines if checks so pets don't attack players or other pets should be |