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.9 by root, Thu Sep 14 22:34:04 2006 UTC vs.
Revision 1.14 by root, Tue Dec 12 21:39:57 2006 UTC

37get_pet_enemy (object *pet, rv_vector * rv) 37get_pet_enemy (object *pet, rv_vector * rv)
38{ 38{
39 object *owner, *tmp, *attacker, *tmp3; 39 object *owner, *tmp, *attacker, *tmp3;
40 int i; 40 int i;
41 sint16 x, y; 41 sint16 x, y;
42 mapstruct *nm; 42 maptile *nm;
43 int search_arr[SIZEOFFREE]; 43 int search_arr[SIZEOFFREE];
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 */
246 246
247 next = obl->next; 247 next = obl->next;
248 if (get_owner (ob) == owner) 248 if (get_owner (ob) == owner)
249 { 249 {
250 if (!QUERY_FLAG (ob, FLAG_REMOVED)) 250 if (!QUERY_FLAG (ob, FLAG_REMOVED))
251 remove_ob (ob); 251 ob->remove ();
252 remove_friendly_object (ob); 252 remove_friendly_object (ob);
253 free_object (ob); 253 ob->destroy ();
254 } 254 }
255 } 255 }
256} 256}
257 257
258/* 258/*
263 * Interesting enough, we don't use the passed map structure in 263 * Interesting enough, we don't use the passed map structure in
264 * this function. 264 * this function.
265 */ 265 */
266 266
267void 267void
268remove_all_pets (mapstruct *map) 268remove_all_pets (maptile *map)
269{ 269{
270 objectlink *obl, *next; 270 objectlink *obl, *next;
271 object *owner; 271 object *owner;
272 272
273 for (obl = first_friendly_object; obl != NULL; obl = next) 273 for (obl = first_friendly_object; obl != NULL; obl = next)
287{ 287{
288 object *tmp; 288 object *tmp;
289 int dir; 289 int dir;
290 290
291 if (!QUERY_FLAG (ob, FLAG_REMOVED)) 291 if (!QUERY_FLAG (ob, FLAG_REMOVED))
292 remove_ob (ob); 292 ob->remove ();
293 293
294 if (owner->map == NULL) 294 if (owner->map == NULL)
295 { 295 {
296 LOG (llevError, "Can't follow owner (%d): no map.\n", &owner->name); 296 LOG (llevError, "Can't follow owner (%d): no map.\n", &owner->name);
297 goto fail; 297 goto fail;
325 325
326 return 0; 326 return 0;
327 327
328fail: 328fail:
329 remove_friendly_object (ob); 329 remove_friendly_object (ob);
330 free_object (ob); 330 ob->destroy ();
331 331
332 return 1; 332 return 1;
333} 333}
334 334
335void 335void
336pet_move (object *ob) 336pet_move (object *ob)
337{ 337{
338 int dir, tag, i; 338 int dir, i;
339 sint16 dx, dy; 339 sint16 dx, dy;
340 object *ob2, *owner; 340 object *ob2, *owner;
341 mapstruct *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 = get_owner (ob)) == NULL)
345 { 345 {
346 remove_ob (ob); /* Will be freed when returning */ 346 ob->remove (); /* Will be freed when returning */
347 remove_friendly_object (ob); 347 remove_friendly_object (ob);
348 free_object (ob); 348 ob->destroy ();
349 LOG (llevMonster, "Pet: no owner, leaving.\n"); 349 LOG (llevMonster, "Pet: no owner, leaving.\n");
350 return; 350 return;
351 } 351 }
352 352
353 /* move monster into the owners map if not in the same map */ 353 /* move monster into the owners map if not in the same map */
381 get_rangevector (ob, ob->owner, &rv, 0); 381 get_rangevector (ob, ob->owner, &rv, 0);
382 dir = rv.direction; 382 dir = rv.direction;
383 } 383 }
384 ob->direction = dir; 384 ob->direction = dir;
385 385
386 tag = ob->count;
387 /* move_ob returns 0 if the object couldn't move. If that is the 386 /* move_ob returns 0 if the object couldn't move. If that is the
388 * case, lets do some other work. 387 * case, lets do some other work.
389 */ 388 */
390 if (!(move_ob (ob, dir, ob))) 389 if (!(move_ob (ob, dir, ob)))
391 { 390 {
392 object *part; 391 object *part;
393 392
394 /* the failed move_ob above may destroy the pet, so check here */ 393 /* the failed move_ob above may destroy the pet, so check here */
395 if (was_destroyed (ob, tag)) 394 if (ob->destroyed ())
396 return; 395 return;
397 396
398 for (part = ob; part != NULL; part = part->more) 397 for (part = ob; part != NULL; part = part->more)
399 { 398 {
400 dx = part->x + freearr_x[dir]; 399 dx = part->x + freearr_x[dir];
538void 537void
539move_golem (object *op) 538move_golem (object *op)
540{ 539{
541 int made_attack = 0; 540 int made_attack = 0;
542 object *tmp; 541 object *tmp;
543 tag_t tag;
544 542
545 if (QUERY_FLAG (op, FLAG_MONSTER)) 543 if (QUERY_FLAG (op, FLAG_MONSTER))
546 return; /* Has already been moved */ 544 return; /* Has already been moved */
547 545
548 if (get_owner (op) == NULL) 546 if (get_owner (op) == NULL)
549 { 547 {
550 LOG (llevDebug, "Golem without owner destructed.\n"); 548 LOG (llevDebug, "Golem without owner destructed.\n");
551 remove_ob (op); 549 op->remove ();
552 free_object (op); 550 op->destroy ();
553 return; 551 return;
554 } 552 }
553
555 /* It would be nice to have a cleaner way of what message to print 554 /* It would be nice to have a cleaner way of what message to print
556 * when the golem expires than these hard coded entries. 555 * when the golem expires than these hard coded entries.
557 * Note it is intentional that a golems duration is based on its 556 * Note it is intentional that a golems duration is based on its
558 * hp, and not duration 557 * hp, and not duration
559 */ 558 */
560 if (--op->stats.hp < 0) 559 if (--op->stats.hp < 0)
561 { 560 {
562 if (op->msg) 561 if (op->msg)
563 new_draw_info (NDI_UNIQUE, 0, op->owner, op->msg); 562 new_draw_info (NDI_UNIQUE, 0, op->owner, op->msg);
563
564 op->owner->contr->ranges[range_golem] = NULL; 564 op->owner->contr->ranges[range_golem] = 0;
565 op->owner->contr->golem_count = 0;
566 remove_friendly_object (op); 565 remove_friendly_object (op);
567 remove_ob (op); 566 op->remove ();
568 free_object (op); 567 op->destroy ();
569 return; 568 return;
570 } 569 }
571 570
572 /* Do golem attacks/movement for single & multisq golems. 571 /* Do golem attacks/movement for single & multisq golems.
573 * Assuming here that op is the 'head' object. Pass only op to 572 * Assuming here that op is the 'head' object. Pass only op to
574 * move_ob (makes recursive calls to other parts) 573 * move_ob (makes recursive calls to other parts)
575 * move_ob returns 0 if the creature was not able to move. 574 * move_ob returns 0 if the creature was not able to move.
576 */ 575 */
577 tag = op->count;
578 if (move_ob (op, op->direction, op)) 576 if (move_ob (op, op->direction, op))
579 return; 577 return;
580 if (was_destroyed (op, tag)) 578
579 if (op->destroyed ())
581 return; 580 return;
582 581
583 for (tmp = op; tmp; tmp = tmp->more) 582 for (tmp = op; tmp; tmp = tmp->more)
584 { 583 {
585 sint16 x = tmp->x + freearr_x[op->direction], y = tmp->y + freearr_y[op->direction]; 584 sint16 x = tmp->x + freearr_x[op->direction], y = tmp->y + freearr_y[op->direction];
586 object *victim; 585 object *victim;
587 mapstruct *m; 586 maptile *m;
588 int mflags; 587 int mflags;
589 588
590 m = op->map; 589 m = op->map;
591 mflags = get_map_flags (m, &m, x, y, &x, &y); 590 mflags = get_map_flags (m, &m, x, y, &x, &y);
592 591
657 char buf[MAX_BUF]; 656 char buf[MAX_BUF];
658 657
659 /* Because there can be different golem spells, player may want to 658 /* Because there can be different golem spells, player may want to
660 * 'lose' their old golem. 659 * 'lose' their old golem.
661 */ 660 */
662 if (op->type == PLAYER && op->contr->ranges[range_golem] != NULL && op->contr->golem_count == op->contr->ranges[range_golem]->count) 661 if (op->type == PLAYER && op->contr->ranges[range_golem])
663 { 662 {
664 new_draw_info (NDI_UNIQUE, 0, op, "You dismiss your existing golem."); 663 new_draw_info (NDI_UNIQUE, 0, op, "You dismiss your existing golem.");
665 remove_ob (op->contr->ranges[range_golem]); 664 op->contr->ranges[range_golem]->remove ();
666 free_object (op->contr->ranges[range_golem]); 665 op->contr->ranges[range_golem]->destroy ();
667 op->contr->ranges[range_golem] = NULL; 666 op->contr->ranges[range_golem] = 0;
668 op->contr->golem_count = (uint32) - 1;
669 } 667 }
670 668
671 if (spob->other_arch) 669 if (spob->other_arch)
672 at = spob->other_arch; 670 at = spob->other_arch;
673 else if (spob->race) 671 else if (spob->race)
714 { 712 {
715 tmp->type = GOLEM; 713 tmp->type = GOLEM;
716 set_owner (tmp, op); 714 set_owner (tmp, op);
717 set_spell_skill (op, caster, spob, tmp); 715 set_spell_skill (op, caster, spob, tmp);
718 op->contr->ranges[range_golem] = tmp; 716 op->contr->ranges[range_golem] = tmp;
719 op->contr->golem_count = tmp->count;
720 /* give the player control of the golem */ 717 /* give the player control of the golem */
721 op->contr->shoottype = range_golem; 718 op->contr->shoottype = range_golem;
722 } 719 }
723 else 720 else
724 { 721 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines