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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your 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 GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * 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> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /* 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 |
… | |
… | |
35 | #include <sproto.h> |
36 | #include <sproto.h> |
36 | |
37 | |
37 | /** |
38 | /** |
38 | * Returns the id of specified god. |
39 | * Returns the id of specified god. |
39 | */ |
40 | */ |
40 | int |
41 | static int |
41 | lookup_god_by_name (shstr_cmp name) |
42 | lookup_god_by_name (shstr_cmp name) |
42 | { |
43 | { |
43 | if (name) |
44 | if (name) |
44 | for (godlink *gl = first_god; gl; gl = gl->next) |
45 | for (godlink *gl = first_god; gl; gl = gl->next) |
45 | if (gl->name == name) |
46 | if (gl->name == name) |
… | |
… | |
213 | return 0; |
214 | return 0; |
214 | |
215 | |
215 | if (follower_has_similar_item (op, tr->item)) |
216 | if (follower_has_similar_item (op, tr->item)) |
216 | return 0; |
217 | return 0; |
217 | |
218 | |
218 | object *tmp = arch_to_object (tr->item); |
219 | object *tmp = tr->item->instance (); |
219 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); |
220 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); |
220 | op->insert (tmp); |
221 | op->insert (tmp); |
221 | |
222 | |
222 | return 1; |
223 | return 1; |
223 | } |
|
|
224 | |
|
|
225 | /** |
|
|
226 | * Player prays at altar. |
|
|
227 | * Checks for god changing, divine intervention, and so on. |
|
|
228 | */ |
|
|
229 | void |
|
|
230 | pray_at_altar (object *pl, object *altar, object *skill) |
|
|
231 | { |
|
|
232 | object *pl_god = find_god (determine_god (pl)); |
|
|
233 | |
|
|
234 | if (INVOKE_PLAYER (PRAY_ALTAR, pl->contr, ARG_OBJECT (altar), ARG_OBJECT (skill))) |
|
|
235 | return; |
|
|
236 | |
|
|
237 | /* If non consecrate altar, don't do anything */ |
|
|
238 | if (!altar->other_arch) |
|
|
239 | return; |
|
|
240 | |
|
|
241 | /* hmm. what happend depends on pl's current god, level, etc */ |
|
|
242 | if (!pl_god) |
|
|
243 | { /*new convert */ |
|
|
244 | become_follower (pl, altar->other_arch); |
|
|
245 | return; |
|
|
246 | } |
|
|
247 | else if (!strcmp (&pl_god->name, altar->other_arch->object::name)) |
|
|
248 | { |
|
|
249 | /* pray at your gods altar */ |
|
|
250 | int bonus = (pl->stats.Wis + skill->level) / 10; |
|
|
251 | |
|
|
252 | /* we can get neg grace up faster */ |
|
|
253 | if (pl->stats.grace < 0) |
|
|
254 | pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10)); |
|
|
255 | |
|
|
256 | /* we can super-charge grace to 2x max */ |
|
|
257 | if (pl->stats.grace < 2 * pl->stats.maxgrace) |
|
|
258 | pl->stats.grace += bonus / 2; |
|
|
259 | else |
|
|
260 | pl->stats.grace = 2 * pl->stats.maxgrace; |
|
|
261 | |
|
|
262 | /* Every once in a while, the god decides to checkup on their |
|
|
263 | * follower, and may intervene to help them out. |
|
|
264 | */ |
|
|
265 | bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */ |
|
|
266 | |
|
|
267 | if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0) |
|
|
268 | god_intervention (pl, pl_god, skill); |
|
|
269 | } |
|
|
270 | else |
|
|
271 | { /* praying to another god! */ |
|
|
272 | uint64 loss = 0; |
|
|
273 | int angry = 1; |
|
|
274 | |
|
|
275 | /* I believe the logic for detecting opposing gods was completely |
|
|
276 | * broken - I think it should work now. altar->other_arch |
|
|
277 | * points to the god of this altar (which we have |
|
|
278 | * already verified is non null). pl_god->other_arch |
|
|
279 | * is the opposing god - we need to verify that exists before |
|
|
280 | * using its values. |
|
|
281 | */ |
|
|
282 | if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname)) |
|
|
283 | { |
|
|
284 | angry = 2; |
|
|
285 | if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) |
|
|
286 | { |
|
|
287 | object *tmp; |
|
|
288 | |
|
|
289 | /* you really screwed up */ |
|
|
290 | angry = 3; |
|
|
291 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foul Priest! %s punishes you!", &pl_god->name); |
|
|
292 | tmp = get_archetype (LOOSE_MANA); |
|
|
293 | cast_magic_storm (pl, tmp, pl_god->level + 20); |
|
|
294 | } |
|
|
295 | else |
|
|
296 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foolish heretic! %s is livid!", &pl_god->name); |
|
|
297 | } |
|
|
298 | else |
|
|
299 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Heretic! %s is angered!", &pl_god->name); |
|
|
300 | |
|
|
301 | /* whether we will be successfull in defecting or not - |
|
|
302 | * we lose experience from the clerical experience obj |
|
|
303 | */ |
|
|
304 | |
|
|
305 | loss = angry * (skill->stats.exp / 10); |
|
|
306 | if (loss) |
|
|
307 | change_exp (pl, -random_roll64 (0, loss, pl, PREFER_LOW), skill ? &skill->skill : "none", SK_SUBTRACT_SKILL_EXP); |
|
|
308 | |
|
|
309 | /* May switch Gods, but its random chance based on our current level |
|
|
310 | * note it gets harder to swap gods the higher we get |
|
|
311 | */ |
|
|
312 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
|
|
313 | become_follower (pl, altar->other_arch); |
|
|
314 | else |
|
|
315 | { |
|
|
316 | /* toss this player off the altar. He can try again. */ |
|
|
317 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); |
|
|
318 | pl->contr->fire_on = 0; |
|
|
319 | pl->speed_left = 1.f; |
|
|
320 | move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ |
|
|
321 | } |
|
|
322 | } |
|
|
323 | } |
224 | } |
324 | |
225 | |
325 | /** |
226 | /** |
326 | * Removes special prayers given by a god. |
227 | * Removes special prayers given by a god. |
327 | */ |
228 | */ |
… | |
… | |
341 | next_tmp = tmp->below; |
242 | next_tmp = tmp->below; |
342 | |
243 | |
343 | /* we mark special prayers with the STARTEQUIP flag, so if it isn't |
244 | /* we mark special prayers with the STARTEQUIP flag, so if it isn't |
344 | * in that category, not something we need to worry about. |
245 | * in that category, not something we need to worry about. |
345 | */ |
246 | */ |
346 | if (tmp->type != SPELL || !QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
247 | if (tmp->type != SPELL || !tmp->flag [FLAG_STARTEQUIP]) |
347 | continue; |
248 | continue; |
348 | |
249 | |
349 | if (god->randomitems == NULL) |
250 | if (god->randomitems == NULL) |
350 | { |
251 | { |
351 | LOG (llevError, "BUG: check_special_prayers(): god %s without randomitems\n", &god->name); |
252 | LOG (llevError, "BUG: check_special_prayers(): god %s without randomitems\n", &god->name); |
… | |
… | |
379 | do_forget_spell (op, tmp->name); |
280 | do_forget_spell (op, tmp->name); |
380 | } |
281 | } |
381 | } |
282 | } |
382 | |
283 | |
383 | /** |
284 | /** |
|
|
285 | * Unapplies up to number worth of items of type |
|
|
286 | */ |
|
|
287 | static void |
|
|
288 | stop_using_item (object *op, int type, int number) |
|
|
289 | { |
|
|
290 | for (object *tmp = op->inv; tmp && number; tmp = tmp->below) |
|
|
291 | if (tmp->type == type && tmp->flag [FLAG_APPLIED]) |
|
|
292 | { |
|
|
293 | op->apply (tmp, AP_UNAPPLY | AP_IGNORE_CURSE); |
|
|
294 | --number; |
|
|
295 | } |
|
|
296 | } |
|
|
297 | |
|
|
298 | /** |
|
|
299 | * If the god does/doesnt have this flag, we |
|
|
300 | * give/remove it from the experience object if it doesnt/does |
|
|
301 | * already exist. For players only! |
|
|
302 | */ |
|
|
303 | static void |
|
|
304 | update_priest_flag (object *god, object *exp_ob, uint32 flag) |
|
|
305 | { |
|
|
306 | if (god->flag [flag] && !exp_ob->flag [flag]) |
|
|
307 | exp_ob->flag [flag]; |
|
|
308 | else if (exp_ob->flag [flag] && !god->flag [flag]) |
|
|
309 | { |
|
|
310 | /* When this is called with the exp_ob set to the player, |
|
|
311 | * this check is broken, because most all players arch |
|
|
312 | * allow use of weapons. I'm not actually sure why this |
|
|
313 | * check is here - I guess if you had a case where the |
|
|
314 | * 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 |
|
|
316 | * there is any case like that. |
|
|
317 | */ |
|
|
318 | |
|
|
319 | /* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ |
|
|
320 | exp_ob->clr_flag (flag); |
|
|
321 | }; |
|
|
322 | } |
|
|
323 | |
|
|
324 | /** |
|
|
325 | * Forbids or let player use something item type. |
|
|
326 | * op is the player. |
|
|
327 | * exp_obj is the widsom experience. |
|
|
328 | * flag is the flag to check against. |
|
|
329 | * string is the string to print out. |
|
|
330 | */ |
|
|
331 | static int |
|
|
332 | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
|
|
333 | { |
|
|
334 | if (op->arch->flag [flag]) |
|
|
335 | if (op->flag [flag] != exp_obj->flag [flag]) |
|
|
336 | { |
|
|
337 | update_priest_flag (exp_obj, op, flag); |
|
|
338 | if (op->flag [flag]) |
|
|
339 | new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); |
|
|
340 | else |
|
|
341 | { |
|
|
342 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string); |
|
|
343 | return 1; |
|
|
344 | } |
|
|
345 | } |
|
|
346 | |
|
|
347 | return 0; |
|
|
348 | } |
|
|
349 | |
|
|
350 | /** |
384 | * This function is called whenever a player has |
351 | * This function is called whenever a player has |
385 | * switched to a new god. It handles basically all the stat changes |
352 | * switched to a new god. It handles basically all the stat changes |
386 | * that happen to the player, including the removal of godgiven |
353 | * that happen to the player, including the removal of godgiven |
387 | * items (from the former cult). |
354 | * items (from the former cult). |
388 | */ |
355 | */ |
… | |
… | |
400 | for (item = op->inv; item; item = next) |
367 | for (item = op->inv; item; item = next) |
401 | { |
368 | { |
402 | next = item->below; |
369 | next = item->below; |
403 | |
370 | |
404 | // remove all invisible startequip items which are not skill, exp or force |
371 | // remove all invisible startequip items which are not skill, exp or force |
405 | if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible && |
372 | if (item->flag [FLAG_STARTEQUIP] && item->invisible && |
406 | (item->type != SKILL) && (item->type != FORCE)) |
373 | (item->type != SKILL) && (item->type != FORCE)) |
407 | { |
374 | { |
408 | if (item->type == SPELL) |
375 | if (item->type == SPELL) |
409 | { |
376 | { |
410 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); |
377 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); |
411 | esrv_remove_spell (op->contr, item); |
378 | esrv_remove_spell (op->contr, item); |
412 | } |
379 | } |
413 | |
380 | |
414 | player_unready_range_ob (op->contr, item); |
|
|
415 | item->destroy (); |
381 | item->destroy (); |
416 | } |
382 | } |
417 | } |
383 | } |
418 | |
384 | |
419 | /* remove any godgiven items from the old god */ |
385 | /* remove any godgiven items from the old god */ |
420 | if (old_god) |
386 | if (old_god) |
421 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
387 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
422 | if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP)) |
388 | if (tr->item && tr->item->flag [FLAG_STARTEQUIP]) |
423 | follower_remove_similar_item (op, tr->item); |
389 | follower_remove_similar_item (op, tr->item); |
424 | |
390 | |
425 | if (!op || !new_god) |
391 | if (!op || !new_god) |
426 | return; |
392 | return; |
427 | |
393 | |
… | |
… | |
458 | /* The archetype should always be defined - if we crash here because it doesn't, |
424 | /* The archetype should always be defined - if we crash here because it doesn't, |
459 | * things are really messed up anyways. |
425 | * things are really messed up anyways. |
460 | */ |
426 | */ |
461 | skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill); |
427 | skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill); |
462 | |
428 | |
463 | sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ |
429 | sk_applied = skop->flag [FLAG_APPLIED]; /* save skill status */ |
464 | |
430 | |
465 | /* Clear the "undead" status. We also need to force a call to change_abil, |
431 | /* Clear the "undead" status. We also need to force a call to change_abil, |
466 | * so I set undeadified for that. |
432 | * so I set undeadified for that. |
467 | * - gros, 21th July 2006. |
433 | * - gros, 21th July 2006. |
468 | */ |
434 | */ |
469 | if (old_god && QUERY_FLAG (old_god, FLAG_UNDEAD)) |
435 | if (old_god && old_god->flag [FLAG_UNDEAD]) |
470 | { |
436 | { |
471 | CLEAR_FLAG (skop, FLAG_UNDEAD); |
437 | skop->clr_flag (FLAG_UNDEAD); |
472 | undeadified = 1; |
438 | undeadified = 1; |
473 | } |
439 | } |
474 | |
440 | |
475 | if (skop->title) |
441 | if (skop->title) |
476 | { |
442 | { |
… | |
… | |
478 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title); |
444 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title); |
479 | |
445 | |
480 | /* The point of this is to really show what abilities the player just lost */ |
446 | /* The point of this is to really show what abilities the player just lost */ |
481 | if (sk_applied || undeadified) |
447 | if (sk_applied || undeadified) |
482 | { |
448 | { |
483 | CLEAR_FLAG (skop, FLAG_APPLIED); |
449 | skop->clr_flag (FLAG_APPLIED); |
484 | change_abil (op, skop); |
450 | change_abil (op, skop); |
485 | } |
451 | } |
486 | } |
452 | } |
487 | |
453 | |
488 | /* now change to the new gods attributes to exp_obj */ |
454 | /* now change to the new gods attributes to exp_obj */ |
… | |
… | |
539 | stop_using_item (op, BOOTS, 1); |
505 | stop_using_item (op, BOOTS, 1); |
540 | stop_using_item (op, GLOVES, 1); |
506 | stop_using_item (op, GLOVES, 1); |
541 | stop_using_item (op, SHIELD, 1); |
507 | stop_using_item (op, SHIELD, 1); |
542 | } |
508 | } |
543 | |
509 | |
544 | SET_FLAG (skop, FLAG_APPLIED); |
510 | skop->set_flag (FLAG_APPLIED); |
545 | (void) change_abil (op, skop); |
511 | change_abil (op, skop); |
546 | |
512 | |
547 | /* return to previous skill status */ |
513 | /* return to previous skill status */ |
548 | if (!sk_applied) |
514 | if (!sk_applied) |
549 | CLEAR_FLAG (skop, FLAG_APPLIED); |
515 | skop->clr_flag (FLAG_APPLIED); |
550 | |
516 | |
551 | check_special_prayers (op, new_god); |
517 | check_special_prayers (op, new_god); |
552 | } |
|
|
553 | |
|
|
554 | /** |
|
|
555 | * Forbids or let player use something item type. |
|
|
556 | * op is the player. |
|
|
557 | * exp_obj is the widsom experience. |
|
|
558 | * flag is the flag to check against. |
|
|
559 | * string is the string to print out. |
|
|
560 | */ |
|
|
561 | |
|
|
562 | int |
|
|
563 | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
|
|
564 | { |
|
|
565 | if (QUERY_FLAG (op->arch, flag)) |
|
|
566 | if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) |
|
|
567 | { |
|
|
568 | update_priest_flag (exp_obj, op, flag); |
|
|
569 | if (QUERY_FLAG (op, flag)) |
|
|
570 | new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); |
|
|
571 | else |
|
|
572 | { |
|
|
573 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string); |
|
|
574 | return 1; |
|
|
575 | } |
|
|
576 | } |
|
|
577 | |
|
|
578 | return 0; |
|
|
579 | } |
|
|
580 | |
|
|
581 | /** |
|
|
582 | * Unapplies up to number worth of items of type |
|
|
583 | */ |
|
|
584 | void |
|
|
585 | stop_using_item (object *op, int type, int number) |
|
|
586 | { |
|
|
587 | object *tmp; |
|
|
588 | |
|
|
589 | for (tmp = op->inv; tmp && number; tmp = tmp->below) |
|
|
590 | if (tmp->type == type && QUERY_FLAG (tmp, FLAG_APPLIED)) |
|
|
591 | { |
|
|
592 | apply_special (op, tmp, AP_UNAPPLY | AP_IGNORE_CURSE); |
|
|
593 | number--; |
|
|
594 | } |
|
|
595 | } |
|
|
596 | |
|
|
597 | /** |
|
|
598 | * If the god does/doesnt have this flag, we |
|
|
599 | * give/remove it from the experience object if it doesnt/does |
|
|
600 | * already exist. For players only! |
|
|
601 | */ |
|
|
602 | |
|
|
603 | void |
|
|
604 | update_priest_flag (object *god, object *exp_ob, uint32 flag) |
|
|
605 | { |
|
|
606 | if (QUERY_FLAG (god, flag) && !QUERY_FLAG (exp_ob, flag)) |
|
|
607 | SET_FLAG (exp_ob, flag); |
|
|
608 | else if (QUERY_FLAG (exp_ob, flag) && !QUERY_FLAG (god, flag)) |
|
|
609 | { |
|
|
610 | /* When this is called with the exp_ob set to the player, |
|
|
611 | * this check is broken, because most all players arch |
|
|
612 | * allow use of weapons. I'm not actually sure why this |
|
|
613 | * check is here - I guess if you had a case where the |
|
|
614 | * value in the archetype (wisdom) should over ride the restrictions |
|
|
615 | * the god places on it, this may make sense. But I don't think |
|
|
616 | * there is any case like that. |
|
|
617 | */ |
|
|
618 | |
|
|
619 | /* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ |
|
|
620 | CLEAR_FLAG (exp_ob, flag); |
|
|
621 | }; |
|
|
622 | } |
518 | } |
623 | |
519 | |
624 | archetype * |
520 | archetype * |
625 | determine_holy_arch (object *god, shstr_cmp type) |
521 | determine_holy_arch (object *god, shstr_cmp type) |
626 | { |
522 | { |
… | |
… | |
657 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
553 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
658 | { |
554 | { |
659 | if (tmp->invisible) |
555 | if (tmp->invisible) |
660 | continue; |
556 | continue; |
661 | |
557 | |
662 | if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation) |
558 | if (tmp->flag [FLAG_DAMNED] && !remove_damnation) |
663 | continue; |
559 | continue; |
664 | |
560 | |
665 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
561 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
666 | { |
562 | { |
667 | success = 1; |
563 | success = 1; |
668 | CLEAR_FLAG (tmp, FLAG_DAMNED); |
564 | tmp->clr_flag (FLAG_DAMNED); |
669 | CLEAR_FLAG (tmp, FLAG_CURSED); |
565 | tmp->clr_flag (FLAG_CURSED); |
670 | CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); |
566 | tmp->clr_flag (FLAG_KNOWN_CURSED); |
671 | |
567 | |
672 | if (object *pl = tmp->visible_to ()) |
568 | if (object *pl = tmp->visible_to ()) |
673 | esrv_update_item (UPD_FLAGS, pl, tmp); |
569 | esrv_update_item (UPD_FLAGS, pl, tmp); |
674 | } |
570 | } |
675 | } |
571 | } |
… | |
… | |
694 | |
590 | |
695 | if (level <= 40) |
591 | if (level <= 40) |
696 | return (20 + (level - 20) / 2) / difficulty; |
592 | return (20 + (level - 20) / 2) / difficulty; |
697 | |
593 | |
698 | return (30 + (level - 40) / 4) / difficulty; |
594 | return (30 + (level - 40) / 4) / difficulty; |
|
|
595 | } |
|
|
596 | |
|
|
597 | /** |
|
|
598 | * God checks item the player is using. |
|
|
599 | * Return either -1 (bad), 0 (neutral) or |
|
|
600 | * 1 (item is ok). If you are using the item of an enemy |
|
|
601 | * god, it can be bad...-b.t. |
|
|
602 | */ |
|
|
603 | static int |
|
|
604 | god_examines_item (object *god, object *item) |
|
|
605 | { |
|
|
606 | char buf[MAX_BUF]; |
|
|
607 | |
|
|
608 | if (!god || !item) |
|
|
609 | return 0; |
|
|
610 | |
|
|
611 | if (!item->title) |
|
|
612 | return 1; /* unclaimed item are ok */ |
|
|
613 | |
|
|
614 | sprintf (buf, "of %s", &god->name); |
|
|
615 | if (!strcmp (&item->title, buf)) |
|
|
616 | return 1; /* belongs to that God */ |
|
|
617 | |
|
|
618 | if (god->title) |
|
|
619 | { /* check if we have any enemy blessed item */ |
|
|
620 | sprintf (buf, "of %s", &god->title); |
|
|
621 | if (!strcmp (&item->title, buf)) |
|
|
622 | { |
|
|
623 | if (item->env) |
|
|
624 | { |
|
|
625 | char buf[MAX_BUF]; |
|
|
626 | |
|
|
627 | sprintf (buf, "Heretic! You are using %s!", query_name (item)); |
|
|
628 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, item->env, buf); |
|
|
629 | } |
|
|
630 | |
|
|
631 | return -1; |
|
|
632 | } |
|
|
633 | } |
|
|
634 | |
|
|
635 | return 0; /* item is sacred to a non-enemy god/or is otherwise magical */ |
699 | } |
636 | } |
700 | |
637 | |
701 | /** |
638 | /** |
702 | * God wants to enchant weapon. |
639 | * God wants to enchant weapon. |
703 | * Affected weapon is the applied one (weapon or bow). It's checked to make sure |
640 | * Affected weapon is the applied one (weapon or bow). It's checked to make sure |
… | |
… | |
710 | object *weapon; |
647 | object *weapon; |
711 | uint32 attacktype; |
648 | uint32 attacktype; |
712 | int tmp; |
649 | int tmp; |
713 | |
650 | |
714 | for (weapon = op->inv; weapon; weapon = weapon->below) |
651 | for (weapon = op->inv; weapon; weapon = weapon->below) |
715 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
652 | if ((weapon->type == WEAPON || weapon->type == BOW) && weapon->flag [FLAG_APPLIED]) |
716 | break; |
653 | break; |
717 | |
654 | |
718 | if (!weapon || god_examines_item (god, weapon) <= 0) |
655 | if (!weapon || god_examines_item (god, weapon) <= 0) |
719 | return 0; |
656 | return 0; |
720 | |
657 | |
… | |
… | |
758 | |
695 | |
759 | return 1; |
696 | return 1; |
760 | } |
697 | } |
761 | |
698 | |
762 | return 0; |
699 | return 0; |
|
|
700 | } |
|
|
701 | |
|
|
702 | /** |
|
|
703 | * Checks and maybe punishes someone praying. |
|
|
704 | * All applied items are examined, if player is using more items of other gods, |
|
|
705 | * s/he loses experience in praying or general experience if no praying. |
|
|
706 | */ |
|
|
707 | static int |
|
|
708 | god_examines_priest (object *op, object *god) |
|
|
709 | { |
|
|
710 | int reaction = 1; |
|
|
711 | object *item = NULL, *skop; |
|
|
712 | |
|
|
713 | for (item = op->inv; item; item = item->below) |
|
|
714 | if (item->flag [FLAG_APPLIED]) |
|
|
715 | reaction += god_examines_item (god, item) * (item->magic ? abs (item->magic) : 1); |
|
|
716 | |
|
|
717 | /* well, well. Looks like we screwed up. Time for god's revenge */ |
|
|
718 | if (reaction < 0) |
|
|
719 | { |
|
|
720 | int loss = 10000000; |
|
|
721 | int angry = abs (reaction); |
|
|
722 | |
|
|
723 | for (skop = op->inv; skop; skop = skop->below) |
|
|
724 | if (skop->type == SKILL && skop->subtype == SK_PRAYING) |
|
|
725 | break; |
|
|
726 | |
|
|
727 | if (skop) |
|
|
728 | loss = 0.05f * skop->stats.exp; |
|
|
729 | |
|
|
730 | change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? &skop->skill : "none", SK_SUBTRACT_SKILL_EXP); |
|
|
731 | |
|
|
732 | if (random_roll (0, angry, op, PREFER_LOW)) |
|
|
733 | { |
|
|
734 | object *tmp = get_archetype (LOOSE_MANA); |
|
|
735 | |
|
|
736 | cast_magic_storm (op, tmp, op->level + (angry * 3)); |
|
|
737 | } |
|
|
738 | |
|
|
739 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name); |
|
|
740 | } |
|
|
741 | |
|
|
742 | return reaction; |
763 | } |
743 | } |
764 | |
744 | |
765 | /** |
745 | /** |
766 | * Every once in a while the god will intervene to help the worshiper. |
746 | * Every once in a while the god will intervene to help the worshiper. |
767 | * Later, this fctn can be used to supply quests, etc for the |
747 | * Later, this fctn can be used to supply quests, etc for the |
768 | * priest. -b.t. |
748 | * priest. -b.t. |
769 | * called from pray_at_altar() currently. |
749 | * called from pray_at_altar() currently. |
770 | */ |
750 | */ |
771 | void |
751 | static void |
772 | god_intervention (object *op, object *god, object *skill) |
752 | god_intervention (object *op, object *god, object *skill) |
773 | { |
753 | { |
774 | treasure *tr; |
754 | treasure *tr; |
775 | |
755 | |
776 | if (!god || !god->randomitems) |
756 | if (!god || !god->randomitems) |
… | |
… | |
904 | { |
884 | { |
905 | object *depl; |
885 | object *depl; |
906 | archetype *at; |
886 | archetype *at; |
907 | int i; |
887 | int i; |
908 | |
888 | |
909 | if ((at = archetype::find (ARCH_DEPLETION)) == NULL) |
889 | if ((at = archetype::find (shstr_depletion)) == NULL) |
910 | { |
890 | { |
911 | LOG (llevError, "Could not find archetype depletion.\n"); |
891 | LOG (llevError, "Could not find archetype depletion.\n"); |
912 | continue; |
892 | continue; |
913 | } |
893 | } |
914 | |
894 | |
… | |
… | |
979 | |
959 | |
980 | new_draw_info (NDI_UNIQUE, 0, op, "You feel rapture."); |
960 | new_draw_info (NDI_UNIQUE, 0, op, "You feel rapture."); |
981 | } |
961 | } |
982 | |
962 | |
983 | /** |
963 | /** |
984 | * Checks and maybe punishes someone praying. |
964 | * Player prays at altar. |
985 | * All applied items are examined, if player is using more items of other gods, |
965 | * Checks for god changing, divine intervention, and so on. |
986 | * s/he loses experience in praying or general experience if no praying. |
|
|
987 | */ |
966 | */ |
988 | int |
967 | void |
989 | god_examines_priest (object *op, object *god) |
968 | pray_at_altar (object *pl, object *altar, object *skill) |
990 | { |
969 | { |
991 | int reaction = 1; |
970 | object *pl_god = find_god (determine_god (pl)); |
992 | object *item = NULL, *skop; |
|
|
993 | |
971 | |
994 | for (item = op->inv; item; item = item->below) |
972 | if (INVOKE_PLAYER (PRAY_ALTAR, pl->contr, ARG_OBJECT (altar), ARG_OBJECT (skill))) |
995 | if (QUERY_FLAG (item, FLAG_APPLIED)) |
|
|
996 | reaction += god_examines_item (god, item) * (item->magic ? abs (item->magic) : 1); |
|
|
997 | |
|
|
998 | /* well, well. Looks like we screwed up. Time for god's revenge */ |
|
|
999 | if (reaction < 0) |
|
|
1000 | { |
|
|
1001 | int loss = 10000000; |
|
|
1002 | int angry = abs (reaction); |
|
|
1003 | |
|
|
1004 | for (skop = op->inv; skop; skop = skop->below) |
|
|
1005 | if (skop->type == SKILL && skop->subtype == SK_PRAYING) |
|
|
1006 | break; |
|
|
1007 | |
|
|
1008 | if (skop) |
|
|
1009 | loss = 0.05f * skop->stats.exp; |
|
|
1010 | |
|
|
1011 | change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? &skop->skill : "none", SK_SUBTRACT_SKILL_EXP); |
|
|
1012 | |
|
|
1013 | if (random_roll (0, angry, op, PREFER_LOW)) |
|
|
1014 | { |
|
|
1015 | object *tmp = get_archetype (LOOSE_MANA); |
|
|
1016 | |
|
|
1017 | cast_magic_storm (op, tmp, op->level + (angry * 3)); |
|
|
1018 | } |
|
|
1019 | |
|
|
1020 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name); |
|
|
1021 | } |
|
|
1022 | |
|
|
1023 | return reaction; |
|
|
1024 | } |
|
|
1025 | |
|
|
1026 | /** |
|
|
1027 | * God checks item the player is using. |
|
|
1028 | * Return either -1 (bad), 0 (neutral) or |
|
|
1029 | * 1 (item is ok). If you are using the item of an enemy |
|
|
1030 | * god, it can be bad...-b.t. |
|
|
1031 | */ |
|
|
1032 | int |
|
|
1033 | god_examines_item (object *god, object *item) |
|
|
1034 | { |
|
|
1035 | char buf[MAX_BUF]; |
|
|
1036 | |
|
|
1037 | if (!god || !item) |
|
|
1038 | return 0; |
973 | return; |
1039 | |
974 | |
1040 | if (!item->title) |
975 | /* If non consecrate altar, don't do anything */ |
1041 | return 1; /* unclaimed item are ok */ |
976 | if (!altar->other_arch) |
|
|
977 | return; |
1042 | |
978 | |
1043 | sprintf (buf, "of %s", &god->name); |
979 | /* hmm. what happend depends on pl's current god, level, etc */ |
1044 | if (!strcmp (&item->title, buf)) |
980 | if (!pl_god) |
1045 | return 1; /* belongs to that God */ |
981 | { /*new convert */ |
|
|
982 | become_follower (pl, altar->other_arch); |
|
|
983 | return; |
|
|
984 | } |
|
|
985 | else if (pl_god->name == altar->other_arch->object::name) |
|
|
986 | { |
|
|
987 | /* pray at your gods altar */ |
|
|
988 | /* this leads to very low levels of wis and pray to result in no doubling! */ |
|
|
989 | int bonus = (pl->stats.Wis + skill->level) / 10; |
1046 | |
990 | |
1047 | if (god->title) |
991 | /* we can get neg grace up faster */ |
1048 | { /* check if we have any enemy blessed item */ |
992 | if (pl->stats.grace < 0) |
1049 | sprintf (buf, "of %s", &god->title); |
993 | pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10)); |
1050 | if (!strcmp (&item->title, buf)) |
994 | |
|
|
995 | /* we can super-charge grace to 2x max */ |
|
|
996 | if (pl->stats.grace < 2 * pl->stats.maxgrace) |
|
|
997 | pl->stats.grace += bonus / 2; |
|
|
998 | else |
|
|
999 | pl->stats.grace = 2 * pl->stats.maxgrace; |
|
|
1000 | |
|
|
1001 | /* Every once in a while, the god decides to checkup on their |
|
|
1002 | * follower, and may intervene to help them out. |
1051 | { |
1003 | */ |
1052 | if (item->env) |
1004 | bonus = max (1, bonus + max (pl->stats.luck, -3)); /* -- DAMN -- */ |
|
|
1005 | |
|
|
1006 | if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0) |
|
|
1007 | god_intervention (pl, pl_god, skill); |
|
|
1008 | } |
|
|
1009 | else |
|
|
1010 | { /* praying to another god! */ |
|
|
1011 | uint64 loss = 0; |
|
|
1012 | int angry = 1; |
|
|
1013 | |
|
|
1014 | /* I believe the logic for detecting opposing gods was completely |
|
|
1015 | * broken - I think it should work now. altar->other_arch |
|
|
1016 | * points to the god of this altar (which we have |
|
|
1017 | * already verified is non null). pl_god->other_arch |
|
|
1018 | * is the opposing god - we need to verify that exists before |
|
|
1019 | * using its values. |
|
|
1020 | */ |
|
|
1021 | if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname)) |
|
|
1022 | { |
|
|
1023 | angry = 2; |
|
|
1024 | if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) |
1053 | { |
1025 | { |
1054 | char buf[MAX_BUF]; |
1026 | object *tmp; |
1055 | |
1027 | |
1056 | sprintf (buf, "Heretic! You are using %s!", query_name (item)); |
1028 | /* you really screwed up */ |
1057 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, item->env, buf); |
1029 | angry = 3; |
|
|
1030 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foul Priest! %s punishes you!", &pl_god->name); |
|
|
1031 | tmp = get_archetype (LOOSE_MANA); |
|
|
1032 | cast_magic_storm (pl, tmp, pl_god->level + 20); |
1058 | } |
1033 | } |
|
|
1034 | else |
|
|
1035 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foolish heretic! %s is livid!", &pl_god->name); |
|
|
1036 | } |
|
|
1037 | else |
|
|
1038 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Heretic! %s is angered!", &pl_god->name); |
1059 | |
1039 | |
1060 | return -1; |
1040 | /* whether we will be successfull in defecting or not - |
|
|
1041 | * we lose experience from the clerical experience obj |
|
|
1042 | */ |
|
|
1043 | |
|
|
1044 | loss = angry * (skill->stats.exp / 10); |
|
|
1045 | if (loss) |
|
|
1046 | change_exp (pl, -random_roll64 (0, loss, pl, PREFER_LOW), skill ? &skill->skill : "none", SK_SUBTRACT_SKILL_EXP); |
|
|
1047 | |
|
|
1048 | /* May switch Gods, but its random chance based on our current level |
|
|
1049 | * note it gets harder to swap gods the higher we get |
|
|
1050 | */ |
|
|
1051 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
|
|
1052 | become_follower (pl, altar->other_arch); |
|
|
1053 | else |
1061 | } |
1054 | { |
|
|
1055 | /* 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."); |
|
|
1057 | pl->contr->fire_on = 0; |
|
|
1058 | pl->speed_left = 1.f; |
|
|
1059 | move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ |
|
|
1060 | } |
1062 | } |
1061 | } |
1063 | |
|
|
1064 | return 0; /* item is sacred to a non-enemy god/or is otherwise magical */ |
|
|
1065 | } |
|
|
1066 | |
|
|
1067 | /** |
|
|
1068 | * Returns priest's god's id. |
|
|
1069 | * Straight calls lookup_god_by_name |
|
|
1070 | */ |
|
|
1071 | int |
|
|
1072 | get_god (object *priest) |
|
|
1073 | { |
|
|
1074 | return lookup_god_by_name (determine_god (priest)); |
|
|
1075 | } |
1062 | } |
1076 | |
1063 | |
1077 | /** |
1064 | /** |
1078 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1065 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1079 | * Returns false if there was no race to assign to the slaying field of the spell, but |
1066 | * Returns false if there was no race to assign to the slaying field of the spell, but |