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

Comparing deliantra/server/server/gods.C (file contents):
Revision 1.3 by root, Tue Aug 29 08:01:37 2006 UTC vs.
Revision 1.4 by root, Sun Sep 3 00:18:42 2006 UTC

1/* 1/*
2 * static char *rcsid_gods_c = 2 * static char *rcsid_gods_c =
3 * "$Id: gods.C,v 1.3 2006/08/29 08:01:37 root Exp $"; 3 * "$Id: gods.C,v 1.4 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
99 /* find a god based on race */ 99 /* find a god based on race */
100 if(!op->title) { 100 if(!op->title) {
101 if (op->race !=NULL) { 101 if (op->race !=NULL) {
102 godname=get_god_for_race(op->race); 102 godname=get_god_for_race(op->race);
103 if (godname!=NULL) { 103 if (godname!=NULL) {
104 op->title = add_string(godname); 104 op->title = godname;
105 } 105 }
106 } 106 }
107 } 107 }
108 108
109 /* find a random god */ 109 /* find a random god */
113 godnr = rndm(1, gl->id); 113 godnr = rndm(1, gl->id);
114 while(gl) { 114 while(gl) {
115 if(gl->id == godnr) break; 115 if(gl->id == godnr) break;
116 gl=gl->next; 116 gl=gl->next;
117 } 117 }
118 op->title = add_string(gl->name); 118 op->title = gl->name;
119 } 119 }
120 120
121 return op->title; 121 return op->title;
122 } 122 }
123 123
225 if (follower_has_similar_item (op, &tr->item->clone)) 225 if (follower_has_similar_item (op, &tr->item->clone))
226 return 0; 226 return 0;
227 227
228 tmp = arch_to_object (tr->item); 228 tmp = arch_to_object (tr->item);
229 new_draw_info_format (NDI_UNIQUE, 0, op, 229 new_draw_info_format (NDI_UNIQUE, 0, op,
230 "%s lets %s appear in your hands.", god->name, query_short_name (tmp)); 230 "%s lets %s appear in your hands.", &god->name, query_short_name (tmp));
231 tmp = insert_ob_in_ob (tmp, op); 231 tmp = insert_ob_in_ob (tmp, op);
232 if (op->type == PLAYER) 232 if (op->type == PLAYER)
233 esrv_send_item (op, tmp); 233 esrv_send_item (op, tmp);
234 return 1; 234 return 1;
235} 235}
250 /* hmm. what happend depends on pl's current god, level, etc */ 250 /* hmm. what happend depends on pl's current god, level, etc */
251 if(!pl_god) { /*new convert */ 251 if(!pl_god) { /*new convert */
252 become_follower(pl,&altar->other_arch->clone); 252 become_follower(pl,&altar->other_arch->clone);
253 return; 253 return;
254 254
255 } else if(!strcmp(pl_god->name,altar->other_arch->clone.name)) { 255 } else if(!strcmp(&pl_god->name,altar->other_arch->clone.name)) {
256 /* pray at your gods altar */ 256 /* pray at your gods altar */
257 int bonus = (pl->stats.Wis+skill->level)/10; 257 int bonus = (pl->stats.Wis+skill->level)/10;
258 258
259 /* we can get neg grace up faster */ 259 /* we can get neg grace up faster */
260 if(pl->stats.grace<0) pl->stats.grace+=(bonus>-1*(pl->stats.grace/10) ? 260 if(pl->stats.grace<0) pl->stats.grace+=(bonus>-1*(pl->stats.grace/10) ?
293 object *tmp; 293 object *tmp;
294 294
295 /* you really screwed up */ 295 /* you really screwed up */
296 angry=3; 296 angry=3;
297 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,pl, 297 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,pl,
298 "Foul Priest! %s punishes you!",pl_god->name); 298 "Foul Priest! %s punishes you!",&pl_god->name);
299 tmp=get_archetype(LOOSE_MANA); 299 tmp=get_archetype(LOOSE_MANA);
300 cast_magic_storm(pl,tmp, pl_god->level+20); 300 cast_magic_storm(pl,tmp, pl_god->level+20);
301 } else 301 } else
302 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,pl, 302 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,pl,
303 "Foolish heretic! %s is livid!",pl_god->name); 303 "Foolish heretic! %s is livid!",&pl_god->name);
304 } else 304 } else
305 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,pl, 305 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,pl,
306 "Heretic! %s is angered!",pl_god->name); 306 "Heretic! %s is angered!",&pl_god->name);
307 307
308 /* whether we will be successfull in defecting or not - 308 /* whether we will be successfull in defecting or not -
309 * we lose experience from the clerical experience obj 309 * we lose experience from the clerical experience obj
310 */ 310 */
311 311
312 loss = angry * (skill->stats.exp / 10); 312 loss = angry * (skill->stats.exp / 10);
313 if(loss) 313 if(loss)
314 change_exp(pl, -random_roll64(0, loss, pl, PREFER_LOW), 314 change_exp(pl, -random_roll64(0, loss, pl, PREFER_LOW),
315 skill?skill->skill:"none", SK_SUBTRACT_SKILL_EXP); 315 skill ? &skill->skill : "none", SK_SUBTRACT_SKILL_EXP);
316 316
317 /* May switch Gods, but its random chance based on our current level 317 /* May switch Gods, but its random chance based on our current level
318 * note it gets harder to swap gods the higher we get 318 * note it gets harder to swap gods the higher we get
319 */ 319 */
320 if((angry==1) && !(random_roll(0, skill->level, pl, PREFER_LOW))) { 320 if((angry==1) && !(random_roll(0, skill->level, pl, PREFER_LOW))) {
349 */ 349 */
350 if (tmp->type != SPELL || !QUERY_FLAG(tmp, FLAG_STARTEQUIP)) 350 if (tmp->type != SPELL || !QUERY_FLAG(tmp, FLAG_STARTEQUIP))
351 continue; 351 continue;
352 352
353 if (god->randomitems == NULL) { 353 if (god->randomitems == NULL) {
354 LOG (llevError, "BUG: check_special_prayers(): god %s without randomitems\n", god->name); 354 LOG (llevError, "BUG: check_special_prayers(): god %s without randomitems\n", &god->name);
355 do_forget_spell (op, tmp->name); 355 do_forget_spell (op, tmp->name);
356 continue; 356 continue;
357 } 357 }
358 358
359 /* Inner loop tries to find the special prayer in the god's treasure 359 /* Inner loop tries to find the special prayer in the god's treasure
378 if (remove) { 378 if (remove) {
379 /* just do the work of removing the spell ourselves - we already 379 /* just do the work of removing the spell ourselves - we already
380 * know that the player knows the spell 380 * know that the player knows the spell
381 */ 381 */
382 new_draw_info_format (NDI_UNIQUE|NDI_NAVY, 0, op, 382 new_draw_info_format (NDI_UNIQUE|NDI_NAVY, 0, op,
383 "You lose knowledge of %s.", tmp->name); 383 "You lose knowledge of %s.", &tmp->name);
384 player_unready_range_ob(op->contr, tmp); 384 player_unready_range_ob(op->contr, tmp);
385 remove_ob(tmp); 385 remove_ob(tmp);
386 free_object(tmp); 386 free_object(tmp);
387 } 387 }
388 388
415 (item->type != SKILL) && (item->type != EXPERIENCE) && 415 (item->type != SKILL) && (item->type != EXPERIENCE) &&
416 (item->type != FORCE)) { 416 (item->type != FORCE)) {
417 417
418 if (item->type == SPELL) 418 if (item->type == SPELL)
419 new_draw_info_format(NDI_UNIQUE|NDI_NAVY, 0, op, 419 new_draw_info_format(NDI_UNIQUE|NDI_NAVY, 0, op,
420 "You lose knowledge of %s.", item->name); 420 "You lose knowledge of %s.", &item->name);
421 player_unready_range_ob(op->contr, item); 421 player_unready_range_ob(op->contr, item);
422 remove_ob(item); 422 remove_ob(item);
423 free_object(item); 423 free_object(item);
424 } 424 }
425 } 425 }
434 434
435 if(!op||!new_god) return; 435 if(!op||!new_god) return;
436 436
437 if(op->race && new_god->slaying && strstr(op->race,new_god->slaying)) { 437 if(op->race && new_god->slaying && strstr(op->race,new_god->slaying)) {
438 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,op,"Fool! %s detests your kind!", 438 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,op,"Fool! %s detests your kind!",
439 new_god->name); 439 &new_god->name);
440 if(random_roll(0, op->level-1, op, PREFER_LOW)-5>0) { 440 if(random_roll(0, op->level-1, op, PREFER_LOW)-5>0) {
441 object *tmp = get_archetype(LOOSE_MANA); 441 object *tmp = get_archetype(LOOSE_MANA);
442 cast_magic_storm(op,tmp, new_god->level+10); 442 cast_magic_storm(op,tmp, new_god->level+10);
443 } 443 }
444 return; 444 return;
451 tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) 451 tr->item->clone.type != BOOK && tr->item->clone.type != SPELL)
452 god_gives_present(op,new_god,tr); } 452 god_gives_present(op,new_god,tr); }
453 453
454 454
455 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,op, 455 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,op,
456 "You become a follower of %s!",new_god->name); 456 "You become a follower of %s!",&new_god->name);
457 457
458 for (skop = op->inv; skop != NULL; skop=skop->below) 458 for (skop = op->inv; skop != NULL; skop=skop->below)
459 if (skop->type == SKILL && skop->subtype == SK_PRAYING) break; 459 if (skop->type == SKILL && skop->subtype == SK_PRAYING) break;
460 460
461 /* Player has no skill - give them the skill */ 461 /* Player has no skill - give them the skill */
479 undeadified=1; 479 undeadified=1;
480 } 480 }
481 481
482 if(skop->title) { /* get rid of old god */ 482 if(skop->title) { /* get rid of old god */
483 new_draw_info_format(NDI_UNIQUE,0,op, 483 new_draw_info_format(NDI_UNIQUE,0,op,
484 "%s's blessing is withdrawn from you.",skop->title); 484 "%s's blessing is withdrawn from you.", &skop->title);
485 /* The point of this is to really show what abilities the player just lost */ 485 /* The point of this is to really show what abilities the player just lost */
486 if (sk_applied || undeadified) { 486 if (sk_applied || undeadified) {
487 487
488 CLEAR_FLAG(skop,FLAG_APPLIED); 488 CLEAR_FLAG(skop,FLAG_APPLIED);
489 (void) change_abil(op,skop); 489 (void) change_abil(op,skop);
490 } 490 }
491 free_string(skop->title);
492 } 491 }
493 492
494 /* now change to the new gods attributes to exp_obj */ 493 /* now change to the new gods attributes to exp_obj */
495 skop->title = add_string(new_god->name); 494 skop->title = new_god->name;
496 skop->path_attuned=new_god->path_attuned; 495 skop->path_attuned=new_god->path_attuned;
497 skop->path_repelled=new_god->path_repelled; 496 skop->path_repelled=new_god->path_repelled;
498 skop->path_denied=new_god->path_denied; 497 skop->path_denied=new_god->path_denied;
499 /* copy god's resistances */ 498 /* copy god's resistances */
500 memcpy(skop->resist, new_god->resist, sizeof(new_god->resist)); 499 memcpy(skop->resist, new_god->resist, sizeof(new_god->resist));
521 update_priest_flag(new_god,skop,FLAG_UNDEAD); 520 update_priest_flag(new_god,skop,FLAG_UNDEAD);
522 update_priest_flag(new_god,skop,FLAG_BLIND); 521 update_priest_flag(new_god,skop,FLAG_BLIND);
523 update_priest_flag(new_god,skop,FLAG_XRAYS); /* better have this if blind! */ 522 update_priest_flag(new_god,skop,FLAG_XRAYS); /* better have this if blind! */
524 523
525 new_draw_info_format(NDI_UNIQUE,0,op, 524 new_draw_info_format(NDI_UNIQUE,0,op,
526 "You are bathed in %s's aura.",new_god->name); 525 "You are bathed in %s's aura.",&new_god->name);
527 526
528 /* Weapon/armour use are special...handle flag toggles here as this can 527 /* Weapon/armour use are special...handle flag toggles here as this can
529 * only happen when gods are worshipped and if the new priest could 528 * only happen when gods are worshipped and if the new priest could
530 * have used armour/weapons in the first place. 529 * have used armour/weapons in the first place.
531 * 530 *
707 if (weapon == NULL || god_examines_item (god, weapon) <= 0) 706 if (weapon == NULL || god_examines_item (god, weapon) <= 0)
708 return 0; 707 return 0;
709 708
710 /* First give it a title, so other gods won't touch it */ 709 /* First give it a title, so other gods won't touch it */
711 if ( ! weapon->title) { 710 if ( ! weapon->title) {
712 sprintf (buf, "of %s", god->name); 711 sprintf (buf, "of %s", &god->name);
713 weapon->title = add_string (buf); 712 weapon->title = buf;
714 if (op->type == PLAYER) 713 if (op->type == PLAYER)
715 esrv_update_item (UPD_NAME, op, weapon); 714 esrv_update_item (UPD_NAME, op, weapon);
716 new_draw_info (NDI_UNIQUE, 0, op, "Your weapon quivers as if struck!"); 715 new_draw_info (NDI_UNIQUE, 0, op, "Your weapon quivers as if struck!");
717 } 716 }
718 717
719 /* Allow the weapon to slay enemies */ 718 /* Allow the weapon to slay enemies */
720 if ( ! weapon->slaying && god->slaying) { 719 if ( ! weapon->slaying && god->slaying) {
721 weapon->slaying = add_string (god->slaying); 720 weapon->slaying = god->slaying;
722 new_draw_info_format (NDI_UNIQUE, 0, op, 721 new_draw_info_format (NDI_UNIQUE, 0, op,
723 "Your %s now hungers to slay enemies of your god!", 722 "Your %s now hungers to slay enemies of your god!",
724 weapon->name); 723 &weapon->name);
725 return 1; 724 return 1;
726 } 725 }
727 726
728 /* Add the gods attacktype */ 727 /* Add the gods attacktype */
729 attacktype = (weapon->attacktype == 0) ? AT_PHYSICAL : weapon->attacktype; 728 attacktype = (weapon->attacktype == 0) ? AT_PHYSICAL : weapon->attacktype;
793 return; 792 return;
794 } 793 }
795 794
796 if ( ! tr->item) { 795 if ( ! tr->item) {
797 LOG (llevError, "BUG: empty entry in %s's treasure list\n", 796 LOG (llevError, "BUG: empty entry in %s's treasure list\n",
798 god->name); 797 &god->name);
799 continue; 798 continue;
800 } 799 }
801 item = &tr->item->clone; 800 item = &tr->item->clone;
802 801
803 /* Grace limit */ 802 /* Grace limit */
953 continue; 952 continue;
954 if (item->level > skill->level) 953 if (item->level > skill->level)
955 continue; 954 continue;
956 955
957 new_draw_info_format(NDI_UNIQUE, 0, op, 956 new_draw_info_format(NDI_UNIQUE, 0, op,
958 "%s grants you use of a special prayer!", god->name); 957 "%s grants you use of a special prayer!", &god->name);
959 do_learn_spell (op, item, 1); 958 do_learn_spell (op, item, 1);
960 return; 959 return;
961 960
962 } 961 }
963 962
998 if (skop->type == SKILL && skop->subtype == SK_PRAYING) break; 997 if (skop->type == SKILL && skop->subtype == SK_PRAYING) break;
999 998
1000 if (skop) 999 if (skop)
1001 loss = (int) (0.05 * (float) skop->stats.exp); 1000 loss = (int) (0.05 * (float) skop->stats.exp);
1002 change_exp(op, -random_roll(0, loss*angry-1, op, PREFER_LOW), 1001 change_exp(op, -random_roll(0, loss*angry-1, op, PREFER_LOW),
1003 skop?skop->skill:"none", SK_SUBTRACT_SKILL_EXP); 1002 skop ? &skop->skill : "none", SK_SUBTRACT_SKILL_EXP);
1004 if(random_roll(0, angry, op, PREFER_LOW)) { 1003 if(random_roll(0, angry, op, PREFER_LOW)) {
1005 object *tmp = get_archetype(LOOSE_MANA); 1004 object *tmp = get_archetype(LOOSE_MANA);
1006 cast_magic_storm(op,tmp,op->level+(angry*3)); 1005 cast_magic_storm(op,tmp,op->level+(angry*3));
1007 } 1006 }
1008 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,op, 1007 new_draw_info_format(NDI_UNIQUE|NDI_NAVY,0,op,
1009 "%s becomes angry and punishes you!",god->name); 1008 "%s becomes angry and punishes you!",&god->name);
1010 } 1009 }
1011 return reaction; 1010 return reaction;
1012} 1011}
1013 1012
1014/** 1013/**
1023 1022
1024 if(!god||!item) return 0; 1023 if(!god||!item) return 0;
1025 1024
1026 if(!item->title) return 1; /* unclaimed item are ok */ 1025 if(!item->title) return 1; /* unclaimed item are ok */
1027 1026
1028 sprintf(buf,"of %s",god->name); 1027 sprintf(buf,"of %s",&god->name);
1029 if(!strcmp(item->title,buf)) return 1; /* belongs to that God */ 1028 if(!strcmp(item->title,buf)) return 1; /* belongs to that God */
1030 1029
1031 if(god->title) { /* check if we have any enemy blessed item*/ 1030 if(god->title) { /* check if we have any enemy blessed item*/
1032 sprintf(buf,"of %s",god->title); 1031 sprintf(buf,"of %s", &god->title);
1033 if(!strcmp(item->title,buf)) { 1032 if(!strcmp(item->title,buf)) {
1034 if(item->env) { 1033 if(item->env) {
1035 char buf[MAX_BUF]; 1034 char buf[MAX_BUF];
1036 sprintf(buf,"Heretic! You are using %s!",query_name(item)); 1035 sprintf(buf,"Heretic! You are using %s!",query_name(item));
1037 new_draw_info(NDI_UNIQUE|NDI_NAVY,0,item->env,buf); 1036 new_draw_info(NDI_UNIQUE|NDI_NAVY,0,item->env,buf);
1101 return 0; 1100 return 0;
1102 } 1101 }
1103 1102
1104 /* either holy word or godpower attacks will set the slaying field */ 1103 /* either holy word or godpower attacks will set the slaying field */
1105 if (spellop->attacktype & AT_HOLYWORD || spellop->attacktype & AT_GODPOWER) { 1104 if (spellop->attacktype & AT_HOLYWORD || spellop->attacktype & AT_GODPOWER) {
1106 if (spellop->slaying) { 1105 if (spellop->slaying)
1107 free_string(spellop->slaying);
1108 spellop->slaying = NULL; 1106 spellop->slaying = NULL;
1109 } 1107
1110 if(!caster_is_spell) 1108 if(!caster_is_spell)
1111 spellop->slaying = add_string(god->slaying); 1109 spellop->slaying = god->slaying;
1112 else if(caster->slaying) 1110 else if(caster->slaying)
1113 spellop->slaying = add_string(caster->slaying); 1111 spellop->slaying = caster->slaying;
1114 } 1112 }
1115 1113
1116 /* only the godpower attacktype adds the god's attack onto the spell */ 1114 /* only the godpower attacktype adds the god's attack onto the spell */
1117 if(spellop->attacktype & AT_GODPOWER) 1115 if(spellop->attacktype & AT_GODPOWER)
1118 spellop->attacktype=spellop->attacktype|god->attacktype; 1116 spellop->attacktype=spellop->attacktype|god->attacktype;
1119 1117
1120 /* tack on the god's name to the spell */ 1118 /* tack on the god's name to the spell */
1121 if(spellop->attacktype&AT_HOLYWORD||spellop->attacktype&AT_GODPOWER) { 1119 if(spellop->attacktype&AT_HOLYWORD||spellop->attacktype&AT_GODPOWER) {
1122 if(spellop->title)
1123 free_string(spellop->title);
1124 spellop->title=add_string(god->name); 1120 spellop->title = god->name;
1125 if(spellop->title){ 1121 if(spellop->title){
1126 char buf[MAX_BUF]; 1122 char buf[MAX_BUF];
1127 sprintf(buf,"%s of %s",spellop->name,spellop->title); 1123 sprintf(buf,"%s of %s",&spellop->name, &spellop->title);
1128 FREE_AND_COPY(spellop->name, buf); 1124 spellop->name = spellop->name_pl = buf;
1129 FREE_AND_COPY(spellop->name_pl, buf);
1130 } 1125 }
1131 } 1126 }
1132 1127
1133 return 1; 1128 return 1;
1134} 1129}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines