mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
InWater(y,x,z) converted to InWater(xyz_location)
This commit is contained in:
parent
d9d89ba9b3
commit
f9e65acf78
@ -7632,15 +7632,17 @@ void command_bestz(Client *c, const Seperator *sep) {
|
||||
|
||||
if(c->GetTarget()) {
|
||||
z=c->GetTarget()->GetZ();
|
||||
auto position = xyz_location(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z);
|
||||
RegionType = zone->watermap->ReturnRegionType(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z);
|
||||
c->Message(0,"InWater returns %d", zone->watermap->InWater(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z));
|
||||
c->Message(0,"InWater returns %d", zone->watermap->InWater(position));
|
||||
c->Message(0,"InLava returns %d", zone->watermap->InLava(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z));
|
||||
|
||||
}
|
||||
else {
|
||||
z=c->GetZ();
|
||||
auto position = xyz_location(c->GetX(), c->GetY(), z);
|
||||
RegionType = zone->watermap->ReturnRegionType(c->GetX(), c->GetY(), z);
|
||||
c->Message(0,"InWater returns %d", zone->watermap->InWater(c->GetX(), c->GetY(), z));
|
||||
c->Message(0,"InWater returns %d", zone->watermap->InWater(position));
|
||||
c->Message(0,"InLava returns %d", zone->watermap->InLava(c->GetX(), c->GetY(), z));
|
||||
|
||||
}
|
||||
|
||||
@ -216,7 +216,8 @@ bool Client::CanFish() {
|
||||
}
|
||||
|
||||
if(zone->zonemap != nullptr && zone->watermap != nullptr && RuleB(Watermap, CheckForWaterWhenFishing)) {
|
||||
float RodX, RodY, RodZ;
|
||||
|
||||
xyz_location rodPosition;
|
||||
// Tweak Rod and LineLength if required
|
||||
const float RodLength = RuleR(Watermap, FishingRodLength);
|
||||
const float LineLength = RuleR(Watermap, FishingLineLength);
|
||||
@ -225,25 +226,25 @@ bool Client::CanFish() {
|
||||
HeadingDegrees = (int) ((GetHeading()*360)/256);
|
||||
HeadingDegrees = HeadingDegrees % 360;
|
||||
|
||||
RodX = m_Position.m_X + RodLength * sin(HeadingDegrees * M_PI/180.0f);
|
||||
RodY = m_Position.m_Y + RodLength * cos(HeadingDegrees * M_PI/180.0f);
|
||||
rodPosition.m_X = m_Position.m_X + RodLength * sin(HeadingDegrees * M_PI/180.0f);
|
||||
rodPosition.m_Y = m_Position.m_Y + RodLength * cos(HeadingDegrees * M_PI/180.0f);
|
||||
|
||||
// Do BestZ to find where the line hanging from the rod intersects the water (if it is water).
|
||||
// and go 1 unit into the water.
|
||||
Map::Vertex dest;
|
||||
dest.x = RodX;
|
||||
dest.y = RodY;
|
||||
dest.x = rodPosition.m_X;
|
||||
dest.y = rodPosition.m_Y;
|
||||
dest.z = m_Position.m_Z+10;
|
||||
|
||||
RodZ = zone->zonemap->FindBestZ(dest, nullptr) + 4;
|
||||
bool in_lava = zone->watermap->InLava(RodX, RodY, RodZ);
|
||||
bool in_water = zone->watermap->InWater(RodX, RodY, RodZ) || zone->watermap->InVWater(RodX, RodY, RodZ);
|
||||
rodPosition.m_Z = zone->zonemap->FindBestZ(dest, nullptr) + 4;
|
||||
bool in_lava = zone->watermap->InLava(rodPosition.m_X, rodPosition.m_Y, rodPosition.m_Z);
|
||||
bool in_water = zone->watermap->InWater(rodPosition) || zone->watermap->InVWater(rodPosition.m_X, rodPosition.m_Y, rodPosition.m_Z);
|
||||
//Message(0, "Rod is at %4.3f, %4.3f, %4.3f, InWater says %d, InLava says %d", RodX, RodY, RodZ, in_water, in_lava);
|
||||
if (in_lava) {
|
||||
Message_StringID(MT_Skills, FISHING_LAVA); //Trying to catch a fire elemental or something?
|
||||
return false;
|
||||
}
|
||||
if((!in_water) || (m_Position.m_Z-RodZ)>LineLength) { //Didn't hit the water OR the water is too far below us
|
||||
if((!in_water) || (m_Position.m_Z-rodPosition.m_Z)>LineLength) { //Didn't hit the water OR the water is too far below us
|
||||
Message_StringID(MT_Skills, FISHING_LAND); //Trying to catch land sharks perhaps?
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define EQEMU_WATER_MAP_H
|
||||
|
||||
#include "../common/types.h"
|
||||
#include "position.h"
|
||||
#include <string>
|
||||
|
||||
enum WaterRegionType {
|
||||
@ -25,7 +26,7 @@ public:
|
||||
|
||||
static WaterMap* LoadWaterMapfile(std::string zone_name);
|
||||
virtual WaterRegionType ReturnRegionType(float y, float x, float z) const { return RegionTypeNormal; }
|
||||
virtual bool InWater(float y, float x, float z) const { return false; }
|
||||
virtual bool InWater(const xyz_location& location) const { return false; }
|
||||
virtual bool InVWater(float y, float x, float z) const { return false; }
|
||||
virtual bool InLava(float y, float x, float z) const { return false; }
|
||||
virtual bool InLiquid(float y, float x, float z) const { return false; }
|
||||
|
||||
@ -17,8 +17,8 @@ WaterRegionType WaterMapV2::ReturnRegionType(float y, float x, float z) const {
|
||||
return RegionTypeNormal;
|
||||
}
|
||||
|
||||
bool WaterMapV2::InWater(float y, float x, float z) const {
|
||||
return ReturnRegionType(y, x, z) == RegionTypeWater;
|
||||
bool WaterMapV2::InWater(const xyz_location& location) const {
|
||||
return ReturnRegionType(location.m_Y, location.m_X, location.m_Z) == RegionTypeWater;
|
||||
}
|
||||
|
||||
bool WaterMapV2::InVWater(float y, float x, float z) const {
|
||||
@ -30,7 +30,8 @@ bool WaterMapV2::InLava(float y, float x, float z) const {
|
||||
}
|
||||
|
||||
bool WaterMapV2::InLiquid(float y, float x, float z) const {
|
||||
return InWater(y, x, z) || InLava(y, x, z);
|
||||
auto location = xyz_location(y, x, z);
|
||||
return InWater(location) || InLava(y, x, z);
|
||||
}
|
||||
|
||||
bool WaterMapV2::Load(FILE *fp) {
|
||||
|
||||
@ -13,7 +13,7 @@ public:
|
||||
~WaterMapV2();
|
||||
|
||||
virtual WaterRegionType ReturnRegionType(float y, float x, float z) const;
|
||||
virtual bool InWater(float y, float x, float z) const;
|
||||
virtual bool InWater(const xyz_location& location) const;
|
||||
virtual bool InVWater(float y, float x, float z) const;
|
||||
virtual bool InLava(float y, float x, float z) const;
|
||||
virtual bool InLiquid(float y, float x, float z) const;
|
||||
|
||||
@ -227,7 +227,7 @@ void NPC::UpdateWaypoint(int wp_index)
|
||||
{
|
||||
|
||||
if(!RuleB(Watermap, CheckForWaterAtWaypoints) || !zone->HasWaterMap() ||
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z)))
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_CurrentWayPoint)))
|
||||
{
|
||||
Map::Vertex dest(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z);
|
||||
|
||||
@ -557,7 +557,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
|
||||
if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving))
|
||||
{
|
||||
if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() ||
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)))
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X)))
|
||||
{
|
||||
Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
|
||||
|
||||
@ -684,7 +684,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
|
||||
if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) {
|
||||
|
||||
if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() ||
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)))
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_Position)))
|
||||
{
|
||||
Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
|
||||
|
||||
@ -806,7 +806,7 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec
|
||||
if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving))
|
||||
{
|
||||
if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() ||
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)))
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_Position)))
|
||||
{
|
||||
Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
|
||||
|
||||
@ -900,8 +900,9 @@ void NPC::AssignWaypoints(int32 grid) {
|
||||
|
||||
if(zone->HasMap() && RuleB(Map, FixPathingZWhenLoading) )
|
||||
{
|
||||
auto positon = xyz_location(newwp.x,newwp.y,newwp.z);
|
||||
if(!RuleB(Watermap, CheckWaypointsInWaterWhenLoading) || !zone->HasWaterMap() ||
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(newwp.x, newwp.y, newwp.z)))
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(positon)))
|
||||
{
|
||||
Map::Vertex dest(newwp.x, newwp.y, newwp.z);
|
||||
|
||||
@ -947,7 +948,7 @@ void Mob::SendTo(float new_x, float new_y, float new_z) {
|
||||
if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo) )
|
||||
{
|
||||
if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() ||
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)))
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_Position)))
|
||||
{
|
||||
Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
|
||||
|
||||
@ -978,7 +979,7 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) {
|
||||
if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo))
|
||||
{
|
||||
if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() ||
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)))
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(m_Position)))
|
||||
{
|
||||
Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user