mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-14 20:12:26 +00:00
[Feature] Intoxication setter/getter for source, getter for Perl/Lua (#3330)
* Add setter and getter methods for intoxication Add GetIntoxication functions for perl and Lua * Remove trailing tab * Use clamp instead of min/max
This commit is contained in:
parent
c64a2aec94
commit
9f4d60ec36
@ -160,7 +160,7 @@ int Mob::compute_tohit(EQ::skills::SkillType skillinuse)
|
||||
if (IsNPC())
|
||||
tohit += CastToNPC()->GetAccuracyRating();
|
||||
if (IsClient()) {
|
||||
double reduction = CastToClient()->m_pp.intoxication / 2.0;
|
||||
double reduction = CastToClient()->GetIntoxication() / 2.0;
|
||||
if (reduction > 20.0) {
|
||||
reduction = std::min((110 - reduction) / 100.0, 1.0);
|
||||
tohit = reduction * static_cast<double>(tohit);
|
||||
@ -256,7 +256,7 @@ int Mob::compute_defense()
|
||||
defense += CastToNPC()->GetAvoidanceRating();
|
||||
|
||||
if (IsClient()) {
|
||||
double reduction = CastToClient()->m_pp.intoxication / 2.0;
|
||||
double reduction = CastToClient()->GetIntoxication() / 2.0;
|
||||
if (reduction > 20.0) {
|
||||
reduction = std::min((110 - reduction) / 100.0, 1.0);
|
||||
defense = reduction * static_cast<double>(defense);
|
||||
|
||||
@ -908,8 +908,8 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
|
||||
}
|
||||
|
||||
// Garble the message based on drunkness
|
||||
if (m_pp.intoxication > 0 && !(RuleB(Chat, ServerWideOOC) && chan_num == ChatChannel_OOC) && !GetGM()) {
|
||||
GarbleMessage(message, (int)(m_pp.intoxication / 3));
|
||||
if (GetIntoxication() > 0 && !(RuleB(Chat, ServerWideOOC) && chan_num == ChatChannel_OOC) && !GetGM()) {
|
||||
GarbleMessage(message, (int)(GetIntoxication() / 3));
|
||||
language = 0; // No need for language when drunk
|
||||
lang_skill = 100;
|
||||
}
|
||||
@ -8340,6 +8340,11 @@ void Client::SetThirst(int32 in_thirst)
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
void Client::SetIntoxication(int32 in_intoxication)
|
||||
{
|
||||
m_pp.intoxication = EQ::Clamp(in_intoxication, 0, 200);
|
||||
}
|
||||
|
||||
void Client::SetConsumption(int32 in_hunger, int32 in_thirst)
|
||||
{
|
||||
EQApplicationPacket *outapp = nullptr;
|
||||
|
||||
@ -67,6 +67,7 @@ namespace EQ
|
||||
#include "task_client_state.h"
|
||||
#include "cheat_manager.h"
|
||||
#include "../common/events/player_events.h"
|
||||
#include "../common/data_verification.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
// since windows defines these within windef.h (which windows.h include)
|
||||
@ -993,6 +994,7 @@ public:
|
||||
void SetThirst(int32 in_thirst);
|
||||
void SetConsumption(int32 in_hunger, int32 in_thirst);
|
||||
bool IsStarved() const { if (GetGM() || !RuleB(Character, EnableFoodRequirement) || !RuleB(Character, EnableHungerPenalties)) return false; return m_pp.hunger_level == 0 || m_pp.thirst_level == 0; }
|
||||
int32 GetIntoxication() const { return m_pp.intoxication; }
|
||||
|
||||
bool CheckTradeLoreConflict(Client* other);
|
||||
bool CheckTradeNonDroppable();
|
||||
@ -1582,6 +1584,7 @@ public:
|
||||
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 SetIntoxication(int32 in_intoxication);
|
||||
|
||||
void ShowNumHits(); // work around function for numhits not showing on buffs
|
||||
|
||||
|
||||
@ -797,10 +797,10 @@ uint32 Client::CalcCurrentWeight()
|
||||
|
||||
int32 Client::CalcAlcoholPhysicalEffect()
|
||||
{
|
||||
if (m_pp.intoxication <= 55) {
|
||||
if (GetIntoxication() <= 55) {
|
||||
return 0;
|
||||
}
|
||||
return (m_pp.intoxication - 40) / 16;
|
||||
return (GetIntoxication() - 40) / 16;
|
||||
}
|
||||
|
||||
int32 Client::CalcSTR()
|
||||
@ -878,8 +878,8 @@ int32 Client::CalcINT()
|
||||
int32 val = m_pp.INT + itembonuses.INT + spellbonuses.INT;
|
||||
int32 mod = aabonuses.INT;
|
||||
INT = val + mod;
|
||||
if (m_pp.intoxication) {
|
||||
int32 AlcINT = INT - (int32)((float)m_pp.intoxication / 200.0f * (float)INT) - 1;
|
||||
if (GetIntoxication()) {
|
||||
int32 AlcINT = INT - (int32)((float)GetIntoxication() / 200.0f * (float)INT) - 1;
|
||||
if ((AlcINT < (int)(0.2 * INT))) {
|
||||
INT = (int)(0.2f * (float)INT);
|
||||
}
|
||||
@ -902,8 +902,8 @@ int32 Client::CalcWIS()
|
||||
int32 val = m_pp.WIS + itembonuses.WIS + spellbonuses.WIS;
|
||||
int32 mod = aabonuses.WIS;
|
||||
WIS = val + mod;
|
||||
if (m_pp.intoxication) {
|
||||
int32 AlcWIS = WIS - (int32)((float)m_pp.intoxication / 200.0f * (float)WIS) - 1;
|
||||
if (GetIntoxication()) {
|
||||
int32 AlcWIS = WIS - (int32)((float)GetIntoxication() / 200.0f * (float)WIS) - 1;
|
||||
if ((AlcWIS < (int)(0.2 * WIS))) {
|
||||
WIS = (int)(0.2f * (float)WIS);
|
||||
}
|
||||
|
||||
@ -1309,7 +1309,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
|
||||
/* If we can maintain intoxication across zones, check for it */
|
||||
if (!RuleB(Character, MaintainIntoxicationAcrossZones))
|
||||
m_pp.intoxication = 0;
|
||||
SetIntoxication(0);
|
||||
|
||||
strcpy(name, m_pp.name);
|
||||
strcpy(lastname, m_pp.last_name);
|
||||
@ -5568,10 +5568,8 @@ void Client::Handle_OP_DeleteItem(const EQApplicationPacket *app)
|
||||
if (IntoxicationIncrease < 0)
|
||||
IntoxicationIncrease = 1;
|
||||
|
||||
m_pp.intoxication += IntoxicationIncrease;
|
||||
SetIntoxication(GetIntoxication()+IntoxicationIncrease);
|
||||
|
||||
if (m_pp.intoxication > 200)
|
||||
m_pp.intoxication = 200;
|
||||
}
|
||||
DeleteItemInInventory(alc->from_slot, 1);
|
||||
|
||||
|
||||
@ -518,9 +518,9 @@ bool Client::Process() {
|
||||
Save(0);
|
||||
}
|
||||
|
||||
if (m_pp.intoxication > 0)
|
||||
if (GetIntoxication() > 0)
|
||||
{
|
||||
--m_pp.intoxication;
|
||||
SetIntoxication(GetIntoxication()-1);
|
||||
CalcBonuses();
|
||||
}
|
||||
|
||||
|
||||
@ -2504,6 +2504,10 @@ int Lua_Client::GetSpellDamage() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetSpellDmg();
|
||||
}
|
||||
int Lua_Client::GetIntoxication() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetIntoxication();
|
||||
}
|
||||
|
||||
void Lua_Client::TaskSelector(luabind::adl::object table) {
|
||||
TaskSelector(table, false);
|
||||
@ -3237,6 +3241,7 @@ luabind::scope lua_register_client() {
|
||||
.def("GetIPExemption", (int(Lua_Client::*)(void))&Lua_Client::GetIPExemption)
|
||||
.def("GetIPString", (std::string(Lua_Client::*)(void))&Lua_Client::GetIPString)
|
||||
.def("GetInstrumentMod", (int(Lua_Client::*)(int))&Lua_Client::GetInstrumentMod)
|
||||
.def("GetIntoxication", (int(Lua_Client::*)(void))&Lua_Client::GetIntoxication)
|
||||
.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)
|
||||
|
||||
@ -395,6 +395,7 @@ public:
|
||||
void QueuePacket(Lua_Packet app, bool ack_req, int client_connection_status, int filter);
|
||||
int GetHunger();
|
||||
int GetThirst();
|
||||
int GetIntoxication();
|
||||
void SetHunger(int in_hunger);
|
||||
void SetThirst(int in_thirst);
|
||||
void SetConsumption(int in_hunger, int in_thirst);
|
||||
|
||||
@ -1522,6 +1522,11 @@ int Perl_Client_GetThirst(Client* self) // @categories Account and Character, St
|
||||
return self->GetThirst();
|
||||
}
|
||||
|
||||
int Perl_Client_GetIntoxication(Client* self) // @categories Account and Character, Stats and Attributes
|
||||
{
|
||||
return self->GetIntoxication();
|
||||
}
|
||||
|
||||
void Perl_Client_SetHunger(Client* self, int in_hunger) // @categories Script Utility, Stats and Attributes
|
||||
{
|
||||
self->SetHunger(in_hunger);
|
||||
@ -3093,6 +3098,7 @@ void perl_register_client()
|
||||
package.add("GetHorseId", &Perl_Client_GetHorseId);
|
||||
package.add("GetHealAmount", &Perl_Client_GetHealAmount);
|
||||
package.add("GetHunger", &Perl_Client_GetHunger);
|
||||
package.add("GetIntoxication", &Perl_Client_GetIntoxication);
|
||||
package.add("GetIP", &Perl_Client_GetIP);
|
||||
package.add("GetIPExemption", &Perl_Client_GetIPExemption);
|
||||
package.add("GetIPString", &Perl_Client_GetIPString);
|
||||
|
||||
@ -1237,7 +1237,7 @@ int64 Mob::Tunecompute_tohit(EQ::skills::SkillType skillinuse, int accuracy_over
|
||||
tohit += add_accuracy;
|
||||
}
|
||||
if (IsClient()) {
|
||||
double reduction = CastToClient()->m_pp.intoxication / 2.0;
|
||||
double reduction = CastToClient()->GetIntoxication() / 2.0;
|
||||
if (reduction > 20.0) {
|
||||
reduction = std::min((110 - reduction) / 100.0, 1.0);
|
||||
tohit = reduction * static_cast<double>(tohit);
|
||||
@ -1366,7 +1366,7 @@ int64 Mob::Tunecompute_defense(int avoidance_override, int add_avoidance)
|
||||
}
|
||||
|
||||
if (IsClient()) {
|
||||
double reduction = CastToClient()->m_pp.intoxication / 2.0;
|
||||
double reduction = CastToClient()->GetIntoxication() / 2.0;
|
||||
if (reduction > 20.0) {
|
||||
reduction = std::min((110 - reduction) / 100.0, 1.0);
|
||||
defense = reduction * static_cast<double>(defense);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user