Browse Source

IsFlying command for Spawn to track if the mob should defy normal floor sticking

Image 4 years ago
parent
commit
3694cd44a7

+ 1 - 1
EQ2/source/WorldServer/NPC.cpp

@@ -191,7 +191,7 @@ void NPC::Runback(){
 	m_runningBack = true;
 	SetSpeed(GetMaxSpeed()*2);
 
-	if (GetInitialState() == 49156 && CheckLoS(glm::vec3(runback->x, runback->z, runback->y + 1.0f), glm::vec3(GetX(), GetZ(), GetY() + 1.0f)))
+	if (IsFlying() && CheckLoS(glm::vec3(runback->x, runback->z, runback->y + 1.0f), glm::vec3(GetX(), GetZ(), GetY() + 1.0f)))
 	{
 		FaceTarget(runback->x, runback->z);
 		ClearRunningLocations();

+ 4 - 4
EQ2/source/WorldServer/Spawn.cpp

@@ -2055,7 +2055,7 @@ void Spawn::MoveToLocation(Spawn* spawn, float distance, bool immediate, bool ma
 
 	if (!IsPlayer() && distance > 0.0f)
 	{
-		if (GetInitialState() == 49156 && CheckLoS(spawn))
+		if (IsFlying() && CheckLoS(spawn))
 		{
 			if (immediate)
 				ClearRunningLocations();
@@ -2504,7 +2504,7 @@ bool Spawn::CalculateChange(){
 				}
 
 				int32 newGrid = GetZone()->Grid->GetGridID(this);
-				if (GetInitialState() != 49156 && newGrid != 0 && newGrid != appearance.pos.grid_id)
+				if (IsFlying() && newGrid != 0 && newGrid != appearance.pos.grid_id)
 					SetPos(&(appearance.pos.grid_id), newGrid);
 			}
 		}
@@ -2543,7 +2543,7 @@ void Spawn::CalculateRunningLocation(bool stop){
 	{
 		if (GetDistance(GetTarget()) > rule_manager.GetGlobalRule(R_Combat, MaxCombatRange)->GetFloat())
 		{
-			if (GetInitialState() == 49156 && CheckLoS(GetTarget()))
+			if (IsFlying() && CheckLoS(GetTarget()))
 				AddRunningLocation(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetSpeed(), 0, false);
 			else
 				GetZone()->movementMgr->NavigateTo((Entity*)this, GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ());
@@ -2999,7 +2999,7 @@ float Spawn::GetFixedZ(const glm::vec3& destination, int32 z_find_offset) {
 
 
 void Spawn::FixZ(bool forceUpdate) {
-	if (IsPlayer() || (this->GetInitialState() == 49156)) {
+	if (IsPlayer() || IsFlying()) {
 		return;
 	}
 	/*

+ 2 - 0
EQ2/source/WorldServer/Spawn.h

@@ -740,6 +740,8 @@ public:
 	int16 GetModelType(){
 		return appearance.model_type;
 	}
+	
+	bool IsFlying() { return (GetInitialState() == 49156); }
 	void SetPrimaryCommand(const char* name, const char* command, float distance = 10);
 	void SetPrimaryCommands(vector<EntityCommand*>* commands);
 	void SetSecondaryCommands(vector<EntityCommand*>* commands);