Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Crow:
- This function is a really heavy height check that is used for getting all types of height checks!
- Since it is in the object class, we can skip any actual variables and instead use our current position.
- This function gets map height and also checks the position of WMO's so that the height is set to the WMO height
- based on the Z position that is given. If no Z position is given, but x and y positions are given, we will instead
- use basic map heights as our Z position. */
- float Object::GetCHeightForPosition(bool checkwater, float x, float y, float z)
- {
- if(!IsInWorld())
- return 0.0f;
- MapMgr* mgr = GetMapMgr();
- float offset = 0.02156f;
- if(x == 0.0f && y == 0.0f)
- {
- x = GetPositionX();
- y = GetPositionY();
- }
- if(z == 0.0f)
- z = GetPositionZ();
- if(!mgr->GetBaseMap() || !mgr->GetBaseMap()->GetMapTerrain())
- return z;
- float waterheight = mgr->GetWaterHeight(x, y);
- float mapheight = mgr->GetLandHeight(x, y);
- if(!mgr->CanUseCollision(this))
- {
- if(checkwater)
- if(waterheight > mapheight)
- return waterheight+offset;
- return mapheight+offset;
- }
- float vmapheight = CollideInterface.GetHeight(GetMapId(), x, y, z);
- if(IS_INSTANCE(mgr->GetMapId()) || !sWorld.CalculatedHeightChecks)
- {
- if(vmapheight != NO_WMO_HEIGHT)
- {
- if(checkwater)
- if(waterheight > vmapheight)
- return waterheight+offset;
- return vmapheight+offset;
- }
- if(checkwater)
- if(waterheight > mapheight)
- return waterheight+offset;
- return mapheight+offset;
- }
- float phx = 0.0f;
- float phy = 0.0f;
- float phz = 0.0f;
- float CMapHeight = NO_LAND_HEIGHT;
- CollideInterface.GetFirstPoint(GetMapId(), x, y, z-50.0f, x, y, z+50.0f, phx, phy, CMapHeight, 0.0f);
- // Mapheight first.
- if(mapheight != NO_LAND_HEIGHT)
- {
- if(mapheight-2.0f < z)
- {
- if(mapheight+2.0f > z) // Accurate map height
- {
- if(checkwater)
- if(waterheight > mapheight)
- return waterheight+offset;
- return mapheight+offset;
- }
- if(!CollideInterface.GetFirstPoint(GetMapId(), x, y, mapheight, x, y, z, phx, phy, phz, 0.0f))
- {
- if(checkwater)
- if(waterheight > mapheight)
- return waterheight+offset;
- return mapheight+offset; // No breaks inbetween us, so its the right height, we're just a bunch of fuckers!
- }
- // TODO
- }
- else
- {
- // TODO
- }
- }
- // Now Vmap Height
- if(vmapheight != NO_WMO_HEIGHT)
- {
- if(vmapheight-2.0f < z)
- {
- if(vmapheight+2.0f > z) // Accurate map height
- {
- if(checkwater)
- if(waterheight > vmapheight)
- return waterheight+offset;
- return vmapheight+offset;
- }
- if(!CollideInterface.GetFirstPoint(GetMapId(), x, y, vmapheight, x, y, z, phx, phy, phz, 0.0f))
- {
- if(checkwater)
- if(waterheight > vmapheight)
- return waterheight+offset;
- return vmapheight+offset; // No breaks inbetween us, so its the right height, we're just a bunch of fuckers!
- }
- if(phz > z)
- {
- if(vmapheight < z)
- {
- float mmapheight = NavMeshInterface.GetWalkingHeight(GetMapId(), x, y, z, vmapheight);
- if(mmapheight != MMAP_UNAVAILABLE)
- {
- if(checkwater)
- if(waterheight > mmapheight)
- return waterheight+offset;
- return mmapheight+offset;
- }
- }
- }
- else
- {
- float mmapheight = NavMeshInterface.GetWalkingHeight(GetMapId(), x, y, z, phz);
- if(mmapheight != MMAP_UNAVAILABLE)
- {
- if(checkwater)
- if(waterheight > mmapheight)
- return waterheight+offset;
- return mmapheight+offset;
- }
- }
- }
- else
- {
- float mmapheight = NavMeshInterface.GetWalkingHeight(GetMapId(), x, y, z, vmapheight);
- if(mmapheight != MMAP_UNAVAILABLE)
- {
- if(checkwater)
- if(waterheight > mmapheight)
- return waterheight+offset;
- return mmapheight+offset;
- }
- }
- }
- // I think it's safe to say, no one is ever perfect.
- if((CMapHeight != z+50.0f) && (CMapHeight != z-50.0f))
- {
- if(checkwater)
- if(waterheight > CMapHeight)
- return waterheight+offset;
- return CMapHeight+offset;
- }
- if(checkwater)
- return waterheight;
- return z;
- /*
- // Crow: WE SHOULD GET HIGHEST REASONABLE VALUE BASED ON Z AND THE CALCULATIONS BELOW
- // For now return the lowest reasonable one!
- if(ccollidemapheight != NO_WMO_HEIGHT)
- {
- if(checkwater == true)
- {
- float wz = mgr->GetWaterHeight(x, y);
- if(wz > ccollidemapheight && !(wz > (WMO_MAX_HEIGHT/2)))
- ccollidemapheight = wz;
- }
- if(ccollidemapheight < cvmapheight && ccollidemapheight+3.0f > cvmapheight || ccollidemapheight < cmapheight && ccollidemapheight+3.0f > cmapheight)
- return ccollidemapheight + ((z-1.0f > ccollidemapheight) ? 1.0f : 0.21563f);
- }
- if(cvmapheight != NO_WMO_HEIGHT)
- {
- if(checkwater == true)
- {
- float wz = mgr->GetWaterHeight(x, y);
- if(wz > cvmapheight && !(wz > (WMO_MAX_HEIGHT/2)))
- cvmapheight = wz;
- }
- if(cvmapheight < ccollidemapheight && cvmapheight+3.0f > ccollidemapheight || cvmapheight < cmapheight && cvmapheight+3.0f > cmapheight)
- return cvmapheight + ((z-1.0f > cvmapheight) ? 1.0f : 0.21563f);
- }
- if(checkwater == true)
- {
- float wz = mgr->GetWaterHeight(x, y);
- if(wz > cmapheight && !(wz > (WMO_MAX_HEIGHT/2)))
- cmapheight = wz;
- }
- return cmapheight + ((z-1.0f > cmapheight) ? 1.0f : 0.21563f);
- float offset = 10.0f;
- if(vmapheight < z) // Make sure we don't have some shit.
- {
- if(mgr->CanUseCollision(this))
- {
- if(CollideInterface.IsIndoor(GetMapId(), x, y, z))
- offset = 5.0f;
- float pointx = 0.0f;
- float pointy = 0.0f;
- float pointz = 0.0f;
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, vmapheight+2.0f, x, y, z, pointx, pointy, pointz, 0.0f)) // Meaning there is a break inbetween us.
- {
- if(pointz+2.0f < vmapheight) // Distance is more than a roof.
- {
- float pointz2 = 0.0f;
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, vmapheight+2.0f, x, y, pointz, pointx, pointy, pointz2, 0.0f)) // Meaning there is a break inbetween us.
- {
- if(pointz2+2.0f < pointz) // Distance is more than a roof.
- {
- float pointz3 = 0.0f;
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, pointz, x, y, pointz2, pointx, pointy, pointz3, 0.0f)) // Meaning there is a break inbetween us.
- vmapheight = pointz3;
- }
- else
- vmapheight = pointz2;
- }
- else
- vmapheight = pointz;
- }
- else
- vmapheight = pointz;
- }
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, z+offset, x, y, vmapheight, pointx, pointy, pointz, 0.0f)) // Meaning there is a break inbetween us.
- {
- if(pointz+2.0f < vmapheight) // Distance is more than a roof.
- {
- float pointz2 = 0.0f;
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, z+offset, x, y, pointz, pointx, pointy, pointz2, 0.0f)) // Meaning there is a break inbetween us.
- {
- if(pointz2+2.0f < pointz) // Distance is more than a roof.
- {
- float pointz3 = 0.0f;
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, pointz, x, y, pointz2, pointx, pointy, pointz3, 0.0f)) // Meaning there is a break inbetween us.
- vmapheight = pointz3;
- }
- else
- vmapheight = pointz2;
- }
- else
- vmapheight = pointz;
- }
- else
- vmapheight = pointz;
- }
- }
- }
- else if(z+2.0f < vmapheight)
- {
- if(mgr->CanUseCollision(this))
- {
- if(CollideInterface.IsIndoor(GetMapId(), x, y, z))
- offset = 5.0f; // Use a smaller offset
- float pointx = 0.0f;
- float pointy = 0.0f;
- float pointz = 0.0f;
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, z+2.0f, x, y, vmapheight, pointx, pointy, pointz, 0.0f)) // Meaning there is a break inbetween us.
- {
- if(pointz+2.0f < vmapheight) // Distance is more than a roof.
- {
- float pointz2 = 0.0f;
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, pointz+2.0f, x, y, vmapheight, pointx, pointy, pointz2, 0.0f)) // Meaning there is a break inbetween us.
- {
- if(pointz2+2.0f < pointz) // Distance is more than a roof.
- {
- float pointz3 = 0.0f;
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, pointz2+2.0f, x, y, pointz, pointx, pointy, pointz3, 0.0f)) // Meaning there is a break inbetween us.
- vmapheight = pointz3;
- }
- else
- vmapheight = pointz2;
- }
- else
- vmapheight = pointz;
- }
- else
- vmapheight = pointz;
- }
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, vmapheight+offset, x, y, z, pointx, pointy, pointz, 0.0f)) // Meaning there is a break inbetween us.
- {
- if(pointz+2.0f < vmapheight) // Distance is more than a roof.
- {
- float pointz2 = 0.0f;
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, vmapheight+offset, x, y, pointz, pointx, pointy, pointz2, 0.0f)) // Meaning there is a break inbetween us.
- {
- if(pointz2+2.0f < pointz) // Distance is more than a roof.
- {
- float pointz3 = 0.0f;
- if(CollideInterface.GetFirstPoint(GetMapId(), x, y, pointz, x, y, pointz2, pointx, pointy, pointz3, 0.0f)) // Meaning there is a break inbetween us.
- vmapheight = pointz3;
- }
- else
- vmapheight = pointz2;
- }
- else
- vmapheight = pointz;
- }
- else
- vmapheight = pointz;
- }
- }
- }
- if(checkwater == true) // Crow: Pretty sure this is all we need.
- {
- float wz = mgr->GetWaterHeight(x, y);
- if(wz > vmapheight)
- vmapheight = wz;
- }
- return vmapheight+0.00321f; // We have a direct offset*/
- }
Add Comment
Please, Sign In to add comment