عرض مشاركة واحدة
احصائياتى

الردود
12

المشاهدات
1569
 
midoazoz
.:: عضو خبير ::.

    غير متواجد

المشاركات
663

+التقييم
0.26

تاريخ التسجيل
Nov 2019

الاقامة

نظام التشغيل

رقم العضوية
2314
2019-11-14, 07:40 PM
المشاركة 1
2019-11-14, 07:40 PM
المشاركة 1
افتراضي ضيف وحوش بسهوله في مابات خش وافهم منقول
السلام عليكم
مرحب رجالتنا الحلوين
انا رجعت للمجال من قريب ولسا مش اول يعني فيه بس
هنزلكم الموضوع ده لاني كنت شايله عندي من سنه ^_^
نزل الموضوع ده عبدالله صاحب لعبه xConquer
المهم الفكره انك تضيف وحوش في مابه بالعدد الي عاوزه بسهوله جدا
يلا نبدا

================================================== ===

اولا هتعمل كلا جديد باسم

كود:
NewMonsterSpawn 

في datebase
وتحط دول


كود:
using System;
using System.IO;
using System.Linq;
using System.Text;
using MidoAzoz.Game;
using System.Collections.Generic;

namespace 
MidoAzoz.Database
{
    public class 
NewMonsterSpawn
    
{
        public static 
bool Loading = false;
        public static 
Map Map;
        public static 
Database.MonsterInformation MonsterInformation;
        public static 
Dictionary<uint, MonstersInfo> MSSpawn = new Dictionary<uint, MonstersInfo>();
        public class 
MonstersInfo
        
{
            public 
uint UID;
            public 
uint Count;
            public 
string Name;
            public 
ushort MapID;
            public 
ushort Xx;
            public 
ushort Yy;
            public 
uint MonsterID;
            public 
bool EmptySpots;
            public 
int Respawn;
            public 
byte RangeSpot;
        }
        public static 
void Load()
        {
            
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("newmobspawn"))
            
using (var reader = cmd.CreateReader())
            {
                while (
reader.Read())
                {
                    
MonstersInfo MoB = new MonstersInfo();
                    
MoB.UID = reader.ReadUInt32("UID");
                    
MoB.Count = reader.ReadUInt32("Count");
                    
MoB.Name = reader.ReadString("Name");
                    
MoB.MapID = reader.ReadUInt16("MapID");
                    if (!
Kernel.Maps.ContainsKey(MoB.MapID))
                        
Database.DMaps.LoadMap(MoB.MapID);
                    
MoB.Xx = reader.ReadUInt16("Xx");
                    
MoB.Yy = reader.ReadUInt16("Yy");
                    
MoB.MonsterID = reader.ReadUInt32("MonsterID");
                    
MoB.EmptySpots = reader.ReadBoolean("EmptySpots");
                    
MoB.Respawn = reader.ReadInt32("Respawn");
                    
MoB.RangeSpot = reader.ReadByte("RangeSpot");
                    
MSSpawn.Add(MoB.UID, MoB);
                }
            }
            
SendSpawns();
            
Loading = false;
        }
        public static 
void SendSpawns()
        {
            
Loading = true;
            foreach (var 
mob in MSSpawn.Values)
            {
                try
                {
                    
Map = Kernel.Maps[mob.MapID];
                    if (
Map == null) { ReportError(mob, "[Map]"); continue; }
                    if (
mob.Count < 1) { ReportError(mob, "[Count]"); continue; }
                    if (
mob.MapID < 1) { ReportError(mob, "[MapID]"); continue; }
                    if (
mob.MonsterID < 1) { ReportError(mob, "[MonsterID]"); continue; }

                    
Tuple<ushort, ushort> coords;
                    if (
mob.EmptySpots)
                    {
                        for (
uint i = 0; i <= mob.Count; i++)
                        {
                            
coords = Map.RandomCoordinates();
                            if (
Kernel.GetDistance(coords.Item1, coords.Item2, mob.Xx, mob.Yy) > mob.RangeSpot * 2)//Mesh haytl3 el wo7osh fi el distance da..
                            
{
                                if (
Map.Npcs.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0 && Map.Entities.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0)
                                    
Spawn(mob, coords.Item1, coords.Item2);//Haytl3 el w7osh [b3eed] 3an el distance ale bt7dd..
                            
}
                        }
                    }
                    if (!
mob.EmptySpots)
                    {
                        if (
mob.Xx > 0)
                        {
                            for (
uint i = 0; i <= mob.Count; i++)
                            {
                                
coords = Kernel.Maps[mob.MapID].RandomCoordinates(mob.Xx, mob.Yy, mob.RangeSpot);
                                if (
Kernel.GetDistance(coords.Item1, coords.Item2, mob.Xx, mob.Yy) < mob.RangeSpot)//Haytl3 el w7osh [fe] el distance ale bt7dd bas..
                                
{
                                    if (
Map.Npcs.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0 && Map.Entities.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0)
                                        
Spawn(mob, coords.Item1, coords.Item2);
                                }
                            }
                        }
                        if (
mob.Xx == 0)
                        {
                            for (
uint i = 0; i <= mob.Count; i++)
                            {
                                
coords = Map.RandomCoordinates();
                                if (
Map.Npcs.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0 && Map.Entities.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0)
                                    
Spawn(mob, coords.Item1, coords.Item2);//Haytl3 el w7osh fe el map kolha
                            
}
                        }
                    }

                }
                catch (
Exception e)
                {
                    
Console.WriteLine(e);
                }
            }
        }
        public static 
void ReportError(MonstersInfo Mob, string reson)
        {
            
Console.ForegroundColor = ConsoleColor.Green;
            
Console.WriteLine(string.Format("UID: {0}, ID: {1}, Name: {2}, Count: {3}, MapID: {4}.." + reson.ToUpper(), Mob.UID, Mob.MonsterID, Mob.Name, Mob.Count, Mob.MapID));
            
Console.ForegroundColor = ConsoleColor.Red;
        }
        public static 
void Spawn(MonstersInfo Mob, ushort X, ushort Y)
        {
            if (
Database.MonsterInformation.MonsterInformations.ContainsKey(Mob.MonsterID))
            {
                
Database.MonsterInformation mt = Database.MonsterInformation.MonsterInformations[Mob.MonsterID];
                
mt.RespawnTime = Mob.Respawn;
                
mt.BoundX = X;
                
mt.BoundY = Y;
                
mt.BoundCX = X;
                
mt.BoundCY = Y;

                
Player entity = new Player(PlayerFlag.Monster, false);
                
entity.MapObjType = MapObjectType.Monster;
                
entity.MonsterInfo = mt.Copy();
                
entity.MonsterInfo.Owner = entity;
                
entity.Name = mt.Name;
                
entity.MinAttack = mt.MinAttack;
                
entity.MaxAttack = entity.MagicAttack = mt.MaxAttack;
                
entity.Hitpoints = entity.MaxHitpoints = mt.Hitpoints;
                
entity.Defence = mt.Defence;
                
entity.Body = mt.Mesh;
                
entity.Level = mt.Level;
                
entity.UID = Map.EntityUIDCounter.Next;
                
entity.MapID = Map.ID;
                
entity.SendUpdates = true;
                
entity.X = X;
                
entity.Y = Y;

                if (
Map.Floor[entity.X, entity.Y, MapObjectType.Monster, entity])
                {
                    
Map.AddEntity(entity);
                }
                
Map.Timer = Map.MonsterTimers.Add(Map);
                foreach (var 
p in Kernel.GamePool.Values.Where(z => z.Map.ID == Map.ID && z.GetDistance(entity) <= 19))
                    
entity.SendSpawn(p);
            }
        }
    }
} 

================================================== =
هتخش في
Map.cs

نبحث عن


كود:
private static void _timerCallBack(Map map, int time) 

تحت فتحه القوس هنحط ده


كود:
if (Database.NewMonsterSpawn.Loading) return; 

بعديل في

Server.cs

هنحط ده تحت اي load


كود:
Database.NewMonsterSpawn.Load(); 

كده تمام السورس

بصو الاضافات دي لسورس msg الفرق بسيط جدا

عموما ده لسورس عادي


كود:
using System;
using System.IO;
using System.Linq;
using System.Text;
using MidoAzoz.Game;
using System.Collections.Generic;

namespace 
MidoAzoz.Database
{
    public class 
NewMonsterSpawn
    
{
        public static 
bool Loading = false;
        public static 
Map Map;
        public static 
Database.MonsterInformation MonsterInformation;
        public static 
Dictionary<uint, MonstersInfo> MSSpawn = new Dictionary<uint, MonstersInfo>();
        public class 
MonstersInfo
        
{
            public 
uint UID;
            public 
uint Count;
            public 
string Name;
            public 
ushort MapID;
            public 
ushort Xx;
            public 
ushort Yy;
            public 
uint MonsterID;
            public 
bool EmptySpots;
            public 
int Respawn;
            public 
byte RangeSpot;
        }
        public static 
void Load()
        {
            
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("newmobspawn"))
            
using (var reader = cmd.CreateReader())
            {
                while (
reader.Read())
                {
                    
MonstersInfo MoB = new MonstersInfo();
                    
MoB.UID = reader.ReadUInt32("UID");
                    
MoB.Count = reader.ReadUInt32("Count");
                    
MoB.Name = reader.ReadString("Name");
                    
MoB.MapID = reader.ReadUInt16("MapID");
                    if (!
Kernel.Maps.ContainsKey(MoB.MapID))
                        
Database.DMaps.LoadMap(MoB.MapID);
                    
MoB.Xx = reader.ReadUInt16("Xx");
                    
MoB.Yy = reader.ReadUInt16("Yy");
                    
MoB.MonsterID = reader.ReadUInt32("MonsterID");
                    
MoB.EmptySpots = reader.ReadBoolean("EmptySpots");
                    
MoB.Respawn = reader.ReadInt32("Respawn");
                    
MoB.RangeSpot = reader.ReadByte("RangeSpot");
                    
MSSpawn.Add(MoB.UID, MoB);
                }
            }
            
SendSpawns();
            
Loading = false;
        }
        public static 
void SendSpawns()
        {
            
Loading = true;
            foreach (var 
mob in MSSpawn.Values)
            {
                try
                {
                    
Map = Kernel.Maps[mob.MapID];
                    if (
Map == null) { ReportError(mob, "[Map]"); continue; }
                    if (
mob.Count < 1) { ReportError(mob, "[Count]"); continue; }
                    if (
mob.MapID < 1) { ReportError(mob, "[MapID]"); continue; }
                    if (
mob.MonsterID < 1) { ReportError(mob, "[MonsterID]"); continue; }

                    
Tuple<ushort, ushort> coords;
                    if (
mob.EmptySpots)
                    {
                        for (
uint i = 0; i <= mob.Count; i++)
                        {
                            
coords = Map.RandomCoordinates();
                            if (
Kernel.GetDistance(coords.Item1, coords.Item2, mob.Xx, mob.Yy) > mob.RangeSpot * 2)//Mesh haytl3 el wo7osh fi el distance da..
                            
{
                                if (
Map.Npcs.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0 && Map.Entities.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0)
                                    
Spawn(mob, coords.Item1, coords.Item2);//Haytl3 el w7osh [b3eed] 3an el distance ale bt7dd..
                            
}
                        }
                    }
                    if (!
mob.EmptySpots)
                    {
                        if (
mob.Xx > 0)
                        {
                            for (
uint i = 0; i <= mob.Count; i++)
                            {
                                
coords = Kernel.Maps[mob.MapID].RandomCoordinates(mob.Xx, mob.Yy, mob.RangeSpot);
                                if (
Kernel.GetDistance(coords.Item1, coords.Item2, mob.Xx, mob.Yy) < mob.RangeSpot)//Haytl3 el w7osh [fe] el distance ale bt7dd bas..
                                
{
                                    if (
Map.Npcs.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0 && Map.Entities.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0)
                                        
Spawn(mob, coords.Item1, coords.Item2);
                                }
                            }
                        }
                        if (
mob.Xx == 0)
                        {
                            for (
uint i = 0; i <= mob.Count; i++)
                            {
                                
coords = Map.RandomCoordinates();
                                if (
Map.Npcs.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0 && Map.Entities.Values.Where(n => n.X == coords.Item1 && n.Y == coords.Item2).Count() == 0)
                                    
Spawn(mob, coords.Item1, coords.Item2);//Haytl3 el w7osh fe el map kolha
                            
}
                        }
                    }

                }
                catch (
Exception e)
                {
                    
Console.WriteLine(e);
                }
            }
        }
        public static 
void ReportError(MonstersInfo Mob, string reson)
        {
            
Console.ForegroundColor = ConsoleColor.Green;
            
Console.WriteLine(string.Format("UID: {0}, ID: {1}, Name: {2}, Count: {3}, MapID: {4}.." + reson.ToUpper(), Mob.UID, Mob.MonsterID, Mob.Name, Mob.Count, Mob.MapID));
            
Console.ForegroundColor = ConsoleColor.Red;
        }
        public static 
void Spawn(MonstersInfo Mob, ushort X, ushort Y)
        {
            if (
Database.MonsterInformation.MonsterInformations.ContainsKey(Mob.MonsterID))
            {
                
Database.MonsterInformation mt = Database.MonsterInformation.MonsterInformations[Mob.MonsterID];
                
mt.RespawnTime = Mob.Respawn;
                
mt.BoundX = X;
                
mt.BoundY = Y;
                
mt.BoundCX = X;
                
mt.BoundCY = Y;

                
Entity entity = new Entity(EntityFlag.Monster, false);
                
entity.MapObjType = MapObjectType.Monster;
                
entity.MonsterInfo = mt.Copy();
                
entity.MonsterInfo.Owner = entity;
                
entity.Name = mt.Name;
                
entity.MinAttack = mt.MinAttack;
                
entity.MaxAttack = entity.MagicAttack = mt.MaxAttack;
                
entity.Hitpoints = entity.MaxHitpoints = mt.Hitpoints;
                
entity.Defence = mt.Defence;
                
entity.Body = mt.Mesh;
                
entity.Level = mt.Level;
                
entity.UID = Map.EntityUIDCounter.Next;
                
entity.MapID = Map.ID;
                
entity.SendUpdates = true;
                
entity.X = X;
                
entity.Y = Y;

                if (
Map.Floor[entity.X, entity.Y, MapObjectType.Monster, entity])
                {
                    
Map.AddEntity(entity);
                }
                
Map.Timer = Map.MonsterTimers.Add(Map);
                foreach (var 
p in Kernel.GamePool.Values.Where(z => z.Map.ID == Map.ID && z.GetDistance(entity) <= 19))
                    
entity.SendSpawn(p);
            }
        }
    }
} 

والباقي هو هو

==============================
يلا في القاعده

عفواً لايمكن عرض الرابط إلا بعد الرد على الموضوع

=============================

متحطوش في map عدد كبير عشان هيجبلك ايرور في القنصول ^_^

بالتوفيق

لو الموضوع موجود عادي اقفلوا ^_^ بس حبيت افيد وانا دورت مش لقيته وموضوع حلوه جدا وبشكر عبدالله عليه بجد والكلام ده من سنه



التعديل الأخير تم بواسطة Hassan Emprator ; 2019-11-14 الساعة 07:47 PM