ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/pets.C
(Generate patch)

Comparing deliantra/server/server/pets.C (file contents):
Revision 1.38 by root, Sun Jul 1 05:00:20 2007 UTC vs.
Revision 1.51 by root, Thu Jan 1 16:05:13 2009 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <sproto.h> 25#include <sproto.h>
26 26
31 * this is now tilemap aware. 31 * this is now tilemap aware.
32 */ 32 */
33object * 33object *
34get_pet_enemy (object *pet, rv_vector * rv) 34get_pet_enemy (object *pet, rv_vector * rv)
35{ 35{
36 object *owner, *tmp, *attacker, *tmp3; 36 object *tmp, *attacker, *tmp3;
37 int i; 37 int i;
38 sint16 x, y; 38 sint16 x, y;
39 maptile *nm; 39 maptile *nm;
40 int search_arr[SIZEOFFREE]; 40 int search_arr[SIZEOFFREE];
41 int mflags; 41 int mflags;
42 42
43 attacker = pet->attacked_by; /*pointer to attacking enemy */ 43 attacker = pet->attacked_by; /*pointer to attacking enemy */
44 pet->attacked_by = NULL; /*clear this, since we are dealing with it */ 44 pet->attacked_by = NULL; /*clear this, since we are dealing with it */
45 45
46 if (owner = pet->owner) 46 object *owner = pet->owner;
47 { 47
48 /* If the owner has turned on the pet, make the pet 48 if (!owner)
49 * unfriendly.
50 */
51 if (check_enemy (owner, rv) == pet)
52 {
53 remove_friendly_object (pet);
54 pet->attack_movement &= ~PETMOVE;
55 return owner;
56 }
57 } 49 {
58 else
59 {
60 /* else the owner is no longer around, so the 50 /* the owner is no longer around, so the
61 * pet no longer needs to be friendly. 51 * pet no longer needs to be friendly.
62 */ 52 */
63 remove_friendly_object (pet); 53 remove_friendly_object (pet);
64 pet->attack_movement &= ~PETMOVE; 54 pet->attack_movement &= ~PETMOVE;
65 return 0; 55 return 0;
56 }
57
58 /* If the owner has turned on the pet, make the pet
59 * unfriendly.
60 */
61 if (check_enemy (owner, rv) == pet)
62 {
63 remove_friendly_object (pet);
64 pet->attack_movement &= ~PETMOVE;
65 return owner;
66 } 66 }
67 67
68 /* If they are not on the same map, the pet won't be agressive */ 68 /* If they are not on the same map, the pet won't be agressive */
69 //if (!on_same_map (pet, owner)) 69 //if (!on_same_map (pet, owner))
70 // return 0; 70 // return 0;
254 { 254 {
255 object *ob = obl->ob; 255 object *ob = obl->ob;
256 next = obl->next; 256 next = obl->next;
257 257
258 if (ob->owner == owner) 258 if (ob->owner == owner)
259 ob->destroy (); 259 ob->drop_and_destroy ();
260 } 260 }
261} 261}
262 262
263/* 263/*
264 * Unfortunately, sometimes, the owner of a pet is in the 264 * Unfortunately, sometimes, the owner of a pet is in the
292int 292int
293follow_owner (object *ob, object *owner) 293follow_owner (object *ob, object *owner)
294{ 294{
295 if (owner->flag [FLAG_REMOVED]) 295 if (owner->flag [FLAG_REMOVED])
296 return 0; // do nothing if the owner is removed 296 return 0; // do nothing if the owner is removed
297 else if (!owner->map || owner->map->in_memory != MAP_IN_MEMORY) 297 else if (!owner->map || owner->map->in_memory != MAP_ACTIVE)
298 LOG (llevError, "owner '%s' of the pet '%s' not on a map in memory!?\n", &owner->name, &ob->name); 298 LOG (llevError, "owner '%s' of the pet '%s' not on a map in memory!?\n", &owner->name, &ob->name);
299 else 299 else
300 { 300 {
301 int dir = find_free_spot (ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE); 301 int dir = find_free_spot (ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE);
302 302
309 309
310 return 0; 310 return 0;
311 } 311 }
312 } 312 }
313 313
314 ob->destroy (); 314 ob->drop_and_destroy ();
315
315 return 1; 316 return 1;
316} 317}
317 318
318void 319void
319pet_move (object *ob) 320pet_move (object *ob)
324 maptile *m; 325 maptile *m;
325 326
326 /* Check to see if player pulled out */ 327 /* Check to see if player pulled out */
327 if ((owner = ob->owner) == NULL) 328 if ((owner = ob->owner) == NULL)
328 { 329 {
329 ob->destroy (); 330 ob->drop_and_destroy ();
330 LOG (llevMonster, "Pet: no owner, leaving.\n"); 331 LOG (llevMonster, "Pet: no owner, leaving.\n");
331 return; 332 return;
332 } 333 }
333 334
334 /* move monster into the owners map if not in the same map 335 /* move monster into the owners map if not in the same map
532 return; /* Has already been moved */ 533 return; /* Has already been moved */
533 534
534 if (!op->owner) 535 if (!op->owner)
535 { 536 {
536 LOG (llevDebug, "Golem without owner destructed.\n"); 537 LOG (llevDebug, "Golem without owner destructed.\n");
537 op->remove ();
538 op->destroy (); 538 op->drop_and_destroy ();
539 return; 539 return;
540 } 540 }
541 541
542 /* It would be nice to have a cleaner way of what message to print 542 /* It would be nice to have a cleaner way of what message to print
543 * when the golem expires than these hard coded entries. 543 * when the golem expires than these hard coded entries.
547 if (--op->stats.hp < 0) 547 if (--op->stats.hp < 0)
548 { 548 {
549 if (op->msg) 549 if (op->msg)
550 new_draw_info (NDI_UNIQUE, 0, op->owner, op->msg); 550 new_draw_info (NDI_UNIQUE, 0, op->owner, op->msg);
551 551
552 op->destroy (); 552 op->drop_and_destroy ();
553 return; 553 return;
554 } 554 }
555 555
556 /* Do golem attacks/movement for single & multisq golems. 556 /* Do golem attacks/movement for single & multisq golems.
557 * Assuming here that op is the 'head' object. Pass only op to 557 * Assuming here that op is the 'head' object. Pass only op to
575 mflags = get_map_flags (m, &m, x, y, &x, &y); 575 mflags = get_map_flags (m, &m, x, y, &x, &y);
576 576
577 if (mflags & P_OUT_OF_MAP) 577 if (mflags & P_OUT_OF_MAP)
578 continue; 578 continue;
579 579
580 for (victim = GET_MAP_OB (op->map, x, y); victim; victim = victim->above) 580 for (victim = GET_MAP_OB (m, x, y); victim; victim = victim->above)
581 if (QUERY_FLAG (victim, FLAG_ALIVE)) 581 if (QUERY_FLAG (victim, FLAG_ALIVE))
582 break; 582 break;
583 583
584 /* We used to call will_hit_self to make sure we don't 584 /* We used to call will_hit_self to make sure we don't
585 * hit ourselves, but that didn't work, and I don't really 585 * hit ourselves, but that didn't work, and I don't really
592 { 592 {
593 /* for golems with race fields, we don't attack 593 /* for golems with race fields, we don't attack
594 * aligned races 594 * aligned races
595 */ 595 */
596 596
597 if (victim->race && op->race && strstr (op->race, victim->race)) 597 if (victim->race && op->race && op->race.contains (victim->race))
598 { 598 {
599 if (op->owner) 599 if (op->owner)
600 new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s avoids damaging %s.", &op->name, &victim->name); 600 new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s avoids damaging %s.", &op->name, &victim->name);
601 } 601 }
602 else if (victim == op->owner) 602 else if (victim == op->owner)
625control_golem (object *op, int dir) 625control_golem (object *op, int dir)
626{ 626{
627 op->direction = dir; 627 op->direction = dir;
628} 628}
629 629
630/* summon golem: summons a monster for 'op'. caster is the object 630/* summon golem: summons a monster for 'op'. caster is the object
631 * casting the spell, dir is the direction to place the monster, 631 * casting the spell, dir is the direction to place the monster,
632 * at is the archetype of the monster, and spob is the spell 632 * at is the archetype of the monster, and spob is the spell
633 * object. At this stage, all spob is really used for is to 633 * object. At this stage, all spob is really used for is to
634 * adjust some values in the monster. 634 * adjust some values in the monster.
635 */ 635 */
644 * 'lose' their old golem. 644 * 'lose' their old golem.
645 */ 645 */
646 if (op->type == PLAYER && op->contr->golem) 646 if (op->type == PLAYER && op->contr->golem)
647 { 647 {
648 new_draw_info (NDI_UNIQUE, 0, op, "You dismiss your existing golem."); 648 new_draw_info (NDI_UNIQUE, 0, op, "You dismiss your existing golem.");
649 op->contr->golem->remove ();
650 op->contr->golem->destroy (); 649 op->contr->golem->drop_and_destroy ();
651 op->contr->golem = 0; 650 op->contr->golem = 0;
652 } 651 }
653 652
654 if (spob->other_arch) 653 if (spob->other_arch)
655 at = spob->other_arch; 654 at = spob->other_arch;
678 } 677 }
679 678
680 if (!dir) 679 if (!dir)
681 dir = find_free_spot (at, op->map, op->x, op->y, 1, SIZEOFFREE1 + 1); 680 dir = find_free_spot (at, op->map, op->x, op->y, 1, SIZEOFFREE1 + 1);
682 681
683 if (dir < 0 || ob_blocked (at, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir])) 682 if (dir < 0 || at->blocked (op->map, op->x + freearr_x[dir], op->y + freearr_y[dir]))
684 { 683 {
685 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 684 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
686 return 0; 685 return 0;
687 } 686 }
688 687
695 } 694 }
696 695
697 if (op->type == PLAYER) 696 if (op->type == PLAYER)
698 { 697 {
699 tmp->type = GOLEM; 698 tmp->type = GOLEM;
700 tmp->set_owner (op);
701 op->contr->golem = tmp; 699 op->contr->golem = tmp;
702 /* give the player control of the golem */ 700 /* give the player control of the golem */
703 set_spell_skill (op, caster, spob, tmp); 701 set_spell_skill (op, caster, spob, tmp);
704 } 702 }
705 else
706 {
707 if (QUERY_FLAG (op, FLAG_FRIENDLY))
708 {
709 object *owner = op->owner;
710
711 if (owner)
712 { /* For now, we transfer ownership */
713 tmp->set_owner (owner);
714 tmp->attack_movement = PETMOVE;
715 add_friendly_object (tmp);
716 }
717 }
718
719 SET_FLAG (tmp, FLAG_MONSTER);
720 }
721 703
722 /* make the speed positive. */ 704 /* make the speed positive. */
723 tmp->speed = FABS (tmp->speed); 705 tmp->speed = fabs (tmp->speed);
724 706
725 /* This sets the level dependencies on dam and hp for monsters */ 707 /* This sets the level dependencies on dam and hp for monsters */
726 /* players can't cope with too strong summonings. */ 708 /* players can't cope with too strong summonings. */
727 /* but monsters can. reserve these for players. */ 709 /* but monsters can. reserve these for players. */
728 if (op->type == PLAYER) 710 if (op->type == PLAYER)
733 tmp->stats.dam += SP_level_dam_adjust (caster, spob); 715 tmp->stats.dam += SP_level_dam_adjust (caster, spob);
734 else 716 else
735 tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); 717 tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob);
736 718
737 tmp->speed += .02 * SP_level_range_adjust (caster, spob); 719 tmp->speed += .02 * SP_level_range_adjust (caster, spob);
738 tmp->speed = MIN (tmp->speed, 1.0); 720 tmp->speed = min (tmp->speed, 1.0);
739 721
740 if (spob->attacktype) 722 if (spob->attacktype)
741 tmp->attacktype = spob->attacktype; 723 tmp->attacktype = spob->attacktype;
742 } 724 }
743 725
747 729
748 /* make experience increase in proportion to the strength. 730 /* make experience increase in proportion to the strength.
749 * this is a bit simplistic - we are basically just looking at how 731 * this is a bit simplistic - we are basically just looking at how
750 * often the sp doubles and use that as the ratio. 732 * often the sp doubles and use that as the ratio.
751 */ 733 */
752 tmp->stats.exp *= 1 + (MAX (spob->stats.maxgrace, spob->stats.sp) / caster_level (caster, spob)); 734 tmp->stats.exp *= 1 + max (spob->stats.maxgrace, spob->stats.sp) / casting_level (caster, spob);
753 tmp->speed_left = 0; 735 tmp->speed_left = 0;
754 tmp->direction = dir; 736 tmp->direction = dir;
755 737
756 /* Holy spell - some additional tailoring */ 738 /* Holy spell - some additional tailoring */
757 if (god) 739 if (god)
773 if (!(tmp->attacktype & AT_PHYSICAL)) 755 if (!(tmp->attacktype & AT_PHYSICAL))
774 tmp->attacktype |= AT_PHYSICAL; 756 tmp->attacktype |= AT_PHYSICAL;
775 } 757 }
776 758
777 insert_ob_in_map (tmp, tmp->map, op, 0); 759 insert_ob_in_map (tmp, tmp->map, op, 0);
760
778 return 1; 761 return 1;
779} 762}
780 763
781 764
782/*************************************************************************** 765/***************************************************************************
788/* Returns a monster (chosen at random) that this particular player (and his 771/* Returns a monster (chosen at random) that this particular player (and his
789 * god) find acceptable. This checks level, races allowed by god, etc 772 * god) find acceptable. This checks level, races allowed by god, etc
790 * to determine what is acceptable. 773 * to determine what is acceptable.
791 * This returns NULL if no match was found. 774 * This returns NULL if no match was found.
792 */ 775 */
793
794object * 776object *
795choose_cult_monster (object *pl, object *god, int summon_level) 777choose_cult_monster (object *pl, object *god, int summon_level)
796{ 778{
797 char buf[MAX_BUF]; 779 char buf[MAX_BUF];
798 const char *race; 780 const char *race;
853 * a valid entry, assuming nothing is available and quit. 835 * a valid entry, assuming nothing is available and quit.
854 */ 836 */
855 if (!mon_nr) 837 if (!mon_nr)
856 return NULL; 838 return NULL;
857 839
858 mon_nr = rndm (0, mon_nr - 1); 840 mon_nr = rndm (mon_nr - 1);
859 for (tobl = list->member; tobl; tobl = tobl->next) 841 for (tobl = list->member; tobl; tobl = tobl->next)
860 { 842 {
861 otmp = tobl->ob; 843 otmp = tobl->ob;
862 if (!otmp || !QUERY_FLAG (otmp, FLAG_MONSTER)) 844 if (!otmp || !QUERY_FLAG (otmp, FLAG_MONSTER))
863 continue; 845 continue;
846
864 if (otmp->level <= summon_level && !mon_nr--) 847 if (otmp->level <= summon_level && !mon_nr--)
865 return otmp; 848 return otmp;
866 } 849 }
850
867 /* This should not happen */ 851 /* This should not happen */
868 LOG (llevDebug, "choose_cult_monster() mon_nr was set, but did not find a monster\n"); 852 LOG (llevDebug, "choose_cult_monster() mon_nr was set, but did not find a monster\n");
869 return NULL; 853 return NULL;
870} 854}
871 855
878 862
879 if (spell_ob->other_arch) 863 if (spell_ob->other_arch)
880 summon_arch = spell_ob->other_arch; 864 summon_arch = spell_ob->other_arch;
881 else if (spell_ob->randomitems) 865 else if (spell_ob->randomitems)
882 { 866 {
883 int level = caster_level (caster, spell_ob); 867 int level = casting_level (caster, spell_ob);
884 treasure *tr, *lasttr = NULL; 868 treasure *tr, *lasttr = NULL;
885 869
886 shstr_cmp sparam (stringarg); 870 shstr_cmp sparam (stringarg);
887 871
888 /* In old code, this was a very convoluted for statement, 872 /* In old code, this was a very convoluted for statement,
911 } 895 }
912 896
913 summon_arch = lasttr->item; 897 summon_arch = lasttr->item;
914 nrof = lasttr->nrof; 898 nrof = lasttr->nrof;
915 } 899 }
916 else if (spell_ob->race && !strcmp (spell_ob->race, "GODCULTMON")) 900 else if (spell_ob->race == shstr_GODCULTMON)
917 { 901 {
918 object *god = find_god (determine_god (op)), *mon, *owner; 902 object *god = find_god (determine_god (op)), *mon, *owner;
919 int summon_level, tries; 903 int summon_level, tries;
920 904
921 if (!god && ((owner = op->owner) != NULL)) 905 if (!god && ((owner = op->owner) != NULL))
930 new_draw_info_format (NDI_UNIQUE, 0, op, "%s has no creatures that you may summon!", &god->name); 914 new_draw_info_format (NDI_UNIQUE, 0, op, "%s has no creatures that you may summon!", &god->name);
931 return 0; 915 return 0;
932 } 916 }
933 917
934 /* the summon level */ 918 /* the summon level */
935 summon_level = caster_level (caster, spell_ob); 919 summon_level = casting_level (caster, spell_ob);
936 if (summon_level == 0) 920 if (summon_level == 0)
937 summon_level = 1; 921 summon_level = 1;
938 922
939 tries = 0; 923 tries = 0;
940 do 924 do
949 ndir = dir; 933 ndir = dir;
950 934
951 if (!ndir) 935 if (!ndir)
952 ndir = find_free_spot (mon, op->map, op->x, op->y, 1, SIZEOFFREE); 936 ndir = find_free_spot (mon, op->map, op->x, op->y, 1, SIZEOFFREE);
953 937
954 if (ndir < 0 || ob_blocked (mon, op->map, op->x + freearr_x[ndir], op->y + freearr_y[ndir])) 938 if (ndir < 0 || mon->blocked (op->map, op->x + freearr_x[ndir], op->y + freearr_y[ndir]))
955 { 939 {
956 ndir = -1; 940 ndir = -1;
957 if (++tries == 5) 941 if (++tries == 5)
958 { 942 {
959 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 943 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
998 { 982 {
999 x = freearr_x[ndir]; 983 x = freearr_x[ndir];
1000 y = freearr_y[ndir]; 984 y = freearr_y[ndir];
1001 } 985 }
1002 986
1003 if (ndir < 0 || ob_blocked (summon_arch, op->map, op->x + x, op->y + y)) 987 if (ndir < 0 || summon_arch->blocked (op->map, op->x + x, op->y + y))
1004 { 988 {
1005 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 989 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
1006 if (nrof > 1) 990 if (nrof > 1)
1007 new_draw_info (NDI_UNIQUE, 0, op, "No more pets for this casting."); 991 new_draw_info (NDI_UNIQUE, 0, op, "No more pets for this casting.");
1008 992
1071 } /* for i < nrof */ 1055 } /* for i < nrof */
1072 1056
1073 return 1; 1057 return 1;
1074} 1058}
1075 1059
1076/* recursively look through the owner property of objects until the real owner
1077is found */
1078object *
1079get_real_owner (object *ob)
1080{
1081 object *realowner = ob;
1082
1083 if (realowner == NULL)
1084 return NULL;
1085
1086 while (realowner->owner != NULL)
1087 {
1088 realowner = realowner->owner;
1089 }
1090 return realowner;
1091}
1092
1093/* determines if checks so pets don't attack players or other pets should be 1060/* determines if checks so pets don't attack players or other pets should be
1094overruled by the arena petmode */ 1061overruled by the arena petmode */
1095int 1062int
1096should_arena_attack (object *pet, object *owner, object *target) 1063should_arena_attack (object *pet, object *owner, object *target)
1097{ 1064{
1101 if ((target == NULL) || (pet == NULL) || (owner == NULL)) 1068 if ((target == NULL) || (pet == NULL) || (owner == NULL))
1102 return 0; 1069 return 0;
1103 1070
1104 /* get the owners of itself and the target, this is to deal with pets of 1071 /* get the owners of itself and the target, this is to deal with pets of
1105 pets */ 1072 pets */
1106 rowner = get_real_owner (owner); 1073 rowner = owner->outer_owner ();
1107 towner = target->type == PLAYER ? 0 : get_real_owner (target); 1074 towner = target->is_player () ? 0 : target->outer_owner ();
1108 1075
1109 /* if the pet has now owner, exit with error */ 1076 /* if the pet has now owner, exit with error */
1110 if (!rowner) 1077 if (!rowner)
1111 { 1078 {
1112 LOG (llevError, "Pet has no owner.\n"); 1079 LOG (llevError, "Pet has no owner.\n");
1113 return 0; 1080 return 0;
1114 } 1081 }
1115 1082
1116 /* if the target is not a player, and has no owner, we shouldn't be here 1083 /* if the target is not a player, and has no owner, we shouldn't be here
1117 */ 1084 */
1118 if ((towner == NULL) && (target->type != PLAYER)) 1085 if (!towner && !target->is_player ())
1119 { 1086 {
1120 LOG (llevError, "Target is not a player but has no owner. We should not be here.\n"); 1087 LOG (llevError, "Target is not a player but has no owner. We should not be here.\n");
1121 return 0; 1088 return 0;
1122 } 1089 }
1123 1090
1124 /* make sure that the owner is a player */ 1091 /* make sure that the owner is a player */
1125 if (rowner->type != PLAYER) 1092 if (!rowner->is_player ())
1126 return 0; 1093 return 0;
1127 1094
1128 /* abort if the petmode is not arena */ 1095 /* abort if the petmode is not arena */
1129 if (rowner->contr->petmode != pet_arena) 1096 if (rowner->contr->petmode != pet_arena)
1130 return 0; 1097 return 0;
1132 /* abort if the pet, it's owner, or the target is not on battleground */ 1099 /* abort if the pet, it's owner, or the target is not on battleground */
1133 if (!(op_on_battleground (pet, NULL, NULL) && op_on_battleground (owner, NULL, NULL) && op_on_battleground (target, NULL, NULL))) 1100 if (!(op_on_battleground (pet, NULL, NULL) && op_on_battleground (owner, NULL, NULL) && op_on_battleground (target, NULL, NULL)))
1134 return 0; 1101 return 0;
1135 1102
1136 /* if the target is a monster, make sure it's owner is not the same */ 1103 /* if the target is a monster, make sure it's owner is not the same */
1137 if ((target->type != PLAYER) && (rowner == towner)) 1104 if (!target->is_player () && rowner == towner)
1138 return 0; 1105 return 0;
1139 1106
1140 /* check if the target is a player which affects how it will handle 1107 /* check if the target is a player which affects how it will handle
1141 parties */ 1108 parties */
1142 if (target->type != PLAYER) 1109 if (!target->is_player ())
1143 { 1110 {
1144 /* if the target is owned by a player make sure than make sure 1111 /* if the target is owned by a player make sure than make sure
1145 it's not in the same party */ 1112 it's not in the same party */
1146 if ((towner->type == PLAYER) && (rowner->contr->party != NULL)) 1113 if (towner->is_player () && rowner->contr->party)
1147 {
1148 if (rowner->contr->party == towner->contr->party) 1114 if (rowner->contr->party == towner->contr->party)
1149 return 0; 1115 return 0;
1150 }
1151 } 1116 }
1152 else 1117 else
1153 { 1118 {
1154 /* if the target is a player make sure than make sure it's not 1119 /* if the target is a player make sure than make sure it's not
1155 in the same party */ 1120 in the same party */
1156 if (rowner->contr->party != NULL) 1121 if (rowner->contr->party)
1157 {
1158 if (rowner->contr->party == target->contr->party) 1122 if (rowner->contr->party == target->contr->party)
1159 return 0; 1123 return 0;
1160 }
1161 } 1124 }
1162 1125
1163 return 1; 1126 return 1;
1164} 1127}
1128

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines