منتدي اكواد

منتدي اكواد (https://code.vpscairo.com/index.php)
-   تطوير سيرفرات كونكر (https://code.vpscairo.com/forumdisplay.php?f=11)
-   -   اضافه حرب GuildPoleWar (https://code.vpscairo.com/showthread.php?t=1972)

Hassan Emprator 2019-08-27 08:48 PM

اضافه حرب GuildPoleWar
 
السلام عليكم انهارضه معانا اضافه كويستت جميله كدا وموجوده في معظم لاسرفر النهرضه احنا نضيفها مع بعضينا
اول حاجه الحرب عباره عن الي هما 3 عواميد زي الجلد ليدر دوبتي ليدر الدوق
دي اخرهم فقط تمام نبدا في الاضافه
اول حاجه دا الانبي سي

كود PHP:

#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(client15000);
                                    }
                                    else
                                    {
                                        
dialog.Text("Sorry you can claim Prize After its end");
                                        
dialog.Option("Ahh."255);
                                        
dialog.Send();
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                
#endregion 

ثاني حاجه نفتح كلاس Handel.cs وي نبحث عن

كود PHP:

 public static void ReceiveAttack(Game.Entity attackerSobNpcSpawn attackedAttack attackuint damageDatabase.SpellInformation spell

لما تلاقيه هضيف دي تحت الكوص

كود PHP:

#region GuildPoleWar
            
if (GuildPoleWar.IsWar)
            {
                if (
attacker.MapID == GuildPoleWar.Map.ID)
                {
                    
GuildPoleWar.Attack(damageattackerattacked);
                }
            }
            
#endregion 

بعدين نفس الكلاس Handel ونبحث عن

كود PHP:

 public static bool CanAttack(Game.Entity attackerSobNpcSpawn attackedDatabase.SpellInformation spell

ونضيف دا برضو

كود PHP:

#region GuildPoleWar
            
if (GuildPoleWar.IsWar)
            {
                if (
attacker.MapID == GuildPoleWar.Map.ID)
                {
                    return 
GuildPoleWar.Attack(0attackerattacked);
                }
            }
            
#endregion 

بعدين نعمل كلاس جديد نسميه GuildPoleWar.cs

ونضيف فيه دا

كود PHP:

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<uintEntity>[] AllScores = new SafeDictionary<uintEntity>[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(work1000);
        }
        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.ID315330);
                
client.OnDisconnect =>
                {
                    
p.Entity.Teleport(1002300278);
                };
            }
        }

        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"300288GuildLeader);
                
Summon("DeputyLeader"300268DeputyLeader);
                
Summon("Member"327266Member);
            }
            catch (
Exception ex)
            {
                
//Program.SaveException(ex, true);
            
}
        }

        public static 
bool Attack(uint addScoreEntity entitySobNpcSpawn 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(addScoreentitypole);
                }

                return 
true;
            }
            return 
false;
        }
        public static 
bool Attack2(Entity entitySobNpcSpawn 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 Nameushort Xushort Yint 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;
            
Base.Y;
            
Poles[rank] = Base;
            if (!
Map.Npcs.ContainsKey(Base.UID))
                
Map.Npcs.Add(Base.UIDBase);


        }

        
#region Score

        
public static bool FirstRound false;
        public static 
Time32 ScoreSendStampLastWin;

        public static 
void Start()
        {
            
AllScores = new SafeDictionary<uintEntity>[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.Entity.GuildRank == (ushort)rank))
                
c.Entity.WarScore 0;

            
IsWar true;
        }

        public static 
void FinishRound(SobNpcSpawn Poleint _ClassEntity 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 addScoreEntity entitySobNpcSpawn 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<uintEntity>();

                if (!
Scores.ContainsKey(entity.UID))
                    
Scores.Add(entity.UIDentity);
                
Pole.Hitpoints -= addScore;
                
entity.WarScore += addScore;

                if ((int)
Pole.Hitpoints <= 0)
                {
                    
FinishRound(Pole, (int)_rankentity);
                    return;
                }
            }
        }

        public static 
void SendScores()
        {
            for (
int i 0AllScores.Lengthi++)
            {
                var 
Scores AllScores[i];

                if (
Scores == null)
                    continue;
                if (
Scores.Count == 0)
                    continue;

                
Entity CurrentTopLeader;

                var 
scoreMessages SortScores(out CurrentTopLeaderi);
                if (
scoreMessages == null)
                    continue;
                for (
int c 0scoreMessages.Lengthc++)
                {
                    
Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red== Message.FirstRightCorner Message.ContinueRightCorner);
                    foreach (
GameState client in Program.Values)
                    {
                        if (
client != null)
                        {
                            if (
client.Map.ID == Map.ID)
                            {
                                if (
== DeputyLeader)
                                {
                                    if (
client.Entity.GuildRank == (ushort)Enums.GuildMemberRank.DeputyLeader)
                                        
client.Send(msg);
                                }
                                else if (
== 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 winnerint i)
        {
            
winner null;
            List<
stringret = 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(1002309260);
                    }
                }

                
SubscriberMax.Dispose();
            }
            catch (
Exception eee)
            {
            }

        }
        public static 
void GetReward(Client.GameState clienthodauint cps)
        {
            if (
IsWar == false)
            {
                if (
clienthoda.Entity.UID == UidPolaGuildLeader)
                {
                    if (
claim1 == true)
                    {

                        
clienthoda.Entity.AddTopStatus((ulong)Update.Flags.TopGuildLeader1DateTime.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.TopDeputyLeader1DateTime.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;
                    }
                }
            }

        }
    }



ملحوظه لو جالك ايرور هتغيره لي اسم البروكت بتاعك وله جالك ايرور في Entity تحولها لي Player

بعدين كلاس ورلد ونبحث عن دا

كود PHP:

  public void CreateTournaments() 

ونضيف فيه دا

كود PHP:

  new GuildPoleWar(); 

في الاخر نضيف دا في

كود PHP:

  private void WorldTournaments(int time

كود PHP:

#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.WhiteMessage.BroadcastMessage), Program.Values);
                        foreach (var 
client in Program.Values)
                            
client.MessageBox("Guild Pole  began! Would you Like to join ...?",
                               
=> { p.Entity.Teleport(1002310258); }, null60);
                    }
                }
                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.WhiteMessage.BroadcastMessage), Program.Values);

                    }
                }
            }
            
#endregion 

اخر حاجه ال maps

اول حاجه 50016/1002/8192/0

محمد ياسر 2019-08-27 08:49 PM

رد: اضافه حرب GuildPoleWar
 
عاش

AhmedNasser 2019-08-28 12:46 AM

رد: اضافه حرب GuildPoleWar
 
عااش


الساعة الآن 05:55 PM

مرحبا بكم في منتدي اكواد لتطوير الالعاب