Example #1
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();
        }
Example #2
0
 public static void Packet_SaveHouses(int index, ref byte[] data)
 {
     checked
     {
         if (!(S_Players.GetPlayerAccess(index) < 2))
         {
             ByteStream buffer = new ByteStream(data);
             int        Count  = buffer.ReadInt32();
             if (Count > 0)
             {
                 int num = Count;
                 for (int z = 1; z <= num; z++)
                 {
                     int i = buffer.ReadInt32();
                     S_Housing.HouseConfig[i].ConfigName   = (buffer.ReadString().Trim());
                     S_Housing.HouseConfig[i].BaseMap      = buffer.ReadInt32();
                     S_Housing.HouseConfig[i].X            = buffer.ReadInt32();
                     S_Housing.HouseConfig[i].Y            = buffer.ReadInt32();
                     S_Housing.HouseConfig[i].Price        = buffer.ReadInt32();
                     S_Housing.HouseConfig[i].MaxFurniture = buffer.ReadInt32();
                     S_Housing.SaveHouse(i);
                     int playersOnline = S_GameLogic.GetPlayersOnline();
                     for (int x = 1; x <= playersOnline; x++)
                     {
                         if (S_NetworkConfig.IsPlaying(x) && modTypes.Player[x].Character[(int)modTypes.TempPlayer[x].CurChar].InHouse == i)
                         {
                             S_Housing.SendFurnitureToHouse(i);
                         }
                     }
                 }
             }
             buffer.Dispose();
         }
     }
 }
Example #3
0
        public static void SendFurnitureToHouse(int Houseindex)
        {
            ByteStream buffer = new ByteStream(4);

            buffer.WriteInt32(92);
            buffer.WriteInt32(Houseindex);
            buffer.WriteInt32(modTypes.Player[Houseindex].Character[(int)modTypes.TempPlayer[Houseindex].CurChar].House.FurnitureCount);

            checked
            {
                if (modTypes.Player[Houseindex].Character[(int)modTypes.TempPlayer[Houseindex].CurChar].House.FurnitureCount > 0)
                {
                    int furnitureCount = modTypes.Player[Houseindex].Character[(int)modTypes.TempPlayer[Houseindex].CurChar].House.FurnitureCount;
                    for (int i = 1; i <= furnitureCount; i++)
                    {
                        buffer.WriteInt32(modTypes.Player[Houseindex].Character[(int)modTypes.TempPlayer[Houseindex].CurChar].House.Furniture[i].ItemNum);
                        buffer.WriteInt32(modTypes.Player[Houseindex].Character[(int)modTypes.TempPlayer[Houseindex].CurChar].House.Furniture[i].X);
                        buffer.WriteInt32(modTypes.Player[Houseindex].Character[(int)modTypes.TempPlayer[Houseindex].CurChar].House.Furniture[i].Y);
                    }
                }
                int playersOnline = S_GameLogic.GetPlayersOnline();
                for (int i = 1; i <= playersOnline; i++)
                {
                    if (S_NetworkConfig.IsPlaying(i))
                    {
                        if (modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].InHouse == Houseindex)
                        {
                            S_NetworkConfig.Socket.SendDataTo(i, 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();
        }
        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();
        }
Example #6
0
        public static void SendTimeToAll()
        {
            int I;
            var loopTo = S_GameLogic.GetPlayersOnline();

            for (I = 1; I <= loopTo; I++)
            {
                if (S_NetworkConfig.IsPlaying(I))
                {
                    SendTimeTo(I);
                }
            }
        }
Example #7
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();
        }
Example #8
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);
                }
            }
        }
Example #9
0
        public static void SendUpdateProjectileToAll(int ProjectileNum)
        {
            ByteStream buffer;

            buffer = new ByteStream(4);

            buffer.WriteInt32((byte)Packets.ServerPackets.SUpdateProjectile);
            buffer.WriteInt32(ProjectileNum);
            buffer.WriteString((Microsoft.VisualBasic.Strings.Trim(Projectiles[ProjectileNum].Name)));
            buffer.WriteInt32(Projectiles[ProjectileNum].Sprite);
            buffer.WriteInt32(Projectiles[ProjectileNum].Range);
            buffer.WriteInt32(Projectiles[ProjectileNum].Speed);
            buffer.WriteInt32(Projectiles[ProjectileNum].Damage);

            S_NetworkConfig.SendDataToAll(ref buffer.Data, buffer.Head);
            buffer.Dispose();
        }
        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();
        }
        public static int GetTotalMapPlayers(int mapNum)
        {
            int i;
            int n;

            n = 0;
            var loopTo = GetPlayersOnline();

            for (i = 1; i <= loopTo; i++)
            {
                if (S_NetworkConfig.IsPlaying(i) && S_Players.GetPlayerMap(i) == mapNum)
                {
                    n = n + 1;
                }
            }

            return(n);
        }
Example #12
0
        public static void DestroyServer()
        {
            S_NetworkConfig.Socket.StopListening();

            Console.WriteLine("Saving players online...");
            modDatabase.SaveAllPlayersOnline();

            Console.WriteLine("Unloading players...");
            for (int i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                S_NetworkSend.SendLeftGame(i);
                S_Players.LeftGame(i);
            }

            S_NetworkConfig.DestroyNetwork();
            ClearGameData();

            Environment.Exit(0);
        }
Example #13
0
        public static void SendProjectileToMap(int mapNum, int ProjectileNum)
        {
            ByteStream buffer;

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

            {
                buffer.WriteInt32(ProjectileNum);
                buffer.WriteInt32(MapProjectiles[mapNum, ProjectileNum].ProjectileNum);
                buffer.WriteInt32(MapProjectiles[mapNum, ProjectileNum].Owner);
                buffer.WriteInt32(MapProjectiles[mapNum, ProjectileNum].OwnerType);
                buffer.WriteInt32(MapProjectiles[mapNum, ProjectileNum].Dir);
                buffer.WriteInt32(MapProjectiles[mapNum, ProjectileNum].X);
                buffer.WriteInt32(MapProjectiles[mapNum, ProjectileNum].Y);
            }

            S_NetworkConfig.SendDataToMap(mapNum, ref buffer.Data, buffer.Head);
            buffer.Dispose();
        }
Example #14
0
        public static void DestroyServer()
        {
            S_NetworkConfig.Socket.StopListening();

            Console.WriteLine("Saving players online...");
            modDatabase.SaveAllPlayersOnline();

            Console.WriteLine("Unloading players...");
            for (int i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                S_NetworkSend.SendLeftGame(i);
                S_Players.LeftGame(i);
            }

            S_NetworkConfig.DestroyNetwork();
            ClearGameData();

            /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElseDirectiveTrivia */
            Environment.Exit(0);
        }
Example #15
0
        // Token: 0x060001D8 RID: 472 RVA: 0x000398D4 File Offset: 0x00037AD4
        public static void LoadHouses()
        {
            bool flag = !File.Exists(Path.Combine(Application.StartupPath, "data", "houseconfig.xml"));

            if (flag)
            {
                S_Housing.CreateHouses();
            }
            XmlClass myXml = new XmlClass
            {
                Filename = Path.Combine(Application.StartupPath, "data", "houseconfig.xml"),
                Root     = "Config"
            };

            myXml.LoadXml();
            int max_HOUSES = S_Housing.MAX_HOUSES;

            checked
            {
                for (int i = 1; i <= max_HOUSES; i++)
                {
                    S_Housing.HouseConfig[i].BaseMap      = (int)Math.Round(Conversion.Val(myXml.ReadString("House" + Conversions.ToString(i), "BaseMap", "")));
                    S_Housing.HouseConfig[i].ConfigName   = (myXml.ReadString("House" + Conversions.ToString(i), "Name", "").Trim());
                    S_Housing.HouseConfig[i].MaxFurniture = (int)Math.Round(Conversion.Val(myXml.ReadString("House" + Conversions.ToString(i), "MaxFurniture", "")));
                    S_Housing.HouseConfig[i].Price        = (int)Math.Round(Conversion.Val(myXml.ReadString("House" + Conversions.ToString(i), "Price", "")));
                    S_Housing.HouseConfig[i].X            = (int)Math.Round(Conversion.Val(myXml.ReadString("House" + Conversions.ToString(i), "X", "")));
                    S_Housing.HouseConfig[i].Y            = (int)Math.Round(Conversion.Val(myXml.ReadString("House" + Conversions.ToString(i), "Y", "")));
                }
                myXml.CloseXml(false);
                int playersOnline = S_GameLogic.GetPlayersOnline();
                for (int i = 1; i <= playersOnline; i++)
                {
                    bool flag2 = S_NetworkConfig.IsPlaying(i);
                    if (flag2)
                    {
                        S_Housing.SendHouseConfigs(i);
                    }
                }
            }
        }
        public static int FindPlayer(string Name)
        {
            int i;
            var loopTo = GetPlayersOnline();

            for (i = 1; i <= loopTo; i++)
            {
                if (S_NetworkConfig.IsPlaying(i))
                {
                    // Make sure we dont try to check a name thats to small
                    if (Microsoft.VisualBasic.Strings.Len(S_Players.GetPlayerName(i)) >= Microsoft.VisualBasic.Strings.Len(Name.Trim()))
                    {
                        if (Microsoft.VisualBasic.Strings.Mid(S_Players.GetPlayerName(i), 1, Microsoft.VisualBasic.Strings.Len(Name.Trim())).ToUpper() == Name.Trim().ToUpper())
                        {
                            return(i);
                        }
                    }
                }
            }

            return(0);
        }
Example #17
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();
        }
Example #18
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();
        }
        public static void SendResourceCacheToMap(int mapNum, int Resource_num)
        {
            int        i;
            ByteStream buffer = new ByteStream(4);

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

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

            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.SendDataToMap(mapNum, ref buffer.Data, buffer.Head);
            buffer.Dispose();
        }
Example #20
0
        internal static void Packet_PartyRquest(int index, ref byte[] data)
        {
            modDatabase.Addlog("Recieved CMSG: CRequestParty", S_Constants.PACKET_LOG);
            Console.WriteLine("Recieved CMSG: CRequestParty");

            // Prevent partying with self
            if (modTypes.TempPlayer[index].Target == index)
            {
                return;
            }
            // make sure it's a valid target
            if (modTypes.TempPlayer[index].TargetType != (byte)Enums.TargetType.Player)
            {
                return;
            }

            // make sure they're connected and on the same map
            if (!S_NetworkConfig.Socket.IsConnected(modTypes.TempPlayer[index].Target) || !S_NetworkConfig.IsPlaying(modTypes.TempPlayer[index].Target))
            {
                return;
            }
            if (S_Players.GetPlayerMap(modTypes.TempPlayer[index].Target) != S_Players.GetPlayerMap(index))
            {
                return;
            }

            // init the request
            Party_Invite(index, modTypes.TempPlayer[index].Target);
        }
Example #21
0
        public static void SendUpdateQuestToAll(int QuestNum)
        {
            ByteStream buffer;

            buffer = new ByteStream(4);

            buffer.WriteInt32((byte)Packets.ServerPackets.SUpdateQuest);
            buffer.WriteInt32(QuestNum);

            buffer.WriteString((Microsoft.VisualBasic.Strings.Trim(Quest[QuestNum].Name)));
            buffer.WriteString((Microsoft.VisualBasic.Strings.Trim(Quest[QuestNum].QuestLog)));
            buffer.WriteInt32(Quest[QuestNum].Repeat);
            buffer.WriteInt32(Quest[QuestNum].Cancelable);

            buffer.WriteInt32(Quest[QuestNum].ReqCount);
            var loopTo = Quest[QuestNum].ReqCount;

            for (var I = 1; I <= loopTo; I++)
            {
                buffer.WriteInt32(Quest[QuestNum].Requirement[I]);
                buffer.WriteInt32(Quest[QuestNum].RequirementIndex[I]);
            }

            buffer.WriteInt32(Quest[QuestNum].QuestGiveItem);
            buffer.WriteInt32(Quest[QuestNum].QuestGiveItemValue);
            buffer.WriteInt32(Quest[QuestNum].QuestRemoveItem);
            buffer.WriteInt32(Quest[QuestNum].QuestRemoveItemValue);

            for (var I = 1; I <= 3; I++)
            {
                buffer.WriteString((Microsoft.VisualBasic.Strings.Trim(Quest[QuestNum].Chat[I])));
            }

            buffer.WriteInt32(Quest[QuestNum].RewardCount);
            var loopTo1 = Quest[QuestNum].RewardCount;

            for (var i = 1; i <= loopTo1; i++)
            {
                buffer.WriteInt32(Quest[QuestNum].RewardItem[i]);
                buffer.WriteInt32(Quest[QuestNum].RewardItemAmount[i]);
            }

            buffer.WriteInt32(Quest[QuestNum].RewardExp);

            buffer.WriteInt32(Quest[QuestNum].TaskCount);
            var loopTo2 = Quest[QuestNum].TaskCount;

            for (var I = 1; I <= loopTo2; I++)
            {
                buffer.WriteInt32(Quest[QuestNum].Task[I].Order);
                buffer.WriteInt32(Quest[QuestNum].Task[I].NPC);
                buffer.WriteInt32(Quest[QuestNum].Task[I].Item);
                buffer.WriteInt32(Quest[QuestNum].Task[I].Map);
                buffer.WriteInt32(Quest[QuestNum].Task[I].Resource);
                buffer.WriteInt32(Quest[QuestNum].Task[I].Amount);
                buffer.WriteString((Microsoft.VisualBasic.Strings.Trim(Quest[QuestNum].Task[I].Speech)));
                buffer.WriteString((Microsoft.VisualBasic.Strings.Trim(Quest[QuestNum].Task[I].TaskLog)));
                buffer.WriteInt32(Quest[QuestNum].Task[I].QuestEnd);
                buffer.WriteInt32(Quest[QuestNum].Task[I].TaskType);
            }

            S_NetworkConfig.SendDataToAll(ref buffer.Data, buffer.Head);
            buffer.Dispose();
        }
Example #22
0
        public static void HandleClearProjectile(int index, ref byte[] data)
        {
            int ProjectileNum;
            int Targetindex;

            Enums.TargetType TargetType;
            int        TargetZone;
            int        mapNum;
            int        Damage;
            int        armor;
            int        npcnum;
            ByteStream buffer = new ByteStream(data);

            ProjectileNum = buffer.ReadInt32();
            Targetindex   = buffer.ReadInt32();
            TargetType    = (Enums.TargetType)buffer.ReadInt32();
            TargetZone    = buffer.ReadInt32();
            buffer.Dispose();

            mapNum = S_Players.GetPlayerMap(index);

            switch (MapProjectiles[mapNum, ProjectileNum].OwnerType)
            {
            case (byte)Enums.TargetType.Player:
            {
                if (MapProjectiles[mapNum, ProjectileNum].Owner == index)
                {
                    switch (TargetType)
                    {
                    case Enums.TargetType.Player:
                    {
                        if (S_NetworkConfig.IsPlaying(Targetindex))
                        {
                            if (Targetindex != index)
                            {
                                if (S_Players.CanPlayerAttackPlayer(index, Targetindex, true) == true)
                                {
                                    // Get the damage we can do
                                    Damage = S_Players.GetPlayerDamage(index) + Projectiles[MapProjectiles[mapNum, ProjectileNum].ProjectileNum].Damage;

                                    // if the npc blocks, take away the block amount
                                    armor  = Convert.ToInt32(S_Players.CanPlayerBlockHit(Targetindex));
                                    Damage = Damage - armor;

                                    // randomise for up to 10% lower than max hit
                                    Damage = S_GameLogic.Random(1, Damage);

                                    if (Damage < 1)
                                    {
                                        Damage = 1;
                                    }

                                    S_Players.AttackPlayer(index, Targetindex, Damage);
                                }
                            }
                        }

                        break;
                    }

                    case Enums.TargetType.Npc:
                    {
                        npcnum = modTypes.MapNpc[mapNum].Npc[Targetindex].Num;
                        if (S_Players.CanPlayerAttackNpc(index, Targetindex, true) == true)
                        {
                            // Get the damage we can do
                            Damage = S_Players.GetPlayerDamage(index) + Projectiles[MapProjectiles[mapNum, ProjectileNum].ProjectileNum].Damage;

                            // if the npc blocks, take away the block amount
                            armor  = 0;
                            Damage = Damage - armor;

                            // randomise from 1 to max hit
                            Damage = S_GameLogic.Random(1, Damage);

                            if (Damage < 1)
                            {
                                Damage = 1;
                            }

                            S_Players.PlayerAttackNpc(index, Targetindex, Damage);
                        }

                        break;
                    }
                    }
                }

                break;
            }
            }

            ClearMapProjectile(mapNum, ProjectileNum);
        }
Example #23
0
        public static void InitServer()
        {
            int i;
            int F;
            int x;
            int time1;
            int time2;

            myStopWatch.Start();

            if (Debugger.IsAttached)
            {
                // Since there is a debugger attached,
                // assume we are running from the IDE
                S_Globals.Debugging = true;
            }
            else
            {
                // Assume we aren't running from the IDE
                AppDomain currentDomain = AppDomain.CurrentDomain;
                currentDomain.UnhandledException += ErrorHandler;
            }

            Console.Title = "Orion+# Server";
            Console.SetWindowSize(120, 20);

            time1 = GetTimeMs();

            // Initialize the random-number generator
            VBMath.Randomize();

            // LOAD ENCRYPTION
            var fi = Application.StartupPath + @"\AsyncKeys.xml";

            if (!File.Exists(fi))
            {
                S_Globals.EKeyPair.GenerateKeys();
                S_Globals.EKeyPair.ExportKey(fi, true); // True exports private key too.
            }
            else
            {
                S_Globals.EKeyPair.ImportKey(fi);
            }
            // END LOAD ENCRYPTION

            modTypes.Map = new MapRec[601];

            modTypes.MapNpc = new MapDataRec[601];
            for (i = 0; i <= S_Instances.MAX_CACHED_MAPS; i++)
            {
                modTypes.MapNpc[i].Npc = new MapNpcRec[Constants.MAX_MAP_NPCS + 1];
                modTypes.Map[i].Npc    = new int[Constants.MAX_MAP_NPCS + 1];
            }

            // quests
            S_Quest.Quest = new QuestRec[251];
            S_Quest.ClearQuests();

            // event
            S_Events.Switches     = new string[501];
            S_Events.Variables    = new string[501];
            S_Events.TempEventMap = new GlobalEventsStruct[601];

            // Housing
            S_Housing.HouseConfig = new HouseRec[S_Housing.MAX_HOUSES + 1];

            for (i = 0; i <= S_Instances.MAX_CACHED_MAPS; i++)
            {
                for (x = 0; x <= Constants.MAX_MAP_NPCS; x++)
                {
                    modTypes.MapNpc[i].Npc[x].Vital = new int[(int)Enums.VitalType.Count + 1];
                }
            }

            modTypes.Bank = new BankRec[71];

            for (i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                modTypes.Bank[i].Item     = new PlayerInvRec[Constants.MAX_BANK + 1];
                modTypes.Bank[i].ItemRand = new RandInvRec[Constants.MAX_BANK + 1];
                for (x = 1; x <= Constants.MAX_BANK; x++)
                {
                    modTypes.Bank[i].ItemRand[x].Stat = new int[7];
                }
            }

            modTypes.Player = new PlayerRec[71];

            for (i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                // multi char
                modTypes.Player[i].Character = new CharacterRec[S_Constants.MAX_CHARS + 1];
                for (x = 1; x <= S_Constants.MAX_CHARS; x++)
                {
                    modTypes.Player[i].Character[x].Switches    = new byte[501];
                    modTypes.Player[i].Character[x].Variables   = new int[501];
                    modTypes.Player[i].Character[x].Vital       = new int[4];
                    modTypes.Player[i].Character[x].Stat        = new int[7];
                    modTypes.Player[i].Character[x].Equipment   = new int[7];
                    modTypes.Player[i].Character[x].Inv         = new PlayerInvRec[Constants.MAX_INV + 1];
                    modTypes.Player[i].Character[x].Skill       = new int[Constants.MAX_PLAYER_SKILLS + 1];
                    modTypes.Player[i].Character[x].PlayerQuest = new PlayerQuestRec[251];

                    modTypes.Player[i].Character[x].RandEquip = new RandInvRec[7];
                    modTypes.Player[i].Character[x].RandInv   = new RandInvRec[Constants.MAX_INV + 1];
                    for (var y = 1; y <= (int)Enums.EquipmentType.Count - 1; y++)
                    {
                        modTypes.Player[i].Character[x].RandEquip[y].Stat = new int[7];
                    }
                    for (int y = 1; y <= Constants.MAX_INV; y++)
                    {
                        modTypes.Player[i].Character[x].RandInv[y].Stat = new int[7];
                    }
                }
            }

            modTypes.TempPlayer = new TempPlayerRec[71];

            for (i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                modTypes.TempPlayer[i].SkillCd    = new int[Constants.MAX_PLAYER_SKILLS + 1];
                modTypes.TempPlayer[i].PetSkillCd = new int[5];
            }

            for (i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                modTypes.TempPlayer[i].TradeOffer = new PlayerInvRec[Constants.MAX_INV + 1];
            }

            S_AutoMap.LoadTilePrefab();

            Types.Classes = new ClassRec[S_Globals.Max_Classes + 1];
            var loopTo = S_Globals.Max_Classes;

            for (i = 0; i <= loopTo; i++)
            {
                Types.Classes[i].Stat       = new byte[7];
                Types.Classes[i].StartItem  = new int[6];
                Types.Classes[i].StartValue = new int[6];
            }

            for (i = 0; i <= Constants.MAX_ITEMS; i++)
            {
                Types.Item[i].Add_Stat        = new byte[7];
                Types.Item[i].Stat_Req        = new byte[7];
                Types.Item[i].FurnitureBlocks = new int[4, 4];
                Types.Item[i].FurnitureFringe = new int[4, 4];
            }
            Types.Npc[Constants.MAX_NPCS].Stat = new byte[7];

            Types.Shop[Constants.MAX_SHOPS].TradeItem = new TradeItemRec[Constants.MAX_TRADES + 1];

            Types.Animation[Constants.MAX_ANIMATIONS].Sprite    = new int[2];
            Types.Animation[Constants.MAX_ANIMATIONS].Frames    = new int[2];
            Types.Animation[Constants.MAX_ANIMATIONS].LoopCount = new int[2];
            Types.Animation[Constants.MAX_ANIMATIONS].LoopTime  = new int[2];

            S_Projectiles.MapProjectiles = new MapProjectileRec[601, 256];
            S_Projectiles.Projectiles    = new ProjectileRec[256];

            // parties
            S_Parties.ClearParties();

            // pets
            S_Pets.Pet = new PetRec[101];
            S_Pets.ClearPets();

            // Check if the directory is there, if its not make it
            CheckDir(Path.Combine(Application.StartupPath, "data"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "items"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "maps"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "npcs"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "shops"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "skills"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "accounts"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "resources"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "animations"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "logs"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "quests"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "recipes"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "pets"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "projectiles"));

            // load options, set if they dont exist
            if (!File.Exists(Path.Combine(Application.StartupPath, "Data", "Config.xml")))
            {
                modTypes.Options.GameName = "Orion+#";
                modTypes.Options.Port     = 7001;
                modTypes.Options.Motd     = "Welcome to the Orion+# Engine";
                modTypes.Options.Website  = "http://ascensiongamedev.com/index.php";
                modTypes.Options.StartMap = 1;
                modTypes.Options.StartX   = 13;
                modTypes.Options.StartY   = 7;
                modDatabase.SaveOptions();
            }
            else
            {
                modDatabase.LoadOptions();
            }

            // Get that network READY SUN! ~ SpiceyWOlf
            S_NetworkConfig.InitNetwork();

            // Init all the player sockets
            Console.WriteLine("Initializing player array...");

            for (x = 1; x <= Constants.MAX_PLAYERS; x++)
            {
                modDatabase.ClearPlayer(x);
            }

            // Serves as a constructor
            ClearGameData();
            LoadGameData();
            Console.WriteLine("Spawning map items...");
            S_Items.SpawnAllMapsItems();
            Console.WriteLine("Spawning map npcs...");
            S_Npc.SpawnAllMapNpcs();

            // Check if the master charlist file exists for checking duplicate names, and if it doesnt make it
            if (!File.Exists(@"data\accounts\charlist.txt"))
            {
                F = FileSystem.FreeFile();
            }

            // resource system
            S_Resources.LoadSkillExp();

            modTime.InitTime();

            UpdateCaption();
            time2 = GetTimeMs();

            Console.Clear();
            Console.WriteLine("   ____       _                   _  _   ");
            Console.WriteLine(@"  / __ \     (_)             _  _| || |_ ");
            Console.WriteLine(" | |  | |_ __ _  ___  _ __ _| ||_  __  _|");
            Console.WriteLine(@" | |  | | '__| |/ _ \| '_ \_   _|| || |_ ");
            Console.WriteLine(@" | |__| | |  | | (_) | | | ||_||_  __  _|");
            Console.WriteLine(@"  \____/|_|  |_|\___/|_| |_|     |_||_|  ");

            Console.WriteLine("");

            Console.WriteLine("Initialization complete. Server loaded in " + (time2 - time1).ToString() + "ms.");
            Console.WriteLine("");
            Console.WriteLine("Use /help for the available commands.");

            MyIPAddress = S_NetworkConfig.GetIP();

            UpdateCaption();

            // reset shutdown value
            S_Globals.isShuttingDown = false;

            // Start listener now that everything is loaded
            S_NetworkConfig.Socket.StartListening(modTypes.Options.Port, 5, 1);

            // Starts the server loop
            modLoop.ServerLoop();
        }
Example #24
0
        public static void Packet_PlaceFurniture(int index, ref byte[] data)
        {
            ByteStream buffer  = new ByteStream(data);
            int        x       = buffer.ReadInt32();
            int        y       = buffer.ReadInt32();
            int        invslot = buffer.ReadInt32();

            buffer.Dispose();
            int ItemNum = modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].Inv[invslot].Num;

            checked
            {
                if (!(ItemNum < 1 || ItemNum > 500))
                {
                    if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse == index)
                    {
                        if (Types.Item[ItemNum].Type == 6)
                        {
                            int i = 1;
                            for (; ;)
                            {
                                if (S_Players.GetPlayerRawStat(index, (Enums.StatType)i) < (int)Types.Item[ItemNum].Stat_Req[i])
                                {
                                    break;
                                }
                                i++;
                                if (i > 6)
                                {
                                    goto Block_6;
                                }
                            }
                            S_NetworkSend.PlayerMsg(index, "You do not meet the stat requirements to use this item.", 12);
                            return;

Block_6:
                            if (S_Players.GetPlayerLevel(index) < Types.Item[ItemNum].LevelReq)
                            {
                                S_NetworkSend.PlayerMsg(index, "You do not meet the level requirement to use this item.", 12);
                            }
                            else
                            {
                                if (Types.Item[ItemNum].ClassReq > 0)
                                {
                                    if (S_Players.GetPlayerClass(index) != Types.Item[ItemNum].ClassReq)
                                    {
                                        S_NetworkSend.PlayerMsg(index, "You do not meet the class requirement to use this item.", 12);
                                        return;
                                    }
                                }
                                if (S_Players.GetPlayerAccess(index) < Types.Item[ItemNum].AccessReq)
                                {
                                    S_NetworkSend.PlayerMsg(index, "You do not meet the access requirement to use this item.", 12);
                                }
                                else
                                {
                                    if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse != index)
                                    {
                                        S_NetworkSend.PlayerMsg(index, "You must be inside your house to place furniture!", 14);
                                    }
                                    else
                                    {
                                        if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount >= S_Housing.HouseConfig[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Houseindex].MaxFurniture)
                                        {
                                            if (S_Housing.HouseConfig[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Houseindex].MaxFurniture > 0)
                                            {
                                                S_NetworkSend.PlayerMsg(index, "Your house cannot hold any more furniture!", 12);
                                                return;
                                            }
                                        }
                                        if (!(x < 0 || x > (int)modTypes.Map[S_Players.GetPlayerMap(index)].MaxX))
                                        {
                                            if (!(y < 0 || y > (int)modTypes.Map[S_Players.GetPlayerMap(index)].MaxY))
                                            {
                                                int x2;
                                                int widthoffset;
                                                if (Types.Item[ItemNum].FurnitureWidth > 2)
                                                {
                                                    x2          = (int)Math.Round(unchecked ((double)x + (double)Types.Item[ItemNum].FurnitureWidth / 2.0));
                                                    widthoffset = x2 - x;
                                                    x2         -= Types.Item[ItemNum].FurnitureWidth - widthoffset;
                                                }
                                                x2          = x;
                                                widthoffset = 0;
                                                int y2 = y;
                                                if (widthoffset > 0)
                                                {
                                                    int num  = x2;
                                                    int num2 = x2 + widthoffset;
                                                    for (x = num; x <= num2; x++)
                                                    {
                                                        int num3 = y2;
                                                        int num4 = y2 - Types.Item[ItemNum].FurnitureHeight + 1;
                                                        for (y = num3; y >= num4; y += -1)
                                                        {
                                                            if (modTypes.Map[S_Players.GetPlayerMap(index)].Tile[x, y].Type == 1)
                                                            {
                                                                return;
                                                            }
                                                            int playersOnline = S_GameLogic.GetPlayersOnline();
                                                            for (i = 1; i <= playersOnline; i++)
                                                            {
                                                                if (S_NetworkConfig.IsPlaying(i) && i != index && S_Players.GetPlayerMap(i) == S_Players.GetPlayerMap(index))
                                                                {
                                                                    if (modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].InHouse == modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse)
                                                                    {
                                                                        if ((int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].X == x && (int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].Y == y)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount > 0)
                                                            {
                                                                int furnitureCount = modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount;
                                                                for (i = 1; i <= furnitureCount; i++)
                                                                {
                                                                    if (x >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X && x <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X + Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureWidth - 1)
                                                                    {
                                                                        if (y <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y && y >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y - Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureHeight + 1)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    int num5 = x2;
                                                    int num6 = x2 - (Types.Item[ItemNum].FurnitureWidth - widthoffset);
                                                    for (x = num5; x >= num6; x += -1)
                                                    {
                                                        int num7 = y2;
                                                        int num8 = y2 - Types.Item[ItemNum].FurnitureHeight + 1;
                                                        for (y = num7; y >= num8; y += -1)
                                                        {
                                                            if (modTypes.Map[S_Players.GetPlayerMap(index)].Tile[x, y].Type == 1)
                                                            {
                                                                return;
                                                            }
                                                            int playersOnline2 = S_GameLogic.GetPlayersOnline();
                                                            for (i = 1; i <= playersOnline2; i++)
                                                            {
                                                                if (S_NetworkConfig.IsPlaying(i) && i != index && S_Players.GetPlayerMap(i) == S_Players.GetPlayerMap(index))
                                                                {
                                                                    if (modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].InHouse == modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse)
                                                                    {
                                                                        if ((int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].X == x && (int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].Y == y)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount > 0)
                                                            {
                                                                int furnitureCount2 = modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount;
                                                                for (i = 1; i <= furnitureCount2; i++)
                                                                {
                                                                    if (x >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X && x <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X + Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureWidth - 1)
                                                                    {
                                                                        if (y <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y && y >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y - Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureHeight + 1)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    int num9  = x2;
                                                    int num10 = x2 + Types.Item[ItemNum].FurnitureWidth - 1;
                                                    for (x = num9; x <= num10; x++)
                                                    {
                                                        int num11 = y2;
                                                        int num12 = y2 - Types.Item[ItemNum].FurnitureHeight + 1;
                                                        for (y = num11; y >= num12; y += -1)
                                                        {
                                                            if (modTypes.Map[S_Players.GetPlayerMap(index)].Tile[x, y].Type == 1)
                                                            {
                                                                return;
                                                            }
                                                            int playersOnline3 = S_GameLogic.GetPlayersOnline();
                                                            for (i = 1; i <= playersOnline3; i++)
                                                            {
                                                                if (S_NetworkConfig.IsPlaying(i) && i != index && S_Players.GetPlayerMap(i) == S_Players.GetPlayerMap(index))
                                                                {
                                                                    if (modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].InHouse == modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse)
                                                                    {
                                                                        if ((int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].X == x && (int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].Y == y)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount > 0)
                                                            {
                                                                int furnitureCount3 = modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount;
                                                                for (i = 1; i <= furnitureCount3; i++)
                                                                {
                                                                    if (x >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X && x <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X + Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureWidth - 1)
                                                                    {
                                                                        if (y <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y && y >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y - Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureHeight + 1)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                x = x2;
                                                y = y2;
                                                modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount = modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount + 1;
                                                modTypes.CharacterRec[] character = modTypes.Player[index].Character;
                                                byte curChar = modTypes.TempPlayer[index].CurChar;
                                                character[(int)curChar].House.Furniture = (S_Housing.FurnitureRec[])Utils.CopyArray(character[(int)curChar].House.Furniture, new S_Housing.FurnitureRec[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount + 1]);
                                                modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount].ItemNum = ItemNum;
                                                modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount].X       = x;
                                                modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount].Y       = y;
                                                S_Players.TakeInvItem(index, ItemNum, 0);
                                                S_Housing.SendFurnitureToHouse(modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse);
                                                modDatabase.SavePlayer(index);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        S_NetworkSend.PlayerMsg(index, "You cannot place furniture unless you are in your own house!", 12);
                    }
                }
            }
        }
Example #25
0
        internal static void PartyMsg(int partyNum, string msg)
        {
            int i;

            // send message to all people
            for (i = 1; i <= Constants.MAX_PARTY_MEMBERS; i++)
            {
                // exist?
                if (Party[partyNum].Member[i] > 0)
                {
                    // make sure they're logged on
                    if (S_NetworkConfig.Socket.IsConnected(Party[partyNum].Member[i]) && S_NetworkConfig.IsPlaying(Party[partyNum].Member[i]))
                    {
                        S_NetworkSend.PlayerMsg(Party[partyNum].Member[i], msg, (int)Enums.ColorType.BrightBlue);
                    }
                }
            }
        }
Example #26
0
        internal static void Party_ShareExp(int partyNum, int exp, int index, int mapNum)
        {
            int  expShare        = 0;
            int  leftOver        = 0;
            int  i               = 0;
            int  tmpindex        = 0;
            byte loseMemberCount = 0;

            // check if it's worth sharing
            if (!(exp >= Party[partyNum].MemberCount))
            {
                // no party - keep exp for self
                S_Events.GivePlayerExp(index, exp);
                return;
            }

            // check members in others maps
            for (i = 1; i <= Constants.MAX_PARTY_MEMBERS; i++)
            {
                tmpindex = Party[partyNum].Member[i];
                if (tmpindex > 0)
                {
                    if (S_NetworkConfig.Socket.IsConnected(tmpindex) && S_NetworkConfig.IsPlaying(tmpindex))
                    {
                        if (S_Players.GetPlayerMap(tmpindex) != mapNum)
                        {
                            loseMemberCount = (byte)(loseMemberCount + 1);
                        }
                    }
                }
            }

            // find out the equal share
            expShare = exp / (Party[partyNum].MemberCount - loseMemberCount);
            leftOver = exp % (Party[partyNum].MemberCount - loseMemberCount);

            // loop through and give everyone exp
            for (i = 1; i <= Constants.MAX_PARTY_MEMBERS; i++)
            {
                tmpindex = Party[partyNum].Member[i];
                // existing member?
                if (tmpindex > 0)
                {
                    // playing?
                    if (S_NetworkConfig.Socket.IsConnected(tmpindex) && S_NetworkConfig.IsPlaying(tmpindex))
                    {
                        if (S_Players.GetPlayerMap(tmpindex) == mapNum)
                        {
                            // give them their share
                            S_Events.GivePlayerExp(tmpindex, expShare);
                        }
                    }
                }
            }

            // give the remainder to a random member
            if (!(leftOver == 0))
            {
                tmpindex = Party[partyNum].Member[S_GameLogic.Random(1, Party[partyNum].MemberCount)];
                // give the exp
                S_Events.GivePlayerExp(tmpindex, leftOver);
            }
        }
Example #27
0
        internal static void Party_Invite(int index, int target)
        {
            int partyNum;
            int i;

            // check if the person is a valid target
            if (!S_NetworkConfig.Socket.IsConnected(target) || !S_NetworkConfig.IsPlaying(target))
            {
                return;
            }

            // make sure they're not busy
            if (modTypes.TempPlayer[target].PartyInvite > 0 || modTypes.TempPlayer[target].TradeRequest > 0)
            {
                // they've already got a request for trade/party
                S_NetworkSend.PlayerMsg(index, "This player is busy.", (int)Enums.ColorType.BrightRed);
                // exit out early
                return;
            }
            // make syure they're not in a party
            if (modTypes.TempPlayer[target].InParty > 0)
            {
                // they're already in a party
                S_NetworkSend.PlayerMsg(index, "This player is already in a party.", (int)Enums.ColorType.BrightRed);
                // exit out early
                return;
            }

            // check if we're in a party
            if (modTypes.TempPlayer[index].InParty > 0)
            {
                partyNum = modTypes.TempPlayer[index].InParty;
                // make sure we're the leader
                if (Party[partyNum].Leader == index)
                {
                    // got a blank slot?
                    for (i = 1; i <= Constants.MAX_PARTY_MEMBERS; i++)
                    {
                        if (Party[partyNum].Member[i] == 0)
                        {
                            // send the invitation
                            SendPartyInvite(target, index);
                            // set the invite target
                            modTypes.TempPlayer[target].PartyInvite = index;
                            // let them know
                            S_NetworkSend.PlayerMsg(index, "Invitation sent.", (int)Enums.ColorType.Yellow);
                            return;
                        }
                    }
                    // no room
                    S_NetworkSend.PlayerMsg(index, "Party is full.", (int)Enums.ColorType.BrightRed);
                    return;
                }
                else
                {
                    // not the leader
                    S_NetworkSend.PlayerMsg(index, "You are not the party leader.", (int)Enums.ColorType.BrightRed);
                    return;
                }
            }
            else
            {
                // not in a party - doesn't matter!
                SendPartyInvite(target, index);
                // set the invite target
                modTypes.TempPlayer[target].PartyInvite = index;
                // let them know
                S_NetworkSend.PlayerMsg(index, "Invitation sent.", (int)Enums.ColorType.Yellow);
                return;
            }
        }