[API] Perl functions to set invulnerable to and modify environmental damage. (#2044)

* invulnerable

* modifier

* fix

* fix

* fix

* [API] Perl functions to set invulnerable to and modify environmental damage.

* [API] Perl and Lua functions to set invulnerable to and modify environmental damage.

credit to kinglykrab for lua
This commit is contained in:
KayenEQ 2022-03-08 19:50:46 -05:00 committed by GitHub
parent 5b6f1d38be
commit dbe0591b09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 113 additions and 0 deletions

View File

@ -353,6 +353,9 @@ Client::Client(EQStreamInterface* ieqs)
temp_pvp = false; temp_pvp = false;
is_client_moving = false; is_client_moving = false;
environment_damage_modifier = 0;
invulnerable_environment_damage = false;
// rate limiter // rate limiter
m_list_task_timers_rate_limit.Start(1000); m_list_task_timers_rate_limit.Start(1000);

View File

@ -1590,6 +1590,11 @@ public:
int mod_food_value(const EQ::ItemData *item, int change); int mod_food_value(const EQ::ItemData *item, int change);
int mod_drink_value(const EQ::ItemData *item, int change); int mod_drink_value(const EQ::ItemData *item, int change);
inline int32 GetEnvironmentDamageModifier() const { return environment_damage_modifier; }
void SetEnvironmentDamageModifier(int32 val) { environment_damage_modifier = val; }
inline bool GetInvulnerableEnvironmentDamage() const { return invulnerable_environment_damage; }
void SetInvulnerableEnvironmentDamage(bool val) { invulnerable_environment_damage = val; }
void ShowNumHits(); // work around function for numhits not showing on buffs void ShowNumHits(); // work around function for numhits not showing on buffs
void ApplyWeaponsStance(); void ApplyWeaponsStance();
@ -1789,6 +1794,8 @@ private:
int Haste; //precalced value int Haste; //precalced value
uint32 tmSitting; // time stamp started sitting, used for HP regen bonus added on MAY 5, 2004 uint32 tmSitting; // time stamp started sitting, used for HP regen bonus added on MAY 5, 2004
int32 environment_damage_modifier;
bool invulnerable_environment_damage;
// dev tools // dev tools
bool display_mob_info_window; bool display_mob_info_window;

View File

@ -5784,6 +5784,11 @@ void Client::Handle_OP_EnvDamage(const EQApplicationPacket *app)
EnvDamage2_Struct* ed = (EnvDamage2_Struct*)app->pBuffer; EnvDamage2_Struct* ed = (EnvDamage2_Struct*)app->pBuffer;
auto damage = ed->damage; auto damage = ed->damage;
if (GetEnvironmentDamageModifier()) {
damage = static_cast<int32>(damage) + (static_cast<int32>(damage) * GetEnvironmentDamageModifier() / 100);
}
if (ed->dmgtype == EQ::constants::EnvironmentalDamage::Falling) { if (ed->dmgtype == EQ::constants::EnvironmentalDamage::Falling) {
uint32 mod = spellbonuses.ReduceFallDamage + itembonuses.ReduceFallDamage + aabonuses.ReduceFallDamage; uint32 mod = spellbonuses.ReduceFallDamage + itembonuses.ReduceFallDamage + aabonuses.ReduceFallDamage;
damage -= damage * mod / 100; damage -= damage * mod / 100;
@ -5817,6 +5822,10 @@ void Client::Handle_OP_EnvDamage(const EQApplicationPacket *app)
); );
SetHP(GetHP() - 1);//needed or else the client wont acknowledge SetHP(GetHP() - 1);//needed or else the client wont acknowledge
return; return;
}
else if (GetInvulnerableEnvironmentDamage()) {
SetHP(GetHP() - 1);
return;
} else if (zone->GetZoneID() == Zones::TUTORIAL || zone->GetZoneID() == Zones::LOAD) { // 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; return;
} else { } else {

View File

@ -2346,6 +2346,26 @@ void Lua_Client::UnscribeSpellBySpellID(uint16 spell_id, bool update_client) {
self->UnscribeSpellBySpellID(spell_id, update_client); self->UnscribeSpellBySpellID(spell_id, update_client);
} }
int Lua_Client::GetEnvironmentDamageModifier() {
Lua_Safe_Call_Int();
return self->GetEnvironmentDamageModifier();
}
void Lua_Client::SetEnvironmentDamageModifier(int value) {
Lua_Safe_Call_Void();
self->SetEnvironmentDamageModifier(value);
}
bool Lua_Client::GetInvulnerableEnvironmentDamage() {
Lua_Safe_Call_Bool();
return self->GetInvulnerableEnvironmentDamage();
}
void Lua_Client::SetInvulnerableEnvironmentDamage(bool value) {
Lua_Safe_Call_Void();
self->SetInvulnerableEnvironmentDamage(value);
}
luabind::scope lua_register_client() { luabind::scope lua_register_client() {
return luabind::class_<Lua_Client, Lua_Mob>("Client") return luabind::class_<Lua_Client, Lua_Mob>("Client")
.def(luabind::constructor<>()) .def(luabind::constructor<>())
@ -2470,6 +2490,7 @@ luabind::scope lua_register_client() {
.def("GetEbonCrystals", (uint32(Lua_Client::*)(void))&Lua_Client::GetEbonCrystals) .def("GetEbonCrystals", (uint32(Lua_Client::*)(void))&Lua_Client::GetEbonCrystals)
.def("GetEndurance", (int(Lua_Client::*)(void))&Lua_Client::GetEndurance) .def("GetEndurance", (int(Lua_Client::*)(void))&Lua_Client::GetEndurance)
.def("GetEndurancePercent", (int(Lua_Client::*)(void))&Lua_Client::GetEndurancePercent) .def("GetEndurancePercent", (int(Lua_Client::*)(void))&Lua_Client::GetEndurancePercent)
.def("GetEnvironmentDamageModifier", (int(Lua_Client::*)(void))&Lua_Client::GetEnvironmentDamageModifier)
.def("GetExpedition", (Lua_Expedition(Lua_Client::*)(void))&Lua_Client::GetExpedition) .def("GetExpedition", (Lua_Expedition(Lua_Client::*)(void))&Lua_Client::GetExpedition)
.def("GetExpeditionLockouts", (luabind::object(Lua_Client::*)(lua_State* L))&Lua_Client::GetExpeditionLockouts) .def("GetExpeditionLockouts", (luabind::object(Lua_Client::*)(lua_State* L))&Lua_Client::GetExpeditionLockouts)
.def("GetExpeditionLockouts", (luabind::object(Lua_Client::*)(lua_State* L, std::string))&Lua_Client::GetExpeditionLockouts) .def("GetExpeditionLockouts", (luabind::object(Lua_Client::*)(lua_State* L, std::string))&Lua_Client::GetExpeditionLockouts)
@ -2486,6 +2507,7 @@ luabind::scope lua_register_client() {
.def("GetIPString", (std::string(Lua_Client::*)(void))&Lua_Client::GetIPString) .def("GetIPString", (std::string(Lua_Client::*)(void))&Lua_Client::GetIPString)
.def("GetInstrumentMod", (int(Lua_Client::*)(int))&Lua_Client::GetInstrumentMod) .def("GetInstrumentMod", (int(Lua_Client::*)(int))&Lua_Client::GetInstrumentMod)
.def("GetInventory", (Lua_Inventory(Lua_Client::*)(void))&Lua_Client::GetInventory) .def("GetInventory", (Lua_Inventory(Lua_Client::*)(void))&Lua_Client::GetInventory)
.def("GetInvulnerableEnvironmentDamage", (bool(Lua_Client::*)(void))&Lua_Client::GetInvulnerableEnvironmentDamage)
.def("GetItemIDAt", (int(Lua_Client::*)(int))&Lua_Client::GetItemIDAt) .def("GetItemIDAt", (int(Lua_Client::*)(int))&Lua_Client::GetItemIDAt)
.def("GetLDoNLosses", (int(Lua_Client::*)(void))&Lua_Client::GetLDoNLosses) .def("GetLDoNLosses", (int(Lua_Client::*)(void))&Lua_Client::GetLDoNLosses)
.def("GetLDoNLossesTheme", (int(Lua_Client::*)(int))&Lua_Client::GetLDoNLossesTheme) .def("GetLDoNLossesTheme", (int(Lua_Client::*)(int))&Lua_Client::GetLDoNLossesTheme)
@ -2671,6 +2693,7 @@ luabind::scope lua_register_client() {
.def("SetEXPModifier", (void(Lua_Client::*)(uint32,double))&Lua_Client::SetEXPModifier) .def("SetEXPModifier", (void(Lua_Client::*)(uint32,double))&Lua_Client::SetEXPModifier)
.def("SetEbonCrystals", (void(Lua_Client::*)(uint32))&Lua_Client::SetEbonCrystals) .def("SetEbonCrystals", (void(Lua_Client::*)(uint32))&Lua_Client::SetEbonCrystals)
.def("SetEndurance", (void(Lua_Client::*)(int))&Lua_Client::SetEndurance) .def("SetEndurance", (void(Lua_Client::*)(int))&Lua_Client::SetEndurance)
.def("SetEnvironmentDamageModifier", (void(Lua_Client::*)(int))&Lua_Client::SetEnvironmentDamageModifier)
.def("SetFactionLevel", (void(Lua_Client::*)(uint32,uint32,int,int,int))&Lua_Client::SetFactionLevel) .def("SetFactionLevel", (void(Lua_Client::*)(uint32,uint32,int,int,int))&Lua_Client::SetFactionLevel)
.def("SetFactionLevel2", (void(Lua_Client::*)(uint32,int,int,int,int,int,int))&Lua_Client::SetFactionLevel2) .def("SetFactionLevel2", (void(Lua_Client::*)(uint32,int,int,int,int,int,int))&Lua_Client::SetFactionLevel2)
.def("SetFeigned", (void(Lua_Client::*)(bool))&Lua_Client::SetFeigned) .def("SetFeigned", (void(Lua_Client::*)(bool))&Lua_Client::SetFeigned)
@ -2679,6 +2702,7 @@ luabind::scope lua_register_client() {
.def("SetHideMe", (void(Lua_Client::*)(bool))&Lua_Client::SetHideMe) .def("SetHideMe", (void(Lua_Client::*)(bool))&Lua_Client::SetHideMe)
.def("SetHorseId", (void(Lua_Client::*)(int))&Lua_Client::SetHorseId) .def("SetHorseId", (void(Lua_Client::*)(int))&Lua_Client::SetHorseId)
.def("SetHunger", (void(Lua_Client::*)(int))&Lua_Client::SetHunger) .def("SetHunger", (void(Lua_Client::*)(int))&Lua_Client::SetHunger)
.def("SetInvulnerableEnvironmentDamage", (void(Lua_Client::*)(int))&Lua_Client::SetInvulnerableEnvironmentDamage)
.def("SetIPExemption", (void(Lua_Client::*)(int))&Lua_Client::SetIPExemption) .def("SetIPExemption", (void(Lua_Client::*)(int))&Lua_Client::SetIPExemption)
.def("SetLanguageSkill", (void(Lua_Client::*)(int,int))&Lua_Client::SetLanguageSkill) .def("SetLanguageSkill", (void(Lua_Client::*)(int,int))&Lua_Client::SetLanguageSkill)
.def("SetMaterial", (void(Lua_Client::*)(int,uint32))&Lua_Client::SetMaterial) .def("SetMaterial", (void(Lua_Client::*)(int,uint32))&Lua_Client::SetMaterial)

View File

@ -393,6 +393,11 @@ public:
void RemoveItem(uint32 item_id, uint32 quantity); void RemoveItem(uint32 item_id, uint32 quantity);
void SetGMStatus(uint32 newStatus); void SetGMStatus(uint32 newStatus);
int GetEnvironmentDamageModifier();
void SetEnvironmentDamageModifier(int value);
bool GetInvulnerableEnvironmentDamage();
void SetInvulnerableEnvironmentDamage(bool value);
void SetPrimaryWeaponOrnamentation(uint32 model_id); void SetPrimaryWeaponOrnamentation(uint32 model_id);
void SetSecondaryWeaponOrnamentation(uint32 model_id); void SetSecondaryWeaponOrnamentation(uint32 model_id);

View File

@ -5996,6 +5996,67 @@ XS(XS_Client_UnscribeSpellBySpellID) {
XSRETURN_EMPTY; XSRETURN_EMPTY;
} }
XS(XS_Client_GetEnvironmentDamageModifier); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_GetEnvironmentDamageModifier) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Client::GetEnvironmentDamageModifier(THIS)"); // @categories Script Utility
{
Client* THIS;
int32 RETVAL;
dXSTARG;
VALIDATE_THIS_IS_CLIENT;
RETVAL = THIS->GetEnvironmentDamageModifier();
XSprePUSH;
PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Client_SetEnvironmentDamageModifier); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_SetEnvironmentDamageModifier) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Client::SetEnvironmentDamageModifier(THIS, int32 modifier)"); // @categories Script Utility
{
Client* THIS;
int32 modifier = (int32)SvIV(ST(1));
VALIDATE_THIS_IS_CLIENT;
THIS->SetEnvironmentDamageModifier(modifier);
}
XSRETURN_EMPTY;
}
XS(XS_Client_GetInvulnerableEnvironmentDamage); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_GetInvulnerableEnvironmentDamage) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Client::InvulnerableEnvironmentDamage(THIS)"); // @categories Script Utility
{
Client* THIS;
bool RETVAL;
VALIDATE_THIS_IS_CLIENT;
RETVAL = THIS->GetInvulnerableEnvironmentDamage();
ST(0) = boolSV(RETVAL);
sv_2mortal(ST(0));
}
XSRETURN(1);
}
XS(XS_Client_SetInvulnerableEnvironmentDamage); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_SetInvulnerableEnvironmentDamage) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage:Client::SetInvulnerableEnvironmentDamage(THIS, bool invulnerable)"); // @categories Script Utility
{
Client *THIS;
bool invul = (bool)SvTRUE(ST(1));
VALIDATE_THIS_IS_CLIENT;
THIS->SetInvulnerableEnvironmentDamage(invul);
}
XSRETURN_EMPTY;
}
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
@ -6104,6 +6165,7 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "GetDiscSlotBySpellID"), XS_Client_GetDiscSlotBySpellID, file, "$$"); newXSproto(strcpy(buf, "GetDiscSlotBySpellID"), XS_Client_GetDiscSlotBySpellID, file, "$$");
newXSproto(strcpy(buf, "GetDisciplineTimer"), XS_Client_GetDisciplineTimer, file, "$$"); newXSproto(strcpy(buf, "GetDisciplineTimer"), XS_Client_GetDisciplineTimer, file, "$$");
newXSproto(strcpy(buf, "GetDuelTarget"), XS_Client_GetDuelTarget, file, "$"); newXSproto(strcpy(buf, "GetDuelTarget"), XS_Client_GetDuelTarget, file, "$");
newXSproto(strcpy(buf, "GetEnvironmentDamageModifier"), XS_Client_GetEnvironmentDamageModifier, file, "$");
newXSproto(strcpy(buf, "GetEXP"), XS_Client_GetEXP, file, "$"); newXSproto(strcpy(buf, "GetEXP"), XS_Client_GetEXP, file, "$");
newXSproto(strcpy(buf, "GetEXPModifier"), XS_Client_GetEXPModifier, file, "$$"); newXSproto(strcpy(buf, "GetEXPModifier"), XS_Client_GetEXPModifier, file, "$$");
newXSproto(strcpy(buf, "GetEbonCrystals"), XS_Client_GetEbonCrystals, file, "$"); newXSproto(strcpy(buf, "GetEbonCrystals"), XS_Client_GetEbonCrystals, file, "$");
@ -6127,6 +6189,7 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "GetInstanceID"), XS_Client_GetInstanceID, file, "$$"); newXSproto(strcpy(buf, "GetInstanceID"), XS_Client_GetInstanceID, file, "$$");
newXSproto(strcpy(buf, "GetInstrumentMod"), XS_Client_GetInstrumentMod, file, "$$"); newXSproto(strcpy(buf, "GetInstrumentMod"), XS_Client_GetInstrumentMod, file, "$$");
newXSproto(strcpy(buf, "GetInventory"), XS_Client_GetInventory, file, "$"); newXSproto(strcpy(buf, "GetInventory"), XS_Client_GetInventory, file, "$");
newXSproto(strcpy(buf, "GetInvulnerableEnvironmentDamage"), XS_Client_GetInvulnerableEnvironmentDamage, file, "$");
newXSproto(strcpy(buf, "GetItemAt"), XS_Client_GetItemAt, file, "$$"); newXSproto(strcpy(buf, "GetItemAt"), XS_Client_GetItemAt, file, "$$");
newXSproto(strcpy(buf, "GetItemIDAt"), XS_Client_GetItemIDAt, file, "$$"); newXSproto(strcpy(buf, "GetItemIDAt"), XS_Client_GetItemIDAt, file, "$$");
newXSproto(strcpy(buf, "GetItemInInventory"), XS_Client_GetItemInInventory, file, "$$"); newXSproto(strcpy(buf, "GetItemInInventory"), XS_Client_GetItemInInventory, file, "$$");
@ -6272,6 +6335,7 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "SetEXPModifier"), XS_Client_SetEXPModifier, file, "$$$"); newXSproto(strcpy(buf, "SetEXPModifier"), XS_Client_SetEXPModifier, file, "$$$");
newXSproto(strcpy(buf, "SetEbonCrystals"), XS_Client_SetEbonCrystals, file, "$$"); newXSproto(strcpy(buf, "SetEbonCrystals"), XS_Client_SetEbonCrystals, file, "$$");
newXSproto(strcpy(buf, "SetEndurance"), XS_Client_SetEndurance, file, "$$"); newXSproto(strcpy(buf, "SetEndurance"), XS_Client_SetEndurance, file, "$$");
newXSproto(strcpy(buf, "SetEnvironmentDamageModifier"), XS_Client_SetEnvironmentDamageModifier, file, "$$");
newXSproto(strcpy(buf, "SetFactionLevel"), XS_Client_SetFactionLevel, file, "$$$$$$"); newXSproto(strcpy(buf, "SetFactionLevel"), XS_Client_SetFactionLevel, file, "$$$$$$");
newXSproto(strcpy(buf, "SetFactionLevel2"), XS_Client_SetFactionLevel2, file, "$$$$$$$"); newXSproto(strcpy(buf, "SetFactionLevel2"), XS_Client_SetFactionLevel2, file, "$$$$$$$");
newXSproto(strcpy(buf, "SetFeigned"), XS_Client_SetFeigned, file, "$$"); newXSproto(strcpy(buf, "SetFeigned"), XS_Client_SetFeigned, file, "$$");
@ -6281,6 +6345,7 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "SetHorseId"), XS_Client_SetHorseId, file, "$$"); newXSproto(strcpy(buf, "SetHorseId"), XS_Client_SetHorseId, file, "$$");
newXSproto(strcpy(buf, "SetHunger"), XS_Client_SetHunger, file, "$$"); newXSproto(strcpy(buf, "SetHunger"), XS_Client_SetHunger, file, "$$");
newXSproto(strcpy(buf, "SetIPExemption"), XS_Client_SetIPExemption, file, "$$"); newXSproto(strcpy(buf, "SetIPExemption"), XS_Client_SetIPExemption, file, "$$");
newXSproto(strcpy(buf, "SetInvulnerableEnvironmentDamage"), XS_Client_SetInvulnerableEnvironmentDamage, file, "$$");
newXSproto(strcpy(buf, "SetLanguageSkill"), XS_Client_SetLanguageSkill, file, "$$$"); newXSproto(strcpy(buf, "SetLanguageSkill"), XS_Client_SetLanguageSkill, file, "$$$");
newXSproto(strcpy(buf, "SetMaterial"), XS_Client_SetMaterial, file, "$$$"); newXSproto(strcpy(buf, "SetMaterial"), XS_Client_SetMaterial, file, "$$$");
newXSproto(strcpy(buf, "SetPVP"), XS_Client_SetPVP, file, "$$"); newXSproto(strcpy(buf, "SetPVP"), XS_Client_SetPVP, file, "$$");