|
المشاركات 1,372 |
+التقييم 0.67 |
تاريخ التسجيل Apr 2019 |
الاقامة شرقيه/زقازيق |
نظام التشغيل |
رقم العضوية 30 |
PoleDomination
// Created By HassanEmprator(HasssanHany)
// please dont change my information
// Have Fun <3
// 01009045798
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MrHassan.Network.GamePackets;
using MrHassan.Client;
namespace MrHassan.Game
{
using Coordinate = Tuple<ushort, ushort, ushort>;
using System.Drawing;
using MrHassan.Game.ConquerStructures.Society;
using MySql.Data.MySqlClient;
using System.Collections.Concurrent;
using System.IO;
public class PoleDomination
{
public const uint MaxHitPoints = 30000000;
private SobNpcSpawn Pole = new SobNpcSpawn()
{
Hitpoints = MaxHitPoints,
MaxHitpoints = MaxHitPoints,
Mesh = 1137,
ShowName = true,
Type = (Enums.NpcType)10,
Name = "FlameLotus-Pole",
Sort = 21,
UID = 123456
};
private IDisposable Subscriber;
private Coordinate[] Locations = new[]
{
new Coordinate(1002, 402, 255),
new Coordinate(1011, 216, 324),
new Coordinate(1020, 612, 590),
new Coordinate(1000, 508, 709),
new Coordinate(1015, 737, 641)
};
private int currentLocation;
private bool poleKilled;
private Map currentMap;
private Coordinate currentCoordinate;
private uint prize;
private Guild lastKiller;
public uint KillerGuildID { get { if (lastKiller == null) return 0; return lastKiller.ID; } }
private ConcurrentDictionary<Guild, ulong> damages;
private List<string> winners;
public PoleDomination(uint prize)
{
Subscriber = World.Subscribe(work, 1000);
currentLocation = -1;
this.prize = prize;
damages = new ConcurrentDictionary<Guild, ulong>();
winners = new List<string>();
File.Open("database\\poledomination.txt", FileMode.OpenOrCreate).Close();
foreach (var name in File.ReadAllLines("database\\poledomination.txt"))
if (name.Length != 0)
winners.Add(name);
}
private void work(int time)
{
Time32 time32 = new Time32(time);
DateTime time64 = DateTime.Now;
// if (time64.DayOfWeek == DayOfWeek.Tuesday)
{
if (Emprator_Times.Start.PoleDomnation/*time64.Hour == 00*/)
//if (time64.Hour == 17)
{
if (time64.Minute % 12 == 0)
{
if (currentLocation != time64.Minute / 12)
{
ushort ID = 0;
if (currentLocation != -1)
{
ID = currentMap.ID;
removePole();
}
setWinner();
bool killedPole = poleKilled;
poleKilled = false;
lastKiller = null;
currentLocation = time64.Minute / 12;
currentCoordinate = Locations[currentLocation];
if (!Kernel.Maps.ContainsKey(currentCoordinate.Item1))
new Map(currentCoordinate.Item1, "");
currentMap = Kernel.Maps[currentCoordinate.Item1];
Pole.MapID = currentMap.ID;
Pole.X = currentCoordinate.Item2;
Pole.Y = currentCoordinate.Item3;
currentMap.AddPole(Pole);
Pole.Hitpoints = Pole.MaxHitpoints = MaxHitPoints;
Kernel.Execute((client) =>
{
if (client.Entity.MapID == currentMap.ID)
if (client.Screen.Add(Pole))
client.Send(Pole);
client.MessageOK = (pClient) => { joinClient(pClient); };
client.Send(new NpcReply(NpcReply.MessageBox, "Pole Domination began in " + ((Enums.Maps)currentMap.ID).ToString() + ". Would you like to join?"));
});
currentMap.WasPKFree = Constants.PKFreeMaps.Contains(currentMap.ID);
if (!currentMap.WasPKFree) Constants.PKFreeMaps.Add(currentMap.ID);
if (currentLocation != -1 && (killedPole && lastKiller != null && currentMap != null))
Kernel.SendWorldMessage(new Message("Guild " + lastKiller.Name + " won the pole in " + ((Enums.Maps)ID).ToString() + "!" + "The Pole Domination moved to " + ((Enums.Maps)currentMap.ID).ToString() + "!", Color.Red, Message.Guild));
else
Kernel.SendWorldMessage(new Message("The Pole Domination moved to " + ((Enums.Maps)currentMap.ID).ToString() + "!", Color.Red, Message.Guild));
}
}
if (time64.Second % 5 == 0)
{
var array = damages.OrderByDescending((p) => p.Value);
int Place = 0;
foreach (KeyValuePair<Guild, ulong> entry in array)
{
string str = "No " + (Place + 1).ToString() + ": " + entry.Key.Name + "(" + entry.Value + ")";
Message msg = new Message(str, System.Drawing.Color.Red, Place == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
Kernel.SendWorldMessage(msg, Program.Values, (ushort)currentMap.ID);
Place++;
if (Place == 4) break;
}
}
}
else
{
if (Pole.MapID != 0)
{
currentMap = Kernel.Maps[Pole.MapID];
removePole();
currentLocation = -1;
setWinner();
if (poleKilled)
Kernel.SendWorldMessage(new Message("Guild " + lastKiller.Name + " won the pole in " + ((Enums.Maps)currentMap.ID).ToString() + "!", Color.Red, Message.Center));
poleKilled = false;
lastKiller = null;
Pole.MapID = 0;
}
}
}
}
private void setWinner()
{
if (poleKilled)
{
Kernel.SendWorldMessage(new Message("Guild " + lastKiller.Name + " won the pole in " + ((Enums.Maps)currentMap.ID).ToString() + "!", Color.Red, Message.Guild));
winners.Add(lastKiller.Name);
SaveWinners();
}
}
public void SaveWinners()
{
StringBuilder builder = new StringBuilder();
foreach (var line in winners) builder.AppendLine(line);
File.WriteAllText("database\\poledomination.txt", builder.ToString());
}
public uint GetWinnerPrize(string name)
{
return (uint)(prize * winners.Count(p => p == name));
}
public void RemoveWinner(string name)
{
winners.RemoveAll(p => p == name);
}
private void joinClient(GameState client)
{
int x = Kernel.Random.Next(36) - 18, y = Kernel.Random.Next(36) - 18;
int times = 1000;
while (times-- > 0)
{
if (!currentMap.Floor[Pole.X + x, Pole.Y + y, MapObjectType.Entity, null])
{
x = Kernel.Random.Next(36) - 18;
y = Kernel.Random.Next(36) - 18;
}
else break;
}
if (times == 0) return;
client.Entity.Teleport(currentMap.BaseID, (ushort)(Pole.X + x), (ushort)(Pole.Y + y)); ;
}
internal void KillPole()
{
var array = damages.OrderByDescending((p) => p.Value).ToArray();
if (array.Length != 0)
lastKiller = array[0].Key;
Pole.Hitpoints = Pole.MaxHitpoints = MaxHitPoints;
Pole.Name = lastKiller.Name;
Kernel.Execute((client) =>
{
if (client.Entity.MapID == currentMap.ID)
client.Send(Pole);
});
Kernel.SendWorldMessage(new Message("Guild " + lastKiller.Name + " have taken the pole in " + ((Enums.Maps)currentMap.ID).ToString() + "! Are they going to win?", Color.Red, Message.Guild));
poleKilled = true;
damages.Clear();
//prize(killer.Owner);
//poleKilled = true;
}
private void removePole()
{
currentMap.RemovePole(Pole);
Kernel.Execute((client) =>
{
if (client.Entity.MapID == currentMap.ID)
{
client.Screen.Remove(Pole);
client.Send(new Data(true) { UID = Pole.UID, ID = Data.RemoveEntity });
}
});
if (!currentMap.WasPKFree)
Constants.PKFreeMaps.Remove(currentMap.ID);
damages.Clear();
}
internal void AddScore(uint damage, Guild guild)
{
if (guild == null) return;
if (!damages.ContainsKey(guild)) damages[guild] = 0;
damages[guild] += damage;
}
}
}
public static bool CanAttack(Game.Entity attacker, SobNpcSpawn attacked,
if (attacked.UID == 123456)
if (attacked.Hitpoints > 0)
if (attacker.GuildID != 0 && attacker.GuildID != Program.World.PoleDomination.KillerGuildID)
return true;
public void Die(Game.Entity killer)
if (UID == 123456)
Program.World.PoleDomination.KillPole();
#region PoleDomination
case 123:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Hello champ! Are you here to claim your prize in the Pole Domination war?");
dialog.Option("Yes sir!", 1);
dialog.Send();
break;
}
case 1:
{
if (client.Entity.GuildID == 0)
{
dialog.Text("You do not belong to a guild!");
dialog.Option("Ahh!", 255);
dialog.Send();
return;
}
if (client.Entity.GuildRank != (int)Game.Enums.GuildMemberRank.GuildLeader)
{
dialog.Text("You have to be the guild leader!");
dialog.Option("Ahh!", 255);
dialog.Send();
return;
}
uint prize = Program.World.PoleDomination.GetWinnerPrize(client.Guild.Name);
if (prize == 0)
{
dialog.Text("There is no prize to be claimed!");
dialog.Option("Ahh!", 255);
dialog.Send();
return;
}
client.Entity.ConquerPoints += 50000000;
Program.World.PoleDomination.RemoveWinner(client.Guild.Name);
dialog.Text("You have claimed " + prize + " Conquer Points! Congratulations!");
dialog.Option("Thank you!", 255);
dialog.Send();
break;
}
}
break;
}
#endregion champ
public PoleDomination PoleDomination;
public void CreateTournaments()
PoleDomination = new PoleDomination(500000000)
public static void ReceiveAttack(Game.Entity attacker, SobNpcSpawn attacked,
if (attacked.UID == 123456)
if (Program.World.PoleDomination.KillerGuildID == attacker.Owner.Guild.ID)
return;
Program.World.PoleDomination.AddScore(damage, attacker.Owner.Guild);
https://top4top.io/downloadf-1510ca3to1-rar.html
public class Start
public static bool PoleDomnation
{
get
{
return (now.Hour == 5 || now.Hour == 17);
}
}
if (time64.Minute % 12 == 0)
if (currentLocation != time64.Minute / 12)
currentLocation = time64.Minute / 12;
//if (time64.Hour == 17)
الذين يشاهدون محتوى الموضوع الآن : 2 ( الأعضاء 0 والزوار 2) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
شوية حمايات كدا كويس ليكو | MohamedModyAdel | تطوير سيرفرات كونكر | 145 | 2024-11-18 07:36 AM |
كويستت TeamWar مقدمه لي MohamedAymen | Hassan Emprator | تطوير سيرفرات كونكر | 2 | 2020-02-29 02:03 PM |
بخصوص HassanEmprator | megokarika | قسم الاقتراحات والابداع | 1 | 2020-02-28 08:34 PM |
كويستت Treasure In Blue مقدمه من HassanEmprator | Hassan Emprator | تطوير سيرفرات كونكر | 5 | 2020-02-20 09:07 PM |
ارينا روم خاصه بي Rider هديه مني ليكو <3 | Hassan Emprator | تطوير سيرفرات كونكر | 1 | 2020-02-15 04:21 PM |