mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
[Bug Fix] Fix issue with overflow on min/max hit dmg in npc scaling calculations (#3052)
* [Cleanup] Cleanup npc.cpp and npc scaling * fix issue with min/max damage overflows * formatting
This commit is contained in:
parent
12dcbd0871
commit
0ba90df1f1
@ -46,7 +46,7 @@ inline std::string GetMobAttributeByString(Mob *mob, const std::string &attribut
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attribute == "end") {
|
if (attribute == "end") {
|
||||||
int endurance = 0;
|
int64 endurance = 0;
|
||||||
if (mob->IsClient()) {
|
if (mob->IsClient()) {
|
||||||
endurance = mob->CastToClient()->GetEndurance();
|
endurance = mob->CastToClient()->GetEndurance();
|
||||||
}
|
}
|
||||||
@ -256,10 +256,10 @@ inline std::string GetMobAttributeByString(Mob *mob, const std::string &attribut
|
|||||||
return std::to_string((int)npc->GetSize());
|
return std::to_string((int)npc->GetSize());
|
||||||
}
|
}
|
||||||
if (attribute == "runspeed") {
|
if (attribute == "runspeed") {
|
||||||
return std::to_string((int)npc->GetRunspeed());
|
return std::to_string(npc->GetRunspeed());
|
||||||
}
|
}
|
||||||
if (attribute == "walkspeed") {
|
if (attribute == "walkspeed") {
|
||||||
return std::to_string((int)npc->GetWalkspeed());
|
return std::to_string(npc->GetWalkspeed());
|
||||||
}
|
}
|
||||||
if (attribute == "spawngroup") {
|
if (attribute == "spawngroup") {
|
||||||
return std::to_string(npc->GetSpawnGroupId());
|
return std::to_string(npc->GetSpawnGroupId());
|
||||||
@ -349,7 +349,7 @@ inline std::string GetMobAttributeByString(Mob *mob, const std::string &attribut
|
|||||||
return std::to_string((int)npc->GetProximityMaxZ());
|
return std::to_string((int)npc->GetProximityMaxZ());
|
||||||
}
|
}
|
||||||
if (attribute == "accuracy") {
|
if (attribute == "accuracy") {
|
||||||
return std::to_string((int)npc->GetAccuracyRating()) + scaling_modified;
|
return std::to_string(npc->GetAccuracyRating()) + scaling_modified;
|
||||||
}
|
}
|
||||||
if (attribute == "slow_mitigation") {
|
if (attribute == "slow_mitigation") {
|
||||||
if (mob->EntityVariableExists("modify_stat_slow_mitigation")) {
|
if (mob->EntityVariableExists("modify_stat_slow_mitigation")) {
|
||||||
@ -401,7 +401,7 @@ inline std::string GetMobAttributeByString(Mob *mob, const std::string &attribut
|
|||||||
return Strings::Commify(std::to_string((int) npc->GetHealScale())) + scaling_modified;
|
return Strings::Commify(std::to_string((int) npc->GetHealScale())) + scaling_modified;
|
||||||
}
|
}
|
||||||
if (attribute == "avoidance") {
|
if (attribute == "avoidance") {
|
||||||
return Strings::Commify(std::to_string((int) npc->GetAvoidanceRating())) + scaling_modified;
|
return Strings::Commify(std::to_string(npc->GetAvoidanceRating())) + scaling_modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
npc->GetNPCEmote(npc->GetEmoteID(), 0);
|
npc->GetNPCEmote(npc->GetEmoteID(), 0);
|
||||||
@ -411,63 +411,63 @@ inline std::string GetMobAttributeByString(Mob *mob, const std::string &attribut
|
|||||||
Client *client = mob->CastToClient();
|
Client *client = mob->CastToClient();
|
||||||
|
|
||||||
if (attribute == "shielding") {
|
if (attribute == "shielding") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetShielding())) + " / " +
|
return Strings::Commify(std::to_string(client->GetShielding())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemShieldingCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemShieldingCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "spell_shielding") {
|
if (attribute == "spell_shielding") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetSpellShield())) + " / " +
|
return Strings::Commify(std::to_string(client->GetSpellShield())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemSpellShieldingCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemSpellShieldingCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "dot_shielding") {
|
if (attribute == "dot_shielding") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetDoTShield())) + " / " +
|
return Strings::Commify(std::to_string(client->GetDoTShield())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemDoTShieldingCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemDoTShieldingCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "stun_resist") {
|
if (attribute == "stun_resist") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetStunResist())) + " / " +
|
return Strings::Commify(std::to_string(client->GetStunResist())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemStunResistCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemStunResistCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "damage_shield") {
|
if (attribute == "damage_shield") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetDS())) + " / " +
|
return Strings::Commify(std::to_string(client->GetDS())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemDamageShieldCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemDamageShieldCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "avoidance") {
|
if (attribute == "avoidance") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetAvoidance())) + " / " +
|
return Strings::Commify(std::to_string(client->GetAvoidance())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemAvoidanceCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemAvoidanceCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "strikethrough") {
|
if (attribute == "strikethrough") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetStrikeThrough())) + " / " +
|
return Strings::Commify(std::to_string(client->GetStrikeThrough())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemStrikethroughCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemStrikethroughCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "accuracy") {
|
if (attribute == "accuracy") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetAccuracy())) + " / " +
|
return Strings::Commify(std::to_string(client->GetAccuracy())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemAccuracyCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemAccuracyCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "combat_effects") {
|
if (attribute == "combat_effects") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetCombatEffects())) + " / " +
|
return Strings::Commify(std::to_string(client->GetCombatEffects())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemCombatEffectsCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemCombatEffectsCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "heal_amount") {
|
if (attribute == "heal_amount") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetHealAmt())) + " / " +
|
return Strings::Commify(std::to_string(client->GetHealAmt())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemHealAmtCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemHealAmtCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "spell_dmg") {
|
if (attribute == "spell_dmg") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetSpellDmg())) + " / " +
|
return Strings::Commify(std::to_string(client->GetSpellDmg())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemSpellDmgCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemSpellDmgCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "clairvoyance") {
|
if (attribute == "clairvoyance") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetClair())) + " / " +
|
return Strings::Commify(std::to_string(client->GetClair())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemClairvoyanceCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemClairvoyanceCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "ds_mitigation") {
|
if (attribute == "ds_mitigation") {
|
||||||
return Strings::Commify(std::to_string((int) client->GetDSMit())) + " / " +
|
return Strings::Commify(std::to_string(client->GetDSMit())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemDSMitigationCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemDSMitigationCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "hp_regen") {
|
if (attribute == "hp_regen") {
|
||||||
return Strings::Commify(std::to_string((int64) client->GetHPRegen())) + " / " +
|
return Strings::Commify(std::to_string(client->GetHPRegen())) + " / " +
|
||||||
Strings::Commify(std::to_string((int) RuleI(Character, ItemHealthRegenCap)));
|
Strings::Commify(std::to_string(RuleI(Character, ItemHealthRegenCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "mana_regen") {
|
if (attribute == "mana_regen") {
|
||||||
return Strings::Commify(std::to_string((int64) client->GetManaRegen())) + " / " +
|
return Strings::Commify(std::to_string(client->GetManaRegen())) + " / " +
|
||||||
Strings::Commify(std::to_string((int64) RuleI(Character, ItemManaRegenCap)));
|
Strings::Commify(std::to_string((int64) RuleI(Character, ItemManaRegenCap)));
|
||||||
}
|
}
|
||||||
if (attribute == "end_regen") {
|
if (attribute == "end_regen") {
|
||||||
@ -500,7 +500,7 @@ inline std::string GetMobAttributeByString(Mob *mob, const std::string &attribut
|
|||||||
inline std::string WriteDisplayInfoSection(
|
inline std::string WriteDisplayInfoSection(
|
||||||
Mob *mob,
|
Mob *mob,
|
||||||
const std::string §ion_name,
|
const std::string §ion_name,
|
||||||
std::vector<std::string> attributes_list,
|
const std::vector<std::string>& attributes_list,
|
||||||
int column_count = 3,
|
int column_count = 3,
|
||||||
bool display_section_name = false
|
bool display_section_name = false
|
||||||
)
|
)
|
||||||
@ -539,7 +539,7 @@ inline std::string WriteDisplayInfoSection(
|
|||||||
if (attribute_name.find('_') != std::string::npos) {
|
if (attribute_name.find('_') != std::string::npos) {
|
||||||
auto split_string = Strings::Split(attribute_name, '_');
|
auto split_string = Strings::Split(attribute_name, '_');
|
||||||
std::string new_attribute_name;
|
std::string new_attribute_name;
|
||||||
for (std::string &string_value : split_string) {
|
for (const std::string &string_value : split_string) {
|
||||||
new_attribute_name += Strings::UcFirst(string_value) + " ";
|
new_attribute_name += Strings::UcFirst(string_value) + " ";
|
||||||
}
|
}
|
||||||
attribute_name = new_attribute_name;
|
attribute_name = new_attribute_name;
|
||||||
|
|||||||
115
zone/npc.cpp
115
zone/npc.cpp
@ -48,6 +48,7 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
@ -2471,7 +2472,7 @@ void NPC::SetLevel(uint8 in_level, bool command)
|
|||||||
SendAppearancePacket(AT_WhoLevel, in_level);
|
SendAppearancePacket(AT_WhoLevel, in_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPC::ModifyNPCStat(std::string stat, std::string value)
|
void NPC::ModifyNPCStat(const std::string& stat, const std::string& value)
|
||||||
{
|
{
|
||||||
auto stat_lower = Strings::ToLower(stat);
|
auto stat_lower = Strings::ToLower(stat);
|
||||||
|
|
||||||
@ -2485,43 +2486,43 @@ void NPC::ModifyNPCStat(std::string stat, std::string value)
|
|||||||
LogNPCScaling("NPC::ModifyNPCStat: Key [{}] Value [{}] ", variable_key, value);
|
LogNPCScaling("NPC::ModifyNPCStat: Key [{}] Value [{}] ", variable_key, value);
|
||||||
|
|
||||||
if (stat_lower == "ac") {
|
if (stat_lower == "ac") {
|
||||||
AC = Strings::ToInt(value.c_str());
|
AC = Strings::ToInt(value);
|
||||||
CalcAC();
|
CalcAC();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "str") {
|
else if (stat_lower == "str") {
|
||||||
STR = Strings::ToInt(value.c_str());
|
STR = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "sta") {
|
else if (stat_lower == "sta") {
|
||||||
STA = Strings::ToInt(value.c_str());
|
STA = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "agi") {
|
else if (stat_lower == "agi") {
|
||||||
AGI = Strings::ToInt(value.c_str());
|
AGI = Strings::ToInt(value);
|
||||||
CalcAC();
|
CalcAC();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "dex") {
|
else if (stat_lower == "dex") {
|
||||||
DEX = Strings::ToInt(value.c_str());
|
DEX = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "wis") {
|
else if (stat_lower == "wis") {
|
||||||
WIS = Strings::ToInt(value.c_str());
|
WIS = Strings::ToInt(value);
|
||||||
CalcMaxMana();
|
CalcMaxMana();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "int" || stat_lower == "_int") {
|
else if (stat_lower == "int" || stat_lower == "_int") {
|
||||||
INT = Strings::ToInt(value.c_str());
|
INT = Strings::ToInt(value);
|
||||||
CalcMaxMana();
|
CalcMaxMana();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "cha") {
|
else if (stat_lower == "cha") {
|
||||||
CHA = Strings::ToInt(value.c_str());
|
CHA = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "max_hp") {
|
else if (stat_lower == "max_hp") {
|
||||||
base_hp = Strings::ToUnsignedBigInt(value.c_str());
|
base_hp = Strings::ToBigInt(value);
|
||||||
|
|
||||||
CalcMaxHP();
|
CalcMaxHP();
|
||||||
if (current_hp > max_hp) {
|
if (current_hp > max_hp) {
|
||||||
@ -2531,7 +2532,7 @@ void NPC::ModifyNPCStat(std::string stat, std::string value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "max_mana") {
|
else if (stat_lower == "max_mana") {
|
||||||
npc_mana = Strings::ToUnsignedBigInt(value.c_str());
|
npc_mana = Strings::ToUnsignedBigInt(value);
|
||||||
CalcMaxMana();
|
CalcMaxMana();
|
||||||
if (current_mana > max_mana) {
|
if (current_mana > max_mana) {
|
||||||
current_mana = max_mana;
|
current_mana = max_mana;
|
||||||
@ -2539,36 +2540,36 @@ void NPC::ModifyNPCStat(std::string stat, std::string value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "mr") {
|
else if (stat_lower == "mr") {
|
||||||
MR = Strings::ToInt(value.c_str());
|
MR = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "fr") {
|
else if (stat_lower == "fr") {
|
||||||
FR = Strings::ToInt(value.c_str());
|
FR = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "cr") {
|
else if (stat_lower == "cr") {
|
||||||
CR = Strings::ToInt(value.c_str());
|
CR = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "cor") {
|
else if (stat_lower == "cor") {
|
||||||
Corrup = Strings::ToInt(value.c_str());
|
Corrup = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "pr") {
|
else if (stat_lower == "pr") {
|
||||||
PR = Strings::ToInt(value.c_str());
|
PR = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "dr") {
|
else if (stat_lower == "dr") {
|
||||||
DR = Strings::ToInt(value.c_str());
|
DR = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "phr") {
|
else if (stat_lower == "phr") {
|
||||||
PhR = Strings::ToInt(value.c_str());
|
PhR = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "runspeed") {
|
else if (stat_lower == "runspeed") {
|
||||||
runspeed = (float) Strings::ToFloat(value.c_str());
|
runspeed = Strings::ToFloat(value);
|
||||||
base_runspeed = (int) ((float) runspeed * 40.0f);
|
base_runspeed = (int) (runspeed * 40.0f);
|
||||||
base_walkspeed = base_runspeed * 100 / 265;
|
base_walkspeed = base_runspeed * 100 / 265;
|
||||||
walkspeed = ((float) base_walkspeed) * 0.025f;
|
walkspeed = ((float) base_walkspeed) * 0.025f;
|
||||||
base_fearspeed = base_runspeed * 100 / 127;
|
base_fearspeed = base_runspeed * 100 / 127;
|
||||||
@ -2577,125 +2578,125 @@ void NPC::ModifyNPCStat(std::string stat, std::string value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "special_attacks") {
|
else if (stat_lower == "special_attacks") {
|
||||||
NPCSpecialAttacks(value.c_str(), 0, 1);
|
NPCSpecialAttacks(value.c_str(), 0, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "special_abilities") {
|
else if (stat_lower == "special_abilities") {
|
||||||
ProcessSpecialAbilities(value.c_str());
|
ProcessSpecialAbilities(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "attack_speed") {
|
else if (stat_lower == "attack_speed") {
|
||||||
attack_speed = (float) Strings::ToFloat(value.c_str());
|
attack_speed = Strings::ToFloat(value);
|
||||||
CalcBonuses();
|
CalcBonuses();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "attack_delay") {
|
else if (stat_lower == "attack_delay") {
|
||||||
/* TODO: fix DB */
|
/* TODO: fix DB */
|
||||||
attack_delay = Strings::ToInt(value.c_str()) * 100;
|
attack_delay = Strings::ToInt(value) * 100;
|
||||||
CalcBonuses();
|
CalcBonuses();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "atk") {
|
else if (stat_lower == "atk") {
|
||||||
ATK = Strings::ToInt(value.c_str());
|
ATK = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "accuracy") {
|
else if (stat_lower == "accuracy") {
|
||||||
accuracy_rating = Strings::ToInt(value.c_str());
|
accuracy_rating = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "avoidance") {
|
else if (stat_lower == "avoidance") {
|
||||||
avoidance_rating = Strings::ToInt(value.c_str());
|
avoidance_rating = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "trackable") {
|
else if (stat_lower == "trackable") {
|
||||||
trackable = Strings::ToInt(value.c_str());
|
trackable = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "min_hit") {
|
else if (stat_lower == "min_hit") {
|
||||||
min_dmg = Strings::ToInt(value.c_str());
|
min_dmg = Strings::ToInt(value);
|
||||||
// TODO: fix DB
|
// TODO: fix DB
|
||||||
base_damage = round((max_dmg - min_dmg) / 1.9);
|
base_damage = round((max_dmg - min_dmg) / 1.9);
|
||||||
min_damage = min_dmg - round(base_damage / 10.0);
|
min_damage = min_dmg - round(base_damage / 10.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "max_hit") {
|
else if (stat_lower == "max_hit") {
|
||||||
max_dmg = Strings::ToInt(value.c_str());
|
max_dmg = Strings::ToInt(value);
|
||||||
// TODO: fix DB
|
// TODO: fix DB
|
||||||
base_damage = round((max_dmg - min_dmg) / 1.9);
|
base_damage = round((max_dmg - min_dmg) / 1.9);
|
||||||
min_damage = min_dmg - round(base_damage / 10.0);
|
min_damage = min_dmg - round(base_damage / 10.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "attack_count") {
|
else if (stat_lower == "attack_count") {
|
||||||
attack_count = Strings::ToInt(value.c_str());
|
attack_count = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "see_invis") {
|
else if (stat_lower == "see_invis") {
|
||||||
see_invis = Strings::ToInt(value.c_str());
|
see_invis = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "see_invis_undead") {
|
else if (stat_lower == "see_invis_undead") {
|
||||||
see_invis_undead = Strings::ToInt(value.c_str());
|
see_invis_undead = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "see_hide") {
|
else if (stat_lower == "see_hide") {
|
||||||
see_hide = Strings::ToInt(value.c_str());
|
see_hide = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "see_improved_hide") {
|
else if (stat_lower == "see_improved_hide") {
|
||||||
see_improved_hide = Strings::ToInt(value.c_str());
|
see_improved_hide = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "hp_regen") {
|
else if (stat_lower == "hp_regen") {
|
||||||
hp_regen = strtoll(value.c_str(), nullptr, 10);
|
hp_regen = Strings::ToBigInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "hp_regen_per_second") {
|
else if (stat_lower == "hp_regen_per_second") {
|
||||||
hp_regen_per_second = strtoll(value.c_str(), nullptr, 10);
|
hp_regen_per_second = Strings::ToBigInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "mana_regen") {
|
else if (stat_lower == "mana_regen") {
|
||||||
mana_regen = strtoll(value.c_str(), nullptr, 10);
|
mana_regen = Strings::ToBigInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "level") {
|
else if (stat_lower == "level") {
|
||||||
SetLevel(Strings::ToInt(value.c_str()));
|
SetLevel(Strings::ToInt(value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "aggro") {
|
else if (stat_lower == "aggro") {
|
||||||
pAggroRange = Strings::ToFloat(value.c_str());
|
pAggroRange = Strings::ToFloat(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "assist") {
|
else if (stat_lower == "assist") {
|
||||||
pAssistRange = Strings::ToFloat(value.c_str());
|
pAssistRange = Strings::ToFloat(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "slow_mitigation") {
|
else if (stat_lower == "slow_mitigation") {
|
||||||
slow_mitigation = Strings::ToInt(value.c_str());
|
slow_mitigation = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "loottable_id") {
|
else if (stat_lower == "loottable_id") {
|
||||||
loottable_id = Strings::ToFloat(value.c_str());
|
loottable_id = Strings::ToFloat(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "healscale") {
|
else if (stat_lower == "healscale") {
|
||||||
healscale = Strings::ToFloat(value.c_str());
|
healscale = Strings::ToFloat(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "spellscale") {
|
else if (stat_lower == "spellscale") {
|
||||||
spellscale = Strings::ToFloat(value.c_str());
|
spellscale = Strings::ToFloat(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "npc_spells_id") {
|
else if (stat_lower == "npc_spells_id") {
|
||||||
AI_AddNPCSpells(Strings::ToInt(value.c_str()));
|
AI_AddNPCSpells(Strings::ToInt(value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "npc_spells_effects_id") {
|
else if (stat_lower == "npc_spells_effects_id") {
|
||||||
AI_AddNPCSpellsEffects(Strings::ToInt(value.c_str()));
|
AI_AddNPCSpellsEffects(Strings::ToInt(value));
|
||||||
CalcBonuses();
|
CalcBonuses();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "heroic_strikethrough") {
|
else if (stat_lower == "heroic_strikethrough") {
|
||||||
heroic_strikethrough = Strings::ToInt(value.c_str());
|
heroic_strikethrough = Strings::ToInt(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "keeps_sold_items") {
|
else if (stat_lower == "keeps_sold_items") {
|
||||||
@ -2704,11 +2705,10 @@ void NPC::ModifyNPCStat(std::string stat, std::string value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float NPC::GetNPCStat(std::string stat)
|
float NPC::GetNPCStat(const std::string& stat)
|
||||||
{
|
{
|
||||||
auto stat_lower = Strings::ToLower(stat);
|
|
||||||
|
|
||||||
if (stat_lower == "ac") {
|
if (auto stat_lower = Strings::ToLower(stat); stat_lower == "ac") {
|
||||||
return AC;
|
return AC;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "str") {
|
else if (stat_lower == "str") {
|
||||||
@ -2759,9 +2759,6 @@ float NPC::GetNPCStat(std::string stat)
|
|||||||
else if (stat_lower == "dr") {
|
else if (stat_lower == "dr") {
|
||||||
return DR;
|
return DR;
|
||||||
}
|
}
|
||||||
else if (stat_lower == "phr") {
|
|
||||||
return PhR;
|
|
||||||
}
|
|
||||||
else if (stat_lower == "runspeed") {
|
else if (stat_lower == "runspeed") {
|
||||||
return runspeed;
|
return runspeed;
|
||||||
}
|
}
|
||||||
@ -2975,7 +2972,6 @@ void NPC::LevelScale() {
|
|||||||
}
|
}
|
||||||
level = random_level;
|
level = random_level;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 NPC::GetSpawnPointID() const
|
uint32 NPC::GetSpawnPointID() const
|
||||||
@ -3023,7 +3019,6 @@ void NPC::SetSwarmTarget(int target_id)
|
|||||||
{
|
{
|
||||||
GetSwarmInfo()->target = target_id;
|
GetSwarmInfo()->target = target_id;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 NPC::CalcMaxMana()
|
int64 NPC::CalcMaxMana()
|
||||||
@ -3036,7 +3031,6 @@ int64 NPC::CalcMaxMana()
|
|||||||
case 'W':
|
case 'W':
|
||||||
max_mana = (((GetWIS() / 2) + 1) * GetLevel()) + spellbonuses.Mana + itembonuses.Mana;
|
max_mana = (((GetWIS() / 2) + 1) * GetLevel()) + spellbonuses.Mana + itembonuses.Mana;
|
||||||
break;
|
break;
|
||||||
case 'N':
|
|
||||||
default:
|
default:
|
||||||
max_mana = 0;
|
max_mana = 0;
|
||||||
break;
|
break;
|
||||||
@ -3055,7 +3049,6 @@ int64 NPC::CalcMaxMana()
|
|||||||
case 'W':
|
case 'W':
|
||||||
max_mana = npc_mana + spellbonuses.Mana + itembonuses.Mana;
|
max_mana = npc_mana + spellbonuses.Mana + itembonuses.Mana;
|
||||||
break;
|
break;
|
||||||
case 'N':
|
|
||||||
default:
|
default:
|
||||||
max_mana = 0;
|
max_mana = 0;
|
||||||
break;
|
break;
|
||||||
@ -3089,16 +3082,16 @@ NPC_Emote_Struct* NPC::GetNPCEmote(uint32 emoteid, uint8 event_) {
|
|||||||
{
|
{
|
||||||
NPC_Emote_Struct* nes = iterator.GetData();
|
NPC_Emote_Struct* nes = iterator.GetData();
|
||||||
if (emoteid == nes->emoteid && event_ == nes->event_) {
|
if (emoteid == nes->emoteid && event_ == nes->event_) {
|
||||||
return (nes);
|
return nes;
|
||||||
}
|
}
|
||||||
iterator.Advance();
|
iterator.Advance();
|
||||||
}
|
}
|
||||||
return (nullptr);
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPC::DoNPCEmote(uint8 event_, uint32 emoteid)
|
void NPC::DoNPCEmote(uint8 event_, uint32 emoteid)
|
||||||
{
|
{
|
||||||
if(this == nullptr || emoteid == 0)
|
if (emoteid == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -422,8 +422,8 @@ public:
|
|||||||
void SetAvoidanceRating(int32 d) { avoidance_rating = d;}
|
void SetAvoidanceRating(int32 d) { avoidance_rating = d;}
|
||||||
int32 GetRawAC() const { return AC; }
|
int32 GetRawAC() const { return AC; }
|
||||||
|
|
||||||
float GetNPCStat(std::string stat);
|
float GetNPCStat(const std::string& stat);
|
||||||
void ModifyNPCStat(std::string stat, std::string value);
|
void ModifyNPCStat(const std::string& stat, const std::string& value);
|
||||||
virtual void SetLevel(uint8 in_level, bool command = false);
|
virtual void SetLevel(uint8 in_level, bool command = false);
|
||||||
|
|
||||||
bool IsLDoNTrapped() const { return ldon_trapped; }
|
bool IsLDoNTrapped() const { return ldon_trapped; }
|
||||||
|
|||||||
@ -137,9 +137,9 @@ void NpcScaleManager::ScaleNPC(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (always_scale || npc->GetMinDMG() == 0) {
|
if (always_scale || npc->GetMinDMG() == 0) {
|
||||||
int min_dmg = scale_data.min_dmg;
|
int64 min_dmg = scale_data.min_dmg;
|
||||||
if (RuleB(Combat, UseNPCDamageClassLevelMods)) {
|
if (RuleB(Combat, UseNPCDamageClassLevelMods)) {
|
||||||
int32 class_level_damage_mod = GetClassLevelDamageMod(npc->GetLevel(), npc->GetClass());
|
uint32 class_level_damage_mod = GetClassLevelDamageMod(npc->GetLevel(), npc->GetClass());
|
||||||
min_dmg = (min_dmg * class_level_damage_mod) / 220;
|
min_dmg = (min_dmg * class_level_damage_mod) / 220;
|
||||||
|
|
||||||
LogNPCScaling("ClassLevelDamageMod::min_dmg base: [{}] calc: [{}]", scale_data.min_dmg, min_dmg);
|
LogNPCScaling("ClassLevelDamageMod::min_dmg base: [{}] calc: [{}]", scale_data.min_dmg, min_dmg);
|
||||||
@ -149,9 +149,9 @@ void NpcScaleManager::ScaleNPC(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (always_scale || npc->GetMaxDMG() == 0) {
|
if (always_scale || npc->GetMaxDMG() == 0) {
|
||||||
int max_dmg = scale_data.max_dmg;
|
int64 max_dmg = scale_data.max_dmg;
|
||||||
if (RuleB(Combat, UseNPCDamageClassLevelMods)) {
|
if (RuleB(Combat, UseNPCDamageClassLevelMods)) {
|
||||||
int32 class_level_damage_mod = GetClassLevelDamageMod(npc->GetLevel(), npc->GetClass());
|
uint32 class_level_damage_mod = GetClassLevelDamageMod(npc->GetLevel(), npc->GetClass());
|
||||||
max_dmg = (scale_data.max_dmg * class_level_damage_mod) / 220;
|
max_dmg = (scale_data.max_dmg * class_level_damage_mod) / 220;
|
||||||
|
|
||||||
LogNPCScaling("ClassLevelDamageMod::max_dmg base: [{}] calc: [{}]", scale_data.max_dmg, max_dmg);
|
LogNPCScaling("ClassLevelDamageMod::max_dmg base: [{}] calc: [{}]", scale_data.max_dmg, max_dmg);
|
||||||
@ -310,7 +310,7 @@ bool NpcScaleManager::LoadScaleData()
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (!has_multiple_zones && has_multiple_versions) {
|
} else if (!has_multiple_zones) {
|
||||||
scale_data.zone_id = Strings::ToUnsignedInt(s.zone_id_list);
|
scale_data.zone_id = Strings::ToUnsignedInt(s.zone_id_list);
|
||||||
|
|
||||||
const auto versions = Strings::Split(s.instance_version_list, "|");
|
const auto versions = Strings::Split(s.instance_version_list, "|");
|
||||||
@ -330,7 +330,7 @@ bool NpcScaleManager::LoadScaleData()
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (has_multiple_zones && has_multiple_versions) {
|
} else {
|
||||||
const auto zones = Strings::Split(s.zone_id_list, "|");
|
const auto zones = Strings::Split(s.zone_id_list, "|");
|
||||||
const auto versions = Strings::Split(s.instance_version_list, "|");
|
const auto versions = Strings::Split(s.instance_version_list, "|");
|
||||||
|
|
||||||
@ -419,7 +419,7 @@ NpcScaleManager::global_npc_scale NpcScaleManager::GetGlobalScaleDataForTypeLeve
|
|||||||
*/
|
*/
|
||||||
uint32 NpcScaleManager::GetClassLevelDamageMod(uint32 level, uint32 npc_class)
|
uint32 NpcScaleManager::GetClassLevelDamageMod(uint32 level, uint32 npc_class)
|
||||||
{
|
{
|
||||||
uint32 multiplier = 0;
|
uint32 multiplier;
|
||||||
|
|
||||||
switch (npc_class) {
|
switch (npc_class) {
|
||||||
case WARRIOR: {
|
case WARRIOR: {
|
||||||
@ -579,9 +579,8 @@ int8 NpcScaleManager::GetNPCScalingType(NPC *&npc)
|
|||||||
*/
|
*/
|
||||||
std::string NpcScaleManager::GetNPCScalingTypeName(NPC *&npc)
|
std::string NpcScaleManager::GetNPCScalingTypeName(NPC *&npc)
|
||||||
{
|
{
|
||||||
int8 scaling_type = GetNPCScalingType(npc);
|
|
||||||
|
|
||||||
if (scaling_type == 1) {
|
if (int8 scaling_type = GetNPCScalingType(npc); scaling_type == 1) {
|
||||||
return "Named";
|
return "Named";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user