So as the title says, if a player in jiang hu mode attacks a ninjas shadow clones, the guards will kill them. Due to my inexperience in c#, I'm not really sure how to fix this (I have been at this for honestly about 4 hours and unfortunately no luck).
I'll post the codes below that I've found, maybe someone could help me fix this problem with the codes I provide.
Code:
case 12090:
{
if (CanUseSpell(spell, attacker.Owner))
{
PrepareSpell(spell, attacker.Owner);
SpellUse spellUse = new SpellUse(true);
spellUse.Attacker = attacker.Owner.Entity.UID;
spellUse.SpellID = spell.ID;
spellUse.SpellLevel = spell.Level;
spellUse.X = attacker.Owner.Entity.X;
spellUse.Y = attacker.Owner.Entity.Y;
attacker.Owner.SendScreen(spellUse, true);
if (attacker.MyClones.Count > 0)
{
foreach (var item in attacker.MyClones.Values)
{
Data data = new Data(true);
data.UID = item.UID;
data.ID = Network.GamePackets.Data.RemoveEntity;
attacker.Owner.SendScreen(data);
attacker.Owner.RemoveScreenSpawn(item, false);
attacker.Owner.Map.RemoveEntity(item);
attacker.Owner.Send(data);
attacker.Owner.SendScreen(data);
attacker.Owner.RemoveScreenSpawn(item, false);
}
attacker.MyClones.Clear();
break;
}
attacker.AddClone("" + attacker.Name + "", 3);
attacker.AddClone("" + attacker.Name + "", 10003);
}
break;
}
Code:
case 2812:
{
var attackedUID = BitConverter.ToUInt32(packet, 4);
var type = packet[8];
var attackerUID = BitConverter.ToUInt32(packet, 9);
var attackerUID2 = BitConverter.ToUInt32(packet, 13);
uint[] attackers = new uint[] { attackerUID, attackerUID2 };
foreach (var attacker in attackers)
{
{
Entity Clone = null;
if (client.Entity.MyClones.TryGetValue(attacker, out Clone))
{
Entity attacked = null;
SobNpcSpawn attackedsob = null;
if (client.Screen.TryGetValue(attackedUID, out attacked))
{
var attack = new Attack(true);
attack.Attacked = attackedUID;
attack.Attacker = attacker;
attack.AttackType = type;
attack.X = attacked.X;
attack.Y = attacked.Y;
if (Time64.Now > client.Entity.MyClones[attacker].AttackStamp.AddMilliseconds(1500))
{
if (Game.Attacking.Handle.CanAttack(client.Entity, attacked, null,
attack.AttackType == GamePackets.Attack.Melee))
{
client.Entity.MyClones[attacker].AttackStamp = Time64.Now;
uint damage = 0;
if (attack.AttackType == GamePackets.Attack.Melee)
damage = Game.Attacking.Calculate.Melee(client.Entity, attacked, ref attack);
damage = damage * 35 / 100;
Game.Attacking.Handle.ReceiveAttack(Clone, attacked, attack, damage, null);
attack.Damage = damage;
// client.Send(attack);
client.SendScreen(attack, true);
}
}
}
else
{
if (client.Screen.TryGetSob(attackedUID, out attackedsob))
{
var attack = new Attack(true);
attack.Attacked = attackedUID;
attack.Attacker = attacker;
attack.AttackType = 2;
attack.X = attackedsob.X;
attack.Y = attackedsob.Y;
client.Entity.MyClones[attacker].AttackPacket = attack;
if (Time64.Now >
client.Entity.MyClones[attacker].AttackStamp.AddMilliseconds(1500))
{
if (Game.Attacking.Handle.CanAttack(client.Entity, attackedsob, null))
{
client.Entity.MyClones[attacker].AttackStamp = Time64.Now;
uint damage = 0;
if (attack.AttackType == GamePackets.Attack.Melee)
damage = Game.Attacking.Calculate.Melee(client.Entity, attackedsob,
ref attack);
Game.Attacking.Handle.ReceiveAttack(Clone, attackedsob, attack, damage,
null);
attack.Damage = damage;
// client.Send(attack);
client.SendScreen(attack, true);
}
}
}
}
}
}
}
break;
}
Code:
if (client.Entity.MyClones.Count > 0)
{
foreach (var clone in client.Entity.MyClones.Values)
{
if (clone.AttackPacket != null)
{
if (Now >
client.Entity.AttackStamp.AddMilliseconds(1000 -
client.Entity.Agility))
{
SobNpcSpawn attacked = null;
if (client.Screen.TryGetSob(clone.AttackPacket.Attacked,
out attacked))
{
var attacker = clone;
attacker.EntityFlag = EntityFlag.Player;
new Game.Attacking.Handle(clone.AttackPacket, attacker, null);
}
}
}
}
}






