Fixes Fleeing, and probably so other movement stuff.
This commit is contained in:
@@ -2214,8 +2214,8 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public Position GetFirstCollisionPosition(float dist, float angle)
|
public Position GetFirstCollisionPosition(float dist, float angle)
|
||||||
{
|
{
|
||||||
var pos = GetPosition();
|
var pos = new Position(GetPosition());
|
||||||
MovePositionToFirstCollision(ref pos, dist, angle);
|
MovePositionToFirstCollision(pos, dist, angle);
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2276,7 +2276,7 @@ namespace Game.Entities
|
|||||||
pos.SetOrientation(GetOrientation());
|
pos.SetOrientation(GetOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MovePositionToFirstCollision(ref Position pos, float dist, float angle)
|
public void MovePositionToFirstCollision(Position pos, float dist, float angle)
|
||||||
{
|
{
|
||||||
angle += GetOrientation();
|
angle += GetOrientation();
|
||||||
float destx = pos.posX + dist * (float)Math.Cos(angle);
|
float destx = pos.posX + dist * (float)Math.Cos(angle);
|
||||||
|
|||||||
@@ -67,10 +67,10 @@ namespace Game.Movement
|
|||||||
// start moving
|
// start moving
|
||||||
owner.AddUnitState(UnitState.ConfusedMove);
|
owner.AddUnitState(UnitState.ConfusedMove);
|
||||||
|
|
||||||
Position destination = _reference;
|
Position destination = new(_reference);
|
||||||
float distance = (float)(4.0f * RandomHelper.FRand(0.0f, 1.0f) - 2.0f);
|
float distance = (float)(4.0f * RandomHelper.FRand(0.0f, 1.0f) - 2.0f);
|
||||||
float angle = RandomHelper.FRand(0.0f, 1.0f) * MathF.PI * 2.0f;
|
float angle = RandomHelper.FRand(0.0f, 1.0f) * MathF.PI * 2.0f;
|
||||||
owner.MovePositionToFirstCollision(ref destination, distance, angle);
|
owner.MovePositionToFirstCollision(destination, distance, angle);
|
||||||
|
|
||||||
if (_path == null)
|
if (_path == null)
|
||||||
_path = new PathGenerator(owner);
|
_path = new PathGenerator(owner);
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ namespace Game.Movement
|
|||||||
|
|
||||||
owner.AddUnitState(UnitState.FleeingMove);
|
owner.AddUnitState(UnitState.FleeingMove);
|
||||||
|
|
||||||
Position destination = owner.GetPosition();
|
Position destination = new Position(owner.GetPosition());
|
||||||
GetPoint(owner, ref destination);
|
GetPoint(owner, destination);
|
||||||
|
|
||||||
// Add LOS check for target point
|
// Add LOS check for target point
|
||||||
if (!owner.IsWithinLOS(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ()))
|
if (!owner.IsWithinLOS(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ()))
|
||||||
@@ -127,7 +127,7 @@ namespace Game.Movement
|
|||||||
_timer.Reset(traveltime + RandomHelper.URand(800, 1500));
|
_timer.Reset(traveltime + RandomHelper.URand(800, 1500));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetPoint(T owner, ref Position position)
|
void GetPoint(T owner, Position position)
|
||||||
{
|
{
|
||||||
float casterDistance, casterAngle;
|
float casterDistance, casterAngle;
|
||||||
Unit fleeTarget = Global.ObjAccessor.GetUnit(owner, _fleeTargetGUID);
|
Unit fleeTarget = Global.ObjAccessor.GetUnit(owner, _fleeTargetGUID);
|
||||||
@@ -162,7 +162,7 @@ namespace Game.Movement
|
|||||||
angle = RandomHelper.FRand(0.0f, 2.0f * MathF.PI);
|
angle = RandomHelper.FRand(0.0f, 2.0f * MathF.PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.MovePositionToFirstCollision(ref position, distance, angle);
|
owner.MovePositionToFirstCollision(position, distance, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override MovementGeneratorType GetMovementGeneratorType()
|
public override MovementGeneratorType GetMovementGeneratorType()
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace Game.Movement
|
|||||||
Position position = new(_reference);
|
Position position = new(_reference);
|
||||||
float distance = RandomHelper.FRand(0.0f, 1.0f) * _wanderDistance;
|
float distance = RandomHelper.FRand(0.0f, 1.0f) * _wanderDistance;
|
||||||
float angle = RandomHelper.FRand(0.0f, 1.0f) * MathF.PI * 2.0f;
|
float angle = RandomHelper.FRand(0.0f, 1.0f) * MathF.PI * 2.0f;
|
||||||
owner.MovePositionToFirstCollision(ref position, distance, angle);
|
owner.MovePositionToFirstCollision(position, distance, angle);
|
||||||
|
|
||||||
uint resetTimer = RandomHelper.randChance(50) ? RandomHelper.URand(5000, 10000) : RandomHelper.URand(1000, 2000);
|
uint resetTimer = RandomHelper.randChance(50) ? RandomHelper.URand(5000, 10000) : RandomHelper.URand(1000, 2000);
|
||||||
|
|
||||||
|
|||||||
@@ -929,8 +929,8 @@ namespace Game.Spells
|
|||||||
if (dist < objSize)
|
if (dist < objSize)
|
||||||
dist = objSize;
|
dist = objSize;
|
||||||
|
|
||||||
Position pos = dest.Position;
|
Position pos = new(dest.Position);
|
||||||
m_caster.MovePositionToFirstCollision(ref pos, dist, angl);
|
m_caster.MovePositionToFirstCollision(pos, dist, angl);
|
||||||
|
|
||||||
dest.Relocate(pos);
|
dest.Relocate(pos);
|
||||||
}
|
}
|
||||||
@@ -961,8 +961,8 @@ namespace Game.Spells
|
|||||||
if (targetType.GetTarget() == Targets.DestRandom)
|
if (targetType.GetTarget() == Targets.DestRandom)
|
||||||
dist *= (float)RandomHelper.NextDouble();
|
dist *= (float)RandomHelper.NextDouble();
|
||||||
|
|
||||||
Position pos = dest.Position;
|
Position pos = new(dest.Position);
|
||||||
target.MovePositionToFirstCollision(ref pos, dist, angle);
|
target.MovePositionToFirstCollision(pos, dist, angle);
|
||||||
|
|
||||||
dest.Relocate(pos);
|
dest.Relocate(pos);
|
||||||
}
|
}
|
||||||
@@ -999,8 +999,8 @@ namespace Game.Spells
|
|||||||
if (targetType.GetTarget() == Targets.DestRandom)
|
if (targetType.GetTarget() == Targets.DestRandom)
|
||||||
dist *= (float)RandomHelper.NextDouble();
|
dist *= (float)RandomHelper.NextDouble();
|
||||||
|
|
||||||
Position pos = m_targets.GetDstPos();
|
Position pos = new(m_targets.GetDstPos());
|
||||||
m_caster.MovePositionToFirstCollision(ref pos, dist, angle);
|
m_caster.MovePositionToFirstCollision(pos, dist, angle);
|
||||||
|
|
||||||
dest.Relocate(pos);
|
dest.Relocate(pos);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user