--- deliantra/server/server/apply.C 2006/09/11 11:46:52 1.23 +++ deliantra/server/server/apply.C 2006/09/11 20:26:41 1.24 @@ -1,7 +1,7 @@ /* * static char *rcsid_apply_c = - * "$Id: apply.C,v 1.23 2006/09/11 11:46:52 root Exp $"; + * "$Id: apply.C,v 1.24 2006/09/11 20:26:41 root Exp $"; */ /* @@ -739,22 +739,22 @@ switch (improver->stats.sp) { - case IMPROVE_STR: - return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Str), 1, "strength"); - case IMPROVE_DEX: - return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Dex), 1, "dexterity"); - case IMPROVE_CON: - return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Con), 1, "constitution"); - case IMPROVE_WIS: - return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Wis), 1, "wisdom"); - case IMPROVE_CHA: - return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Cha), 1, "charisma"); - case IMPROVE_INT: - return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Int), 1, "intelligence"); - case IMPROVE_POW: - return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Pow), 1, "power"); - default: - new_draw_info (NDI_UNIQUE, 0, op, "Unknown improvement type."); + case IMPROVE_STR: + return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Str), 1, "strength"); + case IMPROVE_DEX: + return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Dex), 1, "dexterity"); + case IMPROVE_CON: + return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Con), 1, "constitution"); + case IMPROVE_WIS: + return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Wis), 1, "wisdom"); + case IMPROVE_CHA: + return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Cha), 1, "charisma"); + case IMPROVE_INT: + return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Int), 1, "intelligence"); + case IMPROVE_POW: + return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Pow), 1, "power"); + default: + new_draw_info (NDI_UNIQUE, 0, op, "Unknown improvement type."); } LOG (llevError, "improve_weapon: Got to end of function\n"); return 0; @@ -1325,7 +1325,6 @@ } } - /** * Handles 'movement' of shop mats. * Returns 1 if 'op' was destroyed, 0 if not. @@ -1356,8 +1355,10 @@ int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); remove_ob (tmp); + if (i == -1) i = 0; + tmp->map = op->map; tmp->x = op->x + freearr_x[i]; tmp->y = op->y + freearr_y[i]; @@ -1379,9 +1380,8 @@ int i = find_free_spot (op, op->map, op->x, op->y, 1, 9); if (i != -1) - { - rv = transfer_ob (op, op->x + freearr_x[i], op->y + freearr_y[i], 0, shop_mat); - } + rv = transfer_ob (op, op->x + freearr_x[i], op->y + freearr_y[i], 0, shop_mat); + return 0; } /* Removed code that checked for multipart objects - it appears that @@ -1389,16 +1389,14 @@ */ rv = teleport (shop_mat, SHOP_MAT, op); } - /* immediate block below is only used for players */ else if (can_pay (op)) { + /* this is only used for players */ get_payment (op, op->inv); rv = teleport (shop_mat, SHOP_MAT, op); if (shop_mat->msg) - { - new_draw_info (NDI_UNIQUE, 0, op, shop_mat->msg); - } + new_draw_info (NDI_UNIQUE, 0, op, shop_mat->msg); /* This check below is a bit simplistic - generally it should be correct, * but there is never a guarantee that the bottom space on the map is * actually the shop floor. @@ -1406,6 +1404,7 @@ else if (!rv && !is_in_shop (op)) { opinion = shopkeeper_approval (op->map, op); + if (opinion > 0.9) new_draw_info (NDI_UNIQUE, 0, op, "The shopkeeper gives you a friendly wave."); else if (opinion > 0.75) @@ -1437,6 +1436,7 @@ rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; } } + CLEAR_FLAG (op, FLAG_NO_APPLY); return rv; } @@ -1709,7 +1709,7 @@ case SIGN: if (victim->type != PLAYER && trap->stats.food > 0) - goto leave; /* monsters musn't apply magic_mouths with counters */ + goto leave; /* monsters musn't apply magic_mouths with counters */ apply_sign (victim, trap, 1); goto leave; @@ -1819,20 +1819,20 @@ { switch ((int) learn_skill (op, tmp)) { - case 0: - new_draw_info (NDI_UNIQUE, 0, op, "You already possess the knowledge "); - new_draw_info_format (NDI_UNIQUE, 0, op, "held within the %s.\n", query_name (tmp)); - return; - - case 1: - new_draw_info_format (NDI_UNIQUE, 0, op, "You succeed in learning %s", &tmp->skill); - decrease_ob (tmp); - return; + case 0: + new_draw_info (NDI_UNIQUE, 0, op, "You already possess the knowledge "); + new_draw_info_format (NDI_UNIQUE, 0, op, "held within the %s.\n", query_name (tmp)); + return; + + case 1: + new_draw_info_format (NDI_UNIQUE, 0, op, "You succeed in learning %s", &tmp->skill); + decrease_ob (tmp); + return; - default: - new_draw_info_format (NDI_UNIQUE, 0, op, "You fail to learn the knowledge of the %s.\n", query_name (tmp)); - decrease_ob (tmp); - return; + default: + new_draw_info_format (NDI_UNIQUE, 0, op, "You fail to learn the knowledge of the %s.\n", query_name (tmp)); + decrease_ob (tmp); + return; } } @@ -2570,219 +2570,219 @@ switch (tmp->type) { - case CF_HANDLE: - new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); - play_sound_map (op->map, op->x, op->y, SOUND_TURN_HANDLE); - tmp->value = tmp->value ? 0 : 1; - SET_ANIMATION (tmp, tmp->value); - update_object (tmp, UP_OBJ_FACE); - push_button (tmp); - return 1; + case CF_HANDLE: + new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); + play_sound_map (op->map, op->x, op->y, SOUND_TURN_HANDLE); + tmp->value = tmp->value ? 0 : 1; + SET_ANIMATION (tmp, tmp->value); + update_object (tmp, UP_OBJ_FACE); + push_button (tmp); + return 1; - case TRIGGER: - if (check_trigger (tmp, op)) - { - new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); - play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE); - } - else - { - new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); - } - return 1; + case TRIGGER: + if (check_trigger (tmp, op)) + { + new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); + play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE); + } + else + { + new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); + } + return 1; - case EXIT: - if (op->type != PLAYER) - return 0; - if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) - { - new_draw_info_format (NDI_UNIQUE, 0, op, "The %s is closed.", query_name (tmp)); - } - else - { - /* Don't display messages for random maps. */ - if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2) && strncmp (EXIT_PATH (tmp), "/random/", 8)) - new_draw_info (NDI_NAVY, 0, op, tmp->msg); - enter_exit (op, tmp); - } - return 1; + case EXIT: + if (op->type != PLAYER) + return 0; + if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) + { + new_draw_info_format (NDI_UNIQUE, 0, op, "The %s is closed.", query_name (tmp)); + } + else + { + /* Don't display messages for random maps. */ + if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2) && strncmp (EXIT_PATH (tmp), "/random/", 8)) + new_draw_info (NDI_NAVY, 0, op, tmp->msg); + enter_exit (op, tmp); + } + return 1; - case SIGN: - apply_sign (op, tmp, 0); - return 1; + case SIGN: + apply_sign (op, tmp, 0); + return 1; - case BOOK: - if (op->type == PLAYER) - { - apply_book (op, tmp); - return 1; - } - else - { - return 0; - } + case BOOK: + if (op->type == PLAYER) + { + apply_book (op, tmp); + return 1; + } + else + { + return 0; + } - case SKILLSCROLL: - if (op->type == PLAYER) - { - apply_skillscroll (op, tmp); - return 1; - } - return 0; + case SKILLSCROLL: + if (op->type == PLAYER) + { + apply_skillscroll (op, tmp); + return 1; + } + return 0; - case SPELLBOOK: - if (op->type == PLAYER) - { - apply_spellbook (op, tmp); - return 1; - } - return 0; + case SPELLBOOK: + if (op->type == PLAYER) + { + apply_spellbook (op, tmp); + return 1; + } + return 0; - case SCROLL: - apply_scroll (op, tmp, 0); - return 1; + case SCROLL: + apply_scroll (op, tmp, 0); + return 1; - case POTION: - (void) apply_potion (op, tmp); - return 1; + case POTION: + (void) apply_potion (op, tmp); + return 1; - /* Eneq(@csd.uu.se): Handle apply on containers. */ - case CLOSE_CON: - if (op->type == PLAYER) - (void) esrv_apply_container (op, tmp->env); - else - (void) apply_container (op, tmp->env); - return 1; + /* Eneq(@csd.uu.se): Handle apply on containers. */ + case CLOSE_CON: + if (op->type == PLAYER) + (void) esrv_apply_container (op, tmp->env); + else + (void) apply_container (op, tmp->env); + return 1; - case CONTAINER: - if (op->type == PLAYER) - (void) esrv_apply_container (op, tmp); - else - (void) apply_container (op, tmp); - return 1; + case CONTAINER: + if (op->type == PLAYER) + (void) esrv_apply_container (op, tmp); + else + (void) apply_container (op, tmp); + return 1; - case TREASURE: - if (op->type == PLAYER) - { - apply_treasure (op, tmp); - return 1; - } - else - { - return 0; - } + case TREASURE: + if (op->type == PLAYER) + { + apply_treasure (op, tmp); + return 1; + } + else + { + return 0; + } - case WEAPON: - case ARMOUR: - case BOOTS: - case GLOVES: - case AMULET: - case GIRDLE: - case BRACERS: - case SHIELD: - case HELMET: - case RING: - case CLOAK: - case WAND: - case ROD: - case HORN: - case SKILL: - case BOW: - case LAMP: - case BUILDER: - case SKILL_TOOL: - if (tmp->env != op) - return 2; /* not in inventory */ - (void) apply_special (op, tmp, aflag); - return 1; + case WEAPON: + case ARMOUR: + case BOOTS: + case GLOVES: + case AMULET: + case GIRDLE: + case BRACERS: + case SHIELD: + case HELMET: + case RING: + case CLOAK: + case WAND: + case ROD: + case HORN: + case SKILL: + case BOW: + case LAMP: + case BUILDER: + case SKILL_TOOL: + if (tmp->env != op) + return 2; /* not in inventory */ + (void) apply_special (op, tmp, aflag); + return 1; - case DRINK: - case FOOD: - case FLESH: - apply_food (op, tmp); - return 1; + case DRINK: + case FOOD: + case FLESH: + apply_food (op, tmp); + return 1; - case POISON: - apply_poison (op, tmp); - return 1; + case POISON: + apply_poison (op, tmp); + return 1; - case SAVEBED: - if (op->type == PLAYER) - { - apply_savebed (op); - return 1; - } - else - { - return 0; - } + case SAVEBED: + if (op->type == PLAYER) + { + apply_savebed (op); + return 1; + } + else + { + return 0; + } - case ARMOUR_IMPROVER: - if (op->type == PLAYER) - { - apply_armour_improver (op, tmp); - return 1; - } - else - { - return 0; - } + case ARMOUR_IMPROVER: + if (op->type == PLAYER) + { + apply_armour_improver (op, tmp); + return 1; + } + else + { + return 0; + } - case WEAPON_IMPROVER: - (void) check_improve_weapon (op, tmp); - return 1; + case WEAPON_IMPROVER: + (void) check_improve_weapon (op, tmp); + return 1; - case CLOCK: - if (op->type == PLAYER) - { - char buf[MAX_BUF]; - timeofday_t tod; + case CLOCK: + if (op->type == PLAYER) + { + char buf[MAX_BUF]; + timeofday_t tod; - get_tod (&tod); - sprintf (buf, "It is %d minute%s past %d o'clock %s", - tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), - ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")); - play_sound_player_only (op->contr, SOUND_CLOCK, 0, 0); - new_draw_info (NDI_UNIQUE, 0, op, buf); - return 1; - } - else - { - return 0; - } + get_tod (&tod); + sprintf (buf, "It is %d minute%s past %d o'clock %s", + tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), + ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")); + play_sound_player_only (op->contr, SOUND_CLOCK, 0, 0); + new_draw_info (NDI_UNIQUE, 0, op, buf); + return 1; + } + else + { + return 0; + } - case MENU: - if (op->type == PLAYER) - { - shop_listing (op); - return 1; - } - else - { - return 0; - } + case MENU: + if (op->type == PLAYER) + { + shop_listing (op); + return 1; + } + else + { + return 0; + } - case POWER_CRYSTAL: - apply_power_crystal (op, tmp); /* see egoitem.c */ - return 1; + case POWER_CRYSTAL: + apply_power_crystal (op, tmp); /* see egoitem.c */ + return 1; - case LIGHTER: /* for lighting torches/lanterns/etc */ - if (op->type == PLAYER) - { - apply_lighter (op, tmp); - return 1; - } - else - { - return 0; - } + case LIGHTER: /* for lighting torches/lanterns/etc */ + if (op->type == PLAYER) + { + apply_lighter (op, tmp); + return 1; + } + else + { + return 0; + } - case ITEM_TRANSFORMER: - apply_item_transformer (op, tmp); - return 1; + case ITEM_TRANSFORMER: + apply_item_transformer (op, tmp); + return 1; - default: - return 0; + default: + return 0; } } @@ -2898,110 +2898,110 @@ CLEAR_FLAG (op, FLAG_APPLIED); switch (op->type) { - case WEAPON: - new_draw_info_format (NDI_UNIQUE, 0, who, "You unwield %s.", query_name (op)); - - (void) change_abil (who, op); - if (QUERY_FLAG (who, FLAG_READY_WEAPON)) - CLEAR_FLAG (who, FLAG_READY_WEAPON); - clear_skill (who); - break; + case WEAPON: + new_draw_info_format (NDI_UNIQUE, 0, who, "You unwield %s.", query_name (op)); - case SKILL: /* allows objects to impart skills */ - case SKILL_TOOL: - if (op != who->chosen_skill) - { - LOG (llevError, "BUG: apply_special(): applied skill is not a chosen skill\n"); - } - if (who->type == PLAYER) - { - if (who->contr->shoottype == range_skill) - who->contr->shoottype = range_none; - if (!op->invisible) - { - new_draw_info_format (NDI_UNIQUE, 0, who, "You stop using the %s.", query_name (op)); - } - else - { - new_draw_info_format (NDI_UNIQUE, 0, who, "You can no longer use the skill: %s.", &op->skill); - } - } - (void) change_abil (who, op); - who->chosen_skill = NULL; - CLEAR_FLAG (who, FLAG_READY_SKILL); - break; + (void) change_abil (who, op); + if (QUERY_FLAG (who, FLAG_READY_WEAPON)) + CLEAR_FLAG (who, FLAG_READY_WEAPON); + clear_skill (who); + break; - case ARMOUR: - case HELMET: - case SHIELD: - case RING: - case BOOTS: - case GLOVES: - case AMULET: - case GIRDLE: - case BRACERS: - case CLOAK: - new_draw_info_format (NDI_UNIQUE, 0, who, "You unwear %s.", query_name (op)); - (void) change_abil (who, op); - break; - case LAMP: - new_draw_info_format (NDI_UNIQUE, 0, who, "You turn off your %s.", &op->name); - tmp2 = arch_to_object (op->other_arch); - tmp2->x = op->x; - tmp2->y = op->y; - tmp2->map = op->map; - tmp2->below = op->below; - tmp2->above = op->above; - tmp2->stats.food = op->stats.food; - CLEAR_FLAG (tmp2, FLAG_APPLIED); - if (QUERY_FLAG (op, FLAG_INV_LOCKED)) - SET_FLAG (tmp2, FLAG_INV_LOCKED); - if (who->type == PLAYER) - esrv_del_item (who->contr, (tag_t) op->count); - remove_ob (op); - free_object (op); - insert_ob_in_ob (tmp2, who); - fix_player (who); - if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) - { - if (who->type == PLAYER) - { - new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); - SET_FLAG (tmp2, FLAG_KNOWN_CURSED); - } - } - if (who->type == PLAYER) - esrv_send_item (who, tmp2); - return 1; /* otherwise, an attempt to drop causes problems */ - break; - case BOW: - case WAND: - case ROD: - case HORN: - clear_skill (who); - new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); - if (who->type == PLAYER) - { + case SKILL: /* allows objects to impart skills */ + case SKILL_TOOL: + if (op != who->chosen_skill) + { + LOG (llevError, "BUG: apply_special(): applied skill is not a chosen skill\n"); + } + if (who->type == PLAYER) + { + if (who->contr->shoottype == range_skill) who->contr->shoottype = range_none; - } - else - { - if (op->type == BOW) - CLEAR_FLAG (who, FLAG_READY_BOW); - else - CLEAR_FLAG (who, FLAG_READY_RANGE); - } - break; + if (!op->invisible) + { + new_draw_info_format (NDI_UNIQUE, 0, who, "You stop using the %s.", query_name (op)); + } + else + { + new_draw_info_format (NDI_UNIQUE, 0, who, "You can no longer use the skill: %s.", &op->skill); + } + } + (void) change_abil (who, op); + who->chosen_skill = NULL; + CLEAR_FLAG (who, FLAG_READY_SKILL); + break; - case BUILDER: - new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); - who->contr->shoottype = range_none; - who->contr->ranges[range_builder] = NULL; - break; + case ARMOUR: + case HELMET: + case SHIELD: + case RING: + case BOOTS: + case GLOVES: + case AMULET: + case GIRDLE: + case BRACERS: + case CLOAK: + new_draw_info_format (NDI_UNIQUE, 0, who, "You unwear %s.", query_name (op)); + (void) change_abil (who, op); + break; + case LAMP: + new_draw_info_format (NDI_UNIQUE, 0, who, "You turn off your %s.", &op->name); + tmp2 = arch_to_object (op->other_arch); + tmp2->x = op->x; + tmp2->y = op->y; + tmp2->map = op->map; + tmp2->below = op->below; + tmp2->above = op->above; + tmp2->stats.food = op->stats.food; + CLEAR_FLAG (tmp2, FLAG_APPLIED); + if (QUERY_FLAG (op, FLAG_INV_LOCKED)) + SET_FLAG (tmp2, FLAG_INV_LOCKED); + if (who->type == PLAYER) + esrv_del_item (who->contr, (tag_t) op->count); + remove_ob (op); + free_object (op); + insert_ob_in_ob (tmp2, who); + fix_player (who); + if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) + { + if (who->type == PLAYER) + { + new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); + SET_FLAG (tmp2, FLAG_KNOWN_CURSED); + } + } + if (who->type == PLAYER) + esrv_send_item (who, tmp2); + return 1; /* otherwise, an attempt to drop causes problems */ + break; + case BOW: + case WAND: + case ROD: + case HORN: + clear_skill (who); + new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); + if (who->type == PLAYER) + { + who->contr->shoottype = range_none; + } + else + { + if (op->type == BOW) + CLEAR_FLAG (who, FLAG_READY_BOW); + else + CLEAR_FLAG (who, FLAG_READY_RANGE); + } + break; - default: - new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); - break; + case BUILDER: + new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); + who->contr->shoottype = range_none; + who->contr->ranges[range_builder] = NULL; + break; + + default: + new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); + break; } fix_player (who); @@ -3433,177 +3433,177 @@ switch (op->type) { - case WEAPON: - if (!check_weapon_power (who, op->last_eat)) - { - new_draw_info (NDI_UNIQUE, 0, who, "That weapon is too powerful for you to use."); - new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); - if (tmp != NULL) - (void) insert_ob_in_ob (tmp, who); - return 1; - } - if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) - { - /* if the weapon does not have the name as the character, can't use it. */ - /* (Ragnarok's sword attempted to be used by Foo: won't work) */ - new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); - if (tmp != NULL) - (void) insert_ob_in_ob (tmp, who); - return 1; - } - SET_FLAG (op, FLAG_APPLIED); + case WEAPON: + if (!check_weapon_power (who, op->last_eat)) + { + new_draw_info (NDI_UNIQUE, 0, who, "That weapon is too powerful for you to use."); + new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); + if (tmp != NULL) + (void) insert_ob_in_ob (tmp, who); + return 1; + } + if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) + { + /* if the weapon does not have the name as the character, can't use it. */ + /* (Ragnarok's sword attempted to be used by Foo: won't work) */ + new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); + if (tmp != NULL) + (void) insert_ob_in_ob (tmp, who); + return 1; + } + SET_FLAG (op, FLAG_APPLIED); - if (skop) - change_skill (who, skop, 1); - if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) - SET_FLAG (who, FLAG_READY_WEAPON); + if (skop) + change_skill (who, skop, 1); + if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) + SET_FLAG (who, FLAG_READY_WEAPON); - new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); + new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); - (void) change_abil (who, op); - break; + (void) change_abil (who, op); + break; - case ARMOUR: - case HELMET: - case SHIELD: - case BOOTS: - case GLOVES: - case GIRDLE: - case BRACERS: - case CLOAK: - case RING: - case AMULET: - SET_FLAG (op, FLAG_APPLIED); - new_draw_info_format (NDI_UNIQUE, 0, who, "You wear %s.", query_name (op)); - (void) change_abil (who, op); - break; - case LAMP: - if (op->stats.food < 1) - { - new_draw_info_format (NDI_UNIQUE, 0, who, "Your %s is out of" " fuel!", &op->name); - return 1; - } - new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); - tmp2 = arch_to_object (op->other_arch); - tmp2->stats.food = op->stats.food; - SET_FLAG (tmp2, FLAG_APPLIED); - if (QUERY_FLAG (op, FLAG_INV_LOCKED)) - SET_FLAG (tmp2, FLAG_INV_LOCKED); - insert_ob_in_ob (tmp2, who); - - /* Remove the old lantern */ - if (who->type == PLAYER) - esrv_del_item (who->contr, (tag_t) op->count); - remove_ob (op); - free_object (op); + case ARMOUR: + case HELMET: + case SHIELD: + case BOOTS: + case GLOVES: + case GIRDLE: + case BRACERS: + case CLOAK: + case RING: + case AMULET: + SET_FLAG (op, FLAG_APPLIED); + new_draw_info_format (NDI_UNIQUE, 0, who, "You wear %s.", query_name (op)); + (void) change_abil (who, op); + break; + case LAMP: + if (op->stats.food < 1) + { + new_draw_info_format (NDI_UNIQUE, 0, who, "Your %s is out of" " fuel!", &op->name); + return 1; + } + new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); + tmp2 = arch_to_object (op->other_arch); + tmp2->stats.food = op->stats.food; + SET_FLAG (tmp2, FLAG_APPLIED); + if (QUERY_FLAG (op, FLAG_INV_LOCKED)) + SET_FLAG (tmp2, FLAG_INV_LOCKED); + insert_ob_in_ob (tmp2, who); + + /* Remove the old lantern */ + if (who->type == PLAYER) + esrv_del_item (who->contr, (tag_t) op->count); + remove_ob (op); + free_object (op); - /* insert the portion that was split off */ - if (tmp != NULL) - { - (void) insert_ob_in_ob (tmp, who); - if (who->type == PLAYER) - esrv_send_item (who, tmp); - } - fix_player (who); - if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) - { - if (who->type == PLAYER) - { - new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); - SET_FLAG (tmp2, FLAG_KNOWN_CURSED); - } - } - if (who->type == PLAYER) - esrv_send_item (who, tmp2); - return 0; - break; + /* insert the portion that was split off */ + if (tmp != NULL) + { + (void) insert_ob_in_ob (tmp, who); + if (who->type == PLAYER) + esrv_send_item (who, tmp); + } + fix_player (who); + if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) + { + if (who->type == PLAYER) + { + new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); + SET_FLAG (tmp2, FLAG_KNOWN_CURSED); + } + } + if (who->type == PLAYER) + esrv_send_item (who, tmp2); + return 0; + break; - /* this part is needed for skill-tools */ - case SKILL: - case SKILL_TOOL: - if (who->chosen_skill) - { - LOG (llevError, "BUG: apply_special(): can't apply two skills\n"); - return 1; - } - if (who->type == PLAYER) - { - who->contr->shoottype = range_skill; - who->contr->ranges[range_skill] = op; - if (!op->invisible) - { - new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); - new_draw_info_format (NDI_UNIQUE, 0, who, "You can now use the skill: %s.", &op->skill); - } - else - { - new_draw_info_format (NDI_UNIQUE, 0, who, "Readied skill: %s.", op->skill ? &op->skill : &op->name); - } - } - SET_FLAG (op, FLAG_APPLIED); - (void) change_abil (who, op); - who->chosen_skill = op; - SET_FLAG (who, FLAG_READY_SKILL); - break; + /* this part is needed for skill-tools */ + case SKILL: + case SKILL_TOOL: + if (who->chosen_skill) + { + LOG (llevError, "BUG: apply_special(): can't apply two skills\n"); + return 1; + } + if (who->type == PLAYER) + { + who->contr->shoottype = range_skill; + who->contr->ranges[range_skill] = op; + if (!op->invisible) + { + new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); + new_draw_info_format (NDI_UNIQUE, 0, who, "You can now use the skill: %s.", &op->skill); + } + else + { + new_draw_info_format (NDI_UNIQUE, 0, who, "Readied skill: %s.", op->skill ? &op->skill : &op->name); + } + } + SET_FLAG (op, FLAG_APPLIED); + (void) change_abil (who, op); + who->chosen_skill = op; + SET_FLAG (who, FLAG_READY_SKILL); + break; - case BOW: - if (!check_weapon_power (who, op->last_eat)) - { - new_draw_info (NDI_UNIQUE, 0, who, "That item is too powerful for you to use."); - new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); - if (tmp != NULL) - (void) insert_ob_in_ob (tmp, who); - return 1; - } - if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) - { - new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); - if (tmp != NULL) - (void) insert_ob_in_ob (tmp, who); - return 1; - } - /*FALLTHROUGH*/ case WAND: - case ROD: - case HORN: - /* check for skill, alter player status */ - SET_FLAG (op, FLAG_APPLIED); - if (skop) - change_skill (who, skop, 0); - new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); + case BOW: + if (!check_weapon_power (who, op->last_eat)) + { + new_draw_info (NDI_UNIQUE, 0, who, "That item is too powerful for you to use."); + new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); + if (tmp != NULL) + (void) insert_ob_in_ob (tmp, who); + return 1; + } + if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) + { + new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); + if (tmp != NULL) + (void) insert_ob_in_ob (tmp, who); + return 1; + } + /*FALLTHROUGH*/ case WAND: + case ROD: + case HORN: + /* check for skill, alter player status */ + SET_FLAG (op, FLAG_APPLIED); + if (skop) + change_skill (who, skop, 0); + new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); - if (who->type == PLAYER) - { - if (op->type == BOW) - { - (void) change_abil (who, op); - new_draw_info_format (NDI_UNIQUE, 0, who, - "You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op)); - who->contr->shoottype = range_bow; - } - else - { - who->contr->shoottype = range_misc; - } - } - else - { - if (op->type == BOW) - SET_FLAG (who, FLAG_READY_BOW); - else - SET_FLAG (who, FLAG_READY_RANGE); - } - break; + if (who->type == PLAYER) + { + if (op->type == BOW) + { + (void) change_abil (who, op); + new_draw_info_format (NDI_UNIQUE, 0, who, + "You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op)); + who->contr->shoottype = range_bow; + } + else + { + who->contr->shoottype = range_misc; + } + } + else + { + if (op->type == BOW) + SET_FLAG (who, FLAG_READY_BOW); + else + SET_FLAG (who, FLAG_READY_RANGE); + } + break; - case BUILDER: - if (who->contr->ranges[range_builder]) - unapply_special (who, who->contr->ranges[range_builder], 0); - who->contr->shoottype = range_builder; - who->contr->ranges[range_builder] = op; - new_draw_info_format (NDI_UNIQUE, 0, who, "You ready your %s.", query_name (op)); - break; + case BUILDER: + if (who->contr->ranges[range_builder]) + unapply_special (who, who->contr->ranges[range_builder], 0); + who->contr->shoottype = range_builder; + who->contr->ranges[range_builder] = op; + new_draw_info_format (NDI_UNIQUE, 0, who, "You ready your %s.", query_name (op)); + break; - default: - new_draw_info_format (NDI_UNIQUE, 0, who, "You apply %s.", query_name (op)); + default: + new_draw_info_format (NDI_UNIQUE, 0, who, "You apply %s.", query_name (op)); } /* end of switch op->type */ SET_FLAG (op, FLAG_APPLIED); @@ -3660,55 +3660,55 @@ switch (op->type) { - case SHOP_FLOOR: - if (!HAS_RANDOM_ITEMS (op)) - return 0; - do - { - i = 10; /* let's give it 10 tries */ - while ((tmp = generate_treasure (op->randomitems, - op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); - if (tmp == NULL) - return 0; - if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) - { - free_object (tmp); - tmp = NULL; - } - } - while (!tmp); - tmp->x = op->x; - tmp->y = op->y; - SET_FLAG (tmp, FLAG_UNPAID); - insert_ob_in_map (tmp, op->map, NULL, 0); - CLEAR_FLAG (op, FLAG_AUTO_APPLY); - identify (tmp); - break; - - case TREASURE: - if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) - return 0; - while ((op->stats.hp--) > 0) - create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, - op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); - - /* If we generated an object and put it in this object inventory, - * move it to the parent object as the current object is about - * to disappear. An example of this item is the random_* stuff - * that is put inside other objects. - */ - for (tmp = op->inv; tmp; tmp = tmp2) - { - tmp2 = tmp->below; - remove_ob (tmp); - if (op->env) - insert_ob_in_ob (tmp, op->env); - else + case SHOP_FLOOR: + if (!HAS_RANDOM_ITEMS (op)) + return 0; + do + { + i = 10; /* let's give it 10 tries */ + while ((tmp = generate_treasure (op->randomitems, + op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); + if (tmp == NULL) + return 0; + if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) + { free_object (tmp); - } - remove_ob (op); - free_object (op); - break; + tmp = NULL; + } + } + while (!tmp); + tmp->x = op->x; + tmp->y = op->y; + SET_FLAG (tmp, FLAG_UNPAID); + insert_ob_in_map (tmp, op->map, NULL, 0); + CLEAR_FLAG (op, FLAG_AUTO_APPLY); + identify (tmp); + break; + + case TREASURE: + if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) + return 0; + while ((op->stats.hp--) > 0) + create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, + op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); + + /* If we generated an object and put it in this object inventory, + * move it to the parent object as the current object is about + * to disappear. An example of this item is the random_* stuff + * that is put inside other objects. + */ + for (tmp = op->inv; tmp; tmp = tmp2) + { + tmp2 = tmp->below; + remove_ob (tmp); + if (op->env) + insert_ob_in_ob (tmp, op->env); + else + free_object (tmp); + } + remove_ob (op); + free_object (op); + break; } return tmp ? 1 : 0; } @@ -4054,82 +4054,82 @@ switch (change->type) { - case CLASS: - { - living *stats = &(pl->contr->orig_stats); - living *ns = &(change->stats); - object *walk; - int flag_change_face = 1; - - /* the following code assigns stats up to the stat max - * for the race, and if the stat max is exceeded, - * tries to randomly reassign the excess stat - */ - int i, j; + case CLASS: + { + living *stats = &(pl->contr->orig_stats); + living *ns = &(change->stats); + object *walk; + int flag_change_face = 1; + + /* the following code assigns stats up to the stat max + * for the race, and if the stat max is exceeded, + * tries to randomly reassign the excess stat + */ + int i, j; - for (i = 0; i < NUM_STATS; i++) - { - sint8 stat = get_attr_value (stats, i); - int race_bonus = get_attr_value (&(pl->arch->clone.stats), i); + for (i = 0; i < NUM_STATS; i++) + { + sint8 stat = get_attr_value (stats, i); + int race_bonus = get_attr_value (&(pl->arch->clone.stats), i); - stat += get_attr_value (ns, i); - if (stat > 20 + race_bonus) - { - excess_stat++; - stat = 20 + race_bonus; - } - set_attr_value (stats, i, stat); - } + stat += get_attr_value (ns, i); + if (stat > 20 + race_bonus) + { + excess_stat++; + stat = 20 + race_bonus; + } + set_attr_value (stats, i, stat); + } - for (j = 0; excess_stat > 0 && j < 100; j++) - { /* try 100 times to assign excess stats */ - int i = rndm (0, 6); - int stat = get_attr_value (stats, i); - int race_bonus = get_attr_value (&(pl->arch->clone.stats), i); - - if (i == CHA) - continue; /* exclude cha from this */ - if (stat < 20 + race_bonus) - { - change_attr_value (stats, i, 1); - excess_stat--; - } - } + for (j = 0; excess_stat > 0 && j < 100; j++) + { /* try 100 times to assign excess stats */ + int i = rndm (0, 6); + int stat = get_attr_value (stats, i); + int race_bonus = get_attr_value (&(pl->arch->clone.stats), i); + + if (i == CHA) + continue; /* exclude cha from this */ + if (stat < 20 + race_bonus) + { + change_attr_value (stats, i, 1); + excess_stat--; + } + } - /* insert the randomitems from the change's treasurelist into - * the player ref: player.c - */ - if (change->randomitems != NULL) - give_initial_items (pl, change->randomitems); + /* insert the randomitems from the change's treasurelist into + * the player ref: player.c + */ + if (change->randomitems != NULL) + give_initial_items (pl, change->randomitems); - /* set up the face, for some races. */ + /* set up the face, for some races. */ - /* first, look for the force object banning - * changing the face. Certain races never change face with class. - */ - for (walk = pl->inv; walk != NULL; walk = walk->below) - if (!strcmp (walk->name, "NOCLASSFACECHANGE")) - flag_change_face = 0; + /* first, look for the force object banning + * changing the face. Certain races never change face with class. + */ + for (walk = pl->inv; walk != NULL; walk = walk->below) + if (!strcmp (walk->name, "NOCLASSFACECHANGE")) + flag_change_face = 0; - if (flag_change_face) - { - pl->animation_id = GET_ANIM_ID (change); - pl->face = change->face; + if (flag_change_face) + { + pl->animation_id = GET_ANIM_ID (change); + pl->face = change->face; - if (QUERY_FLAG (change, FLAG_ANIMATE)) - SET_FLAG (pl, FLAG_ANIMATE); - else - CLEAR_FLAG (pl, FLAG_ANIMATE); - } + if (QUERY_FLAG (change, FLAG_ANIMATE)) + SET_FLAG (pl, FLAG_ANIMATE); + else + CLEAR_FLAG (pl, FLAG_ANIMATE); + } - /* check the special case of can't use weapons */ - /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ - if (!strcmp (change->name, "monk")) - CLEAR_FLAG (pl, FLAG_USE_WEAPON); + /* check the special case of can't use weapons */ + /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ + if (!strcmp (change->name, "monk")) + CLEAR_FLAG (pl, FLAG_USE_WEAPON); - break; - } + break; + } } }