Esempio n. 1
0
        public static void Packet_StartCraft(int index, ref byte[] data)
        {
            int        recipeindex;
            int        amount;
            ByteStream buffer = new ByteStream(data);

            S_General.AddDebug("Recieved CMSG: CStartCraft");

            recipeindex = buffer.ReadInt32();
            amount      = buffer.ReadInt32();

            if (modTypes.TempPlayer[index].IsCrafting == false)
            {
                return;
            }

            if (recipeindex == 0 || amount == 0)
            {
                return;
            }

            if (!CheckLearnedRecipe(index, recipeindex))
            {
                return;
            }

            StartCraft(index, recipeindex, amount);

            buffer.Dispose();
        }
Esempio n. 2
0
        public static void SendResourceCacheTo(int index, int Resource_num)
        {
            int        i;
            int        mapnum;
            ByteStream buffer = new ByteStream(4);

            mapnum = S_Players.GetPlayerMap(index);

            buffer.WriteInt32((int)Packets.ServerPackets.SResourceCache);
            buffer.WriteInt32(ResourceCache[mapnum].ResourceCount);

            S_General.AddDebug("Sent SMSG: SResourcesCache");

            if (ResourceCache[mapnum].ResourceCount > 0)
            {
                var loopTo = ResourceCache[mapnum].ResourceCount;
                for (i = 0; i <= loopTo; i++)
                {
                    buffer.WriteInt32(ResourceCache[mapnum].ResourceData[i].ResourceState);
                    buffer.WriteInt32(ResourceCache[mapnum].ResourceData[i].X);
                    buffer.WriteInt32(ResourceCache[mapnum].ResourceData[i].Y);
                }
            }

            S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head);
            buffer.Dispose();
        }
Esempio n. 3
0
        internal static void UpdateCraft(int index)
        {
            int i;

            // ok, we made the item, give and take the shit
            if (S_Players.GiveInvItem(index, Recipe[modTypes.TempPlayer[index].CraftRecipe].MakeItemNum, Recipe[modTypes.TempPlayer[index].CraftRecipe].MakeItemAmount, true))
            {
                for (i = 1; i <= Constants.MAX_INGREDIENT; i++)
                {
                    S_Players.TakeInvItem(index, Recipe[modTypes.TempPlayer[index].CraftRecipe].Ingredients[i].ItemNum, Recipe[modTypes.TempPlayer[index].CraftRecipe].Ingredients[i].Value);
                }
                S_NetworkSend.PlayerMsg(index, "You created " + Microsoft.VisualBasic.Strings.Trim(Types.Item[Recipe[modTypes.TempPlayer[index].CraftRecipe].MakeItemNum].Name) + " X " + Recipe[modTypes.TempPlayer[index].CraftRecipe].MakeItemAmount, (int)Enums.ColorType.BrightGreen);
            }
            ;

            if (modTypes.TempPlayer[index].IsCrafting)
            {
                modTypes.TempPlayer[index].CraftAmount = modTypes.TempPlayer[index].CraftAmount - 1;

                if (modTypes.TempPlayer[index].CraftAmount > 0)
                {
                    modTypes.TempPlayer[index].CraftTimer      = S_General.GetTimeMs();
                    modTypes.TempPlayer[index].CraftTimeNeeded = Recipe[modTypes.TempPlayer[index].CraftRecipe].CreateTime;
                    modTypes.TempPlayer[index].CraftIt         = 1;
                    SendCraftUpdate(index, 0);
                }
                SendCraftUpdate(index, 1);
            }
        }
Esempio n. 4
0
        public static void SendUpdateRecipeToAll(int RecipeNum)
        {
            ByteStream buffer;

            buffer = new ByteStream(4);
            buffer.WriteInt32((int)Packets.ServerPackets.SUpdateRecipe);
            buffer.WriteInt32(RecipeNum);

            S_General.AddDebug("Sent SMSG: SUpdateRecipe To All");

            buffer.WriteString((Microsoft.VisualBasic.Strings.Trim(Recipe[RecipeNum].Name)));
            buffer.WriteInt32(Recipe[RecipeNum].RecipeType);
            buffer.WriteInt32(Recipe[RecipeNum].MakeItemNum);
            buffer.WriteInt32(Recipe[RecipeNum].MakeItemAmount);

            for (var i = 1; i <= Constants.MAX_INGREDIENT; i++)
            {
                buffer.WriteInt32(Recipe[RecipeNum].Ingredients[i].ItemNum);
                buffer.WriteInt32(Recipe[RecipeNum].Ingredients[i].Value);
            }

            buffer.WriteInt32(Recipe[RecipeNum].CreateTime);

            S_NetworkConfig.SendDataToAll(ref buffer.Data, buffer.Head);

            buffer.Dispose();
        }
        public static void SendUpdateAnimationToAll(int AnimationNum)
        {
            ByteStream buffer = new ByteStream(4);

            buffer.WriteInt32((int)Packets.ServerPackets.SUpdateAnimation);

            buffer.WriteBlock(AnimationData(AnimationNum));

            // buffer.WriteInt32(AnimationNum)

            // For i = 0 To UBound(Animation(AnimationNum).Frames)
            // buffer.WriteInt32(Animation(AnimationNum).Frames(i))
            // Next

            // For i = 0 To UBound(Animation(AnimationNum).LoopCount)
            // buffer.WriteInt32(Animation(AnimationNum).LoopCount(i))
            // Next

            // For i = 0 To UBound(Animation(AnimationNum).LoopTime)
            // buffer.WriteInt32(Animation(AnimationNum).LoopTime(i))
            // Next

            // buffer.WriteString((Animation(AnimationNum).Name))
            // buffer.WriteString((Animation(AnimationNum).Sound))

            // For i = 0 To UBound(Animation(AnimationNum).Sprite)
            // buffer.WriteInt32(Animation(AnimationNum).Sprite(i))
            // Next

            S_General.AddDebug("Sent SMSG: SUpdateAnimation To All");

            S_NetworkConfig.SendDataToAll(ref buffer.Data, buffer.Head);
            buffer.Dispose();
        }
Esempio n. 6
0
        public static void Main()
        {
            threadConsole = new Thread(new ThreadStart(ConsoleThread));
            threadConsole.Start();

            // Spin up the server on the main thread
            S_General.InitServer();
        }
        public static void Packet_SaveAnimation(int index, ref byte[] data)
        {
            int        AnimNum;
            ByteStream buffer = new ByteStream(data);

            S_General.AddDebug("Recieved EMSG: SaveAnimation");

            AnimNum = buffer.ReadInt32();
            var loopTo = Information.UBound(Types.Animation[AnimNum].Frames);

            // Update the Animation
            for (var i = 0; i <= loopTo; i++)
            {
                Types.Animation[AnimNum].Frames[i] = buffer.ReadInt32();
            }
            var loopTo1 = Information.UBound(Types.Animation[AnimNum].LoopCount);

            for (int i = 0; i <= loopTo1; i++)
            {
                Types.Animation[AnimNum].LoopCount[i] = buffer.ReadInt32();
            }
            var loopTo2 = Information.UBound(Types.Animation[AnimNum].LoopTime);

            for (int i = 0; i <= loopTo2; i++)
            {
                Types.Animation[AnimNum].LoopTime[i] = buffer.ReadInt32();
            }

            Types.Animation[AnimNum].Name  = buffer.ReadString();
            Types.Animation[AnimNum].Sound = buffer.ReadString();

            if (Types.Animation[AnimNum].Name == null)
            {
                Types.Animation[AnimNum].Name = "";
            }
            if (Types.Animation[AnimNum].Sound == null)
            {
                Types.Animation[AnimNum].Sound = "";
            }
            var loopTo3 = Information.UBound(Types.Animation[AnimNum].Sprite);

            for (var i = 0; i <= loopTo3; i++)
            {
                Types.Animation[AnimNum].Sprite[i] = buffer.ReadInt32();
            }

            buffer.Dispose();

            // Save it
            SaveAnimation(AnimNum);
            SendUpdateAnimationToAll(AnimNum);
            modDatabase.Addlog(S_Players.GetPlayerLogin(index) + " saved Animation #" + AnimNum + ".", S_Constants.ADMIN_LOG);
        }
Esempio n. 8
0
        internal static void PlayerFireProjectile(int index, int IsSkill = 0)
        {
            int ProjectileSlot = 0;
            int ProjectileNum  = 0;
            int mapNum         = 0;
            int i = 0;

            mapNum = S_Players.GetPlayerMap(index);

            // Find a free projectile
            for (i = 1; i <= MAX_PROJECTILES; i++)
            {
                if (MapProjectiles[mapNum, i].ProjectileNum == 0)
                {
                    ProjectileSlot = i;
                    break;
                }
            }

            // Check for no projectile, if so just overwrite the first slot
            if (ProjectileSlot == 0)
            {
                ProjectileSlot = 1;
            }

            // Check for skill, if so then load data acordingly
            if (IsSkill > 0)
            {
                ProjectileNum = Types.Skill[IsSkill].Projectile;
            }
            else
            {
                ProjectileNum = Types.Item[S_Players.GetPlayerEquipment(index, Enums.EquipmentType.Weapon)].Projectile;
            }

            if (ProjectileNum == 0)
            {
                return;
            }

            {
                MapProjectiles[mapNum, ProjectileSlot].ProjectileNum = ProjectileNum;
                MapProjectiles[mapNum, ProjectileSlot].Owner         = index;
                MapProjectiles[mapNum, ProjectileSlot].OwnerType     = (byte)Enums.TargetType.Player;
                MapProjectiles[mapNum, ProjectileSlot].Dir           = (byte)S_Players.GetPlayerDir(index);
                MapProjectiles[mapNum, ProjectileSlot].X             = S_Players.GetPlayerX(index);
                MapProjectiles[mapNum, ProjectileSlot].Y             = S_Players.GetPlayerY(index);
                MapProjectiles[mapNum, ProjectileSlot].Timer         = S_General.GetTimeMs() + 60000;
            }

            SendProjectileToMap(mapNum, ProjectileSlot);
        }
Esempio n. 9
0
        public static void SendOpenCraft(int index)
        {
            ByteStream buffer;

            buffer = new ByteStream(4);
            buffer.WriteInt32((int)Packets.ServerPackets.SOpenCraft);

            S_General.AddDebug("Sent SMSG: SOpenCraft");

            S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head);

            buffer.Dispose();
        }
Esempio n. 10
0
        internal static void StartCraft(int index, int RecipeNum, int Amount)
        {
            if (modTypes.TempPlayer[index].IsCrafting)
            {
                modTypes.TempPlayer[index].CraftRecipe = RecipeNum;
                modTypes.TempPlayer[index].CraftAmount = Amount;

                modTypes.TempPlayer[index].CraftTimer      = S_General.GetTimeMs();
                modTypes.TempPlayer[index].CraftTimeNeeded = Recipe[RecipeNum].CreateTime;

                modTypes.TempPlayer[index].CraftIt = 1;
            }
        }
Esempio n. 11
0
        public static void SendUpdateResourceToAll(int ResourceNum)
        {
            ByteStream buffer = new ByteStream(4);

            buffer.WriteInt32((int)Packets.ServerPackets.SUpdateResource);

            buffer.WriteBlock(ResourceData(ResourceNum));

            S_General.AddDebug("Sent SMSG: SUpdateResource");

            S_NetworkConfig.SendDataToAll(ref buffer.Data, buffer.Head);
            buffer.Dispose();
        }
Esempio n. 12
0
        public static void SendTimeTo(int index)
        {
            ByteStream buffer = new ByteStream(4);

            buffer.WriteInt32((int)Packets.ServerPackets.STime);
            buffer.WriteByte((byte)Time.Instance.TimeOfDay);
            S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head);

            S_General.AddDebug("Sent SMSG: STime");

            S_General.AddDebug(" Player: " + S_Players.GetPlayerName(index) + " : " + " Time Of Day: " + Time.Instance.TimeOfDay);

            buffer.Dispose();
        }
Esempio n. 13
0
        public static void SendUpdateItemToAll(int itemNum)
        {
            ByteStream buffer;

            buffer = new ByteStream(4);
            buffer.WriteInt32((byte)Packets.ServerPackets.SUpdateItem);

            buffer.WriteBlock(ItemData(itemNum));

            S_General.AddDebug("Sent SMSG: SUpdateItem To All");

            S_NetworkConfig.SendDataToAll(ref buffer.Data, buffer.Head);
            buffer.Dispose();
        }
Esempio n. 14
0
        public static void SendGameClockTo(int index)
        {
            ByteStream buffer = new ByteStream(4);

            buffer.WriteInt32((int)Packets.ServerPackets.SClock);
            buffer.WriteInt32((int)Time.Instance.GameSpeed);
            buffer.WriteBytes(BitConverter.GetBytes(Time.Instance._Time.Ticks));
            S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head);

            S_General.AddDebug("Sent SMSG: SClock");

            S_General.AddDebug(" Player: " + S_Players.GetPlayerName(index) + " : " + " GameSpeed: " + Time.Instance.GameSpeed + " Instance Time Ticks: " + Time.Instance._Time.Ticks);

            buffer.Dispose();
        }
Esempio n. 15
0
        // Token: 0x060001DD RID: 477 RVA: 0x0003A20C File Offset: 0x0003840C
        public static void Packet_AcceptInvite(int index, ref byte[] data)
        {
            ByteStream buffer   = new ByteStream(data);
            int        response = buffer.ReadInt32();

            buffer.Dispose();
            bool flag = response == 1;

            if (flag)
            {
                bool flag2 = modTypes.TempPlayer[index].Invitationindex > 0;
                if (flag2)
                {
                    bool flag3 = modTypes.TempPlayer[index].InvitationTimer > S_General.GetTimeMs();
                    if (flag3)
                    {
                        bool flag4 = S_NetworkConfig.IsPlaying(modTypes.TempPlayer[index].Invitationindex);
                        if (flag4)
                        {
                            modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse = modTypes.TempPlayer[index].Invitationindex;
                            modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].LastX   = S_Players.GetPlayerX(index);
                            modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].LastY   = S_Players.GetPlayerY(index);
                            modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].LastMap = S_Players.GetPlayerMap(index);
                            modTypes.TempPlayer[index].InvitationTimer = 0;
                            S_Players.PlayerWarp(index, modTypes.Player[modTypes.TempPlayer[index].Invitationindex].Character[(int)modTypes.TempPlayer[index].CurChar].Map, S_Housing.HouseConfig[modTypes.Player[modTypes.TempPlayer[index].Invitationindex].Character[(int)modTypes.TempPlayer[modTypes.TempPlayer[index].Invitationindex].CurChar].House.Houseindex].X, S_Housing.HouseConfig[modTypes.Player[modTypes.TempPlayer[index].Invitationindex].Character[(int)modTypes.TempPlayer[modTypes.TempPlayer[index].Invitationindex].CurChar].House.Houseindex].Y, true, true);
                        }
                        else
                        {
                            modTypes.TempPlayer[index].InvitationTimer = 0;
                            S_NetworkSend.PlayerMsg(index, "Cannot find player!", 12);
                        }
                    }
                    else
                    {
                        S_NetworkSend.PlayerMsg(index, "Your invitation has expired, have your friend re-invite you.", 14);
                    }
                }
            }
            else
            {
                bool flag5 = S_NetworkConfig.IsPlaying(modTypes.TempPlayer[index].Invitationindex);
                if (flag5)
                {
                    modTypes.TempPlayer[index].InvitationTimer = 0;
                    S_NetworkSend.PlayerMsg(modTypes.TempPlayer[index].Invitationindex, (S_Players.GetPlayerName(index).Trim()) + " rejected your invitation", 12);
                }
            }
        }
Esempio n. 16
0
        public static void Packet_EditAnimation(int index, ref byte[] data)
        {
            S_General.AddDebug("Recieved EMSG: RequestEditAnimation");

            // Prevent hacking
            if (S_Players.GetPlayerAccess(index) < (int)Enums.AdminType.Developer)
            {
                return;
            }

            var Buffer = new ByteStream(4);

            Buffer.WriteInt32((int)Packets.ServerPackets.SAnimationEditor);
            S_NetworkConfig.Socket.SendDataTo(index, Buffer.Data, Buffer.Head);
            Buffer.Dispose();
        }
Esempio n. 17
0
        public static void SendAnimation(int mapNum, int Anim, int X, int Y, byte LockType = 0, int Lockindex = 0)
        {
            ByteStream buffer = new ByteStream(4);

            buffer.WriteInt32((int)Packets.ServerPackets.SAnimation);
            buffer.WriteInt32(Anim);
            buffer.WriteInt32(X);
            buffer.WriteInt32(Y);
            buffer.WriteInt32(LockType);
            buffer.WriteInt32(Lockindex);

            S_General.AddDebug("Sent SMSG: SAnimation");

            S_NetworkConfig.SendDataToMap(mapNum, ref buffer.Data, buffer.Head);

            buffer.Dispose();
        }
Esempio n. 18
0
        public static void Packet_SaveResource(int index, ref byte[] data)
        {
            int        resourcenum;
            ByteStream buffer = new ByteStream(data);

            S_General.AddDebug("Recieved EMSG: SaveResource");

            // Prevent hacking
            if (S_Players.GetPlayerAccess(index) < (int)Enums.AdminType.Developer)
            {
                return;
            }

            resourcenum = buffer.ReadInt32();

            // Prevent hacking
            if (resourcenum <= 0 || resourcenum > Constants.MAX_RESOURCES)
            {
                return;
            }

            Types.Resource[resourcenum].Animation      = buffer.ReadInt32();
            Types.Resource[resourcenum].EmptyMessage   = buffer.ReadString();
            Types.Resource[resourcenum].ExhaustedImage = buffer.ReadInt32();
            Types.Resource[resourcenum].Health         = buffer.ReadInt32();
            Types.Resource[resourcenum].ExpReward      = buffer.ReadInt32();
            Types.Resource[resourcenum].ItemReward     = buffer.ReadInt32();
            Types.Resource[resourcenum].Name           = buffer.ReadString();
            Types.Resource[resourcenum].ResourceImage  = buffer.ReadInt32();
            Types.Resource[resourcenum].ResourceType   = buffer.ReadInt32();
            Types.Resource[resourcenum].RespawnTime    = buffer.ReadInt32();
            Types.Resource[resourcenum].SuccessMessage = buffer.ReadString();
            Types.Resource[resourcenum].LvlRequired    = buffer.ReadInt32();
            Types.Resource[resourcenum].ToolRequired   = buffer.ReadInt32();
            Types.Resource[resourcenum].Walkthrough    = Convert.ToBoolean(buffer.ReadInt32());

            // Save it
            SendUpdateResourceToAll(resourcenum);
            SaveResource(resourcenum);

            modDatabase.Addlog(S_Players.GetPlayerLogin(index) + " saved Resource #" + resourcenum + ".", S_Constants.ADMIN_LOG);

            buffer.Dispose();
        }
Esempio n. 19
0
        public static void SendPlayerRecipes(int index)
        {
            int        i;
            ByteStream buffer;

            buffer = new ByteStream(4);
            buffer.WriteInt32((int)Packets.ServerPackets.SSendPlayerRecipe);

            S_General.AddDebug("Sent SMSG: SSendPlayerRecipe");

            for (i = 1; i <= Constants.MAX_RECIPE; i++)
            {
                buffer.WriteInt32(modTypes.Player[index].Character[modTypes.TempPlayer[index].CurChar].RecipeLearned[i]);
            }

            S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head);

            buffer.Dispose();
        }
Esempio n. 20
0
        public static void Packet_SaveRecipe(int index, ref byte[] data)
        {
            int n;

            // Prevent hacking
            if (S_Players.GetPlayerAccess(index) < (int)Enums.AdminType.Developer)
            {
                return;
            }
            ByteStream buffer = new ByteStream(data);

            S_General.AddDebug("Recieved EMSG: SaveRecipe");

            // recipe index
            n = buffer.ReadInt32();

            // Update the Recipe
            Recipe[n].Name           = buffer.ReadString();
            Recipe[n].RecipeType     = (byte)buffer.ReadInt32();
            Recipe[n].MakeItemNum    = buffer.ReadInt32();
            Recipe[n].MakeItemAmount = buffer.ReadInt32();

            for (var i = 1; i <= Constants.MAX_INGREDIENT; i++)
            {
                Recipe[n].Ingredients[i].ItemNum = buffer.ReadInt32();
                Recipe[n].Ingredients[i].Value   = buffer.ReadInt32();
            }

            Recipe[n].CreateTime = (byte)buffer.ReadInt32();

            // save
            SaveRecipe(n);

            // send to all
            SendUpdateRecipeToAll(n);

            buffer.Dispose();
        }
Esempio n. 21
0
        public static void SendMapItemsToAll(int mapNum)
        {
            int        i;
            ByteStream buffer;

            buffer = new ByteStream(4);

            buffer.WriteInt32((int)Packets.ServerPackets.SMapItemData);

            S_General.AddDebug("Sent SMSG: SMapItemData To All");

            for (i = 1; i <= Constants.MAX_MAP_ITEMS; i++)
            {
                buffer.WriteInt32(modTypes.MapItem[mapNum, i].Num);
                buffer.WriteInt32(modTypes.MapItem[mapNum, i].Value);
                buffer.WriteInt32(modTypes.MapItem[mapNum, i].X);
                buffer.WriteInt32(modTypes.MapItem[mapNum, i].Y);
            }

            S_NetworkConfig.SendDataToMap(mapNum, ref buffer.Data, buffer.Head);

            buffer.Dispose();
        }
Esempio n. 22
0
        public static void Packet_DropItem(int index, ref byte[] data)
        {
            int        InvNum;
            int        Amount;
            ByteStream buffer = new ByteStream(data);

            S_General.AddDebug("Recieved CMSG: CMapDropItem");

            InvNum = buffer.ReadInt32();
            Amount = buffer.ReadInt32();
            buffer.Dispose();

            if (modTypes.TempPlayer[index].InBank || Convert.ToBoolean(modTypes.TempPlayer[index].InShop))
            {
                return;
            }

            // Prevent hacking
            if (InvNum < 1 || InvNum > Constants.MAX_INV)
            {
                return;
            }
            if (S_Players.GetPlayerInvItemNum(index, InvNum) < 1 || S_Players.GetPlayerInvItemNum(index, InvNum) > Constants.MAX_ITEMS)
            {
                return;
            }
            if (Types.Item[S_Players.GetPlayerInvItemNum(index, InvNum)].Type == (int)Enums.ItemType.Currency || Types.Item[S_Players.GetPlayerInvItemNum(index, InvNum)].Stackable == 1)
            {
                if (Amount < 1 || Amount > S_Players.GetPlayerInvItemValue(index, InvNum))
                {
                    return;
                }
            }

            // everything worked out fine
            S_Players.PlayerMapDropItem(index, InvNum, Amount);
        }
Esempio n. 23
0
        public static void SpawnItemSlot(int MapItemSlot, int itemNum, int ItemVal, int mapNum, int x, int y)
        {
            int        i;
            ByteStream buffer = new ByteStream(4);

            // Check for subscript out of range
            if (MapItemSlot <= 0 || MapItemSlot > Constants.MAX_MAP_ITEMS || itemNum < 0 || itemNum > Constants.MAX_ITEMS || mapNum <= 0 || mapNum > S_Instances.MAX_CACHED_MAPS)
            {
                return;
            }

            i = MapItemSlot;

            if (i != 0)
            {
                if (itemNum >= 0 && itemNum <= Constants.MAX_ITEMS)
                {
                    modTypes.MapItem[mapNum, i].Num   = itemNum;
                    modTypes.MapItem[mapNum, i].Value = ItemVal;
                    modTypes.MapItem[mapNum, i].X     = (byte)x;
                    modTypes.MapItem[mapNum, i].Y     = (byte)y;

                    buffer.WriteInt32((int)Packets.ServerPackets.SSpawnItem);
                    buffer.WriteInt32(i);
                    buffer.WriteInt32(itemNum);
                    buffer.WriteInt32(ItemVal);
                    buffer.WriteInt32(x);
                    buffer.WriteInt32(y);

                    S_General.AddDebug("Sent SMSG: SSpawnItem MapItemSlot");

                    S_NetworkConfig.SendDataToMap(mapNum, ref buffer.Data, buffer.Head);
                }
            }

            buffer.Dispose();
        }
Esempio n. 24
0
        public static void Packet_RequestAnimations(int index, ref byte[] data)
        {
            S_General.AddDebug("Recieved CMSG: CRequestAnimations");

            SendAnimations(index);
        }
Esempio n. 25
0
        public static void Packet_RequestResources(int index, ref byte[] data)
        {
            S_General.AddDebug("Recieved CMSG: CRequestResources");

            SendResources(index);
        }
Esempio n. 26
0
        public static void Packet_GetItem(int index, ref byte[] data)
        {
            S_General.AddDebug("Recieved CMSG: CMapGetItem");

            S_Players.PlayerMapGetItem(index);
        }
Esempio n. 27
0
        public static void Packet_SaveItem(int index, ref byte[] data)
        {
            int        n;
            ByteStream buffer = new ByteStream(data);

            S_General.AddDebug("Recieved EMSG: SaveItem");

            // Prevent hacking
            if (S_Players.GetPlayerAccess(index) < (int)Enums.AdminType.Developer)
            {
                return;
            }

            n = buffer.ReadInt32();

            if (n < 0 || n > Constants.MAX_ITEMS)
            {
                return;
            }

            // Update the item
            Types.Item[n].AccessReq = buffer.ReadInt32();

            for (var i = 0; i <= (int)Enums.StatType.Count - 1; i++)
            {
                Types.Item[n].Add_Stat[i] = (byte)buffer.ReadInt32();
            }

            Types.Item[n].Animation = buffer.ReadInt32();
            Types.Item[n].BindType  = (byte)buffer.ReadInt32();
            Types.Item[n].ClassReq  = buffer.ReadInt32();
            Types.Item[n].Data1     = buffer.ReadInt32();
            Types.Item[n].Data2     = buffer.ReadInt32();
            Types.Item[n].Data3     = buffer.ReadInt32();
            Types.Item[n].TwoHanded = buffer.ReadInt32();
            Types.Item[n].LevelReq  = buffer.ReadInt32();
            Types.Item[n].Mastery   = (byte)buffer.ReadInt32();
            Types.Item[n].Name      = Microsoft.VisualBasic.Strings.Trim(buffer.ReadString());
            Types.Item[n].Paperdoll = buffer.ReadInt32();
            Types.Item[n].Pic       = buffer.ReadInt32();
            Types.Item[n].Price     = buffer.ReadInt32();
            Types.Item[n].Rarity    = (byte)buffer.ReadInt32();
            Types.Item[n].Speed     = buffer.ReadInt32();

            Types.Item[n].Randomize = (byte)buffer.ReadInt32();
            Types.Item[n].RandomMin = (byte)buffer.ReadInt32();
            Types.Item[n].RandomMax = (byte)buffer.ReadInt32();

            Types.Item[n].Stackable   = (byte)buffer.ReadInt32();
            Types.Item[n].Description = Microsoft.VisualBasic.Strings.Trim(buffer.ReadString());

            for (var i = 0; i <= (int)Enums.StatType.Count - 1; i++)
            {
                Types.Item[n].Stat_Req[i] = (byte)buffer.ReadInt32();
            }

            Types.Item[n].Type    = (byte)buffer.ReadInt32();
            Types.Item[n].SubType = (byte)buffer.ReadInt32();

            Types.Item[n].ItemLevel = (byte)buffer.ReadInt32();

            // Housing
            Types.Item[n].FurnitureWidth  = buffer.ReadInt32();
            Types.Item[n].FurnitureHeight = buffer.ReadInt32();

            for (var a = 0; a <= 3; a++)
            {
                for (var b = 0; b <= 3; b++)
                {
                    Types.Item[n].FurnitureBlocks[a, b] = buffer.ReadInt32();
                    Types.Item[n].FurnitureFringe[a, b] = buffer.ReadInt32();
                }
            }

            Types.Item[n].KnockBack      = (byte)buffer.ReadInt32();
            Types.Item[n].KnockBackTiles = (byte)buffer.ReadInt32();

            Types.Item[n].Projectile = buffer.ReadInt32();
            Types.Item[n].Ammo       = buffer.ReadInt32();

            // Save it
            SendUpdateItemToAll(n);
            SaveItem(n);
            modDatabase.Addlog(S_Players.GetPlayerLogin(index) + " saved item #" + n + ".", S_Constants.ADMIN_LOG);
            buffer.Dispose();
        }
Esempio n. 28
0
        public static void CheckResource(int index, int x, int y)
        {
            int  Resource_num;
            byte ResourceType;
            int  Resource_index;
            int  rX;
            int  rY;
            int  Damage;

            if (modTypes.Map[S_Players.GetPlayerMap(index)].Tile[x, y].Type == (byte)Enums.TileType.Resource)
            {
                Resource_num   = 0;
                Resource_index = modTypes.Map[S_Players.GetPlayerMap(index)].Tile[x, y].Data1;
                ResourceType   = (byte)Types.Resource[Resource_index].ResourceType;
                var loopTo = ResourceCache[S_Players.GetPlayerMap(index)].ResourceCount;

                // Get the cache number
                for (var i = 0; i <= loopTo; i++)
                {
                    if (ResourceCache[S_Players.GetPlayerMap(index)].ResourceData[i].X == x)
                    {
                        if (ResourceCache[S_Players.GetPlayerMap(index)].ResourceData[i].Y == y)
                        {
                            Resource_num = i;
                        }
                    }
                }

                if (Resource_num > 0)
                {
                    if (S_Players.GetPlayerEquipment(index, Enums.EquipmentType.Weapon) > 0 || Types.Resource[Resource_index].ToolRequired == 0)
                    {
                        if (Types.Item[S_Players.GetPlayerEquipment(index, Enums.EquipmentType.Weapon)].Data3 == Types.Resource[Resource_index].ToolRequired)
                        {
                            // inv space?
                            if (Types.Resource[Resource_index].ItemReward > 0)
                            {
                                if (S_Players.FindOpenInvSlot(index, Types.Resource[Resource_index].ItemReward) == 0)
                                {
                                    S_NetworkSend.PlayerMsg(index, "You have no inventory space.", (int)Enums.ColorType.Yellow);
                                    return;
                                }
                            }

                            // required lvl?
                            if (Types.Resource[Resource_index].LvlRequired > GetPlayerGatherSkillLvl(index, ResourceType))
                            {
                                S_NetworkSend.PlayerMsg(index, "Your level is too low!", (int)Enums.ColorType.Yellow);
                                return;
                            }

                            // check if already cut down
                            if (ResourceCache[S_Players.GetPlayerMap(index)].ResourceData[Resource_num].ResourceState == 0)
                            {
                                rX = ResourceCache[S_Players.GetPlayerMap(index)].ResourceData[Resource_num].X;
                                rY = ResourceCache[S_Players.GetPlayerMap(index)].ResourceData[Resource_num].Y;

                                if (Types.Resource[Resource_index].ToolRequired == 0)
                                {
                                    Damage = 1 * GetPlayerGatherSkillLvl(index, ResourceType);
                                }
                                else
                                {
                                    Damage = Types.Item[S_Players.GetPlayerEquipment(index, Enums.EquipmentType.Weapon)].Data2;
                                }

                                // check if damage is more than health
                                if (Damage > 0)
                                {
                                    // cut it down!
                                    if (ResourceCache[S_Players.GetPlayerMap(index)].ResourceData[Resource_num].CurHealth - Damage <= 0)
                                    {
                                        ResourceCache[S_Players.GetPlayerMap(index)].ResourceData[Resource_num].ResourceState = 1; // Cut
                                        ResourceCache[S_Players.GetPlayerMap(index)].ResourceData[Resource_num].ResourceTimer = S_General.GetTimeMs();
                                        SendResourceCacheToMap(S_Players.GetPlayerMap(index), Resource_num);
                                        S_NetworkSend.SendActionMsg(S_Players.GetPlayerMap(index), Types.Resource[Resource_index].SuccessMessage.Trim(), (int)Enums.ColorType.BrightGreen, 1, (S_Players.GetPlayerX(index) * 32), (S_Players.GetPlayerY(index) * 32));
                                        S_Players.GiveInvItem(index, Types.Resource[Resource_index].ItemReward, 1);
                                        S_Animations.SendAnimation(S_Players.GetPlayerMap(index), Types.Resource[Resource_index].Animation, rX, rY);
                                        SetPlayerGatherSkillExp(index, ResourceType, GetPlayerGatherSkillExp(index, ResourceType) + Types.Resource[Resource_index].ExpReward);
                                        // send msg
                                        S_NetworkSend.PlayerMsg(index, string.Format("Your {0} has earned {1} experience. ({2}/{3})", GetResourceSkillName((Enums.ResourceSkills)ResourceType), Types.Resource[Resource_index].ExpReward, GetPlayerGatherSkillExp(index, ResourceType), GetPlayerGatherSkillMaxExp(index, ResourceType)), (int)Enums.ColorType.BrightGreen);
                                        S_NetworkSend.SendPlayerData(index);

                                        CheckResourceLevelUp(index, ResourceType);
                                    }
                                    else
                                    {
                                        // just do the damage
                                        ResourceCache[S_Players.GetPlayerMap(index)].ResourceData[Resource_num].CurHealth = (byte)(ResourceCache[S_Players.GetPlayerMap(index)].ResourceData[Resource_num].CurHealth - Damage);
                                        S_NetworkSend.SendActionMsg(S_Players.GetPlayerMap(index), "-" + Damage, (int)Enums.ColorType.BrightRed, 1, (rX * 32), (rY * 32));
                                        S_Animations.SendAnimation(S_Players.GetPlayerMap(index), Types.Resource[Resource_index].Animation, rX, rY);
                                    }
                                    S_Quest.CheckTasks(index, (int)Enums.QuestType.Gather, Resource_index);
                                }
                                else
                                {
                                    // too weak
                                    S_NetworkSend.SendActionMsg(S_Players.GetPlayerMap(index), "Miss!", (int)Enums.ColorType.BrightRed, 1, (rX * 32), (rY * 32));
                                }
                            }
                            else
                            {
                                S_NetworkSend.SendActionMsg(S_Players.GetPlayerMap(index), Types.Resource[Resource_index].EmptyMessage.Trim(), (int)Enums.ColorType.BrightRed, 1, (S_Players.GetPlayerX(index) * 32), (S_Players.GetPlayerY(index) * 32));
                            }
                        }
                        else
                        {
                            S_NetworkSend.PlayerMsg(index, "You have the wrong type of tool equiped.", (int)Enums.ColorType.Yellow);
                        }
                    }
                    else
                    {
                        S_NetworkSend.PlayerMsg(index, "You need a tool to gather this resource.", (int)Enums.ColorType.Yellow);
                    }
                }
            }
        }
Esempio n. 29
0
 public static void HandleTimeChanged(ref Time source)
 {
     S_General.UpdateCaption();
 }
Esempio n. 30
0
        public static void Packet_CloseCraft(int index, ref byte[] data)
        {
            S_General.AddDebug("Recieved CMSG: CCloseCraft");

            modTypes.TempPlayer[index].IsCrafting = false;
        }