Exemplo n.º 1
0
        public virtual bool SetBossState(uint id, EncounterState state)
        {
            if (id < bosses.Count)
            {
                BossInfo bossInfo = bosses[id];
                if (bossInfo.state == EncounterState.ToBeDecided) // loading
                {
                    bossInfo.state = state;
                    Log.outDebug(LogFilter.Scripts, $"InstanceScript: Initialize boss {id} state as {state} (map {instance.GetId()}, {instance.GetInstanceId()}).");
                    return(false);
                }
                else
                {
                    if (bossInfo.state == state)
                    {
                        return(false);
                    }

                    if (bossInfo.state == EncounterState.Done)
                    {
                        Log.outError(LogFilter.Maps, $"InstanceScript: Tried to set instance boss {id} state from {bossInfo.state} back to {state} for map {instance.GetId()}, instance id {instance.GetInstanceId()}. Blocked!");
                        return(false);
                    }

                    if (state == EncounterState.Done)
                    {
                        foreach (var guid in bossInfo.minion)
                        {
                            Creature minion = instance.GetCreature(guid);
                            if (minion)
                            {
                                if (minion.IsWorldBoss() && minion.IsAlive())
                                {
                                    return(false);
                                }
                            }
                        }
                    }

                    switch (state)
                    {
                    case EncounterState.InProgress:
                    {
                        uint resInterval = GetCombatResurrectionChargeInterval();
                        InitializeCombatResurrections(1, resInterval);
                        SendEncounterStart(1, 9, resInterval, resInterval);

                        var playerList = instance.GetPlayers();
                        foreach (var player in playerList)
                        {
                            if (player.IsAlive())
                            {
                                Unit.ProcSkillsAndAuras(player, null, ProcFlags.EncounterStart, ProcFlags.None, ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.None, ProcFlagsHit.None, null, null, null);
                            }
                        }
                        break;
                    }

                    case EncounterState.Fail:
                    case EncounterState.Done:
                        ResetCombatResurrections();
                        SendEncounterEnd();
                        break;

                    default:
                        break;
                    }

                    bossInfo.state = state;
                    SaveToDB();
                }

                for (uint type = 0; type < (int)DoorType.Max; ++type)
                {
                    foreach (var guid in bossInfo.door[type])
                    {
                        GameObject door = instance.GetGameObject(guid);
                        if (door)
                        {
                            UpdateDoorState(door);
                        }
                    }
                }

                foreach (var guid in bossInfo.minion.ToArray())
                {
                    Creature minion = instance.GetCreature(guid);
                    if (minion)
                    {
                        UpdateMinionState(minion, state);
                    }
                }

                UpdateSpawnGroups();
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 public DoorInfo(BossInfo _bossInfo, DoorType _type)
 {
     bossInfo = _bossInfo;
     type     = _type;
 }
Exemplo n.º 3
0
 public MinionInfo(BossInfo _bossInfo)
 {
     bossInfo = _bossInfo;
 }
Exemplo n.º 4
0
        public virtual bool SetBossState(uint id, EncounterState state)
        {
            if (id < bosses.Count)
            {
                BossInfo bossInfo = bosses[id];
                if (bossInfo.state == EncounterState.ToBeDecided) // loading
                {
                    bossInfo.state = state;
                    //Log.outError(LogFilter.General "Inialize boss {0} state as {1}.", id, (uint32)state);
                    return(false);
                }
                else
                {
                    if (bossInfo.state == state)
                    {
                        return(false);
                    }

                    if (state == EncounterState.Done)
                    {
                        foreach (var guid in bossInfo.minion)
                        {
                            Creature minion = instance.GetCreature(guid);
                            if (minion)
                            {
                                if (minion.IsWorldBoss() && minion.IsAlive())
                                {
                                    return(false);
                                }
                            }
                        }
                    }

                    switch (state)
                    {
                    case EncounterState.InProgress:
                    {
                        uint resInterval = GetCombatResurrectionChargeInterval();
                        InitializeCombatResurrections(1, resInterval);
                        SendEncounterStart(1, 9, resInterval, resInterval);

                        var playerList = instance.GetPlayers();
                        foreach (var player in playerList)
                        {
                            if (player.IsAlive())
                            {
                                player.ProcSkillsAndAuras(null, ProcFlags.EncounterStart, ProcFlags.None, ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.None, ProcFlagsHit.None, null, null, null);
                            }
                        }
                        break;
                    }

                    case EncounterState.Fail:
                    case EncounterState.Done:
                        ResetCombatResurrections();
                        SendEncounterEnd();
                        break;

                    default:
                        break;
                    }

                    bossInfo.state = state;
                    SaveToDB();
                }

                for (uint type = 0; type < (int)DoorType.Max; ++type)
                {
                    foreach (var guid in bossInfo.door[type])
                    {
                        GameObject door = instance.GetGameObject(guid);
                        if (door)
                        {
                            UpdateDoorState(door);
                        }
                    }
                }

                foreach (var guid in bossInfo.minion.ToArray())
                {
                    Creature minion = instance.GetCreature(guid);
                    if (minion)
                    {
                        UpdateMinionState(minion, state);
                    }
                }

                return(true);
            }
            return(false);
        }