Exemplo n.º 1
0
    public bool MonsterDead(int[] spawnPointIds, bool arg2)
    {
        // TODO: Needs a better check for multiple mob spawns
        foreach (int spawnPointId in spawnPointIds)
        {
            MapEventNpcSpawnPoint spawnPoint = MapEntityMetadataStorage.GetMapEventNpcSpawnPoint(Field.MapId, spawnPointId);
            if (spawnPoint == null)
            {
                continue;
            }

            foreach (string npcId in spawnPoint.NpcIds)
            {
                if (!int.TryParse(npcId, out int id))
                {
                    continue;
                }

                if (Field.State.Mobs.Values.Any(x => x.Value.Id == id && !x.IsDead))
                {
                    return(false);
                }
            }
        }

        return(true);
    }
Exemplo n.º 2
0
    public void CreateMonster(int[] spawnPointIds, bool spawnAnimation, int arg3)
    {
        foreach (int spawnPointId in spawnPointIds)
        {
            MapEventNpcSpawnPoint spawnPoint = MapEntityMetadataStorage.GetMapEventNpcSpawnPoint(Field.MapId, spawnPointId);
            if (spawnPoint is null)
            {
                continue;
            }

            for (int i = 0; i < spawnPoint.Count; i++)
            {
                foreach (string npcId in spawnPoint.NpcIds)
                {
                    if (!int.TryParse(npcId, out int id))
                    {
                        continue;
                    }

                    short animation = -1;
                    if (spawnAnimation)
                    {
                        NpcMetadata npcMetadata = NpcMetadataStorage.GetNpcMetadata(id);
                        if (npcMetadata is null || !npcMetadata.StateActions.TryGetValue(NpcState.Normal, out (string, NpcAction, short)[] stateAction))
                        {
                            continue;
                        }

                        if (stateAction.Length == 0)
                        {
                            continue;
                        }

                        animation = AnimationStorage.GetSequenceIdBySequenceName(npcMetadata.NpcMetadataModel.Model, stateAction[0].Item1);
                    }

                    Npc npc = Field.RequestNpc(id, spawnPoint.Position, spawnPoint.Rotation, animation);
                    npc.SpawnPointId = spawnPointId;
                }
            }
        }
    }
Exemplo n.º 3
0
    public void SpawnNpcRange(int[] rangeId, bool isAutoTargeting, byte randomPickCount, int score)
    {
        foreach (int spawnPointId in rangeId)
        {
            MapEventNpcSpawnPoint spawnPoint = MapEntityMetadataStorage.GetMapEventNpcSpawnPoint(Field.MapId, spawnPointId);
            if (spawnPoint == null)
            {
                continue;
            }

            foreach (string npcId in spawnPoint.NpcIds)
            {
                if (!int.TryParse(npcId, out int id))
                {
                    continue;
                }

                Npc npc = Field.RequestNpc(id, spawnPoint.Position, spawnPoint.Rotation);
                npc.SpawnPointId = spawnPointId;
            }
        }
    }
Exemplo n.º 4
0
    public void FaceEmotion(int spawnPointId, string emotionName)
    {
        if (spawnPointId == 0)
        {
            IFieldActor <Player> firstPlayer = Field.State.Players.FirstOrDefault().Value;
            Field.BroadcastPacket(TriggerPacket.SetFaceEmotion(firstPlayer.ObjectId, emotionName));
            return;
        }

        MapEventNpcSpawnPoint spawnPoint = MapEntityMetadataStorage.GetMapEventNpcSpawnPoint(Field.MapId, spawnPointId);

        if (spawnPoint is null)
        {
            return;
        }

        foreach (string npcId in spawnPoint.NpcIds)
        {
            if (!int.TryParse(npcId, out int id))
            {
                continue;
            }

            if (Field.State.Npcs.TryGetValue(id, out Npc npc))
            {
                Field.BroadcastPacket(TriggerPacket.SetFaceEmotion(npc.ObjectId, emotionName));
                return;
            }

            if (Field.State.Mobs.TryGetValue(id, out Npc mob))
            {
                Field.BroadcastPacket(TriggerPacket.SetFaceEmotion(mob.ObjectId, emotionName));
                return;
            }
        }
    }