Quote:
Originally Posted by pro4never
There's probably a much better way to modularize your code (such as creating an overload for the Monster/Entity constructor to let you generate a monster based on ID/Map/X/Y).
Also worth noting that goto statements should be avoided and are considered poor programming practice. You'd be better off doing something like..
while(client.Map.Entities.ContainsKey((uint)(entit y.UID)))
entity.UID = (uint)ServerBase.Kernel.Random.Next(400000, 500000);
Still... much MUCH better ways to write this all.
|
i've done this ages ago

with 2 overrides
one of them with client instance and one without
Code:
#region summonat
case "summonat":
{
//bookmark3
RESPAWN:
Database.MonsterInformation monster = Database.MonsterInformation.MonsterInfos[Convert.ToUInt32(Data[1])];
Game.Entity entity = new Game.Entity(Game.EntityFlag.Monster, false);
entity.MapObjType = Game.MapObjectType.Monster;
entity.MonsterInfo = monster;
entity.MonsterInfo.Owner = entity;
entity.Name = monster.Name;
entity.MinAttack = monster.MinAttack;
entity.MaxAttack = entity.MagicAttack = monster.MaxAttack;
entity.Hitpoints = entity.MaxHitpoints = monster.Hitpoints;
entity.Body = monster.Mesh;
entity.Level = monster.Level;
entity.Defence = 100;
entity.X = Convert.ToUInt16(Data[3]);
entity.Y = Convert.ToUInt16(Data[4]);
entity.UID = (uint)ServerBase.Kernel.Random.Next(500000, 500050);
entity.MapID = Convert.ToUInt16(Data[2]);
entity.SendUpdates = true;
client.Map.RemoveEntity(entity);
client.Map.AddEntity(entity);
if (!client.Map.Entities.ContainsKey((uint)(entity.UID)))
{
Conquer_Online_Server.Console.WriteLine("couldn't summon monster , retrying");
goto RESPAWN;
}
break;
}
#endregion
but im no longer using that

but thanks for the notifying about goto

now im using method with instance of monster information parameter and summoning it which is way better , btw this method sometimes fail to summon monsters which to why i no longer use it
thanks pro ^^