| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "global.h" |
| 20 |
|
| 21 |
#include <assert.h> |
| 22 |
#include <ctype.h> |
| 23 |
#include <stdlib.h> |
| 24 |
#include <string.h> |
| 25 |
|
| 26 |
#include "sproto.h" |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
static void mark_inventory_as_no_drop(object *ob) { |
| 35 |
FOR_INV_PREPARE(ob, tmp) |
| 36 |
SET_FLAG(tmp, FLAG_NO_DROP); |
| 37 |
FOR_INV_FINISH(); |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
object *pets_get_enemy(object *pet, rv_vector *rv) { |
| 55 |
object *owner, *tmp, *attacker, *tmp3; |
| 56 |
int i; |
| 57 |
int16_t x, y; |
| 58 |
mapstruct *nm; |
| 59 |
int search_arr[SIZEOFFREE]; |
| 60 |
int mflags; |
| 61 |
|
| 62 |
attacker = pet->attacked_by; |
| 63 |
pet->attacked_by = NULL; |
| 64 |
|
| 65 |
owner = object_get_owner(pet); |
| 66 |
if (owner != NULL) { |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
if (monster_check_enemy(owner, rv) == pet) { |
| 71 |
CLEAR_FLAG(pet, FLAG_FRIENDLY); |
| 72 |
remove_friendly_object(pet); |
| 73 |
pet->attack_movement &= ~PETMOVE; |
| 74 |
return owner; |
| 75 |
} |
| 76 |
} else { |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
CLEAR_FLAG(pet, FLAG_FRIENDLY); |
| 81 |
remove_friendly_object(pet); |
| 82 |
pet->attack_movement &= ~PETMOVE; |
| 83 |
return NULL; |
| 84 |
} |
| 85 |
|
| 86 |
if (!on_same_map(pet, owner)) |
| 87 |
return NULL; |
| 88 |
|
| 89 |
|
| 90 |
tmp = monster_check_enemy(pet, rv); |
| 91 |
if (tmp != NULL) { |
| 92 |
if (tmp != owner || QUERY_FLAG(pet, FLAG_CONFUSED) || !QUERY_FLAG(pet, FLAG_FRIENDLY)) |
| 93 |
return tmp; |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
object_set_enemy(pet, NULL); |
| 99 |
} |
| 100 |
get_search_arr(search_arr); |
| 101 |
|
| 102 |
if (owner->type == PLAYER && owner->contr->petmode == pet_sad) { |
| 103 |
tmp = monster_find_nearest_living_creature(pet); |
| 104 |
if (tmp != NULL && get_rangevector(pet, tmp, rv, 0) && monster_check_enemy(pet, rv) != NULL) |
| 105 |
return tmp; |
| 106 |
|
| 107 |
|
| 108 |
object_set_enemy(pet, NULL); |
| 109 |
return NULL; |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
tmp3 = NULL; |
| 116 |
for (i = 0; i < SIZEOFFREE; i++) { |
| 117 |
x = owner->x+freearr_x[search_arr[i]]; |
| 118 |
y = owner->y+freearr_y[search_arr[i]]; |
| 119 |
nm = owner->map; |
| 120 |
|
| 121 |
mflags = get_map_flags(nm, &nm, x, y, &x, &y); |
| 122 |
if (!(mflags&P_OUT_OF_MAP) && mflags&P_IS_ALIVE) { |
| 123 |
FOR_MAP_PREPARE(nm, x, y, tmp) { |
| 124 |
object *tmp2 = HEAD(tmp); |
| 125 |
|
| 126 |
if (QUERY_FLAG(tmp2, FLAG_ALIVE) |
| 127 |
&& ((!QUERY_FLAG(tmp2, FLAG_FRIENDLY) && tmp2->type != PLAYER) || pets_should_arena_attack(pet, owner, tmp2)) |
| 128 |
&& !QUERY_FLAG(tmp2, FLAG_UNAGGRESSIVE) |
| 129 |
&& tmp2 != pet |
| 130 |
&& tmp2 != owner |
| 131 |
&& monster_can_detect_enemy(pet, tmp2, rv)) { |
| 132 |
if (!monster_can_see_enemy(pet, tmp2)) { |
| 133 |
if (tmp3 == NULL) |
| 134 |
tmp3 = tmp2; |
| 135 |
} else { |
| 136 |
object_set_enemy(pet, tmp2); |
| 137 |
if (monster_check_enemy(pet, rv) != NULL) |
| 138 |
return tmp2; |
| 139 |
object_set_enemy(pet, NULL); |
| 140 |
} |
| 141 |
} |
| 142 |
} FOR_MAP_FINISH(); |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
if (tmp3 != NULL) { |
| 149 |
object_set_enemy(pet, tmp3); |
| 150 |
if (monster_check_enemy(pet, rv) != NULL) |
| 151 |
return tmp3; |
| 152 |
object_set_enemy(pet, NULL); |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
if (attacker != NULL) { |
| 157 |
|
| 158 |
if (attacker->count == pet->attacked_by_count) { |
| 159 |
|
| 160 |
|
| 161 |
if (!QUERY_FLAG(attacker, FLAG_FRIENDLY) && on_same_map(pet, attacker)) { |
| 162 |
object_set_enemy(pet, attacker); |
| 163 |
if (monster_check_enemy(pet, rv) != NULL) |
| 164 |
return attacker; |
| 165 |
object_set_enemy(pet, NULL); |
| 166 |
} |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
if (owner->type == PLAYER && owner->contr->petmode != pet_defend) { |
| 176 |
tmp3 = NULL; |
| 177 |
for (i = 0; i < SIZEOFFREE; i++) { |
| 178 |
x = pet->x+freearr_x[search_arr[i]]; |
| 179 |
y = pet->y+freearr_y[search_arr[i]]; |
| 180 |
nm = pet->map; |
| 181 |
|
| 182 |
mflags = get_map_flags(nm, &nm, x, y, &x, &y); |
| 183 |
if (!(mflags&P_OUT_OF_MAP) && mflags&P_IS_ALIVE) { |
| 184 |
FOR_MAP_PREPARE(nm, x, y, tmp) { |
| 185 |
object *tmp2 = HEAD(tmp); |
| 186 |
if (QUERY_FLAG(tmp2, FLAG_ALIVE) |
| 187 |
&& ((!QUERY_FLAG(tmp2, FLAG_FRIENDLY) && tmp2->type != PLAYER) || pets_should_arena_attack(pet, owner, tmp2)) |
| 188 |
&& !QUERY_FLAG(tmp2, FLAG_UNAGGRESSIVE) |
| 189 |
&& tmp2 != pet |
| 190 |
&& tmp2 != owner |
| 191 |
&& monster_can_detect_enemy(pet, tmp2, rv)) { |
| 192 |
if (!monster_can_see_enemy(pet, tmp2)) { |
| 193 |
assert(tmp3 == NULL); |
| 194 |
} else { |
| 195 |
object_set_enemy(pet, tmp2); |
| 196 |
if (monster_check_enemy(pet, rv) != NULL) |
| 197 |
return tmp2; |
| 198 |
object_set_enemy(pet, NULL); |
| 199 |
} |
| 200 |
} |
| 201 |
} FOR_MAP_FINISH(); |
| 202 |
} |
| 203 |
} |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
if (tmp3 != NULL) { |
| 209 |
object_set_enemy(pet, tmp3); |
| 210 |
if (monster_check_enemy(pet, rv) != NULL) |
| 211 |
return tmp3; |
| 212 |
object_set_enemy(pet, NULL); |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
return monster_check_enemy(pet, rv); |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
void pets_terminate_all(object *owner) { |
| 226 |
objectlink *obl, *next; |
| 227 |
|
| 228 |
for (obl = first_friendly_object; obl != NULL; obl = next) { |
| 229 |
object *ob = obl->ob; |
| 230 |
next = obl->next; |
| 231 |
if (object_get_owner(ob) == owner) { |
| 232 |
if (!QUERY_FLAG(ob, FLAG_REMOVED)) |
| 233 |
object_remove(ob); |
| 234 |
remove_friendly_object(ob); |
| 235 |
object_free_drop_inventory(ob); |
| 236 |
} |
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
void pets_remove_all(void) { |
| 249 |
objectlink *obl, *next; |
| 250 |
object *owner; |
| 251 |
|
| 252 |
for (obl = first_friendly_object; obl != NULL; obl = next) { |
| 253 |
next = obl->next; |
| 254 |
if (obl->ob->type != PLAYER |
| 255 |
&& QUERY_FLAG(obl->ob, FLAG_FRIENDLY) |
| 256 |
&& (owner = object_get_owner(obl->ob)) != NULL |
| 257 |
&& !on_same_map(owner, obl->ob)) { |
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
pets_follow_owner(obl->ob, owner); |
| 262 |
if (obl->ob && QUERY_FLAG(obl->ob, FLAG_REMOVED) && FABS(obl->ob->speed) > MIN_ACTIVE_SPEED) { |
| 263 |
object *ob = obl->ob; |
| 264 |
|
| 265 |
LOG(llevMonster, "(pet failed to follow)\n"); |
| 266 |
remove_friendly_object(ob); |
| 267 |
object_free_drop_inventory(ob); |
| 268 |
} |
| 269 |
} |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
void pets_follow_owner(object *ob, object *owner) { |
| 282 |
int dir; |
| 283 |
|
| 284 |
if (!QUERY_FLAG(ob, FLAG_REMOVED)) |
| 285 |
object_remove(ob); |
| 286 |
|
| 287 |
if (owner->map == NULL) { |
| 288 |
LOG(llevError, "Can't follow owner: no map.\n"); |
| 289 |
return; |
| 290 |
} |
| 291 |
if (owner->map->in_memory != MAP_IN_MEMORY) { |
| 292 |
LOG(llevError, "Owner of the pet not on a map in memory!?\n"); |
| 293 |
return; |
| 294 |
} |
| 295 |
dir = object_find_free_spot(ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE); |
| 296 |
|
| 297 |
if (dir == -1) { |
| 298 |
LOG(llevMonster, "No space for pet to follow, freeing %s.\n", ob->name); |
| 299 |
return; |
| 300 |
} |
| 301 |
object_insert_in_map_at(ob, owner->map, NULL, 0, owner->x+freearr_x[dir], owner->y+freearr_y[dir]); |
| 302 |
if (owner->type == PLAYER) |
| 303 |
draw_ext_info(NDI_UNIQUE, 0, owner, MSG_TYPE_SPELL, MSG_TYPE_SPELL_PET, |
| 304 |
"Your pet magically appears next to you"); |
| 305 |
return; |
| 306 |
} |
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
void pets_move(object *ob) { |
| 315 |
int dir, i; |
| 316 |
tag_t tag; |
| 317 |
int16_t dx, dy; |
| 318 |
object *owner; |
| 319 |
mapstruct *m; |
| 320 |
|
| 321 |
|
| 322 |
owner = object_get_owner(ob); |
| 323 |
if (owner == NULL) { |
| 324 |
object_remove(ob); |
| 325 |
remove_friendly_object(ob); |
| 326 |
object_free_drop_inventory(ob); |
| 327 |
LOG(llevMonster, "Pet: no owner, leaving.\n"); |
| 328 |
return; |
| 329 |
} |
| 330 |
|
| 331 |
|
| 332 |
if (!on_same_map(ob, owner)) { |
| 333 |
pets_follow_owner(ob, owner); |
| 334 |
return; |
| 335 |
} |
| 336 |
|
| 337 |
if (owner->type == PLAYER && owner->contr->petmode == pet_sad) { |
| 338 |
|
| 339 |
for (i = 0; i < 15; i++) { |
| 340 |
dir = get_random_dir(); |
| 341 |
dx = ob->x+freearr_x[dir]; |
| 342 |
dy = ob->y+freearr_y[dir]; |
| 343 |
m = ob->map; |
| 344 |
if (!(get_map_flags(ob->map, &m, dx, dy, &dx, &dy)&P_OUT_OF_MAP) |
| 345 |
&& !OB_TYPE_MOVE_BLOCK(ob, GET_MAP_MOVE_BLOCK(m, dx, dy))) |
| 346 |
break; |
| 347 |
} |
| 348 |
} else { |
| 349 |
rv_vector rv; |
| 350 |
|
| 351 |
if (get_rangevector(ob, owner, &rv, 0)) |
| 352 |
dir = rv.direction; |
| 353 |
else |
| 354 |
dir = get_random_dir(); |
| 355 |
} |
| 356 |
ob->direction = dir; |
| 357 |
|
| 358 |
tag = ob->count; |
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
if (!move_ob(ob, dir, ob)) { |
| 363 |
object *part; |
| 364 |
|
| 365 |
|
| 366 |
if (object_was_destroyed(ob, tag)) |
| 367 |
return; |
| 368 |
|
| 369 |
for (part = ob; part != NULL; part = part->more) { |
| 370 |
dx = part->x+freearr_x[dir]; |
| 371 |
dy = part->y+freearr_y[dir]; |
| 372 |
m = get_map_from_coord(part->map, &dx, &dy); |
| 373 |
if (m == NULL) |
| 374 |
continue; |
| 375 |
|
| 376 |
FOR_MAP_PREPARE(m, dx, dy, ob2) { |
| 377 |
object *new_ob; |
| 378 |
|
| 379 |
new_ob = HEAD(ob2); |
| 380 |
if (new_ob == ob) |
| 381 |
break; |
| 382 |
if (new_ob == owner) |
| 383 |
return; |
| 384 |
if (object_get_owner(new_ob) == owner) |
| 385 |
break; |
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
if (QUERY_FLAG(new_ob, FLAG_ALIVE) |
| 391 |
&& !QUERY_FLAG(ob, FLAG_UNAGGRESSIVE) |
| 392 |
&& !QUERY_FLAG(new_ob, FLAG_UNAGGRESSIVE) |
| 393 |
&& !QUERY_FLAG(new_ob, FLAG_FRIENDLY)) { |
| 394 |
object_set_enemy(ob, new_ob); |
| 395 |
if (new_ob->enemy == NULL) |
| 396 |
object_set_enemy(new_ob, ob); |
| 397 |
return; |
| 398 |
} else if (new_ob->type == PLAYER) { |
| 399 |
draw_ext_info(NDI_UNIQUE, 0, new_ob, |
| 400 |
MSG_TYPE_MISC, MSG_SUBTYPE_NONE, |
| 401 |
"You stand in the way of someones pet."); |
| 402 |
return; |
| 403 |
} |
| 404 |
} FOR_MAP_FINISH(); |
| 405 |
} |
| 406 |
|
| 407 |
dir = absdir(dir+4-(RANDOM()%5)-(RANDOM()%5)); |
| 408 |
(void)move_ob(ob, dir, ob); |
| 409 |
} |
| 410 |
return; |
| 411 |
} |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
static object *fix_summon_pet(archetype *at, object *op, int dir) { |
| 432 |
archetype *atmp; |
| 433 |
object *tmp = NULL, *prev = NULL, *head = NULL; |
| 434 |
|
| 435 |
for (atmp = at; atmp != NULL; atmp = atmp->more) { |
| 436 |
tmp = arch_to_object(atmp); |
| 437 |
if (atmp == at) { |
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
if (tmp->move_type == 0) { |
| 442 |
LOG(llevError, "summoned %s [%s] is without move_type!\n", tmp->name, atmp->name); |
| 443 |
tmp->move_type = MOVE_WALK; |
| 444 |
} |
| 445 |
|
| 446 |
object_set_owner(tmp, op); |
| 447 |
if (op->type == PLAYER) { |
| 448 |
tmp->stats.exp = 0; |
| 449 |
add_friendly_object(tmp); |
| 450 |
SET_FLAG(tmp, FLAG_FRIENDLY); |
| 451 |
CLEAR_FLAG(tmp, FLAG_MONSTER); |
| 452 |
} else if (QUERY_FLAG(op, FLAG_FRIENDLY)) { |
| 453 |
object *owner = object_get_owner(op); |
| 454 |
|
| 455 |
if (owner != NULL) { |
| 456 |
object_set_owner(tmp, owner); |
| 457 |
tmp->attack_movement = PETMOVE; |
| 458 |
add_friendly_object(tmp); |
| 459 |
SET_FLAG(tmp, FLAG_FRIENDLY); |
| 460 |
} |
| 461 |
} |
| 462 |
if (op->type != PLAYER) { |
| 463 |
tmp->attack_movement = PETMOVE; |
| 464 |
tmp->speed_left = -1; |
| 465 |
tmp->type = 0; |
| 466 |
object_set_enemy(tmp, op->enemy); |
| 467 |
} else |
| 468 |
tmp->type = GOLEM; |
| 469 |
} |
| 470 |
if (head == NULL) |
| 471 |
head = tmp; |
| 472 |
tmp->x = op->x+freearr_x[dir]+tmp->arch->clone.x; |
| 473 |
tmp->y = op->y+freearr_y[dir]+tmp->arch->clone.y; |
| 474 |
tmp->map = op->map; |
| 475 |
if (tmp->invisible) |
| 476 |
tmp->invisible = 0; |
| 477 |
if (head != tmp) |
| 478 |
tmp->head = head, |
| 479 |
prev->more = tmp; |
| 480 |
prev = tmp; |
| 481 |
} |
| 482 |
head->direction = dir; |
| 483 |
|
| 484 |
if (head->randomitems) { |
| 485 |
create_treasure(head->randomitems, head, GT_STARTEQUIP, 6, 0); |
| 486 |
if (QUERY_FLAG(head, FLAG_MONSTER)) { |
| 487 |
monster_check_apply_all(head); |
| 488 |
} |
| 489 |
} |
| 490 |
mark_inventory_as_no_drop(head); |
| 491 |
|
| 492 |
|
| 493 |
head->last_heal = 0; |
| 494 |
head->last_eat = 0; |
| 495 |
head->last_grace = 0; |
| 496 |
head->last_sp = 0; |
| 497 |
head->other_arch = NULL; |
| 498 |
head->stats.exp = 0; |
| 499 |
CLEAR_FLAG(head, FLAG_CHANGING); |
| 500 |
CLEAR_FLAG(head, FLAG_STAND_STILL); |
| 501 |
CLEAR_FLAG(head, FLAG_GENERATOR); |
| 502 |
CLEAR_FLAG(head, FLAG_SPLITTING); |
| 503 |
if (head->attacktype&AT_GHOSTHIT) |
| 504 |
head->attacktype = (AT_PHYSICAL|AT_DRAIN); |
| 505 |
|
| 506 |
return head; |
| 507 |
} |
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
void pets_move_golem(object *op) { |
| 517 |
int made_attack = 0; |
| 518 |
object *tmp; |
| 519 |
tag_t tag; |
| 520 |
object *owner; |
| 521 |
|
| 522 |
if (QUERY_FLAG(op, FLAG_MONSTER)) |
| 523 |
return; |
| 524 |
|
| 525 |
owner = object_get_owner(op); |
| 526 |
if (owner == NULL) { |
| 527 |
LOG(llevDebug, "Golem without owner destructed.\n"); |
| 528 |
object_remove(op); |
| 529 |
object_free_drop_inventory(op); |
| 530 |
return; |
| 531 |
} |
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
if (--op->stats.hp < 0) { |
| 538 |
if (op->msg != NULL) |
| 539 |
draw_ext_info(NDI_UNIQUE, 0, owner, MSG_TYPE_SPELL, MSG_TYPE_SPELL_PET, |
| 540 |
op->msg); |
| 541 |
owner->contr->ranges[range_golem] = NULL; |
| 542 |
owner->contr->golem_count = 0; |
| 543 |
remove_friendly_object(op); |
| 544 |
object_remove(op); |
| 545 |
object_free_drop_inventory(op); |
| 546 |
return; |
| 547 |
} |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
tag = op->count; |
| 555 |
if (move_ob(op, op->direction, op)) |
| 556 |
return; |
| 557 |
if (object_was_destroyed(op, tag)) |
| 558 |
return; |
| 559 |
|
| 560 |
for (tmp = op; tmp; tmp = tmp->more) { |
| 561 |
int16_t x = tmp->x+DIRX(op), y = tmp->y+DIRY(op); |
| 562 |
object *victim; |
| 563 |
mapstruct *m; |
| 564 |
int mflags; |
| 565 |
|
| 566 |
m = op->map; |
| 567 |
mflags = get_map_flags(m, &m, x, y, &x, &y); |
| 568 |
|
| 569 |
if (mflags&P_OUT_OF_MAP) |
| 570 |
continue; |
| 571 |
|
| 572 |
victim = NULL; |
| 573 |
FOR_MAP_PREPARE(op->map, x, y, tmp) |
| 574 |
if (QUERY_FLAG(tmp, FLAG_ALIVE)) { |
| 575 |
victim = tmp; |
| 576 |
break; |
| 577 |
} |
| 578 |
FOR_MAP_FINISH(); |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
if (victim != NULL && victim != op && victim->head != op) { |
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
if (victim->race != NULL && op->race != NULL && strstr(op->race, victim->race)) { |
| 593 |
if (owner != NULL) |
| 594 |
draw_ext_info_format(NDI_UNIQUE, 0, owner, |
| 595 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_PET, |
| 596 |
"%s avoids damaging %s.", |
| 597 |
op->name, victim->name); |
| 598 |
} else if (victim == owner) { |
| 599 |
if (owner != NULL) |
| 600 |
draw_ext_info_format(NDI_UNIQUE, 0, owner, |
| 601 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_PET, |
| 602 |
"%s avoids damaging you.", |
| 603 |
op->name); |
| 604 |
} else { |
| 605 |
attack_ob(victim, op); |
| 606 |
made_attack = 1; |
| 607 |
} |
| 608 |
} |
| 609 |
} |
| 610 |
if (made_attack) |
| 611 |
object_update(op, UP_OBJ_FACE); |
| 612 |
} |
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
void pets_control_golem(object *op, int dir) { |
| 628 |
op->direction = dir; |
| 629 |
} |
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
int pets_summon_golem(object *op, object *caster, int dir, object *spob) { |
| 649 |
object *tmp; |
| 650 |
const object *god = NULL; |
| 651 |
archetype *at; |
| 652 |
char buf[MAX_BUF]; |
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
if (op->type == PLAYER |
| 658 |
&& op->contr->ranges[range_golem] != NULL |
| 659 |
&& op->contr->golem_count == op->contr->ranges[range_golem]->count) { |
| 660 |
draw_ext_info(NDI_UNIQUE, 0, op, |
| 661 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_PET, |
| 662 |
"You dismiss your existing golem."); |
| 663 |
object_remove(op->contr->ranges[range_golem]); |
| 664 |
object_free_drop_inventory(op->contr->ranges[range_golem]); |
| 665 |
op->contr->ranges[range_golem] = NULL; |
| 666 |
op->contr->golem_count = -1; |
| 667 |
} |
| 668 |
|
| 669 |
if (spob->other_arch != NULL) |
| 670 |
at = spob->other_arch; |
| 671 |
else if (spob->race != NULL) { |
| 672 |
god = find_god(determine_god(caster)); |
| 673 |
if (god == NULL) { |
| 674 |
draw_ext_info_format(NDI_UNIQUE, 0, op, |
| 675 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 676 |
"You must worship a god to cast %s.", |
| 677 |
spob->name); |
| 678 |
return 0; |
| 679 |
} |
| 680 |
|
| 681 |
at = determine_holy_arch(god, spob->race); |
| 682 |
if (at == NULL) { |
| 683 |
draw_ext_info_format(NDI_UNIQUE, 0, op, |
| 684 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 685 |
"%s has no %s for you to call.", |
| 686 |
god->name, spob->race); |
| 687 |
return 0; |
| 688 |
} |
| 689 |
} else { |
| 690 |
LOG(llevError, "Spell %s lacks other_arch\n", spob->name); |
| 691 |
return 0; |
| 692 |
} |
| 693 |
|
| 694 |
if (!dir) |
| 695 |
dir = object_find_free_spot(NULL, op->map, op->x, op->y, 1, SIZEOFFREE1+1); |
| 696 |
|
| 697 |
if (dir == -1 |
| 698 |
|| ob_blocked(&at->clone, op->map, op->x+freearr_x[dir], op->y+freearr_y[dir])) { |
| 699 |
draw_ext_info(NDI_UNIQUE, 0, op, |
| 700 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 701 |
"There is something in the way."); |
| 702 |
return 0; |
| 703 |
} |
| 704 |
|
| 705 |
tmp = fix_summon_pet(at, op, dir); |
| 706 |
if (tmp == NULL) { |
| 707 |
draw_ext_info(NDI_UNIQUE, 0, op, |
| 708 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 709 |
"Your spell fails."); |
| 710 |
return 0; |
| 711 |
} |
| 712 |
|
| 713 |
if (op->type == PLAYER) { |
| 714 |
tmp->type = GOLEM; |
| 715 |
object_set_owner(tmp, op); |
| 716 |
set_spell_skill(op, caster, spob, tmp); |
| 717 |
op->contr->ranges[range_golem] = tmp; |
| 718 |
op->contr->golem_count = tmp->count; |
| 719 |
|
| 720 |
op->contr->shoottype = range_golem; |
| 721 |
} else { |
| 722 |
if (QUERY_FLAG(op, FLAG_FRIENDLY)) { |
| 723 |
object *owner = object_get_owner(op); |
| 724 |
|
| 725 |
if (owner != NULL) { |
| 726 |
object_set_owner(tmp, owner); |
| 727 |
tmp->attack_movement = PETMOVE; |
| 728 |
add_friendly_object(tmp); |
| 729 |
set_spell_skill(op, caster, spob, tmp); |
| 730 |
SET_FLAG(tmp, FLAG_FRIENDLY); |
| 731 |
} |
| 732 |
} |
| 733 |
SET_FLAG(tmp, FLAG_MONSTER); |
| 734 |
} |
| 735 |
|
| 736 |
|
| 737 |
tmp->speed = FABS(tmp->speed); |
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
if (op->type == PLAYER) { |
| 743 |
tmp->stats.hp += spob->duration+SP_level_duration_adjust(caster, spob); |
| 744 |
tmp->stats.maxhp = tmp->stats.hp; |
| 745 |
if (!spob->stats.dam) |
| 746 |
tmp->stats.dam += SP_level_dam_adjust(caster, spob); |
| 747 |
else |
| 748 |
tmp->stats.dam = spob->stats.dam+SP_level_dam_adjust(caster, spob); |
| 749 |
tmp->speed += .02*SP_level_range_adjust(caster, spob); |
| 750 |
tmp->speed = MIN(tmp->speed, 1.0); |
| 751 |
if (spob->attacktype) |
| 752 |
tmp->attacktype = spob->attacktype; |
| 753 |
} |
| 754 |
tmp->stats.wc -= SP_level_wc_adjust(caster, spob); |
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
tmp->stats.exp *= 1+(MAX(spob->stats.maxgrace, spob->stats.sp)/caster_level(caster, spob)); |
| 763 |
tmp->speed_left = 0; |
| 764 |
tmp->direction = dir; |
| 765 |
|
| 766 |
|
| 767 |
if (god != NULL) { |
| 768 |
object *tmp2; |
| 769 |
|
| 770 |
snprintf(buf, sizeof(buf), "%s of %s", spob->name, god->name); |
| 771 |
buf[0] = toupper(buf[0]); |
| 772 |
for (tmp2 = tmp; tmp2; tmp2 = tmp2->more) { |
| 773 |
if (tmp2->name != NULL) |
| 774 |
free_string(tmp2->name); |
| 775 |
tmp2->name = add_string(buf); |
| 776 |
} |
| 777 |
tmp->attacktype |= god->attacktype; |
| 778 |
memcpy(tmp->resist, god->resist, sizeof(tmp->resist)); |
| 779 |
if (tmp->race != NULL) |
| 780 |
FREE_AND_CLEAR_STR(tmp->race); |
| 781 |
if (god->race != NULL) |
| 782 |
tmp->race = add_string(god->race); |
| 783 |
if (tmp->slaying != NULL) |
| 784 |
FREE_AND_CLEAR_STR(tmp->slaying); |
| 785 |
if (god->slaying != NULL) |
| 786 |
tmp->slaying = add_string(god->slaying); |
| 787 |
|
| 788 |
if (!(tmp->attacktype&AT_PHYSICAL)) |
| 789 |
tmp->attacktype |= AT_PHYSICAL; |
| 790 |
} |
| 791 |
|
| 792 |
object_insert_in_map_at(tmp, tmp->map, op, 0, tmp->x, tmp->y); |
| 793 |
return 1; |
| 794 |
} |
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
static object *choose_cult_monster(object *pl, const object *god, int summon_level) { |
| 817 |
char buf[MAX_BUF]; |
| 818 |
const char *race; |
| 819 |
int racenr, mon_nr, i; |
| 820 |
racelink *list; |
| 821 |
objectlink *tobl; |
| 822 |
object *otmp; |
| 823 |
|
| 824 |
|
| 825 |
racenr = 0; |
| 826 |
safe_strncpy(buf, god->race, sizeof(buf)); |
| 827 |
race = strtok(buf, ","); |
| 828 |
while (race) { |
| 829 |
racenr++; |
| 830 |
race = strtok(NULL, ","); |
| 831 |
} |
| 832 |
|
| 833 |
|
| 834 |
if (racenr > 1) { |
| 835 |
racenr = rndm(0, racenr-1); |
| 836 |
safe_strncpy(buf, god->race, sizeof(buf)); |
| 837 |
race = strtok(buf, ","); |
| 838 |
for (i = 0; i < racenr; i++) |
| 839 |
race = strtok(NULL, ","); |
| 840 |
} else |
| 841 |
race = god->race; |
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
list = find_racelink(race); |
| 850 |
if (list == NULL) { |
| 851 |
draw_ext_info_format(NDI_UNIQUE, 0, pl, |
| 852 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 853 |
"The spell fails! %s's creatures are beyond the range of your summons", |
| 854 |
god->name); |
| 855 |
LOG(llevDebug, "choose_cult_monster() requested non-existent aligned race!\n"); |
| 856 |
return NULL; |
| 857 |
} |
| 858 |
|
| 859 |
|
| 860 |
mon_nr = 0; |
| 861 |
for (tobl = list->member; tobl; tobl = tobl->next) { |
| 862 |
otmp = tobl->ob; |
| 863 |
if (otmp == NULL || !QUERY_FLAG(otmp, FLAG_MONSTER)) |
| 864 |
continue; |
| 865 |
if (otmp->level <= summon_level) |
| 866 |
mon_nr++; |
| 867 |
} |
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
if (!mon_nr) |
| 875 |
return NULL; |
| 876 |
|
| 877 |
mon_nr = rndm(0, mon_nr-1); |
| 878 |
for (tobl = list->member; tobl; tobl = tobl->next) { |
| 879 |
otmp = tobl->ob; |
| 880 |
if (otmp == NULL || !QUERY_FLAG(otmp, FLAG_MONSTER)) |
| 881 |
continue; |
| 882 |
if (otmp->level <= summon_level && !mon_nr--) |
| 883 |
return otmp; |
| 884 |
} |
| 885 |
|
| 886 |
LOG(llevDebug, "choose_cult_monster() mon_nr was set, but did not find a monster\n"); |
| 887 |
return NULL; |
| 888 |
} |
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
int pets_summon_object(object *op, object *caster, object *spell_ob, int dir, const char *stringarg) { |
| 909 |
int16_t x, y, nrof = 1, i; |
| 910 |
archetype *summon_arch; |
| 911 |
int ndir, mult; |
| 912 |
|
| 913 |
if (spell_ob->other_arch != NULL) { |
| 914 |
summon_arch = spell_ob->other_arch; |
| 915 |
} else if (spell_ob->randomitems != NULL) { |
| 916 |
int level = caster_level(caster, spell_ob); |
| 917 |
treasure *tr, *lasttr = NULL; |
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
for (tr = spell_ob->randomitems->items; tr; tr = tr->next) { |
| 924 |
if (level < tr->magic) |
| 925 |
break; |
| 926 |
lasttr = tr; |
| 927 |
if (stringarg != NULL && !strcmp(tr->item->name, stringarg)) |
| 928 |
break; |
| 929 |
if (tr->next == NULL || tr->next->item == NULL) |
| 930 |
break; |
| 931 |
} |
| 932 |
if (lasttr == NULL) { |
| 933 |
LOG(llevError, "Treasurelist %s did not generate a valid entry in pets_summon_object\n", spell_ob->randomitems->name); |
| 934 |
draw_ext_info(NDI_UNIQUE, 0, op, |
| 935 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 936 |
"The spell fails to summon any monsters."); |
| 937 |
return 0; |
| 938 |
} |
| 939 |
summon_arch = lasttr->item; |
| 940 |
nrof = lasttr->nrof; |
| 941 |
} else if (spell_ob->race != NULL && !strcmp(spell_ob->race, "GODCULTMON")) { |
| 942 |
const object *god = find_god(determine_god(op)); |
| 943 |
object *mon, *owner; |
| 944 |
int summon_level, tries; |
| 945 |
|
| 946 |
if (god == NULL) { |
| 947 |
owner = object_get_owner(op); |
| 948 |
if (owner != NULL) { |
| 949 |
god = find_god(determine_god(owner)); |
| 950 |
} |
| 951 |
} |
| 952 |
|
| 953 |
if (god == NULL) |
| 954 |
return 0; |
| 955 |
|
| 956 |
if (god->race == NULL) { |
| 957 |
draw_ext_info_format(NDI_UNIQUE, 0, op, |
| 958 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 959 |
"%s has no creatures that you may summon!", |
| 960 |
god->name); |
| 961 |
return 0; |
| 962 |
} |
| 963 |
|
| 964 |
summon_level = caster_level(caster, spell_ob); |
| 965 |
if (summon_level == 0) |
| 966 |
summon_level = 1; |
| 967 |
tries = 0; |
| 968 |
do { |
| 969 |
mon = choose_cult_monster(op, god, summon_level); |
| 970 |
if (mon == NULL) { |
| 971 |
draw_ext_info_format(NDI_UNIQUE, 0, op, |
| 972 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 973 |
"%s fails to send anything.", |
| 974 |
god->name); |
| 975 |
return 0; |
| 976 |
} |
| 977 |
ndir = dir; |
| 978 |
if (!ndir) |
| 979 |
ndir = object_find_free_spot(mon, op->map, op->x, op->y, 1, SIZEOFFREE); |
| 980 |
if (ndir == -1 |
| 981 |
|| ob_blocked(mon, op->map, op->x+freearr_x[ndir], op->y+freearr_y[ndir])) { |
| 982 |
ndir = -1; |
| 983 |
if (++tries == 5) { |
| 984 |
draw_ext_info(NDI_UNIQUE, 0, op, |
| 985 |
MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 986 |
"There is something in the way."); |
| 987 |
return 0; |
| 988 |
} |
| 989 |
} |
| 990 |
} while (ndir == -1); |
| 991 |
if (mon->level > summon_level/2) |
| 992 |
nrof = random_roll(1, 2, op, PREFER_HIGH); |
| 993 |
else |
| 994 |
nrof = die_roll(2, 2, op, PREFER_HIGH); |
| 995 |
summon_arch = mon->arch; |
| 996 |
} else { |
| 997 |
summon_arch = NULL; |
| 998 |
} |
| 999 |
|
| 1000 |
if (spell_ob->stats.dam) |
| 1001 |
nrof += spell_ob->stats.dam+SP_level_dam_adjust(caster, spell_ob); |
| 1002 |
|
| 1003 |
if (summon_arch == NULL) { |
| 1004 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 1005 |
"There is no monsters available for summoning."); |
| 1006 |
return 0; |
| 1007 |
} |
| 1008 |
|
| 1009 |
if (dir) { |
| 1010 |
|
| 1011 |
x = freearr_x[dir]; |
| 1012 |
y = freearr_y[dir]; |
| 1013 |
if (ob_blocked(&summon_arch->clone, op->map, op->x+x, op->y+y)) { |
| 1014 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, |
| 1015 |
"There is something in the way."); |
| 1016 |
return 0; |
| 1017 |
} |
| 1018 |
} |
| 1019 |
|
| 1020 |
mult = (RANDOM()%2 ? -1 : 1); |
| 1021 |
|
| 1022 |
for (i = 1; i <= nrof; i++) { |
| 1023 |
archetype *atmp; |
| 1024 |
object *prev = NULL, *head = NULL, *tmp; |
| 1025 |
|
| 1026 |
if (dir) { |
| 1027 |
ndir = absdir(dir+(i/2)*mult); |
| 1028 |
mult = -mult; |
| 1029 |
} else |
| 1030 |
ndir = object_find_free_spot(&summon_arch->clone, op->map, op->x, op->y, 1, SIZEOFFREE); |
| 1031 |
|
| 1032 |
x = ndir > 0 ? freearr_x[ndir] : 0; |
| 1033 |
y = ndir > 0 ? freearr_y[ndir] : 0; |
| 1034 |
if (ndir == -1 || ob_blocked(&summon_arch->clone, op->map, op->x+x, op->y+y)) |
| 1035 |
continue; |
| 1036 |
|
| 1037 |
for (atmp = summon_arch; atmp != NULL; atmp = atmp->more) { |
| 1038 |
tmp = arch_to_object(atmp); |
| 1039 |
if (atmp == summon_arch) { |
| 1040 |
if (QUERY_FLAG(tmp, FLAG_MONSTER)) { |
| 1041 |
object_set_owner(tmp, op); |
| 1042 |
set_spell_skill(op, caster, spell_ob, tmp); |
| 1043 |
object_set_enemy(tmp, op->enemy); |
| 1044 |
tmp->type = 0; |
| 1045 |
CLEAR_FLAG(tmp, FLAG_SLEEP); |
| 1046 |
if (op->type == PLAYER || QUERY_FLAG(op, FLAG_FRIENDLY)) { |
| 1047 |
|
| 1048 |
if (!QUERY_FLAG(spell_ob, FLAG_MONSTER)) { |
| 1049 |
SET_FLAG(tmp, FLAG_FRIENDLY); |
| 1050 |
add_friendly_object(tmp); |
| 1051 |
tmp->stats.exp = 0; |
| 1052 |
if (spell_ob->attack_movement) |
| 1053 |
tmp->attack_movement = spell_ob->attack_movement; |
| 1054 |
if (object_get_owner(op) != NULL) |
| 1055 |
object_set_owner(tmp, object_get_owner(op)); |
| 1056 |
} |
| 1057 |
} |
| 1058 |
} |
| 1059 |
if (tmp->speed > MIN_ACTIVE_SPEED) |
| 1060 |
tmp->speed_left = -1; |
| 1061 |
} |
| 1062 |
if (head == NULL) |
| 1063 |
head = tmp; |
| 1064 |
else { |
| 1065 |
tmp->head = head; |
| 1066 |
prev->more = tmp; |
| 1067 |
} |
| 1068 |
prev = tmp; |
| 1069 |
} |
| 1070 |
head->direction = freedir[ndir]; |
| 1071 |
head->stats.exp = 0; |
| 1072 |
head = object_insert_in_map_at(head, op->map, op, 0, op->x+x, op->y+y); |
| 1073 |
if (head != NULL && head->randomitems) { |
| 1074 |
create_treasure(head->randomitems, head, GT_STARTEQUIP, 6, 0); |
| 1075 |
if (QUERY_FLAG(head, FLAG_MONSTER)) { |
| 1076 |
monster_check_apply_all(head); |
| 1077 |
} |
| 1078 |
} |
| 1079 |
if (head != NULL) { |
| 1080 |
mark_inventory_as_no_drop(head); |
| 1081 |
} |
| 1082 |
} |
| 1083 |
return 1; |
| 1084 |
} |
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
static object *get_real_owner(object *ob) { |
| 1096 |
object *realowner = ob; |
| 1097 |
|
| 1098 |
if (realowner == NULL) |
| 1099 |
return NULL; |
| 1100 |
|
| 1101 |
while (object_get_owner(realowner) != NULL) { |
| 1102 |
realowner = object_get_owner(realowner); |
| 1103 |
} |
| 1104 |
return realowner; |
| 1105 |
} |
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
int pets_should_arena_attack(object *pet, object *owner, object *target) { |
| 1123 |
object *rowner, *towner; |
| 1124 |
|
| 1125 |
|
| 1126 |
if (target == NULL || pet == NULL || owner == NULL) |
| 1127 |
return 0; |
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
rowner = get_real_owner(owner); |
| 1132 |
if (target->type != PLAYER) { |
| 1133 |
towner = get_real_owner(target); |
| 1134 |
} else { |
| 1135 |
towner = NULL; |
| 1136 |
} |
| 1137 |
|
| 1138 |
|
| 1139 |
if (rowner == NULL) { |
| 1140 |
LOG(llevError, "Pet has no owner.\n"); |
| 1141 |
return 0; |
| 1142 |
} |
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
if (towner == NULL && target->type != PLAYER) { |
| 1147 |
LOG(llevError, "Target is not a player but has no owner. We should not be here.\n"); |
| 1148 |
return 0; |
| 1149 |
} |
| 1150 |
|
| 1151 |
|
| 1152 |
if (rowner->type != PLAYER) |
| 1153 |
return 0; |
| 1154 |
|
| 1155 |
|
| 1156 |
if (rowner->contr->petmode != pet_arena) |
| 1157 |
return 0; |
| 1158 |
|
| 1159 |
|
| 1160 |
if (!(op_on_battleground(pet, NULL, NULL, NULL) |
| 1161 |
&& op_on_battleground(owner, NULL, NULL, NULL) |
| 1162 |
&& op_on_battleground(target, NULL, NULL, NULL))) |
| 1163 |
return 0; |
| 1164 |
|
| 1165 |
|
| 1166 |
if (target->type != PLAYER && rowner == towner) |
| 1167 |
return 0; |
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
if (target->type != PLAYER) { |
| 1172 |
|
| 1173 |
|
| 1174 |
if (towner->type == PLAYER && rowner->contr->party != NULL) { |
| 1175 |
if (rowner->contr->party == towner->contr->party) |
| 1176 |
return 0; |
| 1177 |
} |
| 1178 |
} else { |
| 1179 |
|
| 1180 |
|
| 1181 |
if (rowner->contr->party != NULL) { |
| 1182 |
if (rowner->contr->party == target->contr->party) |
| 1183 |
return 0; |
| 1184 |
} |
| 1185 |
} |
| 1186 |
|
| 1187 |
return 1; |
| 1188 |
} |