Пример #1
0
        //*********************************************************************************************
        // PlayerMove / Revisto pela última vez em 01/08/2016, criado por Allyson S. Bacon
        // Move determinado jogador para determinada posição
        //*********************************************************************************************
        public static void PlayerMove(int index, byte Dir)
        {
            //EXTEND
            if (Extensions.ExtensionApp.ExtendMyApp
                    (MethodBase.GetCurrentMethod().Name, index, Dir) != null)
            {
                return;
            }

            //CÓDIGO
            if (PStruct.tempplayer[index].Warping)
            {
                return;
            }
            //Tentamos nos mover
            switch (Dir)
            {
            case 8:
                PStruct.character[index, PStruct.player[index].SelectedChar].Y   = Convert.ToByte(Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].Y) - 1);
                PStruct.character[index, PStruct.player[index].SelectedChar].Dir = Globals.DirUp;
                break;

            case 2:
                PStruct.character[index, PStruct.player[index].SelectedChar].Y   = Convert.ToByte(Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].Y) + 1);
                PStruct.character[index, PStruct.player[index].SelectedChar].Dir = Globals.DirDown;
                break;

            case 4:
                PStruct.character[index, PStruct.player[index].SelectedChar].X   = Convert.ToByte(Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].X) - 1);
                PStruct.character[index, PStruct.player[index].SelectedChar].Dir = Globals.DirLeft;
                break;

            case 6:
                PStruct.character[index, PStruct.player[index].SelectedChar].X   = Convert.ToByte(Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].X) + 1);
                PStruct.character[index, PStruct.player[index].SelectedChar].Dir = Globals.DirRight;
                break;

            default:
                WinsockAsync.Log(String.Format("Direção nula"));
                break;
            }

            int map = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].Map);
            int x   = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].X);
            int y   = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].Y);

            //Verifica os tipos de tiles
            if (MStruct.tile[map, x, y].Data1 == "2")
            {
                PStruct.tempplayer[index].Warping = true;
                PlayerWarp(index, Convert.ToInt32(MStruct.tile[map, x, y].Data2), Convert.ToByte(MStruct.tile[map, x, y].Data3), Convert.ToByte(MStruct.tile[map, x, y].Data4));
                return;
            }

            //Se nenhum tile tem ação, enviar as novas coordenadas do jogador após o movimento
            SendData.Send_PlayerXY(index);
            SendData.Send_PlayerDir(index, 1);
        }
Пример #2
0
        //*********************************************************************************************
        // ConsoleEventCallBack / Revisto pela última vez em 01/08/2016, criado por Allyson S. Bacon
        // Desconectar usuários antes de fechar o servidor.
        //*********************************************************************************************
        static bool ConsoleEventCallback(int eventType)
        {
            //EXTEND
            if (Extensions.ExtensionApp.ExtendMyApp
                    (MethodBase.GetCurrentMethod().Name, eventType) != null)
            {
                return(Convert.ToBoolean(Extensions.ExtensionApp.ExtendMyApp
                                             (MethodBase.GetCurrentMethod().Name, eventType)));
            }

            //CÓDIGO
            if (eventType == 2)
            {
                for (int i = 0; i <= WinsockAsync.Clients.Count; i++)
                {
                    WinsockAsync.DisconnectUser(i);
                }
            }
            return(false);
        }
Пример #3
0
        //*********************************************************************************************
        // CanPlayerMove / Revisto pela última vez em 01/08/2016, criado por Allyson S. Bacon
        // Verifica se determinado jogador pode se mover no contexto em que está atualmente
        //*********************************************************************************************
        public static bool CanPlayerMove(int index, byte Dir, int x = 0, int y = 0)
        {
            //EXTEND
            if (Extensions.ExtensionApp.ExtendMyApp
                    (MethodBase.GetCurrentMethod().Name, index, Dir, x, y) != null)
            {
                return(Convert.ToBoolean(Extensions.ExtensionApp.ExtendMyApp
                                             (MethodBase.GetCurrentMethod().Name, index, Dir, x, y)));
            }

            //CÓDIGO
            int map = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].Map);

            if (x <= 0 || y <= 0)
            {
                x = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].X);
                y = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].Y);
            }

            //Tentamos nos mover
            switch (Dir)
            {
            case 8:
                if (y - 1 < 0)
                {
                    return(false);
                }
                if (Convert.ToBoolean(MStruct.tile[map, x, y].UpBlock) == false)
                {
                    return(false);
                }
                if (Convert.ToBoolean(MStruct.tile[map, x, y - 1].DownBlock) == false)
                {
                    return(false);
                }
                if ((MStruct.tile[map, x, y - 1].Data1 == "3") || (MStruct.tile[map, x, y - 1].Data1 == "10"))
                {
                    return(false);
                }
                if (MStruct.tile[map, x, y - 1].Data1 == "21")
                {
                    if (!PlayerRelations.IsPlayerPremmy(index))
                    {
                        PlayerMove(index, Convert.ToByte(Convert.ToInt32(MStruct.tile[map, x, y - 1].Data2)));
                        return(false);
                    }
                }
                break;

            case 2:
                if (y + 1 > 14)
                {
                    return(false);
                }
                if (Convert.ToBoolean(MStruct.tile[map, x, y].DownBlock) == false)
                {
                    return(false);
                }
                if (Convert.ToBoolean(MStruct.tile[map, x, y + 1].UpBlock) == false)
                {
                    return(false);
                }
                if ((MStruct.tile[map, x, y + 1].Data1 == "3") || (MStruct.tile[map, x, y + 1].Data1 == "10"))
                {
                    return(false);
                }
                if (MStruct.tile[map, x, y + 1].Data1 == "21")
                {
                    if (!PlayerRelations.IsPlayerPremmy(index))
                    {
                        PlayerMove(index, Convert.ToByte(Convert.ToInt32(MStruct.tile[map, x, y + 1].Data2)));
                        return(false);
                    }
                }
                break;

            case 4:
                if (x - 1 < 0)
                {
                    return(false);
                }
                if (Convert.ToBoolean(MStruct.tile[map, x, y].LeftBlock) == false)
                {
                    return(false);
                }
                if (Convert.ToBoolean(MStruct.tile[map, x - 1, y].RightBlock) == false)
                {
                    return(false);
                }
                if ((MStruct.tile[map, x - 1, y].Data1 == "3") || (MStruct.tile[map, x - 1, y].Data1 == "10"))
                {
                    return(false);
                }
                if (MStruct.tile[map, x - 1, y].Data1 == "21")
                {
                    if (!PlayerRelations.IsPlayerPremmy(index))
                    {
                        PlayerMove(index, Convert.ToByte(Convert.ToInt32(MStruct.tile[map, x - 1, y].Data2)));
                        return(false);
                    }
                }
                break;

            case 6:
                if (x + 1 > 19)
                {
                    return(false);
                }
                if (Convert.ToBoolean(MStruct.tile[map, x, y].RightBlock) == false)
                {
                    return(false);
                }
                if (Convert.ToBoolean(MStruct.tile[map, x + 1, y].LeftBlock) == false)
                {
                    return(false);
                }
                if ((MStruct.tile[map, x + 1, y].Data1 == "3") || (MStruct.tile[map, x + 1, y].Data1 == "10"))
                {
                    return(false);
                }
                if (MStruct.tile[map, x + 1, y].Data1 == "21")
                {
                    if (!PlayerRelations.IsPlayerPremmy(index))
                    {
                        PlayerMove(index, Convert.ToByte(Convert.ToInt32(MStruct.tile[map, x + 1, y].Data2)));
                        return(false);
                    }
                }
                break;

            default:
                WinsockAsync.Log(String.Format("Direção nula"));
                break;
            }

            return(true);
        }
Пример #4
0
        //*********************************************************************************************
        // AlphaLoop / Revisto pela última vez em 01/08/2016, criado por Allyson S. Bacon
        // Trabalha com informações direcionadas ao jogo e os jogadores.
        //*********************************************************************************************
        public static void AlphaLoop()
        {
            //EXTEND
            if (Extensions.ExtensionApp.ExtendMyApp
                    (MethodBase.GetCurrentMethod().Name) != null)
            {
                return;
            }

            //CÓDIGO
            long tmr100;
            long tmr256;
            long Tick;

            tmr100 = 0;
            tmr256 = 0;
            Database.DefineAdmin();
            WinsockAsync.Log(lang.server_started_in_date + " " + DateTime.Now);

            do
            {
                Tick = TickCount.ElapsedMilliseconds;

                //EXTEND
                if (Extensions.ExtensionApp.ExtendMyApp
                        ("alpha_inject", Tick) != null)
                {
                    return;
                }

                //WinsockAsync.Listen();

                Command = "First For";
                for (int i = 1; i <= Globals.Player_Highindex; i++)
                {
                    if (PStruct.tempplayer[i].ingame)
                    {
                        PStruct.PetMove(i);
                    }
                    if ((PStruct.tempplayer[i].SORE) && (PStruct.character[i, PStruct.player[i].SelectedChar].PVPPenalty < Loops.TickCount.ElapsedMilliseconds))
                    {
                        PStruct.tempplayer[i].SORE = false;
                        PStruct.character[i, PStruct.player[i].SelectedChar].PVPPenalty = 0;
                        SendData.Send_PlayerSoreToMap(i);
                        SendData.Send_Animation(PStruct.character[i, PStruct.player[i].SelectedChar].Map, Globals.Target_Player, i, 148);
                    }
                    for (int p = 1; p < Globals.MaxPassiveEffects; p++)
                    {
                        if ((PStruct.ppassiveffect[i, p].active) && (Tick > PStruct.ppassiveffect[i, p].timer))
                        {
                            PStruct.ExecutePassiveEffect(i, p);
                        }
                    }
                    if (PStruct.tempplayer[i].RegenTimer < Tick)
                    {
                        PStruct.PlayerRegen(i);
                    }
                    if ((PStruct.tempplayer[i].preparingskill > 0) && (Tick > PStruct.tempplayer[i].skilltimer))
                    {
                        PlayerLogic.ExecuteSkill(i);
                    }
                    //Dano sobre tempo
                    for (int s = 1; s < Globals.MaxNTempSpells; s++)
                    {
                        if ((PStruct.ptempspell[i, s].active) && (Tick > PStruct.ptempspell[i, s].timer))
                        {
                            PStruct.ExecuteTempSpell(i, s);
                        }
                    }
                    if ((PStruct.tempplayer[i].Stunned) && (PStruct.tempplayer[i].StunTimer < Tick))
                    {
                        SendData.Send_Stun(PStruct.character[i, PStruct.player[i].SelectedChar].Map, 1, i, 0);
                        PStruct.tempplayer[i].Stunned = false;
                    }
                    if ((PStruct.tempplayer[i].Sleeping) && (PStruct.tempplayer[i].SleepTimer < Tick))
                    {
                        SendData.Send_Sleep(PStruct.character[i, PStruct.player[i].SelectedChar].Map, 1, i, 0);
                        PStruct.tempplayer[i].Sleeping = false;
                    }
                    if ((PStruct.tempplayer[i].Blind) && (PStruct.tempplayer[i].BlindTimer < Tick))
                    {
                        //SendData.Send_Stun(PStruct.character[i, PStruct.player[i].SelectedChar].Map, 1, i, 0);
                        PStruct.tempplayer[i].Blind = false;
                    }
                    if ((PStruct.tempplayer[i].Slowed) && (PStruct.tempplayer[i].SlowTimer < Tick))
                    {
                        if (PStruct.tempplayer[i].isFrozen)
                        {
                            PStruct.tempplayer[i].isFrozen = false;
                            SendData.Send_Frozen(Globals.Target_Player, i);
                        }
                        PStruct.tempplayer[i].Slowed    = false;
                        PStruct.tempplayer[i].movespeed = Globals.NormalMoveSpeed;
                        SendData.Send_MoveSpeed(Globals.Target_Player, i);
                    }
                }


                Command = "tmr100";
                if (tmr100 < Tick)
                {
                    for (int i = 0; i <= WinsockAsync.Clients.Count - 1; i++)
                    {
                        if (!WinsockAsync.Clients[i].IsConnected)
                        {
                            if (WinsockAsync.Clients[i].index >= 0)
                            {
                                WinsockAsync.DisconnectUser(i);
                            }
                        }
                    }

                    for (int i = 0; i <= Globals.Max_WorkPoints - 1; i++)
                    {
                        if ((MStruct.tempworkpoint[i].respawn > 0) && (Loops.TickCount.ElapsedMilliseconds > MStruct.tempworkpoint[i].respawn))
                        {
                            MStruct.tempworkpoint[i].vitality = MStruct.workpoint[i].vitality;
                            MStruct.tempworkpoint[i].respawn  = 0;
                            SendData.Send_EventGraphicToMap(MStruct.workpoint[i].map, MStruct.tile[MStruct.workpoint[i].map, MStruct.workpoint[i].x, MStruct.workpoint[i].y].Event_Id, "", 0, Convert.ToByte(MStruct.workpoint[i].active_sprite));
                        }
                    }

                    tmr100 = Tick + 100;
                }

                Command = "tmr256";

                if (tmr256 < Tick)
                {
                    for (int i = 0; i < Globals.MaxMaps; i++)
                    {
                        MStruct.CheckMapItems(i);

                        if (MStruct.tempmap[i].WarActive)
                        {
                            if (Tick > MStruct.tempmap[i].WarTimer)
                            {
                                bool b = false;
                                for (int i2 = 0; i2 <= MStruct.tempmap[i].NpcCount; i2++)
                                {
                                    if (NStruct.tempnpc[i, i2].guildnum > 0)
                                    {
                                        if (NStruct.tempnpc[i, i2].Target > 0)
                                        {
                                            MStruct.tempmap[i].WarTimer += Tick + 20000;
                                            b = true;
                                        }
                                        NStruct.RegenNpc(i, i2, true);
                                    }
                                }
                                if (b)
                                {
                                    break;
                                }
                                SendData.Send_MsgToGuild(MStruct.map[i].guildnum, lang.the_colector_of + " " + MStruct.map[i].name + " " + lang.has_survived, Globals.ColorYellow, Globals.Msg_Type_Server);
                                MStruct.tempmap[i].WarActive = false;
                            }
                        }
                        Command = "NPC COUNT";
                        for (int i2 = 0; i2 <= MStruct.tempmap[i].NpcCount; i2++)
                        {
                            if (i2 > 0)
                            {
                                Command = "TIME DAMAGE";
                                //Dano sobre tempo
                                for (int s = 1; s < Globals.MaxNTempSpells; s++)
                                {
                                    if ((NStruct.ntempspell[i, i2, s].active) && (Tick > NStruct.ntempspell[i, i2, s].timer))
                                    {
                                        NStruct.ExecuteTempSpell(i, i2, s);
                                    }
                                }

                                //Processamento do NPC
                                if (MStruct.ExistPlayerInMap(i))
                                {
                                    Command = "NPC MOVE";
                                    NpcIA.CheckNpcMove(i, i2);
                                    if ((NStruct.tempnpc[i, i2].preparingskill > 0) && (Tick > NStruct.tempnpc[i, i2].skilltimer))
                                    {
                                        Command = "NPC EXECUTE SKILL";
                                        NpcIA.ExecuteSkill(i, i2);
                                    }
                                    if (NStruct.tempnpc[i, i2].RegenTimer < Tick)
                                    {
                                        Command = "REGEN NPC";
                                        NStruct.RegenNpc(i, i2);
                                    }
                                    if ((NStruct.tempnpc[i, i2].Stunned) && (NStruct.tempnpc[i, i2].StunTimer < Tick))
                                    {
                                        Command = "NPC STUN";
                                        SendData.Send_Stun(i, 2, i2, 0);
                                        NStruct.tempnpc[i, i2].Stunned = false;
                                    }
                                    if ((NStruct.tempnpc[i, i2].Sleeping) && (NStruct.tempnpc[i, i2].SleepTimer < Tick))
                                    {
                                        Command = "NPC SLEEP";
                                        SendData.Send_Sleep(i, 2, i2, 0);
                                        NStruct.tempnpc[i, i2].Sleeping = false;
                                    }
                                    if ((NStruct.tempnpc[i, i2].Blind) && (NStruct.tempnpc[i, i2].BlindTimer < Tick))
                                    {
                                        Command = "NPC BLIND";
                                        // A fazer SendData.Send_Stun(i, 2, i2, 0);
                                        NStruct.tempnpc[i, i2].Blind = false;
                                    }
                                    if ((NStruct.tempnpc[i, i2].Slowed) && (NStruct.tempnpc[i, i2].SlowTimer < Tick))
                                    {
                                        if (NStruct.tempnpc[i, i2].isFrozen)
                                        {
                                            NStruct.tempnpc[i, i2].isFrozen = false;
                                            SendData.Send_Frozen(Globals.Target_Npc, i2, i);
                                        }
                                        NStruct.tempnpc[i, i2].Slowed    = false;
                                        NStruct.tempnpc[i, i2].movespeed = Globals.NormalMoveSpeed;
                                        SendData.Send_MoveSpeed(Globals.Target_Npc, i2, i);
                                    }
                                }
                                else
                                {
                                    Command = "NPC SUPER REGEN";
                                    NStruct.RegenNpc(i, i2, true);
                                    if (NStruct.tempnpc[i, i2].Target > 0)
                                    {
                                        NStruct.tempnpc[i, i2].Target = 0;
                                    }
                                }
                                Command = "NPC RESPAWN";
                                if ((NStruct.tempnpc[i, i2].Dead == true) && (Tick > NStruct.tempnpc[i, i2].RespawnTimer))
                                {
                                    //Respawn
                                    NpcIA.NpcRespawned(i, i2);
                                }
                            }
                        }
                        //for (int i2 = 0; i2 <= MStruct.Ge; i2++)
                        // {
                        //}
                    }
                    tmr256 = Tick + 256;
                }
                long test1 = Tick;
                Command = "Save Timer";
                if (Save_Timer < TickCount.ElapsedMilliseconds)
                {                        //Salva o jogador SE PRECISAR
                    if (WinsockAsync.Clients.Count > 0)
                    {
                        for (int i = 0; i < WinsockAsync.Clients.Count; i++)
                        {
                            if (PStruct.tempplayer[WinsockAsync.Clients[i].index].ingame)
                            {
                                Database.SaveCharacter(WinsockAsync.Clients[i].index, PStruct.player[WinsockAsync.Clients[i].index].Email, PStruct.player[WinsockAsync.Clients[i].index].SelectedChar);
                                Database.SaveBank(WinsockAsync.Clients[i].index);
                            }
                        }
                    }
                    Save_Timer = TickCount.ElapsedMilliseconds + 600000;
                    Console.WriteLine(lang.server_has_been_saved);
                }

                Command = "TPP";
                if ((test1 - Tick) > 0)
                {
                    Console.WriteLine("TPP: " + (test1 - Tick));
                }
                Thread.Sleep(10);
            }while (true);
        }
Пример #5
0
        //*********************************************************************************************
        // Main / Revisto pela última vez em 01/08/2016, criado por Allyson S. Bacon
        // Iniciamos o servidor aqui.
        //*********************************************************************************************
        static void Main(string[] args)
        {
            LoadLang();
            Console.WriteLine("");
            Console.WriteLine("///////////////////////////////////////////////////////");
            Console.WriteLine("/                                                     /");
            Console.WriteLine(@"/        ___          _                               /");
            Console.WriteLine(@"/       / __\__  _ __(_) ___ _ __ _   _ _ __ ___      /");
            Console.WriteLine(@"/      / _\/ _ \| '__| |/ _ \ '__| | | | '_ ` _ \     /");
            Console.WriteLine(@"/     / / | (_) | |  | |  __/ |  | |_| | | | | | |    /");
            Console.WriteLine(@"/     \/   \___/|_| _/ |\___|_|   \__,_|_| |_| |_|    /");
            Console.WriteLine(@"/                  |__/                               /");
            Console.WriteLine("/                                                     /");
            Console.WriteLine("/                 http://4tabern.com                  /");
            Console.WriteLine("/         Copyright (C) 2016 Allyson S. Bacon         /");
            Console.WriteLine("/                                                     /");
            Console.WriteLine("///////////////////////////////////////////////////////");

            Console.WriteLine("");
            Console.WriteLine(lang.making_the_query_extensions_in_project);
            Extensions.ExtensionApp.InstanceTypes();

            //EXTEND
            if (Extensions.ExtensionApp.ExtendMyApp
                    (MethodBase.GetCurrentMethod().Name, args) != null)
            {
                return;
            }

            //CÓDIGO PARA RESETAR JOGADORES
            //PStruct.InitializePlayerArrays();
            //Database.ResetAndGiveExp();

            Log(Languages.LStruct.lang.starting_server);
            Log(lang.setting_global_names);
            Globals.GAME_NAME = Database.GET_GAME_NAME();
            Globals.MOTD      = Database.GET_MOTD();
            Globals.NOTICE    = Database.GET_NOTICE();
            Log(lang.starting_server);
            Log(lang.client_defined);
            Log("");
            Log(lang.starting_player_arrays);
            PStruct.InitializePlayerArrays();
            Log(lang.starting_guild_arrays);
            GStruct.InitializeGuildArrays();
            Log(lang.arrays_started);
            Log("");
            Log(lang.loading_enemies);
            Database.LoadEnemies();
            Log(lang.loaded);
            Log(lang.loading_maps_monsters_and_missions);
            Database.LoadMaps();
            Log(lang.loaded);
            Log(lang.loading_items);
            Database.LoadItems();
            Log(lang.loaded);
            Log(lang.loading_weapons);
            Database.LoadWeapons();
            Log(lang.loaded);
            Log(lang.loading_armors);
            Database.LoadArmors();
            Log(lang.loaded);
            Log(lang.loading_skills);
            Database.LoadSkills();
            Log(lang.loaded);
            Log(lang.loading_shops);
            Database.LoadShops();
            //Rudimentar :/
            Database.LoadShopsRud();
            Log(lang.loaded);
            Log(lang.loading_recipes);
            Database.LoadRecipes();
            Log(lang.loaded);
            Log(lang.loading_guilds);
            Database.LoadGuilds();
            Log(lang.loaded);
            Log(lang.loading_classes);
            Database.DEFINE_CLASSES_DATA();
            Log(lang.loaded);
            Log("");
            Log(lang.setting_variables);
            rdn = new Random();
            Log(lang.OK);
            Log("");
            Log(lang.starting_server_loop);
            Log(lang.starting_tcpip_connection);

            WinsockAsync.start();
        }