コード例 #1
0
        public static void ShopPurchase(ClientInfo _cInfo, string _itemName, int _count, int _quality, int _price, string _playerName, int currentCoins)
        {
            World     world      = GameManager.Instance.World;
            ItemValue itemValue  = new ItemValue(ItemClass.GetItem(_itemName).type, _quality, _quality, true);
            var       entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
            {
                entityClass     = EntityClass.FromString("item"),
                id              = EntityFactory.nextEntityID++,
                itemStack       = new ItemStack(itemValue, _count),
                pos             = world.Players.dict[_cInfo.entityId].position,
                rot             = new Vector3(20f, 0f, 20f),
                lifetime        = 60f,
                belongsPlayerId = _cInfo.entityId
            });

            world.SpawnEntityInWorld(entityItem);
            _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
            world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
            SdtdConsole.Instance.Output(string.Format("Sold {0} to {1}.", itemValue.ItemClass.GetLocalizedItemName() ?? itemValue.ItemClass.Name, _cInfo.playerName));
            string _message = "{Count} {Item} was purchased through the shop. If your bag is full, check the ground.";

            _message = _message.Replace("{Count}", _count.ToString());
            _message = _message.Replace("{Item}", itemValue.ItemClass.GetLocalizedItemName() ?? itemValue.ItemClass.Name);
            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _price);
        }
コード例 #2
0
        public static void Exec(ClientInfo _cInfo)
        {
            World world = GameManager.Instance.World;

            foreach (KeyValuePair <string, int[]> kvp in startItemList)
            {
                ItemValue _itemValue = new ItemValue(ItemClass.GetItem(kvp.Key).type, kvp.Value[1], kvp.Value[1], true);
                var       entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                {
                    entityClass     = EntityClass.FromString("item"),
                    id              = EntityFactory.nextEntityID++,
                    itemStack       = new ItemStack(_itemValue, kvp.Value[0]),
                    pos             = world.Players.dict[_cInfo.entityId].position,
                    rot             = new Vector3(20f, 0f, 20f),
                    lifetime        = 60f,
                    belongsPlayerId = _cInfo.entityId
                });
                world.SpawnEntityInWorld(entityItem);
                _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                Log.Out(string.Format("[SERVERTOOLS] Spawned starting item {0} for {1}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name, _cInfo.playerName));
            }
            string _sql = string.Format("UPDATE Players SET startingItems = 'true' WHERE steamid = '{0}'", _cInfo.playerId);

            SQL.FastQuery(_sql);
        }
コード例 #3
0
 public static void Send(ClientInfo _cInfo)
 {
     if (StartingItems.startItemList.Count > 0)
     {
         World world = GameManager.Instance.World;
         foreach (KeyValuePair <string, int[]> kvp in StartingItems.startItemList)
         {
             ItemValue _itemValue = new ItemValue(ItemClass.GetItem(kvp.Key).type, kvp.Value[1], kvp.Value[1], true);
             var       entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
             {
                 entityClass     = EntityClass.FromString("item"),
                 id              = EntityFactory.nextEntityID++,
                 itemStack       = new ItemStack(_itemValue, kvp.Value[0]),
                 pos             = world.Players.dict[_cInfo.entityId].position,
                 rot             = new Vector3(20f, 0f, 20f),
                 lifetime        = 60f,
                 belongsPlayerId = _cInfo.entityId
             });
             world.SpawnEntityInWorld(entityItem);
             _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
             world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
             SdtdConsole.Instance.Output(string.Format("Spawned starting item {0} for {1}.", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name, _cInfo.playerName));
             Log.Out(string.Format("[SERVERTOOLS] Spawned starting item {0} for {1}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name, _cInfo.playerName));
         }
         string _phrase806;
         if (!Phrases.Dict.TryGetValue(806, out _phrase806))
         {
             _phrase806 = "you have received the starting items. Check your inventory. If full, check the ground.";
         }
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase806 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
コード例 #4
0
 private static void RandomItem(ClientInfo _cInfo)
 {
     try
     {
         string _randomItem = list.RandomObject();
         ItemValue _itemValue = new ItemValue(ItemClass.GetItem(_randomItem, false).type, false);
         int[] _itemData;
         if (Dict.TryGetValue(_randomItem, out _itemData))
         {
             int _count = 0;
             if (_itemData[0] > _itemData[1])
             {
                 _count = random.Next(_itemData[1], _itemData[0] + 1);
             }
             else
             {
                 _count = random.Next(_itemData[0], _itemData[1] + 1);
             }
             if (_itemValue.HasQuality && _itemData[2] > 0 && _itemData[3] >= _itemData[2])
             {
                 _itemValue.Quality = random.Next(_itemData[2], _itemData[3] + 1);
             }
             var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
             {
                 entityClass = EntityClass.FromString("item"),
                 id = EntityFactory.nextEntityID++,
                 itemStack = new ItemStack(_itemValue, _count),
                 pos = GameManager.Instance.World.Players.dict[_cInfo.entityId].position,
                 rot = new Vector3(20f, 0f, 20f),
                 lifetime = 60f,
                 belongsPlayerId = _cInfo.entityId
             });
             GameManager.Instance.World.SpawnEntityInWorld(entityItem);
             _cInfo.SendPackage(NetPackageManager.GetPackage<NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
             GameManager.Instance.World.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
             if (Wallet.IsEnabled && Command_Cost >= 1)
             {
                 Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
             }
             PersistentContainer.Instance.Players[_cInfo.playerId].LastGimme = DateTime.Now;
             PersistentContainer.Instance.Save();
             Phrases.Dict.TryGetValue(22, out string _phrase22);
             _phrase22 = _phrase22.Replace("{ItemCount}", _count.ToString());
             Dict1.TryGetValue(_randomItem, out string _name);
             if (_name != "")
             {
                 _phrase22 = _phrase22.Replace("{ItemName}", _name);
             }
             else
             {
                 _phrase22 = _phrase22.Replace("{ItemName}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name);
             }
             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase22 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Gimme.RandomItem: {0}", e.Message));
     }
 }
コード例 #5
0
        public static void ReturnBlock(ClientInfo _cInfo, string _blockName, int _quantity)
        {
            EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId);

            if (_player != null && _player.IsSpawned() && !_player.IsDead())
            {
                World     _world     = GameManager.Instance.World;
                ItemValue _itemValue = ItemClass.GetItem(_blockName, false);
                if (_itemValue != null)
                {
                    var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                    {
                        entityClass     = EntityClass.FromString("item"),
                        id              = EntityFactory.nextEntityID++,
                        itemStack       = new ItemStack(_itemValue, _quantity),
                        pos             = _world.Players.dict[_cInfo.entityId].position,
                        rot             = new Vector3(20f, 0f, 20f),
                        lifetime        = 60f,
                        belongsPlayerId = _cInfo.entityId
                    });
                    _world.SpawnEntityInWorld(entityItem);
                    _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                    _world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
                    Phrases.Dict.TryGetValue(901, out string _phrase901);
                    _phrase901 = _phrase901.Replace("{Value}", _quantity.ToString());
                    _phrase901 = _phrase901.Replace("{ItemName}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name);
                    ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase901 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                }
            }
        }
コード例 #6
0
        public static void Postfix(EntityAlive __instance)
        {
            String strSpawnGroup = "";
            EntityClass entityClass = EntityClass.list[__instance.entityClass];
            if (entityClass.Properties.Values.ContainsKey("SpawnOnDeath"))
            {
                // Spawn location
                Vector3i blockPos = default(Vector3i);
                blockPos.x = (int)__instance.position.x;
                blockPos.y = (int)__instance.position.y;
                blockPos.z = (int)__instance.position.z;


                // <property name="SpawnOnDeath" value="EnemyAnimalsForest" />
                strSpawnGroup = entityClass.Properties.Values["SpawnOnDeath"];

                int classID = 0;
                // try to spawn from a group
                Entity entity = EntityFactory.CreateEntity(EntityGroups.GetRandomFromGroup(strSpawnGroup, ref classID), __instance.position);
                if (entity != null)
                {
                    __instance.world.SetBlockRPC(blockPos, BlockValue.Air);
                    GameManager.Instance.World.SpawnEntityInWorld(entity);
                    return;
                }

                // If no group, then assume its an entity
                int entityID = EntityClass.FromString(strSpawnGroup);
                entity = EntityFactory.CreateEntity(entityID, __instance.position);
                if(entity != null)
                {
                    GameManager.Instance.World.SpawnEntityInWorld(entity);
                }
            }
        }
コード例 #7
0
 public static void BuyAuction(ClientInfo _cInfo, int _purchase, int _price)
 {
     if (AuctionItems.TryGetValue(_purchase, out string _steamId))
     {
         if (PersistentContainer.Instance.Players[_steamId].Auction != null && PersistentContainer.Instance.Players[_steamId].Auction.Count > 0)
         {
             PersistentContainer.Instance.Players[_steamId].Auction.TryGetValue(_purchase, out ItemDataSerializable _itemData);
             ItemValue _itemValue = new ItemValue(ItemClass.GetItem(_itemData.name, false).type, false);
             if (_itemValue != null)
             {
                 _itemValue.UseTimes = _itemData.useTimes;
                 _itemValue.Quality  = _itemData.quality;
                 World      world      = GameManager.Instance.World;
                 EntityItem entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                 {
                     entityClass     = EntityClass.FromString("item"),
                     id              = EntityFactory.nextEntityID++,
                     itemStack       = new ItemStack(_itemValue, _itemData.count),
                     pos             = world.Players.dict[_cInfo.entityId].position,
                     rot             = new Vector3(20f, 0f, 20f),
                     lifetime        = 60f,
                     belongsPlayerId = _cInfo.entityId
                 });
                 world.SpawnEntityInWorld(entityItem);
                 _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                 world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
                 AuctionItems.Remove(_purchase);
                 PersistentContainer.Instance.Players[_steamId].Auction.Remove(_purchase);
                 PersistentContainer.Instance.AuctionPrices.Remove(_purchase);
                 PersistentContainer.DataChange = true;
                 Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _price);
                 float _fee           = _price * ((float)Tax / 100);
                 int   _adjustedPrice = _price - (int)_fee;
                 Wallet.AddCoinsToWallet(_steamId, _adjustedPrice);
                 string _playerName = PersistentOperations.GetPlayerDataFileFromSteamId(_steamId).ecd.entityName;
                 using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                 {
                     sw.WriteLine(string.Format("{0}: {1} {2} has purchased auction entry {3}, profits went to steam id {4} {5}", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _purchase, _steamId, _playerName));
                     sw.WriteLine();
                     sw.Flush();
                     sw.Close();
                 }
                 Phrases.Dict.TryGetValue(629, out string _phrase629);
                 _phrase629 = _phrase629.Replace("{Count}", _itemData.count.ToString());
                 _phrase629 = _phrase629.Replace("{ItemName}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName());
                 _phrase629 = _phrase629.Replace("{Value}", _price.ToString());
                 _phrase629 = _phrase629.Replace("{CoinName}", Wallet.Coin_Name);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase629 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForPlayerId(_steamId);
                 if (_cInfo2 != null)
                 {
                     Phrases.Dict.TryGetValue(630, out string _phrase630);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase630 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
         }
     }
 }
コード例 #8
0
        public static void SpawnItems(ClientInfo _cInfo)
        {
            try
            {
                if (StartingItems.Dict.Count > 0)
                {
                    World world = GameManager.Instance.World;
                    if (world.Players.dict.ContainsKey(_cInfo.entityId))
                    {
                        EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);
                        if (_player != null && _player.IsSpawned() && !_player.IsDead())
                        {
                            PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].StartingItems = true;
                            PersistentContainer.DataChange = true;
                            List <string> _itemList = StartingItems.Dict.Keys.ToList();
                            for (int i = 0; i < _itemList.Count; i++)
                            {
                                string _item = _itemList[i];
                                StartingItems.Dict.TryGetValue(_item, out int[]  _itemData);
                                ItemValue _itemValue = new ItemValue(ItemClass.GetItem(_item, false).type, false);
                                if (_itemValue.HasQuality && _itemData[1] > 0)
                                {
                                    _itemValue.Quality = _itemData[1];
                                }
                                EntityItem entityItem = new EntityItem();
                                entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                                {
                                    entityClass     = EntityClass.FromString("item"),
                                    id              = EntityFactory.nextEntityID++,
                                    itemStack       = new ItemStack(_itemValue, _itemData[0]),
                                    pos             = world.Players.dict[_cInfo.entityId].position,
                                    rot             = new Vector3(20f, 0f, 20f),
                                    lifetime        = 60f,
                                    belongsPlayerId = _cInfo.entityId
                                });
                                world.SpawnEntityInWorld(entityItem);
                                _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
                                Thread.Sleep(TimeSpan.FromSeconds(1));
                            }
                            Log.Out(string.Format("[SERVERTOOLS] '{0}' with id '{1}' received their starting items", _cInfo.playerName, _cInfo.CrossplatformId.CombinedString));
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] '{0}' with id '{1}' received their starting items", _cInfo.playerName, _cInfo.CrossplatformId.CombinedString));

                            Phrases.Dict.TryGetValue("StartingItems1", out string _phrase);
                            ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Player with id '{0}' has not spawned. Unable to give starting items", _cInfo.CrossplatformId.CombinedString));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Out(string.Format("[SERVERTOOLS] Error in GiveStartingItemsConsole.SpawnItems: {0}", e.Message));
            }
        }
コード例 #9
0
    public override void OnAddedToWorld()
    {
        DisplayLog("EntityClass: " + this.entityClass);

        EntityClass entityClass = EntityClass.list[this.entityClass];

        if (entityClass.Properties.Classes.ContainsKey("SpawnSettings"))
        {
            DisplayLog(" Found Spawn Settings.. reading...");
            DynamicProperties dynamicProperties3 = entityClass.Properties.Classes["SpawnSettings"];
            foreach (KeyValuePair <string, object> keyValuePair in dynamicProperties3.Values.Dict.Dict)
            {
                DisplayLog("Key: " + keyValuePair.Key);
                if (keyValuePair.Key == "Leader")
                {
                    DisplayLog(" Found a Leader");
                    this.strLeaderEntity = dynamicProperties3.Values[keyValuePair.Key];

                    SpawnEntity(EntityClass.FromString(this.strLeaderEntity), true);
                    continue;
                }

                if (keyValuePair.Key == "Followers")
                {
                    DisplayLog("Found Followers");

                    int Range = GetRange(dynamicProperties3, "Followers");
                    for (int x = 0; x <= Range; x++)
                    {
                        // if it contains commas, it's individual entities.
                        String strValue = dynamicProperties3.Values[keyValuePair.Key];
                        if (strValue.Contains(","))
                        {
                            foreach (String strEntity in strValue.Split(','))
                            {
                                SpawnEntity(EntityClass.FromString(strEntity), false);
                            }

                            // If we spawn in each entity, break, as we don't want multiple spawns.
                            break;
                        }
                        else  //  Spawn from Entity Group
                        {
                            SpawnFromGroup(strValue, 1);
                        }
                    }
                    continue;
                }
            }
        }
        else
        {
            DisplayLog(" No Spawn settings found.");
        }

        this.SetDead();
    }
コード例 #10
0
    // spawns a children next to the parent.
    private void SpawnFlock()
    {
        if (previousID <= 0)
        {
            return;                  // does NOT do this yet.
        }
        if (hasFlock)
        {
            return;
        }
        if (dtaNextSpawn > DateTime.Now.AddSeconds(30))
        {
            dtaNextSpawn = DateTime.Now.AddMilliseconds(500);
        }
        if (DateTime.Now < dtaNextSpawn)
        {
            return;
        }
        // spawn them right by the parent
        // separates the spawning a few miliseconds just to avoid overlapping
        var newPos      = position + Vector3.up;
        var maxDistance = new Vector3(5, 5, 5);
        int x;
        int y;
        int z;

        if (world.FindRandomSpawnPointNearPosition(position, 15, out x, out y, out z, maxDistance, false, true))
        {
            newPos = new Vector3(x, y, z);
            if (lastSpawnPosition != newPos)
            {
                lastSpawnPosition = newPos;
                if (debug)
                {
                    Debug.Log("SPAWNING CHILDREN FOR ID " + entityId);
                }
                var spawnEntity = EntityFactory.CreateEntity(EntityClass.FromString(EntityName), newPos);
                spawnEntity.SetSpawnerSource(EnumSpawnerSource.Unknown);
                GameManager.Instance.World.SpawnEntityInWorld(spawnEntity);
                (spawnEntity as EntityZombieFlyingSDX).setMasterEntity(this);
                // flying entities spawning is a bit odd, so we "override" the position to where we want the children to be
                // which is by its parent
                // spawnEntity.position = newPos;
                numberSpawned++;
                if (numberSpawned > maxToSpawn)
                {
                    hasFlock = true;
                }
            }
        }
        else if (debug)
        {
            Debug.Log("No place to spawn");
        }

        dtaNextSpawn = DateTime.Now.AddMilliseconds(200);
    }
コード例 #11
0
        public static void Send(ClientInfo _cInfo)
        {
            if (StartingItems.startItemList.Count > 0)
            {
                World world = GameManager.Instance.World;
                foreach (KeyValuePair <string, int[]> kvp in StartingItems.startItemList)
                {
                    ItemValue itemValue;
                    var       itemId = 4096;
                    int       _itemId;
                    if (int.TryParse(kvp.Key, out _itemId))
                    {
                        int calc = (_itemId + 4096);
                        itemId    = calc;
                        itemValue = ItemClass.list[itemId] == null ? ItemValue.None : new ItemValue(itemId, kvp.Value[1], kvp.Value[1], true);
                    }
                    else
                    {
                        if (!ItemClass.ItemNames.Contains(kvp.Key))
                        {
                            Log.Out(string.Format("[SERVERTOOLS] Unable to find item {0}", kvp.Key));
                        }

                        itemValue = new ItemValue(ItemClass.GetItem(kvp.Key).type, kvp.Value[1], kvp.Value[1], true);
                    }

                    if (Equals(itemValue, ItemValue.None))
                    {
                        Log.Out(string.Format("[SERVERTOOLS] Unable to find item {0}", kvp.Key));
                    }
                    var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                    {
                        entityClass     = EntityClass.FromString("item"),
                        id              = EntityFactory.nextEntityID++,
                        itemStack       = new ItemStack(itemValue, kvp.Value[0]),
                        pos             = world.Players.dict[_cInfo.entityId].position,
                        rot             = new Vector3(20f, 0f, 20f),
                        lifetime        = 60f,
                        belongsPlayerId = _cInfo.entityId
                    });
                    world.SpawnEntityInWorld(entityItem);
                    _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                    world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                    SdtdConsole.Instance.Output(string.Format("Spawned starting item {0} for {1}.", itemValue.ItemClass.localizedName ?? itemValue.ItemClass.Name, _cInfo.playerName));
                    Log.Out(string.Format("[SERVERTOOLS] Spawned starting item {0} for {1}", itemValue.ItemClass.localizedName ?? itemValue.ItemClass.Name, _cInfo.playerName));
                }
                string _phrase806;
                if (!Phrases.Dict.TryGetValue(806, out _phrase806))
                {
                    _phrase806 = "{PlayerName} have received the starting items. Check your inventory. If full, check the ground.";
                }
                _phrase806 = _phrase806.Replace("{PlayerName}", _cInfo.playerName);
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase806), Config.Server_Response_Name, false, "ServerTools", false));
            }
        }
コード例 #12
0
 public static void SpawnItems(ClientInfo _cInfo)
 {
     try
     {
         if (ItemList.Count > 0)
         {
             PersistentContainer.Instance.Players[_cInfo.playerId].StartingItems = true;
             PersistentContainer.Instance.Save();
             World         world     = GameManager.Instance.World;
             List <string> _itemList = ItemList.Keys.ToList();
             for (int i = 0; i < _itemList.Count; i++)
             {
                 string _item = _itemList[i];
                 int[]  _itemData;
                 if (ItemList.TryGetValue(_item, out _itemData))
                 {
                     ItemValue _itemValue = new ItemValue(ItemClass.GetItem(_item, false).type, false);
                     if (_itemValue.HasQuality && _itemData[1] > 0)
                     {
                         _itemValue.Quality = _itemData[1];
                     }
                     EntityItem entityItem = new EntityItem();
                     entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                     {
                         entityClass     = EntityClass.FromString("item"),
                         id              = EntityFactory.nextEntityID++,
                         itemStack       = new ItemStack(_itemValue, _itemData[0]),
                         pos             = world.Players.dict[_cInfo.entityId].position,
                         rot             = new Vector3(20f, 0f, 20f),
                         lifetime        = 60f,
                         belongsPlayerId = _cInfo.entityId
                     });
                     world.SpawnEntityInWorld(entityItem);
                     _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                     world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
                     Thread.Sleep(TimeSpan.FromSeconds(1));
                 }
             }
             Log.Out(string.Format("[SERVERTOOLS] {0} with steam id {1} received their starting items", _cInfo.playerName, _cInfo.playerId));
             SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] {0} with steam id {1} received their starting items", _cInfo.playerName, _cInfo.playerId));
             string _phrase806;
             if (!Phrases.Dict.TryGetValue(806, out _phrase806))
             {
                 _phrase806 = "You have received the starting items. Check your inventory. If full, check the ground.";
             }
             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase806 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in StartingItems.SpawnItems: {0}", e.Message));
     }
 }
コード例 #13
0
        public static Entity Spawn(Vector3 pos, string entityName)     // fixme entityID useless here
        {
            int    entityClassID = EntityClass.FromString(entityName); // "zombieBoe" "animalSnake"
            Entity entity        = EntityFactory.CreateEntity(entityClassID, pos);

            entity.SetSpawnerSource(EnumSpawnerSource.Dynamic);
            // entity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner, 0, entityGroup);
            GameManager.Instance.World.SpawnEntityInWorld(entity);
            // Zombiome.Routines.Start(WaitEntity(entity));
            // Zombiome.Routines.Start(testWait());
            return(entity);
        }
コード例 #14
0
 public static void CancelAuction(ClientInfo _cInfo, string _auctionId)
 {
     if (int.TryParse(_auctionId, out int _id))
     {
         if (AuctionItems.ContainsKey(_id))
         {
             if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction != null && PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Count > 0)
             {
                 if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction.TryGetValue(_id, out ItemDataSerializable _itemData))
                 {
                     ItemValue _itemValue = new ItemValue(ItemClass.GetItem(_itemData.name, false).type, false);
                     if (_itemValue != null)
                     {
                         _itemValue.UseTimes = _itemData.useTimes;
                         _itemValue.Quality  = _itemData.quality;
                         World world      = GameManager.Instance.World;
                         var   entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                         {
                             entityClass     = EntityClass.FromString("item"),
                             id              = EntityFactory.nextEntityID++,
                             itemStack       = new ItemStack(_itemValue, _itemData.count),
                             pos             = world.Players.dict[_cInfo.entityId].position,
                             rot             = new Vector3(20f, 0f, 20f),
                             lifetime        = 60f,
                             belongsPlayerId = _cInfo.entityId
                         });
                         world.SpawnEntityInWorld(entityItem);
                         _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                         world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
                         AuctionItems.Remove(_id);
                         PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Remove(_id);
                         PersistentContainer.Instance.AuctionPrices.Remove(_id);
                         PersistentContainer.DataChange = true;
                         using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                         {
                             sw.WriteLine(string.Format("{0}: {1} {2} has cancelled their auction entry # {3}.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _cInfo.entityId));
                             sw.WriteLine();
                             sw.Flush();
                             sw.Close();
                         }
                         Phrases.Dict.TryGetValue(631, out string _phrase631);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase631 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
             }
         }
         else
         {
             Phrases.Dict.TryGetValue(632, out string _phrase632);
             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase632 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
         }
     }
 }
コード例 #15
0
 internal static EntityItem MakeEntity(ItemValue itemValue, int belongsPlayerId, Vector3 pos, int quantity)
 {
     return((EntityItem)EntityFactory.CreateEntity(new EntityCreationData
     {
         entityClass = EntityClass.FromString("item"),
         id = EntityFactory.nextEntityID++,
         itemStack = new ItemStack(itemValue, quantity),
         pos = pos,
         rot = new Vector3(20f, 0f, 20f),
         lifetime = 60f,
         belongsPlayerId = belongsPlayerId
     }));
 }
コード例 #16
0
 private static void RandomItem(ClientInfo _cInfo)
 {
     try
     {
         string    _randomItem = list.RandomObject();
         ItemValue _itemValue  = new ItemValue(ItemClass.GetItem(_randomItem, false).type, false);
         int[]     _itemData;
         if (Dict.TryGetValue(_randomItem, out _itemData))
         {
             int _count = 0;
             if (_itemData[0] > _itemData[1])
             {
                 _count = random.Next(_itemData[1], _itemData[0] + 1);
             }
             else
             {
                 _count = random.Next(_itemData[0], _itemData[1] + 1);
             }
             if (_itemValue.HasQuality && _itemData[2] > 0 && _itemData[3] >= _itemData[2])
             {
                 _itemValue.Quality = random.Next(_itemData[2], _itemData[3] + 1);
             }
             World world      = GameManager.Instance.World;
             var   entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
             {
                 entityClass     = EntityClass.FromString("item"),
                 id              = EntityFactory.nextEntityID++,
                 itemStack       = new ItemStack(_itemValue, _count),
                 pos             = world.Players.dict[_cInfo.entityId].position,
                 rot             = new Vector3(20f, 0f, 20f),
                 lifetime        = 60f,
                 belongsPlayerId = _cInfo.entityId
             });
             world.SpawnEntityInWorld(entityItem);
             _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
             world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
             string _message = " received {ItemCount} {ItemName} from Hades.";
             _message = _message.Replace("{ItemCount}", _count.ToString());
             string _name;
             Dict1.TryGetValue(_randomItem, out _name);
             _message = _message.Replace("{ItemName}", _name);
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.RandomItem: {0}.", e.Message));
     }
 }
コード例 #17
0
 public static void Send(ClientInfo _cInfo)
 {
     try
     {
         if (StartingItems.ItemList.Count > 0)
         {
             World         world     = GameManager.Instance.World;
             List <string> _itemList = StartingItems.ItemList.Keys.ToList();
             for (int i = 0; i < _itemList.Count; i++)
             {
                 string _item = _itemList[i];
                 int[]  _itemData;
                 StartingItems.ItemList.TryGetValue(_item, out _itemData);
                 ItemValue _itemValue = new ItemValue(ItemClass.GetItem(_item, false).type, false);
                 if (_itemValue.HasQuality && _itemData[1] > 0)
                 {
                     _itemValue.Quality = _itemData[1];
                 }
                 EntityItem entityItem = new EntityItem();
                 entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                 {
                     entityClass     = EntityClass.FromString("item"),
                     id              = EntityFactory.nextEntityID++,
                     itemStack       = new ItemStack(_itemValue, _itemData[0]),
                     pos             = world.Players.dict[_cInfo.entityId].position,
                     rot             = new Vector3(20f, 0f, 20f),
                     lifetime        = 60f,
                     belongsPlayerId = _cInfo.entityId
                 });
                 world.SpawnEntityInWorld(entityItem);
                 _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                 world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                 SdtdConsole.Instance.Output(string.Format("Spawned starting item {0} for {1}.", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name, _cInfo.playerName));
                 Log.Out(string.Format("[SERVERTOOLS] Spawned starting item {0} for {1}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name, _cInfo.playerName));
             }
             string _phrase806;
             if (!Phrases.Dict.TryGetValue(806, out _phrase806))
             {
                 _phrase806 = " you have received the starting items. Check your inventory. If full, check the ground.";
             }
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase806 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in GiveStartingItemsConsole.Send: {0}", e));
     }
 }
コード例 #18
0
        public static void Exec(ClientInfo _cInfo)
        {
            World world = GameManager.Instance.World;

            foreach (KeyValuePair <string, int[]> kvp in startItemList)
            {
                ItemValue itemValue;
                var       itemId = 4096;
                int       _itemId;
                if (int.TryParse(kvp.Key, out _itemId))
                {
                    int calc = (_itemId + 4096);
                    itemId    = calc;
                    itemValue = ItemClass.list[itemId] == null ? ItemValue.None : new ItemValue(itemId, kvp.Value[1], kvp.Value[1], true);
                }
                else
                {
                    if (!ItemClass.ItemNames.Contains(kvp.Key))
                    {
                        Log.Out(string.Format("[SERVERTOOLS] Unable to find item {0} for Starting_Items", kvp.Key));
                    }

                    itemValue = new ItemValue(ItemClass.GetItem(kvp.Key).type, kvp.Value[1], kvp.Value[1], true);
                }

                if (Equals(itemValue, ItemValue.None))
                {
                    Log.Out(string.Format("[SERVERTOOLS] Unable to find item {0} for Starting_Items", kvp.Key));
                }
                var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                {
                    entityClass     = EntityClass.FromString("item"),
                    id              = EntityFactory.nextEntityID++,
                    itemStack       = new ItemStack(itemValue, kvp.Value[0]),
                    pos             = world.Players.dict[_cInfo.entityId].position,
                    rot             = new Vector3(20f, 0f, 20f),
                    lifetime        = 60f,
                    belongsPlayerId = _cInfo.entityId
                });
                world.SpawnEntityInWorld(entityItem);
                _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                Log.Out(string.Format("[SERVERTOOLS] Spawned starting item {0} for {1}", itemValue.ItemClass.localizedName ?? itemValue.ItemClass.Name, _cInfo.playerName));
            }
            PersistentContainer.Instance.Players[_cInfo.playerId, true].StartingItems = true;
            PersistentContainer.Instance.Save();
        }
コード例 #19
0
 public static void ShopPurchase(ClientInfo _cInfo, string _itemName, string _secondaryName, int _count, int _quality, int _price)
 {
     try
     {
         World     world     = GameManager.Instance.World;
         ItemValue itemValue = new ItemValue(ItemClass.GetItem(_itemName).type);
         if (itemValue.HasQuality)
         {
             itemValue.Quality = 1;
             if (_quality > 0)
             {
                 itemValue.Quality = _quality;
             }
         }
         var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
         {
             entityClass     = EntityClass.FromString("item"),
             id              = EntityFactory.nextEntityID++,
             itemStack       = new ItemStack(itemValue, _count),
             pos             = world.Players.dict[_cInfo.entityId].position,
             rot             = new Vector3(20f, 0f, 20f),
             lifetime        = 60f,
             belongsPlayerId = _cInfo.entityId
         });
         world.SpawnEntityInWorld(entityItem);
         _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
         world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
         Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, _price);
         Log.Out(string.Format("Sold '{0}' to '{1}' '{2}' named '{3}' through the shop", itemValue.ItemClass.Name, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName));
         Phrases.Dict.TryGetValue("Shop16", out string _phrase);
         _phrase = _phrase.Replace("{Count}", _count.ToString());
         if (_secondaryName != "")
         {
             _phrase = _phrase.Replace("{Item}", _secondaryName);
         }
         else
         {
             _phrase = _phrase.Replace("{Item}", itemValue.ItemClass.GetLocalizedItemName() ?? itemValue.ItemClass.GetItemName());
         }
         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Shop.ShopPurchase: {0}", e.Message));
     }
 }
コード例 #20
0
    public void SpawnFromGroup(String strGroup, int Count)
    {
        int EntityID = -1;

        for (int x = 0; x < this.MaxSpawn; x++)
        {
            // Verify that it's an entity group or individual entity.. just in case.
            if (EntityGroups.list.ContainsKey(strGroup))
            {
                DisplayLog(" Spawning from : " + strGroup);
                EntityID = EntityGroups.GetRandomFromGroup(strGroup);
                SpawnEntity(EntityID, false);
            }
            else
            {
                SpawnEntity(EntityClass.FromString(strGroup), false);
            }
        }
    }
コード例 #21
0
 private static void RandomItem(ClientInfo _cInfo)
 {
     try
     {
         string    _randomItem = list.RandomObject();
         ItemValue _itemValue  = new ItemValue(ItemClass.GetItem(_randomItem, false).type, false);
         int[]     _itemData;
         if (Dict.TryGetValue(_randomItem, out _itemData))
         {
             int _count = 0;
             if (_itemData[0] > _itemData[1])
             {
                 _count = random.Next(_itemData[1], _itemData[0] + 1);
             }
             else
             {
                 _count = random.Next(_itemData[0], _itemData[1] + 1);
             }
             if (_itemValue.HasQuality && _itemData[2] > 0 && _itemData[3] >= _itemData[2])
             {
                 _itemValue.Quality = random.Next(_itemData[2], _itemData[3] + 1);
             }
             World world      = GameManager.Instance.World;
             var   entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
             {
                 entityClass     = EntityClass.FromString("item"),
                 id              = EntityFactory.nextEntityID++,
                 itemStack       = new ItemStack(_itemValue, _count),
                 pos             = world.Players.dict[_cInfo.entityId].position,
                 rot             = new Vector3(20f, 0f, 20f),
                 lifetime        = 60f,
                 belongsPlayerId = _cInfo.entityId
             });
             world.SpawnEntityInWorld(entityItem);
             _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
             world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.RandomItem: {0}", e.Message));
     }
 }
コード例 #22
0
        public static void ReturnItem(ClientInfo _cInfo)
        {
            foreach (ItemStack _item in _stacks)
            {
                ItemValue _itemValue = _item.itemValue;
                if (_itemValue != null && !_itemValue.Equals(ItemValue.None))
                {
                    int _quality = 1;
                    if (_itemValue.HasQuality)
                    {
                        _quality = _itemValue.Quality;
                    }
                    string    _itemName = ItemClass.list[_itemValue.type].GetItemName();
                    ItemValue itemValue = new ItemValue(ItemClass.GetItem(_itemName).type, _quality, _quality, true);
                    World     world     = GameManager.Instance.World;
                    if (world.Players.dict[_cInfo.entityId].IsSpawned())
                    {
                        var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                        {
                            entityClass     = EntityClass.FromString("item"),
                            id              = EntityFactory.nextEntityID++,
                            itemStack       = new ItemStack(itemValue, _item.count),
                            pos             = world.Players.dict[_cInfo.entityId].position,
                            rot             = new Vector3(20f, 0f, 20f),
                            lifetime        = 60f,
                            belongsPlayerId = _cInfo.entityId
                        });
                        world.SpawnEntityInWorld(entityItem);
                        _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                        world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                    }
                }
            }
            string _phrase770;

            if (!Phrases.Dict.TryGetValue(770, out _phrase770))
            {
                _phrase770 = "The items from your dropped bag were sent to your inventory. If your bag is full, check the ground.";
            }
            _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase770), Config.Server_Response_Name, false, "ServerTools", false));
            LastBagPos.Remove(_cInfo.entityId);
            Que();
        }
コード例 #23
0
ファイル: Shop.cs プロジェクト: JustinByrne/7dtd-ServerTools
        public static void ShopPurchase(ClientInfo _cInfo, string _itemName, string _secondaryName, int _count, int _quality, int _price, int currentCoins)
        {
            World     world       = GameManager.Instance.World;
            ItemValue _itemValue  = new ItemValue(ItemClass.GetItem(_itemName).type, _quality, _quality, false, null, 1);
            int       _maxAllowed = _itemValue.ItemClass.Stacknumber.Value;

            if (_count <= _maxAllowed)
            {
                var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                {
                    entityClass     = EntityClass.FromString("item"),
                    id              = EntityFactory.nextEntityID++,
                    itemStack       = new ItemStack(_itemValue, _count),
                    pos             = world.Players.dict[_cInfo.entityId].position,
                    rot             = new Vector3(20f, 0f, 20f),
                    lifetime        = 60f,
                    belongsPlayerId = _cInfo.entityId
                });
                world.SpawnEntityInWorld(entityItem);
                _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
                Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _price);
                Log.Out(string.Format("Sold {0} to {1}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name, _cInfo.playerName));
                string _message = "{Count} {Item} was purchased through the shop. If your bag is full, check the ground.";
                _message = _message.Replace("{Count}", _count.ToString());
                if (_secondaryName != "")
                {
                    _message = _message.Replace("{Item}", _secondaryName);
                }
                else
                {
                    _message = _message.Replace("{Item}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name);
                }
                ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            else
            {
                string _message = "You can only purchase a full stack worth at a time. The maximum stack size for this is {Max}.";
                _message = _message.Replace("{Max}", _maxAllowed.ToString());
                ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
        }
コード例 #24
0
        public static void firstClaim(ClientInfo _cInfo)
        {
            string    _sql    = string.Format("SELECT firstClaim FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
            DataTable _result = SQL.TQuery(_sql);
            bool      _firstClaim;

            bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _firstClaim);
            _result.Dispose();
            if (!_firstClaim)
            {
                World     world      = GameManager.Instance.World;
                string    claimBlock = "keystoneBlock";
                ItemValue itemValue;
                itemValue = new ItemValue(ItemClass.GetItem(claimBlock).type, 1, 1, true);

                if (Equals(itemValue, ItemValue.None))
                {
                    SdtdConsole.Instance.Output(string.Format("Unable to find block {0} for /claim command", claimBlock));
                }
                var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                {
                    entityClass     = EntityClass.FromString("item"),
                    id              = EntityFactory.nextEntityID++,
                    itemStack       = new ItemStack(itemValue, 1),
                    pos             = world.Players.dict[_cInfo.entityId].position,
                    rot             = new Vector3(20f, 0f, 20f),
                    lifetime        = 60f,
                    belongsPlayerId = _cInfo.entityId
                });
                world.SpawnEntityInWorld(entityItem);
                _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", claim block has been added to your inventory or if inventory is full, it dropped at your feet.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
                _sql = string.Format("UPDATE Players SET firstClaim = 'true' WHERE steamid = '{0}'", _cInfo.playerId);
                SQL.FastQuery(_sql);
            }
            else
            {
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have already received your first claim block. Contact an administrator if you require help.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
            }
        }
コード例 #25
0
 public static void SpawnItems(ClientInfo _cInfo)
 {
     try
     {
         World         world     = GameManager.Instance.World;
         List <string> _itemList = StartingItems.ItemList.Keys.ToList();
         for (int i = 0; i < _itemList.Count; i++)
         {
             string _item = _itemList[i];
             int[]  _itemData;
             StartingItems.ItemList.TryGetValue(_item, out _itemData);
             ItemValue _itemValue = new ItemValue(ItemClass.GetItem(_item, false).type, false);
             if (_itemValue.HasQuality && _itemData[1] > 0)
             {
                 _itemValue.Quality = _itemData[1];
             }
             EntityItem entityItem = new EntityItem();
             entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
             {
                 entityClass     = EntityClass.FromString("item"),
                 id              = EntityFactory.nextEntityID++,
                 itemStack       = new ItemStack(_itemValue, _itemData[0]),
                 pos             = world.Players.dict[_cInfo.entityId].position,
                 rot             = new Vector3(20f, 0f, 20f),
                 lifetime        = 60f,
                 belongsPlayerId = _cInfo.entityId
             });
             world.SpawnEntityInWorld(entityItem);
             _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
             world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
             Log.Out(string.Format("[SERVERTOOLS] Spawned starting item {0} for {1} with steam id {2}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name, _cInfo.playerName, _cInfo.playerId));
             PersistentContainer.Instance.Players[_cInfo.playerId].StartingItems = true;
             PersistentContainer.Instance.Save();
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in StartingItems.SpawnItems: {0}.", e.Message));
     }
 }
コード例 #26
0
    // spawns a children next to the parent.
    private void SpawnFlock()
    {
        if (DateTime.Now < dtaNextSpawn)
        {
            return;
        }
        // spawn them right by the parent
        // separates the spawning a few miliseconds just to avoid overlapping
        Vector3 newPos = this.position + Vector3.up;

        if (debug)
        {
            Debug.Log("SPAWNING CHILDREN FOR ID " + this.entityId);
        }

        Debug.Log("Creating entity");

        int intIndex  = UnityEngine.Random.Range(0, this.strFlockEntities.Length - 1);
        int intEntity = EntityClass.FromString(this.strFlockEntities[intIndex]);

        Debug.Log("Spawning: " + this.strFlockEntities[intIndex]);
        //Entity spawnEntity = EntityFactory.CreateEntity(EntityClass.FromString(this.EntityName), newPos);
        Entity spawnEntity = EntityFactory.CreateEntity(intEntity, newPos);

        spawnEntity.SetSpawnerSource(EnumSpawnerSource.Unknown);
        Debug.Log("Spawning entity");
        GameManager.Instance.World.SpawnEntityInWorld(spawnEntity);

        (spawnEntity as EntityZombieFlockSDX).setMasterEntity(this as EntityAlive);
        // flying entities spawning is a bit odd, so we "override" the position to where we want the children to be
        // which is by its parent
        spawnEntity.position = newPos;
        numberSpawned++;
        if (numberSpawned > maxToSpawn)
        {
            hasFlock = true;
        }
        dtaNextSpawn = DateTime.Now.AddMilliseconds(50);
    }
コード例 #27
0
ファイル: VoteReward.cs プロジェクト: Mink80/7dtd-ServerTools
        private static void Give(ClientInfo _cInfo, ItemValue _itemValue, int _count)
        {
            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];

            if (_player.IsSpawned())
            {
                World world      = GameManager.Instance.World;
                var   entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                {
                    entityClass     = EntityClass.FromString("item"),
                    id              = EntityFactory.nextEntityID++,
                    itemStack       = new ItemStack(_itemValue, _count),
                    pos             = world.Players.dict[_cInfo.entityId].position,
                    rot             = new Vector3(20f, 0f, 20f),
                    lifetime        = 60f,
                    belongsPlayerId = _cInfo.entityId
                });
                world.SpawnEntityInWorld(entityItem);
                _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
            }
        }
コード例 #28
0
        public static void FirstClaim(ClientInfo _cInfo)
        {
            bool _firstClaim = PersistentContainer.Instance.Players[_cInfo.playerId].FirstClaimBlock;

            if (!_firstClaim)
            {
                World     world      = GameManager.Instance.World;
                string    claimBlock = "keystoneBlock";
                ItemValue itemValue;
                itemValue = new ItemValue(ItemClass.GetItem(claimBlock).type, 1, 1, true);

                if (Equals(itemValue, ItemValue.None))
                {
                    SdtdConsole.Instance.Output(string.Format("Unable to find block {0} for /{1} command", claimBlock, Command32));
                }
                var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                {
                    entityClass     = EntityClass.FromString("item"),
                    id              = EntityFactory.nextEntityID++,
                    itemStack       = new ItemStack(itemValue, 1),
                    pos             = world.Players.dict[_cInfo.entityId].position,
                    rot             = new Vector3(20f, 0f, 20f),
                    lifetime        = 60f,
                    belongsPlayerId = _cInfo.entityId
                });
                world.SpawnEntityInWorld(entityItem);
                _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
                PersistentContainer.Instance.Players[_cInfo.playerId].FirstClaimBlock = true;
                PersistentContainer.DataChange = true;
                Phrases.Dict.TryGetValue(701, out string _phrase701);
                ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase701 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
            }
            else
            {
                Phrases.Dict.TryGetValue(702, out string _phrase702);
                ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase702 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
            }
        }
コード例 #29
0
        public static void ShopPurchase(ClientInfo _cInfo, string _itemName, int _count, int _quality, int _price, string _playerName, int currentCoins, Player p)
        {
            World     world      = GameManager.Instance.World;
            ItemValue _itemValue = ItemClass.GetItem(_itemName, true);

            if (_itemValue.type != ItemValue.None.type)
            {
                ItemValue itemValue  = new ItemValue(ItemClass.GetItem(_itemName).type, _quality, _quality, true);
                var       entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                {
                    entityClass     = EntityClass.FromString("item"),
                    id              = EntityFactory.nextEntityID++,
                    itemStack       = new ItemStack(itemValue, _count),
                    pos             = world.Players.dict[_cInfo.entityId].position,
                    rot             = new Vector3(20f, 0f, 20f),
                    lifetime        = 60f,
                    belongsPlayerId = _cInfo.entityId
                });
                world.SpawnEntityInWorld(entityItem);
                _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                SdtdConsole.Instance.Output(string.Format("Sold {0} to {1}.", itemValue.ItemClass.localizedName ?? itemValue.ItemClass.Name, _cInfo.playerName));
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} {2} was purchased through the shop. If your bag is full, check the ground.[-]", Config.Chat_Response_Color, _count, itemValue.ItemClass.localizedName ?? itemValue.ItemClass.Name), Config.Server_Response_Name, false, "ServerTools", false));
                int newCoins = p.PlayerSpentCoins - _price;
                PersistentContainer.Instance.Players[_cInfo.playerId, true].PlayerSpentCoins = newCoins;
                PersistentContainer.Instance.Save();
            }
            else
            {
                string _phrase623;
                if (!Phrases.Dict.TryGetValue(623, out _phrase623))
                {
                    _phrase623 = "{PlayerName} there was an error in the shop list. Unable to buy this item. Please alert an administrator.";
                    Log.Out(string.Format("Player {0} tried to buy item {1} from the shop. The item name in the Market.xml does not match an existing item. Check your Item.xml for the correct item name. It is case sensitive.", _cInfo.playerName, _itemName));
                }
                _phrase623 = _phrase623.Replace("{PlayerName}", _playerName);
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase623), Config.Server_Response_Name, false, "ServerTools", false));
            }
        }
コード例 #30
0
        public static void firstClaim(ClientInfo _cInfo)
        {
            World  world = GameManager.Instance.World;
            Player p     = PersistentContainer.Instance.Players[_cInfo.playerId, false];

            if (p == null || !p.FirstClaim)
            {
                string    claimBlock = "keystoneBlock";
                ItemValue itemValue;
                itemValue = new ItemValue(ItemClass.GetItem(claimBlock).type, 1, 1, true);

                if (Equals(itemValue, ItemValue.None))
                {
                    SdtdConsole.Instance.Output(string.Format("Unable to find block {0} for /claim command", claimBlock));
                }
                var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                {
                    entityClass     = EntityClass.FromString("item"),
                    id              = EntityFactory.nextEntityID++,
                    itemStack       = new ItemStack(itemValue, 1),
                    pos             = world.Players.dict[_cInfo.entityId].position,
                    rot             = new Vector3(20f, 0f, 20f),
                    lifetime        = 60f,
                    belongsPlayerId = _cInfo.entityId
                });
                world.SpawnEntityInWorld(entityItem);
                _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Claim block has been added to your inventory or if inventory is full, it dropped at your feet.[-]", Config.Chat_Response_Color), Config.Server_Response_Name, false, "ServerTools", false));
                PersistentContainer.Instance.Players[_cInfo.playerId, true].FirstClaim = true;
                PersistentContainer.Instance.Save();
            }
            else
            {
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}You have already received your first claim block. Contact an administrator if you require help.[-]", Config.Chat_Response_Color), Config.Server_Response_Name, false, "ServerTools", false));
            }
        }