void CUser::MoveProcess(Packet & pkt)
{
	ASSERT(GetMap() != nullptr);
	if (m_bWarp || isDead()) 
		return;

	uint16 will_x, will_z, will_y;
	int16 speed=0;
	float real_x, real_z, real_y;
	uint8 echo;

	pkt >> will_x >> will_z >> will_y >> speed >> echo;
	real_x = will_x/10.0f; real_z = will_z/10.0f; real_y = will_y/10.0f;

	if (!isGM())
	{
		// TO-DO: Handle proper speed checks against server-side amounts.
		// We should also avoid relying on what the client has sent us.
		if (speed > 200)	// What is the signifance of this number? Considering 90 is light feet...
			// We shouldn't be using magic numbers at all here.
		{
			Disconnect();
			return;
		}
	}

	if (!GetMap()->IsValidPosition(real_x, real_z, real_y)) 
		return;

	if (m_oldx != GetX()
		|| m_oldz != GetZ())
	{
		m_oldx = GetX();
		m_oldy = GetY();
		m_oldz = GetZ();
	}

	// TO-DO: Ensure this is checked properly to prevent speedhacking
	SetPosition(real_x, real_y, real_z);

	if (RegisterRegion())
	{
		g_pMain->RegionNpcInfoForMe(this);
		g_pMain->RegionUserInOutForMe(this);
		g_pMain->MerchantUserInOutForMe(this);
	}

	if (m_bInvisibilityType == INVIS_DISPEL_ON_MOVE)
		CMagicProcess::RemoveStealth(this, INVIS_DISPEL_ON_MOVE);

	Packet result(WIZ_MOVE);
	result << GetSocketID() << will_x << will_z << will_y << speed << echo;
	SendToRegion(&result);

	GetMap()->CheckEvent(real_x, real_z, this);

	result.Initialize(AG_USER_MOVE);
	result << GetSocketID() << m_curx << m_curz << m_cury << speed;
	Send_AIServer(&result);
}
示例#2
0
//o--------------------------------------------------------------------------o
//|	Function		-	Cleanup( void )
//|	Date			-	26th September, 2001
//|	Programmer		-	Abaddon
//|	Modified		-
//o--------------------------------------------------------------------------o
//|	Purpose			-	Makes sure that any items and chars inside the multi
//|						are removed
//o--------------------------------------------------------------------------o
void CMultiObj::Cleanup( void )
{
	for( CItem *iRemove = itemInMulti.First(); !itemInMulti.Finished(); iRemove = itemInMulti.Next() )
	{
		if( ValidateObject( iRemove ) )
		{
			ItemTypes iType = iRemove->GetType();
			if( iType == IT_DOOR || iType == IT_LOCKEDDOOR || iType == IT_HOUSESIGN )
				iRemove->Delete();
			else
			{
				if( iRemove->IsLockedDown() )
					iRemove->SetMovable( 1 );
				iRemove->SetMulti( INVALIDSERIAL );
				iRemove->SetZ( GetZ() );
			}
		}
	}
	for( CChar *cRemove = charInMulti.First(); !charInMulti.Finished(); cRemove = charInMulti.Next() )
	{
		if( ValidateObject( cRemove ) )
		{
			cRemove->SetMulti( INVALIDSERIAL );
			cRemove->SetZ( GetZ() );
		}
	}
	CItem::Cleanup();
}
示例#3
0
NaGeVector3D NaGeVector3D::operator * (const NaGeMatrix33 &M)
{
	NaGeVector3D V;
	V.SetX(M(0,0)*GetX()+M(0,1)*GetY()+M(0,2)*GetZ());
	V.SetY(M(1,0)*GetX()+M(1,1)*GetY()+M(1,2)*GetZ());
	V.SetZ(M(2,0)*GetX()+M(2,1)*GetY()+M(2,2)*GetZ());
	return V;
}
示例#4
0
NaGeVector3D NaGeVector3D::Crossed(const NaGeVector3D &V1) const
{
	NaGeVector3D result;
	result.SetX(GetY()*V1.GetZ()-GetZ()*V1.GetY());
	result.SetY(GetZ()*V1.GetX()-GetX()*V1.GetZ());
	result.SetZ(GetX()*V1.GetY()-GetY()*V1.GetX());
	return result;
}
示例#5
0
  bool BoundingBox::CollidesWith (const ICollidable& other) const
  {
    if (GetZ () >= other.GetZ () + other.GetH () ||
        GetZ () + GetH () <= other.GetZ ())
      return false;

    return spatial3Info_.GetRectangle ().intersects (other.GetRectangle ());
  }
示例#6
0
文件: fearpath.cpp 项目: Vaion/Server
void Mob::CalculateNewFearpoint()
{
	if(RuleB(Pathing, Fear) && zone->pathing)
	{
		int Node = zone->pathing->GetRandomPathNode();
	
		VERTEX Loc = zone->pathing->GetPathNodeCoordinates(Node);

		++Loc.z;

		VERTEX CurrentPosition(GetX(), GetY(), GetZ());

		list<int> Route = zone->pathing->FindRoute(CurrentPosition, Loc);

		if(Route.size() > 0)
		{
			fear_walkto_x = Loc.x;
			fear_walkto_y = Loc.y;
			fear_walkto_z = Loc.z;
			curfp = true;

			mlog(PATHING__DEBUG, "Feared to node %i (%8.3f, %8.3f, %8.3f)", Node, Loc.x, Loc.y, Loc.z);
			return;
		}

		mlog(PATHING__DEBUG, "No path found to selected node. Falling through to old fear point selection.");
	}

	int loop = 0;
	float ranx, rany, ranz;
	curfp = false;
	while (loop < 100) //Max 100 tries
	{
		int ran = 250 - (loop*2);
		loop++;
		ranx = GetX()+MakeRandomInt(0, ran-1)-MakeRandomInt(0, ran-1);
		rany = GetY()+MakeRandomInt(0, ran-1)-MakeRandomInt(0, ran-1);
		ranz = FindGroundZ(ranx,rany);
		if (ranz == -999999)
			continue;
		float fdist = ranz - GetZ();
		if (fdist >= -12 && fdist <= 12 && CheckCoordLosNoZLeaps(GetX(),GetY(),GetZ(),ranx,rany,ranz))
		{
			curfp = true;
			break;
		}
	}
	if (curfp)
	{
		fear_walkto_x = ranx;
		fear_walkto_y = rany;
		fear_walkto_z = ranz;
	}
	else //Break fear
	{
		BuffFadeByEffect(SE_Fear);
	}
}
示例#7
0
///**
// *	MyWindow::OnMouseWheel()
// *	マウスホイールを動かした
// */
//bool MyWindow::OnMouseWheel(MouseMessage* pMsg)
//{
//	float z = 0.0f;
//	if (pMsg->GetZ() > 0) z = 0.1f;
//	if (pMsg->GetZ() < 0) z = -0.1f;
//
//	MyApp::GetInstance().Scale(z);
//
//	PRINTF("WHEEL: z=%d\n", pMsg->GetZ());
//	return true;
//}
bool MyWindow::OnMouseWheel::Handle()
{
	float z = 0.0f;
	if (GetZ() > 0) z = 0.1f;
	if (GetZ() < 0) z = -0.1f;

	MyApp::GetInstance().Scale(z);

	PRINTF("WHEEL: z=%d\n", GetZ());
	return true;
}
void CUser::MoveProcess(Packet & pkt)
{
	ASSERT(GetMap() != nullptr);
	if (m_bWarp || isDead()) 
		return;

	uint16 will_x, will_z, will_y;
	int16 speed=0;
	float real_x, real_z, real_y;
	uint8 echo;

	pkt >> will_x >> will_z >> will_y >> speed >> echo;
	real_x = will_x/10.0f; real_z = will_z/10.0f; real_y = will_y/10.0f;

	m_sSpeed = speed;
	SpeedHackUser();

	if (!GetMap()->IsValidPosition(real_x, real_z, real_y)) 
		return;

	if (m_oldx != GetX()
		|| m_oldz != GetZ())
	{
		m_oldx = GetX();
		m_oldy = GetY();
		m_oldz = GetZ();
	}

	// TODO: Ensure this is checked properly to prevent speedhacking
	SetPosition(real_x, real_y, real_z);

	if (RegisterRegion())
	{
		g_pMain->RegionNpcInfoForMe(this);
		g_pMain->RegionUserInOutForMe(this);
		g_pMain->MerchantUserInOutForMe(this);
	}

	if (m_bInvisibilityType == INVIS_DISPEL_ON_MOVE)
		CMagicProcess::RemoveStealth(this, INVIS_DISPEL_ON_MOVE);

	Packet result(WIZ_MOVE);
	result << GetSocketID() << will_x << will_z << will_y << speed << echo;
	SendToRegion(&result);

	GetMap()->CheckEvent(real_x, real_z, this);

	result.Initialize(AG_USER_MOVE);
	result << GetSocketID() << m_curx << m_curz << m_cury << speed;
	Send_AIServer(&result);
}
示例#9
0
void Mob::CalculateNewFearpoint()
{
	if(RuleB(Pathing, Fear) && zone->pathing)
	{
		int Node = zone->pathing->GetRandomPathNode();

		glm::vec3 Loc = zone->pathing->GetPathNodeCoordinates(Node);

		++Loc.z;

		glm::vec3 CurrentPosition(GetX(), GetY(), GetZ());

		std::deque<int> Route = zone->pathing->FindRoute(CurrentPosition, Loc);

		if(Route.size() > 0)
		{
            m_FearWalkTarget = glm::vec3(Loc.x, Loc.y, Loc.z);
			curfp = true;

			Log.Out(Logs::Detail, Logs::None, "Feared to node %i (%8.3f, %8.3f, %8.3f)", Node, Loc.x, Loc.y, Loc.z);
			return;
		}

		Log.Out(Logs::Detail, Logs::None, "No path found to selected node. Falling through to old fear point selection.");
	}

	int loop = 0;
	float ranx, rany, ranz;
	curfp = false;
	while (loop < 100) //Max 100 tries
	{
		int ran = 250 - (loop*2);
		loop++;
		ranx = GetX()+zone->random.Int(0, ran-1)-zone->random.Int(0, ran-1);
		rany = GetY()+zone->random.Int(0, ran-1)-zone->random.Int(0, ran-1);
		ranz = FindGroundZ(ranx,rany);
		if (ranz == -999999)
			continue;
		float fdist = ranz - GetZ();
		if (fdist >= -12 && fdist <= 12 && CheckCoordLosNoZLeaps(GetX(),GetY(),GetZ(),ranx,rany,ranz))
		{
			curfp = true;
			break;
		}
	}
	if (curfp)
        m_FearWalkTarget = glm::vec3(ranx, rany, ranz);
	else //Break fear
		BuffFadeByEffect(SE_Fear);
}
示例#10
0
bool Triple::EpsilonEquals(Triple t, double d)
{
  assert(d >= 0);
  if (GetX() - t.GetX() < d && GetX() - t.GetX() > -d)
    {
      if (GetY() - t.GetY() < d && GetY() - t.GetY() > -d)
	{
	  if (GetZ() - t.GetZ() < d && GetZ() - t.GetZ() > -d)
	    {
	      return true;
	    }
	}
    }
  return false;
}
示例#11
0
void Triple::Absolute()
{
  if (GetX() < 0)
    {
      SetX(-GetX());
    }
  if (GetY() < 0)
    {
      SetY(-GetY());
    }
  if (GetZ() < 0)
    {
      SetZ(-GetZ());
    }
}
示例#12
0
//Calculates the position of a point on the line between this matrix and the matrix
//"To" given that position's Z value.  Returns the result in ret;
void CPosMatrix::CalculateIntermediatePosFromZ(float fTargetDepth,CPosMatrix & To,CPosMatrix &ret)
{
	ASSERT(GetZ()>=fTargetDepth && To.GetZ()<=fTargetDepth);	//should be between and from higher then to
	float fDeltaZ=fTargetDepth-GetZ();
	if (fDeltaZ==0.0)	//No Z position change
	{
		ret=*this;
		return;
	}
	float fTotalDeltaZ=GetZ()-To.GetZ();
	float fTotalDeltaX=GetX()-To.GetX();
	float fTotalDeltaY=GetY()-To.GetY();
	float fPercent=fDeltaZ/fTotalDeltaZ;
	ret.Set(GetX()+fTotalDeltaX*fPercent,GetY()+fTotalDeltaY*fPercent,fTargetDepth);
}
示例#13
0
  bool BoundingBox::CollidesWith (
    const ICollidable& other,
    const Vector2& offset) const
  {
    if (GetZ () >= other.GetZ () + other.GetH () ||
        GetZ () + GetH () <= other.GetZ ())
      return false;

    FloatRect rect (
      spatial3Info_.GetRectangle ().left + offset.x,
      spatial3Info_.GetRectangle ().top + offset.y,
      spatial3Info_.GetRectangle ().width,
      spatial3Info_.GetRectangle ().height);

    return rect.intersects (other.GetRectangle ());
  }
示例#14
0
void TilemapSubLayer::Draw() {
	if (!tilemap->GetChipset()) {
		return;
	}

	tilemap->Draw(GetZ());
}
示例#15
0
void ADXL345_SPI::UpdateTable() {
	if (m_table != NULL) {
		m_table->PutNumber("X", GetX());
		m_table->PutNumber("Y", GetY());
		m_table->PutNumber("Z", GetZ());
	}
}
示例#16
0
void IsometricSprite::Update(double elapsed, const Map* map) {
	// Llamamos al metodo padre
	Sprite::Update(elapsed, map);

	// Convertimos las coordenadas
	TransformIsoCoords(GetX(), GetY(), GetZ(), &screenX, &screenY);
}
示例#17
0
bool Mob::CheckLosFN(float posX, float posY, float posZ, float mobSize) {
	if(zone->zonemap == nullptr) {
		//not sure what the best return is on error
		//should make this a database variable, but im lazy today
#ifdef LOS_DEFAULT_CAN_SEE
		return(true);
#else
		return(false);
#endif
	}

	glm::vec3 myloc;
	glm::vec3 oloc;

#define LOS_DEFAULT_HEIGHT 6.0f

	myloc.x = GetX();
	myloc.y = GetY();
	myloc.z = GetZ() + (GetSize()==0.0?LOS_DEFAULT_HEIGHT:GetSize())/2 * HEAD_POSITION;

	oloc.x = posX;
	oloc.y = posY;
	oloc.z = posZ + (mobSize==0.0?LOS_DEFAULT_HEIGHT:mobSize)/2 * SEE_POSITION;

#if LOSDEBUG>=5
	Log.Out(Logs::General, Logs::None, "LOS from (%.2f, %.2f, %.2f) to (%.2f, %.2f, %.2f) sizes: (%.2f, %.2f)", myloc.x, myloc.y, myloc.z, oloc.x, oloc.y, oloc.z, GetSize(), mobSize);
#endif
	return zone->zonemap->CheckLoS(myloc, oloc);
}
void BuiltInAccelerometer::UpdateTable() {
  if (m_table != nullptr) {
    m_table->PutNumber("X", GetX());
    m_table->PutNumber("Y", GetY());
    m_table->PutNumber("Z", GetZ());
  }
}
示例#19
0
void Matrix::TranslateLocal (float x, float y, float z)
{
	Vector vTranslation = GetX() * x + GetY() * y + GetZ() * z;
	fMatrix[12] += vTranslation[0];
	fMatrix[13] += vTranslation[1];
	fMatrix[14] += vTranslation[2];
}
示例#20
0
template <typename T> U32 TVector4<T>::GetBGRAU32( void ) const
{	U32 r = U32(GetX()*T(255.0f));
	U32 g = U32(GetY()*T(255.0f));
	U32 b = U32(GetZ()*T(255.0f));
	U32 a = U32(GetW()*T(255.0f));
	
	return U32( (b<<24)|(g<<16)|(r<<8)|a );
}
示例#21
0
NaGeVector3D NaGeVector3D::operator * (const double &scalar)
{
	NaGeVector3D result;
	result.SetX(GetX()*scalar);
	result.SetY(GetY()*scalar);
	result.SetZ(GetZ()*scalar);
	return result;
}
示例#22
0
NaGeVector3D NaGeVector3D::operator - (const NaGeVector3D &V1)
{
	NaGeVector3D result;
	result.SetX(GetX()-V1.GetX());
	result.SetY(GetY()-V1.GetY());
	result.SetZ(GetZ()-V1.GetZ());
	return result;
}
示例#23
0
void Doors::CreateDatabaseEntry()
{
	if(database.GetDoorsDBCountPlusOne(zone->GetShortName(), zone->GetInstanceVersion()) - 1 >= 255)
	{
		return;
	}
	database.InsertDoor(GetDoorDBID(), GetDoorID(), GetDoorName(), GetX(), GetY(), GetZ(), GetHeading(), GetOpenType(), GetGuildID(), GetLockpick(), GetKeyItem(), GetDoorParam(), GetInvertState(), GetIncline(), GetSize());
}
示例#24
0
Double_t KVRecombination::Invert(Double_t energy){
   	//Given the PHD (in MeV) of a particle of charge Z and mass A
   	//(set using SetZandA() method), this method inverts the Parlog formula
   	//in order to find the energy loss of the particle in the detector.

   	const_cast<KVRecombination*>(this)->GetParlogPHDFunction(GetZ(),GetA());
	Double_t xmin, xmax; fParlog->GetRange(xmin,xmax);
   	return fParlog->GetX(energy,xmin,xmax);
}
示例#25
0
void ImmediateContext::SetNormal(Vec4f normal)
{
	Vec3 &p = *reinterpret_cast<Vec3 *>(mVertexBufferPointer);
	p.x = GetX(normal);
	p.y = GetY(normal);
	p.z = GetZ(normal);
	mVertexBufferPointer += sizeof(Vec3);
	assert(mVertexBufferPointer < mVertexBufferEnd);
}
示例#26
0
template <typename T> U16 TVector4<T>::GetRGBU16( void ) const 
{
	U32 r = U32(GetX() * T(31.0f));
	U32 g = U32(GetY() * T(31.0f));
	U32 b = U32(GetZ() * T(31.0f));
								
	U16 rval = U16((b<<10)|(g<<5)|r);

	return rval;
}
示例#27
0
void Engine::Mesh::Update()
{
	if (Engine::UserInput::IsKeyPressed(VK_LEFT))
	{
		SetX(GetX() - 0.1f);
	}
	if (Engine::UserInput::IsKeyPressed(VK_RIGHT))
	{
		SetX(GetX() + 0.1f);
	}
	if (Engine::UserInput::IsKeyPressed(VK_UP))
	{
		SetZ(GetZ() + 0.1f);
	}
	if (Engine::UserInput::IsKeyPressed(VK_DOWN))
	{
		SetZ(GetZ() - 0.1f);
	}
}
示例#28
0
Double_t KVPulseHeightDefect::Invert(Double_t energy)
{
   //Given the PHD (in MeV) of a particle of charge Z
   //(set using SetZ() method), this method inverts the Moulton formula
   //in order to find the energy loss of the particle in the detector.

   const_cast<KVPulseHeightDefect*>(this)->GetMoultonPHDFunction(GetZ());
	Double_t xmin, xmax; fMoulton->GetRange(xmin,xmax);
   return fMoulton->GetX(energy,xmin,xmax);
}
示例#29
0
Var* ff_radial_symmetry2(vfuncptr func, Var* arg)
{
	Var *obj = NULL, *rval = NULL;
	float ignore = FLT_MIN;
	float* out;
	int x, y, z, i, j;
	int size  = 0;
	int width = 0, height = 0;
	Window* w;

	Alist alist[9];
	alist[0]      = make_alist("object", ID_VAL, NULL, &obj);
	alist[1]      = make_alist("x", DV_INT32, NULL, &width);
	alist[2]      = make_alist("y", DV_INT32, NULL, &height);
	alist[3]      = make_alist("size", DV_INT32, NULL, &size);
	alist[4]      = make_alist("ignore", DV_FLOAT, NULL, &ignore);
	alist[5].name = NULL;

	if (parse_args(func, arg, alist) == 0) return (NULL);

	if (obj == NULL) {
		parse_error("%s: No object specified\n", func->name);
		return (NULL);
	}

	if (size) {
		width  = size;
		height = size;
	}

	if (width <= 0 || height <= 0) {
		parse_error("%s: Invalid size specified (%dx%d)\n", func->name, width, height);
		return (NULL);
	}

	x = GetX(obj);
	y = GetY(obj);
	z = GetZ(obj);
	w = create_window(width, height, DV_FLOAT);

	out  = calloc((size_t)x * (size_t)y, sizeof(float));
	rval = newVal(BSQ, x, y, 1, DV_FLOAT, out);

	for (i = 0; i < x; i += 1) {
		load_window(w, obj, i, 0, ignore);
		for (j = 0; j < y; j += 1) {
			if (j) roll_window(w, obj, i, j, ignore);

			out[cpos(i, j, 0, rval)] = radial_symmetry2(w->row, width, height, ignore);
		}
	}

	free_window(w);
	return (rval);
}
示例#30
0
void User::UpdatePos(double dx, double dy)
{
	glLoadIdentity();
	
	//rotates and moves the camera
	glRotatef(dy, 1, 0, 0);
	glRotatef(dx, 0, 1, 0);
	glRotatef(180 - terrainAngle*180/M_PI, 0, 1, 0);
	
	glTranslatef(-GetX(), -GetY(), -GetZ());
}