Пример #1
0
    public override void Execute(GameCommandTrigger trigger)
    {
        Player player = trigger.Session.Player;
        IFieldActor <Player> fieldPlayer  = player.FieldPlayer;
        FieldManager         fieldManager = trigger.Session.FieldManager;

        bool mapIsHome = player.MapId == (int)Map.PrivateResidence;

        if (!mapIsHome)
        {
            return;
        }

        Home home = GameServer.HomeManager.GetHomeById(player.VisitingHomeId);

        if (home.AccountId != player.AccountId)
        {
            return;
        }

        IFieldObject <GuideObject> ballObject = fieldManager.State.Guide.Values.FirstOrDefault(x => x.Value.IsBall);

        if (ballObject is not null)
        {
            fieldManager.RemoveGuide(ballObject);
            fieldManager.BroadcastPacket(HomeActionPacket.RemoveBall(ballObject));
            return;
        }

        int size = trigger.Get <int>("size");

        size = Math.Min(30 + size * 30, 330);
        if (size < 0)
        {
            size = 60;
        }

        GuideObject ball = new(0, player.CharacterId)
        {
            IsBall = true
        };
        IFieldObject <GuideObject> fieldObject = fieldManager.RequestFieldObject(ball);

        fieldObject.Coord    = CoordF.From(fieldPlayer.Coord.X, fieldPlayer.Coord.Y, fieldPlayer.Coord.Z + Block.BLOCK_SIZE * 2);
        fieldObject.Rotation = CoordF.From(0, 0, size);

        fieldManager.AddGuide(fieldObject);

        fieldManager.BroadcastPacket(HomeActionPacket.AddBall(fieldObject));
    }
}
 public Task BreakObject(FieldManager field)
 {
     return(Task.Run(async() =>
     {
         State = BreakableState.Break;
         field.BroadcastPacket(BreakablePacket.Interact(this));
         await Task.Delay(HideDuration);
         State = BreakableState.Despawn;
         field.BroadcastPacket(BreakablePacket.Interact(this));
         await Task.Delay(ResetDuration);
         State = BreakableState.Spawn;
         field.BroadcastPacket(BreakablePacket.Interact(this));
     }));
 }
Пример #3
0
    private static void HandleRegionDamage(FieldManager field, SkillCast skillCast)
    {
        if (!field.State.Players.TryGetValue(skillCast.CasterObjectId, out Character caster))
        {
            // Handle NPCs/Triggers sending skills
            return;
        }

        List <DamageHandler> damages = new();

        foreach (IFieldActor <NpcMetadata> mob in field.State.Mobs.Values)
        {
            foreach (CoordF effectCoord in skillCast.EffectCoords)
            {
                if ((mob.Coord - effectCoord).Length() > skillCast.SkillAttack.RangeProperty.Distance)
                {
                    continue;
                }

                DamageHandler damage = DamageHandler.CalculateDamage(skillCast, caster, mob);
                mob.Damage(damage, caster.Value.Session);

                damages.Add(damage);
            }
        }

        if (damages.Count <= 0)
        {
            return;
        }

        field.BroadcastPacket(SkillDamagePacket.RegionDamage(skillCast, damages));
    }
Пример #4
0
 private static void VibrateObjects(FieldManager field, SkillCast skillCast)
 {
     foreach ((string objectId, MapVibrateObject metadata) in field.State.VibrateObjects)
     {
         foreach (CoordF effectCoord in skillCast.EffectCoords)
         {
             if ((metadata.Position - effectCoord).Length() > skillCast.SkillAttack.RangeProperty.Distance)
             {
                 continue;
             }
             field.BroadcastPacket(VibratePacket.Vibrate(objectId, skillCast));
         }
     }
 }