… | |
… | |
242 | next_tmp = tmp->below; |
242 | next_tmp = tmp->below; |
243 | |
243 | |
244 | /* 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 |
245 | * in that category, not something we need to worry about. |
245 | * in that category, not something we need to worry about. |
246 | */ |
246 | */ |
247 | if (tmp->type != SPELL || !QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
247 | if (tmp->type != SPELL || !tmp->flag [FLAG_STARTEQUIP]) |
248 | continue; |
248 | continue; |
249 | |
249 | |
250 | if (god->randomitems == NULL) |
250 | if (god->randomitems == NULL) |
251 | { |
251 | { |
252 | 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); |
… | |
… | |
285 | * Unapplies up to number worth of items of type |
285 | * Unapplies up to number worth of items of type |
286 | */ |
286 | */ |
287 | static void |
287 | static void |
288 | stop_using_item (object *op, int type, int number) |
288 | stop_using_item (object *op, int type, int number) |
289 | { |
289 | { |
290 | object *tmp; |
|
|
291 | |
|
|
292 | for (tmp = op->inv; tmp && number; tmp = tmp->below) |
290 | for (object *tmp = op->inv; tmp && number; tmp = tmp->below) |
293 | if (tmp->type == type && QUERY_FLAG (tmp, FLAG_APPLIED)) |
291 | if (tmp->type == type && tmp->flag [FLAG_APPLIED]) |
294 | { |
292 | { |
295 | apply_special (op, tmp, AP_UNAPPLY | AP_IGNORE_CURSE); |
293 | op->apply (tmp, AP_UNAPPLY | AP_IGNORE_CURSE); |
296 | number--; |
294 | --number; |
297 | } |
295 | } |
298 | } |
296 | } |
299 | |
297 | |
300 | /** |
298 | /** |
301 | * If the god does/doesnt have this flag, we |
299 | * If the god does/doesnt have this flag, we |
302 | * give/remove it from the experience object if it doesnt/does |
300 | * give/remove it from the experience object if it doesnt/does |
303 | * already exist. For players only! |
301 | * already exist. For players only! |
304 | */ |
302 | */ |
305 | static void |
303 | static inline void |
306 | update_priest_flag (object *god, object *exp_ob, uint32 flag) |
304 | update_priest_flag (object *god, object *exp_ob, uint32 flag) |
307 | { |
305 | { |
308 | if (QUERY_FLAG (god, flag) && !QUERY_FLAG (exp_ob, flag)) |
306 | exp_ob->flag [flag] = god->flag [flag]; |
309 | SET_FLAG (exp_ob, flag); |
307 | return; |
310 | else if (QUERY_FLAG (exp_ob, flag) && !QUERY_FLAG (god, flag)) |
308 | |
|
|
309 | // old code follows for reference... |
|
|
310 | if (god->flag [flag] && !exp_ob->flag [flag]) |
|
|
311 | exp_ob->set_flag (flag); |
|
|
312 | else if (exp_ob->flag [flag] && !god->flag [flag]) |
311 | { |
313 | { |
312 | /* When this is called with the exp_ob set to the player, |
314 | /* When this is called with the exp_ob set to the player, |
313 | * this check is broken, because most all players arch |
315 | * this check is broken, because most all players arch |
314 | * allow use of weapons. I'm not actually sure why this |
316 | * allow use of weapons. I'm not actually sure why this |
315 | * check is here - I guess if you had a case where the |
317 | * check is here - I guess if you had a case where the |
316 | * value in the archetype (wisdom) should over ride the restrictions |
318 | * 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 |
319 | * the god places on it, this may make sense. But I don't think |
318 | * there is any case like that. |
320 | * there is any case like that. |
319 | */ |
321 | */ |
320 | |
|
|
321 | /* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ |
322 | /* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ |
322 | CLEAR_FLAG (exp_ob, flag); |
323 | exp_ob->clr_flag (flag); |
323 | }; |
324 | }; |
324 | } |
325 | } |
325 | |
326 | |
326 | /** |
327 | /** |
327 | * Forbids or let player use something item type. |
328 | * Forbids or let player use something item type. |
… | |
… | |
331 | * string is the string to print out. |
332 | * string is the string to print out. |
332 | */ |
333 | */ |
333 | static int |
334 | static int |
334 | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
335 | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
335 | { |
336 | { |
336 | if (QUERY_FLAG (op->arch, flag)) |
337 | if (op->arch->flag [flag]) |
337 | if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) |
338 | if (op->flag [flag] != exp_obj->flag [flag]) |
338 | { |
339 | { |
339 | update_priest_flag (exp_obj, op, flag); |
340 | update_priest_flag (exp_obj, op, flag); |
340 | if (QUERY_FLAG (op, flag)) |
341 | if (op->flag [flag]) |
341 | new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); |
342 | new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); |
342 | else |
343 | else |
343 | { |
344 | { |
344 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string); |
345 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string); |
345 | return 1; |
346 | return 1; |
… | |
… | |
369 | for (item = op->inv; item; item = next) |
370 | for (item = op->inv; item; item = next) |
370 | { |
371 | { |
371 | next = item->below; |
372 | next = item->below; |
372 | |
373 | |
373 | // remove all invisible startequip items which are not skill, exp or force |
374 | // remove all invisible startequip items which are not skill, exp or force |
374 | if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible && |
375 | if (item->flag [FLAG_STARTEQUIP] && item->invisible && |
375 | (item->type != SKILL) && (item->type != FORCE)) |
376 | (item->type != SKILL) && (item->type != FORCE)) |
376 | { |
377 | { |
377 | if (item->type == SPELL) |
378 | if (item->type == SPELL) |
378 | { |
379 | { |
379 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); |
380 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); |
380 | esrv_remove_spell (op->contr, item); |
381 | esrv_remove_spell (op->contr, item); |
381 | } |
382 | } |
382 | |
383 | |
383 | player_unready_range_ob (op->contr, item); |
|
|
384 | item->destroy (); |
384 | item->destroy (); |
385 | } |
385 | } |
386 | } |
386 | } |
387 | |
387 | |
388 | /* remove any godgiven items from the old god */ |
388 | /* remove any godgiven items from the old god */ |
389 | if (old_god) |
389 | if (old_god) |
390 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
390 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
391 | if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP)) |
391 | if (tr->item && tr->item->flag [FLAG_STARTEQUIP]) |
392 | follower_remove_similar_item (op, tr->item); |
392 | follower_remove_similar_item (op, tr->item); |
393 | |
393 | |
394 | if (!op || !new_god) |
394 | if (!op || !new_god) |
395 | return; |
395 | return; |
396 | |
396 | |
… | |
… | |
427 | /* The archetype should always be defined - if we crash here because it doesn't, |
427 | /* The archetype should always be defined - if we crash here because it doesn't, |
428 | * things are really messed up anyways. |
428 | * things are really messed up anyways. |
429 | */ |
429 | */ |
430 | skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill); |
430 | skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill); |
431 | |
431 | |
432 | sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ |
432 | sk_applied = skop->flag [FLAG_APPLIED]; /* save skill status */ |
433 | |
433 | |
434 | /* Clear the "undead" status. We also need to force a call to change_abil, |
434 | /* Clear the "undead" status. We also need to force a call to change_abil, |
435 | * so I set undeadified for that. |
435 | * so I set undeadified for that. |
436 | * - gros, 21th July 2006. |
436 | * - gros, 21th July 2006. |
437 | */ |
437 | */ |
438 | if (old_god && QUERY_FLAG (old_god, FLAG_UNDEAD)) |
438 | if (old_god && old_god->flag [FLAG_UNDEAD]) |
439 | { |
439 | { |
440 | CLEAR_FLAG (skop, FLAG_UNDEAD); |
440 | skop->clr_flag (FLAG_UNDEAD); |
441 | undeadified = 1; |
441 | undeadified = 1; |
442 | } |
442 | } |
443 | |
443 | |
444 | if (skop->title) |
444 | if (skop->title) |
445 | { |
445 | { |
… | |
… | |
447 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title); |
447 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title); |
448 | |
448 | |
449 | /* The point of this is to really show what abilities the player just lost */ |
449 | /* The point of this is to really show what abilities the player just lost */ |
450 | if (sk_applied || undeadified) |
450 | if (sk_applied || undeadified) |
451 | { |
451 | { |
452 | CLEAR_FLAG (skop, FLAG_APPLIED); |
452 | skop->clr_flag (FLAG_APPLIED); |
453 | change_abil (op, skop); |
453 | change_abil (op, skop); |
454 | } |
454 | } |
455 | } |
455 | } |
456 | |
456 | |
457 | /* now change to the new gods attributes to exp_obj */ |
457 | /* now change to the new gods attributes to exp_obj */ |
… | |
… | |
508 | stop_using_item (op, BOOTS, 1); |
508 | stop_using_item (op, BOOTS, 1); |
509 | stop_using_item (op, GLOVES, 1); |
509 | stop_using_item (op, GLOVES, 1); |
510 | stop_using_item (op, SHIELD, 1); |
510 | stop_using_item (op, SHIELD, 1); |
511 | } |
511 | } |
512 | |
512 | |
513 | SET_FLAG (skop, FLAG_APPLIED); |
513 | skop->set_flag (FLAG_APPLIED); |
514 | change_abil (op, skop); |
514 | change_abil (op, skop); |
515 | |
515 | |
516 | /* return to previous skill status */ |
516 | /* return to previous skill status */ |
517 | if (!sk_applied) |
517 | if (!sk_applied) |
518 | CLEAR_FLAG (skop, FLAG_APPLIED); |
518 | skop->clr_flag (FLAG_APPLIED); |
519 | |
519 | |
520 | check_special_prayers (op, new_god); |
520 | check_special_prayers (op, new_god); |
521 | } |
521 | } |
522 | |
522 | |
523 | archetype * |
523 | archetype * |
… | |
… | |
556 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
556 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
557 | { |
557 | { |
558 | if (tmp->invisible) |
558 | if (tmp->invisible) |
559 | continue; |
559 | continue; |
560 | |
560 | |
561 | if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation) |
561 | if (tmp->flag [FLAG_DAMNED] && !remove_damnation) |
562 | continue; |
562 | continue; |
563 | |
563 | |
564 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
564 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
565 | { |
565 | { |
566 | success = 1; |
566 | success = 1; |
567 | CLEAR_FLAG (tmp, FLAG_DAMNED); |
567 | tmp->clr_flag (FLAG_DAMNED); |
568 | CLEAR_FLAG (tmp, FLAG_CURSED); |
568 | tmp->clr_flag (FLAG_CURSED); |
569 | CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); |
569 | tmp->clr_flag (FLAG_KNOWN_CURSED); |
570 | |
570 | |
571 | if (object *pl = tmp->visible_to ()) |
571 | if (object *pl = tmp->visible_to ()) |
572 | esrv_update_item (UPD_FLAGS, pl, tmp); |
572 | esrv_update_item (UPD_FLAGS, pl, tmp); |
573 | } |
573 | } |
574 | } |
574 | } |
… | |
… | |
650 | object *weapon; |
650 | object *weapon; |
651 | uint32 attacktype; |
651 | uint32 attacktype; |
652 | int tmp; |
652 | int tmp; |
653 | |
653 | |
654 | for (weapon = op->inv; weapon; weapon = weapon->below) |
654 | for (weapon = op->inv; weapon; weapon = weapon->below) |
655 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
655 | if ((weapon->type == WEAPON || weapon->type == BOW) && weapon->flag [FLAG_APPLIED]) |
656 | break; |
656 | break; |
657 | |
657 | |
658 | if (!weapon || god_examines_item (god, weapon) <= 0) |
658 | if (!weapon || god_examines_item (god, weapon) <= 0) |
659 | return 0; |
659 | return 0; |
660 | |
660 | |
… | |
… | |
712 | { |
712 | { |
713 | int reaction = 1; |
713 | int reaction = 1; |
714 | object *item = NULL, *skop; |
714 | object *item = NULL, *skop; |
715 | |
715 | |
716 | for (item = op->inv; item; item = item->below) |
716 | for (item = op->inv; item; item = item->below) |
717 | if (QUERY_FLAG (item, FLAG_APPLIED)) |
717 | if (item->flag [FLAG_APPLIED]) |
718 | reaction += god_examines_item (god, item) * (item->magic ? abs (item->magic) : 1); |
718 | reaction += god_examines_item (god, item) * (item->magic ? abs (item->magic) : 1); |
719 | |
719 | |
720 | /* well, well. Looks like we screwed up. Time for god's revenge */ |
720 | /* well, well. Looks like we screwed up. Time for god's revenge */ |
721 | if (reaction < 0) |
721 | if (reaction < 0) |
722 | { |
722 | { |