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

الردود
13

المشاهدات
10434
 
midoazoz

midoazoz is on a distinguished road

    غير متواجد

المشاركات
328

+التقييم
0.16

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

الاقامة

نظام التشغيل

رقم العضوية
2314
2019-11-14, 07:40 PM
المشاركة 1 
#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<uintMonstersInfoMSSpawn = new Dictionary<uintMonstersInfo>();
        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.UIDMoB);
                }
            }
            
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<ushortushortcoords;
                    if (
mob.EmptySpots)
                    {
                        for (
uint i 0<= mob.Counti++)
                        {
                            
coords Map.RandomCoordinates();
                            if (
Kernel.GetDistance(coords.Item1coords.Item2mob.Xxmob.Yy) > mob.RangeSpot 2)//Mesh haytl3 el wo7osh fi el distance da..
                            
{
                                if (
Map.Npcs.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == && Map.Entities.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == 0)
                                    
Spawn(mobcoords.Item1coords.Item2);//Haytl3 el w7osh [b3eed] 3an el distance ale bt7dd..
                            
}
                        }
                    }
                    if (!
mob.EmptySpots)
                    {
                        if (
mob.Xx 0)
                        {
                            for (
uint i 0<= mob.Counti++)
                            {
                                
coords Kernel.Maps[mob.MapID].RandomCoordinates(mob.Xxmob.Yymob.RangeSpot);
                                if (
Kernel.GetDistance(coords.Item1coords.Item2mob.Xxmob.Yy) < mob.RangeSpot)//Haytl3 el w7osh [fe] el distance ale bt7dd bas..
                                
{
                                    if (
Map.Npcs.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == && Map.Entities.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == 0)
                                        
Spawn(mobcoords.Item1coords.Item2);
                                }
                            }
                        }
                        if (
mob.Xx == 0)
                        {
                            for (
uint i 0<= mob.Counti++)
                            {
                                
coords Map.RandomCoordinates();
                                if (
Map.Npcs.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == && Map.Entities.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == 0)
                                    
Spawn(mobcoords.Item1coords.Item2);//Haytl3 el w7osh fe el map kolha
                            
}
                        }
                    }

                }
                catch (
Exception e)
                {
                    
Console.WriteLine(e);
                }
            }
        }
        public static 
void ReportError(MonstersInfo Mobstring reson)
        {
            
Console.ForegroundColor ConsoleColor.Green;
            
Console.WriteLine(string.Format("UID: {0}, ID: {1}, Name: {2}, Count: {3}, MapID: {4}.." reson.ToUpper(), Mob.UIDMob.MonsterIDMob.NameMob.CountMob.MapID));
            
Console.ForegroundColor ConsoleColor.Red;
        }
        public static 
void Spawn(MonstersInfo Mobushort Xushort 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.Monsterfalse);
                
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;
                
entity.Y;

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


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

نبحث عن


كود:
private static void _timerCallBack(Map mapint 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<uintMonstersInfoMSSpawn = new Dictionary<uintMonstersInfo>();
        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.UIDMoB);
                }
            }
            
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<ushortushortcoords;
                    if (
mob.EmptySpots)
                    {
                        for (
uint i 0<= mob.Counti++)
                        {
                            
coords Map.RandomCoordinates();
                            if (
Kernel.GetDistance(coords.Item1coords.Item2mob.Xxmob.Yy) > mob.RangeSpot 2)//Mesh haytl3 el wo7osh fi el distance da..
                            
{
                                if (
Map.Npcs.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == && Map.Entities.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == 0)
                                    
Spawn(mobcoords.Item1coords.Item2);//Haytl3 el w7osh [b3eed] 3an el distance ale bt7dd..
                            
}
                        }
                    }
                    if (!
mob.EmptySpots)
                    {
                        if (
mob.Xx 0)
                        {
                            for (
uint i 0<= mob.Counti++)
                            {
                                
coords Kernel.Maps[mob.MapID].RandomCoordinates(mob.Xxmob.Yymob.RangeSpot);
                                if (
Kernel.GetDistance(coords.Item1coords.Item2mob.Xxmob.Yy) < mob.RangeSpot)//Haytl3 el w7osh [fe] el distance ale bt7dd bas..
                                
{
                                    if (
Map.Npcs.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == && Map.Entities.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == 0)
                                        
Spawn(mobcoords.Item1coords.Item2);
                                }
                            }
                        }
                        if (
mob.Xx == 0)
                        {
                            for (
uint i 0<= mob.Counti++)
                            {
                                
coords Map.RandomCoordinates();
                                if (
Map.Npcs.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == && Map.Entities.Values.Where(=> n.== coords.Item1 && n.== coords.Item2).Count() == 0)
                                    
Spawn(mobcoords.Item1coords.Item2);//Haytl3 el w7osh fe el map kolha
                            
}
                        }
                    }

                }
                catch (
Exception e)
                {
                    
Console.WriteLine(e);
                }
            }
        }
        public static 
void ReportError(MonstersInfo Mobstring reson)
        {
            
Console.ForegroundColor ConsoleColor.Green;
            
Console.WriteLine(string.Format("UID: {0}, ID: {1}, Name: {2}, Count: {3}, MapID: {4}.." reson.ToUpper(), Mob.UIDMob.MonsterIDMob.NameMob.CountMob.MapID));
            
Console.ForegroundColor ConsoleColor.Red;
        }
        public static 
void Spawn(MonstersInfo Mobushort Xushort 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.Monsterfalse);
                
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;
                
entity.Y;

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


والباقي هو هو

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

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

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

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

بالتوفيق

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