public override string GetDescription() { var description = $"{ActorType.Name}({ActorId}) moved " + $"{Enum.GetName(Direction.GetType(), Direction)} {Distance} tiles " + $"using {Enum.GetName(MoveType.GetType(), MoveType)}."; return(description); }
/// <summary> /// 正方形巡航 / Square Cruise /// </summary> /// <param name="caster">触发角色 / Trigger role</param> /// <param name="npc">NPC</param> /// <param name="degree">角度 默认360度 / Default angle 360 degrees</param> public override void Execute(Npc npc) { if (Count < Degree / 2) { npc.Position.X += (float)0.1; } else if (Count < Degree) { npc.Position.X -= (float)0.1; } if (Count < Degree / 4 || (Count > (Degree / 4 + Degree / 2) && Count < Degree)) { npc.Position.Y += (float)0.1; } else if (Count < (Degree / 4 + Degree / 2)) { npc.Position.Y -= (float)0.1; } //模拟unit / Simulated unit var type = (MoveTypeEnum)1; //返回moveType对象 var moveType = (UnitMoveType)MoveType.GetType(type); //改变NPC坐标 / Return moveType object moveType.X = npc.Position.X; moveType.Y = npc.Position.Y; moveType.Z = npc.Position.Z; moveType.Flags = 5; moveType.VelZ = VelZ; moveType.DeltaMovement = new sbyte[3]; moveType.DeltaMovement[0] = 0; moveType.DeltaMovement[1] = 127; moveType.DeltaMovement[2] = 0; moveType.Stance = 0; moveType.Alertness = 2; moveType.Time = Seq; npc.BroadcastPacket(new SCOneUnitMovementPacket(npc.ObjId, moveType), true); if (Count < Degree) { Repet(npc); } else { moveType.DeltaMovement[1] = 0; npc.BroadcastPacket(new SCOneUnitMovementPacket(npc.ObjId, moveType), true); LoopAuto(npc); } }
public override void Read(PacketStream stream) { var objId = stream.ReadBc(); var myObjId = Connection.ActiveChar.ObjId; var type = (MoveTypeEnum)stream.ReadByte(); var moveType = MoveType.GetType(type); stream.Read(moveType); if (objId != myObjId) // Can be mate { var mateInfo = MateManager.Instance.GetActiveMateByMateObjId(objId); if (mateInfo == null) { return; } RemoveEffects(mateInfo, moveType); mateInfo.SetPosition(moveType.X, moveType.Y, moveType.Z, moveType.RotationX, moveType.RotationY, moveType.RotationZ); mateInfo.BroadcastPacket(new SCOneUnitMovementPacket(objId, moveType), myObjId); if (mateInfo.Att1 > 0) { var owner = WorldManager.Instance.GetCharacterByObjId(mateInfo.Att1); if (owner != null) { RemoveEffects(owner, moveType); owner.SetPosition(moveType.X, moveType.Y, moveType.Z, moveType.RotationX, moveType.RotationY, moveType.RotationZ); owner.BroadcastPacket(new SCOneUnitMovementPacket(owner.ObjId, moveType), false); } } if (mateInfo.Att2 > 0) { var passenger = WorldManager.Instance.GetCharacterByObjId(mateInfo.Att2); if (passenger != null) { RemoveEffects(passenger, moveType); passenger.SetPosition(moveType.X, moveType.Y, moveType.Z, moveType.RotationX, moveType.RotationY, moveType.RotationZ); passenger.BroadcastPacket(new SCOneUnitMovementPacket(passenger.ObjId, moveType), false); } } } else { RemoveEffects(Connection.ActiveChar, moveType); Connection .ActiveChar .SetPosition(moveType.X, moveType.Y, moveType.Z, moveType.RotationX, moveType.RotationY, moveType.RotationZ); Connection.ActiveChar.BroadcastPacket(new SCOneUnitMovementPacket(objId, moveType), false); } }
public override void Execute(Npc npc) { //debug by Yanlongli date 2019.04.18 //将自己的移动赋予选择的对象 跟随自己一起移动 / Give your own movement to the selected object, move with yourself //模拟unit / Simulated unit var type = (MoveTypeEnum)1; //返回moveType对象 var moveType = (UnitMoveType)MoveType.GetType(type); if (npc.Position.RotationX < 127) { npc.Position.RotationZ += 1; } else { npc.Position.RotationX = 0; } //改变NPC坐标 / Changing NPC coordinates moveType.Z = npc.Position.Z; moveType.RotationZ = npc.Position.RotationZ; moveType.Flags = 5; moveType.DeltaMovement = new sbyte[3]; moveType.DeltaMovement[0] = 0; moveType.DeltaMovement[1] = 127; moveType.DeltaMovement[2] = 0; moveType.Stance = 0; moveType.Alertness = 2; moveType.Time = Seq; //圆形巡航 / Round cruising var hudu = 4 * Math.PI / 360 * Count; moveType.X = npc.Position.X = npc.Spawner.Position.X + (float)Math.Sin(hudu) * Radius; moveType.Y = npc.Position.Y = npc.Spawner.Position.Y + Radius - (float)Math.Cos(hudu) * Radius; //广播移动状态 / Broadcasting Mobile State npc.BroadcastPacket(new SCOneUnitMovementPacket(npc.ObjId, moveType), true); ///如果执行次数小于角度则继续添加任务 否则停止移动 / If the number of executions is less than the angle, continue adding tasks or stop moving if (Count < Degree) { Repet(npc); } else { //停止移动 / Stop moving moveType.DeltaMovement[1] = 0; npc.BroadcastPacket(new SCOneUnitMovementPacket(npc.ObjId, moveType), true); LoopAuto(npc); } }
public override void Read(PacketStream stream) { var bc = stream.ReadBc(); if (bc != Connection.ActiveChar.ObjId) { return; } var type = (MoveTypeEnum)stream.ReadByte(); var moveType = MoveType.GetType(type); stream.Read(moveType); Connection .ActiveChar .SetPosition(moveType.X, moveType.Y, moveType.Z, moveType.RotationX, moveType.RotationY, moveType.RotationZ); Connection.ActiveChar.BroadcastPacket(new SCOneUnitMovementPacket(bc, moveType), false); }
public override void Read(PacketStream stream) { var bc = stream.ReadBc(); if (bc != Connection.ActiveChar.ObjId) { return; } var type = (MoveTypeEnum)stream.ReadByte(); var moveType = MoveType.GetType(type); stream.Read(moveType); if (moveType.VelX != 0 || moveType.VelY != 0 || moveType.VelZ != 0) { var effects = Connection.ActiveChar.Effects.GetEffectsByType(typeof(BuffTemplate)); foreach (var effect in effects) { if (((BuffTemplate)effect.Template).RemoveOnMove) { effect.Exit(); } } effects = Connection.ActiveChar.Effects.GetEffectsByType(typeof(BuffEffect)); foreach (var effect in effects) { if (((BuffEffect)effect.Template).Buff.RemoveOnMove) { effect.Exit(); } } } Connection .ActiveChar .SetPosition(moveType.X, moveType.Y, moveType.Z, moveType.RotationX, moveType.RotationY, moveType.RotationZ); Connection.ActiveChar.BroadcastPacket(new SCOneUnitMovementPacket(bc, moveType), false); }
public override void Execute(Npc npc) { if (Position == null) { Stop(npc); return; } bool move = false; float x = npc.Position.X - Position.X; float y = npc.Position.Y - Position.Y; float z = npc.Position.Z - Position.Z; float MaxXYZ = Math.Max(Math.Max(Math.Abs(x), Math.Abs(y)), Math.Abs(z)); float tempMovingDistance; if (Math.Abs(x) > distance) { if (MaxXYZ != Math.Abs(x)) { tempMovingDistance = Math.Abs(x) / (MaxXYZ / MovingDistance); tempMovingDistance = Math.Min(tempMovingDistance, MovingDistance); } else { tempMovingDistance = MovingDistance; } if (x < 0) { npc.Position.X += tempMovingDistance; } else { npc.Position.X -= tempMovingDistance; } if (Math.Abs(x) < tempMovingDistance) { npc.Position.X = Position.X; } move = true; } if (Math.Abs(y) > distance) { if (MaxXYZ != Math.Abs(y)) { tempMovingDistance = Math.Abs(y) / (MaxXYZ / MovingDistance); tempMovingDistance = Math.Min(tempMovingDistance, MovingDistance); } else { tempMovingDistance = MovingDistance; } if (y < 0) { npc.Position.Y += tempMovingDistance; } else { npc.Position.Y -= tempMovingDistance; } if (Math.Abs(y) < tempMovingDistance) { npc.Position.Y = Position.Y; } move = true; } if (Math.Abs(z) > distance) { if (MaxXYZ != Math.Abs(z)) { tempMovingDistance = Math.Abs(z) / (MaxXYZ / MovingDistance); tempMovingDistance = Math.Min(tempMovingDistance, MovingDistance); } else { tempMovingDistance = MovingDistance; } if (z < 0) { npc.Position.Z += tempMovingDistance; } else { npc.Position.Z -= tempMovingDistance; } if (Math.Abs(z) < tempMovingDistance) { npc.Position.Z = Position.Z; } move = true; } //模拟unit / Simulated unit var type = (MoveTypeEnum)1; //返回moveType对象 / Return moveType object var moveType = (UnitMoveType)MoveType.GetType(type); //改变NPC坐标 / Changing NPC coordinates moveType.X = npc.Position.X; moveType.Y = npc.Position.Y; moveType.Z = npc.Position.Z; moveType.Flags = 5; moveType.DeltaMovement = new sbyte[3]; moveType.DeltaMovement[0] = 0; moveType.DeltaMovement[1] = 127; moveType.DeltaMovement[2] = 0; moveType.Stance = 0; moveType.Alertness = 2; moveType.Time = Seq; if (move) { //广播移动状态 / Broadcasting Mobile State npc.BroadcastPacket(new SCOneUnitMovementPacket(npc.ObjId, moveType), true); LoopDelay = 500; Repet(npc); } else { //停止移动 / Stop moving moveType.DeltaMovement[1] = 0; npc.BroadcastPacket(new SCOneUnitMovementPacket(npc.ObjId, moveType), true); LoopAuto(npc); } }
public override void Execute(Npc npc) { Interrupt = false; bool move = false; float x = npc.Position.X - npc.CurrentTarget.Position.X; float y = npc.Position.Y - npc.CurrentTarget.Position.Y; float z = npc.Position.Z - npc.CurrentTarget.Position.Z; float MaxXYZ = Math.Max(Math.Max(Math.Abs(x), Math.Abs(y)), Math.Abs(z)); float tempMovingDistance; if (Math.Abs(x) > distance) { if (MaxXYZ != Math.Abs(x)) { tempMovingDistance = Math.Abs(x) / (MaxXYZ / MovingDistance); } else { tempMovingDistance = MovingDistance; } if (x < 0) { npc.Position.X += tempMovingDistance; } else { npc.Position.X -= tempMovingDistance; } move = true; } if (Math.Abs(y) > distance) { if (MaxXYZ != Math.Abs(y)) { tempMovingDistance = Math.Abs(y) / (MaxXYZ / MovingDistance); } else { tempMovingDistance = MovingDistance; } if (y < 0) { npc.Position.Y += tempMovingDistance; } else { npc.Position.Y -= tempMovingDistance; } move = true; } if (Math.Abs(z) > distance) { if (MaxXYZ != Math.Abs(z)) { tempMovingDistance = Math.Abs(z) / (MaxXYZ / MovingDistance); } else { tempMovingDistance = MovingDistance; } if (z < 0) { npc.Position.Z += tempMovingDistance; } else { npc.Position.Z -= tempMovingDistance; } move = true; } if (Math.Max(Math.Max(Math.Abs(x), Math.Abs(y)), Math.Abs(z)) > 20) { move = false; } //模拟unit / Simulated unit var type = (MoveTypeEnum)1; //返回moveType对象 / Return moveType object var moveType = (UnitMoveType)MoveType.GetType(type); //改变NPC坐标 / Changing NPC coordinates moveType.X = npc.Position.X; moveType.Y = npc.Position.Y; moveType.Z = npc.Position.Z; moveType.Flags = 5; moveType.DeltaMovement = new sbyte[3]; moveType.DeltaMovement[0] = 0; moveType.DeltaMovement[1] = 127; moveType.DeltaMovement[2] = 0; moveType.Stance = 0; moveType.Alertness = 2; moveType.Time = Seq; if (move) { //广播移动状态 / Broadcasting Mobile State npc.BroadcastPacket(new SCOneUnitMovementPacket(npc.ObjId, moveType), true); LoopDelay = 500; Repet(npc); } else { //如果小于差距则停止移动准备攻击 / Stop moving and prepare for attack if it is less than the gap if (Math.Max(Math.Max(Math.Abs(x), Math.Abs(y)), Math.Abs(z)) <= distance) { Combat combat = new Combat(); combat.LastPatrol = LastPatrol; combat.LoopDelay = 2900; combat.Pause(npc); LastPatrol = combat; } else { npc.BroadcastPacket(new SCCombatClearedPacket(npc.CurrentTarget.ObjId), true); npc.BroadcastPacket(new SCCombatClearedPacket(npc.ObjId), true); npc.CurrentTarget = null; npc.StartRegen(); npc.BroadcastPacket(new SCTargetChangedPacket(npc.ObjId, 0), true); } //距离超过指定长度 放弃追踪 停止移动 / Abandon tracking to stop moving beyond specified length moveType.DeltaMovement[1] = 0; npc.BroadcastPacket(new SCOneUnitMovementPacket(npc.ObjId, moveType), true); Stop(npc); } if (LastPatrol == null) { //创建直线巡航回归上次巡航暂停点 / Create Linear Cruise Return to Last Cruise Stop Point Line line = new Line(); //不可中断,不受外力及攻击影响 类似于处于脱战状态 / Uninterruptible, unaffected by external forces and attacks, similar to being out of combat line.Interrupt = false; line.Loop = false; line.Abandon = false; line.Pause(npc); LastPatrol = line; } }