--- deliantra/server/common/living.C 2010/03/28 18:44:21 1.114 +++ deliantra/server/common/living.C 2010/04/30 09:36:32 1.120 @@ -141,7 +141,7 @@ Both come in handy at least in function add_exp() */ -#define MAX_EXPERIENCE levels[settings.max_level] +#define MAX_EXPERIENCE levels [settings.max_level] /* because exp_obj sum to make the total score, * we cannot allow that sum to exceed the maximum @@ -158,9 +158,7 @@ * -b.t. */ -#define MAX_EXP_IN_OBJ levels[settings.max_level]/(MAX_EXP_CAT - 1) - -extern sint64 *levels; +#define MAX_EXP_IN_OBJ MAX_EXP_IN_OBJ / (MAX_EXP_CAT - 1) #define MAX_SAVE_LEVEL 110 @@ -463,7 +461,7 @@ else { new_draw_info (NDI_UNIQUE, 0, op, "You are blinded."); - SET_FLAG (op, FLAG_BLIND); + op->set_flag (FLAG_BLIND); if (op->type == PLAYER) op->contr->do_los = 1; } @@ -475,7 +473,7 @@ else { new_draw_info (NDI_UNIQUE, 0, op, "Your vision returns."); - CLEAR_FLAG (op, FLAG_BLIND); + op->clr_flag (FLAG_BLIND); if (op->type == PLAYER) op->contr->do_los = 1; } @@ -523,29 +521,33 @@ DIFF_MSG (flag * tmp->stats.luck, "You feel more lucky.", "You feel less lucky."); } - if (tmp->stats.hp && op->type == PLAYER) + if (digest_types [tmp->type]) { - success = 1; - DIFF_MSG (flag * tmp->stats.hp, "You feel much more healthy!", "You feel much less healthy!"); - } + if (tmp->stats.hp && op->type == PLAYER) + { + success = 1; + DIFF_MSG (flag * tmp->stats.hp, "You feel much more healthy!", "You feel much less healthy!"); + } - if (tmp->stats.sp && op->type == PLAYER && tmp->type != SKILL) - { - success = 1; - DIFF_MSG (flag * tmp->stats.sp, "You feel one with the powers of magic!", "You suddenly feel very mundane."); - } + if (tmp->stats.sp && op->type == PLAYER + && tmp->type != SKILL && tmp->type != BOW) + { + success = 1; + DIFF_MSG (flag * tmp->stats.sp, "You feel one with the powers of magic!", "You suddenly feel very mundane."); + } - /* for the future when artifacts set this -b.t. */ - if (tmp->stats.grace && op->type == PLAYER) - { - success = 1; - DIFF_MSG (flag * tmp->stats.grace, "You feel closer to your god!", "You suddenly feel less holy."); - } + /* for the future when artifacts set this -b.t. */ + if (tmp->stats.grace && op->type == PLAYER) + { + success = 1; + DIFF_MSG (flag * tmp->stats.grace, "You feel closer to your god!", "You suddenly feel less holy."); + } - if (tmp->stats.food && op->type == PLAYER) - { - success = 1; - DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up."); + if (tmp->stats.food && op->type == PLAYER) + { + success = 1; + DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up."); + } } /* Messages for changed resistance */ @@ -608,7 +610,7 @@ { tmp = at->instance (); tmp = insert_ob_in_ob (tmp, this); - SET_FLAG (tmp, FLAG_APPLIED); + tmp->set_flag (FLAG_APPLIED); } } @@ -638,7 +640,7 @@ tmp = at->instance (); tmp = insert_ob_in_ob (tmp, this); - SET_FLAG (tmp, FLAG_APPLIED); + tmp->set_flag (FLAG_APPLIED); } if (value) @@ -702,32 +704,6 @@ } } -/* These are the items that currently can change digestion, regeneration, - * spell point recovery and mana point recovery. Seems sort of an arbitary - * list, but other items store other info into stats array. - */ -static struct digest_types : std::bitset -{ - digest_types () - { - set (WEAPON); - set (BOW); - set (ARMOUR); - set (HELMET); - set (SHIELD); - set (RING); - set (BOOTS); - set (GLOVES); - set (AMULET); - set (GIRDLE); - set (BRACERS); - set (CLOAK); - set (DISEASE); - set (FORCE); - set (SKILL); - } -} digest_types; - static struct copy_flags : object::flags_t { copy_flags () @@ -791,20 +767,20 @@ slaying = 0; - if (!QUERY_FLAG (this, FLAG_WIZ)) + if (!this->flag [FLAG_WIZ]) { - CLEAR_FLAG (this, FLAG_XRAYS); - CLEAR_FLAG (this, FLAG_MAKE_INVIS); + this->clr_flag (FLAG_XRAYS); + this->clr_flag (FLAG_MAKE_INVIS); } - CLEAR_FLAG (this, FLAG_LIFESAVE); - CLEAR_FLAG (this, FLAG_STEALTH); - CLEAR_FLAG (this, FLAG_BLIND); + this->clr_flag (FLAG_LIFESAVE); + this->clr_flag (FLAG_STEALTH); + this->clr_flag (FLAG_BLIND); - if (!QUERY_FLAG (arch, FLAG_REFL_SPELL )) CLEAR_FLAG (this, FLAG_REFL_SPELL); - if (!QUERY_FLAG (arch, FLAG_REFL_MISSILE)) CLEAR_FLAG (this, FLAG_REFL_MISSILE); - if (!QUERY_FLAG (arch, FLAG_UNDEAD )) CLEAR_FLAG (this, FLAG_UNDEAD); - if (!QUERY_FLAG (arch, FLAG_SEE_IN_DARK )) CLEAR_FLAG (this, FLAG_SEE_IN_DARK); + if (!arch->flag [FLAG_REFL_SPELL ]) this->clr_flag (FLAG_REFL_SPELL); + if (!arch->flag [FLAG_REFL_MISSILE]) this->clr_flag (FLAG_REFL_MISSILE); + if (!arch->flag [FLAG_UNDEAD ]) this->clr_flag (FLAG_UNDEAD); + if (!arch->flag [FLAG_SEE_IN_DARK ]) this->clr_flag (FLAG_SEE_IN_DARK); path_attuned = arch->path_attuned; path_repelled = arch->path_repelled; @@ -812,8 +788,6 @@ glow_radius = arch->glow_radius; move_type = arch->move_type; - object *chosen_skill = 0; - /* initializing resistances from the values in player/monster's * archetype clone */ @@ -839,7 +813,7 @@ * basically, if a server updates its max level, these playes may find * that their protection from physical goes down */ - if (!QUERY_FLAG (this, FLAG_USE_ARMOUR) && type == PLAYER) + if (!this->flag [FLAG_USE_ARMOUR] && type == PLAYER) { ac = max (-10, arch->stats.ac - level / 3); prot[ATNR_PHYSICAL] += ((100 - prot[AT_PHYSICAL]) * (80 * level / settings.max_level)) / 100; @@ -850,6 +824,8 @@ stats.luck = arch->stats.luck; speed = arch->speed; + chosen_skill = 0; + /* OK - we've reset most all the objects attributes to sane values. * now go through and make adjustments for what the player has equipped. */ @@ -859,7 +835,7 @@ * applied so we can tell the player what changed. But change_abil * then calls this function. */ - if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == POTION) + if (tmp->flag [FLAG_APPLIED] && tmp->type == POTION) continue; glow_radius += tmp->glow_radius; @@ -903,13 +879,6 @@ { contr->item_power += tmp->item_power; - if (tmp == contr->combat_ob || tmp == contr->ranged_ob) - if (tmp != current_weapon - && (tmp->type != SKILL || tmp->subtype != SK_PRAYING) - && !tmp->flag [FLAG_CURSED] - && !tmp->flag [FLAG_DAMNED]) - continue; - for (int i = 0; i < NUM_STATS; i++) stat_sum [i] += tmp->stats.stat (i); @@ -930,7 +899,7 @@ } /* Update slots used for items */ - if (tmp->flag [FLAG_APPLIED]) + if (tmp->flag [FLAG_APPLIED]) // exclude praying... for (int i = 0; i < NUM_BODY_LOCATIONS; i++) slot[i].used += tmp->slot[i].info; @@ -965,12 +934,13 @@ flag |= tmp->flag & copy_flags; - if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) - SET_FLAG (this, FLAG_UNDEAD); + if (tmp->flag [FLAG_UNDEAD] && !arch->flag [FLAG_UNDEAD]) + this->set_flag (FLAG_UNDEAD); - if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) + //TODO: copy_flags? + if (tmp->flag [FLAG_MAKE_INVIS]) { - SET_FLAG (this, FLAG_MAKE_INVIS); + set_flag (FLAG_MAKE_INVIS); invisible = 1; } @@ -987,11 +957,10 @@ switch (tmp->type) { - /* skills modifying the character -b.t. */ - /* for all skills and skill granting objects */ case SKILL: { - if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) + // some skills will end up here without counting as "applied" + if (!tmp->flag [FLAG_APPLIED] || skill_flags [tmp->subtype] & SF_AUTARK) break; if (chosen_skill) @@ -1003,16 +972,13 @@ update_stats (); return; } - else - chosen_skill = tmp; + + chosen_skill = tmp; if (tmp->stats.dam > 0) { /* skill is a 'weapon' */ - if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) - weapon_speed = WEAPON_SPEED (tmp); - - if (weapon_speed < 0) - weapon_speed = 0; + if (!this->flag [FLAG_READY_WEAPON]) + weapon_speed = max (0, WEAPON_SPEED (tmp)); weapon_weight = tmp->weight; stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; @@ -1061,40 +1027,32 @@ case WAND: case ROD: case HORN: - case SKILL_TOOL: - if (type != PLAYER) - chosen_skill = find_skill_by_name (this, tmp->skill); break; case BOW: case WEAPON: - if (type != PLAYER || current_weapon == tmp) - { - chosen_skill = find_skill_by_name (this, tmp->skill); - - wc -= tmp->stats.wc + tmp->magic; - - if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) - ac -= tmp->stats.ac + tmp->magic; - - stats.dam += tmp->stats.dam + tmp->magic; - weapon_weight = tmp->weight; - weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; - - if (weapon_speed < 0) - weapon_speed = 0; + wc -= tmp->stats.wc + tmp->magic; - slaying = tmp->slaying; + if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) + ac -= tmp->stats.ac + tmp->magic; - /* If there is desire that two handed weapons should do - * extra strength damage, this is where the code should - * go. - */ - - if (type == PLAYER) - if (settings.spell_encumbrance) - contr->encumbrance += tmp->weight * 3 / 1000; - } + stats.dam += tmp->stats.dam + tmp->magic; + weapon_weight = tmp->weight; + weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; + + if (weapon_speed < 0) + weapon_speed = 0; + + slaying = tmp->slaying; + + /* If there is desire that two handed weapons should do + * extra strength damage, this is where the code should + * go. + */ + + if (type == PLAYER) + if (settings.spell_encumbrance) + contr->encumbrance += tmp->weight * 3 / 1000; break; @@ -1140,9 +1098,6 @@ } /* item is equipped */ } /* for loop of items */ - if (type != PLAYER) - this->chosen_skill = chosen_skill; - min_it (glow_radius, MAX_LIGHT_RADIUS); /* We've gone through all the objects the player has equipped. For many things, we @@ -1570,7 +1525,7 @@ /* clear the flag - exp goes into this bucket, but player * still doesn't know it. */ - CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); + skill_obj->clr_flag (FLAG_CAN_USE_SKILL); skill_obj->stats.exp = 0; skill_obj->level = 1; op->insert (skill_obj); @@ -1657,10 +1612,7 @@ sint64 level_exp (int level, double expmul) { - if (level > settings.max_level) - return (sint64) (expmul * levels[settings.max_level]); - - return (sint64) (expmul * levels[level]); + return expmul * level_to_min_exp (level); } /* @@ -1738,7 +1690,7 @@ * than half what you need to gain for next level. */ exp_to_add = exp; - limit = (levels[op->level + 1] - levels[op->level]) / 2; + limit = (levels [op->level + 1] - levels [op->level]) / 2; if (exp_to_add > limit) exp_to_add = limit; @@ -1755,7 +1707,7 @@ if (skill_obj) { exp_to_add = exp; - limit = (levels[skill_obj->level + 1] - levels[skill_obj->level]) / 2; + limit = (levels [skill_obj->level + 1] - levels [skill_obj->level]) / 2; if (exp_to_add > limit) exp_to_add = limit; @@ -1893,7 +1845,7 @@ if (op->type != PLAYER) { /* Sanity check */ - if (!QUERY_FLAG (op, FLAG_ALIVE)) + if (!op->flag [FLAG_ALIVE]) return; /* reset exp to max allowed value. We subtract from