Esempio n. 1
0
            //same here
            public override bool Fallback(string[] @params = null, CommandGroup cmd = null)
            {
                if (@params == null || cmd == null || @params.Count() < 2)
                {
                    return(false);
                }

                uint objectId;

                uint.TryParse(@params[0], out objectId);

                if (objectId == 0)
                {
                    return(false);
                }

                uint spawntimeSecs;

                uint.TryParse(@params[1], out spawntimeSecs);

                GameObjectTemplate objectInfo = ObjMgr.GetGameObjectTemplate(objectId);

                if (objectInfo == null)
                {
                    cmd.SendErrorMessage(CypherStrings.GameobjectNotExist, objectId);
                    return(false);
                }

                //if (objectInfo.displayId != 0 && !DBCStorage.sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
                {
                    // report to DB errors log as in loading case
                    //sLog->outError(LOG_FILTER_SQL, "Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", objectId, objectInfo->type, objectInfo->displayId);
                    //handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, objectId);
                    //return false;
                }

                Player player = cmd.GetSession().GetPlayer();
                float  x      = player.GetPositionX();
                float  y      = player.GetPositionY();
                float  z      = player.GetPositionZ();
                float  o      = player.GetOrientation();
                Map    map    = player.GetMap();

                GameObject obj     = new GameObject();
                uint       guidLow = ObjMgr.GenerateLowGuid(HighGuidType.GameObject);

                if (!obj.Create(guidLow, objectInfo.entry, map, 1 /*player.GetPhaseMgr().GetPhaseMaskForSpawn()*/, x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GameObjectState.Ready))
                {
                    return(false);
                }

                //if (spawntimeSecs != 0)
                {
                    //obj.SetRespawnTime(spawntimeSecs);
                }

                // fill the gameobject data and save to the db
                obj.SaveToDB(map.GetId(), (byte)(1 << (int)map.GetSpawnMode()), 1);//player.GetPhaseMgr().GetPhaseMaskForSpawn());

                // this will generate a new guid if the object is in an instance
                if (!obj.LoadGameObjectFromDB(guidLow, map))
                {
                    return(false);
                }

                // TODO: is it really necessary to add both the real and DB table guid here ?
                ObjMgr.AddGameObjectToGrid(guidLow, ObjMgr.GetGOData(guidLow));
                cmd.SendSysMessage(CypherStrings.GameobjectAdd, objectId, objectInfo.name, guidLow, x, y, z);
                return(true);
            }