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.53 by root, Sat Nov 7 18:30:06 2009 UTC vs.
Revision 1.74 by root, Sat Nov 17 23:40:03 2018 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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * 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 10 * 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 11 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 12 * option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 * 18 *
18 * You should have received a copy of the Affero GNU General Public License 19 * 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 20 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 21 * <http://www.gnu.org/licenses/>.
21 * 22 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 23 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 24 */
24 25
25/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and 26/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and
26 * monster race initialization. b.t. 27 * monster race initialization. b.t.
62 63
63 return 0; 64 return 0;
64} 65}
65 66
66/** 67/**
67 * Returns a string that is the name of the god that should be natively worshipped by a 68 * Returns a string that is the name of the god that should be natively worshipped by a
68 * creature of who has race *race 69 * creature of who has race *race
69 * if we can't find a god that is appropriate, we return NULL 70 * if we can't find a god that is appropriate, we return NULL
70 */ 71 */
71static shstr_tmp 72static shstr_tmp
72get_god_for_race (shstr_cmp race) 73get_god_for_race (shstr_cmp race)
80} 81}
81 82
82/** 83/**
83 * Determines if op worships a god. 84 * Determines if op worships a god.
84 * Returns the godname if they do or "none" if they have no god. 85 * Returns the godname if they do or "none" if they have no god.
85 * In the case of an NPC, if they have no god, we try and guess 86 * In the case of an NPC, if they have no god, we try and guess
86 * who they should worship based on their race. If that fails we 87 * who they should worship based on their race. If that fails we
87 * give them a random one. 88 * give them a random one.
88 */ 89 */
89shstr_tmp 90shstr_tmp
90determine_god (object *op) 91determine_god (object *op)
91{ 92{
214 return 0; 215 return 0;
215 216
216 if (follower_has_similar_item (op, tr->item)) 217 if (follower_has_similar_item (op, tr->item))
217 return 0; 218 return 0;
218 219
219 object *tmp = arch_to_object (tr->item); 220 object *tmp = tr->item->instance ();
220 new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); 221 new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp));
221 op->insert (tmp); 222 op->insert (tmp);
222 223
223 return 1; 224 return 1;
224} 225}
242 next_tmp = tmp->below; 243 next_tmp = tmp->below;
243 244
244 /* we mark special prayers with the STARTEQUIP flag, so if it isn't 245 /* we mark special prayers with the STARTEQUIP flag, so if it isn't
245 * in that category, not something we need to worry about. 246 * in that category, not something we need to worry about.
246 */ 247 */
247 if (tmp->type != SPELL || !QUERY_FLAG (tmp, FLAG_STARTEQUIP)) 248 if (tmp->type != SPELL || !tmp->flag [FLAG_STARTEQUIP])
248 continue; 249 continue;
249 250
250 if (god->randomitems == NULL) 251 if (god->randomitems == NULL)
251 { 252 {
252 LOG (llevError, "BUG: check_special_prayers(): god %s without randomitems\n", &god->name); 253 LOG (llevError, "BUG: check_special_prayers(): god %s without randomitems\n", &god->name);
285 * Unapplies up to number worth of items of type 286 * Unapplies up to number worth of items of type
286 */ 287 */
287static void 288static void
288stop_using_item (object *op, int type, int number) 289stop_using_item (object *op, int type, int number)
289{ 290{
290 object *tmp;
291
292 for (tmp = op->inv; tmp && number; tmp = tmp->below) 291 for (object *tmp = op->inv; tmp && number; tmp = tmp->below)
293 if (tmp->type == type && QUERY_FLAG (tmp, FLAG_APPLIED)) 292 if (tmp->type == type && tmp->flag [FLAG_APPLIED])
294 { 293 {
295 apply_special (op, tmp, AP_UNAPPLY | AP_IGNORE_CURSE); 294 op->apply (tmp, AP_UNAPPLY | AP_IGNORE_CURSE);
296 number--; 295 --number;
297 } 296 }
298} 297}
299 298
300/** 299/**
301 * If the god does/doesnt have this flag, we 300 * If the god does/doesnt have this flag, we
302 * give/remove it from the experience object if it doesnt/does 301 * give/remove it from the experience object if it doesnt/does
303 * already exist. For players only! 302 * already exist. For players only!
304 */ 303 */
305static void 304static inline void
306update_priest_flag (object *god, object *exp_ob, uint32 flag) 305update_priest_flag (object *god, object *exp_ob, uint32 flag)
307{ 306{
308 if (QUERY_FLAG (god, flag) && !QUERY_FLAG (exp_ob, flag)) 307 exp_ob->flag [flag] = god->flag [flag];
309 SET_FLAG (exp_ob, flag); 308 return;
310 else if (QUERY_FLAG (exp_ob, flag) && !QUERY_FLAG (god, flag)) 309
310 // old code follows for reference...
311 if (god->flag [flag] && !exp_ob->flag [flag])
312 exp_ob->set_flag (flag);
313 else if (exp_ob->flag [flag] && !god->flag [flag])
311 { 314 {
312 /* When this is called with the exp_ob set to the player, 315 /* When this is called with the exp_ob set to the player,
313 * this check is broken, because most all players arch 316 * this check is broken, because most all players arch
314 * allow use of weapons. I'm not actually sure why this 317 * allow use of weapons. I'm not actually sure why this
315 * check is here - I guess if you had a case where the 318 * check is here - I guess if you had a case where the
316 * value in the archetype (wisdom) should over ride the restrictions 319 * value in the archetype (wisdom) should over ride the restrictions
317 * the god places on it, this may make sense. But I don't think 320 * the god places on it, this may make sense. But I don't think
318 * there is any case like that. 321 * there is any case like that.
319 */ 322 */
320
321/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ 323/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/
322 CLEAR_FLAG (exp_ob, flag); 324 exp_ob->clr_flag (flag);
323 }; 325 };
324} 326}
325 327
326/** 328/**
327 * Forbids or let player use something item type. 329 * Forbids or let player use something item type.
331 * string is the string to print out. 333 * string is the string to print out.
332 */ 334 */
333static int 335static int
334worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) 336worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string)
335{ 337{
336 if (QUERY_FLAG (op->arch, flag)) 338 if (op->arch->flag [flag])
337 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) 339 if (op->flag [flag] != exp_obj->flag [flag])
338 { 340 {
339 update_priest_flag (exp_obj, op, flag); 341 update_priest_flag (exp_obj, op, flag);
340 if (QUERY_FLAG (op, flag)) 342 if (op->flag [flag])
341 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); 343 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string);
342 else 344 else
343 { 345 {
344 new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string); 346 new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string);
345 return 1; 347 return 1;
354 * switched to a new god. It handles basically all the stat changes 356 * switched to a new god. It handles basically all the stat changes
355 * that happen to the player, including the removal of godgiven 357 * that happen to the player, including the removal of godgiven
356 * items (from the former cult). 358 * items (from the former cult).
357 */ 359 */
358void 360void
359become_follower (object *op, object *new_god) 361object::become_follower (object *new_god)
360{ 362{
361 object *old_god = NULL; /* old god */ 363 object *old_god = 0; /* old god */
362 treasure *tr; 364 treasure *tr;
363 object *item, *skop, *next; 365 object *item, *skop, *next;
364 int i, sk_applied, undeadified = 0; /* Turns to true if changing god can changes the undead status of the player. */ 366 int i, sk_applied, undeadified = 0; /* Turns to true if changing god can changes the undead status of the player. */
365 367
368 if (!contr)
369 return;
370
371 contr->queue_stats_update ();
372
366 old_god = find_god (determine_god (op)); 373 old_god = find_god (determine_god (this));
367 374
368 /* take away any special god-characteristic items. */ 375 /* take away any special god-characteristic items. */
369 for (item = op->inv; item; item = next) 376 for (item = inv; item; item = next)
370 { 377 {
371 next = item->below; 378 next = item->below;
372 379
373 // remove all invisible startequip items which are not skill, exp or force 380 // remove all invisible startequip items which are not skill, exp or force
374 if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible && 381 if (item->flag [FLAG_STARTEQUIP] && item->invisible
375 (item->type != SKILL) && (item->type != FORCE)) 382 && item->type != SKILL && item->type != FORCE)
376 { 383 {
377 if (item->type == SPELL) 384 if (item->type == SPELL)
378 { 385 {
379 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); 386 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, this, "You lose knowledge of %s.", &item->name);
380 esrv_remove_spell (op->contr, item); 387 esrv_remove_spell (contr, item);
381 } 388 }
382 389
383 player_unready_range_ob (op->contr, item);
384 item->destroy (); 390 item->destroy ();
385 } 391 }
386 } 392 }
387 393
388 /* remove any godgiven items from the old god */ 394 /* remove any godgiven items from the old god */
389 if (old_god) 395 if (old_god)
390 for (tr = old_god->randomitems->items; tr; tr = tr->next) 396 for (tr = old_god->randomitems->items; tr; tr = tr->next)
391 if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP)) 397 if (tr->item && tr->item->flag [FLAG_STARTEQUIP])
392 follower_remove_similar_item (op, tr->item); 398 follower_remove_similar_item (this, tr->item);
393 399
394 if (!op || !new_god) 400 if (!new_god)
395 return; 401 return;
396 402
397 if (new_god->slaying && op->race.contains (new_god->slaying)) 403 if (new_god->slaying && new_god->slaying.contains (race))
398 { 404 {
399 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); 405 failmsgf ("Fool! %s detests your kind! H<This god does not accept followers of your race.>", &new_god->name);
400 406
401 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) 407 if (random_roll (0, level - 1, this, PREFER_LOW) - 5 > 0)
402 { 408 {
403 object *tmp = get_archetype (LOOSE_MANA); 409 object *tmp = archetype::get (LOOSE_MANA);
404 410
405 cast_magic_storm (op, tmp, new_god->level + 10); 411 cast_magic_storm (this, tmp, new_god->level + 10);
406 } 412 }
407 413
408 return; 414 return;
409 } 415 }
410 416
411 /* give the player any special god-characteristic-items. */ 417 /* give the player any special god-characteristic-items. */
412 for (tr = new_god->randomitems->items; tr; tr = tr->next) 418 for (tr = new_god->randomitems->items; tr; tr = tr->next)
413 {
414 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK 419 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK
415 && tr->item->type != BOOK && tr->item->type != SPELL) 420 && tr->item->type != BOOK && tr->item->type != SPELL)
416 god_gives_present (op, new_god, tr); 421 god_gives_present (this, new_god, tr);
417 }
418 422
419 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); 423 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, this, "You become a follower of %s!", &new_god->name);
420 424
421 for (skop = op->inv; skop; skop = skop->below) 425 for (skop = inv; skop; skop = skop->below)
422 if (skop->type == SKILL && skop->subtype == SK_PRAYING) 426 if (skop->type == SKILL && skop->subtype == SK_PRAYING)
423 break; 427 break;
424 428
425 /* Player has no skill - give them the skill */ 429 /* Player has no skill - give them the skill */
426 if (!skop) 430 if (!skop)
427 /* The archetype should always be defined - if we crash here because it doesn't, 431 /* The archetype should always be defined - if we crash here because it doesn't,
428 * things are really messed up anyways. 432 * things are really messed up anyways.
429 */ 433 */
430 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill); 434 skop = give_skill_by_name (this, shstr_praying);
431 435
432 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ 436 sk_applied = skop->flag [FLAG_APPLIED]; /* save skill status */
433 437
434 /* Clear the "undead" status. We also need to force a call to change_abil, 438 /* Clear the "undead" status. We also need to force a call to change_abil,
435 * so I set undeadified for that. 439 * so I set undeadified for that.
436 * - gros, 21th July 2006. 440 * - gros, 21th July 2006.
437 */ 441 */
438 if (old_god && QUERY_FLAG (old_god, FLAG_UNDEAD)) 442 if (old_god && old_god->flag [FLAG_UNDEAD])
439 { 443 {
440 CLEAR_FLAG (skop, FLAG_UNDEAD); 444 skop->clr_flag (FLAG_UNDEAD);
441 undeadified = 1; 445 undeadified = 1;
442 } 446 }
443 447
444 if (skop->title) 448 if (skop->title)
445 { 449 {
446 /* get rid of old god */ 450 /* get rid of old god */
447 new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title); 451 new_draw_info_format (NDI_UNIQUE, 0, this, "%s's blessing is withdrawn from you.", &skop->title);
448 452
449 /* The point of this is to really show what abilities the player just lost */ 453 /* The point of this is to really show what abilities the player just lost */
450 if (sk_applied || undeadified) 454 if (sk_applied || undeadified)
451 { 455 {
452 CLEAR_FLAG (skop, FLAG_APPLIED); 456 skop->clr_flag (FLAG_APPLIED);
453 change_abil (op, skop); 457 change_abil (this, skop);
454 } 458 }
455 } 459 }
456 460
457 /* now change to the new gods attributes to exp_obj */ 461 /* now change to the new gods attributes to exp_obj */
458 skop->title = new_god->name; 462 skop->title = new_god->name;
461 skop->path_denied = new_god->path_denied; 465 skop->path_denied = new_god->path_denied;
462 /* copy god's resistances */ 466 /* copy god's resistances */
463 memcpy (skop->resist, new_god->resist, sizeof (new_god->resist)); 467 memcpy (skop->resist, new_god->resist, sizeof (new_god->resist));
464 468
465 /* make sure that certain immunities do NOT get passed 469 /* make sure that certain immunities do NOT get passed
466 * to the follower! 470 * to the follower!
467 */ 471 */
468 for (i = 0; i < NROFATTACKS; i++) 472 for (i = 0; i < NROFATTACKS; i++)
469 if (skop->resist[i] > 30 && (i == ATNR_FIRE || i == ATNR_COLD || i == ATNR_ELECTRICITY || i == ATNR_POISON)) 473 if (skop->resist[i] > 30 && (i == ATNR_FIRE || i == ATNR_COLD || i == ATNR_ELECTRICITY || i == ATNR_POISON))
470 skop->resist[i] = 30; 474 skop->resist[i] = 30;
471 475
482 update_priest_flag (new_god, skop, FLAG_MAKE_INVIS); 486 update_priest_flag (new_god, skop, FLAG_MAKE_INVIS);
483 update_priest_flag (new_god, skop, FLAG_UNDEAD); 487 update_priest_flag (new_god, skop, FLAG_UNDEAD);
484 update_priest_flag (new_god, skop, FLAG_BLIND); 488 update_priest_flag (new_god, skop, FLAG_BLIND);
485 update_priest_flag (new_god, skop, FLAG_XRAYS); /* better have this if blind! */ 489 update_priest_flag (new_god, skop, FLAG_XRAYS); /* better have this if blind! */
486 490
487 new_draw_info_format (NDI_UNIQUE, 0, op, "You are bathed in %s's aura.", &new_god->name); 491 new_draw_info_format (NDI_UNIQUE, 0, this, "You are bathed in %s's aura.", &new_god->name);
488 492
489 /* Weapon/armour use are special...handle flag toggles here as this can 493 /* 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 494 * only happen when gods are worshipped and if the new priest could
491 * have used armour/weapons in the first place. 495 * have used armour/weapons in the first place.
492 * 496 *
493 * This also can happen for monks which cannot use weapons. In this case 497 * 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. 498 * do not allow to use weapons even if the god otherwise would allow it.
495 */ 499 */
496 if (!present_in_ob_by_name (FORCE, "no weapon force", op)) 500 if (!present_in_ob_by_name (FORCE, "no weapon force", this))
497 update_priest_flag (new_god, skop, FLAG_USE_WEAPON); 501 update_priest_flag (new_god, skop, FLAG_USE_WEAPON);
498 502
499 update_priest_flag (new_god, skop, FLAG_USE_ARMOUR); 503 update_priest_flag (new_god, skop, FLAG_USE_ARMOUR);
500 504
501 if (worship_forbids_use (op, skop, FLAG_USE_WEAPON, "weapons")) 505 if (worship_forbids_use (this, skop, FLAG_USE_WEAPON, "weapons"))
502 stop_using_item (op, WEAPON, 2); 506 stop_using_item (this, WEAPON, 2);
503 507
504 if (worship_forbids_use (op, skop, FLAG_USE_ARMOUR, "armour")) 508 if (worship_forbids_use (this, skop, FLAG_USE_ARMOUR, "armour"))
505 { 509 {
506 stop_using_item (op, ARMOUR, 1); 510 stop_using_item (this, ARMOUR, 1);
507 stop_using_item (op, HELMET, 1); 511 stop_using_item (this, HELMET, 1);
508 stop_using_item (op, BOOTS, 1); 512 stop_using_item (this, BOOTS, 1);
509 stop_using_item (op, GLOVES, 1); 513 stop_using_item (this, GLOVES, 1);
510 stop_using_item (op, SHIELD, 1); 514 stop_using_item (this, SHIELD, 1);
511 } 515 }
512 516
513 SET_FLAG (skop, FLAG_APPLIED); 517 skop->set_flag (FLAG_APPLIED);
514 (void) change_abil (op, skop); 518 change_abil (this, skop);
515 519
516 /* return to previous skill status */ 520 /* return to previous skill status */
517 if (!sk_applied) 521 if (!sk_applied)
518 CLEAR_FLAG (skop, FLAG_APPLIED); 522 {
523 skop->clr_flag (FLAG_APPLIED);
524 contr->queue_stats_update ();
525 }
519 526
520 check_special_prayers (op, new_god); 527 check_special_prayers (this, new_god);
521} 528}
522 529
523archetype * 530archetype *
524determine_holy_arch (object *god, shstr_cmp type) 531determine_holy_arch (object *god, shstr_cmp type)
525{ 532{
556 for (object *tmp = op->inv; tmp; tmp = tmp->below) 563 for (object *tmp = op->inv; tmp; tmp = tmp->below)
557 { 564 {
558 if (tmp->invisible) 565 if (tmp->invisible)
559 continue; 566 continue;
560 567
561 if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation) 568 if (tmp->flag [FLAG_DAMNED] && !remove_damnation)
562 continue; 569 continue;
563 570
564 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 571 if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED])
565 { 572 {
566 success = 1; 573 success = 1;
567 CLEAR_FLAG (tmp, FLAG_DAMNED); 574 tmp->clr_flag (FLAG_DAMNED);
568 CLEAR_FLAG (tmp, FLAG_CURSED); 575 tmp->clr_flag (FLAG_CURSED);
569 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); 576 tmp->clr_flag (FLAG_KNOWN_CURSED);
570 577
571 if (object *pl = tmp->visible_to ()) 578 if (object *pl = tmp->visible_to ())
572 esrv_update_item (UPD_FLAGS, pl, tmp); 579 esrv_update_item (UPD_FLAGS, pl, tmp);
573 } 580 }
574 } 581 }
645 * attacktype, slaying and such. 652 * attacktype, slaying and such.
646 */ 653 */
647static int 654static int
648god_enchants_weapon (object *op, object *god, object *tr, object *skill) 655god_enchants_weapon (object *op, object *god, object *tr, object *skill)
649{ 656{
650 object *weapon; 657 if (!op->contr)
651 uint32 attacktype; 658 return 0;
652 int tmp;
653 659
654 for (weapon = op->inv; weapon; weapon = weapon->below) 660 object *weapon = op->contr->combat_ob;
655 if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED))
656 break;
657 661
662 if (!weapon)
663 return 0;
664
665 if (weapon->type != WEAPON && weapon->type != BOW)
666 return 0;
667
658 if (!weapon || god_examines_item (god, weapon) <= 0) 668 if (god_examines_item (god, weapon) <= 0)
659 return 0; 669 return 0;
660 670
661 /* First give it a title, so other gods won't touch it */ 671 /* First give it a title, so other gods won't touch it */
662 if (!weapon->title) 672 if (!weapon->title)
663 { 673 {
676 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s now hungers to slay enemies of your god!", &weapon->name); 686 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s now hungers to slay enemies of your god!", &weapon->name);
677 return 1; 687 return 1;
678 } 688 }
679 689
680 /* Add the gods attacktype */ 690 /* Add the gods attacktype */
681 attacktype = (weapon->attacktype == 0) ? AT_PHYSICAL : weapon->attacktype; 691 uint32 attacktype = (weapon->attacktype == 0) ? AT_PHYSICAL : weapon->attacktype;
692
682 if ((attacktype & god->attacktype) != god->attacktype) 693 if ((attacktype & god->attacktype) != god->attacktype)
683 { 694 {
684 new_draw_info (NDI_UNIQUE, 0, op, "Your weapon suddenly glows!"); 695 new_draw_info (NDI_UNIQUE, 0, op, "Your weapon suddenly glows!");
685 weapon->attacktype = attacktype | god->attacktype; 696 weapon->attacktype = attacktype | god->attacktype;
686 return 1; 697 return 1;
687 } 698 }
688 699
689 /* Higher magic value */ 700 /* Higher magic value */
690 tmp = follower_level_to_enchantments (skill->level, tr->level); 701 if (weapon->magic < follower_level_to_enchantments (skill->level, tr->level))
691 if (weapon->magic < tmp)
692 { 702 {
693 new_draw_info (NDI_UNIQUE, 0, op, "A phosphorescent glow envelops your weapon!"); 703 new_draw_info (NDI_UNIQUE, 0, op, "A phosphorescent glow envelops your weapon!");
694 weapon->magic++; 704 weapon->magic++;
695 705
696 if (object *pl = weapon->visible_to ()) 706 if (object *pl = weapon->visible_to ())
712{ 722{
713 int reaction = 1; 723 int reaction = 1;
714 object *item = NULL, *skop; 724 object *item = NULL, *skop;
715 725
716 for (item = op->inv; item; item = item->below) 726 for (item = op->inv; item; item = item->below)
717 if (QUERY_FLAG (item, FLAG_APPLIED)) 727 if (item->flag [FLAG_APPLIED])
718 reaction += god_examines_item (god, item) * (item->magic ? abs (item->magic) : 1); 728 reaction += god_examines_item (god, item) * (item->magic ? abs (item->magic) : 1);
719 729
720 /* well, well. Looks like we screwed up. Time for god's revenge */ 730 /* well, well. Looks like we screwed up. Time for god's revenge */
721 if (reaction < 0) 731 if (reaction < 0)
722 { 732 {
728 break; 738 break;
729 739
730 if (skop) 740 if (skop)
731 loss = 0.05f * skop->stats.exp; 741 loss = 0.05f * skop->stats.exp;
732 742
733 change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? &skop->skill : "none", SK_SUBTRACT_SKILL_EXP); 743 change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? skop->skill : shstr_none, SK_SUBTRACT_SKILL_EXP);
734 744
735 if (random_roll (0, angry, op, PREFER_LOW)) 745 if (random_roll (0, angry, op, PREFER_LOW))
736 { 746 {
737 object *tmp = get_archetype (LOOSE_MANA); 747 object *tmp = archetype::get (LOOSE_MANA);
738 748
739 cast_magic_storm (op, tmp, op->level + (angry * 3)); 749 cast_magic_storm (op, tmp, op->level + (angry * 3));
740 } 750 }
741 751
742 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name); 752 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name);
745 return reaction; 755 return reaction;
746} 756}
747 757
748/** 758/**
749 * Every once in a while the god will intervene to help the worshiper. 759 * Every once in a while the god will intervene to help the worshiper.
750 * Later, this fctn can be used to supply quests, etc for the 760 * Later, this fctn can be used to supply quests, etc for the
751 * priest. -b.t. 761 * priest. -b.t.
752 * called from pray_at_altar() currently. 762 * called from pray_at_altar() currently.
753 */ 763 */
754static void 764static void
755god_intervention (object *op, object *god, object *skill) 765god_intervention (object *op, object *god, object *skill)
756{ 766{
757 treasure *tr; 767 treasure *tr;
803 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) 813 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace)
804 { 814 {
805 /* Follower lacks the required grace for the following 815 /* Follower lacks the required grace for the following
806 * treasure list items. */ 816 * treasure list items. */
807 817
808 object *tmp = get_archetype (HOLY_POSSESSION); 818 object *tmp = archetype::get (HOLY_POSSESSION);
809 cast_change_ability (op, op, tmp, 0, 1); 819 cast_change_ability (op, op, tmp, 0, 1);
810 tmp->destroy (); 820 tmp->destroy ();
811 return; 821 return;
812 } 822 }
813 823
980 return; 990 return;
981 991
982 /* hmm. what happend depends on pl's current god, level, etc */ 992 /* hmm. what happend depends on pl's current god, level, etc */
983 if (!pl_god) 993 if (!pl_god)
984 { /*new convert */ 994 { /*new convert */
985 become_follower (pl, altar->other_arch); 995 pl->become_follower (altar->other_arch);
986 return; 996 return;
987 } 997 }
988 else if (pl_god->name == altar->other_arch->object::name) 998 else if (pl_god->name == altar->other_arch->object::name)
989 { 999 {
990 /* pray at your gods altar */ 1000 /* pray at your gods altar */
1029 object *tmp; 1039 object *tmp;
1030 1040
1031 /* you really screwed up */ 1041 /* you really screwed up */
1032 angry = 3; 1042 angry = 3;
1033 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foul Priest! %s punishes you!", &pl_god->name); 1043 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foul Priest! %s punishes you!", &pl_god->name);
1034 tmp = get_archetype (LOOSE_MANA); 1044 tmp = archetype::get (LOOSE_MANA);
1035 cast_magic_storm (pl, tmp, pl_god->level + 20); 1045 cast_magic_storm (pl, tmp, pl_god->level + 20);
1036 } 1046 }
1037 else 1047 else
1038 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foolish heretic! %s is livid!", &pl_god->name); 1048 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foolish heretic! %s is livid!", &pl_god->name);
1039 } 1049 }
1040 else 1050 else
1041 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Heretic! %s is angered!", &pl_god->name); 1051 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Heretic! %s is angered!", &pl_god->name);
1042 1052
1043 /* whether we will be successfull in defecting or not - 1053 /* whether we will be successfull in defecting or not -
1044 * we lose experience from the clerical experience obj 1054 * we lose experience from the clerical experience obj
1045 */ 1055 */
1046 1056
1047 loss = angry * (skill->stats.exp / 10); 1057 loss = angry * (skill->stats.exp / 10);
1048 if (loss) 1058 if (loss)
1049 change_exp (pl, -random_roll64 (0, loss, pl, PREFER_LOW), skill ? &skill->skill : "none", SK_SUBTRACT_SKILL_EXP); 1059 change_exp (pl, -random_roll64 (0, loss, pl, PREFER_LOW), skill ? skill->skill : shstr_none, SK_SUBTRACT_SKILL_EXP);
1050 1060
1051 /* May switch Gods, but its random chance based on our current level 1061 /* May switch Gods, but its random chance based on our current level
1052 * note it gets harder to swap gods the higher we get 1062 * note it gets harder to swap gods the higher we get
1053 */ 1063 */
1054 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) 1064 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
1055 become_follower (pl, altar->other_arch); 1065 pl->become_follower (altar->other_arch);
1056 else 1066 else
1057 { 1067 {
1058 /* toss this player off the altar. He can try again. */ 1068 /* 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."); 1069 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar.");
1060 pl->contr->fire_on = 0; 1070 pl->contr->fire_on = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines