/// <summary> /// Process the monster's fight. /// </summary> /// <param name="monster"></param> private void ProcessMonsterFight(IMonsterEntity monster) { if (monster.Battle.Target.IsDead) { monster.Follow.Reset(); monster.Battle.Reset(); return; } if (monster.Follow.IsFollowing) { if (monster.Moves.SpeedFactor != 2f) { monster.Moves.SpeedFactor = 2; _moverPacketFactory.SendSpeedFactor(monster, monster.Moves.SpeedFactor); } if (monster.Object.Position.IsInCircle(monster.Follow.Target.Object.Position, monster.Follow.FollowDistance)) { if (monster.Timers.NextAttackTime <= Time.TimeInMilliseconds()) { _battleSystem.MeleeAttack(monster, monster.Battle.Target, ObjectMessageType.OBJMSG_ATK1, monster.Data.AttackSpeed); monster.Timers.NextAttackTime = (long)(Time.TimeInMilliseconds() + monster.Data.ReAttackDelay); } } else { _followSystem.Follow(monster, monster.Battle.Target); } } else { _followSystem.Follow(monster, monster.Battle.Target); } }
/// <inheritdoc /> public void Execute(IPlayerEntity player, object[] parameters) { ObjectMessageType defaultAttackType = ObjectMessageType.OBJMSG_ATK1; float defaultAttackSpeed = 1.0f; for (int i = 0; i < player.Object.Entities.Count; i++) { if (player.Object.Entities[i] is IMonsterEntity monsterEntity) { if (!monsterEntity.Follow.IsFollowing) { _followSystem.Follow(monsterEntity, player); } _battleSystem.MeleeAttack(player, monsterEntity, defaultAttackType, defaultAttackSpeed); } } }
public void OnPlayerSetDestObject(IWorldClient client, PlayerDestObjectPacket packet) { _followSystem.Follow(client.Player, packet.TargetObjectId, packet.Distance); }