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.21 by root, Sat May 12 18:14:48 2007 UTC vs.
Revision 1.36 by root, Mon May 5 15:05:26 2008 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your 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 GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 20 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 22 */
24
25 23
26/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and 24/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and
27 * monster race initialization. b.t. 25 * monster race initialization. b.t.
28 */ 26 */
29 27
50 godlink *gl; 48 godlink *gl;
51 49
52 for (gl = first_god; gl; gl = gl->next) 50 for (gl = first_god; gl; gl = gl->next)
53 if (!strncmp (name, gl->name, MIN ((size_t) strlen (gl->name), nmlen))) 51 if (!strncmp (name, gl->name, MIN ((size_t) strlen (gl->name), nmlen)))
54 break; 52 break;
53
55 if (gl) 54 if (gl)
56 godnr = gl->id; 55 godnr = gl->id;
57 } 56 }
57
58 return godnr; 58 return godnr;
59} 59}
60 60
61/** 61/**
62 * Returns pointer to specified god's object through pntr_to_god_obj.. 62 * Returns pointer to specified god's object through pntr_to_god_obj..
104 { 104 {
105 105
106 /* find a god based on race */ 106 /* find a god based on race */
107 if (!op->title) 107 if (!op->title)
108 { 108 {
109 if (op->race != NULL) 109 if (op->race)
110 { 110 {
111 godname = get_god_for_race (op->race); 111 godname = get_god_for_race (op->race);
112
112 if (godname != NULL) 113 if (godname)
113 {
114 op->title = godname; 114 op->title = godname;
115 }
116 } 115 }
117 } 116 }
118 117
119 /* find a random god */ 118 /* find a random god */
120 if (!op->title) 119 if (!op->title)
124 godnr = rndm (1, gl->id); 123 godnr = rndm (1, gl->id);
125 while (gl) 124 while (gl)
126 { 125 {
127 if (gl->id == godnr) 126 if (gl->id == godnr)
128 break; 127 break;
128
129 gl = gl->next; 129 gl = gl->next;
130 } 130 }
131
131 op->title = gl->name; 132 op->title = gl->name;
132 } 133 }
133 134
134 return op->title; 135 return op->title;
135 } 136 }
140 * that skill, once we find it, we can return, either with the 141 * that skill, once we find it, we can return, either with the
141 * title or "none". 142 * title or "none".
142 */ 143 */
143 if (op->type == PLAYER) 144 if (op->type == PLAYER)
144 { 145 {
145 object *tmp;
146
147 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 146 for (object *tmp = op->inv; tmp; tmp = tmp->below)
148 if (tmp->type == SKILL && tmp->subtype == SK_PRAYING) 147 if (tmp->type == SKILL && tmp->subtype == SK_PRAYING)
149 { 148 {
150 if (tmp->title) 149 if (tmp->title)
151 return (tmp->title); 150 return tmp->title;
152 else 151 else
153 return ("none"); 152 return "none";
154 } 153 }
155 } 154 }
155
156 return ("none"); 156 return "none";
157} 157}
158 158
159/** 159/**
160 * Returns 1 if s1 and s2 are the same - either both NULL, or strcmp( ) == 0 160 * Returns 1 if s1 and s2 are the same - either both NULL, or strcmp( ) == 0
161 */ 161 */
171 return 0; 171 return 0;
172 else 172 else
173 return strcmp (s1, s2) == 0; 173 return strcmp (s1, s2) == 0;
174} 174}
175 175
176
177/** 176/**
178 * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively). 177 * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively).
179 * Any matching items in the inventory are deleted, and a 178 * Any matching items in the inventory are deleted, and a
180 * message is displayed to the player. 179 * message is displayed to the player.
181 */ 180 */
200 if (tmp->nrof > 1) 199 if (tmp->nrof > 1)
201 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumble to dust!", query_short_name (tmp)); 200 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumble to dust!", query_short_name (tmp));
202 else 201 else
203 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumbles to dust!", query_short_name (tmp)); 202 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumbles to dust!", query_short_name (tmp));
204 203
205 tmp->remove (); /* remove obj from players inv. */ 204 tmp->destroy ();
206 esrv_del_item (op->contr, tmp->count); /* notify client */
207 tmp->destroy (); /* free object */
208 } 205 }
209 206
210 if (tmp->inv) 207 if (tmp->inv)
211 follower_remove_similar_item (tmp, item); 208 follower_remove_similar_item (tmp, item);
212 } 209 }
238 * God gives an item to the player. 235 * God gives an item to the player.
239 */ 236 */
240static int 237static int
241god_gives_present (object *op, object *god, treasure *tr) 238god_gives_present (object *op, object *god, treasure *tr)
242{ 239{
243 object *tmp;
244
245 if (!tr->item) 240 if (!tr->item)
246 return 0; 241 return 0;
247 242
248 if (follower_has_similar_item (op, &tr->item->clone)) 243 if (follower_has_similar_item (op, tr->item))
249 return 0; 244 return 0;
250 245
251 tmp = arch_to_object (tr->item); 246 object *tmp = arch_to_object (tr->item);
252 new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); 247 new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp));
253 tmp = insert_ob_in_ob (tmp, op); 248 op->insert (tmp);
254 if (op->type == PLAYER)
255 esrv_send_item (op, tmp);
256 249
257 return 1; 250 return 1;
258} 251}
259 252
260/** 253/**
274 return; 267 return;
275 268
276 /* hmm. what happend depends on pl's current god, level, etc */ 269 /* hmm. what happend depends on pl's current god, level, etc */
277 if (!pl_god) 270 if (!pl_god)
278 { /*new convert */ 271 { /*new convert */
279 become_follower (pl, &altar->other_arch->clone); 272 become_follower (pl, altar->other_arch);
280 return; 273 return;
281
282 } 274 }
283 else if (!strcmp (&pl_god->name, altar->other_arch->clone.name)) 275 else if (!strcmp (&pl_god->name, altar->other_arch->object::name))
284 { 276 {
285 /* pray at your gods altar */ 277 /* pray at your gods altar */
286 int bonus = (pl->stats.Wis + skill->level) / 10; 278 int bonus = (pl->stats.Wis + skill->level) / 10;
287 279
288 /* we can get neg grace up faster */ 280 /* we can get neg grace up faster */
289 if (pl->stats.grace < 0) 281 if (pl->stats.grace < 0)
290 pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10)); 282 pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10));
283
291 /* we can super-charge grace to 2x max */ 284 /* we can super-charge grace to 2x max */
292 if (pl->stats.grace < (2 * pl->stats.maxgrace)) 285 if (pl->stats.grace < 2 * pl->stats.maxgrace)
293 {
294 pl->stats.grace += bonus / 2; 286 pl->stats.grace += bonus / 2;
295 } 287 else
296 if (pl->stats.grace > (2 * pl->stats.maxgrace))
297 {
298 pl->stats.grace = (2 * pl->stats.maxgrace); 288 pl->stats.grace = 2 * pl->stats.maxgrace;
299 }
300 289
301 /* Every once in a while, the god decides to checkup on their 290 /* Every once in a while, the god decides to checkup on their
302 * follower, and may intervene to help them out. 291 * follower, and may intervene to help them out.
303 */ 292 */
304 bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */ 293 bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */
305 294
306 if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0) 295 if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0)
307 god_intervention (pl, pl_god, skill); 296 god_intervention (pl, pl_god, skill);
308
309 } 297 }
310 else 298 else
311 { /* praying to another god! */ 299 { /* praying to another god! */
312 uint64 loss = 0; 300 uint64 loss = 0;
313 int angry = 1; 301 int angry = 1;
317 * points to the god of this altar (which we have 305 * points to the god of this altar (which we have
318 * already verified is non null). pl_god->other_arch 306 * already verified is non null). pl_god->other_arch
319 * is the opposing god - we need to verify that exists before 307 * is the opposing god - we need to verify that exists before
320 * using its values. 308 * using its values.
321 */ 309 */
322 if (pl_god->other_arch && (altar->other_arch->name == pl_god->other_arch->name)) 310 if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname))
323 { 311 {
324 angry = 2; 312 angry = 2;
325 if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) 313 if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0)
326 { 314 {
327 object *tmp; 315 object *tmp;
348 336
349 /* May switch Gods, but its random chance based on our current level 337 /* May switch Gods, but its random chance based on our current level
350 * note it gets harder to swap gods the higher we get 338 * note it gets harder to swap gods the higher we get
351 */ 339 */
352 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) 340 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
353 {
354 become_follower (pl, &altar->other_arch->clone); 341 become_follower (pl, altar->other_arch);
355 }
356 else 342 else
357 { 343 {
358 /* toss this player off the altar. He can try again. */ 344 /* toss this player off the altar. He can try again. */
359 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); 345 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar.");
346 pl->contr->fire_on = 0;
347 pl->speed_left = 1.f;
360 move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ 348 move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */
361 } 349 }
362 } 350 }
363} 351}
364 352
402 object *item; 390 object *item;
403 391
404 if (!tr->item) 392 if (!tr->item)
405 continue; 393 continue;
406 394
407 item = &tr->item->clone; 395 item = tr->item;
408 396
409 /* Basically, see if the matching spell is granted by this god. */ 397 /* Basically, see if the matching spell is granted by this god. */
410 398
411 if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) 399 if (tr->item->type == SPELL && tr->item->object::name == tmp->name)
412 { 400 {
413 remove = 0; 401 remove = 0;
414 break; 402 break;
415 } 403 }
416 } 404 }
405
417 if (remove) 406 if (remove)
418 { 407 do_forget_spell (op, tmp->name);
419 /* just do the work of removing the spell ourselves - we already
420 * know that the player knows the spell
421 */
422 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &tmp->name);
423 player_unready_range_ob (op->contr, tmp);
424 tmp->destroy ();
425 }
426
427 } 408 }
428} 409}
429 410
430/** 411/**
431 * This function is called whenever a player has 412 * This function is called whenever a player has
439 object *old_god = NULL; /* old god */ 420 object *old_god = NULL; /* old god */
440 treasure *tr; 421 treasure *tr;
441 object *item, *skop, *next; 422 object *item, *skop, *next;
442 int i, sk_applied, undeadified = 0; /* Turns to true if changing god can changes the undead status of the player. */ 423 int i, sk_applied, undeadified = 0; /* Turns to true if changing god can changes the undead status of the player. */
443 424
444
445 old_god = find_god (determine_god (op)); 425 old_god = find_god (determine_god (op));
446 426
447 /* take away any special god-characteristic items. */ 427 /* take away any special god-characteristic items. */
448 for (item = op->inv; item != NULL; item = next) 428 for (item = op->inv; item; item = next)
449 { 429 {
450 next = item->below; 430 next = item->below;
431
451 // remove all invisible startequip items which are not skill, exp or force 432 // remove all invisible startequip items which are not skill, exp or force
452 if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible && 433 if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible &&
453 (item->type != SKILL) && (item->type != FORCE)) 434 (item->type != SKILL) && (item->type != FORCE))
454 { 435 {
455
456 if (item->type == SPELL) 436 if (item->type == SPELL)
437 {
457 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); 438 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name);
439 esrv_remove_spell (op->contr, item);
440 }
458 441
459 player_unready_range_ob (op->contr, item); 442 player_unready_range_ob (op->contr, item);
460 item->destroy (); 443 item->destroy ();
461 } 444 }
462 } 445 }
463 446
464 /* remove any godgiven items from the old god */ 447 /* remove any godgiven items from the old god */
465 if (old_god) 448 if (old_god)
466 for (tr = old_god->randomitems->items; tr; tr = tr->next) 449 for (tr = old_god->randomitems->items; tr; tr = tr->next)
467 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) 450 if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP))
468 follower_remove_similar_item (op, &tr->item->clone); 451 follower_remove_similar_item (op, tr->item);
469 452
470 if (!op || !new_god) 453 if (!op || !new_god)
471 return; 454 return;
472 455
473 if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) 456 if (op->race && new_god->slaying && strstr (op->race, new_god->slaying))
482 } 465 }
483 466
484 return; 467 return;
485 } 468 }
486 469
487
488 /* give the player any special god-characteristic-items. */ 470 /* give the player any special god-characteristic-items. */
489 for (tr = new_god->randomitems->items; tr; tr = tr->next) 471 for (tr = new_god->randomitems->items; tr; tr = tr->next)
490 { 472 {
491 if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK 473 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK
492 && tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) 474 && tr->item->type != BOOK && tr->item->type != SPELL)
493 god_gives_present (op, new_god, tr); 475 god_gives_present (op, new_god, tr);
494 } 476 }
495
496 477
497 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); 478 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name);
498 479
499 for (skop = op->inv; skop != NULL; skop = skop->below) 480 for (skop = op->inv; skop != NULL; skop = skop->below)
500 if (skop->type == SKILL && skop->subtype == SK_PRAYING) 481 if (skop->type == SKILL && skop->subtype == SK_PRAYING)
504 if (!skop) 485 if (!skop)
505 { 486 {
506 /* The arhetype should always be defined - if we crash here because it doesn't, 487 /* The arhetype should always be defined - if we crash here because it doesn't,
507 * things are really messed up anyways. 488 * things are really messed up anyways.
508 */ 489 */
509 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->clone.skill); 490 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill);
510 link_player_skills (op); 491 link_player_skills (op);
511 } 492 }
512 493
513 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ 494 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */
514 495
521 CLEAR_FLAG (skop, FLAG_UNDEAD); 502 CLEAR_FLAG (skop, FLAG_UNDEAD);
522 undeadified = 1; 503 undeadified = 1;
523 } 504 }
524 505
525 if (skop->title) 506 if (skop->title)
526 { /* get rid of old god */ 507 {
508 /* get rid of old god */
527 new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title); 509 new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title);
510
528 /* The point of this is to really show what abilities the player just lost */ 511 /* The point of this is to really show what abilities the player just lost */
529 if (sk_applied || undeadified) 512 if (sk_applied || undeadified)
530 { 513 {
531
532 CLEAR_FLAG (skop, FLAG_APPLIED); 514 CLEAR_FLAG (skop, FLAG_APPLIED);
533 (void) change_abil (op, skop); 515 change_abil (op, skop);
534 } 516 }
535 } 517 }
536 518
537 /* now change to the new gods attributes to exp_obj */ 519 /* now change to the new gods attributes to exp_obj */
538 skop->title = new_god->name; 520 skop->title = new_god->name;
573 * This also can happen for monks which cannot use weapons. In this case 555 * This also can happen for monks which cannot use weapons. In this case
574 * do not allow to use weapons even if the god otherwise would allow it. 556 * do not allow to use weapons even if the god otherwise would allow it.
575 */ 557 */
576 if (!present_in_ob_by_name (FORCE, "no weapon force", op)) 558 if (!present_in_ob_by_name (FORCE, "no weapon force", op))
577 update_priest_flag (new_god, skop, FLAG_USE_WEAPON); 559 update_priest_flag (new_god, skop, FLAG_USE_WEAPON);
560
578 update_priest_flag (new_god, skop, FLAG_USE_ARMOUR); 561 update_priest_flag (new_god, skop, FLAG_USE_ARMOUR);
579 562
580 if (worship_forbids_use (op, skop, FLAG_USE_WEAPON, "weapons")) 563 if (worship_forbids_use (op, skop, FLAG_USE_WEAPON, "weapons"))
581 stop_using_item (op, WEAPON, 2); 564 stop_using_item (op, WEAPON, 2);
582 565
608 */ 591 */
609 592
610int 593int
611worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) 594worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string)
612{ 595{
613
614 if (QUERY_FLAG (&op->arch->clone, flag)) 596 if (QUERY_FLAG (op->arch, flag))
615 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) 597 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag))
616 { 598 {
617 update_priest_flag (exp_obj, op, flag); 599 update_priest_flag (exp_obj, op, flag);
618 if (QUERY_FLAG (op, flag)) 600 if (QUERY_FLAG (op, flag))
619 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); 601 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string);
621 { 603 {
622 new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string); 604 new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string);
623 return 1; 605 return 1;
624 } 606 }
625 } 607 }
608
626 return 0; 609 return 0;
627} 610}
628 611
629/** 612/**
630 * Unapplies up to number worth of items of type 613 * Unapplies up to number worth of items of type
667/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ 650/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/
668 CLEAR_FLAG (exp_ob, flag); 651 CLEAR_FLAG (exp_ob, flag);
669 }; 652 };
670} 653}
671 654
672
673
674archetype * 655archetype *
675determine_holy_arch (object *god, const char *type) 656determine_holy_arch (object *god, const char *type)
676{ 657{
677 treasure *tr; 658 treasure *tr;
678 659
679 if (!god || !god->randomitems) 660 if (!god || !god->randomitems)
680 { 661 {
681 LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); 662 LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n");
682 return NULL; 663 return 0;
683 } 664 }
684 665
685 for (tr = god->randomitems->items; tr; tr = tr->next) 666 for (tr = god->randomitems->items; tr; tr = tr->next)
686 { 667 {
687 if (!tr->item) 668 if (!tr->item)
688 continue; 669 continue;
689 670
690 object *item = &tr->item->clone; 671 object *item = tr->item;
691 672
692 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 673 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0)
693 return item->other_arch; 674 return item->other_arch;
694 } 675 }
676
695 return NULL; 677 return 0;
696} 678}
697 679
698/** 680/**
699 * God helps player by removing curse and/or damnation. 681 * God helps player by removing curse and/or damnation.
700 */ 682 */
701static int 683static int
702god_removes_curse (object *op, int remove_damnation) 684god_removes_curse (object *op, int remove_damnation)
703{ 685{
704 object *tmp;
705 int success = 0; 686 int success = 0;
706 687
707 for (tmp = op->inv; tmp; tmp = tmp->below) 688 for (object *tmp = op->inv; tmp; tmp = tmp->below)
708 { 689 {
709 if (tmp->invisible) 690 if (tmp->invisible)
710 continue; 691 continue;
692
711 if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation) 693 if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation)
712 continue; 694 continue;
695
713 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 696 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
714 { 697 {
715 success = 1; 698 success = 1;
716 CLEAR_FLAG (tmp, FLAG_DAMNED); 699 CLEAR_FLAG (tmp, FLAG_DAMNED);
717 CLEAR_FLAG (tmp, FLAG_CURSED); 700 CLEAR_FLAG (tmp, FLAG_CURSED);
718 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); 701 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED);
719 if (op->type == PLAYER) 702
703 if (object *pl = tmp->visible_to ())
720 esrv_send_item (op, tmp); 704 esrv_update_item (UPD_FLAGS, pl, tmp);
721 } 705 }
722 } 706 }
723 707
724 if (success) 708 if (success)
725 new_draw_info (NDI_UNIQUE, 0, op, "You feel like someone is helping you."); 709 new_draw_info (NDI_UNIQUE, 0, op, "You feel like someone is helping you.");
710
726 return success; 711 return success;
727} 712}
728 713
729static int 714static int
730follower_level_to_enchantments (int level, int difficulty) 715follower_level_to_enchantments (int level, int difficulty)
735 return 0; 720 return 0;
736 } 721 }
737 722
738 if (level <= 20) 723 if (level <= 20)
739 return level / difficulty; 724 return level / difficulty;
725
740 if (level <= 40) 726 if (level <= 40)
741 return (20 + (level - 20) / 2) / difficulty; 727 return (20 + (level - 20) / 2) / difficulty;
742 728
743 return (30 + (level - 40) / 4) / difficulty; 729 return (30 + (level - 40) / 4) / difficulty;
744} 730}
750 * attacktype, slaying and such. 736 * attacktype, slaying and such.
751 */ 737 */
752static int 738static int
753god_enchants_weapon (object *op, object *god, object *tr, object *skill) 739god_enchants_weapon (object *op, object *god, object *tr, object *skill)
754{ 740{
755 char buf[MAX_BUF];
756 object *weapon; 741 object *weapon;
757 uint32 attacktype; 742 uint32 attacktype;
758 int tmp; 743 int tmp;
759 744
760 for (weapon = op->inv; weapon; weapon = weapon->below) 745 for (weapon = op->inv; weapon; weapon = weapon->below)
761 if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) 746 if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED))
762 break; 747 break;
763 748
764 if (weapon == NULL || god_examines_item (god, weapon) <= 0) 749 if (!weapon || god_examines_item (god, weapon) <= 0)
765 return 0; 750 return 0;
766 751
767 /* First give it a title, so other gods won't touch it */ 752 /* First give it a title, so other gods won't touch it */
768 if (!weapon->title) 753 if (!weapon->title)
769 { 754 {
770 sprintf (buf, "of %s", &god->name); 755 weapon->title = format ("of %s", &god->name);
771 weapon->title = buf; 756
772 if (op->type == PLAYER) 757 if (object *pl = weapon->visible_to ())
773 esrv_update_item (UPD_NAME, op, weapon); 758 esrv_update_item (UPD_NAME, pl, weapon);
759
774 new_draw_info (NDI_UNIQUE, 0, op, "Your weapon quivers as if struck!"); 760 new_draw_info (NDI_UNIQUE, 0, op, "Your weapon quivers as if struck!");
775 } 761 }
776 762
777 /* Allow the weapon to slay enemies */ 763 /* Allow the weapon to slay enemies */
778 if (!weapon->slaying && god->slaying) 764 if (!weapon->slaying && god->slaying)
795 tmp = follower_level_to_enchantments (skill->level, tr->level); 781 tmp = follower_level_to_enchantments (skill->level, tr->level);
796 if (weapon->magic < tmp) 782 if (weapon->magic < tmp)
797 { 783 {
798 new_draw_info (NDI_UNIQUE, 0, op, "A phosphorescent glow envelops your weapon!"); 784 new_draw_info (NDI_UNIQUE, 0, op, "A phosphorescent glow envelops your weapon!");
799 weapon->magic++; 785 weapon->magic++;
800 if (op->type == PLAYER) 786
787 if (object *pl = weapon->visible_to ())
801 esrv_update_item (UPD_NAME, op, weapon); 788 esrv_update_item (UPD_NAME, pl, weapon);
789
802 return 1; 790 return 1;
803 } 791 }
804 792
805 return 0; 793 return 0;
806} 794}
807
808 795
809/** 796/**
810 * Every once in a while the god will intervene to help the worshiper. 797 * Every once in a while the god will intervene to help the worshiper.
811 * Later, this fctn can be used to supply quests, etc for the 798 * Later, this fctn can be used to supply quests, etc for the
812 * priest. -b.t. 799 * priest. -b.t.
813 * called from pray_at_altar() currently. 800 * called from pray_at_altar() currently.
814 */ 801 */
815
816void 802void
817god_intervention (object *op, object *god, object *skill) 803god_intervention (object *op, object *god, object *skill)
818{ 804{
819 treasure *tr; 805 treasure *tr;
820 806
828 814
829 /* lets do some checks of whether we are kosher with our god */ 815 /* lets do some checks of whether we are kosher with our god */
830 if (god_examines_priest (op, god) < 0) 816 if (god_examines_priest (op, god) < 0)
831 return; 817 return;
832 818
819 op->play_sound (sound_find ("god_intervention"));
833 new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); 820 new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!");
834 821
835 for (tr = god->randomitems->items; tr; tr = tr->next) 822 for (tr = god->randomitems->items; tr; tr = tr->next)
836 { 823 {
837 object *item; 824 object *item;
845 treasurelist *tl = treasurelist::find (tr->name); 832 treasurelist *tl = treasurelist::find (tr->name);
846 833
847 if (tl == NULL) 834 if (tl == NULL)
848 continue; 835 continue;
849 836
850 new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); 837 new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your eyes. You catch it before it falls to the ground.");
851 838
852 create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); 839 create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD, skill->level, 0);
853 return; 840 return;
854 } 841 }
855 842
856 if (!tr->item) 843 if (!tr->item)
857 continue; 844 continue;
858 845
859 item = &tr->item->clone; 846 item = tr->item;
860 847
861 /* Grace limit */ 848 /* Grace limit */
862 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) 849 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0)
863 { 850 {
864 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) 851 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace)
871 tmp = get_archetype (HOLY_POSSESSION); 858 tmp = get_archetype (HOLY_POSSESSION);
872 cast_change_ability (op, op, tmp, 0, 1); 859 cast_change_ability (op, op, tmp, 0, 1);
873 tmp->destroy (); 860 tmp->destroy ();
874 return; 861 return;
875 } 862 }
863
876 continue; 864 continue;
877 } 865 }
878 866
879 /* Restore grace */ 867 /* Restore grace */
880 if (item->type == BOOK && item->invisible && strcmp (item->name, "restore grace") == 0) 868 if (item->type == BOOK && item->invisible && strcmp (item->name, "restore grace") == 0)
904 /* Restore to 50 .. 100%, if sp < 50% */ 892 /* Restore to 50 .. 100%, if sp < 50% */
905 int new_sp = (int) (random_roll (1000, 1999, op, PREFER_HIGH) / 2000.0 * max); 893 int new_sp = (int) (random_roll (1000, 1999, op, PREFER_HIGH) / 2000.0 * max);
906 894
907 if (op->stats.sp >= max / 2) 895 if (op->stats.sp >= max / 2)
908 continue; 896 continue;
897
909 new_draw_info (NDI_UNIQUE, 0, op, "A blue lightning strikes " "your head but doesn't hurt you!"); 898 new_draw_info (NDI_UNIQUE, 0, op, "A blue lightning strikes your head but doesn't hurt you!");
910 op->stats.sp = new_sp; 899 op->stats.sp = new_sp;
911 } 900 }
912 901
913 /* Various heal spells */ 902 /* Various heal spells */
914 if (item->type == BOOK && item->invisible && strcmp (item->name, "heal spell") == 0) 903 if (item->type == BOOK && item->invisible && strcmp (item->name, "heal spell") == 0)
915 { 904 {
916 object *tmp;
917 int success;
918
919 tmp = get_archetype_by_object_name (item->slaying); 905 object *tmp = archetype::get (item->slaying);
920
921 success = cast_heal (op, op, tmp, 0); 906 int success = cast_heal (op, op, tmp, 0);
922 tmp->destroy (); 907 tmp->destroy ();
908
923 if (success) 909 if (success)
924 return; 910 return;
925 else 911 else
926 continue; 912 continue;
927 } 913 }
973 } 959 }
974 960
975 /* Voices */ 961 /* Voices */
976 if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) 962 if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0)
977 { 963 {
978 new_draw_info (NDI_UNIQUE, 0, op, "You hear a voice from behind you, but you don't dare to " "turn around:"); 964 new_draw_info (NDI_UNIQUE, 0, op, "You hear a voice from behind you, but you don't dare to turn around:");
979 new_draw_info (NDI_WHITE, 0, op, item->msg); 965 new_draw_info (NDI_WHITE, 0, op, item->msg);
980 return; 966 return;
981 } 967 }
982 968
983 /* Messages */ 969 /* Messages */
1134 1120
1135 if (race == NULL) 1121 if (race == NULL)
1136 return NULL; 1122 return NULL;
1137 while (gl) 1123 while (gl)
1138 { 1124 {
1139 if (!strcasecmp (gl->arch->clone.race, race)) 1125 if (!strcasecmp (gl->arch->race, race))
1140 { 1126 {
1141 godname = gl->name; 1127 godname = gl->name;
1142 break; 1128 break;
1143 } 1129 }
1144 gl = gl->next; 1130 gl = gl->next;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines