المشاركة الأصلية كتبت بواسطة hassan emprator
(المشاركة 20081)
اوك تمام
ابدا واحده واحده ولو جالك ايرورو قولي
اول حاجه هتروح handel.cs
وتبحث عن
هنبدله بي دا
كود PHP:
#region shadowclone
case 12090:
{
attacker.attackpacket = null;
if (attacker.myclones.count > 0)
{
var clones = attacker.myclones.values.toarray();
for (int i = 0; i < clones.length; i++)
{
var item = clones[i];
if (item == null)
continue;
data data = new data(true);
data.uid = item.uid;
data.id = network.gamepackets.data.removeentity;
attacker.owner.sendscreen(data);
attacker.myclones[item.uid] = null;
}
attacker.myclones.clear();
}
else
{
if (canusespell(spell, attacker.owner))
{
preparespell(spell, attacker.owner);
spelluse spelluse = new spelluse(true);
spelluse.attacker = attacker.uid;
spelluse.spellid = spell.id;
spelluse.spelllevel = spell.level;
spelluse.x = x;
spelluse.y = y;
attacker.addclone(3);
if (spell.level >= 4)
attacker.addclone(10003);
foreach (var item in attacker.myclones.values)
spelluse.addtarget(item, 0, attack);
attacker.owner.sendscreen(spelluse, true);
}
}
break;
}
#endregion
هيجللك ايرور في addclone
هتفتح كلاس entity
هضيف دا في اي مكان تحت اي فويد
كود PHP:
public safedictionary<uint, entity> myclones = new safedictionary<uint, entity>();
public bool isclone = false;
public void addclone(ushort cloneid)
{
#region spawnpacket(10014)
var entity = new entity(entityflag.entity, true);
entity.monsterinfo = new monsterinformation();
monsterinformation.monsterinformations.trygetvalue(9003, out entity.monsterinfo);
entity.owner = owner;
entity.monsterinfo.owner = entity;
entity.isclone = true;
entity._name = "shadowclone";
entity.clan = name;
entity.spawnpacket = new byte[8 + _names + _name.length + 36];
array.copy(spawnpacket, entity.spawnpacket, entity.spawnpacket.length);
writestringlist(new list<string>() { "shadowclone", "", "", name, "" }, _names, entity.spawnpacket);
entity.mesh = mesh;
entity.hitpoints = 1;
entity.uid = owner.map.clonecounter.next;
entity.guildid = entity.guildrank = entity.action = 0;
entity.countryid = enums.countryid.default;
entity.statusflag = entity.statusflag2 = entity.statusflag3 = entity.statusflag4 = 0;
writer.write((uint)0, game.conquerstructures.equipment.steed, entity.spawnpacket);
writer.write((uint)0, game.conquerstructures.equipment.steedplus, entity.spawnpacket);
writer.write((uint)0, game.conquerstructures.equipment.steedcolor, entity.spawnpacket);
writer.write((uint)0, game.conquerstructures.equipment.mountarmor, entity.spawnpacket);
writer.write((uint)0, game.conquerstructures.equipment.wing, entity.spawnpacket);
writer.write((uint)0, game.conquerstructures.equipment.wingplus, entity.spawnpacket);
entity.flowerrank = 0;
entity.nobilityrank = conquerstructures.nobilityrank.serf;
entity.class = entity.firstrebornclass = entity.secondrebornclass = entity.jiangtalent = entity.subclassesactive = entity.reborn = entity.level = entity.serverid = 0;
writer.write((byte)2, 271, entity.spawnpacket);
writer.write(cloneid, 272, entity.spawnpacket);
entity.owneruid = uid;
entity.jiangactive = false;
writer.write((uint)0, 178, entity.spawnpacket);
writer.write((uint)0, 182, entity.spawnpacket);
writer.write((uint)0, 186, entity.spawnpacket);
writer.write((uint)0, _unionexploits, entity.spawnpacket);
writer.write((uint)0, _unionid, entity.spawnpacket);
writer.write((uint)0, _unionrank, entity.spawnpacket);
writer.write((uint)0, _uniontype, entity.spawnpacket);
writer.write((uint)0, _mytitle, entity.spawnpacket);
writer.write((uint)0, _mytitlescore, entity.spawnpacket);
writer.write((uint)0, _mywing, entity.spawnpacket);
entity.minattack = minattack;
entity.maxattack = entity.magicattack = math.max(minattack, maxattack);
entity.appearance = appearance;
entity.mapid = owner.map.id;
entity.sendupdates = true;
#endregion spawnpacket(10014)
#region pet(2035)
msgpetinfo pet = new msgpetinfo();
pet.uid = entity.uid;
pet.petid = cloneid;
pet.pettype = 2;
pet.mesh = mesh;
pet.attackrange = (byte)attackrange;
pet.x = x;
pet.y = y;
pet.name = "shadowclone";
owner.send(pet);
#endregion pet(2035)
myclones.add(entity.uid, entity);
owner.sendscreen(entity.spawnpacket, true);
owner.sendscreenspawn(entity, true);
#region data(10010)
data data = new data(true);
data.uid = entity.uid;
data.facing = entity.facing;
data.id = data.addentity;
data.wparam1 = entity.x;
data.wparam2 = entity.y;
owner.send(data);
#endregion data(10010)
}
طيب دلوتقي هيجليلي ايررور ان في ايرورو هيجلي دلوقتي في كلمه اسمها already
لو لاقيت الكود دا معناه ان الكود دا متكرر الي متكرر روح امسحه وسيب الي انا ضايفهولك تمام ؟
هتبحث عن الكود دا
كود PHP:
public void reload(interfaces.ipacket spawnwith = null)
هتلاقيه في دا
كود PHP:
#region other pet & clones
بدله بي دا
كود PHP:
#region other pet & clones
if (pclient.entity.myclones.count > 0)
{
foreach (var clone in pclient.entity.myclones.values)
{
if (clone == null) continue;
if (kernel.getdistance(clone.x, clone.y, owner.entity.x, owner.entity.y) <= 18 && !contains(clone.uid))
{
if (!clone.dead)
clone.sendspawn(owner);
}
}
}
if (pclient.pet.pets.count > 0)
{
foreach (var pet in pclient.pet.pets.values)
{
if (pet == null) continue;
if (pet.entity == null) continue;
if (kernel.getdistance(pet.entity.x, pet.entity.y, owner.entity.x, owner.entity.y) <= 18 && !contains(pet.entity.uid))
{
if (!pet.entity.dead)
pet.entity.sendspawn(owner);
}
}
}
#endregion
وهتلا
وهتلاقي دا برضو فيه برضو
بدله بي دا
كود بلغة HTML:
#region my pet & clones
if (owner.entity.myclones.count > 0)
{
foreach (var clone in owner.entity.myclones.values)
{
if (clone == null) continue;
if (kernel.getdistance(clone.x, clone.y, owner.entity.x, owner.entity.y) <= 18 && !contains(clone.uid))
{
if (!clone.dead)
clone.sendspawn(owner);
}
}
}
if (owner.pet.pets.count > 0)
{
foreach (var pet in owner.pet.pets.values)
{
if (pet == null) continue;
if (pet.entity == null) continue;
if (kernel.getdistance(pet.entity.x, pet.entity.y, owner.entity.x, owner.entity.y) <= 18/* && !contains(pet.entity.uid)*/)
{
if (!pet.entity.dead)
owner.send(pet.entity.spawnpacket);
// pet.entity.sendspawn(owner, false);
}
}
}
#endregion
هتعمل كلاس جديد وهتسميه pet
كود PHP:
using system;
using system.collections.generic;
using system.linq;
using system.text;
using mrhassan.client;
using mrhassan.game;
using system.threading.generic;
using mrhassan.database;
using mrhassan.network.gamepackets;
using mrhassan.network;
using mrhassan.game.conquerstructures;
using system.collections.concurrent;
namespace mrhassan.copra
{
public class pet
{
public enum pettype
{
normal = 0,
looter,
stiger,
attacker,
defender
}
public class petinfo
{
public entity entity;
public pettype type;
public gamestate owner;
}
#region static actions
private static timerrule<gamestate> petsaction;
public static void createtimerfactories()
{
petsaction = new timerrule<gamestate>(petsactioncallback, 500);
}
private static void petsactioncallback(gamestate client, int time)
{
if (!client.socket.alive)
{
client.pet.disposetimers();
return;
}
if (client.entity == null)
return;
if (client.map == null)
return;
if (client.pet == null)
return;
if (client.pet.pets == null)
{
client.pet.disposetimers();
return;
}
time32 now = new time32(time);
var pets = client.pet.pets.values;
foreach (var pet in pets)
{
if (pet != null)
{
#region back to owner
short distance = kernel.getdistance(pet.entity.x, pet.entity.y, client.entity.x, client.entity.y);
if (distance >= 8)
{
ushort x = (ushort)(client.entity.x + kernel.random.next(2));
ushort y = (ushort)(client.entity.y + kernel.random.next(2));
if (!client.map.selectcoordonates(ref x, ref y))
{
x = client.entity.x;
y = client.entity.y;
}
pet.entity.x = x;
pet.entity.y = y;
network.gamepackets.data data = new mrhassan.network.gamepackets.data(true);
data.id = network.gamepackets.data.jump;
data.dwparam = (uint)((y << 16) | x);
data.wparam1 = x;
data.wparam2 = y;
data.uid = pet.entity.uid;
pet.entity.monsterinfo.sendscreen(data);
client.sendscreenspawn(pet.entity, true);
}
else if (distance > 4)
{
enums.conquerangle facing = kernel.getangle(pet.entity.x, pet.entity.y, pet.entity.owner.entity.x, pet.entity.owner.entity.y);
if (!pet.entity.move(facing))
{
facing = (enums.conquerangle)kernel.random.next(7);
if (pet.entity.move(facing))
{
pet.entity.facing = facing;
network.gamepackets.groundmovement move = new mrhassan.network.gamepackets.groundmovement(true);
move.direction = facing;
move.uid = pet.entity.uid;
move.groundmovementtype = network.gamepackets.groundmovement.run;
pet.entity.monsterinfo.sendscreen(move);
}
}
else
{
pet.entity.facing = facing;
network.gamepackets.groundmovement move = new mrhassan.network.gamepackets.groundmovement(true);
move.direction = facing;
move.uid = pet.entity.uid;
move.groundmovementtype = network.gamepackets.groundmovement.run;
pet.entity.monsterinfo.sendscreen(move);
}
client.sendscreenspawn(pet.entity, true);
}
#endregion
switch (pet.type)
{
case pettype.normal:
{
/* #region normal attack guard
{
var monster = pet.entity;
if (monster.monsterinfo.insight == 0)
{
if (client.entity.attackpacket != null)
{
if (client.entity.attackpacket.attacktype == network.gamepackets.attack.magic)
{
if (client.entity.attackpacket.decoded)
{
if (database.spelltable.spellinformations.containskey((ushort)client.entity.attackpacket.damage))
{
var info = database.spelltable.spellinformations[(ushort)client.entity.attackpacket.damage].values.toarray()[client.spells[(ushort)client.entity.attackpacket.damage].level];
if (info.cankill)
{
monster.monsterinfo.insight = client.entity.attackpacket.attacked;
}
}
}
}
else
{
monster.monsterinfo.insight = client.entity.attackpacket.attacked;
}
}
}
else
{
if (monster.monsterinfo.insight > 400000 && monster.monsterinfo.insight < 600000 || monster.monsterinfo.insight > 800000 && monster.monsterinfo.insight != monster.uid)
{
entity attacked = null;
if (client.screen.trygetvalue(monster.monsterinfo.insight, out attacked))
{
if (now > monster.attackstamp.addmilliseconds(monster.monsterinfo.attackspeed))
{
monster.attackstamp = now;
if (attacked.dead)
{
monster.monsterinfo.insight = 0;
}
else
new game.attacking.handle(null, monster, attacked);
}
}
else
monster.monsterinfo.insight = 0;
}
}
}
#endregion*/
break;
}
case pettype.stiger:
{
/* #region stiger guard
if (!client.entity.containsflag(update.flags.stigma))
{
spelluse suse = new spelluse(true);
suse.attacker = pet.entity.uid;
suse.spellid = 1095;
suse.spelllevel = 4;
suse.x = client.entity.x;
suse.y = client.entity.y;
suse.addtarget(client.entity, 0, null);
client.entity.addflag(update.flags.stigma);
client.entity.stigmastamp = time32.now;
client.entity.stigmaincrease = 50;
client.entity.stigmatime = (byte)60;
if (client.entity.entityflag == entityflag.entity)
client.entity.owner.send(constants.stigma(50, 60));
}
#endregion*/
break;
}
case pettype.looter:
{
/* #region shield guard
if (!client.entity.containsflag(update.flags.magicshield))
{
spelluse suse = new spelluse(true);
suse.attacker = pet.entity.uid;
suse.spellid = 1090;
suse.spelllevel = 4;
suse.x = client.entity.x;
suse.y = client.entity.y;
suse.addtarget(client.entity, 0, null);
client.entity.addflag(update.flags.magicshield);
client.entity.shieldstamp = time32.now;
client.entity.shieldincrease = 1.1f;
client.entity.shieldtime = (byte)60;
if (client.entity.entityflag == entityflag.entity)
client.entity.owner.send(constants.shield(50, 60));
}
#endregion*/
break;
}
case pettype.attacker:
{
/* #region attacker
foreach (var obj in client.screen.objects)
{
if (client.entity.dead)
return;
if (obj.mapobjtype == mapobjecttype.monster)
{
var attacked = obj as entity;
if (attacked.companion || attacked.monsterinfo.guard)
continue;
// if (kernel.getdistance(pet.entity.x, pet.entity.y, attacked.x, attacked.y) <= 15)
{
if (now > pet.entity.attackstamp.addmilliseconds(1000 - client.entity.agility))
{
pet.entity.attackstamp = now;
if (!attacked.dead)
new game.attacking.handle(null, pet.entity, attacked);
}
}
}
else if (obj.mapobjtype == mapobjecttype.entity)
{
var attacked = obj as entity;
if (attacked.dead)
continue;
if (game.attacking.handle.canattack(client.entity, attacked, null, true))
{
// if (kernel.getdistance(pet.entity.x, pet.entity.y, attacked.x, attacked.y) <= 15)
{
if (now > pet.entity.attackstamp.addmilliseconds(1000 - client.entity.agility))
{
pet.entity.attackstamp = now;
if (!attacked.dead)
new game.attacking.handle(null, pet.entity, attacked);
}
}
}
}
else if (obj.mapobjtype == mapobjecttype.sobnpc)
{
var attackedsobnpc = obj as sobnpcspawn;
if (game.attacking.handle.canattack(client.entity, attackedsobnpc, null))
{
// if (kernel.getdistance(pet.entity.x, pet.entity.y, attackedsobnpc.x, attackedsobnpc.y) <= 15)
{
if (now > pet.entity.attackstamp.addmilliseconds(1000 - client.entity.agility))
{
pet.entity.attackstamp = now;
spelluse suse = new spelluse(true);
attack attack = new attack(true);
attack.effect1 = attack.attackeffects1.none;
uint damage = game.attacking.calculate.melee(client.entity, attackedsobnpc, ref attack);
suse.effect1 = attack.effect1;
game.attacking.handle.receiveattack(pet.entity, attackedsobnpc, attack, damage, null);
suse.attacker = pet.entity.uid;
suse.spellid = pet.entity.monsterinfo.spellid;
suse.x = attackedsobnpc.x;
suse.y = attackedsobnpc.y;
suse.addtarget(attackedsobnpc, damage, attack);
pet.entity.owner.sendscreen(suse, true);
}
}
}
}
}
#endregion*/
break;
}
case pettype.defender:
{
/* #region defender
foreach (var obj in client.screen.objects)
{
if (obj.mapobjtype == mapobjecttype.monster)
{
var attacked = obj as entity;
if (attacked.monsterinfo != null)
{
if (attacked.monsterinfo.insight == client.entity.uid || attacked.monsterinfo.insight == pet.entity.uid)
{
if (now > pet.entity.attackstamp.addmilliseconds(1000 - client.entity.agility))
{
pet.entity.attackstamp = now;
if (!attacked.dead)
new game.attacking.handle(null, pet.entity, attacked);
}
}
}
}
else if (obj.mapobjtype == mapobjecttype.entity)
{
var attacked = obj as entity;
if (attacked.attackpacket != null)
{
if (attacked.attackpacket.attacked == client.entity.uid || attacked.attackpacket.attacked == pet.entity.uid)
{
if (now > pet.entity.attackstamp.addmilliseconds(1000 - client.entity.agility))
{
pet.entity.attackstamp = now;
if (!attacked.dead)
new game.attacking.handle(null, pet.entity, attacked);
}
}
}
}
}
#endregion*/
break;
}
}
}
else
break;
}
}
#endregion
#region timers
private idisposable[] timersubscriptions;
private object disposalsyncroot;
~pet()
{
disposetimers();
owner = null;
pets = null;
}
private void disposetimers()
{
lock (disposalsyncroot)
{
if (timersubscriptions == null) return;
for (int i = 0; i < timersubscriptions.length; i++)
{
if (timersubscriptions[i] != null)
{
timersubscriptions[i].dispose();
timersubscriptions[i] = null;
}
}
}
}
#endregion
public uint maxallowed = 2;
public gamestate owner;
public safeconcurrentdictionary<pettype, petinfo> pets;
public pet(gamestate client)
{
owner = client;
pets = new safeconcurrentdictionary<pettype, petinfo>();
timersubscriptions = new idisposable[]
{
petsaction.add(client)
};
disposalsyncroot = new object();
}
public void addpet(monsterinformation mob, pettype type = pettype.normal)
{
if (pets.count == maxallowed)
clearall();
if (mob.mesh == 847)
type = pettype.stiger;
if (mob.mesh == 850)
type = pettype.attacker;
if (mob.mesh == 848 || mob.mesh == 849)
type = pettype.defender;
if (mob.mesh == 846)
type = pettype.looter;
if (mob.spellid == 0)
mob.spellid = 1002;
if (type != pettype.normal)
{
var mesh = mob.mesh;
var name = mob.name;
monsterinformation.monsterinformations.trygetvalue(9003, out mob);
mob.mesh = mesh;
mob.name = name;
}
if (pets.containskey(type))
{
data data = new data(true);
data.uid = pets[type].entity.uid;
data.id = data.removeentity;
pets[type].entity.monsterinfo.sendscreen(data);
pets[type].entity = null;
pets.remove(type);
}
petinfo pet = new petinfo();
pet.type = type;
pet.owner = owner;
pet.entity = new entity(entityflag.monster, true);
pet.entity.monsterinfo = new monsterinformation();
pet.entity.owner = owner;
pet.entity.mapobjtype = mapobjecttype.monster;
pet.entity.monsterinfo = mob.copy();
pet.entity.monsterinfo.owner = pet.entity;
pet.entity.name = mob.name;
if (type != pettype.normal)
pet.entity.name = mob.name + "(" + owner.entity.name + ")";
pet.entity.minattack = mob.minattack;
pet.entity.maxattack = pet.entity.magicattack = math.max(mob.minattack, mob.maxattack);
pet.entity.hitpoints = pet.entity.maxhitpoints = mob.hitpoints;
pet.entity.body = mob.mesh;
pet.entity.level = mob.level;
pet.entity.uid = (uint)(owner.entity.uid - (200000 + pets.count));
pet.entity.mapid = owner.map.id;
pet.entity.sendupdates = true;
pet.entity.x = owner.entity.x;
pet.entity.y = owner.entity.y;
pet.entity.pettype = type;
pets.add(pet.type, pet);
owner.sendscreenspawn(pet.entity, true);
// pet.entity.sendspawn(owner);
}
public void removepet(pettype type)
{
if (pets.count == 0)
return;
if (pets[type] == null) return;
data data = new data(true);
data.uid = pets[type].entity.uid;
data.id = data.removeentity;
pets[type].entity.monsterinfo.sendscreen(data);
pets.remove(type);
}
public void clearall()
{
if (pets.count > 0)
{
foreach (var pet in pets.values)
{
data data = new data(true);
data.uid = pet.entity.uid;
data.id = data.removeentity;
pet.entity.monsterinfo.sendscreen(data);
pet.entity = null;
}
pets.clear();
}
}
}
}
بعدين هتبحث عن الكود دا
كود PHP:
public languages language = languages.english;
تضيف دا تحته
بعديت تبحث عن
كود PHP:
foreach (var clone in entity.myclones)
هتبدله بي دا
كود PHP:
if (entity.myclones.count > 0)
{
foreach (var item in entity.myclones.values)
{
data data = new data(true);
data.uid = item.uid;
data.id = network.gamepackets.data.removeentity;
item.monsterinfo.sendscreen(data);
}
entity.myclones.clear();
}
بعدين هتبحث عن الكود
دا
كود PHP:
public void die(uint32 killer)
هتلاقي فيه داد
كود PHP:
foreach (var clone in myclones)
بدله بي دا
كود PHP:
if (myclones.count > 0)
{
foreach (var item in myclones.values)
{
data data = new data(true);
data.uid = item.uid;
data.id = network.gamepackets.data.removeentity;
item.monsterinfo.sendscreen(data);
}
myclones.clear();
}
بعيدن هتبحث عن الكود دا
كود PHP:
public void die(entity killer)
هتلاقي فيه دا
بدله
بي دا
كود PHP:
#region myclones
if (myclones.count > 0)
{
foreach (var item in myclones.values)
{
data data = new data(true);
data.uid = item.uid;
data.id = network.gamepackets.data.removeentity;
item.monsterinfo.sendscreen(data);
}
myclones.clear();
}
#endregion
بعدين هتبحث عن الكود دا
كود PHP:
public void teleporthouse(ushort mapid, ushort x, ushort y)
هتلاقي فيه دا
كود PHP:
if (myclones.count != 0)
{
foreach (var clone in myclones)
clone.removethat();
myclones.clear();
}
امثحه
بعيدن هتضور عا الكود دا
كود PHP:
public void advancedteleport(bool remove = false)
هتلاقيه في دا
كود PHP:
#region teleport with pet & clones
بدله بي دا
كود PHP:
#region teleport with pet & clones
if (entityflag == entityflag.entity)
{
if (myclones.count > 0)
{
foreach (var clone in myclones.values)
{
if (clone == null) continue;
if (remove)
{
data data = new data(true);
data.uid = clone.uid;
data.id = network.gamepackets.data.removeentity;
owner.sendscreen(data);
owner.removescreenspawn(clone, true);
}
else
{
clone.mapid = this.mapid;
clone.x = this.x;
clone.y = this.y;
network.gamepackets.data data = new network.gamepackets.data(true);
data.uid = clone.uid;
data.id = network.gamepackets.data.teleport;
data.dwparam = database.mapstable.mapinformations[mapid].baseid;
data.wparam1 = clone.x;
data.wparam2 = clone.y;
owner.sendscreen(data);
owner.sendscreenspawn(clone, true);
}
}
}
if (owner.pet != null)
{
if (owner.pet.pets.count > 0)
{
foreach (var pet in owner.pet.pets.values)
{
if (pet == null) continue;
if (pet.entity == null) continue;
if (remove)
{
data data = new data(true);
data.uid = pet.entity.uid;
data.id = network.gamepackets.data.removeentity;
owner.sendscreen(data);
owner.removescreenspawn(pet.entity, true);
}
else
{
pet.entity.mapid = this.mapid;
pet.entity.x = this.x;
pet.entity.y = this.y;
owner.sendscreenspawn(pet.entity, true);
}
}
}
}
if (remove)
owner.removescreenspawn(owner.entity, false);
}
#endregion teleport with pet & clones
بعدين هيجلك ايررو في الاخر
شكله كدا
كود PHP:
pet.entity.pettype = type;
اعمله //
بس كدا تم حلها ولو لسا في مشاكل كلمني
|