Example #1
0
        public Creature CreateNPCPassenger(ulong guid, CreatureData data)
        {
            Map map = GetMap();

            if (map.GetCreatureRespawnTime(guid) != 0)
            {
                return(null);
            }

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

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

            float x, y, z, o;

            data.spawnPoint.GetPosition(out x, out y, out z, out o);

            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);
        }
Example #2
0
        GameObject CreateGOPassenger(ulong guid, GameObjectData data)
        {
            Map map = GetMap();

            if (map.GetGORespawnTime(guid) != 0)
            {
                return(null);
            }

            GameObject go = CreateGameObjectFromDB(guid, map, false);

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

            float x, y, z, o;

            data.spawnPoint.GetPosition(out x, out y, out z, out o);

            go.SetTransport(this);
            go.m_movementInfo.transport.guid = GetGUID();
            go.m_movementInfo.transport.pos.Relocate(x, y, z, o);
            go.m_movementInfo.transport.seat = -1;
            CalculatePassengerPosition(ref x, ref y, ref z, ref o);
            go.Relocate(x, y, z, o);
            go.RelocateStationaryPosition(x, y, z, o);

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

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

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

            _staticPassengers.Add(go);
            return(go);
        }