Exemple #1
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.Handler.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_Highs; i++)
                {
                    if (PlayerStruct.tempplayer[i].ingame)
                    {
                        PetRelations.petMove(i);
                    }
                    if ((PlayerStruct.tempplayer[i].SORE) && (PlayerStruct.character[i, PlayerStruct.player[i].SelectedChar].PVPPenalty < Loops.TickCount.ElapsedMilliseconds))
                    {
                        PlayerStruct.tempplayer[i].SORE = false;
                        PlayerStruct.character[i, PlayerStruct.player[i].SelectedChar].PVPPenalty = 0;
                        SendData.sendPlayerSoreToMap(i);
                        SendData.sendAnimation(PlayerStruct.character[i, PlayerStruct.player[i].SelectedChar].Map, Globals.Target_Player, i, 148);
                    }
                    for (int p = 1; p < Globals.MaxPassiveEffects; p++)
                    {
                        if ((PlayerStruct.ppassiveffect[i, p].active) && (Tick > PlayerStruct.ppassiveffect[i, p].timer))
                        {
                            SkillRelations.executePassiveEffect(i, p);
                        }
                    }
                    if (PlayerStruct.tempplayer[i].RegenTimer < Tick)
                    {
                        PlayerRelations.playerRegen(i);
                    }
                    if ((PlayerStruct.tempplayer[i].preparingskill > 0) && (Tick > PlayerStruct.tempplayer[i].skilltimer))
                    {
                        PlayerLogic.ExecuteSkill(i);
                    }
                    //Dano sobre tempo
                    for (int s = 1; s < Globals.MaxNTempSpells; s++)
                    {
                        if ((PlayerStruct.ptempspell[i, s].active) && (Tick > PlayerStruct.ptempspell[i, s].timer))
                        {
                            SkillRelations.executeTempSpell(i, s);
                        }
                    }
                    if ((PlayerStruct.tempplayer[i].Stunned) && (PlayerStruct.tempplayer[i].StunTimer < Tick))
                    {
                        SendData.sendStun(PlayerStruct.character[i, PlayerStruct.player[i].SelectedChar].Map, 1, i, 0);
                        PlayerStruct.tempplayer[i].Stunned = false;
                    }
                    if ((PlayerStruct.tempplayer[i].Sleeping) && (PlayerStruct.tempplayer[i].SleepTimer < Tick))
                    {
                        SendData.sendSleep(PlayerStruct.character[i, PlayerStruct.player[i].SelectedChar].Map, 1, i, 0);
                        PlayerStruct.tempplayer[i].Sleeping = false;
                    }
                    if ((PlayerStruct.tempplayer[i].Blind) && (PlayerStruct.tempplayer[i].BlindTimer < Tick))
                    {
                        //SendData.sendStun(PlayerStruct.character[i, PlayerStruct.player[i].SelectedChar].Map, 1, i, 0);
                        PlayerStruct.tempplayer[i].Blind = false;
                    }
                    if ((PlayerStruct.tempplayer[i].Slowed) && (PlayerStruct.tempplayer[i].SlowTimer < Tick))
                    {
                        if (PlayerStruct.tempplayer[i].isFrozen)
                        {
                            PlayerStruct.tempplayer[i].isFrozen = false;
                            SendData.sendFrozen(Globals.Target_Player, i);
                        }
                        PlayerStruct.tempplayer[i].Slowed    = false;
                        PlayerStruct.tempplayer[i].movespeed = Globals.NormalMoveSpeed;
                        SendData.sendMoveSpeed(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].s >= 0)
                            {
                                WinsockAsync.disconnectUser(i);
                            }
                        }
                    }

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

                    tmr100 = Tick + 100;
                }

                Command = "tmr256";

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

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

                                //Processamento do NPC
                                if (MapStruct.ExistPlayerInMap(i))
                                {
                                    Command = "NPC MOVE";
                                    NpcIA.CheckNpcMove(i, i2);
                                    if ((NpcStruct.tempnpc[i, i2].preparingskill > 0) && (Tick > NpcStruct.tempnpc[i, i2].skilltimer))
                                    {
                                        Command = "NPC EXECUTE SKILL";
                                        NpcIA.ExecuteSkill(i, i2);
                                    }
                                    if (NpcStruct.tempnpc[i, i2].RegenTimer < Tick)
                                    {
                                        Command = "REGEN NPC";
                                        NpcStruct.RegenNpc(i, i2);
                                    }
                                    if ((NpcStruct.tempnpc[i, i2].Stunned) && (NpcStruct.tempnpc[i, i2].StunTimer < Tick))
                                    {
                                        Command = "NPC STUN";
                                        SendData.sendStun(i, 2, i2, 0);
                                        NpcStruct.tempnpc[i, i2].Stunned = false;
                                    }
                                    if ((NpcStruct.tempnpc[i, i2].Sleeping) && (NpcStruct.tempnpc[i, i2].SleepTimer < Tick))
                                    {
                                        Command = "NPC SLEEP";
                                        SendData.sendSleep(i, 2, i2, 0);
                                        NpcStruct.tempnpc[i, i2].Sleeping = false;
                                    }
                                    if ((NpcStruct.tempnpc[i, i2].Blind) && (NpcStruct.tempnpc[i, i2].BlindTimer < Tick))
                                    {
                                        Command = "NPC BLIND";
                                        // A fazer SendData.sendStun(i, 2, i2, 0);
                                        NpcStruct.tempnpc[i, i2].Blind = false;
                                    }
                                    if ((NpcStruct.tempnpc[i, i2].Slowed) && (NpcStruct.tempnpc[i, i2].SlowTimer < Tick))
                                    {
                                        if (NpcStruct.tempnpc[i, i2].isFrozen)
                                        {
                                            NpcStruct.tempnpc[i, i2].isFrozen = false;
                                            SendData.sendFrozen(Globals.Target_Npc, i2, i);
                                        }
                                        NpcStruct.tempnpc[i, i2].Slowed    = false;
                                        NpcStruct.tempnpc[i, i2].movespeed = Globals.NormalMoveSpeed;
                                        SendData.sendMoveSpeed(Globals.Target_Npc, i2, i);
                                    }
                                }
                                else
                                {
                                    Command = "NPC SUPER REGEN";
                                    NpcStruct.RegenNpc(i, i2, true);
                                    if (NpcStruct.tempnpc[i, i2].Target > 0)
                                    {
                                        NpcStruct.tempnpc[i, i2].Target = 0;
                                    }
                                }
                                Command = "NPC RESPAWN";
                                if ((NpcStruct.tempnpc[i, i2].Dead == true) && (Tick > NpcStruct.tempnpc[i, i2].RespawnTimer))
                                {
                                    //Respawn
                                    NpcIA.NpcRespawned(i, i2);
                                }
                            }
                        }
                        //for (int i2 = 0; i2 <= MapStruct.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 (PlayerStruct.tempplayer[WinsockAsync.Clients[i].s].ingame)
                            {
                                Database.Characters.saveCharacter(WinsockAsync.Clients[i].s, PlayerStruct.player[WinsockAsync.Clients[i].s].Email, PlayerStruct.player[WinsockAsync.Clients[i].s].SelectedChar);
                                Database.Banks.saveBank(WinsockAsync.Clients[i].s);
                            }
                        }
                    }
                    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);
        }
Exemple #2
0
        public static void AlphaLoop()
        {
            long tmr100;
            long tmr256;
            long Tick;

            tmr100 = 0;
            tmr256 = 0;
            Database.DefineAdmin();
            WinsockAsync.Log("Servidor iniciado no dia " + DateTime.Now);

            do
            {
                Tick = TickCount.ElapsedMilliseconds;

                //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, "O coletor de " + MStruct.map[i].name + " se recuperou do ataque!", 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("Servidor Salvo.");
                }

                Command = "TPP";
                if ((test1 - Tick) > 0)
                {
                    Console.WriteLine("TPP: " + (test1 - Tick));
                }
                Thread.Sleep(10);
            }while (true);
        }