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.17 by root, Tue Dec 26 08:55:00 2006 UTC vs.
Revision 1.19 by root, Wed Jan 3 20:32:13 2007 UTC

79 */ 79 */
80 pet->enemy = NULL; 80 pet->enemy = NULL;
81 else 81 else
82 return tmp; 82 return tmp;
83 } 83 }
84
84 get_search_arr (search_arr); 85 get_search_arr (search_arr);
85 86
86 if (owner->type == PLAYER && owner->contr->petmode > pet_normal) 87 if (owner->type == PLAYER && owner->contr->petmode > pet_normal)
87 { 88 {
88 if (owner->contr->petmode == pet_sad) 89 if (owner->contr->petmode == pet_sad)
112 x = owner->x + freearr_x[search_arr[i]]; 113 x = owner->x + freearr_x[search_arr[i]];
113 y = owner->y + freearr_y[search_arr[i]]; 114 y = owner->y + freearr_y[search_arr[i]];
114 nm = owner->map; 115 nm = owner->map;
115 /* Only look on the space if there is something alive there. */ 116 /* Only look on the space if there is something alive there. */
116 mflags = get_map_flags (nm, &nm, x, y, &x, &y); 117 mflags = get_map_flags (nm, &nm, x, y, &x, &y);
118
117 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) 119 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE)
118 { 120 {
119 for (tmp = GET_MAP_OB (nm, x, y); tmp != NULL; tmp = tmp->above) 121 for (tmp = GET_MAP_OB (nm, x, y); tmp != NULL; tmp = tmp->above)
120 { 122 {
121 object *tmp2 = tmp->head == NULL ? tmp : tmp->head; 123 object *tmp2 = tmp->head == NULL ? tmp : tmp->head;
258 * Thus the map isn't loaded yet, and we have to remove 260 * Thus the map isn't loaded yet, and we have to remove
259 * the pet... 261 * the pet...
260 * Interesting enough, we don't use the passed map structure in 262 * Interesting enough, we don't use the passed map structure in
261 * this function. 263 * this function.
262 */ 264 */
263
264void 265void
265remove_all_pets (maptile *map) 266remove_all_pets (maptile *map)
266{ 267{
267 objectlink *obl, *next; 268 objectlink *obl, *next;
268 object *owner; 269 object *owner;
453fix_summon_pet (archetype *at, object *op, int dir, int is_golem) 454fix_summon_pet (archetype *at, object *op, int dir, int is_golem)
454{ 455{
455 archetype *atmp; 456 archetype *atmp;
456 object *tmp = NULL, *prev = NULL, *head = NULL; 457 object *tmp = NULL, *prev = NULL, *head = NULL;
457 458
458 for (atmp = at; atmp != NULL; atmp = atmp->more) 459 for (atmp = at; atmp; atmp = atmp->more)
459 { 460 {
460 tmp = arch_to_object (atmp); 461 tmp = arch_to_object (atmp);
462
461 if (atmp == at) 463 if (atmp == at)
462 { 464 {
463 if (!is_golem) 465 if (!is_golem)
464 SET_FLAG (tmp, FLAG_MONSTER); 466 SET_FLAG (tmp, FLAG_MONSTER);
467
465 tmp->set_owner (op); 468 tmp->set_owner (op);
466 if (op->type == PLAYER) 469 if (op->type == PLAYER)
467 { 470 {
468 tmp->stats.exp = 0; 471 tmp->stats.exp = 0;
469 add_friendly_object (tmp); 472 add_friendly_object (tmp);
475 { 478 {
476 if (QUERY_FLAG (op, FLAG_FRIENDLY)) 479 if (QUERY_FLAG (op, FLAG_FRIENDLY))
477 { 480 {
478 object *owner = op->owner; 481 object *owner = op->owner;
479 482
480 if (owner != NULL) 483 if (owner)
481 { /* For now, we transfer ownership */ 484 { /* For now, we transfer ownership */
482 tmp->set_owner (owner); 485 tmp->set_owner (owner);
483 tmp->attack_movement = PETMOVE; 486 tmp->attack_movement = PETMOVE;
484 add_friendly_object (tmp); 487 add_friendly_object (tmp);
485 SET_FLAG (tmp, FLAG_FRIENDLY); 488 SET_FLAG (tmp, FLAG_FRIENDLY);
486 } 489 }
487 } 490 }
488 } 491 }
492
489 if (op->type != PLAYER || !is_golem) 493 if (op->type != PLAYER || !is_golem)
490 { 494 {
491 tmp->attack_movement = PETMOVE; 495 tmp->attack_movement = PETMOVE;
492 tmp->speed_left = -1; 496 tmp->speed_left = -1;
493 tmp->type = 0; 497 tmp->type = 0;
495 } 499 }
496 else 500 else
497 tmp->type = GOLEM; 501 tmp->type = GOLEM;
498 502
499 } 503 }
504
500 if (head == NULL) 505 if (!head)
501 head = tmp; 506 head = tmp;
507
502 tmp->x = op->x + freearr_x[dir] + tmp->arch->clone.x; 508 tmp->x = op->x + freearr_x[dir] + tmp->arch->clone.x;
503 tmp->y = op->y + freearr_y[dir] + tmp->arch->clone.y; 509 tmp->y = op->y + freearr_y[dir] + tmp->arch->clone.y;
504 tmp->map = op->map; 510 tmp->map = op->map;
511
505 if (tmp->invisible) 512 if (tmp->invisible)
506 tmp->invisible = 0; 513 tmp->invisible = 0;
514
507 if (head != tmp) 515 if (head != tmp)
508 tmp->head = head, prev->more = tmp; 516 tmp->head = head, prev->more = tmp;
517
509 prev = tmp; 518 prev = tmp;
510 } 519 }
520
511 head->direction = dir; 521 head->direction = dir;
512 522
513 /* need to change some monster attr to prevent problems/crashing */ 523 /* need to change some monster attr to prevent problems/crashing */
514 head->last_heal = 0; 524 head->last_heal = 0;
515 head->last_eat = 0; 525 head->last_eat = 0;
526 536
527 return head; 537 return head;
528} 538}
529 539
530/* updated this to allow more than the golem 'head' to attack */ 540/* updated this to allow more than the golem 'head' to attack */
531
532/* op is the golem to be moved. */ 541/* op is the golem to be moved. */
533
534void 542void
535move_golem (object *op) 543move_golem (object *op)
536{ 544{
537 int made_attack = 0; 545 int made_attack = 0;
538 object *tmp; 546 object *tmp;
695 if (dir == -1 || ob_blocked (&at->clone, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir])) 703 if (dir == -1 || ob_blocked (&at->clone, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir]))
696 { 704 {
697 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 705 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
698 return 0; 706 return 0;
699 } 707 }
708
700 /* basically want to get proper map/coordinates for this object */ 709 /* basically want to get proper map/coordinates for this object */
701 710
702 if (!(tmp = fix_summon_pet (at, op, dir, GOLEM))) 711 if (!(tmp = fix_summon_pet (at, op, dir, GOLEM)))
703 { 712 {
704 new_draw_info (NDI_UNIQUE, 0, op, "Your spell fails."); 713 new_draw_info (NDI_UNIQUE, 0, op, "Your spell fails.");
718 { 727 {
719 if (QUERY_FLAG (op, FLAG_FRIENDLY)) 728 if (QUERY_FLAG (op, FLAG_FRIENDLY))
720 { 729 {
721 object *owner = op->owner; 730 object *owner = op->owner;
722 731
723 if (owner != NULL) 732 if (owner)
724 { /* For now, we transfer ownership */ 733 { /* For now, we transfer ownership */
725 tmp->set_owner (owner); 734 tmp->set_owner (owner);
726 tmp->attack_movement = PETMOVE; 735 tmp->attack_movement = PETMOVE;
727 add_friendly_object (tmp); 736 add_friendly_object (tmp);
728 SET_FLAG (tmp, FLAG_FRIENDLY); 737 SET_FLAG (tmp, FLAG_FRIENDLY);
902 * with all the checks in the 'for' portion itself. Much 911 * with all the checks in the 'for' portion itself. Much
903 * more readable to break some of the conditions out. 912 * more readable to break some of the conditions out.
904 */ 913 */
905 for (tr = spell_ob->randomitems->items; tr; tr = tr->next) 914 for (tr = spell_ob->randomitems->items; tr; tr = tr->next)
906 { 915 {
916 if (!tr->item)
917 continue;
918
907 if (level < tr->magic) 919 if (level < tr->magic)
908 break; 920 break;
909 921
910 lasttr = tr; 922 lasttr = tr;
911 923
912 if (tr->item->name == sparam) 924 if (tr->item->name == sparam)
913 break;
914
915 if (!tr->next || !tr->next->item)
916 break; 925 break;
917 } 926 }
918 927
919 if (!lasttr) 928 if (!lasttr)
920 { 929 {
922 new_draw_info (NDI_UNIQUE, 0, op, "The spell fails to summon any monsters."); 931 new_draw_info (NDI_UNIQUE, 0, op, "The spell fails to summon any monsters.");
923 return 0; 932 return 0;
924 } 933 }
925 934
926 summon_arch = lasttr->item; 935 summon_arch = lasttr->item;
927 nrof = lasttr->nrof; 936 nrof = lasttr->nrof;
928 } 937 }
929 else if (spell_ob->race && !strcmp (spell_ob->race, "GODCULTMON")) 938 else if (spell_ob->race && !strcmp (spell_ob->race, "GODCULTMON"))
930 { 939 {
931 object *god = find_god (determine_god (op)), *mon, *owner; 940 object *god = find_god (determine_god (op)), *mon, *owner;
932 int summon_level, tries; 941 int summon_level, tries;
1076 head->stats.exp = 0; 1085 head->stats.exp = 0;
1077 head = insert_ob_in_map (head, head->map, op, 0); 1086 head = insert_ob_in_map (head, head->map, op, 0);
1078 1087
1079 if (head && head->randomitems) 1088 if (head && head->randomitems)
1080 { 1089 {
1081 object *tmp;
1082
1083 create_treasure (head->randomitems, head, GT_APPLY | GT_STARTEQUIP, 6, 0); 1090 create_treasure (head->randomitems, head, GT_APPLY | GT_STARTEQUIP, 6, 0);
1091
1084 for (tmp = head->inv; tmp; tmp = tmp->below) 1092 for (object *tmp = head->inv; tmp; tmp = tmp->below)
1085 if (!tmp->nrof)
1086 SET_FLAG (tmp, FLAG_NO_DROP); 1093 SET_FLAG (tmp, FLAG_NO_DROP);
1087 } 1094 }
1088 } /* for i < nrof */ 1095 } /* for i < nrof */
1089 1096
1090 return 1; 1097 return 1;
1091} 1098}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines