Advertisement
shekohex

Clone Attack Packet

Oct 2nd, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.96 KB | None | 0 0
  1.                 #region  Shadow Clone Attack
  2.                 case 2812:
  3.                     {
  4.  
  5.                         var attackd = BitConverter.ToUInt32(packet, 4);
  6.                         var attack = client.Entity.Shadowattack;
  7.                         ushort skillmeto = attack.MagicType;
  8.                         ushort levelmeto = attack.MagicLevel;
  9.                         attack.Attacked = attackd;
  10.                         var clonecount = packet[8];
  11.                         for (int i = 0; i < clonecount; i++)
  12.                         {
  13.                             var attackr = BitConverter.ToUInt32(packet, 9 + (i * 4));
  14.                             attack.Attacker = attackr;
  15.  
  16.                             #region var
  17.  
  18.                             #endregion
  19.  
  20.                             if (client.Entity.MyClones.Count == 0)
  21.                                 return;
  22.                             if (attackr == client.Entity.UID)
  23.                                 return;
  24.                             Entity Clone = null;
  25.                             #region CloneAttack MeToOo
  26.                             if (client.Entity.MyClones.TryGetValue(attackr, out Clone))
  27.                             {
  28.                                 Entity attacked = null;
  29.                                 SobNpcSpawn attackedsob = null;
  30.                                 if (client.Screen.TryGetValue(attackd, out attacked))
  31.                                 {
  32.                                     if (Game.Attacking.Handle.CanAttack(client.Entity, attacked, null, attack.AttackType == GamePackets.Attack.Melee))
  33.                                     {
  34.                                         var spell = Database.SpellTable.GetSpell(skillmeto, (byte)levelmeto);
  35.                                         if (spell == null)
  36.                                         {
  37.                                             Game.Attacking.Handle.CloneEntityMelee(Clone, attacked, attackedsob, client.Entity.Shadowattack);
  38.                                         }
  39.                                         else
  40.                                         {
  41.                                             uint damage = 0;
  42.                                             if (attack.AttackType == GamePackets.Attack.Melee)
  43.                                                 damage = Game.Attacking.Calculate.Melee(client.Entity, attacked, ref attack);
  44.                                             else if (attack.AttackType == GamePackets.Attack.Ranged)
  45.                                                 damage = Game.Attacking.Calculate.Ranged(client.Entity, attacked, ref attack);
  46.                                             if (attack.AttackType == GamePackets.Attack.Magic)
  47.                                                 damage = Game.Attacking.Calculate.Magic(client.Entity, attacked, spell, ref attack);
  48.  
  49.                                             damage = (uint)((double)damage * 0.6);
  50.  
  51.                                             attack.Damage = damage;
  52.                                             SpellUse spellUse = new SpellUse(true);
  53.                                             spellUse.Attacker = Clone.UID;
  54.                                             spellUse.SpellID = spell.ID;
  55.                                             spellUse.SpellLevel = spell.Level;
  56.                                             spellUse.X = Clone.X;
  57.                                             spellUse.Y = Clone.Y;
  58.                                             spellUse.Effect1 = attack.Effect1;
  59.                                             spellUse.Effect2 = attack.Effect2;
  60.                                             spellUse.AddTarget(attacked.UID, damage, attack);
  61.                                             Game.Attacking.Handle.ReceiveAttack(Clone, attacked, attack, damage, spell);
  62.                                             client.SendScreen(spellUse, true);
  63.                                             client.SendScreen(attack, true);
  64.                                         }
  65.                                     }
  66.                                 }
  67.                                 else if (client.Screen.TryGetSob(attackd, out attackedsob))
  68.                                 {
  69.                                     if (Game.Attacking.Handle.CanAttack(client.Entity, attackedsob, null))
  70.                                     {
  71.                                         var spell = Database.SpellTable.GetSpell(skillmeto, (byte)levelmeto);
  72.                                         if (spell == null)
  73.                                         {
  74.                                             Game.Attacking.Handle.CloneEntityMelee(Clone, attacked, attackedsob, client.Entity.Shadowattack);
  75.                                         }
  76.                                         else
  77.                                         {
  78.                                             uint damage = 0;
  79.                                             if (attack.AttackType == GamePackets.Attack.Melee)
  80.                                                 damage = Game.Attacking.Calculate.Melee(client.Entity, attackedsob, ref attack);
  81.                                             else if (attack.AttackType == GamePackets.Attack.Ranged)
  82.                                                 damage = Game.Attacking.Calculate.Ranged(client.Entity, attackedsob, ref attack);
  83.                                             if (attack.AttackType == GamePackets.Attack.Magic)
  84.                                                 damage = Game.Attacking.Calculate.Magic(client.Entity, attackedsob, spell, ref attack);
  85.  
  86.                                             damage = (uint)((double)damage * 0.6);
  87.  
  88.                                             attack.Damage = damage;
  89.                                             SpellUse spellUse = new SpellUse(true);
  90.                                             spellUse.Attacker = Clone.UID;
  91.                                             spellUse.SpellID = spell.ID;
  92.                                             spellUse.SpellLevel = spell.Level;
  93.                                             spellUse.X = Clone.X;
  94.                                             spellUse.Y = Clone.Y;
  95.                                             spellUse.Effect1 = attack.Effect1;
  96.                                             spellUse.Effect2 = attack.Effect2;
  97.                                             spellUse.AddTarget(attackedsob.UID, damage, attack);
  98.                                             Game.Attacking.Handle.ReceiveAttack(Clone, attackedsob, attack, damage, spell);
  99.                                             client.SendScreen(spellUse, true);
  100.                                             client.SendScreen(attack, true);
  101.                                         }
  102.  
  103.                                     }
  104.                                 }
  105.                             }
  106.                             #endregion
  107.                         }
  108.  
  109.  
  110.  
  111.                         break;
  112.                     }
  113.                 #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement