[Quest API] Add GetEnvironmentalDamageName() to Perl/Lua. (#1964)

- Add EQ::constants::GetEnvironmentalDamageMap() and EQ::constants::GetEnvironmentalDamageName().
- Add quest::getenvironmentaldamagename(damage_type) to Perl.
- Add eq.get_environmental_damage_name(damage_type) to Lua.
- Cleanup GM messages for avoiding environmental damage.
This commit is contained in:
Kinglykrab
2022-02-10 16:09:56 -05:00
committed by GitHub
parent d656be6be4
commit f9eb4603a3
12 changed files with 98 additions and 33 deletions
+28 -21
View File
@@ -5784,8 +5784,7 @@ void Client::Handle_OP_EndLootRequest(const EQApplicationPacket *app)
void Client::Handle_OP_EnvDamage(const EQApplicationPacket *app)
{
if (!ClientFinishedLoading())
{
if (!ClientFinishedLoading()) {
SetHP(GetHP() - 1);
return;
}
@@ -5795,38 +5794,46 @@ void Client::Handle_OP_EnvDamage(const EQApplicationPacket *app)
DumpPacket(app);
return;
}
EnvDamage2_Struct* ed = (EnvDamage2_Struct*)app->pBuffer;
int damage = ed->damage;
if (ed->dmgtype == 252) {
int mod = spellbonuses.ReduceFallDamage + itembonuses.ReduceFallDamage + aabonuses.ReduceFallDamage;
auto damage = ed->damage;
if (ed->dmgtype == EQ::constants::EnvironmentalDamage::Falling) {
uint32 mod = spellbonuses.ReduceFallDamage + itembonuses.ReduceFallDamage + aabonuses.ReduceFallDamage;
damage -= damage * mod / 100;
}
if (damage < 0)
if (damage < 0) {
damage = 31337;
}
if (admin >= minStatusToAvoidFalling && GetGM()) {
Message(Chat::Red, "Your GM status protects you from %i points of type %i environmental damage.", ed->damage, ed->dmgtype);
Message(
Chat::Red,
fmt::format(
"Your GM status protects you from {} points of {} (Type {}) damage.",
ed->damage,
EQ::constants::GetEnvironmentalDamageName(ed->dmgtype),
ed->dmgtype
).c_str()
);
SetHP(GetHP() - 1);//needed or else the client wont acknowledge
return;
}
else if (GetInvul()) {
Message(Chat::Red, "Your invuln status protects you from %i points of type %i environmental damage.", ed->damage, ed->dmgtype);
} else if (GetInvul()) {
Message(
Chat::Red,
fmt::format(
"Your invulnerability protects you from {} points of {} (Type {}) damage.",
ed->damage,
EQ::constants::GetEnvironmentalDamageName(ed->dmgtype),
ed->dmgtype
).c_str()
);
SetHP(GetHP() - 1);//needed or else the client wont acknowledge
return;
}
else if (zone->GetZoneID() == 183 || zone->GetZoneID() == 184) {
// Hard coded tutorial and load zones for no fall damage
} else if (zone->GetZoneID() == Zones::TUTORIAL || zone->GetZoneID() == Zones::LOAD) { // Hard coded tutorial and load zones for no fall damage
return;
}
else {
} else {
SetHP(GetHP() - (damage * RuleR(Character, EnvironmentDamageMulipliter)));
/* EVENT_ENVIRONMENTAL_DAMAGE */
int final_damage = (damage * RuleR(Character, EnvironmentDamageMulipliter));
std::string export_string = fmt::format(
"{} {} {}",
+17
View File
@@ -8092,6 +8092,22 @@ XS(XS__getbodytypename) {
}
}
XS(XS__getenvironmentaldamagename);
XS(XS__getenvironmentaldamagename) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: quest::getenvironmentaldamagename(uint8 damage_type)");
dXSTARG;
uint8 damage_type = (uint8) SvIV(ST(0));
std::string environmental_damage_name = quest_manager.getenvironmentaldamagename(damage_type);
sv_setpv(TARG, environmental_damage_name.c_str());
XSprePUSH;
PUSHTARG;
XSRETURN(1);
}
/*
This is the callback perl will look for to setup the
quest package's XSUBs
@@ -8398,6 +8414,7 @@ EXTERN_C XS(boot_quest) {
newXS(strcpy(buf, "getcurrencyitemid"), XS__getcurrencyitemid, file);
newXS(strcpy(buf, "getgendername"), XS__getgendername, file);
newXS(strcpy(buf, "getdeityname"), XS__getdeityname, file);
newXS(strcpy(buf, "getenvironmentaldamagename"), XS__getenvironmentaldamagename, file);
newXS(strcpy(buf, "getguildnamebyid"), XS__getguildnamebyid, file);
newXS(strcpy(buf, "getguildidbycharid"), XS__getguildidbycharid, file);
newXS(strcpy(buf, "getgroupidbycharid"), XS__getgroupidbycharid, file);
+5
View File
@@ -3367,6 +3367,10 @@ std::string lua_get_body_type_name(uint32 bodytype_id) {
return quest_manager.getbodytypename(bodytype_id);
}
std::string lua_get_environmental_damage_name(uint8 damage_type) {
return quest_manager.getenvironmentaldamagename(damage_type);
}
#define LuaCreateNPCParse(name, c_type, default_value) do { \
cur = table[#name]; \
if(luabind::type(cur) != LUA_TNIL) { \
@@ -3814,6 +3818,7 @@ luabind::scope lua_register_general() {
luabind::def("get_faction_name", &lua_get_faction_name),
luabind::def("get_language_name", &lua_get_language_name),
luabind::def("get_body_type_name", &lua_get_body_type_name),
luabind::def("get_environmental_damage_name", &lua_get_environmental_damage_name),
/*
Cross Zone
+5
View File
@@ -3698,3 +3698,8 @@ const SPDat_Spell_Struct* QuestManager::getspell(uint32 spell_id) {
}
return nullptr;
}
std::string QuestManager::getenvironmentaldamagename(uint8 damage_type) {
std::string environmental_damage_name = EQ::constants::GetEnvironmentalDamageName(damage_type);
return environmental_damage_name;
}
+2 -1
View File
@@ -330,7 +330,8 @@ public:
std::string getinventoryslotname(int16 slot_id);
int getitemstat(uint32 item_id, std::string stat_identifier);
int getspellstat(uint32 spell_id, std::string stat_identifier, uint8 slot = 0);
const SPDat_Spell_Struct *getspell(uint32 spell_id);
const SPDat_Spell_Struct *getspell(uint32 spell_id);
std::string getenvironmentaldamagename(uint8 damage_type);
Client *GetInitiator() const;
NPC *GetNPC() const;