Exemplo n.º 1
0
    public static void encounter_create(RandomEncounter encounter)
    {
        Logger.Info("Testing encounter_create with id={0}", encounter.Id);
        var is_sleep_encounter = false;

        LocAndOffsets location;

        if ((encounter.Id >= 4000))
        {
            location           = SelectedPartyLeader.GetLocationFull();
            is_sleep_encounter = true;
        }
        else
        {
            location = new LocAndOffsets(encounter.Location);
        }

        var i = 0;

        var total = encounter.Enemies.Count;

        while ((i < total))
        {
            var j = 0;

            while ((j < encounter.Enemies[i].Count))
            {
                if (is_sleep_encounter)
                {
                    var party = new List <GameObject>();

                    foreach (var pc in GameSystems.Party.PartyMembers)
                    {
                        if (!pc.IsUnconscious())
                        {
                            party.Add(pc);
                        }
                    }

                    if (party.Count > 0)
                    {
                        location = party[i % party.Count].GetLocationFull();
                    }
                }

                var npc = GameSystems.MapObject.CreateObject(encounter.Enemies[i].ProtoId, location);

                if ((npc != null))
                {
                    npc.TurnTowards(SelectedPartyLeader);
                    if (((encounter.Id < 2000) || (encounter.Id >= 4000)))
                    {
                        npc.Attack(SelectedPartyLeader);
                        npc.SetNpcFlag(NpcFlag.KOS);
                    }
                }

                j = j + 1;
            }

            i = i + 1;
        }

        return;
    }