Advertisement
XConquer

Pole Jugadores [EVENTO PRIVADO]

Feb 26th, 2021 (edited)
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 18.34 KB | None | 0 0
  1. NPCS
  2.  
  3. #region Pole Jugadores
  4.                 #region Pole
  5.                 case 999:
  6.                     {
  7.                         dialog.Text("Bienvenido a Pole Jugadores!.");
  8.                         dialog.Option("Gracias.", 255);
  9.                         dialog.Send();
  10.                         break;
  11.                     }
  12.                 #endregion
  13.                 #region Ir a la Pole Jugadores
  14.                 case 17042021:
  15.                     {
  16.                         switch (npcRequest.OptionID)
  17.                         {
  18.                             case 0:
  19.                                 {
  20.                                     dialog.Text("Quieres Ir a la Pole Jugadores?");
  21.                                     dialog.Option("Quiero Participar!", 8);
  22.  
  23.                                     dialog.Option("No Adios!", 255);
  24.                                     dialog.Send();
  25.                                     break;
  26.                                 }
  27.                             case 8:
  28.                                 {
  29.                                     if (PoleJugadores.IsWar)
  30.                                     {
  31.                                         Random R = new Random();
  32.                                         int Nr = R.Next(2, 8);
  33.                                         if (Nr == 2) client.Entity.Teleport(3973, 224, 112);
  34.                                         if (Nr == 3) client.Entity.Teleport(3973, 226, 122);
  35.                                         if (Nr == 4) client.Entity.Teleport(3973, 227, 139);
  36.                                         if (Nr == 5) client.Entity.Teleport(3973, 228, 153);
  37.                                         if (Nr == 6) client.Entity.Teleport(3973, 227, 162);
  38.                                         if (Nr == 7) client.Entity.Teleport(3973, 229, 178);
  39.                                         if (Nr == 8) client.Entity.Teleport(3973, 149, 167);
  40.                                     }
  41.                                     else
  42.                                     {
  43.                                         dialog.Text("La Pole no Esta Encendida.. Regresa mas Tarde.");
  44.                                         dialog.Option("OK", 255);
  45.                                         dialog.Send();
  46.                                         break;
  47.                                     }
  48.                                     break;
  49.                                 }
  50.                         }
  51.                         break;
  52.                     }
  53.                 #endregion
  54.                 #region Premio Pole Jugadores
  55.                 case 17042020:
  56.                     {
  57.                         switch (npcRequest.OptionID)
  58.                         {
  59.                             case 0:
  60.                                 {
  61.                                     dialog.Text("Hola Quieres Reclamar el Premio De la Pole de Jugadores? .");
  62.                                     dialog.Option("Si, Soy el Ganador", 1);
  63.  
  64.                                     dialog.Option("No Adios!", 255);
  65.                                     dialog.Send();
  66.                                     break;
  67.                                 }
  68.  
  69.                             case 1:
  70.                                 {
  71.  
  72.                                     if (PoleJugadores.KeeperID == client.Entity.UID)
  73.                                     {
  74.                                         dialog.Text("Hola, Quieres Reclamar tu Premio?");
  75.                                         dialog.Option("Si.", 2);
  76.                                         dialog.Option("Ah, No", 255);
  77.                                         dialog.Send();
  78.                                     }
  79.                                     else
  80.                                     {
  81.                                         dialog.Text("Perdon Pero solo el Ganador Puede Reclamar.");
  82.                                         dialog.Option("Ahh.", 255);
  83.                                         dialog.Send();
  84.                                     }
  85.                                     break;
  86.                                 }
  87.                             case 2:
  88.                                 {
  89.                                     if (!PoleJugadores.IsWar)
  90.                                     {
  91.  
  92.                                         if (PoleJugadores.KeeperID != 0)
  93.                                         {
  94.                                             if (PoleJugadores.ReclamarPremioPP && client.Entity.UID == PoleJugadores.KeeperID)
  95.                                             {
  96.  
  97.                                                 PoleJugadores.ReclamarPremioPP = false;
  98.                                                 PoleJugadores.KeeperID = 0;
  99.                                                 client.Entity.ConquerPoints += 200;
  100.                                                 Kernel.SendWorldMessage(new Network.GamePackets.Message("RECLAMO EL PREMIO POR GANAR LA POLE JUGADORES! ARRODILLENSE ANTE EL.", System.Drawing.Color.White, Network.GamePackets.Message.Center), Program.Values);
  101.                                                 if (client.Entity.ContainsFlag3(Update.Flags3.rygh_hglx))
  102.                                                 { client.MessageBox("Ya Posees Este Grandioso Top "); return; }
  103.                                                 client.Entity.AddTopStatus(Update.Flags3.rygh_hglx, 3, DateTime.Now.AddHours(1));
  104.                                             }
  105.                                             else
  106.                                             {
  107.                                                 dialog.Text("Perdon No Tienes Premios.");
  108.                                                 dialog.Option("OK.", 255);
  109.                                                 dialog.Send();
  110.                                                 break;
  111.                                             }
  112.                                         }
  113.                                     }
  114.                                     else
  115.                                     {
  116.                                         dialog.Text("Oye Oye " + client.Entity.Name + "No Puedes Reclamar si la Pole Aun esta Encendida");
  117.                                         dialog.Option("OK", 255);
  118.                                         dialog.Send();
  119.                                         break;
  120.                                     }
  121.                                     break;
  122.                                 }
  123.                         }
  124.                         break;
  125.                     }
  126.                 #endregion
  127.                 #endregion
  128.  
  129.  
  130. ================================================================
  131. Crear una Nueva Clase
  132.  
  133. using Sword.Game;
  134. using Sword.Game.ConquerStructures.Society;
  135. using Sword.Network.GamePackets;
  136. using System;
  137. using System.Collections.Generic;
  138. using System.Linq;
  139. using System.Text;
  140.  
  141. namespace Sword
  142. {
  143.     public unsafe class PoleJugadores
  144.     {
  145.         public static SobNpcSpawn Poles;
  146.         public static SafeDictionary<uint, Entity> Scores = new SafeDictionary<uint, Entity>(100);
  147.         public static bool IsWar = false, FirstRound = false;
  148.         public static Time32 ScoreSendStamp, LastWin;
  149.         public static Entity PoleKeeper, CurrentTopLeader;
  150.         private static bool changed = false;
  151.         private static string[] scoreMessages;
  152.         public static DateTime StartTime;
  153.         public static bool ReclamarPremioPP
  154.         {
  155.             get { return Program.Vars["ppclaim"]; }
  156.             set { Program.Vars["ppclaim"] = value; }
  157.         }
  158.         public static uint KeeperID
  159.         {
  160.             get { return Program.Vars["ppkeeperid"]; }
  161.             set { Program.Vars["ppkeeperid"] = value; }
  162.         }
  163.         public static void PoleJugadoresIniciacion()
  164.         {
  165.             var Map = Kernel.Maps[3973];
  166.             Poles = (SobNpcSpawn)Map.Npcs[999];
  167.         }
  168.         public static void Start()
  169.         {
  170.             if (Poles == null) return;
  171.             ReclamarPremioPP = false;
  172.             Scores = new SafeDictionary<uint, Entity>(100);
  173.             StartTime = DateTime.Now;
  174.             Kernel.SendWorldMessage(new Message("Pole Jugadores Comenzo!", System.Drawing.Color.Red, Message.Center), Program.Values);
  175.             FirstRound = true;
  176.             foreach (Entity PlayerScore in Kernel.PlayerPool.Values)
  177.             {
  178.                 PlayerScore.PoleJugadoresScore = 0;
  179.             }
  180.             IsWar = true;
  181.         }
  182.         public static void Reset()
  183.         {
  184.             Scores = new SafeDictionary<uint, Entity>(100);
  185.             Poles.Hitpoints = Poles.MaxHitpoints;
  186.             foreach (Entity PlayerScore in Kernel.PlayerPool.Values)
  187.             {
  188.                 PlayerScore.PoleJugadoresScore = 0;
  189.             }
  190.             IsWar = true;
  191.         }
  192.         public static void FinishRound()
  193.         {
  194.  
  195.             LastWin = Time32.Now;
  196.             FirstRound = false;
  197.             SortScores(out PoleKeeper);
  198.             //         if (PoleKeeper != null)
  199.             {
  200.                 KeeperID = PoleKeeper.UID;
  201.                 Kernel.SendWorldMessage(new Message("El Jugador, " + PoleKeeper.Name + ", Esta Dominando La Pole De Jugadores!", System.Drawing.Color.Red, Message.Center), Program.Values);
  202.                 if (PoleKeeper.PerdidaPole == 0)
  203.                     PoleKeeper.GanadaPole++;
  204.                 else
  205.                     PoleKeeper.PerdidaPole--;
  206.  
  207.                 Poles.Name = PoleKeeper.Name;
  208.             }
  209.             //   Poles.Name = PoleKeeper.Name;
  210.             Poles.Hitpoints = Poles.MaxHitpoints;
  211.             Kernel.SendWorldMessage(Poles, Program.Values, (ushort)3973);
  212.             Reset();
  213.         }
  214.         public static void End()
  215.         {
  216.             if (PoleKeeper != null)
  217.             {
  218.                 Kernel.SendWorldMessage(new Message("El Jugador " + PoleKeeper.Name + " Gano La Pole De Jugadores!", System.Drawing.Color.White, Message.Center), Program.Values);
  219.             }
  220.             else
  221.             {
  222.                 Kernel.SendWorldMessage(new Message("Pole Jugadores Termino y No Hubo Ganadores!", System.Drawing.Color.Red, Message.Center), Program.Values);
  223.             }
  224.             IsWar = false;
  225.             ReclamarPremioPP = true;
  226.             UpdatePole(Poles);
  227.  
  228.         }
  229.         public static void AddScore(uint addScore, Entity Player)
  230.         {
  231.             if (Player != null)
  232.             {
  233.                 Player.PoleJugadoresScore += addScore;
  234.                 changed = true;
  235.                 if (!Scores.ContainsKey(Player.UID))
  236.                     Scores.Add(Player.UID, Player);
  237.                 if ((int)Poles.Hitpoints <= 0)
  238.                 {
  239.                     FinishRound();
  240.                     return;
  241.                 }
  242.             }
  243.         }
  244.         public static void SendScores()
  245.         {
  246.             if (scoreMessages == null)
  247.                 scoreMessages = new string[0];
  248.             if (Scores.Count == 0)
  249.                 return;
  250.             if (changed)
  251.                 SortScores(out CurrentTopLeader);
  252.             for (int c = 0; c < scoreMessages.Length; c++)
  253.             {
  254.                 Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red,
  255.                     c == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
  256.                 Kernel.SendWorldMessage(msg, Program.Values, (ushort)3973);
  257.                 Kernel.SendWorldMessage(msg, Program.Values, (ushort)3973);
  258.             }
  259.         }
  260.         private static void SortScores(out Entity winner)
  261.         {
  262.             winner = null;
  263.             List<string> ret = new List<string>();
  264.             int Place = 0;
  265.             foreach (Entity Player in Scores.Values.OrderByDescending((p) => p.PoleJugadoresScore))
  266.             {
  267.                 if (Place == 0)
  268.                     winner = Player;
  269.                 string str = "No  " + (Place + 1).ToString() + ": " + Player.Name + "(" + Player.PoleJugadoresScore + ")";
  270.                 ret.Add(str);
  271.                 Place++;
  272.                 if (Place == 4)
  273.                     break;
  274.             }
  275.             changed = false;
  276.             scoreMessages = ret.ToArray();
  277.         }
  278.         private static void UpdatePole(SobNpcSpawn pole)
  279.         {
  280.             new Database.MySqlCommand(Sword.Database.MySqlCommandType.UPDATE)
  281.                 .Update("sobnpcs").Set("name", pole.Name).Set("life", Poles.Hitpoints).Where("id", pole.UID).Execute();
  282.         }
  283.     }
  284. }
  285.  
  286. ===========================================================================
  287. En MsgNpcInfoEx o SobNpcSpawn buscamos "void Die" y Agregamos :
  288.   if (MapID == 3973)//PoleJugadores
  289.             {
  290.                 if (UID != 999)
  291.                 {
  292.                     if (Hitpoints != 0 || Mesh != 251 && Mesh != 281)
  293.                     {
  294.                         if (Mesh == 241)
  295.                             Mesh = (ushort)(250 + Mesh % 10);
  296.                         else
  297.                             Mesh = (ushort)(280 + Mesh % 10);
  298.  
  299.                         Update upd = new Update(true);
  300.                         upd.UID = UID;
  301.                         upd.Append(Update.Mesh, Mesh);
  302.                         killer.Owner.SendScreen(upd, true);
  303.                         Hitpoints = 0;
  304.                     }
  305.                     Attack attack = new Attack(true);
  306.                     attack.Attacker = killer.UID;
  307.                     attack.Attacked = UID;
  308.                     attack.AttackType = Network.GamePackets.Attack.Kill;
  309.                     attack.X = X;
  310.                     attack.Y = Y;
  311.                     killer.Owner.Send(attack);
  312.                     killer.KOCount++;
  313.                 }
  314.             }
  315.  
  316. ============================================================
  317. En Kernel.cs Agregamos :
  318.  
  319.  public static SafeDictionary<uint, Entity> PlayerPool = new SafeDictionary<uint, Entity>(100000);//PoleJugadores
  320.  
  321. ===========================================================
  322. En Program o Server.cs (EN LA PARTE DE CARGA DE LAS COSAS)
  323.  new Game.Map(3973, 3973, Database.DMaps.MapPaths[3973]);//PoleJugadores
  324.  
  325. ===========================================================
  326. En World.cs o Thread.cs (en la parte donde tengan sus eventos pk osea para ir a los eventos) Agregamos
  327.  #region Pole Jugadores
  328.             {
  329.                 foreach (var client in Program.Values)
  330.                     if (client.Entity.MapID == 6000 || client.Entity.MapID == 6001 || client.Entity.MapID == 6002 || client.Entity.MapID == 6003 || client.Entity.MapID == 6004)
  331.                         return;
  332.                 if (!PoleJugadores.IsWar)
  333.                 {
  334.                     if (Now64.Minute == 19 && Now64.Second == 10)
  335.                     {
  336.                         PoleJugadores.Start();
  337.                         foreach (var client in Program.Values)
  338.  
  339.                             client.MessageBox("Pole Jugadores Comenzo Quieres Ir?",
  340.                                 p => { p.Entity.Teleport(1002, 336, 295); }, null);
  341.                     }
  342.                 }
  343.                 if (PoleJugadores.IsWar)
  344.                 {
  345.                     if (Time32.Now > PoleJugadores.ScoreSendStamp.AddSeconds(3))
  346.                     {
  347.                         PoleJugadores.ScoreSendStamp = Time32.Now;
  348.                         PoleJugadores.SendScores();
  349.                     }
  350.                     if (Now64.Minute == 24 && Now64.Second <= 10)
  351.                     {
  352.                         Kernel.SendWorldMessage(new Network.GamePackets.Message("Faltan 5 Minutos Para que Acabe la Pole De Jugadores, Apresurate y Mata a los Noobs.", System.Drawing.Color.White, Network.GamePackets.Message.Center), Program.Values);
  353.                     }
  354.                 }
  355.  
  356.                 if (PoleJugadores.IsWar)
  357.                 {
  358.                     if (Now64.Minute == 30 && Now64.Second == 10)
  359.                     {
  360.                         PoleJugadores.End();
  361.  
  362.                     }
  363.                     if (Now64.Minute == 30 && Now64.Second == 15)
  364.                     {
  365.                         foreach (var client in Program.Values)
  366.                         {
  367.                             client.Entity.Teleport(1002, 300, 240);
  368.                         }
  369.  
  370.                     }
  371.                 }
  372.             }
  373.             #endregion
  374.  
  375. =======================================================
  376. Entity.cs // Player.cs
  377. public uint PoleJugadoresScore,PerdidaPole,GanadaPole;
  378. ======================================================
  379. Handler.cs buscamos void ReceiveAttack --> HAY 2 RECEIVE, DEBEMOS IR AL QUE TENGA SOBNPCSPAWN O MSGNPCINFOEX y Agregamos :
  380. VER IMAGEN : https://prnt.sc/107z8la
  381.  
  382.   if (attacker.MapID == 3973)//Pole Jugadore
  383.             {
  384.                 if (attacked.UID == 999)
  385.                 {
  386.                     if (attacked.Hitpoints <= damage)
  387.                         attacked.Hitpoints = 0;
  388.                     PoleJugadores.AddScore(damage, attacker);
  389.                     attacker.PoleJugadoresScore += damage;
  390.                 }
  391.             }
  392.  
  393.  
  394. Luego Buscamos bool CanAttack lo mismo que arriba la parte de sobnpcspawn o MsgNpcInfoEx
  395.  
  396.   if (attacker.MapID == 3973)//Pole Jugadores
  397.             {
  398.                 if (!PoleJugadores.IsWar)
  399.                 {
  400.                     if (attacked.UID == 999)
  401.                     {
  402.                         return false;
  403.                     }
  404.                 }
  405.                
  406.             }
  407.  if (attacker.MapID == 3973)//Pole Jugadores
  408.             {
  409.                 if (!PoleJugadores.IsWar)
  410.                 {
  411.  
  412.                     if (PoleJugadores.Poles != null)
  413.                         if (attacked.UID == PoleJugadores.Poles.UID)
  414.                             return false;
  415.                 }
  416.                 if (PoleJugadores.PoleKeeper != null)
  417.                 {
  418.                    
  419.                 }
  420.                
  421.  
  422.             }
  423.  
  424. ======================================================
  425. Ahora vamos a Navicat -> Nuestra Base de Datos del Server -> Buscamos y Abrimos la Tabla llamada sobnpcs
  426. https://prnt.sc/107zcz0 -> Ver Imagen para que sepan en que lado debe ir cada cosa.
  427. 999 POLEJUGADORES   10  1137    3973    138 166 16000000    16000000    0   17  1   0
  428. Agregamos manualmente en ORDEN ese codigo.
  429. =====================================================
  430. POSIBLES ERRORES:
  431. Entity -> Player
  432. SobNpcSpawn -> MsgNpcInfoEx
  433. Program.Values -> Server.Values
  434. Message -> MsgTalk
  435. Time32 -> Time64
  436. new Attack = new MsgInteract  ((si hay mas errores de Attack, lo cambian a MsgInteract)
  437.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement