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.61 by root, Tue Apr 13 21:23:49 2010 UTC vs.
Revision 1.62 by root, Tue Apr 13 22:05:42 2010 UTC

355 * 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
356 * that happen to the player, including the removal of godgiven 356 * that happen to the player, including the removal of godgiven
357 * items (from the former cult). 357 * items (from the former cult).
358 */ 358 */
359void 359void
360become_follower (object *op, object *new_god) 360object::become_follower (object *new_god)
361{ 361{
362 object *old_god = NULL; /* old god */ 362 object *old_god = 0; /* old god */
363 treasure *tr; 363 treasure *tr;
364 object *item, *skop, *next; 364 object *item, *skop, *next;
365 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. */
366 366
367 if (!contr)
368 return;
369
370 contr->queue_stats_update ();
371
367 old_god = find_god (determine_god (op)); 372 old_god = find_god (determine_god (this));
368 373
369 /* take away any special god-characteristic items. */ 374 /* take away any special god-characteristic items. */
370 for (item = op->inv; item; item = next) 375 for (item = inv; item; item = next)
371 { 376 {
372 next = item->below; 377 next = item->below;
373 378
374 // 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
375 if (item->flag [FLAG_STARTEQUIP] && item->invisible && 380 if (item->flag [FLAG_STARTEQUIP] && item->invisible
376 (item->type != SKILL) && (item->type != FORCE)) 381 && item->type != SKILL && item->type != FORCE)
377 { 382 {
378 if (item->type == SPELL) 383 if (item->type == SPELL)
379 { 384 {
380 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);
381 esrv_remove_spell (op->contr, item); 386 esrv_remove_spell (contr, item);
382 } 387 }
383 388
384 item->destroy (); 389 item->destroy ();
385 } 390 }
386 } 391 }
387 392
388 /* remove any godgiven items from the old god */ 393 /* remove any godgiven items from the old god */
389 if (old_god) 394 if (old_god)
390 for (tr = old_god->randomitems->items; tr; tr = tr->next) 395 for (tr = old_god->randomitems->items; tr; tr = tr->next)
391 if (tr->item && tr->item->flag [FLAG_STARTEQUIP]) 396 if (tr->item && tr->item->flag [FLAG_STARTEQUIP])
392 follower_remove_similar_item (op, tr->item); 397 follower_remove_similar_item (this, tr->item);
393 398
394 if (!op || !new_god) 399 if (!new_god)
395 return; 400 return;
396 401
397 if (new_god->slaying && op->race.contains (new_god->slaying)) 402 if (new_god->slaying && race.contains (new_god->slaying))
398 { 403 {
399 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);
400 405
401 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) 406 if (random_roll (0, level - 1, this, PREFER_LOW) - 5 > 0)
402 { 407 {
403 object *tmp = get_archetype (LOOSE_MANA); 408 object *tmp = get_archetype (LOOSE_MANA);
404 409
405 cast_magic_storm (op, tmp, new_god->level + 10); 410 cast_magic_storm (this, tmp, new_god->level + 10);
406 } 411 }
407 412
408 return; 413 return;
409 } 414 }
410 415
411 /* give the player any special god-characteristic-items. */ 416 /* give the player any special god-characteristic-items. */
412 for (tr = new_god->randomitems->items; tr; tr = tr->next) 417 for (tr = new_god->randomitems->items; tr; tr = tr->next)
413 {
414 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK 418 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK
415 && tr->item->type != BOOK && tr->item->type != SPELL) 419 && tr->item->type != BOOK && tr->item->type != SPELL)
416 god_gives_present (op, new_god, tr); 420 god_gives_present (this, new_god, tr);
417 }
418 421
419 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);
420 423
421 for (skop = op->inv; skop; skop = skop->below) 424 for (skop = inv; skop; skop = skop->below)
422 if (skop->type == SKILL && skop->subtype == SK_PRAYING) 425 if (skop->type == SKILL && skop->subtype == SK_PRAYING)
423 break; 426 break;
424 427
425 /* Player has no skill - give them the skill */ 428 /* Player has no skill - give them the skill */
426 if (!skop) 429 if (!skop)
427 /* 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,
428 * things are really messed up anyways. 431 * things are really messed up anyways.
429 */ 432 */
430 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill); 433 skop = give_skill_by_name (this, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill);
431 434
432 sk_applied = skop->flag [FLAG_APPLIED]; /* save skill status */ 435 sk_applied = skop->flag [FLAG_APPLIED]; /* save skill status */
433 436
434 /* 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,
435 * so I set undeadified for that. 438 * so I set undeadified for that.
442 } 445 }
443 446
444 if (skop->title) 447 if (skop->title)
445 { 448 {
446 /* get rid of old god */ 449 /* get rid of old god */
447 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);
448 451
449 /* 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 */
450 if (sk_applied || undeadified) 453 if (sk_applied || undeadified)
451 { 454 {
452 skop->clr_flag (FLAG_APPLIED); 455 skop->clr_flag (FLAG_APPLIED);
453 change_abil (op, skop); 456 change_abil (this, skop);
454 } 457 }
455 } 458 }
456 459
457 /* now change to the new gods attributes to exp_obj */ 460 /* now change to the new gods attributes to exp_obj */
458 skop->title = new_god->name; 461 skop->title = new_god->name;
482 update_priest_flag (new_god, skop, FLAG_MAKE_INVIS); 485 update_priest_flag (new_god, skop, FLAG_MAKE_INVIS);
483 update_priest_flag (new_god, skop, FLAG_UNDEAD); 486 update_priest_flag (new_god, skop, FLAG_UNDEAD);
484 update_priest_flag (new_god, skop, FLAG_BLIND); 487 update_priest_flag (new_god, skop, FLAG_BLIND);
485 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! */
486 489
487 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);
488 491
489 /* 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
490 * 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
491 * have used armour/weapons in the first place. 494 * have used armour/weapons in the first place.
492 * 495 *
493 * 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
494 * 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.
495 */ 498 */
496 if (!present_in_ob_by_name (FORCE, "no weapon force", op)) 499 if (!present_in_ob_by_name (FORCE, "no weapon force", this))
497 update_priest_flag (new_god, skop, FLAG_USE_WEAPON); 500 update_priest_flag (new_god, skop, FLAG_USE_WEAPON);
498 501
499 update_priest_flag (new_god, skop, FLAG_USE_ARMOUR); 502 update_priest_flag (new_god, skop, FLAG_USE_ARMOUR);
500 503
501 if (worship_forbids_use (op, skop, FLAG_USE_WEAPON, "weapons")) 504 if (worship_forbids_use (this, skop, FLAG_USE_WEAPON, "weapons"))
502 stop_using_item (op, WEAPON, 2); 505 stop_using_item (this, WEAPON, 2);
503 506
504 if (worship_forbids_use (op, skop, FLAG_USE_ARMOUR, "armour")) 507 if (worship_forbids_use (this, skop, FLAG_USE_ARMOUR, "armour"))
505 { 508 {
506 stop_using_item (op, ARMOUR, 1); 509 stop_using_item (this, ARMOUR, 1);
507 stop_using_item (op, HELMET, 1); 510 stop_using_item (this, HELMET, 1);
508 stop_using_item (op, BOOTS, 1); 511 stop_using_item (this, BOOTS, 1);
509 stop_using_item (op, GLOVES, 1); 512 stop_using_item (this, GLOVES, 1);
510 stop_using_item (op, SHIELD, 1); 513 stop_using_item (this, SHIELD, 1);
511 } 514 }
512 515
513 skop->set_flag (FLAG_APPLIED); 516 skop->set_flag (FLAG_APPLIED);
514 change_abil (op, skop); 517 change_abil (this, skop);
515 518
516 /* return to previous skill status */ 519 /* return to previous skill status */
517 if (!sk_applied) 520 if (!sk_applied)
521 {
518 skop->clr_flag (FLAG_APPLIED); 522 skop->clr_flag (FLAG_APPLIED);
523 contr->queue_stats_update ();
524 }
519 525
520 check_special_prayers (op, new_god); 526 check_special_prayers (this, new_god);
521} 527}
522 528
523archetype * 529archetype *
524determine_holy_arch (object *god, shstr_cmp type) 530determine_holy_arch (object *god, shstr_cmp type)
525{ 531{
980 return; 986 return;
981 987
982 /* hmm. what happend depends on pl's current god, level, etc */ 988 /* hmm. what happend depends on pl's current god, level, etc */
983 if (!pl_god) 989 if (!pl_god)
984 { /*new convert */ 990 { /*new convert */
985 become_follower (pl, altar->other_arch); 991 pl->become_follower (altar->other_arch);
986 return; 992 return;
987 } 993 }
988 else if (pl_god->name == altar->other_arch->object::name) 994 else if (pl_god->name == altar->other_arch->object::name)
989 { 995 {
990 /* pray at your gods altar */ 996 /* pray at your gods altar */
1050 1056
1051 /* May switch Gods, but its random chance based on our current level 1057 /* May switch Gods, but its random chance based on our current level
1052 * note it gets harder to swap gods the higher we get 1058 * note it gets harder to swap gods the higher we get
1053 */ 1059 */
1054 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) 1060 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
1055 become_follower (pl, altar->other_arch); 1061 pl->become_follower (altar->other_arch);
1056 else 1062 else
1057 { 1063 {
1058 /* toss this player off the altar. He can try again. */ 1064 /* toss this player off the altar. He can try again. */
1059 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); 1065 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar.");
1060 pl->contr->fire_on = 0; 1066 pl->contr->fire_on = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines