|
المشاركات 1,372 |
+التقييم 0.67 |
تاريخ التسجيل Apr 2019 |
الاقامة شرقيه/زقازيق |
نظام التشغيل |
رقم العضوية 30 |
SuperGuildWar
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HarryPotter.Network.GamePackets;
using HarryPotter.Game.ConquerStructures.Society;
namespace HarryPotter.Game
{
public class SuperGuildWar
{
public static SobNpcSpawn Pole, RightGate, LeftGate;
public static SobNpcSpawn Poles;
public static SafeDictionary<uint, Guild> Scores = new SafeDictionary<uint, Guild>(100);
public static bool IsWar = 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["sgwclaim"]; }
set { Program.Vars["sgwclaim"] = value; }
}
public static uint KeeperID
{
get { return Program.Vars["sgwkeeperid"]; }
set { Program.Vars["sgwkeeperid"] = value; }
}
public static void Initiate()
{
var Map = Kernel.Maps[10380];
Pole = (SobNpcSpawn)Map.Npcs[8100];
LeftGate = (SobNpcSpawn)Map.Npcs[516174];
RightGate = (SobNpcSpawn)Map.Npcs[516175];
Console.WriteLine("SuperGuildWar Information Loaded");
}
public static void Start()
{
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);
Kernel.SendWorldMessage(new Message("Super Guild war has began!", System.Drawing.Color.Red, Message.Center), Program.Values);
FirstRound = true;
foreach (Guild guild in Kernel.Guilds.Values)
{
guild.sWarScore = 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)10380);
upd.Clear();
upd.UID = RightGate.UID;
upd.Append(Update.Mesh, RightGate.Mesh);
upd.Append(Update.Hitpoints, RightGate.Hitpoints);
Kernel.SendWorldMessage(upd, Program.Values, (ushort)10380);
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)10380);
upd.Clear();
upd.UID = RightGate.UID;
upd.Append(Update.Mesh, RightGate.Mesh);
upd.Append(Update.Hitpoints, RightGate.Hitpoints);
Kernel.SendWorldMessage(upd, Program.Values, (ushort)10380);
foreach (Guild guild in Kernel.Guilds.Values)
{
guild.sWarScore = 0;
}
IsWar = true;
}
public static void FinishRound()
{
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 Super guild war 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);
Pole.Name = PoleKeeper.Name;
}
Pole.Hitpoints = Pole.MaxHitpoints;
Kernel.SendWorldMessage(Pole, Program.Values, (ushort)10380);
Reset();
}
public static void End()
{
if (PoleKeeper != null)
{
Kernel.SendWorldMessage(new Message("The guild, " + PoleKeeper.Name + ", owned by " + PoleKeeper.LeaderName + " has won this Super guild war!---Guild war has ended!", System.Drawing.Color.White, Message.Center), Program.Values);
//HarryPotter.Database.EntityTable.Status2();
}
else
{
Kernel.SendWorldMessage(new Message("Super Guild war has ended and there was no winner!", System.Drawing.Color.Red, Message.Center), Program.Values);
//HarryPotter.Database.EntityTable.Status2();
}
IsWar = false;
Claim = true;
UpdatePole(Pole);
}
public static void AddScore(uint addScore, Guild guild)
{
if (guild != null)
{
guild.sWarScore += 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)10380);
Kernel.SendWorldMessage(msg, Program.Values, (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.sWarScore))
{
if (Place == 0)
winner = guild;
string str = "No " + (Place + 1).ToString() + ": " + guild.Name + "(" + guild.sWarScore + ")";
ret.Add(str);
Place++;
if (Place == 4)
break;
}
changed = false;
scoreMessages = ret.ToArray();
}
private static void UpdatePole(SobNpcSpawn pole)
{
new Database.MySqlCommand(HarryPotter.Database.MySqlCommandType.UPDATE)
.Update("sobnpcs").Set("name", pole.Name).Set("life", Pole.Hitpoints).Where("id", pole.UID).Execute();
}
}
}
Handel.cs
if (attacker.MapID == 10380)
if (attacker.MapID == 10380)
{
if (attacker.GuildID == 0 || !Game.SuperGuildWar.IsWar)
{
if (attacked.UID == 8100)
{
return false;
}
}
if (Game.SuperGuildWar.PoleKeeper != null)
{
if (Game.SuperGuildWar.PoleKeeper == attacker.Owner.Guild)
{
if (attacked.UID == 8100)
{
return false;
}
}
else if (attacked.UID == 516175 || attacked.UID == 516174)
{
if (Game.SuperGuildWar.PoleKeeper == attacker.Owner.Guild)
{
if (attacker.PKMode == Enums.PKMode.Team)
return false;
}
}
}
}
Game.GuildWar.AddScore(damage, attacker.Owner.Guild);
if (attacker.MapID == 10380)
{
if (attacked.UID == 8100)
{
if (Game.SuperGuildWar.PoleKeeper == attacker.Owner.Guild)
return;
if (attacked.Hitpoints <= damage)
attacked.Hitpoints = 0;
Game.SuperGuildWar.AddScore(damage, attacker.Owner.Guild);
}
}
Claculations.cs
else if (client.Entity.MapID == HarryPotter.Game.SuperGuildWar.RightGate.MapID)
else if (client.Entity.MapID == HarryPotter.Game.SuperGuildWar.RightGate.MapID)
{
if (HarryPotter.Game.SuperGuildWar.RightGate.Mesh == (270 + HarryPotter.Game.SuperGuildWar.RightGate.Mesh % 10) && oldX >= HarryPotter.Game.SuperGuildWar.RightGate.X && client.Entity.X <= HarryPotter.Game.SuperGuildWar.RightGate.X && client.Entity.Y < HarryPotter.Game.SuperGuildWar.LeftGate.Y)
{
client.Entity.X = oldX;
client.Entity.Y = oldY;
client.Disconnect();
return;
}
if (HarryPotter.Game.SuperGuildWar.LeftGate.Mesh == (240 + HarryPotter.Game.SuperGuildWar.LeftGate.Mesh % 10) && oldY >= HarryPotter.Game.SuperGuildWar.LeftGate.Y && client.Entity.Y <= HarryPotter.Game.SuperGuildWar.LeftGate.Y && client.Entity.X < HarryPotter.Game.SuperGuildWar.RightGate.X)
{
client.Entity.X = oldX;
client.Entity.Y = oldY;
client.Disconnect();
return;
}
}
}
}
}
PacketHandler.cs
if (client.Map.BaseID == 1038 && (HarryPotter.Game.GuildWar.IsWar
|| HarryPotter.Game.SuperGuildWar.IsWar))
if (client.Map.BaseID == 1038 && (HarryPotter.Game.GuildWar.IsWar || HarryPotter.Game.SuperGuildWar.IsWar))
Entity.cs
if (Game.GuildWar.RightGate.Mesh / 10 == 27)
if (Game.SuperGuildWar.RightGate == null)
return false;
if (MapID == 10380)
{
if ((X == 223 || X == 222) && (Y >= 175 && Y <= 185))
{
if (Game.SuperGuildWar.RightGate.Mesh / 10 == 27)
{
return true;
}
}
}
return false;
}
if (Game.GuildWar.LeftGate.Mesh / 10 == 24)
if (Game.SuperGuildWar.LeftGate == null)
return false;
if (MapID == 10380)
{
if ((Y == 210 || Y == 209) && (X >= 154 && X <= 166))
{
if (Game.SuperGuildWar.LeftGate.Mesh / 10 == 24)
{
return true;
}
}
}
return false;
}
Guild.cs
public uint sWarScore;
public bool SuperPoleKeeper
{
get
{
return SuperGuildWar.Pole.Name == Name;
}
}
Game.SuperGuildWar.Initiate();
Console.WriteLine("SuperGuildWar By Emprator");
#region Guild war
#region SuperGuild war
case 10380:
{
switch (client.ActiveNpc)
{
#region Pole
case 8100:
{
dialog.Text("Please, don't hurt me!.");
dialog.Option("Sorry.", 255);
dialog.Send();
break;
}
#endregion
#region SuperClaimGuildPrize
case 44821140:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Hello there. Do you want to Claim Super Guild War Prize you can only Claim it 1 Time if you won SGW.");
dialog.Option("Leme Claim Prize.", 1);
dialog.Option("Get Top.", 3);
dialog.Option("Just Passing By!", 255);
dialog.Send();
break;
}
case 3:
{
if (client.Guild != null)
{
if (client.AsMember.Rank == HarryPotter.Game.Enums.GuildMemberRank.GuildLeader)
{
dialog.Text("Are you sure you want to exchange for your Prize?");
dialog.Option("Yes.", 4);
dialog.Option("Ah, nevermind.", 255);
dialog.Send();
}
else
{
dialog.Text("Sorry only GuildLeader of the Winner Guild can Claim The Prize After SuperGuildWar End.");
dialog.Option("Ahh.", 255);
dialog.Send();
}
}
else
{
dialog.Text("Sorry You are not Member in any guild yet");
dialog.Option("Ahh.", 255);
dialog.Send();
}
break;
}
case 4:
{
var count = client.Inventory.Objects.Where(x => x.ID == 723467).Count();
switch (count)
{
case 0:
{
dialog.Text("Are you sure you have tokens ?");
dialog.Option("Ah, nevermind.", 255);
dialog.Send();
break;
}
case 1:
{
client.Entity.AddTopStatus((ulong)Update.Flags3.ConuqerSuperUnderBlue, DateTime.Now.AddDays(7));
// client.Inventory.Add(2100055, 0, 1);
client.Entity.ConquerPoints += CPanel.GuildWar;
break;
}
case 2:
{
client.Entity.AddTopStatus((ulong)Update.Flags3.ConuqerSuperBlue, DateTime.Now.AddDays(7));
// client.Inventory.Add(2100065, 0, 1);
client.Entity.ConquerPoints += CPanel.EliteGw;
break;
}
default:
{
if (count >= 3)
{
client.Entity.AddTopStatus((ulong)Update.Flags3.ConuqerSuperYellow, DateTime.Now.AddDays(7));
//client.Inventory.Add(2100075, 0, 1);
client.Entity.ConquerPoints += 100000;
}
break;
}
}
client.Inventory.Remove(723467, (byte)Math.Min(count, 3));
break;
}
case 1:
{
if (client.Guild != null)
{
if (client.Guild.SuperPoleKeeper && client.AsMember.Rank == HarryPotter.Game.Enums.GuildMemberRank.GuildLeader)
{
dialog.Text("Are you sure you want to Claim your Prize?");
dialog.Option("Yes.", 2);
dialog.Option("Ah, nevermind.", 255);
dialog.Send();
}
else
{
dialog.Text("Sorry only GuildLeader of the Winner Guild can Claim The Prize After GuildWar End.");
dialog.Option("Ahh.", 255);
dialog.Send();
}
}
else
{
dialog.Text("Sorry You are not Member in any guild yet");
dialog.Option("Ahh.", 255);
dialog.Send();
}
break;
}
case 2:
{
if (!SuperGuildWar.IsWar && SuperGuildWar.Claim && client.Guild != null && client.Entity.GuildID == SuperGuildWar.KeeperID && client.Entity.GuildRank == (ushort)Game.Enums.GuildMemberRank.GuildLeader)
{
//#warning GUILD WAR PRIZE
SuperGuildWar.Claim = false;
SuperGuildWar.KeeperID = 0;
client.Inventory.Add(723467, 0, 1);
HarryPotter.Kernel.SendWorldMessage(new Message("Congratulations! " + client.Entity.Name + " Leader of " + client.Guild.PoleKeeper + " The winner guild has Claimed Super Guild War Prize " + rates.GuildWar + " cps and LordToken!", System.Drawing.Color.White, Message.TopLeft), Program.Values);
}
else
{
dialog.Text("Sorry you dont have Any Prize to claim only GL of the winner guild can claim Prize After SGW");
dialog.Option("Ahh.", 255);
dialog.Send();
}
break;
}
}
break;
}
#endregion
#region Gates
case 516174:
{
if (client.Guild != null)
{
if (client.Guild.SuperPoleKeeper)
{
switch (npcRequest.OptionID)
{
case 0:
dialog.Text("Select the option you want to pursue.");
if (client.AsMember.Rank != HarryPotter.Game.Enums.GuildMemberRank.Member)
{
dialog.Option("Open gate.", 1);
dialog.Option("Close gate.", 2);
}
dialog.Option("Get inside.", 3);
dialog.Option("Nothing.", 255);
dialog.Send();
break;
case 1:
{
HarryPotter.Game.SuperGuildWar.LeftGate.Mesh = (ushort)(250 + HarryPotter.Game.SuperGuildWar.LeftGate.Mesh % 10);
Update upd = new Update(true);
upd.UID = HarryPotter.Game.SuperGuildWar.LeftGate.UID;
upd.Append(Update.Mesh, HarryPotter.Game.SuperGuildWar.LeftGate.Mesh);
client.SendScreen(upd, true);
break;
}
case 2:
{
Game.SuperGuildWar.LeftGate.Mesh = (ushort)(240 + Game.SuperGuildWar.LeftGate.Mesh % 10);
Game.SuperGuildWar.LeftGate.Hitpoints = Game.SuperGuildWar.LeftGate.MaxHitpoints;
Update upd = new Update(true);
upd.UID = HarryPotter.Game.SuperGuildWar.LeftGate.UID;
upd.Append(Update.Mesh, HarryPotter.Game.SuperGuildWar.LeftGate.Mesh);
upd.Append(Update.Hitpoints, HarryPotter.Game.SuperGuildWar.LeftGate.Hitpoints);
client.SendScreen(upd, true);
break;
}
case 3:
{
client.Entity.Teleport(10380, 162, 198);
break;
}
}
}
}
break;
}
case 516175:
{
if (client.Guild != null)
{
if (client.Guild.SuperPoleKeeper)
{
switch (npcRequest.OptionID)
{
case 0:
dialog.Text("Select the option you want to pursue.");
if (client.AsMember.Rank != HarryPotter.Game.Enums.GuildMemberRank.Member)
{
dialog.Option("Open gate.", 1);
dialog.Option("Close gate.", 2);
}
dialog.Option("Get inside.", 3);
dialog.Option("Nothing.", 255);
dialog.Send();
break;
case 1:
{
HarryPotter.Game.SuperGuildWar.RightGate.Mesh = (ushort)(280 + HarryPotter.Game.SuperGuildWar.RightGate.Mesh % 10);
Update upd = new Update(true);
upd.UID = HarryPotter.Game.SuperGuildWar.RightGate.UID;
upd.Append(Update.Mesh, HarryPotter.Game.SuperGuildWar.RightGate.Mesh);
client.SendScreen(upd, true);
break;
}
case 2:
{
HarryPotter.Game.SuperGuildWar.RightGate.Mesh = (ushort)(270 + HarryPotter.Game.SuperGuildWar.RightGate.Mesh % 10);
Game.GuildWar.RightGate.Hitpoints = Game.SuperGuildWar.RightGate.MaxHitpoints;
Update upd = new Update(true);
upd.UID = HarryPotter.Game.SuperGuildWar.RightGate.UID;
upd.Append(Update.Mesh, HarryPotter.Game.SuperGuildWar.RightGate.Mesh);
upd.Append(Update.Hitpoints, HarryPotter.Game.SuperGuildWar.RightGate.Hitpoints);
client.SendScreen(upd, true);
break;
}
case 3:
{
client.Entity.Teleport(10380, 210, 177);
break;
}
}
}
}
break;
}
#endregion
#region Guild Conductresses
#region Exit Guild Arena
case 70000:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Do you want to leave the guild arena?");
dialog.Option("Yes.", 1);
dialog.Option("No.", 255);
dialog.Send();
break;
}
case 1:
{
client.Entity.Teleport(1002, 429, 378);
break;
}
}
break;
}
#endregion
#endregion
}
break;
}
#endregion
#region SuperGuildWar
if (Now64.DayOfWeek != DayOfWeek.Friday && Now64.DayOfWeek != DayOfWeek.Monday)
if (DateTime.Now.Hour == 21 && DateTime.Now.Minute == 00 && DateTime.Now.Second <= 00)
{ // By HaMaDa.ShaDow // TorNaDo-TeaM === forum.vpscairo.com
Game.SuperGuildWar.Start();
Kernel.SendWorldMessage(new HarryPotter.Network.GamePackets.Message("SuperGuildWar Is Started Now !", Color.Red, 2012));
foreach (var client in Program.Values)
client.MessageBox("SuperGuild War began! Would You Like To Join?",
p => { p.Entity.Teleport(1002, 300, 358); }, null, 60);
if (Game.SuperGuildWar.IsWar)
Kernel.SendWorldMessage(new Message("You Have To Be Ready For The SuperGuild War !", Color.White, Message.Center), Program.Values);
{
if (Time32.Now > Game.SuperGuildWar.ScoreSendStamp.AddSeconds(3))
{
Game.SuperGuildWar.ScoreSendStamp = Time32.Now;
Game.SuperGuildWar.SendScores();
}
if (DateTime.Now.Hour == 21 && DateTime.Now.Minute == 50 && DateTime.Now.Second <= 2)
{
Kernel.SendWorldMessage(new Network.GamePackets.Message("10 Minutes left till Super GuildWar End Hurry kick other Guild's Ass!.", System.Drawing.Color.White, Network.GamePackets.Message.Center), Program.Values);
}
}
}
else if (DateTime.Now.Hour == 22 && DateTime.Now.Minute == 00 && DateTime.Now.Second == 00)
{
if (Game.SuperGuildWar.IsWar)
{
Game.SuperGuildWar.End();
}
}
#endregion
Entity.cs
case Network.GamePackets.Update.Flags2.TopPirate: return 22;
case Network.GamePackets.Update.Flags3.ConuqerSuperUnderBlue: return 230;
case Network.GamePackets.Update.Flags3.ConuqerSuperBlue: return 240;
case Network.GamePackets.Update.Flags3.ConuqerSuperYellow: return 250;
case 22: return Network.GamePackets.Update.Flags2.TopPirate;
ase 230: return Network.GamePackets.Update.Flags3.ConuqerSuperUnderBlue;
case 240: return Network.GamePackets.Update.Flags3.ConuqerSuperBlue;
case 250: return Network.GamePackets.Update.Flags3.ConuqerSuperYellow;
Update.cs
public class Flags3
ConuqerSuperYellow = (ulong)1UL << 23, //GL flag
ConuqerSuperBlue = (ulong)1UL << 24, //DL flag
ConuqerSuperUnderBlue = (ulong)1UL << 25, // Memeber Flag
Maps
10380 1038 0 0
..
Sobnpcs
8100 Hassan.Emprator 10 1137 10380 84 99 23446500 30000000 0 17 1 0
516174 ii 26 251 10380 163 210 10000000 10000000 24 21 0 0
516175 ii 26 277 10380 223 177 10000000 10000000 27 21 0 0
..
Npc
44821140 Super Guild War 2 8160 10380 44 60
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
أدوات الموضوع | |
|