… | |
… | |
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 | */ |
303 | static void |
303 | static inline void |
304 | update_priest_flag (object *god, object *exp_ob, uint32 flag) |
304 | update_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 | */ |
356 | void |
359 | void |
357 | become_follower (object *op, object *new_god) |
360 | object::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 && race.contains (new_god->slaying)) |
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 = get_archetype (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 | |
520 | archetype * |
529 | archetype * |
521 | determine_holy_arch (object *god, shstr_cmp type) |
530 | determine_holy_arch (object *god, shstr_cmp type) |
522 | { |
531 | { |
… | |
… | |
977 | return; |
986 | return; |
978 | |
987 | |
979 | /* hmm. what happend depends on pl's current god, level, etc */ |
988 | /* hmm. what happend depends on pl's current god, level, etc */ |
980 | if (!pl_god) |
989 | if (!pl_god) |
981 | { /*new convert */ |
990 | { /*new convert */ |
982 | become_follower (pl, altar->other_arch); |
991 | pl->become_follower (altar->other_arch); |
983 | return; |
992 | return; |
984 | } |
993 | } |
985 | else if (pl_god->name == altar->other_arch->object::name) |
994 | else if (pl_god->name == altar->other_arch->object::name) |
986 | { |
995 | { |
987 | /* pray at your gods altar */ |
996 | /* pray at your gods altar */ |
… | |
… | |
1047 | |
1056 | |
1048 | /* 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 |
1049 | * note it gets harder to swap gods the higher we get |
1058 | * note it gets harder to swap gods the higher we get |
1050 | */ |
1059 | */ |
1051 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
1060 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
1052 | become_follower (pl, altar->other_arch); |
1061 | pl->become_follower (altar->other_arch); |
1053 | else |
1062 | else |
1054 | { |
1063 | { |
1055 | /* toss this player off the altar. He can try again. */ |
1064 | /* 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."); |
1065 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); |
1057 | pl->contr->fire_on = 0; |
1066 | pl->contr->fire_on = 0; |