|
المشاركات 1,372 |
+التقييم 0.68 |
تاريخ التسجيل Apr 2019 |
الاقامة شرقيه/زقازيق |
نظام التشغيل |
رقم العضوية 30 |
#region [ GuildPolerWar ] [ xx : 44]
case 41167:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Hello There. Do you want to Join The GuildPoleWar?.");
dialog.Option("Yes Please.", 1);
dialog.Option("Cliam Prize.", 2);
dialog.Option("Just Passing By!", 255);
dialog.Send();
break;
}
case 1:
{
if (GuildPoleWar.IsWar)
{
GuildPoleWar.Join(client);
}
else
{
dialog.Text("The War Has Not Started [Pole Started [44] End [50] Minat] ");
dialog.Option("Aww ok!", 255);
dialog.Send();
}
break;
}
case 2:
{
if (!GuildPoleWar.IsWar)
{
GuildPoleWar.GetReward(client, 15000);
}
else
{
dialog.Text("Sorry you can claim Prize After its end");
dialog.Option("Ahh.", 255);
dialog.Send();
}
break;
}
}
break;
}
#endregion
public static void ReceiveAttack(Game.Entity attacker, SobNpcSpawn attacked, Attack attack, uint damage, Database.SpellInformation spell)
#region GuildPoleWar
if (GuildPoleWar.IsWar)
{
if (attacker.MapID == GuildPoleWar.Map.ID)
{
GuildPoleWar.Attack(damage, attacker, attacked);
}
}
#endregion
public static bool CanAttack(Game.Entity attacker, SobNpcSpawn attacked, Database.SpellInformation spell)
#region GuildPoleWar
if (GuildPoleWar.IsWar)
{
if (attacker.MapID == GuildPoleWar.Map.ID)
{
return GuildPoleWar.Attack(0, attacker, attacked);
}
}
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading.Generic;
using MrHassan.Game;
using MrHassan;
using MrHassan.Network.GamePackets;
using MrHassan.Client;
namespace MrHassan.Game
{
public class GuildPoleWar
{
public const int Member = 0,
DeputyLeader = 1,
GuildLeader = 2;
public static uint UidPolaGuildLeader = 0;
public static uint UidPolaDubLeader = 0;
public static uint UidPolaMemberLeader = 0;
public static SobNpcSpawn[] Poles = new SobNpcSpawn[3];
public static uint[] PolesWinners = new uint[3];
public static SafeDictionary<uint, Entity>[] AllScores = new SafeDictionary<uint, Entity>[3];
public static DateTime WarStart;
public static Map Map;
public static bool IsWar = false;
public static bool claim1 = false;
public static bool claim2 = false;
public static bool claim3 = false;
public static IDisposable SubscriberMax;
public GuildPoleWar()
{
Map = Kernel.Maps[50016];
SubscriberMax = World.Subscribe(work, 1000);
}
public void work(int time)
{
if (IsWar)
{
if (Time32.Now > ScoreSendStamp.AddSeconds(3))
{
ScoreSendStamp = Time32.Now;
SendScores();
}
}
}
public static void Join(GameState client)
{
if (IsWar)
{
//var cooord = Map.RandomCoordinates();
client.Entity.Teleport(Map.ID, 315, 330);
client.OnDisconnect = p =>
{
p.Entity.Teleport(1002, 300, 278);
};
}
}
public static void StartWar()
{
try
{
IsWar = true;
WarStart = DateTime.Now;
Poles = new SobNpcSpawn[3];
PolesWinners = new uint[3];
claim1 = false;
claim2 = false;
claim3 = false;
Map.Statues.Clear();
Map.Npcs.Clear();
Start();
Summon("GuildLeader", 300, 288, GuildLeader);
Summon("DeputyLeader", 300, 268, DeputyLeader);
Summon("Member", 327, 266, Member);
}
catch (Exception ex)
{
//Program.SaveException(ex, true);
}
}
public static bool Attack(uint addScore, Entity entity, SobNpcSpawn Pole)
{
if (!IsWar)
return false;
int _rank = (int)Member;
if (entity.GuildRank == (ushort)Enums.GuildMemberRank.GuildLeader)
_rank = GuildLeader;
else if (entity.GuildRank == (ushort)Enums.GuildMemberRank.DeputyLeader)
_rank = DeputyLeader;
var pole = Poles[_rank];
if (pole != null)
{
if (pole != Pole)
return false;
if (PolesWinners[_rank] == entity.UID)
return false;
if (addScore > 0)
{
AddScore(addScore, entity, pole);
}
return true;
}
return false;
}
public static bool Attack2(Entity entity, SobNpcSpawn Pole)
{
if (!IsWar)
return false;
int _rank = (int)Member;
if (entity.GuildRank == (ushort)Enums.GuildMemberRank.GuildLeader)
_rank = GuildLeader;
else if (entity.GuildRank == (ushort)Enums.GuildMemberRank.DeputyLeader)
_rank = DeputyLeader;
var pole = Poles[_rank];
if (pole != null)
{
if (pole != Pole)
return false;
if (PolesWinners[_rank] == entity.UID)
return false;
return true;
}
return false;
}
public static void Summon(string Name, ushort X, ushort Y, int rank)
{
SobNpcSpawn Base = new SobNpcSpawn();
Base.UID = Map.EntityUIDCounter2.Next + 100;
Base.Mesh = 1137;
Base.Type = (Enums.NpcType)10;
Base.Sort = 21;
Base.ShowName = true;
Base.Name = Name;
Base.Hitpoints = Base.MaxHitpoints = 30000000;
Base.MapID = Map.ID;
Base.X = X;
Base.Y = Y;
Poles[rank] = Base;
if (!Map.Npcs.ContainsKey(Base.UID))
Map.Npcs.Add(Base.UID, Base);
}
#region Score
public static bool FirstRound = false;
public static Time32 ScoreSendStamp, LastWin;
public static void Start()
{
AllScores = new SafeDictionary<uint, Entity>[3];
WarStart = DateTime.Now;
FirstRound = true;
foreach (var c in Program.Values)
c.Entity.WarScore = 0;
IsWar = true;
}
public static void Reset(int _Class)
{
var rank = Enums.GuildMemberRank.Member;
if (_Class == DeputyLeader)
rank = Enums.GuildMemberRank.DeputyLeader;
if (_Class == GuildLeader)
rank = Enums.GuildMemberRank.GuildLeader;
foreach (var c in Program.Values.Where(p => p.Entity.GuildRank == (ushort)rank))
c.Entity.WarScore = 0;
IsWar = true;
}
public static void FinishRound(SobNpcSpawn Pole, int _Class, Entity PoleKeeper)
{
//Entity PoleKeeper;
LastWin = Time32.Now;
FirstRound = false;
SortScores(out PoleKeeper, _Class);
if (PoleKeeper != null)
{
Pole.Name = PoleKeeper.Name;
PolesWinners[_Class] = PoleKeeper.UID;
Pole.Hitpoints = Pole.MaxHitpoints;
if (PoleKeeper.GuildRank == (ushort)Enums.GuildMemberRank.GuildLeader)
{
UidPolaGuildLeader = PoleKeeper.UID;
}
else if (PoleKeeper.GuildRank == (ushort)Enums.GuildMemberRank.DeputyLeader)
{
UidPolaDubLeader = PoleKeeper.UID;
}
else
{
UidPolaMemberLeader = PoleKeeper.UID;
}
}
Pole.Hitpoints = Pole.MaxHitpoints;
foreach (var c in Program.Values)
{
if (c.Map.ID == Map.ID)
Pole.SendSpawn(c);
}
Reset(_Class);
}
public static void AddScore(uint addScore, Entity entity, SobNpcSpawn Pole)
{
if (entity != null)
{
int _rank = (int)Member;
if (entity.GuildRank == (ushort)Enums.GuildMemberRank.GuildLeader)
_rank = GuildLeader;
else if (entity.GuildRank == (ushort)Enums.GuildMemberRank.DeputyLeader)
_rank = DeputyLeader;
if (Pole.Hitpoints <= addScore)
Pole.Hitpoints = 0;
var Scores = AllScores[(ushort)((int)_rank)];
if (Scores == null)
Scores = AllScores[(ushort)((int)_rank)] = new SafeDictionary<uint, Entity>();
if (!Scores.ContainsKey(entity.UID))
Scores.Add(entity.UID, entity);
Pole.Hitpoints -= addScore;
entity.WarScore += addScore;
if ((int)Pole.Hitpoints <= 0)
{
FinishRound(Pole, (int)_rank, entity);
return;
}
}
}
public static void SendScores()
{
for (int i = 0; i < AllScores.Length; i++)
{
var Scores = AllScores[i];
if (Scores == null)
continue;
if (Scores.Count == 0)
continue;
Entity CurrentTopLeader;
var scoreMessages = SortScores(out CurrentTopLeader, i);
if (scoreMessages == null)
continue;
for (int c = 0; c < scoreMessages.Length; c++)
{
Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red, c == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
foreach (GameState client in Program.Values)
{
if (client != null)
{
if (client.Map.ID == Map.ID)
{
if (i == DeputyLeader)
{
if (client.Entity.GuildRank == (ushort)Enums.GuildMemberRank.DeputyLeader)
client.Send(msg);
}
else if (i == GuildLeader)
{
if (client.Entity.GuildRank == (ushort)Enums.GuildMemberRank.GuildLeader)
client.Send(msg);
}
else
{
if (client.Entity.GuildRank != (ushort)Enums.GuildMemberRank.GuildLeader && client.Entity.GuildRank != (ushort)Enums.GuildMemberRank.DeputyLeader)
client.Send(msg);
}
}
}
}
}
}
}
private static string[] SortScores(out Entity winner, int i)
{
winner = null;
List<string> ret = new List<string>();
int Place = 0;
var Scores = AllScores[i];
if (Scores == null) return new string[0];
foreach (var e in Scores.Values.OrderByDescending((p) => p.WarScore))
{
if (Place == 0)
winner = e;
string str = "No " + (Place + 1).ToString() + ": " + e.Name + "(" + e.WarScore + ")";
ret.Add(str);
Place++;
if (Place == 4)
break;
}
return ret.ToArray();
}
#endregion
public static void EndWar()
{
try
{
IsWar = false;
claim1 = true;
claim2 = true;
claim3 = true;
if (Map.Npcs != null)
Map.Npcs.Clear();
foreach (var client in Program.Values)
{
if (client.Entity.MapID == Map.ID)
{
client.Entity.Teleport(1002, 309, 260);
}
}
SubscriberMax.Dispose();
}
catch (Exception eee)
{
}
}
public static void GetReward(Client.GameState clienthoda, uint cps)
{
if (IsWar == false)
{
if (clienthoda.Entity.UID == UidPolaGuildLeader)
{
if (claim1 == true)
{
clienthoda.Entity.AddTopStatus((ulong)Update.Flags.TopGuildLeader, 1, DateTime.Now.AddDays(1));
UidPolaGuildLeader = 0;
clienthoda.Entity.ConquerPoints += cps;
claim1 = false;
}
}
else if (clienthoda.Entity.UID == UidPolaDubLeader)
{
if (claim2 == true)
{
clienthoda.Entity.AddTopStatus((ulong)Update.Flags.TopDeputyLeader, 1, DateTime.Now.AddDays(1));
UidPolaDubLeader = 0;
clienthoda.Entity.ConquerPoints += cps;
claim2 = false;
}
}
else if (clienthoda.Entity.UID == UidPolaMemberLeader)
{
if (claim3 == true)
{
UidPolaMemberLeader = 0;
clienthoda.Entity.ConquerPoints += cps;
claim3 = false;
}
}
}
}
}
}
public void CreateTournaments()
new GuildPoleWar();
private void WorldTournaments(int time)
#region GuildPoleWar
{
if (Now64.Minute == 01 && Now64.Second <= 00)
{
if (GuildPoleWar.IsWar == false)
{
GuildPoleWar.StartWar();
Kernel.SendWorldMessage(new Message("Guild Pole Pk War began !", Color.White, Message.BroadcastMessage), Program.Values);
foreach (var client in Program.Values)
client.MessageBox("Guild Pole began! Would you Like to join ...?",
p => { p.Entity.Teleport(1002, 310, 258); }, null, 60);
}
}
if (GuildPoleWar.IsWar)
{
if (Time32.Now > GuildPoleWar.ScoreSendStamp.AddSeconds(3))
{
GuildPoleWar.ScoreSendStamp = Time32.Now;
GuildPoleWar.SendScores();
}
}
if (Now64.Minute == 59 && Now64.Second == 59)
{
if (GuildPoleWar.IsWar == true)
{
GuildPoleWar.EndWar();
Kernel.SendWorldMessage(new Message("GuildPole war has ended.!", Color.White, Message.BroadcastMessage), Program.Values);
}
}
}
#endregion
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
شرح اضافه وحش BoS | abuhaneen | مشكلات السيرفيرات كونكر الشخصيه | 18 | 2023-10-30 07:21 PM |
اضافه رون | medo2020 | مشكلات السيرفيرات كونكر الشخصيه | 5 | 2020-04-30 06:04 PM |
اضافه مابه | anwer1 | مشكلات السيرفيرات كونكر الشخصيه | 8 | 2019-09-25 05:10 AM |
اضافه | Hassan Emprator | مشكلات السيرفيرات كونكر الشخصيه | 2 | 2019-07-30 05:08 PM |
اضافه رنك الورد | محمد ياسر | تطوير سيرفرات كونكر | 4 | 2019-07-11 03:44 PM |