Beispiel #1
0
        public void Reward()
        {
            // 3. Reward killer (and group, if necessary).
            if (_group)
            {
                // 3.1. If killer is in group, reward group.
                _RewardGroup();
            }
            else
            {
                // 3.2. Reward single killer (not group case).
                // 3.2.1. Initialize initial XP amount based on killer's level.
                _InitXP(_killer);
                // To avoid unnecessary calculations and calls,
                // proceed only if XP is not ZERO or player is not on Battleground
                // (Battlegroundrewards only XP, that's why).
                if (!_isBattleground || _xp != 0)
                {
                    // 3.2.2. Reward killer.
                    _RewardPlayer(_killer, false);
                }
            }

            // 5. Credit instance encounter.
            // 6. Update guild achievements.
            // 7. Credit scenario criterias
            Creature victim = _victim.ToCreature();

            if (victim != null)
            {
                if (victim.IsDungeonBoss())
                {
                    InstanceScript instance = _victim.GetInstanceScript();
                    if (instance != null)
                    {
                        instance.UpdateEncounterStateForKilledCreature(_victim.GetEntry(), _victim);
                    }
                }

                uint guildId = victim.GetMap().GetOwnerGuildId();
                var  guild   = Global.GuildMgr.GetGuildById(guildId);
                if (guild != null)
                {
                    guild.UpdateCriteria(CriteriaTypes.KillCreature, victim.GetEntry(), 1, 0, victim, _killer);
                }

                Scenario scenario = victim.GetScenario();
                if (scenario != null)
                {
                    scenario.UpdateCriteria(CriteriaTypes.KillCreature, victim.GetEntry(), 1, 0, victim, _killer);
                }
            }
        }
Beispiel #2
0
        public Creature CreateNPCPassenger(ulong guid, CreatureData data)
        {
            Map map = GetMap();

            Creature creature = Creature.CreateCreatureFromDB(guid, map, false);

            if (!creature)
            {
                return(null);
            }

            float x = data.posX;
            float y = data.posY;
            float z = data.posZ;
            float o = data.orientation;

            creature.SetTransport(this);
            creature.m_movementInfo.transport.guid = GetGUID();
            creature.m_movementInfo.transport.pos.Relocate(x, y, z, o);
            creature.m_movementInfo.transport.seat = -1;
            CalculatePassengerPosition(ref x, ref y, ref z, ref o);
            creature.Relocate(x, y, z, o);
            creature.SetHomePosition(creature.GetPositionX(), creature.GetPositionY(), creature.GetPositionZ(), creature.GetOrientation());
            creature.SetTransportHomePosition(creature.m_movementInfo.transport.pos);

            // @HACK - transport models are not added to map's dynamic LoS calculations
            //         because the current GameObjectModel cannot be moved without recreating
            creature.AddUnitState(UnitState.IgnorePathfinding);

            if (!creature.IsPositionValid())
            {
                Log.outError(LogFilter.Transport, "Creature (guidlow {0}, entry {1}) not created. Suggested coordinates aren't valid (X: {2} Y: {3})", creature.GetGUID().ToString(), creature.GetEntry(), creature.GetPositionX(), creature.GetPositionY());
                return(null);
            }

            PhasingHandler.InitDbPhaseShift(creature.GetPhaseShift(), data.phaseUseFlags, data.phaseId, data.phaseGroup);
            PhasingHandler.InitDbVisibleMapId(creature.GetPhaseShift(), data.terrainSwapMap);

            if (!map.AddToMap(creature))
            {
                return(null);
            }

            _staticPassengers.Add(creature);
            Global.ScriptMgr.OnAddCreaturePassenger(this, creature);
            return(creature);
        }
Beispiel #3
0
        public Creature CreateNPCPassenger(ulong guid, CreatureData data)
        {
            Map      map      = GetMap();
            Creature creature = new Creature();

            if (!creature.LoadCreatureFromDB(guid, map, false))
            {
                return(null);
            }

            float x = data.posX;
            float y = data.posY;
            float z = data.posZ;
            float o = data.orientation;

            creature.SetTransport(this);
            creature.m_movementInfo.transport.guid = GetGUID();
            creature.m_movementInfo.transport.pos.Relocate(x, y, z, o);
            creature.m_movementInfo.transport.seat = -1;
            CalculatePassengerPosition(ref x, ref y, ref z, ref o);
            creature.Relocate(x, y, z, o);
            creature.SetHomePosition(creature.GetPositionX(), creature.GetPositionY(), creature.GetPositionZ(), creature.GetOrientation());
            creature.SetTransportHomePosition(creature.m_movementInfo.transport.pos);

            // @HACK - transport models are not added to map's dynamic LoS calculations
            //         because the current GameObjectModel cannot be moved without recreating
            creature.AddUnitState(UnitState.IgnorePathfinding);

            if (!creature.IsPositionValid())
            {
                Log.outError(LogFilter.Transport, "Creature (guidlow {0}, entry {1}) not created. Suggested coordinates aren't valid (X: {2} Y: {3})", creature.GetGUID().ToString(), creature.GetEntry(), creature.GetPositionX(), creature.GetPositionY());
                return(null);
            }

            if (data.phaseid != 0)
            {
                creature.SetInPhase(data.phaseid, false, true);
            }
            else if (data.phaseGroup != 0)
            {
                foreach (var phase in Global.DB2Mgr.GetPhasesForGroup(data.phaseGroup))
                {
                    creature.SetInPhase(phase, false, true);
                }
            }
            else
            {
                creature.CopyPhaseFrom(this);
            }

            if (!map.AddToMap(creature))
            {
                return(null);
            }

            _staticPassengers.Add(creature);
            Global.ScriptMgr.OnAddCreaturePassenger(this, creature);
            return(creature);
        }