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.60 by root, Sun Apr 11 00:34:06 2010 UTC vs.
Revision 1.72 by root, Wed Nov 16 23:42:02 2016 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the Affero GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and 25/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and
26 * monster race initialization. b.t. 26 * monster race initialization. b.t.
298/** 298/**
299 * If the god does/doesnt have this flag, we 299 * If the god does/doesnt have this flag, we
300 * give/remove it from the experience object if it doesnt/does 300 * give/remove it from the experience object if it doesnt/does
301 * already exist. For players only! 301 * already exist. For players only!
302 */ 302 */
303static void 303static inline void
304update_priest_flag (object *god, object *exp_ob, uint32 flag) 304update_priest_flag (object *god, object *exp_ob, uint32 flag)
305{ 305{
306 exp_ob->flag [flag] = god->flag [flag];
307 return;
308
309 // old code follows for reference...
306 if (god->flag [flag] && !exp_ob->flag [flag]) 310 if (god->flag [flag] && !exp_ob->flag [flag])
307 exp_ob->flag [flag]; 311 exp_ob->set_flag (flag);
308 else if (exp_ob->flag [flag] && !god->flag [flag]) 312 else if (exp_ob->flag [flag] && !god->flag [flag])
309 { 313 {
310 /* When this is called with the exp_ob set to the player, 314 /* When this is called with the exp_ob set to the player,
311 * this check is broken, because most all players arch 315 * this check is broken, because most all players arch
312 * allow use of weapons. I'm not actually sure why this 316 * allow use of weapons. I'm not actually sure why this
313 * check is here - I guess if you had a case where the 317 * check is here - I guess if you had a case where the
314 * value in the archetype (wisdom) should over ride the restrictions 318 * value in the archetype (wisdom) should over ride the restrictions
315 * the god places on it, this may make sense. But I don't think 319 * the god places on it, this may make sense. But I don't think
316 * there is any case like that. 320 * there is any case like that.
317 */ 321 */
318
319/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ 322/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/
320 exp_ob->clr_flag (flag); 323 exp_ob->clr_flag (flag);
321 }; 324 };
322} 325}
323 326
352 * switched to a new god. It handles basically all the stat changes 355 * switched to a new god. It handles basically all the stat changes
353 * that happen to the player, including the removal of godgiven 356 * that happen to the player, including the removal of godgiven
354 * items (from the former cult). 357 * items (from the former cult).
355 */ 358 */
356void 359void
357become_follower (object *op, object *new_god) 360object::become_follower (object *new_god)
358{ 361{
359 object *old_god = NULL; /* old god */ 362 object *old_god = 0; /* old god */
360 treasure *tr; 363 treasure *tr;
361 object *item, *skop, *next; 364 object *item, *skop, *next;
362 int i, sk_applied, undeadified = 0; /* Turns to true if changing god can changes the undead status of the player. */ 365 int i, sk_applied, undeadified = 0; /* Turns to true if changing god can changes the undead status of the player. */
363 366
367 if (!contr)
368 return;
369
370 contr->queue_stats_update ();
371
364 old_god = find_god (determine_god (op)); 372 old_god = find_god (determine_god (this));
365 373
366 /* take away any special god-characteristic items. */ 374 /* take away any special god-characteristic items. */
367 for (item = op->inv; item; item = next) 375 for (item = inv; item; item = next)
368 { 376 {
369 next = item->below; 377 next = item->below;
370 378
371 // remove all invisible startequip items which are not skill, exp or force 379 // remove all invisible startequip items which are not skill, exp or force
372 if (item->flag [FLAG_STARTEQUIP] && item->invisible && 380 if (item->flag [FLAG_STARTEQUIP] && item->invisible
373 (item->type != SKILL) && (item->type != FORCE)) 381 && item->type != SKILL && item->type != FORCE)
374 { 382 {
375 if (item->type == SPELL) 383 if (item->type == SPELL)
376 { 384 {
377 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); 385 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, this, "You lose knowledge of %s.", &item->name);
378 esrv_remove_spell (op->contr, item); 386 esrv_remove_spell (contr, item);
379 } 387 }
380 388
381 item->destroy (); 389 item->destroy ();
382 } 390 }
383 } 391 }
384 392
385 /* remove any godgiven items from the old god */ 393 /* remove any godgiven items from the old god */
386 if (old_god) 394 if (old_god)
387 for (tr = old_god->randomitems->items; tr; tr = tr->next) 395 for (tr = old_god->randomitems->items; tr; tr = tr->next)
388 if (tr->item && tr->item->flag [FLAG_STARTEQUIP]) 396 if (tr->item && tr->item->flag [FLAG_STARTEQUIP])
389 follower_remove_similar_item (op, tr->item); 397 follower_remove_similar_item (this, tr->item);
390 398
391 if (!op || !new_god) 399 if (!new_god)
392 return; 400 return;
393 401
394 if (new_god->slaying && op->race.contains (new_god->slaying)) 402 if (new_god->slaying && new_god->slaying.contains (race))
395 { 403 {
396 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); 404 failmsgf ("Fool! %s detests your kind! H<This god does not accept followers of your race.>", &new_god->name);
397 405
398 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) 406 if (random_roll (0, level - 1, this, PREFER_LOW) - 5 > 0)
399 { 407 {
400 object *tmp = get_archetype (LOOSE_MANA); 408 object *tmp = archetype::get (LOOSE_MANA);
401 409
402 cast_magic_storm (op, tmp, new_god->level + 10); 410 cast_magic_storm (this, tmp, new_god->level + 10);
403 } 411 }
404 412
405 return; 413 return;
406 } 414 }
407 415
408 /* give the player any special god-characteristic-items. */ 416 /* give the player any special god-characteristic-items. */
409 for (tr = new_god->randomitems->items; tr; tr = tr->next) 417 for (tr = new_god->randomitems->items; tr; tr = tr->next)
410 {
411 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK 418 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK
412 && tr->item->type != BOOK && tr->item->type != SPELL) 419 && tr->item->type != BOOK && tr->item->type != SPELL)
413 god_gives_present (op, new_god, tr); 420 god_gives_present (this, new_god, tr);
414 }
415 421
416 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); 422 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, this, "You become a follower of %s!", &new_god->name);
417 423
418 for (skop = op->inv; skop; skop = skop->below) 424 for (skop = inv; skop; skop = skop->below)
419 if (skop->type == SKILL && skop->subtype == SK_PRAYING) 425 if (skop->type == SKILL && skop->subtype == SK_PRAYING)
420 break; 426 break;
421 427
422 /* Player has no skill - give them the skill */ 428 /* Player has no skill - give them the skill */
423 if (!skop) 429 if (!skop)
424 /* The archetype should always be defined - if we crash here because it doesn't, 430 /* The archetype should always be defined - if we crash here because it doesn't,
425 * things are really messed up anyways. 431 * things are really messed up anyways.
426 */ 432 */
427 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill); 433 skop = give_skill_by_name (this, shstr_praying);
428 434
429 sk_applied = skop->flag [FLAG_APPLIED]; /* save skill status */ 435 sk_applied = skop->flag [FLAG_APPLIED]; /* save skill status */
430 436
431 /* Clear the "undead" status. We also need to force a call to change_abil, 437 /* Clear the "undead" status. We also need to force a call to change_abil,
432 * so I set undeadified for that. 438 * so I set undeadified for that.
439 } 445 }
440 446
441 if (skop->title) 447 if (skop->title)
442 { 448 {
443 /* get rid of old god */ 449 /* get rid of old god */
444 new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title); 450 new_draw_info_format (NDI_UNIQUE, 0, this, "%s's blessing is withdrawn from you.", &skop->title);
445 451
446 /* The point of this is to really show what abilities the player just lost */ 452 /* The point of this is to really show what abilities the player just lost */
447 if (sk_applied || undeadified) 453 if (sk_applied || undeadified)
448 { 454 {
449 skop->clr_flag (FLAG_APPLIED); 455 skop->clr_flag (FLAG_APPLIED);
450 change_abil (op, skop); 456 change_abil (this, skop);
451 } 457 }
452 } 458 }
453 459
454 /* now change to the new gods attributes to exp_obj */ 460 /* now change to the new gods attributes to exp_obj */
455 skop->title = new_god->name; 461 skop->title = new_god->name;
479 update_priest_flag (new_god, skop, FLAG_MAKE_INVIS); 485 update_priest_flag (new_god, skop, FLAG_MAKE_INVIS);
480 update_priest_flag (new_god, skop, FLAG_UNDEAD); 486 update_priest_flag (new_god, skop, FLAG_UNDEAD);
481 update_priest_flag (new_god, skop, FLAG_BLIND); 487 update_priest_flag (new_god, skop, FLAG_BLIND);
482 update_priest_flag (new_god, skop, FLAG_XRAYS); /* better have this if blind! */ 488 update_priest_flag (new_god, skop, FLAG_XRAYS); /* better have this if blind! */
483 489
484 new_draw_info_format (NDI_UNIQUE, 0, op, "You are bathed in %s's aura.", &new_god->name); 490 new_draw_info_format (NDI_UNIQUE, 0, this, "You are bathed in %s's aura.", &new_god->name);
485 491
486 /* Weapon/armour use are special...handle flag toggles here as this can 492 /* Weapon/armour use are special...handle flag toggles here as this can
487 * only happen when gods are worshipped and if the new priest could 493 * only happen when gods are worshipped and if the new priest could
488 * have used armour/weapons in the first place. 494 * have used armour/weapons in the first place.
489 * 495 *
490 * This also can happen for monks which cannot use weapons. In this case 496 * This also can happen for monks which cannot use weapons. In this case
491 * do not allow to use weapons even if the god otherwise would allow it. 497 * do not allow to use weapons even if the god otherwise would allow it.
492 */ 498 */
493 if (!present_in_ob_by_name (FORCE, "no weapon force", op)) 499 if (!present_in_ob_by_name (FORCE, "no weapon force", this))
494 update_priest_flag (new_god, skop, FLAG_USE_WEAPON); 500 update_priest_flag (new_god, skop, FLAG_USE_WEAPON);
495 501
496 update_priest_flag (new_god, skop, FLAG_USE_ARMOUR); 502 update_priest_flag (new_god, skop, FLAG_USE_ARMOUR);
497 503
498 if (worship_forbids_use (op, skop, FLAG_USE_WEAPON, "weapons")) 504 if (worship_forbids_use (this, skop, FLAG_USE_WEAPON, "weapons"))
499 stop_using_item (op, WEAPON, 2); 505 stop_using_item (this, WEAPON, 2);
500 506
501 if (worship_forbids_use (op, skop, FLAG_USE_ARMOUR, "armour")) 507 if (worship_forbids_use (this, skop, FLAG_USE_ARMOUR, "armour"))
502 { 508 {
503 stop_using_item (op, ARMOUR, 1); 509 stop_using_item (this, ARMOUR, 1);
504 stop_using_item (op, HELMET, 1); 510 stop_using_item (this, HELMET, 1);
505 stop_using_item (op, BOOTS, 1); 511 stop_using_item (this, BOOTS, 1);
506 stop_using_item (op, GLOVES, 1); 512 stop_using_item (this, GLOVES, 1);
507 stop_using_item (op, SHIELD, 1); 513 stop_using_item (this, SHIELD, 1);
508 } 514 }
509 515
510 skop->set_flag (FLAG_APPLIED); 516 skop->set_flag (FLAG_APPLIED);
511 change_abil (op, skop); 517 change_abil (this, skop);
512 518
513 /* return to previous skill status */ 519 /* return to previous skill status */
514 if (!sk_applied) 520 if (!sk_applied)
521 {
515 skop->clr_flag (FLAG_APPLIED); 522 skop->clr_flag (FLAG_APPLIED);
523 contr->queue_stats_update ();
524 }
516 525
517 check_special_prayers (op, new_god); 526 check_special_prayers (this, new_god);
518} 527}
519 528
520archetype * 529archetype *
521determine_holy_arch (object *god, shstr_cmp type) 530determine_holy_arch (object *god, shstr_cmp type)
522{ 531{
642 * attacktype, slaying and such. 651 * attacktype, slaying and such.
643 */ 652 */
644static int 653static int
645god_enchants_weapon (object *op, object *god, object *tr, object *skill) 654god_enchants_weapon (object *op, object *god, object *tr, object *skill)
646{ 655{
647 object *weapon; 656 if (!op->contr)
648 uint32 attacktype; 657 return 0;
649 int tmp;
650 658
651 for (weapon = op->inv; weapon; weapon = weapon->below) 659 object *weapon = op->contr->combat_ob;
652 if ((weapon->type == WEAPON || weapon->type == BOW) && weapon->flag [FLAG_APPLIED])
653 break;
654 660
661 if (!weapon)
662 return 0;
663
664 if (weapon->type != WEAPON && weapon->type != BOW)
665 return 0;
666
655 if (!weapon || god_examines_item (god, weapon) <= 0) 667 if (god_examines_item (god, weapon) <= 0)
656 return 0; 668 return 0;
657 669
658 /* First give it a title, so other gods won't touch it */ 670 /* First give it a title, so other gods won't touch it */
659 if (!weapon->title) 671 if (!weapon->title)
660 { 672 {
673 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s now hungers to slay enemies of your god!", &weapon->name); 685 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s now hungers to slay enemies of your god!", &weapon->name);
674 return 1; 686 return 1;
675 } 687 }
676 688
677 /* Add the gods attacktype */ 689 /* Add the gods attacktype */
678 attacktype = (weapon->attacktype == 0) ? AT_PHYSICAL : weapon->attacktype; 690 uint32 attacktype = (weapon->attacktype == 0) ? AT_PHYSICAL : weapon->attacktype;
691
679 if ((attacktype & god->attacktype) != god->attacktype) 692 if ((attacktype & god->attacktype) != god->attacktype)
680 { 693 {
681 new_draw_info (NDI_UNIQUE, 0, op, "Your weapon suddenly glows!"); 694 new_draw_info (NDI_UNIQUE, 0, op, "Your weapon suddenly glows!");
682 weapon->attacktype = attacktype | god->attacktype; 695 weapon->attacktype = attacktype | god->attacktype;
683 return 1; 696 return 1;
684 } 697 }
685 698
686 /* Higher magic value */ 699 /* Higher magic value */
687 tmp = follower_level_to_enchantments (skill->level, tr->level); 700 if (weapon->magic < follower_level_to_enchantments (skill->level, tr->level))
688 if (weapon->magic < tmp)
689 { 701 {
690 new_draw_info (NDI_UNIQUE, 0, op, "A phosphorescent glow envelops your weapon!"); 702 new_draw_info (NDI_UNIQUE, 0, op, "A phosphorescent glow envelops your weapon!");
691 weapon->magic++; 703 weapon->magic++;
692 704
693 if (object *pl = weapon->visible_to ()) 705 if (object *pl = weapon->visible_to ())
725 break; 737 break;
726 738
727 if (skop) 739 if (skop)
728 loss = 0.05f * skop->stats.exp; 740 loss = 0.05f * skop->stats.exp;
729 741
730 change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? &skop->skill : "none", SK_SUBTRACT_SKILL_EXP); 742 change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? skop->skill : shstr_none, SK_SUBTRACT_SKILL_EXP);
731 743
732 if (random_roll (0, angry, op, PREFER_LOW)) 744 if (random_roll (0, angry, op, PREFER_LOW))
733 { 745 {
734 object *tmp = get_archetype (LOOSE_MANA); 746 object *tmp = archetype::get (LOOSE_MANA);
735 747
736 cast_magic_storm (op, tmp, op->level + (angry * 3)); 748 cast_magic_storm (op, tmp, op->level + (angry * 3));
737 } 749 }
738 750
739 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name); 751 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name);
800 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) 812 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace)
801 { 813 {
802 /* Follower lacks the required grace for the following 814 /* Follower lacks the required grace for the following
803 * treasure list items. */ 815 * treasure list items. */
804 816
805 object *tmp = get_archetype (HOLY_POSSESSION); 817 object *tmp = archetype::get (HOLY_POSSESSION);
806 cast_change_ability (op, op, tmp, 0, 1); 818 cast_change_ability (op, op, tmp, 0, 1);
807 tmp->destroy (); 819 tmp->destroy ();
808 return; 820 return;
809 } 821 }
810 822
977 return; 989 return;
978 990
979 /* hmm. what happend depends on pl's current god, level, etc */ 991 /* hmm. what happend depends on pl's current god, level, etc */
980 if (!pl_god) 992 if (!pl_god)
981 { /*new convert */ 993 { /*new convert */
982 become_follower (pl, altar->other_arch); 994 pl->become_follower (altar->other_arch);
983 return; 995 return;
984 } 996 }
985 else if (pl_god->name == altar->other_arch->object::name) 997 else if (pl_god->name == altar->other_arch->object::name)
986 { 998 {
987 /* pray at your gods altar */ 999 /* pray at your gods altar */
1026 object *tmp; 1038 object *tmp;
1027 1039
1028 /* you really screwed up */ 1040 /* you really screwed up */
1029 angry = 3; 1041 angry = 3;
1030 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foul Priest! %s punishes you!", &pl_god->name); 1042 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foul Priest! %s punishes you!", &pl_god->name);
1031 tmp = get_archetype (LOOSE_MANA); 1043 tmp = archetype::get (LOOSE_MANA);
1032 cast_magic_storm (pl, tmp, pl_god->level + 20); 1044 cast_magic_storm (pl, tmp, pl_god->level + 20);
1033 } 1045 }
1034 else 1046 else
1035 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foolish heretic! %s is livid!", &pl_god->name); 1047 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foolish heretic! %s is livid!", &pl_god->name);
1036 } 1048 }
1041 * we lose experience from the clerical experience obj 1053 * we lose experience from the clerical experience obj
1042 */ 1054 */
1043 1055
1044 loss = angry * (skill->stats.exp / 10); 1056 loss = angry * (skill->stats.exp / 10);
1045 if (loss) 1057 if (loss)
1046 change_exp (pl, -random_roll64 (0, loss, pl, PREFER_LOW), skill ? &skill->skill : "none", SK_SUBTRACT_SKILL_EXP); 1058 change_exp (pl, -random_roll64 (0, loss, pl, PREFER_LOW), skill ? skill->skill : shstr_none, SK_SUBTRACT_SKILL_EXP);
1047 1059
1048 /* May switch Gods, but its random chance based on our current level 1060 /* May switch Gods, but its random chance based on our current level
1049 * note it gets harder to swap gods the higher we get 1061 * note it gets harder to swap gods the higher we get
1050 */ 1062 */
1051 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) 1063 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
1052 become_follower (pl, altar->other_arch); 1064 pl->become_follower (altar->other_arch);
1053 else 1065 else
1054 { 1066 {
1055 /* toss this player off the altar. He can try again. */ 1067 /* toss this player off the altar. He can try again. */
1056 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); 1068 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar.");
1057 pl->contr->fire_on = 0; 1069 pl->contr->fire_on = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines