mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Commands] Cleanup #modifynpcstat Command. (#2499)
* [Commands] Cleanup #modifynpcstat Command. Cleanup messages and logic, Add map and loop through it to display all stats, can add to this in the future if we add more stuff modifiable by this command. * Delete settings.json * Update modifynpcstat.cpp * Update modifynpcstat.cpp * Update questmgr.h
This commit is contained in:
parent
b512447448
commit
dcbc9a358f
@ -213,7 +213,7 @@ int command_init(void)
|
||||
command_add("memspell", "[Spell ID] [Spell Gem] - Memorize a Spell by ID to the specified Spell Gem for you or your target", AccountStatus::Guide, command_memspell) ||
|
||||
command_add("merchant_close_shop", "Closes a merchant shop", AccountStatus::GMAdmin, command_merchantcloseshop) ||
|
||||
command_add("merchant_open_shop", "Opens a merchants shop", AccountStatus::GMAdmin, command_merchantopenshop) ||
|
||||
command_add("modifynpcstat", "Modifies an NPC's stats", AccountStatus::GMLeadAdmin, command_modifynpcstat) ||
|
||||
command_add("modifynpcstat", "[Stat] [Value] - Modifies an NPC's stats temporarily.", AccountStatus::GMLeadAdmin, command_modifynpcstat) ||
|
||||
command_add("motd", "[Message of the Day] - Set Message of the Day (leave empty to have no Message of the Day)", AccountStatus::GMLeadAdmin, command_motd) ||
|
||||
command_add("movechar", "[Character ID|Character Name] [Zone ID|Zone Short Name] - Move an offline character to the specified zone", AccountStatus::Guide, command_movechar) ||
|
||||
command_add("movement", "Various movement commands", AccountStatus::GMMgmt, command_movement) ||
|
||||
|
||||
@ -28,6 +28,9 @@ int command_notavail(Client *c, std::string message);
|
||||
int command_realdispatch(Client *c, std::string message);
|
||||
void command_logcommand(Client *c, std::string message);
|
||||
uint8 GetCommandStatus(Client *c, std::string command_name);
|
||||
void ListModifyNPCStatMap(Client *c);
|
||||
std::map<std::string, std::string> GetModifyNPCStatMap();
|
||||
std::string GetModifyNPCStatDescription(std::string stat);
|
||||
|
||||
// Commands
|
||||
void command_acceptrules(Client *c, const Seperator *sep);
|
||||
|
||||
@ -2,29 +2,127 @@
|
||||
|
||||
void command_modifynpcstat(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (!c) {
|
||||
auto arguments = sep->argnum;
|
||||
if (!arguments) {
|
||||
c->Message(Chat::White, "Usage: #modifynpcstat [Stat] [Value]");
|
||||
ListModifyNPCStatMap(c);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!c->GetTarget() || !c->GetTarget()->IsNPC()) {
|
||||
c->Message(Chat::White, "You must target an NPC to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sep->arg[1][0] == '\0') {
|
||||
c->Message(Chat::White, "usage #modifynpcstat arg value");
|
||||
auto target = c->GetTarget()->CastToNPC();
|
||||
|
||||
std::string stat = sep->arg[1];
|
||||
std::string value = sep->arg[2] ? sep->arg[2] : "";
|
||||
|
||||
auto stat_description = GetModifyNPCStatDescription(stat);
|
||||
if (!stat_description.length()) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
"Args: ac, str, sta, agi, dex, wis, _int, cha, max_hp, mr, fr, cr, pr, dr, runspeed, special_attacks, "
|
||||
"attack_speed, atk, accuracy, trackable, min_hit, max_hit, see_invis_undead, see_hide, see_improved_hide, "
|
||||
"hp_regen, mana_regen, aggro, assist, slow_mitigation, loottable_id, healscale, spellscale"
|
||||
fmt::format(
|
||||
"Stat '{}' does not exist.",
|
||||
stat
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!c->GetTarget()) {
|
||||
return;
|
||||
}
|
||||
target->ModifyNPCStat(stat, value);
|
||||
|
||||
if (!c->GetTarget()->IsNPC()) {
|
||||
return;
|
||||
}
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Stat Modified | Target: {}",
|
||||
c->GetTargetDescription(target)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
c->GetTarget()->CastToNPC()->ModifyNPCStat(sep->arg[1], sep->arg[2]);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Stat Modified | Stat: {} ({}) Value: {}",
|
||||
GetModifyNPCStatDescription(stat),
|
||||
stat,
|
||||
value
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> GetModifyNPCStatMap()
|
||||
{
|
||||
std::map<std::string, std::string> identifiers_map = {
|
||||
{ "ac", "Armor Class" },
|
||||
{ "accuracy", "Accuracy" },
|
||||
{ "aggro", "Aggro" },
|
||||
{ "agi", "Agility" },
|
||||
{ "assist", "Assist" },
|
||||
{ "atk", "Attack" },
|
||||
{ "attack_count", "Attack Count" },
|
||||
{ "attack_delay", "Attack Delay" },
|
||||
{ "attack_speed", "Attack Speed" },
|
||||
{ "avoidance", "Avoidance" },
|
||||
{ "cha", "Charisma" },
|
||||
{ "cr", "Cold Resist" },
|
||||
{ "dex", "Dexterity" },
|
||||
{ "dr", "Disease Resist" },
|
||||
{ "fr", "Fire Resist" },
|
||||
{ "healscale", "Heal Scale" },
|
||||
{ "heroic_strikethrough", "Heroic Strikethrough" },
|
||||
{ "hp_regen", "HP Regen" },
|
||||
{ "hp_regen_per_second", "HP Regen Per Second" },
|
||||
{ "int", "Intelligence" },
|
||||
{ "_int", "Intelligence" },
|
||||
{ "level", "Level" },
|
||||
{ "loottable_id", "Loottable ID" },
|
||||
{ "mana_regen", "Mana Regen" },
|
||||
{ "max_hit", "Maximum Damage" },
|
||||
{ "min_hit", "Minimum Damage" },
|
||||
{ "mr", "Magic Resist" },
|
||||
{ "npc_spells_id", "NPC Spells ID" },
|
||||
{ "npc_spells_effects_id", "NPC Spells Effects ID" },
|
||||
{ "phr", "Physical Resist" },
|
||||
{ "pr", "Poison Resist" },
|
||||
{ "runspeed", "Run Speed" },
|
||||
{ "see_invis", "See Invisible" },
|
||||
{ "see_invis_undead", "See Invisible vs. Undead" },
|
||||
{ "see_hide", "See Hide" },
|
||||
{ "see_improved_hide", "See Improved Hide" },
|
||||
{ "slow_mitigation", "Slow Mitigation" },
|
||||
{ "special_attacks", "Special Attacks" },
|
||||
{ "special_abilities", "Special Abilities" },
|
||||
{ "spellscale", "Spell Scale" },
|
||||
{ "sta", "Stamina" },
|
||||
{ "str", "Strength" },
|
||||
{ "trackable", "Trackable" },
|
||||
{ "wis", "Wisdom" }
|
||||
};
|
||||
|
||||
return identifiers_map;
|
||||
}
|
||||
|
||||
std::string GetModifyNPCStatDescription(std::string stat)
|
||||
{
|
||||
if (GetModifyNPCStatMap().find(stat) != GetModifyNPCStatMap().end()) {
|
||||
return GetModifyNPCStatMap().find(stat)->second;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void ListModifyNPCStatMap(Client *c)
|
||||
{
|
||||
for (const auto& s : GetModifyNPCStatMap()) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Usage: #modifynpcstat {} [Value] - Modifies an NPC's {}",
|
||||
s.first,
|
||||
s.second
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -812,8 +812,8 @@ void lua_create_door(const char *model, float x, float y, float z, float h, int
|
||||
quest_manager.CreateDoor(model, x, y, z, h, open_type, size);
|
||||
}
|
||||
|
||||
void lua_modify_npc_stat(const char *id, const char *value) {
|
||||
quest_manager.ModifyNPCStat(id, value);
|
||||
void lua_modify_npc_stat(std::string stat, std::string value) {
|
||||
quest_manager.ModifyNPCStat(stat, value);
|
||||
}
|
||||
|
||||
int lua_collect_items(uint32 item_id, bool remove) {
|
||||
|
||||
@ -458,7 +458,7 @@ void Lua_NPC::SetSwarmTarget(int target) {
|
||||
self->SetSwarmTarget(target);
|
||||
}
|
||||
|
||||
void Lua_NPC::ModifyNPCStat(const char *stat, const char *value) {
|
||||
void Lua_NPC::ModifyNPCStat(std::string stat, std::string value) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->ModifyNPCStat(stat, value);
|
||||
}
|
||||
@ -663,10 +663,10 @@ bool Lua_NPC::HasAISpellEffect(int spell_effect_id)
|
||||
return self->HasAISpellEffect(spell_effect_id);
|
||||
}
|
||||
|
||||
float Lua_NPC::GetNPCStat(const char* identifier)
|
||||
float Lua_NPC::GetNPCStat(std::string stat)
|
||||
{
|
||||
Lua_Safe_Call_Real();
|
||||
return self->GetNPCStat(identifier);
|
||||
return self->GetNPCStat(stat);
|
||||
}
|
||||
|
||||
bool Lua_NPC::IsRareSpawn()
|
||||
@ -736,7 +736,7 @@ luabind::scope lua_register_npc() {
|
||||
.def("GetNPCHate", (int64(Lua_NPC::*)(Lua_Mob))&Lua_NPC::GetNPCHate)
|
||||
.def("GetNPCSpellsID", (int(Lua_NPC::*)(void))&Lua_NPC::GetNPCSpellsID)
|
||||
.def("GetNPCSpellsID", (int(Lua_NPC::*)(void))&Lua_NPC::GetNPCSpellsID)
|
||||
.def("GetNPCStat", (float(Lua_NPC::*)(const char*))&Lua_NPC::GetNPCStat)
|
||||
.def("GetNPCStat", (float(Lua_NPC::*)(std::string))&Lua_NPC::GetNPCStat)
|
||||
.def("GetPetSpellID", (int(Lua_NPC::*)(void))&Lua_NPC::GetPetSpellID)
|
||||
.def("GetPlatinum", (uint32(Lua_NPC::*)(void))&Lua_NPC::GetPlatinum)
|
||||
.def("GetPrimSkill", (int(Lua_NPC::*)(void))&Lua_NPC::GetPrimSkill)
|
||||
@ -769,7 +769,7 @@ luabind::scope lua_register_npc() {
|
||||
.def("IsTaunting", (bool(Lua_NPC::*)(void))&Lua_NPC::IsTaunting)
|
||||
.def("MerchantCloseShop", (void(Lua_NPC::*)(void))&Lua_NPC::MerchantCloseShop)
|
||||
.def("MerchantOpenShop", (void(Lua_NPC::*)(void))&Lua_NPC::MerchantOpenShop)
|
||||
.def("ModifyNPCStat", (void(Lua_NPC::*)(const char*,const char*))&Lua_NPC::ModifyNPCStat)
|
||||
.def("ModifyNPCStat", (void(Lua_NPC::*)(std::string,std::string))&Lua_NPC::ModifyNPCStat)
|
||||
.def("MoveTo", (void(Lua_NPC::*)(float,float,float,float,bool))&Lua_NPC::MoveTo)
|
||||
.def("NextGuardPosition", (void(Lua_NPC::*)(void))&Lua_NPC::NextGuardPosition)
|
||||
.def("PauseWandering", (void(Lua_NPC::*)(int))&Lua_NPC::PauseWandering)
|
||||
|
||||
@ -118,7 +118,7 @@ public:
|
||||
int GetSwarmOwner();
|
||||
int GetSwarmTarget();
|
||||
void SetSwarmTarget(int target);
|
||||
void ModifyNPCStat(const char *stat, const char *value);
|
||||
void ModifyNPCStat(std::string stat, std::string value);
|
||||
void AddAISpell(int priority, int spell_id, int type, int mana_cost, int recast_delay, int resist_adjust);
|
||||
void AddAISpell(int priority, int spell_id, int type, int mana_cost, int recast_delay, int resist_adjust, int min_hp, int max_hp);
|
||||
void RemoveAISpell(int spell_id);
|
||||
@ -156,7 +156,7 @@ public:
|
||||
void AddAISpellEffect(int spell_effect_id, int base_value, int limit_value, int max_value);
|
||||
void RemoveAISpellEffect(int spell_effect_id);
|
||||
bool HasAISpellEffect(int spell_effect_id);
|
||||
float GetNPCStat(const char* identifier);
|
||||
float GetNPCStat(std::string stat);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
312
zone/npc.cpp
312
zone/npc.cpp
@ -2445,54 +2445,57 @@ void NPC::SetLevel(uint8 in_level, bool command)
|
||||
SendAppearancePacket(AT_WhoLevel, in_level);
|
||||
}
|
||||
|
||||
void NPC::ModifyNPCStat(const char *identifier, const char *new_value)
|
||||
void NPC::ModifyNPCStat(std::string stat, std::string value)
|
||||
{
|
||||
std::string id = Strings::ToLower(identifier);
|
||||
std::string val = new_value;
|
||||
auto stat_lower = Strings::ToLower(stat);
|
||||
|
||||
std::string variable_key = StringFormat("modify_stat_%s", id.c_str());
|
||||
SetEntityVariable(variable_key.c_str(), new_value);
|
||||
auto variable_key = fmt::format(
|
||||
"modify_stat_{}",
|
||||
stat_lower
|
||||
);
|
||||
|
||||
LogNPCScaling("NPC::ModifyNPCStat key: [{}] val: [{}] ", variable_key.c_str(), new_value);
|
||||
SetEntityVariable(variable_key.c_str(), value.c_str());
|
||||
|
||||
if (id == "ac") {
|
||||
AC = atoi(val.c_str());
|
||||
LogNPCScaling("NPC::ModifyNPCStat: Key [{}] Value [{}] ", variable_key, value);
|
||||
|
||||
if (stat_lower == "ac") {
|
||||
AC = atoi(value.c_str());
|
||||
CalcAC();
|
||||
return;
|
||||
}
|
||||
else if (id == "str") {
|
||||
STR = atoi(val.c_str());
|
||||
else if (stat_lower == "str") {
|
||||
STR = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "sta") {
|
||||
STA = atoi(val.c_str());
|
||||
else if (stat_lower == "sta") {
|
||||
STA = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "agi") {
|
||||
AGI = atoi(val.c_str());
|
||||
else if (stat_lower == "agi") {
|
||||
AGI = atoi(value.c_str());
|
||||
CalcAC();
|
||||
return;
|
||||
}
|
||||
else if (id == "dex") {
|
||||
DEX = atoi(val.c_str());
|
||||
else if (stat_lower == "dex") {
|
||||
DEX = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "wis") {
|
||||
WIS = atoi(val.c_str());
|
||||
else if (stat_lower == "wis") {
|
||||
WIS = atoi(value.c_str());
|
||||
CalcMaxMana();
|
||||
return;
|
||||
}
|
||||
else if (id == "int" || id == "_int") {
|
||||
INT = atoi(val.c_str());
|
||||
else if (stat_lower == "int" || stat_lower == "_int") {
|
||||
INT = atoi(value.c_str());
|
||||
CalcMaxMana();
|
||||
return;
|
||||
}
|
||||
else if (id == "cha") {
|
||||
CHA = atoi(val.c_str());
|
||||
else if (stat_lower == "cha") {
|
||||
CHA = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "max_hp") {
|
||||
base_hp = std::stoull(val.c_str());
|
||||
else if (stat_lower == "max_hp") {
|
||||
base_hp = std::stoull(value.c_str());
|
||||
|
||||
CalcMaxHP();
|
||||
if (current_hp > max_hp) {
|
||||
@ -2501,48 +2504,44 @@ void NPC::ModifyNPCStat(const char *identifier, const char *new_value)
|
||||
|
||||
return;
|
||||
}
|
||||
else if (id == "max_mana") {
|
||||
npc_mana = std::stoull(val.c_str());
|
||||
else if (stat_lower == "max_mana") {
|
||||
npc_mana = std::stoull(value.c_str());
|
||||
CalcMaxMana();
|
||||
if (current_mana > max_mana) {
|
||||
current_mana = max_mana;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (id == "mr") {
|
||||
MR = atoi(val.c_str());
|
||||
else if (stat_lower == "mr") {
|
||||
MR = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "fr") {
|
||||
FR = atoi(val.c_str());
|
||||
else if (stat_lower == "fr") {
|
||||
FR = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "cr") {
|
||||
CR = atoi(val.c_str());
|
||||
else if (stat_lower == "cr") {
|
||||
CR = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "cor") {
|
||||
Corrup = atoi(val.c_str());
|
||||
else if (stat_lower == "cor") {
|
||||
Corrup = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "phr") {
|
||||
PhR = atoi(val.c_str());
|
||||
else if (stat_lower == "pr") {
|
||||
PR = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "pr") {
|
||||
PR = atoi(val.c_str());
|
||||
else if (stat_lower == "dr") {
|
||||
DR = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "dr") {
|
||||
DR = atoi(val.c_str());
|
||||
else if (stat_lower == "phr") {
|
||||
PhR = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "phr") {
|
||||
PhR = atoi(val.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "runspeed") {
|
||||
runspeed = (float) atof(val.c_str());
|
||||
else if (stat_lower == "runspeed") {
|
||||
runspeed = (float) atof(value.c_str());
|
||||
base_runspeed = (int) ((float) runspeed * 40.0f);
|
||||
base_walkspeed = base_runspeed * 100 / 265;
|
||||
walkspeed = ((float) base_walkspeed) * 0.025f;
|
||||
@ -2551,290 +2550,289 @@ void NPC::ModifyNPCStat(const char *identifier, const char *new_value)
|
||||
CalcBonuses();
|
||||
return;
|
||||
}
|
||||
else if (id == "special_attacks") {
|
||||
NPCSpecialAttacks(val.c_str(), 0, 1);
|
||||
else if (stat_lower == "special_attacks") {
|
||||
NPCSpecialAttacks(value.c_str(), 0, 1);
|
||||
return;
|
||||
}
|
||||
else if (id == "special_abilities") {
|
||||
ProcessSpecialAbilities(val.c_str());
|
||||
else if (stat_lower == "special_abilities") {
|
||||
ProcessSpecialAbilities(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "attack_speed") {
|
||||
attack_speed = (float) atof(val.c_str());
|
||||
else if (stat_lower == "attack_speed") {
|
||||
attack_speed = (float) atof(value.c_str());
|
||||
CalcBonuses();
|
||||
return;
|
||||
}
|
||||
else if (id == "attack_delay") {
|
||||
else if (stat_lower == "attack_delay") {
|
||||
/* TODO: fix DB */
|
||||
attack_delay = atoi(val.c_str()) * 100;
|
||||
attack_delay = atoi(value.c_str()) * 100;
|
||||
CalcBonuses();
|
||||
return;
|
||||
}
|
||||
else if (id == "atk") {
|
||||
ATK = atoi(val.c_str());
|
||||
else if (stat_lower == "atk") {
|
||||
ATK = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "accuracy") {
|
||||
accuracy_rating = atoi(val.c_str());
|
||||
else if (stat_lower == "accuracy") {
|
||||
accuracy_rating = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "avoidance") {
|
||||
avoidance_rating = atoi(val.c_str());
|
||||
else if (stat_lower == "avoidance") {
|
||||
avoidance_rating = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "trackable") {
|
||||
trackable = atoi(val.c_str());
|
||||
else if (stat_lower == "trackable") {
|
||||
trackable = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "min_hit") {
|
||||
min_dmg = atoi(val.c_str());
|
||||
else if (stat_lower == "min_hit") {
|
||||
min_dmg = atoi(value.c_str());
|
||||
// TODO: fix DB
|
||||
base_damage = round((max_dmg - min_dmg) / 1.9);
|
||||
min_damage = min_dmg - round(base_damage / 10.0);
|
||||
return;
|
||||
}
|
||||
else if (id == "max_hit") {
|
||||
max_dmg = atoi(val.c_str());
|
||||
else if (stat_lower == "max_hit") {
|
||||
max_dmg = atoi(value.c_str());
|
||||
// TODO: fix DB
|
||||
base_damage = round((max_dmg - min_dmg) / 1.9);
|
||||
min_damage = min_dmg - round(base_damage / 10.0);
|
||||
return;
|
||||
}
|
||||
else if (id == "attack_count") {
|
||||
attack_count = atoi(val.c_str());
|
||||
else if (stat_lower == "attack_count") {
|
||||
attack_count = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "see_invis") {
|
||||
see_invis = atoi(val.c_str());
|
||||
else if (stat_lower == "see_invis") {
|
||||
see_invis = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "see_invis_undead") {
|
||||
see_invis_undead = atoi(val.c_str());
|
||||
else if (stat_lower == "see_invis_undead") {
|
||||
see_invis_undead = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "see_hide") {
|
||||
see_hide = atoi(val.c_str());
|
||||
else if (stat_lower == "see_hide") {
|
||||
see_hide = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "see_improved_hide") {
|
||||
see_improved_hide = atoi(val.c_str());
|
||||
else if (stat_lower == "see_improved_hide") {
|
||||
see_improved_hide = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "hp_regen") {
|
||||
hp_regen = strtoll(val.c_str(), nullptr, 10);
|
||||
else if (stat_lower == "hp_regen") {
|
||||
hp_regen = strtoll(value.c_str(), nullptr, 10);
|
||||
return;
|
||||
}
|
||||
else if (id == "hp_regen_per_second") {
|
||||
hp_regen_per_second = strtoll(val.c_str(), nullptr, 10);
|
||||
else if (stat_lower == "hp_regen_per_second") {
|
||||
hp_regen_per_second = strtoll(value.c_str(), nullptr, 10);
|
||||
return;
|
||||
}
|
||||
else if (id == "mana_regen") {
|
||||
mana_regen = strtoll(val.c_str(), nullptr, 10);
|
||||
else if (stat_lower == "mana_regen") {
|
||||
mana_regen = strtoll(value.c_str(), nullptr, 10);
|
||||
return;
|
||||
}
|
||||
else if (id == "level") {
|
||||
SetLevel(atoi(val.c_str()));
|
||||
else if (stat_lower == "level") {
|
||||
SetLevel(atoi(value.c_str()));
|
||||
return;
|
||||
}
|
||||
else if (id == "aggro") {
|
||||
pAggroRange = atof(val.c_str());
|
||||
else if (stat_lower == "aggro") {
|
||||
pAggroRange = atof(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "assist") {
|
||||
pAssistRange = atof(val.c_str());
|
||||
else if (stat_lower == "assist") {
|
||||
pAssistRange = atof(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "slow_mitigation") {
|
||||
slow_mitigation = atoi(val.c_str());
|
||||
else if (stat_lower == "slow_mitigation") {
|
||||
slow_mitigation = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "loottable_id") {
|
||||
loottable_id = atof(val.c_str());
|
||||
else if (stat_lower == "loottable_id") {
|
||||
loottable_id = atof(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "healscale") {
|
||||
healscale = atof(val.c_str());
|
||||
else if (stat_lower == "healscale") {
|
||||
healscale = atof(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "spellscale") {
|
||||
spellscale = atof(val.c_str());
|
||||
else if (stat_lower == "spellscale") {
|
||||
spellscale = atof(value.c_str());
|
||||
return;
|
||||
}
|
||||
else if (id == "npc_spells_id") {
|
||||
AI_AddNPCSpells(atoi(val.c_str()));
|
||||
else if (stat_lower == "npc_spells_id") {
|
||||
AI_AddNPCSpells(atoi(value.c_str()));
|
||||
return;
|
||||
}
|
||||
else if (id == "npc_spells_effects_id") {
|
||||
AI_AddNPCSpellsEffects(atoi(val.c_str()));
|
||||
else if (stat_lower == "npc_spells_effects_id") {
|
||||
AI_AddNPCSpellsEffects(atoi(value.c_str()));
|
||||
CalcBonuses();
|
||||
return;
|
||||
}
|
||||
else if (id == "heroic_strikethrough") {
|
||||
heroic_strikethrough = atoi(val.c_str());
|
||||
else if (stat_lower == "heroic_strikethrough") {
|
||||
heroic_strikethrough = atoi(value.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float NPC::GetNPCStat(const char *identifier)
|
||||
float NPC::GetNPCStat(std::string stat)
|
||||
{
|
||||
std::string id = Strings::ToLower(identifier);
|
||||
auto stat_lower = Strings::ToLower(stat);
|
||||
|
||||
if (id == "ac") {
|
||||
if (stat_lower == "ac") {
|
||||
return AC;
|
||||
}
|
||||
else if (id == "str") {
|
||||
else if (stat_lower == "str") {
|
||||
return STR;
|
||||
}
|
||||
else if (id == "sta") {
|
||||
else if (stat_lower == "sta") {
|
||||
return STA;
|
||||
}
|
||||
else if (id == "agi") {
|
||||
else if (stat_lower == "agi") {
|
||||
return AGI;
|
||||
}
|
||||
else if (id == "dex") {
|
||||
else if (stat_lower == "dex") {
|
||||
return DEX;
|
||||
}
|
||||
else if (id == "wis") {
|
||||
else if (stat_lower == "wis") {
|
||||
return WIS;
|
||||
}
|
||||
else if (id == "int" || id == "_int") {
|
||||
else if (stat_lower == "int" || stat_lower == "_int") {
|
||||
return INT;
|
||||
}
|
||||
else if (id == "cha") {
|
||||
else if (stat_lower == "cha") {
|
||||
return CHA;
|
||||
}
|
||||
else if (id == "max_hp") {
|
||||
else if (stat_lower == "max_hp") {
|
||||
return base_hp;
|
||||
}
|
||||
else if (id == "max_mana") {
|
||||
else if (stat_lower == "max_mana") {
|
||||
return npc_mana;
|
||||
}
|
||||
else if (id == "mr") {
|
||||
else if (stat_lower == "mr") {
|
||||
return MR;
|
||||
}
|
||||
else if (id == "fr") {
|
||||
else if (stat_lower == "fr") {
|
||||
return FR;
|
||||
}
|
||||
else if (id == "cr") {
|
||||
else if (stat_lower == "cr") {
|
||||
return CR;
|
||||
}
|
||||
else if (id == "cor") {
|
||||
else if (stat_lower == "cor") {
|
||||
return Corrup;
|
||||
}
|
||||
else if (id == "phr") {
|
||||
else if (stat_lower == "phr") {
|
||||
return PhR;
|
||||
}
|
||||
else if (id == "pr") {
|
||||
else if (stat_lower == "pr") {
|
||||
return PR;
|
||||
}
|
||||
else if (id == "dr") {
|
||||
else if (stat_lower == "dr") {
|
||||
return DR;
|
||||
}
|
||||
else if (id == "phr") {
|
||||
else if (stat_lower == "phr") {
|
||||
return PhR;
|
||||
}
|
||||
else if (id == "runspeed") {
|
||||
else if (stat_lower == "runspeed") {
|
||||
return runspeed;
|
||||
}
|
||||
|
||||
else if (id == "attack_speed") {
|
||||
else if (stat_lower == "attack_speed") {
|
||||
return attack_speed;
|
||||
}
|
||||
else if (id == "attack_delay") {
|
||||
else if (stat_lower == "attack_delay") {
|
||||
return attack_delay;
|
||||
}
|
||||
else if (id == "atk") {
|
||||
else if (stat_lower == "atk") {
|
||||
return ATK;
|
||||
}
|
||||
else if (id == "accuracy") {
|
||||
else if (stat_lower == "accuracy") {
|
||||
return accuracy_rating;
|
||||
}
|
||||
else if (id == "avoidance") {
|
||||
else if (stat_lower == "avoidance") {
|
||||
return avoidance_rating;
|
||||
}
|
||||
else if (id == "trackable") {
|
||||
else if (stat_lower == "trackable") {
|
||||
return trackable;
|
||||
}
|
||||
else if (id == "min_hit") {
|
||||
else if (stat_lower == "min_hit") {
|
||||
return min_dmg;
|
||||
}
|
||||
else if (id == "max_hit") {
|
||||
else if (stat_lower == "max_hit") {
|
||||
return max_dmg;
|
||||
}
|
||||
else if (id == "attack_count") {
|
||||
else if (stat_lower == "attack_count") {
|
||||
return attack_count;
|
||||
}
|
||||
else if (id == "see_invis") {
|
||||
else if (stat_lower == "see_invis") {
|
||||
return see_invis;
|
||||
}
|
||||
else if (id == "see_invis_undead") {
|
||||
else if (stat_lower == "see_invis_undead") {
|
||||
return see_invis_undead;
|
||||
}
|
||||
else if (id == "see_hide") {
|
||||
else if (stat_lower == "see_hide") {
|
||||
return see_hide;
|
||||
}
|
||||
else if (id == "see_improved_hide") {
|
||||
else if (stat_lower == "see_improved_hide") {
|
||||
return see_improved_hide;
|
||||
}
|
||||
else if (id == "hp_regen") {
|
||||
else if (stat_lower == "hp_regen") {
|
||||
return hp_regen;
|
||||
}
|
||||
else if (id == "hp_regen_per_second") {
|
||||
else if (stat_lower == "hp_regen_per_second") {
|
||||
return hp_regen_per_second;
|
||||
}
|
||||
else if (id == "mana_regen") {
|
||||
else if (stat_lower == "mana_regen") {
|
||||
return mana_regen;
|
||||
}
|
||||
else if (id == "level") {
|
||||
else if (stat_lower == "level") {
|
||||
return GetOrigLevel();
|
||||
}
|
||||
else if (id == "aggro") {
|
||||
else if (stat_lower == "aggro") {
|
||||
return pAggroRange;
|
||||
}
|
||||
else if (id == "assist") {
|
||||
else if (stat_lower == "assist") {
|
||||
return pAssistRange;
|
||||
}
|
||||
else if (id == "slow_mitigation") {
|
||||
else if (stat_lower == "slow_mitigation") {
|
||||
return slow_mitigation;
|
||||
}
|
||||
else if (id == "loottable_id") {
|
||||
else if (stat_lower == "loottable_id") {
|
||||
return loottable_id;
|
||||
}
|
||||
else if (id == "healscale") {
|
||||
else if (stat_lower == "healscale") {
|
||||
return healscale;
|
||||
}
|
||||
else if (id == "spellscale") {
|
||||
else if (stat_lower == "spellscale") {
|
||||
return spellscale;
|
||||
}
|
||||
else if (id == "npc_spells_id") {
|
||||
else if (stat_lower == "npc_spells_id") {
|
||||
return npc_spells_id;
|
||||
}
|
||||
else if (id == "npc_spells_effects_id") {
|
||||
else if (stat_lower == "npc_spells_effects_id") {
|
||||
return npc_spells_effects_id;
|
||||
}
|
||||
else if (id == "heroic_strikethrough") {
|
||||
else if (stat_lower == "heroic_strikethrough") {
|
||||
return heroic_strikethrough;
|
||||
}
|
||||
//default values
|
||||
else if (id == "default_ac") {
|
||||
else if (stat_lower == "default_ac") {
|
||||
return default_ac;
|
||||
}
|
||||
else if (id == "default_min_hit") {
|
||||
else if (stat_lower == "default_min_hit") {
|
||||
return default_min_dmg;
|
||||
}
|
||||
else if (id == "default_max_hit") {
|
||||
else if (stat_lower == "default_max_hit") {
|
||||
return default_max_dmg;
|
||||
}
|
||||
else if (id == "default_attack_delay") {
|
||||
else if (stat_lower == "default_attack_delay") {
|
||||
return default_attack_delay;
|
||||
}
|
||||
else if (id == "default_accuracy") {
|
||||
else if (stat_lower == "default_accuracy") {
|
||||
return default_accuracy_rating;
|
||||
}
|
||||
else if (id == "default_avoidance") {
|
||||
else if (stat_lower == "default_avoidance") {
|
||||
return default_avoidance_rating;
|
||||
}
|
||||
else if (id == "default_atk") {
|
||||
else if (stat_lower == "default_atk") {
|
||||
return default_atk;
|
||||
}
|
||||
|
||||
|
||||
@ -431,8 +431,8 @@ public:
|
||||
void SetAvoidanceRating(int32 d) { avoidance_rating = d;}
|
||||
int32 GetRawAC() const { return AC; }
|
||||
|
||||
float GetNPCStat(const char *identifier);
|
||||
void ModifyNPCStat(const char *identifier, const char *new_value);
|
||||
float GetNPCStat(std::string stat);
|
||||
void ModifyNPCStat(std::string stat, std::string value);
|
||||
virtual void SetLevel(uint8 in_level, bool command = false);
|
||||
|
||||
bool IsLDoNTrapped() const { return (ldon_trapped); }
|
||||
|
||||
@ -449,14 +449,14 @@ void Perl_NPC_SetSwarmTarget(NPC* self, int target_id) // @categories Pet
|
||||
self->SetSwarmTarget(target_id);
|
||||
}
|
||||
|
||||
void Perl_NPC_ModifyNPCStat(NPC* self, const char* stat, const char* value) // @categories Stats and Attributes
|
||||
void Perl_NPC_ModifyNPCStat(NPC* self, std::string stat, std::string value) // @categories Stats and Attributes
|
||||
{
|
||||
self->ModifyNPCStat(stat, value);
|
||||
}
|
||||
|
||||
float Perl_NPC_GetNPCStat(NPC* self, const char* identifier) // @categories Stats and Attributes
|
||||
float Perl_NPC_GetNPCStat(NPC* self, std::string stat) // @categories Stats and Attributes
|
||||
{
|
||||
return self->GetNPCStat(identifier);
|
||||
return self->GetNPCStat(stat);
|
||||
}
|
||||
|
||||
void Perl_NPC_AddSpellToNPCList(NPC* self, int16 priority, uint16_t spell_id, uint32 type, int mana_cost, int recast_delay, int16 resist_adjust) // @categories Spells and Disciplines, Script Utility
|
||||
|
||||
@ -2579,14 +2579,11 @@ uint16 QuestManager::CreateGroundObjectFromModel(const char *model, const glm::v
|
||||
return entid;
|
||||
}
|
||||
|
||||
void QuestManager::ModifyNPCStat(const char *identifier, const char *newValue)
|
||||
void QuestManager::ModifyNPCStat(std::string stat, std::string value)
|
||||
{
|
||||
QuestManagerCurrentQuestVars();
|
||||
if(owner){
|
||||
if(owner->IsNPC())
|
||||
{
|
||||
owner->CastToNPC()->ModifyNPCStat(identifier, newValue);
|
||||
}
|
||||
if (owner && owner->IsNPC()) {
|
||||
owner->CastToNPC()->ModifyNPCStat(stat, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -250,7 +250,7 @@ public:
|
||||
void removetitle(int titlecheck);
|
||||
uint16 CreateGroundObject(uint32 itemid, const glm::vec4& position, uint32 decay_time = 300000);
|
||||
uint16 CreateGroundObjectFromModel(const char* model, const glm::vec4& position, uint8 type = 0x00, uint32 decay_time = 0);
|
||||
void ModifyNPCStat(const char *identifier, const char *newValue);
|
||||
void ModifyNPCStat(std::string stat, std::string value);
|
||||
void UpdateSpawnTimer(uint32 id, uint32 newTime);
|
||||
void MerchantSetItem(uint32 NPCid, uint32 itemid, uint32 quantity = 0);
|
||||
uint32 MerchantCountItem(uint32 NPCid, uint32 itemid);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user