
النهاردا ان شاء الله هشرح أضافة حرب StatuesWar لكل السورسات
وهطبق الشرح علي سورس TroZenA ولو بتستخدم سورس تاني هقولك
مكان أضافة الأكواد لو النظام عندك مختلف .
أولا : كلاس الحرب هتعمل كلاس بأسم StatuesWar
في فولدر Game
وبدل الاكواد دي بالي فيه
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using TroZenA.Client; using TroZenA.Interfaces; using TroZenA.Network.GamePackets; using System.Drawing; using TroZenA.Network; using TroZenA.Game.ConquerStructures; using System.Threading.Generic; using TroZenA.Game.ConquerStructures.Society; namespace TroZenA.Game { public class StatuesWar { public static SobNpcSpawn RightGate, LeftGate, Pole; public static DateTime WarStart; public static Map Map; public static bool IsWar = false; private IDisposable Subscriber; public StatuesWar() { Subscriber = World.Subscribe(work, 1000); } public void work(int time) { if (IsWar) if (DateTime.Now > WarStart.AddMinutes(60)) EndWar(); if (TroZenA_Times.Start.StatuesWar && !IsWar) StartWar(); if (IsWar) { if (Time32.Now > ScoreSendStamp.AddSeconds(3)) { ScoreSendStamp = Time32.Now; SendScores(); } } } public static void Join(Client.GameClient client) { if (IsWar) { if (client.AsMember == null) return; var cooord = Map.RandomCoordinates(); client.Entity.Teleport(Map.ID, 292, 187); client.Entity.Teleport(Map.ID, 224, 210); client.Entity.Teleport(Map.ID, 162, 139); if (!Map.Floor[client.Entity.X, client.Entity.Y, Game.MapObjectType.Player, null]) { client.Entity.PKMode = Game.Enums.PKMode.PK; client.Send(new Data(true) { UID = client.Entity.UID, ID = Data.ChangePKMode, dwParam = (uint)client.Entity.PKMode }); } client.Send(RightGate); client.Send(LeftGate); client.Send(Pole); client.OnDisconnect = p => { p.Entity.Teleport(1002, 300, 278); }; } } public static void StartWar() { try { if (IsWar) EndWar(); PoleKeeper = null; IsWar = true; WarStart = DateTime.Now; Map = Kernel.Maps[3868].MakeDynamicMap(); if (!Kernel.Maps.ContainsKey(Map.ID)) Kernel.Maps.Add(Map.ID, Map); if (!Database.MapsTable.MapInformations.ContainsKey(Map.ID)) Database.MapsTable.MapInformations.Add(Map.ID, new Database.MapsTable.MapInformation() { ID = Map.ID, BaseID = Map.BaseID }); Constants.PKForbiddenMaps.Remove(Map.ID); Constants.PKFreeMaps.Add(Map.ID); Kernel.SendWorldMessage(new Message("StatuesWar War began [Prize : 5.000 ] Cps!", Color.White, Message.BroadcastMessage), Program.Values); foreach (var client in Program.Values) client.MessageBox("You Want To Join StatuesWar and Got Cps from the War [Prize : 5.000] Cps!", p => { p.Entity.Teleport(1002, 295, 167); }, null, 60); #region RightGate LeftGate = new Network.GamePackets.SobNpcSpawn(); LeftGate.UID = 84523; LeftGate.Mesh = 277; LeftGate.Type = (Enums.NpcType)26; LeftGate.X = (ushort)282; LeftGate.Y = (ushort)143; LeftGate.Hitpoints = 10000000; LeftGate.MaxHitpoints = 10000000; LeftGate.MapID = Map.ID; LeftGate.Mesh = (ushort)(240 + LeftGate.Mesh % 10); #endregion #region LeftGate RightGate = new Network.GamePackets.SobNpcSpawn(); RightGate.UID = 84524; RightGate.Mesh = 277; RightGate.Type = (Enums.NpcType)26; RightGate.X = (ushort)175; RightGate.Y = (ushort)138; RightGate.Hitpoints = 10000000; RightGate.MaxHitpoints = 10000000; RightGate.MapID = Map.ID; #endregion #region StatuesPole Pole = new Network.GamePackets.SobNpcSpawn(); Pole.UID = Map.EntityUIDCounter2.Next; Pole.Mesh = 1137; Pole.Type = (Enums.NpcType)10; Pole.X = 222; Pole.Y = 131; Pole.ShowName = true; Pole.Sort = 17; Pole.Hitpoints = 20000000; Pole.MaxHitpoints = 20000000; Pole.Name = "Statues-War"; Pole.MapID = Map.ID; #endregion Map.AddNpc(LeftGate);//.Npcs.Add(LeftGate.UID, LeftGate); Map.AddNpc(RightGate);//.Npcs.Add(RightGate.UID, RightGate); Map.AddNpc(Pole);//.Npcs.Add(StatuesPole.UID, StatuesPole); } catch (Exception ex) { Console.WriteLine(ex); Program.SaveException(ex); } } #region Score public static SafeDictionary<uint, Guild.Member> Scores = new SafeDictionary<uint, Guild.Member>(100); public static Guild.Member PoleKeeper, CurrentTopLeader; private static bool changed = false; private static string[] scoreMessages; public static bool FirstRound = false; public static Time32 ScoreSendStamp, LastWin; public static bool Claim { get { return Program.Vars["stwclaim"]; } set { Program.Vars["stwclaim"] = value; } } public static uint KeeperID { get { return Program.Vars["stwkeeperid"]; } set { Program.Vars["stwkeeperid"] = value; } } public static void Start() { Scores = new SafeDictionary<uint, Guild.Member>(1000); WarStart = DateTime.Now; FirstRound = true; foreach (Guild Guild in Kernel.Guilds.Values) { foreach (Guild.Member member in Guild.Members.Values) member.WarScore = 0; } Claim = false; IsWar = true; } public static void Reset() { 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)Map.ID); upd.Clear(); upd.UID = RightGate.UID; upd.Append(Update.Mesh, RightGate.Mesh); upd.Append(Update.Hitpoints, RightGate.Hitpoints); Kernel.SendWorldMessage(upd, Program.Values, (ushort)Map.ID); foreach (Guild Guild in Kernel.Guilds.Values) { foreach (Guild.Member member in Guild.Members.Values) member.WarScore = 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("" + PoleKeeper.Name + " Win At StatueWar Around!", System.Drawing.Color.Red, Message.Center), Program.Values); Pole.Name = PoleKeeper.Name; if (PoleKeeper.Client != null) { byte[] _buffer = new byte[PoleKeeper.Client.Entity.SpawnPacket.Length]; Buffer.BlockCopy(PoleKeeper.Client.Entity.SpawnPacket, 0, _buffer, 0, PoleKeeper.Client.Entity.SpawnPacket.Length); Pole.SpawnPacket = _buffer; Map.Statues.Clear(); Map.Npcs.Clear(); Map.Npcs.Add(Pole.UID, Pole); if (!Map.Statues.ContainsKey(Pole.UID)) Map.Statues.Add(Pole.UID, Pole); Game.Statue statue = new Statue(PoleKeeper.Client.Entity.SpawnPacket, 105176, Enums.ConquerAction.Cool, (byte)Enums.ConquerAngle.SouthWest, 327, 336, true); statue = new Statue(PoleKeeper.Client.Entity.SpawnPacket, 105177, Enums.ConquerAction.Wave, (byte)Enums.ConquerAngle.SouthEast, 381, 260, true); for (int i = 0; i < 2; i++) { SobNpcSpawn Base = new SobNpcSpawn(); Base.Owner = PoleKeeper.Client; Base.SpawnPacket = _buffer; Base.UID = Map.EntityUIDCounter2.Next; Base.Mesh = 1003; Base.Type = Enums.NpcType.Stake; Base.Sort = 21; Base.ShowName = true; Base.Name = PoleKeeper.Client.Entity.Name; Base.Hitpoints = Base.MaxHitpoints = 2000000; Base.MapID = Map.ID; switch (i) { case 0: Base.X = 310; Base.Y = 335; break; case 1: Base.X = 385; Base.Y = 255; break; } if (!Map.Statues.ContainsKey(Base.UID)) Map.Statues.Add(Base.UID, Base); if (!Map.Npcs.ContainsKey(Base.UID)) Map.Npcs.Add(Base.UID, Base); } } } Pole.Hitpoints = Pole.MaxHitpoints; Reset(); foreach (var c in Program.Values) if (c.Entity.MapID == Map.ID) { c.Screen.FullWipe(); c.Screen.Reload(null); } } public static void AddScore(uint addScore, Guild.Member Guild) { if (Guild != null) { Guild.WarScore += 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)Map.ID); } } private static void SortScores(out Guild.Member winner) { winner = null; List ret = new List(); int Place = 0; foreach (Guild.Member Guild in Scores.Values.OrderByDescending((p) => p.WarScore)) { if (Place == 0) winner = Guild; string str = "No " + (Place + 1).ToString() + ": " + Guild.Name + "(" + Guild.WarScore + ")"; ret.Add(str); Place++; if (Place == 4) break; } changed = false; scoreMessages = ret.ToArray(); } #endregion public static void EndWar() { try { if (PoleKeeper != null) { Kernel.SendWorldMessage(new Message(PoleKeeper.Name + " StatueWar End !", System.Drawing.Color.White, Message.Center), Program.Values); } else { Kernel.SendWorldMessage(new Message("No Winner at STatueWar and ended!", System.Drawing.Color.Red, Message.Center), Program.Values); } Claim = true; IsWar = false; foreach (var client in Program.Values) if (client.Entity.MapID == Map.ID) client.Entity.Teleport(1002, 300, 278); if (!Database.MapsTable.MapInformations.ContainsKey(Map.ID)) Database.MapsTable.MapInformations.Remove(Map.ID); Map.Dispose(); } catch (Exception ex) { Console.WriteLine(ex); Program.SaveException(ex); } } } } |
هتفتح PacketHandler ولو سورسك مختلف هتلاقي الاوامر في GameClient or GameState
هتبحث عن
1 |
case "hairstyle": |
فوقه حط الكود دا عشان تشغل الحرب بالشفره وقت ما تحب
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
case "statueswar": { switch (Data[1]) { case "on": { if (!StatuesWar.IsWar) { StatuesWar.Start(); foreach (var client2 in Kernel.GamePool.Values) { client2.Send(new Message("Statues War Starts", System.Drawing.Color.Red, Network.GamePackets.Message.BroadcastMessage)); } } break; } case "off": { if (!StatuesWar.IsWar) { StatuesWar.EndWar(); foreach (var client2 in Kernel.GamePool.Values) { client2.Send(new Message("Statues War Ended", System.Drawing.Color.Red, Network.GamePackets.Message.BroadcastMessage)); } } break; } } break; } |
ودا الانبسي
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
#region StatuesWar case 41162: { switch (npcRequest.OptionID) { case 0: { dialog.Text("Hello there. Do you want to Join The StatuesWar?."); dialog.Option("Yes Please.", 1); dialog.Option("Cliam Prize.", 2); dialog.Option("Just Passing By!", 255); dialog.Send(); break; } case 1: { if (StatuesWar.IsWar) { Random R = new Random(); int Nr = R.Next(1, 4); if (Nr == 1) client.Entity.Teleport(3868, 292, 187); if (Nr == 2) client.Entity.Teleport(3868, 224, 210); if (Nr == 3) client.Entity.Teleport(3868, 162, 139); if (Nr == 4) client.Entity.Teleport(3868, 162, 139); } else { dialog.Text("The War Has Not Started Start [17.00] Every Thursday"); dialog.Option("Aww ok!", 255); dialog.Send(); } break; } case 2: { if (StatuesWar.KeeperID != 0 && !StatuesWar.IsWar && StatuesWar.Claim && client.Entity.UID == StatuesWar.KeeperID) { StatuesWar.Claim = false; StatuesWar.KeeperID = 0; client.Entity.ConquerPoints += 20000; client.Entity.AddTopStatus(Update.Flags2.Top2Monk, 2, DateTime.Now.AddDays(1)); TroZenA.Kernel.SendWorldMessage(new Message("Congratulations! " + client.Entity.Name + " has Claimed StatuesWar Prize [ 20k cps ] !", System.Drawing.Color.White, Message.Center), Program.Values); } else { dialog.Text("Sorry you dont have Any Prize to claim only CL of the winner guild can claim Prize After CW"); dialog.Option("Ahh.", 255); dialog.Send(); } break; } } break; } #endregion |
افتح World ابحث عن
1 |
public void CreateTournaments() |
وحط الكود دا تحته
1 |
new Game.StatuesWar(); |
ركز بقا في الي جاي هتفتح Handle.cs
وهتلاقيه في المسار دا Game\Attacking
هتبحث عن الكود دا
1 |
if (attacker.MapID == 1509) |
هتحط فوقه دا
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#region StatuesWar if (Game.StatuesWar.IsWar) { if (Game.StatuesWar.Pole != null) { if (attacker.MapID == 3868 && attacked.UID == 3091995) { if (Game.StatuesWar.PoleKeeper == attacker.Owner.AsMember) return; if (attacked.Hitpoints <= damage) attacked.Hitpoints = 0; Game.StatuesWar.AddScore(damage, attacker.Owner.AsMember); } } } #endregion TWin War |
وهتبحث عن الفويد دا
1 |
public static bool CanAttack( |
وانزل تحت مثلا لحد الكود دا أو اي كود شبهه
1 |
if (attacker.MapID == 1507) |
وحط فوقه الكود دا
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#region StatueWar if (Game.StatuesWar.IsWar) { if (attacker.MapID == Game.StatuesWar.Map.ID) { if (attacker.GuildID == 0 || !Game.StatuesWar.IsWar) if (attacked.UID == Game.StatuesWar.Pole.UID) return false; if (Game.StatuesWar.PoleKeeper != null) { if (Game.StatuesWar.PoleKeeper == attacker.Owner.AsMember) if (attacked.UID == Game.StatuesWar.Pole.UID) return false; if (Game.StatuesWar.PoleKeeper == attacker.Owner.AsMember) if (attacker.PKMode == Enums.PKMode.Team) return false; } } } #endregion Twinwar |
بعد كدا هتبحث عن كلاس SobNpcSpawn
1 |
class SobNpcSpawn : Writer, |
ابحث فيه عن
1 |
public void Die(Game.Entity killer) |
تحته حط الكود دا
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#region StatuesWar if (Game.StatuesWar.Map != null) { if (MapID == Game.StatuesWar.Map.ID) { if (UID != Game.StatuesWar.Pole.UID) { if (Hitpoints != 0 || Mesh != 251 && Mesh != 281) { 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; } Attack attack = new Attack(true); attack.Attacker = killer.UID; attack.Attacked = UID; attack.AttackType = Network.GamePackets.Attack.Kill; attack.X = X; attack.Y = Y; killer.Owner.Send(attack); killer.KOCount++; } } } #endregion |
خلصنا الاضافه نعرف السورس عليه بقا ونشيل الايرور
هتفتح كلاس Guild.cs
1 |
class Guild : Writer |
ابحث عن الكود دا
1 |
public uint CTFCpsReward |
تحته ضيف الكود دا
1 |
public uint WarScore; |
بعدين هنبحث عن
1 |
class SobNpcSpawn : Writer |
تحته هنحط الكود دا
1 |
public byte[] SpawnPacket; |
بعد كدا ابحث عن الكود دا
1 |
public Dictionary<uint, INpc> Npcs; |
تحته ضيف
1 |
public Dictionary<uint, INpc> Statues = new Dictionary<uint, INpc>(); |
وكدا مبقاش عندك أي ايرور ان شاء الله 🙂
وعشان نشطب وتبقا كدا الحرب كامله 100% ان شاء الله هنرفع دا في النافي كات
و دا كود النافي كات يضلف في sobnpcs
1 |
3091995 Statues-War 10 1137 3868 222 131 20000000 20000000 24 17 1 0 |
وطبعآ معاد الحرب الساعه 5 كل يوم وتقدر تغيرو من الكود دا
1 2 3 4 5 6 7 |
public static bool StatuesWar { get { return (now.DayOfWeek == DayOfWeek.Thursday && now.Hour == 17 && now.Minute == 0); } } |
وهتلاقيه في Program
في رعاية الله
12 تعليق “شرح : أضافة حرب StatusWar Full 100%”
حبيبي تسلم
طيب حضرتك الملف دا مش قاعدد فى السورس اللى هو Gulid.csاعمل ايه دلوقتى
ممكن رابط شرح الاضافه علي كلينت 5095
مش فاهم قصدك
شكرا للشرح الرائع
ايو مانا عارف انا عايز الاحدثيات الي احطها في جدول ال map
يا استاذ محمد انت مفهمتش قصدي انا قصدي ان خريطه 3868 مش موجود عندي فاي الmap في النفي كات ياعني الساحه
3333 700 7 0
انا عايز الاحديثات بتاعت المابه بتاع الحرب ده
ضيفها يا محمد من جدول map
تمام شكرا
ممكن ال map يا استاذ محمد علشان مش موجوده في النفي كات عندي
3868, 292, 187
شكرا موضوع جميل جاري التجربه