Implement PVP regions

This commit is contained in:
Michael Cook (mackal) 2016-08-04 23:56:08 -04:00
parent d53d569020
commit 68df09a570
8 changed files with 57 additions and 11 deletions

View File

@ -44,6 +44,7 @@ extern volatile bool RunLoops;
#include "zonedb.h" #include "zonedb.h"
#include "petitions.h" #include "petitions.h"
#include "command.h" #include "command.h"
#include "water_map.h"
#ifdef BOTS #ifdef BOTS
#include "bot_command.h" #include "bot_command.h"
#endif #endif
@ -156,7 +157,8 @@ Client::Client(EQStreamInterface* ieqs)
m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f), m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f),
m_AutoAttackPosition(0.0f, 0.0f, 0.0f, 0.0f), m_AutoAttackPosition(0.0f, 0.0f, 0.0f, 0.0f),
m_AutoAttackTargetLocation(0.0f, 0.0f, 0.0f), m_AutoAttackTargetLocation(0.0f, 0.0f, 0.0f),
m_lastsave(-1) m_lastsave(-1),
last_region_type(RegionTypeUnsupported)
{ {
for(int cf=0; cf < _FilterCount; cf++) for(int cf=0; cf < _FilterCount; cf++)
ClientFilters[cf] = FilterShow; ClientFilters[cf] = FilterShow;
@ -2482,13 +2484,15 @@ uint16 Client::GetMaxSkillAfterSpecializationRules(EQEmu::skills::SkillType skil
return Result; return Result;
} }
void Client::SetPVP(bool toggle) { void Client::SetPVP(bool toggle, bool message) {
m_pp.pvp = toggle ? 1 : 0; m_pp.pvp = toggle ? 1 : 0;
if(GetPVP()) if (message) {
this->Message_StringID(MT_Shout,PVP_ON); if(GetPVP())
else this->Message_StringID(MT_Shout,PVP_ON);
Message(13, "You no longer follow the ways of discord."); else
Message(13, "You no longer follow the ways of discord.");
}
SendAppearancePacket(AT_PVP, GetPVP()); SendAppearancePacket(AT_PVP, GetPVP());
Save(); Save();
@ -8533,3 +8537,27 @@ uint32 Client::GetMoney(uint8 type, uint8 subtype) {
int Client::GetAccountAge() { int Client::GetAccountAge() {
return (time(nullptr) - GetAccountCreation()); return (time(nullptr) - GetAccountCreation());
} }
void Client::CheckRegionTypeChanges()
{
if (!zone->HasWaterMap())
return;
auto new_region = zone->watermap->ReturnRegionType(glm::vec3(m_Position));
// still same region, do nothing
if (last_region_type == new_region)
return;
// region type changed
last_region_type = new_region;
// PVP is the only state we need to keep track of, so we can just return now for PVP servers
if (RuleI(World, PVPSettings) > 0)
return;
if (last_region_type == RegionTypePVP)
SetPVP(true, false);
else if (GetPVP())
SetPVP(false, false);
}

View File

@ -27,6 +27,7 @@ class Object;
class Raid; class Raid;
class Seperator; class Seperator;
class ServerPacket; class ServerPacket;
enum WaterRegionType : int;
namespace EQEmu namespace EQEmu
{ {
@ -360,9 +361,9 @@ public:
int32 LevelRegen(); int32 LevelRegen();
void HPTick(); void HPTick();
void SetGM(bool toggle); void SetGM(bool toggle);
void SetPVP(bool toggle); void SetPVP(bool toggle, bool message = true);
inline bool GetPVP() const { return zone->GetZoneID() == 77 ? true : (m_pp.pvp != 0); } inline bool GetPVP() const { return m_pp.pvp != 0; }
inline bool GetGM() const { return m_pp.gm != 0; } inline bool GetGM() const { return m_pp.gm != 0; }
inline void SetBaseClass(uint32 i) { m_pp.class_=i; } inline void SetBaseClass(uint32 i) { m_pp.class_=i; }
@ -1233,6 +1234,8 @@ public:
void SendHPUpdateMarquee(); void SendHPUpdateMarquee();
void CheckRegionTypeChanges();
protected: protected:
friend class Mob; friend class Mob;
void CalcItemBonuses(StatBonuses* newbon); void CalcItemBonuses(StatBonuses* newbon);
@ -1417,6 +1420,7 @@ private:
uint8 zonesummon_ignorerestrictions; uint8 zonesummon_ignorerestrictions;
ZoneMode zone_mode; ZoneMode zone_mode;
WaterRegionType last_region_type;
Timer position_timer; Timer position_timer;
uint8 position_timer_counter; uint8 position_timer_counter;

View File

@ -4576,8 +4576,11 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
safe_delete(outapp); safe_delete(outapp);
} }
if(zone->watermap && zone->watermap->InLiquid(glm::vec3(m_Position))) if (zone->watermap) {
CheckIncreaseSkill(EQEmu::skills::SkillSwimming, nullptr, -17); if (zone->watermap->InLiquid(glm::vec3(m_Position)))
CheckIncreaseSkill(EQEmu::skills::SkillSwimming, nullptr, -17);
CheckRegionTypeChanges();
}
return; return;
} }

View File

@ -8,7 +8,7 @@
extern const ZoneConfig *Config; extern const ZoneConfig *Config;
enum WaterRegionType { enum WaterRegionType : int {
RegionTypeUnsupported = -2, RegionTypeUnsupported = -2,
RegionTypeUntagged = -1, RegionTypeUntagged = -1,
RegionTypeNormal = 0, RegionTypeNormal = 0,
@ -33,6 +33,7 @@ public:
virtual bool InVWater(const glm::vec3& location) const = 0; virtual bool InVWater(const glm::vec3& location) const = 0;
virtual bool InLava(const glm::vec3& location) const = 0; virtual bool InLava(const glm::vec3& location) const = 0;
virtual bool InLiquid(const glm::vec3& location) const = 0; virtual bool InLiquid(const glm::vec3& location) const = 0;
virtual bool InPvP(const glm::vec3& location) const = 0;
protected: protected:
virtual bool Load(FILE *fp) { return false; } virtual bool Load(FILE *fp) { return false; }

View File

@ -30,6 +30,10 @@ bool WaterMapV1::InLiquid(const glm::vec3& location) const {
return InWater(location) || InLava(location); return InWater(location) || InLava(location);
} }
bool WaterMapV1::InPvP(const glm::vec3& location) const {
return ReturnRegionType(location) == RegionTypePVP;
}
bool WaterMapV1::Load(FILE *fp) { bool WaterMapV1::Load(FILE *fp) {
uint32 bsp_tree_size; uint32 bsp_tree_size;
if (fread(&bsp_tree_size, sizeof(bsp_tree_size), 1, fp) != 1) { if (fread(&bsp_tree_size, sizeof(bsp_tree_size), 1, fp) != 1) {

View File

@ -24,6 +24,7 @@ public:
virtual bool InVWater(const glm::vec3& location) const; virtual bool InVWater(const glm::vec3& location) const;
virtual bool InLava(const glm::vec3& location) const; virtual bool InLava(const glm::vec3& location) const;
virtual bool InLiquid(const glm::vec3& location) const; virtual bool InLiquid(const glm::vec3& location) const;
virtual bool InPvP(const glm::vec3& location) const;
protected: protected:
virtual bool Load(FILE *fp); virtual bool Load(FILE *fp);

View File

@ -33,6 +33,10 @@ bool WaterMapV2::InLiquid(const glm::vec3& location) const {
return InWater(location) || InLava(location); return InWater(location) || InLava(location);
} }
bool WaterMapV2::InPvP(const glm::vec3& location) const {
return ReturnRegionType(location) == RegionTypePVP;
}
bool WaterMapV2::Load(FILE *fp) { bool WaterMapV2::Load(FILE *fp) {
uint32 region_count; uint32 region_count;
if (fread(&region_count, sizeof(region_count), 1, fp) != 1) { if (fread(&region_count, sizeof(region_count), 1, fp) != 1) {

View File

@ -17,6 +17,7 @@ public:
virtual bool InVWater(const glm::vec3& location) const; virtual bool InVWater(const glm::vec3& location) const;
virtual bool InLava(const glm::vec3& location) const; virtual bool InLava(const glm::vec3& location) const;
virtual bool InLiquid(const glm::vec3& location) const; virtual bool InLiquid(const glm::vec3& location) const;
virtual bool InPvP(const glm::vec3& location) const;
protected: protected:
virtual bool Load(FILE *fp); virtual bool Load(FILE *fp);