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.2 by root, Tue Aug 29 08:01:37 2006 UTC vs.
Revision 1.3 by root, Sun Sep 3 00:18:42 2006 UTC

1/* 1/*
2 * static char *rcsid_pets_c = 2 * static char *rcsid_pets_c =
3 * "$Id: pets.C,v 1.2 2006/08/29 08:01:37 root Exp $"; 3 * "$Id: pets.C,v 1.3 2006/09/03 00:18:42 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
267 267
268 if (!QUERY_FLAG(ob,FLAG_REMOVED)) 268 if (!QUERY_FLAG(ob,FLAG_REMOVED))
269 remove_ob(ob); 269 remove_ob(ob);
270 270
271 if(owner->map == NULL) { 271 if(owner->map == NULL) {
272 LOG(llevError,"Can't follow owner (%d): no map.\n", owner->name); 272 LOG(llevError,"Can't follow owner (%d): no map.\n", &owner->name);
273 goto fail; 273 goto fail;
274 } 274 }
275 if(owner->map->in_memory != MAP_IN_MEMORY) { 275 if(owner->map->in_memory != MAP_IN_MEMORY) {
276 LOG(llevError,"Owner of the pet not on a map in memory!?\n"); 276 LOG(llevError,"Owner of the pet not on a map in memory!?\n");
277 goto fail; 277 goto fail;
278 } 278 }
279 279
280 dir = find_free_spot(ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE); 280 dir = find_free_spot(ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE);
281 281
282 if (dir==-1) { 282 if (dir==-1) {
283 LOG(llevMonster,"No space for pet to follow, freeing %s.\n",ob->name); 283 LOG(llevMonster,"No space for pet to follow, freeing %s.\n", &ob->name);
284 goto fail; 284 goto fail;
285 } 285 }
286 for(tmp=ob;tmp!=NULL;tmp=tmp->more) { 286 for(tmp=ob;tmp!=NULL;tmp=tmp->more) {
287 tmp->x = owner->x + freearr_x[dir]+(tmp->arch==NULL?0:tmp->arch->clone.x); 287 tmp->x = owner->x + freearr_x[dir]+(tmp->arch==NULL?0:tmp->arch->clone.x);
288 tmp->y = owner->y + freearr_y[dir]+(tmp->arch==NULL?0:tmp->arch->clone.y); 288 tmp->y = owner->y + freearr_y[dir]+(tmp->arch==NULL?0:tmp->arch->clone.y);
544 * aligned races 544 * aligned races
545 */ 545 */
546 546
547 if(victim->race && op->race && strstr(op->race,victim->race)) { 547 if(victim->race && op->race && strstr(op->race,victim->race)) {
548 if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner, 548 if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner,
549 "%s avoids damaging %s.",op->name,victim->name); 549 "%s avoids damaging %s.", &op->name, &victim->name);
550 } else if (victim == op->owner) { 550 } else if (victim == op->owner) {
551 if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner, 551 if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner,
552 "%s avoids damaging you.",op->name); 552 "%s avoids damaging you.", &op->name);
553 } else { 553 } else {
554 attack_ob(victim,op); 554 attack_ob(victim,op);
555 made_attack=1; 555 made_attack=1;
556 } 556 }
557 } /* If victim */ 557 } /* If victim */
596 at = spob->other_arch; 596 at = spob->other_arch;
597 else if (spob->race) { 597 else if (spob->race) {
598 god = find_god(determine_god(caster)); 598 god = find_god(determine_god(caster));
599 599
600 if (!god) { 600 if (!god) {
601 new_draw_info_format(NDI_UNIQUE, 0,op,"You must worship a god to cast %s.", spob->name); 601 new_draw_info_format(NDI_UNIQUE, 0,op,"You must worship a god to cast %s.", &spob->name);
602 return 0; 602 return 0;
603 } 603 }
604 at = determine_holy_arch (god, spob->race); 604 at = determine_holy_arch (god, spob->race);
605 if (!at) { 605 if (!at) {
606 new_draw_info_format(NDI_UNIQUE, 0,op,"%s has no %s for you to call.", 606 new_draw_info_format(NDI_UNIQUE, 0,op,"%s has no %s for you to call.",
607 god->name,spob->race); 607 &god->name, &spob->race);
608 return 0; 608 return 0;
609 } 609 }
610 } else { 610 } else {
611 LOG(llevError,"Spell %s lacks other_arch\n", spob->name); 611 LOG(llevError,"Spell %s lacks other_arch\n", &spob->name);
612 return 0; 612 return 0;
613 } 613 }
614 614
615 if(!dir) 615 if(!dir)
616 dir=find_free_spot(NULL,op->map,op->x,op->y,1,SIZEOFFREE1+1); 616 dir=find_free_spot(NULL,op->map,op->x,op->y,1,SIZEOFFREE1+1);
680 680
681 /* Holy spell - some additional tailoring */ 681 /* Holy spell - some additional tailoring */
682 if (god) { 682 if (god) {
683 object *tmp2; 683 object *tmp2;
684 684
685 sprintf(buf,"%s of %s",spob->name,god->name); 685 sprintf(buf,"%s of %s", &spob->name, &god->name);
686 buf[0] = toupper(buf[0]); 686 buf[0] = toupper(buf[0]);
687
687 for (tmp2=tmp; tmp2; tmp2=tmp2->more) { 688 for (tmp2=tmp; tmp2; tmp2=tmp2->more)
688 if (tmp2->name) free_string(tmp2->name);
689 tmp2->name = add_string(buf); 689 tmp2->name = buf;
690 } 690
691 tmp->attacktype |= god->attacktype; 691 tmp->attacktype |= god->attacktype;
692 memcpy(tmp->resist, god->resist, sizeof(tmp->resist)); 692 memcpy(tmp->resist, god->resist, sizeof(tmp->resist));
693 if (tmp->race) FREE_AND_CLEAR_STR(tmp->race); 693 tmp->race = god->race;
694 if (god->race) tmp->race = add_string(god->race); 694 tmp->slaying = god->slaying;
695 if (tmp->slaying) FREE_AND_CLEAR_STR(tmp->slaying);
696 if (god->slaying) tmp->slaying = add_string(god->slaying);
697 /* safety, we must allow a god's servants some reasonable attack */ 695 /* safety, we must allow a god's servants some reasonable attack */
698 if(!(tmp->attacktype&AT_PHYSICAL)) tmp->attacktype|=AT_PHYSICAL; 696 if(!(tmp->attacktype&AT_PHYSICAL)) tmp->attacktype|=AT_PHYSICAL;
699 } 697 }
700 698
701 insert_ob_in_map(tmp,tmp->map,op,0); 699 insert_ob_in_map(tmp,tmp->map,op,0);
749 * race file 747 * race file
750 */ 748 */
751 if((list=find_racelink(race))==NULL) { 749 if((list=find_racelink(race))==NULL) {
752 new_draw_info_format(NDI_UNIQUE, 0,pl, 750 new_draw_info_format(NDI_UNIQUE, 0,pl,
753 "The spell fails! %s's creatures are beyond the range of your summons", 751 "The spell fails! %s's creatures are beyond the range of your summons",
754 god->name); 752 &god->name);
755 LOG(llevDebug,"choose_cult_monster() requested non-existent aligned race!\n"); 753 LOG(llevDebug,"choose_cult_monster() requested non-existent aligned race!\n");
756 return 0; 754 return 0;
757 } 755 }
758 756
759 /* search for an apprplritate monster on this race list */ 757 /* search for an apprplritate monster on this race list */
806 if(stringarg && !strcmp(tr->item->name,stringarg)) break; 804 if(stringarg && !strcmp(tr->item->name,stringarg)) break;
807 if (tr->next == NULL || tr->next->item == NULL) break; 805 if (tr->next == NULL || tr->next->item == NULL) break;
808 } 806 }
809 if (!lasttr) { 807 if (!lasttr) {
810 LOG(llevError,"Treasurelist %s did not generate a valid entry in summon_object\n", 808 LOG(llevError,"Treasurelist %s did not generate a valid entry in summon_object\n",
811 spell_ob->randomitems->name); 809 &spell_ob->randomitems->name);
812 new_draw_info(NDI_UNIQUE, 0, op, "The spell fails to summon any monsters."); 810 new_draw_info(NDI_UNIQUE, 0, op, "The spell fails to summon any monsters.");
813 return 0; 811 return 0;
814 } 812 }
815 summon_arch = lasttr->item; 813 summon_arch = lasttr->item;
816 nrof = lasttr->nrof; 814 nrof = lasttr->nrof;
825 /* If we can't find a god, can't get what monster to summon */ 823 /* If we can't find a god, can't get what monster to summon */
826 if (!god) return 0; 824 if (!god) return 0;
827 825
828 if (!god->race) { 826 if (!god->race) {
829 new_draw_info_format(NDI_UNIQUE, 0,op, 827 new_draw_info_format(NDI_UNIQUE, 0,op,
830 "%s has no creatures that you may summon!",god->name); 828 "%s has no creatures that you may summon!", &god->name);
831 return 0; 829 return 0;
832 } 830 }
833 /* the summon level */ 831 /* the summon level */
834 summon_level=caster_level(caster, spell_ob); 832 summon_level=caster_level(caster, spell_ob);
835 if (summon_level==0) summon_level=1; 833 if (summon_level==0) summon_level=1;
836 tries = 0; 834 tries = 0;
837 do { 835 do {
838 mon = choose_cult_monster(op, god,summon_level); 836 mon = choose_cult_monster(op, god,summon_level);
839 if (!mon) { 837 if (!mon) {
840 new_draw_info_format(NDI_UNIQUE, 0,op, 838 new_draw_info_format(NDI_UNIQUE, 0,op,
841 "%s fails to send anything.",god->name); 839 "%s fails to send anything.", &god->name);
842 return 0; 840 return 0;
843 } 841 }
844 ndir = dir; 842 ndir = dir;
845 if (!ndir) 843 if (!ndir)
846 ndir = find_free_spot(mon, op->map, op->x, op->y, 1, SIZEOFFREE); 844 ndir = find_free_spot(mon, op->map, op->x, op->y, 1, SIZEOFFREE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines