|
المشاركات 1,372 |
+التقييم 0.68 |
تاريخ التسجيل Apr 2019 |
الاقامة شرقيه/زقازيق |
نظام التشغيل |
رقم العضوية 30 |
PoleIslanD
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EmpratorServer.Network.GamePackets;
using EmpratorServer.Game.ConquerStructures.Society;
namespace EmpratorServer.Game
{
public class PoleIslanD
{
public static SobNpcSpawn Pole, RightGate, LeftGate;
public static SobNpcSpawn Poles;
public const ushort MapID = 2075;
public static SafeDictionary<uint, Guild> Scores = new SafeDictionary<uint, Guild>(100);
public static bool IsWar = false, Flame10th = false, FirstRound = false;
public static Time32 ScoreSendStamp, LastWin;
public static Guild PoleKeeper, CurrentTopLeader;
private static bool changed = false;
private static string[] scoreMessages;
public static DateTime StartTime;
public static bool Claim
{
get { return Program.Vars["pwclaim"]; }
set { Program.Vars["pwclaim"] = value; }
}
public static uint KeeperID
{
get { return Program.Vars["pwkeeperid"]; }
set { Program.Vars["pwkeeperid"] = value; }
}
public static void PoleIslanDIni()
{
var Map = Kernel.Maps[2075];
Pole = (SobNpcSpawn)Map.Npcs[815];
LeftGate = (SobNpcSpawn)Map.Npcs[516020];
RightGate = (SobNpcSpawn)Map.Npcs[516021];
}
public static void Start()
{
object[] name;
if (LeftGate == null) return;
Scores = new SafeDictionary<uint, Guild>(100);
StartTime = DateTime.Now;
LeftGate.Mesh = (ushort)(240 + LeftGate.Mesh % 10);
RightGate.Mesh = (ushort)(270 + LeftGate.Mesh % 10);
name = new object[] { "Quest PoleIslanD Has Started Go To Guild Controller At TwinCity (352,337)" };
Kernel.SendWorldMessage(new Message(string.Concat(name), "ALLUSERS", "PoleIslanD", System.Drawing.Color.Red, 2500), Program.Values);
Kernel.SendWorldMessage(new Message("PoleIslanD has began!", System.Drawing.Color.Red, Message.Center), Program.Values);
FirstRound = true;
foreach (Guild guild in Kernel.Guilds.Values)
{
guild.PIScore = 0;
}
Update upd = new Update(true);
upd.UID = LeftGate.UID;
upd.Append(Update.Mesh, LeftGate.Mesh);
upd.Append(Update.Hitpoints, LeftGate.Hitpoints);
Kernel.SendWorldMessage(upd, Program.Values, (ushort)2075);
upd.Clear();
upd.UID = RightGate.UID;
upd.Append(Update.Mesh, RightGate.Mesh);
upd.Append(Update.Hitpoints, RightGate.Hitpoints);
Kernel.SendWorldMessage(upd, Program.Values, (ushort)2075);
Claim = false;
IsWar = true;
}
public static void Reset()
{
Scores = new SafeDictionary<uint, Guild>(100);
LeftGate.Mesh = (ushort)(240 + LeftGate.Mesh % 10);
RightGate.Mesh = (ushort)(270 + LeftGate.Mesh % 10);
LeftGate.Hitpoints = LeftGate.MaxHitpoints;
RightGate.Hitpoints = RightGate.MaxHitpoints;
Pole.Hitpoints = Pole.MaxHitpoints;
Update upd = new Update(true);
upd.UID = LeftGate.UID;
upd.Append(Update.Mesh, LeftGate.Mesh);
upd.Append(Update.Hitpoints, LeftGate.Hitpoints);
Kernel.SendWorldMessage(upd, Program.Values, (ushort)2075);
upd.Clear();
upd.UID = RightGate.UID;
upd.Append(Update.Mesh, RightGate.Mesh);
upd.Append(Update.Hitpoints, RightGate.Hitpoints);
Kernel.SendWorldMessage(upd, Program.Values, (ushort)2075);
foreach (Guild guild in Kernel.Guilds.Values)
{
guild.PIScore = 0;
}
IsWar = true;
}
public static void FinishRound()
{
if (PoleKeeper != null && !FirstRound)
{
if (PoleKeeper.Wins == 0)
PoleKeeper.Losts++;
else
PoleKeeper.Wins--;
Database.GuildTable.UpdateGuildWarStats(PoleKeeper);
}
LastWin = Time32.Now;
FirstRound = false;
SortScores(out PoleKeeper);
if (PoleKeeper != null)
{
KeeperID = PoleKeeper.ID;
Kernel.SendWorldMessage(new Message("The guild, " + PoleKeeper.Name + ", owned by " + PoleKeeper.LeaderName + " has won this PoleIslanD round!", System.Drawing.Color.Red, Message.Center), Program.Values);
Kernel.SendWorldMessage(new Message("It is generald pardon time. You have 5 minutes to leave, run for your life!", System.Drawing.Color.White, Message.TopLeft), Program.Values, (ushort)6001);
if (PoleKeeper.Losts == 0)
PoleKeeper.Wins++;
else
PoleKeeper.Losts--;
Database.GuildTable.UpdateGuildWarStats(PoleKeeper);
Pole.Name = PoleKeeper.Name;
}
Pole.Hitpoints = Pole.MaxHitpoints;
Kernel.SendWorldMessage(Pole, Program.Values, (ushort)2075);
Reset();
}
public static void End()
{
if (PoleKeeper != null)
{
Kernel.SendWorldMessage(new Message("The guild, " + PoleKeeper.Name + ", owned by " + PoleKeeper.LeaderName + " has won this PoleIslanD!---PoleIslanD has ended!", System.Drawing.Color.White, Message.Center), Program.Values);
//EmpratorServer.Database.EntityTable.Status2();
}
else
{
Kernel.SendWorldMessage(new Message("PoleIslanD has ended and there was no winner!", System.Drawing.Color.Red, Message.Center), Program.Values);
//EmpratorServer.Database.EntityTable.Status2();
}
IsWar = false;
Claim = true;
UpdatePole(Pole);
foreach (Client.GameState client in Program.Values)
{
//client.Entity.Status2 = 0;
//client.Entity.RemoveFlag(Network.GamePackets.Update.Flags.TopDeputyLeader);
//client.Entity.RemoveFlag(Network.GamePackets.Update.Flags.TopGuildLeader);
}
}
public static void AddScore(uint addScore, Guild guild)
{
if (guild != null)
{
guild.PIScore += addScore;
changed = true;
if (!Scores.ContainsKey(guild.ID))
Scores.Add(guild.ID, guild);
if ((int)Pole.Hitpoints <= 0)
{
FinishRound();
return;
}
}
}
public static void SendScores()
{
if (scoreMessages == null)
scoreMessages = new string[0];
if (Scores.Count == 0)
return;
if (changed)
SortScores(out CurrentTopLeader);
for (int c = 0; c < scoreMessages.Length; c++)
{
Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red, c == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
Kernel.SendWorldMessage(msg, Program.Values, (ushort)2075);
//Kernel.SendWorldMessage(msg, Program.GamePool, (ushort)6001);
}
}
private static void SortScores(out Guild winner)
{
winner = null;
List<string> ret = new List<string>();
int Place = 0;
foreach (Guild guild in Scores.Values.OrderByDescending((p) => p.PTScore))
{
if (Place == 0)
winner = guild;
string str = "No " + (Place + 1).ToString() + ": " + guild.Name + "(" + guild.PTScore + ")";
ret.Add(str);
Place++;
if (Place == 4)
break;
}
changed = false;
scoreMessages = ret.ToArray();
}
private static void UpdatePole(SobNpcSpawn pole)
{
new Database.MySqlCommand(EmpratorServer.Database.MySqlCommandType.UPDATE)
.Update("sobnpcs").Set("name", pole.Name).Set("life", Pole.Hitpoints).Where("id", pole.UID).Execute();
}
}
}
#region PoleIslanD
case 115202:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Hey there " + client.Entity.Name + " Would you like to Join PoleIslanD?.");
dialog.Text("or claim the Prize?, you can join Every day At 16:00 to 17:00.");
dialog.Text("and the winner Guild Leader will get 999.999.999 cps after it finish u have 5 minutes to claim?.");
dialog.Option("Join PoleIslanD", 1);
dialog.Option("Claim Prize.", 5);
dialog.Send();
break;
}
case 1:
{
if (PoleIslanD.IsWar)
{
Random R = new Random();
int Nr = R.Next(1, 7);
if (Nr == 1) client.Entity.Teleport(2075, 790, 571);
if (Nr == 2) client.Entity.Teleport(2075, 790, 534);
if (Nr == 3) client.Entity.Teleport(2075, 790, 590);
if (Nr == 4) client.Entity.Teleport(2075, 789, 620);
if (Nr == 5) client.Entity.Teleport(2075, 759, 530);
if (Nr == 6) client.Entity.Teleport(2075, 737, 624);
if (Nr == 7) client.Entity.Teleport(2075, 713, 622);
}
else
{
dialog.Text("The war is not held now! It will start every day at 16:00");
dialog.Option("okay", 255);
dialog.Send();
break;
}
break;
}
case 5:
{
if (!PoleIslanD.IsWar)
{
if (client.Guild != null)
{
if (PoleIslanD.KeeperID != 0)
{
if (PoleIslanD.Claim && client.AsMember.Rank == Game.Enums.GuildMemberRank.GuildLeader && client.Guild.ID == PoleIslanD.KeeperID)
{
PoleIslanD.Claim = false;
PoleIslanD.KeeperID = 0;
EmpratorServer.Kernel.SendWorldMessage(new Message("Congratulations! " + client.Entity.Name + " claimed the prize 999.999.999 CPs for winning the PoleIslanD.", System.Drawing.Color.Black, Message.Center), Program.Values);
client.Entity.ConquerPoints += ServerRates.Poles;
Program.AddWarLog("Pole", "5.00.000.000 CPS", client.Entity.Name);
}
else
{
dialog.Text("sorry u dont have any prize to claim....");
dialog.Option("okay", 255);
dialog.Send();
break;
}
}
}
else
{
dialog.Text("sorry u dont have any prize to claim");
dialog.Option("okay", 255);
dialog.Send();
break;
}
}
else
{
dialog.Text("Hey there " + client.Entity.Name + " You can't get the prize while the war is on!");
dialog.Option("okay", 255);
dialog.Send();
break;
}
break;
}
}
break;
}
#endregion
#region PoleIslanD
case 815:
{
dialog.Text("Welcome in PoleIslanD HaveFun!.");
dialog.Option("Thanks.", 255);
dialog.Send();
break;
}
#endregion
public static void ReceiveAttack(Game.Entity attacker, SobNpcSpawn attacked, Attack attack, uint damage,
if (attacked.UID == 123456)
if (attacker.MapID == 2075)
{
if (attacked.UID == 815)
{
if (Game.PoleIslanD.PoleKeeper == attacker.Owner.Guild)
return;
if (attacked.Hitpoints <= damage)
attacked.Hitpoints = 0;
Game.PoleIslanD.AddScore(damage, attacker.Owner.Guild);
}
}
public static bool CanAttack(Game.Entity attacker, SobNpcSpawn attacked,
if (Game.PoleIslanD.PoleKeeper != null)
if (attacker.MapID == 2075)
{
if (attacker.GuildID == 0 || !Game.PoleIslanD.IsWar)
{
if (attacked.UID == 815)
{
return false;
}
}
case "island":
{
switch (Data[1])
{
case "on": PoleIslanD.Start();
foreach (var cclient in Program.Values)
cclient.MessageBox("PoleIslanD has begun! Would you like to join?",
p => { p.Entity.Teleport(1002, 313, 267); }, null); break;
case "off": PoleIslanD.End(); break;
}
break;
}
Database.MapsTable.Load();
Game.PoleIslanD.PoleIslanDIni();
Console.WriteLine("PoleIslanD initializated.");
#region PoleIslanD
if (!Game.PoleIslanD.IsWar)
{
if (Now64.Hour == 16 && Now64.Minute == 00 && Now64.Second == 04)
{
Game.PoleIslanD.Start();
foreach (var client in Program.Values)
if (client.Entity.MapID == 6000 || client.Entity.MapID == 6001 || client.Entity.MapID == 6002 || client.Entity.MapID == 6003 || client.Entity.MapID == 6004)
return;
foreach (var client in Program.Values)
if (client.Entity.GuildID != 0)
client.MessageBox("PoleIslanD has begun! Would you like to join? ",
p => { p.Entity.Teleport(1002, 278, 192); }, null);
}
}
if (Game.PoleIslanD.IsWar)
{
if (Time32.Now > Game.PoleIslanD.ScoreSendStamp.AddSeconds(3))
{
Game.PoleIslanD.ScoreSendStamp = Time32.Now;
Game.PoleIslanD.SendScores();
}
if (Now64.Hour == 16 && Now64.Minute == 50 && Now64.Second <= 2)
{
Kernel.SendWorldMessage(new Network.GamePackets.Message("10 Minutes left till PoleIslanD End Hurry kick other Guild's Ass!.", System.Drawing.Color.White, Network.GamePackets.Message.Center), Program.Values);
}
}
if (Game.PoleIslanD.IsWar)
{
if (Now64.Hour == 17 && Now64.Minute == 00 && Now64.Second == 04)
{
Game.PoleIslanD.End();
{
}
}
}
#endregion
new Game.Map(2075, Database.DMaps.MapPaths[2075]);
public void Die(Game.Entity killer)
if (MapID == 2075)//island
{
if (UID != 815)
{
if (Hitpoints != 0 || Mesh != 252 && Mesh != 282)
{
if (Mesh == 241)
Mesh = (ushort)(250 + Mesh % 10);
else
Mesh = (ushort)(280 + Mesh % 10);
Update upd = new Update(true);
upd.UID = UID;
upd.Append(Update.Mesh, Mesh);
killer.Owner.SendScreen(upd, true);
Hitpoints = 0;
}
public static readonly System.Collections.Generic.List<ushort> PKFreeMaps
2075,
2075 2075 7 0