Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 11.35 KB | None | 0 0
  1.  
  2.     public void attackNpc()
  3.     {
  4.         try
  5.         {
  6.             if (!checkNpcCombatStatus())
  7.                 return;
  8.             NPC npc = Server.s.npcHandler.npcs[attacknpc];
  9.             int nType = npc.NpcType;
  10.             int nX = npc.absX;
  11.             int nY = npc.absY;
  12.             boolean isUsingSpecial = false;
  13.             useBow = false;
  14.             useSpell = false;
  15.             int wepId = playerEquipment[playerWeapon];
  16.             int disNeeded = 1;
  17.             if ((wepId >= 1379 && wepId <= 1409 || wepId >= 2415 && wepId <= 2417 || wepId >= 3053 && wepId <= 3056 || wepId == 4170 || wepId == 4675 || wepId == 9084 || wepId == 4710 || wepId == 6526 || wepId == 6563 || wepId == 6726) && spellCastedId > 0)
  18.             {
  19.                 useSpell = true;
  20.                 disNeeded = 7;
  21.             }
  22.             else
  23.             if (wepId >= 800 && wepId <= 876 || wepId >= 4212 && wepId <= 4223 || wepId == 4734 || wepId == 6724 || wepId == 11235 || wepId == 9185 || wepId == 9174 || wepId == 6522 || wepId == 9183)
  24.             {
  25.                 useBow = true;
  26.                 disNeeded = 7;
  27.             }
  28.             if (npc.size > 1)
  29.             {
  30.                 if (absX < nX && absY > nY)
  31.                 {
  32.                     if (absY - nY > 1 && npc.size >= 3)
  33.                         disNeeded += (int)(npc.size);
  34.                     else
  35.                         disNeeded += (int)(npc.size / 2);
  36.                 }
  37.                 else if (absX > nX && absY > nY)
  38.                 {
  39.                     if (absY - nY > 1 && npc.size >= 3)
  40.                         disNeeded += (int)(npc.size);
  41.                     else
  42.                         disNeeded += (int)(npc.size / 2);
  43.                 }
  44.                 else if (absX > nX && absY <= nY)
  45.                 {
  46.                     if (absX - nX > 1 && npc.size >= 3)
  47.                         disNeeded += (int)(npc.size / 2);
  48.                     else
  49.                         disNeeded += (int)(npc.size / 2) - 1;
  50.                 }
  51.             }
  52.             if ((useBow || useSpell) && Misc.withinDistance(nX, nY, absX, absY, 7))
  53.             {
  54.                 stopMovement();
  55.             }
  56.             if (Misc.withinDistance(nX, nY, absX, absY, disNeeded))
  57.             {
  58.                 stopMovement();
  59.             }
  60.             if (Misc.withinDistance(nX, nY, absX, absY, 0)) {
  61.                 return;
  62.             }
  63.             if (meleeDelay <= 0)
  64.             {
  65.                 int offsetX = (absX - nX) * -1;
  66.                 int offsetY = (absY - nY) * -1;
  67.                 inCombat = true;
  68.                 TurnPlayerTo(attacknpc);
  69.                 if (castingDamage)
  70.                 {
  71.                     castingDamage = false;
  72.                     UsingSpecial = true;
  73.                 }
  74.                 if (Misc.withinDistance(nX, nY, absX, absY, 8) && useBow && !useSpell)
  75.                 {
  76.                     if (npc.NpcType >= 239 && npc.NpcType <= 247)
  77.                     {
  78.                         getPA().sendMessage("You can only melee this monster!");
  79.                         resetAtk();
  80.                         return;
  81.                     }
  82.                     if (npc.NpcType == 1354)
  83.                     {
  84.                         getPA().sendMessage("You can only melee this monster!");
  85.                         resetAtk();
  86.                         return;
  87.                     }
  88.                     if (npc.NpcType == 1353)
  89.                     {
  90.                         getPA().sendMessage("You can only mage this monster!");
  91.                         resetAtk();
  92.                         return;
  93.                     }
  94.                     npc.combatWith = playerId;
  95.                     CheckArrows();
  96.                     if (!HasArrows)
  97.                     {
  98.                         getPA().sendMessage("You can't range like this!");
  99.                         resetAtk();
  100.                         return;
  101.                     }
  102.                     combatDelay = 30;
  103.                     calculateRange();
  104.                     damageHit = Misc.random(playerMaxHit);
  105.                     int speed = 60;
  106.                     if (!Misc.withinDistance(nX, nY, absX, absY, 1) && !(UsingSpecial && wepId == 805))
  107.                     {
  108.                         speed = 70;
  109.                     }
  110.                     if (wepId != 4214 && wepId != 4212)
  111.                     {
  112.                         if (Misc.random(100) >= 50)
  113.                         {
  114.  
  115.                             if (ArrowSlot)
  116.                             {
  117.                                 if (playerEquipment[playerArrows] > 0)
  118.                                 {
  119.                                     Server.s.itemHandler.NpcDropItem(playerEquipment[playerArrows], 1, nX, nY, playerId);
  120.                                 }
  121.                             }
  122.                             else
  123.                             {
  124.                                 if (wepId >= 800 && wepId <= 836 || wepId >= 863 && wepId <= 876)
  125.                                 {
  126.                                     Server.s.itemHandler.NpcDropItem(wepId, 1, nX, nY, playerId);
  127.                                 }
  128.  
  129.                             }
  130.                         }
  131.                     }
  132.                     else
  133.                     {
  134.                         calcCrystalBow();
  135.                     }
  136.                     DeleteArrow();
  137.                     if (!UsingSpecial)
  138.                     {
  139.                         startAnimation(GetWeaponAtkEmote(getItemName(wepId), skillId), 0);
  140.                         int Gfx = getRangeGfx(playerEquipment[playerArrows], wepId);
  141.                         if (wepId == 11235)
  142.                         {
  143.                             if (!HasSecondHit)
  144.                             {
  145.                                 createProjectile(absY, absX, offsetY, offsetX, getRangePro(playerEquipment[playerArrows], wepId), 43, 31, speed, attacknpc+1);
  146.                                 HasSecondHit = true;
  147.                                 if (Gfx != -1)
  148.                                     createPlayerGfx(Gfx, 0, 100);
  149.                             }
  150.                             else
  151.                             if (HasSecondHit)
  152.                             {
  153.                                 createProjectile(absY, absX, offsetY, offsetX, getRangePro(playerEquipment[playerArrows], wepId), 53, 31, speed, attacknpc+1);
  154.                                 HasSecondHit = false;
  155.                             }
  156.                         }
  157.                         if (wepId != 11235)
  158.                         {
  159.                             if (Gfx != -1)
  160.                                 createPlayerGfx(Gfx, 0, 100);
  161.                             createProjectile(absY, absX, offsetY, offsetX, getRangePro(playerEquipment[playerArrows], wepId), 43, 31, speed, attacknpc+1);
  162.                         }
  163.                     }
  164.                     if (UsingSpecial && needsSpecBar(wepId) || UsingSpecial && HasSecondHit)
  165.                     {
  166.                         if (specialAmount >= SpecDrainAmount() || UsingSpecial && HasSecondHit)
  167.                         {
  168.                             isUsingSpecial = true;
  169.                             calculateRange();
  170.                             if (!Misc.withinDistance(nX, nY, absX, absY, 1) && (UsingSpecial && wepId == 11235))
  171.                             {
  172.                                 speed = 80;
  173.                             }
  174.                             if (wepId == 11235)
  175.                                 damageHit = Misc.random((playerMaxHit - 8)) + 8;
  176.                             else
  177.                                 calcSpecialDamage();
  178.                             if (wepId == 861 || wepId == 859)
  179.                                 createProjectile(absY, absX, offsetY, offsetX, 249, 43, 31, speed, attacknpc + 1);
  180.                             else
  181.                             if (wepId == 6724)
  182.                                 createProjectile(absY, absX, offsetY, offsetX, 471, 43, 31, speed, attacknpc + 1);
  183.                             else
  184.                             if (wepId == 11235 && !HasSecondHit)
  185.                                 createProjectile(absY, absX, offsetY, offsetX, 672, 43, 31, speed, attacknpc + 1);
  186.                             else
  187.                             if (wepId == 11235 && HasSecondHit)
  188.                                 createProjectile(absY, absX, offsetY, offsetX, 672, 53, 31, speed, attacknpc + 1);
  189.                             else
  190.                             if (wepId == 805)
  191.                             {
  192.                                 thrownaxeXIndex[0] = npc.absX;
  193.                                 thrownaxeYIndex[0] = npc.absY;
  194.                                 thrownaxeIndex[0] = attacknpc;
  195.                                 axeSpecDelay = 2;
  196.                                 createProjectile(absY, absX, offsetY, offsetX, 258, 43, 31, speed, attacknpc + 1);
  197.                             }
  198.                             if (CheckIfDoubleHitter())
  199.                             {
  200.                                 if (!HasSecondHit)
  201.                                 {
  202.                                     StartSpecEmote(wepId);
  203.                                     createPlayerGfx(ReturnPlayerSpecGfx(wepId), ReturnSpecDelay(), ReturnSpecHeight());
  204.                                     createNpcGfx(ReturnOtherGfx(wepId), ReturnSpecOtherDelay(), attacknpc, ReturnSpecHeightOther());
  205.                                     specialAmount -= SpecDrainAmount();
  206.                                     HasSecondHit = true;
  207.                                     firstSpecDone = false;
  208.                                 }
  209.                                 else
  210.                                 if (HasSecondHit)
  211.                                     HasSecondHit = false;
  212.                             }
  213.                             else
  214.                             {
  215.                                 StartSpecEmote(wepId);
  216.                                 createPlayerGfx(ReturnPlayerSpecGfx(wepId), ReturnSpecDelay(), ReturnSpecHeight());
  217.                                 createNpcGfx(ReturnOtherGfx(wepId), ReturnSpecOtherDelay(), attacknpc, ReturnSpecHeightOther());
  218.                                 specialAmount -= SpecDrainAmount();
  219.                             }
  220.                         }
  221.                         daggerBar();
  222.                     }
  223.                     if (playerEquipment[playerWeapon] == 9185 && playerEquipment[playerArrows] == 7989)
  224.                     {
  225.                         if (Misc.random(10) == 4)
  226.                         {
  227.                             boltEffect = 1;
  228.                             calculateRange();
  229.                             createNpcGfx(197, 0, attacknpc, 0);
  230.                             damageHit = Misc.random(playerMaxHit);
  231.                             if (damageHit < (playerMaxHit / 2))
  232.                                 damageHit = Misc.random(playerMaxHit / 3) + Misc.random(playerMaxHit / 3) + Misc.random(playerMaxHit / 3);
  233.                         }
  234.                     }
  235.                     int myAtk = Misc.random(rangeAtk(isUsingSpecial));
  236.                     int nDef = Misc.random(npc.DefPower());
  237.                     int nHp = npc.CurrentHp;
  238.                     if (npc.DefType == 1)
  239.                     {
  240.                         nDef -= (nDef * 0.15);
  241.                     }
  242.                     if (myAtk < nDef)
  243.                     {
  244.                         if (isUsingSpecial && playerEquipment[playerWeapon] == 11235)
  245.                             damageHit = 8;
  246.                         else
  247.                             damageHit = 0;
  248.                     }
  249.                     if ((nHp - damageHit) <= 0)
  250.                     {
  251.                         damageHit = nHp;
  252.                     }
  253.                     applyPoisonNPC(-1, playerEquipment[playerArrows], attacknpc);
  254.                     for (int i = 0; i < 5; i++)
  255.                     {
  256.                         if (delayedDmgSlot[i] == 0)
  257.                         {
  258.                             delayedDmgSlot[i] = attacknpc;
  259.                             delayedDmgTarget[i] = 0;
  260.                             delayedDmgType[i] = 1;
  261.                             delayedDmgHit[i] = damageHit;
  262.                             if (Misc.withinDistance(nX, nY, absX, absY, 1))
  263.                             {
  264.                                 delayedDmgTime[i] = 2;
  265.                             }
  266.                             else
  267.                             {
  268.                                 delayedDmgTime[i] = 3;
  269.                             }
  270.                             break;
  271.                         }
  272.                             }
  273.                     if (HasSecondHit)
  274.                         meleeDelay = 0;
  275.                     else
  276.                         meleeDelay = getWeaponSpeed(wepId);
  277.                     if (HasSecondHit)
  278.                         attackNpc();
  279.                 }
  280.                 else if (useSpell)
  281.                     autoSpellOnNpc();
  282.                 else if (Misc.withinDistance(nX, nY, absX, absY, disNeeded) && !useBow && !useSpell)
  283.                 {
  284.                     if ( npc.NpcType == 1117
  285.                         || npc.NpcType == 1140
  286.                         || npc.NpcType == 1141
  287.                         || npc.NpcType == 1142
  288.                         || npc.NpcType == 1143
  289.                         || npc.NpcType == 1144
  290.                         || npc.NpcType == 1145 )
  291.                     {
  292.                         getPA().sendMessage("You can only range or mage this monster!");
  293.                         resetAtk();
  294.                         return;
  295.                     }
  296.                     if (npc.NpcType == 1355)
  297.                     {
  298.                         getPA().sendMessage("You can only range this monster!");
  299.                         resetAtk();
  300.                         return;
  301.                     }
  302.                     if (npc.NpcType == 1353)
  303.                     {
  304.                         getPA().sendMessage("You can only mage this monster!");
  305.                         resetAtk();
  306.                         return;
  307.                     }
  308.                     npc.combatWith = playerId;
  309.                     combatDelay = 30;
  310.                     calculateMelee();
  311.                     damageHit = Misc.random(playerMaxHit);
  312.                     if (!UsingSpecial)
  313.                         startAnimation(GetWeaponAtkEmote(getItemName(wepId), skillId), 0);
  314.                     else if (UsingSpecial && needsSpecBar(wepId) || UsingSpecial && HasSecondHit || wepId == 4153)
  315.                     {
  316.                         if (specialAmount >= SpecDrainAmount() || UsingSpecial && HasSecondHit)
  317.                         {
  318.                             isUsingSpecial = true;
  319.                             calcSpecialDamage();
  320.                             if (CheckIfDoubleHitter())
  321.                             {
  322.                                 if (!HasSecondHit)
  323.                                 {
  324.                                     firstSpecDone = false;
  325.                                     StartSpecEmote(wepId);
  326.                                     createPlayerGfx(ReturnPlayerSpecGfx(wepId), ReturnSpecDelay(), ReturnSpecHeight());
  327.                                     createNpcGfx(ReturnOtherGfx(wepId), ReturnSpecDelay(), attacknpc, ReturnSpecHeightOther());
  328.                                     specialAmount -= SpecDrainAmount();
  329.                                     HasSecondHit = true;
  330.                                 }
  331.                                 else
  332.                                 if (HasSecondHit)
  333.                                 {
  334.                                     if (wepId == 11730)
  335.                                     {
  336.                                         damageHit = Misc.random(10) + 5;
  337.                                     }
  338.                                     HasSecondHit = false;
  339.                                 }
  340.                             }
  341.                             else
  342.                             {
  343.                                 StartSpecEmote(wepId);
  344.                                 createPlayerGfx(ReturnPlayerSpecGfx(wepId), ReturnSpecDelay(), ReturnSpecHeight());
  345.                                 createNpcGfx(ReturnOtherGfx(wepId), ReturnSpecDelay(), attacknpc, ReturnSpecHeightOther());
  346.                                 if (wepId != 4153)
  347.                                     specialAmount -= SpecDrainAmount();
  348.                             }
  349.                         }
  350.                     }
  351.                     int myAtk = Misc.random(meleeAtk(isUsingSpecial));
  352.                     int nDef = Misc.random(npc.DefPower());
  353.                     int nHp = npc.CurrentHp;
  354.                     if (npc.DefType == 0)
  355.                     {
  356.                         nDef -= (nDef * 0.15);
  357.                     }
  358.                     if (myAtk <= nDef)
  359.                     {
  360.                         if (!FullVeracEquipped())
  361.                             damageHit = 0;
  362.                         else
  363.                         if (Misc.random(6) != 0)
  364.                             damageHit = 0;
  365.                     }
  366.                     if ((nHp - damageHit) <= 0)
  367.                         damageHit = nHp;
  368.                     if (FullGuthanEquipped())
  369.                     {
  370.                         if (Misc.random(6) >= 4)
  371.                         {
  372.                             updateHp(damageHit, true);
  373.                             getPA().sendMessage("You drain the enemies health!");
  374.                             createNpcGfx(398, 0, attacknpc, 100);
  375.                         }
  376.                     }
  377.                     if (isUsingSpecial && playerEquipment[playerWeapon] == 11698){
  378.                         updateHp(damageHit, true);
  379.                     }
  380.                     if (isUsingSpecial && playerEquipment[playerWeapon] == 11700){
  381.                         npc.EntangleDelay = 20;
  382.                     }
  383.                     applyPoisonNPC(playerEquipment[playerWeapon], -1, attacknpc);
  384.                     for (int i = 0; i < 5; i++)
  385.                     {
  386.                         if (delayedDmgSlot[i] == 0)
  387.                         {
  388.                             delayedDmgSlot[i] = attacknpc;
  389.                             delayedDmgTarget[i] = 0;
  390.                             delayedDmgType[i] = 0;
  391.                             delayedDmgHit[i] = damageHit;
  392.                             delayedDmgTime[i] = 1;
  393.                             break;
  394.                         }
  395.                             }
  396.                     if (HasSecondHit)
  397.                     {
  398.                         meleeDelay = 0;
  399.                         attackNpc();
  400.                     }
  401.                     else
  402.                         meleeDelay = getWeaponSpeed(wepId);
  403.                 }
  404.             }
  405.         }
  406.         catch(Exception e)
  407.         {
  408.         }
  409.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement