Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void attackNpc()
- {
- try
- {
- if (!checkNpcCombatStatus())
- return;
- NPC npc = Server.s.npcHandler.npcs[attacknpc];
- int nType = npc.NpcType;
- int nX = npc.absX;
- int nY = npc.absY;
- boolean isUsingSpecial = false;
- useBow = false;
- useSpell = false;
- int wepId = playerEquipment[playerWeapon];
- int disNeeded = 1;
- 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)
- {
- useSpell = true;
- disNeeded = 7;
- }
- else
- if (wepId >= 800 && wepId <= 876 || wepId >= 4212 && wepId <= 4223 || wepId == 4734 || wepId == 6724 || wepId == 11235 || wepId == 9185 || wepId == 9174 || wepId == 6522 || wepId == 9183)
- {
- useBow = true;
- disNeeded = 7;
- }
- if (npc.size > 1)
- {
- if (absX < nX && absY > nY)
- {
- if (absY - nY > 1 && npc.size >= 3)
- disNeeded += (int)(npc.size);
- else
- disNeeded += (int)(npc.size / 2);
- }
- else if (absX > nX && absY > nY)
- {
- if (absY - nY > 1 && npc.size >= 3)
- disNeeded += (int)(npc.size);
- else
- disNeeded += (int)(npc.size / 2);
- }
- else if (absX > nX && absY <= nY)
- {
- if (absX - nX > 1 && npc.size >= 3)
- disNeeded += (int)(npc.size / 2);
- else
- disNeeded += (int)(npc.size / 2) - 1;
- }
- }
- if ((useBow || useSpell) && Misc.withinDistance(nX, nY, absX, absY, 7))
- {
- stopMovement();
- }
- if (Misc.withinDistance(nX, nY, absX, absY, disNeeded))
- {
- stopMovement();
- }
- if (Misc.withinDistance(nX, nY, absX, absY, 0)) {
- return;
- }
- if (meleeDelay <= 0)
- {
- int offsetX = (absX - nX) * -1;
- int offsetY = (absY - nY) * -1;
- inCombat = true;
- TurnPlayerTo(attacknpc);
- if (castingDamage)
- {
- castingDamage = false;
- UsingSpecial = true;
- }
- if (Misc.withinDistance(nX, nY, absX, absY, 8) && useBow && !useSpell)
- {
- if (npc.NpcType >= 239 && npc.NpcType <= 247)
- {
- getPA().sendMessage("You can only melee this monster!");
- resetAtk();
- return;
- }
- if (npc.NpcType == 1354)
- {
- getPA().sendMessage("You can only melee this monster!");
- resetAtk();
- return;
- }
- if (npc.NpcType == 1353)
- {
- getPA().sendMessage("You can only mage this monster!");
- resetAtk();
- return;
- }
- npc.combatWith = playerId;
- CheckArrows();
- if (!HasArrows)
- {
- getPA().sendMessage("You can't range like this!");
- resetAtk();
- return;
- }
- combatDelay = 30;
- calculateRange();
- damageHit = Misc.random(playerMaxHit);
- int speed = 60;
- if (!Misc.withinDistance(nX, nY, absX, absY, 1) && !(UsingSpecial && wepId == 805))
- {
- speed = 70;
- }
- if (wepId != 4214 && wepId != 4212)
- {
- if (Misc.random(100) >= 50)
- {
- if (ArrowSlot)
- {
- if (playerEquipment[playerArrows] > 0)
- {
- Server.s.itemHandler.NpcDropItem(playerEquipment[playerArrows], 1, nX, nY, playerId);
- }
- }
- else
- {
- if (wepId >= 800 && wepId <= 836 || wepId >= 863 && wepId <= 876)
- {
- Server.s.itemHandler.NpcDropItem(wepId, 1, nX, nY, playerId);
- }
- }
- }
- }
- else
- {
- calcCrystalBow();
- }
- DeleteArrow();
- if (!UsingSpecial)
- {
- startAnimation(GetWeaponAtkEmote(getItemName(wepId), skillId), 0);
- int Gfx = getRangeGfx(playerEquipment[playerArrows], wepId);
- if (wepId == 11235)
- {
- if (!HasSecondHit)
- {
- createProjectile(absY, absX, offsetY, offsetX, getRangePro(playerEquipment[playerArrows], wepId), 43, 31, speed, attacknpc+1);
- HasSecondHit = true;
- if (Gfx != -1)
- createPlayerGfx(Gfx, 0, 100);
- }
- else
- if (HasSecondHit)
- {
- createProjectile(absY, absX, offsetY, offsetX, getRangePro(playerEquipment[playerArrows], wepId), 53, 31, speed, attacknpc+1);
- HasSecondHit = false;
- }
- }
- if (wepId != 11235)
- {
- if (Gfx != -1)
- createPlayerGfx(Gfx, 0, 100);
- createProjectile(absY, absX, offsetY, offsetX, getRangePro(playerEquipment[playerArrows], wepId), 43, 31, speed, attacknpc+1);
- }
- }
- if (UsingSpecial && needsSpecBar(wepId) || UsingSpecial && HasSecondHit)
- {
- if (specialAmount >= SpecDrainAmount() || UsingSpecial && HasSecondHit)
- {
- isUsingSpecial = true;
- calculateRange();
- if (!Misc.withinDistance(nX, nY, absX, absY, 1) && (UsingSpecial && wepId == 11235))
- {
- speed = 80;
- }
- if (wepId == 11235)
- damageHit = Misc.random((playerMaxHit - 8)) + 8;
- else
- calcSpecialDamage();
- if (wepId == 861 || wepId == 859)
- createProjectile(absY, absX, offsetY, offsetX, 249, 43, 31, speed, attacknpc + 1);
- else
- if (wepId == 6724)
- createProjectile(absY, absX, offsetY, offsetX, 471, 43, 31, speed, attacknpc + 1);
- else
- if (wepId == 11235 && !HasSecondHit)
- createProjectile(absY, absX, offsetY, offsetX, 672, 43, 31, speed, attacknpc + 1);
- else
- if (wepId == 11235 && HasSecondHit)
- createProjectile(absY, absX, offsetY, offsetX, 672, 53, 31, speed, attacknpc + 1);
- else
- if (wepId == 805)
- {
- thrownaxeXIndex[0] = npc.absX;
- thrownaxeYIndex[0] = npc.absY;
- thrownaxeIndex[0] = attacknpc;
- axeSpecDelay = 2;
- createProjectile(absY, absX, offsetY, offsetX, 258, 43, 31, speed, attacknpc + 1);
- }
- if (CheckIfDoubleHitter())
- {
- if (!HasSecondHit)
- {
- StartSpecEmote(wepId);
- createPlayerGfx(ReturnPlayerSpecGfx(wepId), ReturnSpecDelay(), ReturnSpecHeight());
- createNpcGfx(ReturnOtherGfx(wepId), ReturnSpecOtherDelay(), attacknpc, ReturnSpecHeightOther());
- specialAmount -= SpecDrainAmount();
- HasSecondHit = true;
- firstSpecDone = false;
- }
- else
- if (HasSecondHit)
- HasSecondHit = false;
- }
- else
- {
- StartSpecEmote(wepId);
- createPlayerGfx(ReturnPlayerSpecGfx(wepId), ReturnSpecDelay(), ReturnSpecHeight());
- createNpcGfx(ReturnOtherGfx(wepId), ReturnSpecOtherDelay(), attacknpc, ReturnSpecHeightOther());
- specialAmount -= SpecDrainAmount();
- }
- }
- daggerBar();
- }
- if (playerEquipment[playerWeapon] == 9185 && playerEquipment[playerArrows] == 7989)
- {
- if (Misc.random(10) == 4)
- {
- boltEffect = 1;
- calculateRange();
- createNpcGfx(197, 0, attacknpc, 0);
- damageHit = Misc.random(playerMaxHit);
- if (damageHit < (playerMaxHit / 2))
- damageHit = Misc.random(playerMaxHit / 3) + Misc.random(playerMaxHit / 3) + Misc.random(playerMaxHit / 3);
- }
- }
- int myAtk = Misc.random(rangeAtk(isUsingSpecial));
- int nDef = Misc.random(npc.DefPower());
- int nHp = npc.CurrentHp;
- if (npc.DefType == 1)
- {
- nDef -= (nDef * 0.15);
- }
- if (myAtk < nDef)
- {
- if (isUsingSpecial && playerEquipment[playerWeapon] == 11235)
- damageHit = 8;
- else
- damageHit = 0;
- }
- if ((nHp - damageHit) <= 0)
- {
- damageHit = nHp;
- }
- applyPoisonNPC(-1, playerEquipment[playerArrows], attacknpc);
- for (int i = 0; i < 5; i++)
- {
- if (delayedDmgSlot[i] == 0)
- {
- delayedDmgSlot[i] = attacknpc;
- delayedDmgTarget[i] = 0;
- delayedDmgType[i] = 1;
- delayedDmgHit[i] = damageHit;
- if (Misc.withinDistance(nX, nY, absX, absY, 1))
- {
- delayedDmgTime[i] = 2;
- }
- else
- {
- delayedDmgTime[i] = 3;
- }
- break;
- }
- }
- if (HasSecondHit)
- meleeDelay = 0;
- else
- meleeDelay = getWeaponSpeed(wepId);
- if (HasSecondHit)
- attackNpc();
- }
- else if (useSpell)
- autoSpellOnNpc();
- else if (Misc.withinDistance(nX, nY, absX, absY, disNeeded) && !useBow && !useSpell)
- {
- if ( npc.NpcType == 1117
- || npc.NpcType == 1140
- || npc.NpcType == 1141
- || npc.NpcType == 1142
- || npc.NpcType == 1143
- || npc.NpcType == 1144
- || npc.NpcType == 1145 )
- {
- getPA().sendMessage("You can only range or mage this monster!");
- resetAtk();
- return;
- }
- if (npc.NpcType == 1355)
- {
- getPA().sendMessage("You can only range this monster!");
- resetAtk();
- return;
- }
- if (npc.NpcType == 1353)
- {
- getPA().sendMessage("You can only mage this monster!");
- resetAtk();
- return;
- }
- npc.combatWith = playerId;
- combatDelay = 30;
- calculateMelee();
- damageHit = Misc.random(playerMaxHit);
- if (!UsingSpecial)
- startAnimation(GetWeaponAtkEmote(getItemName(wepId), skillId), 0);
- else if (UsingSpecial && needsSpecBar(wepId) || UsingSpecial && HasSecondHit || wepId == 4153)
- {
- if (specialAmount >= SpecDrainAmount() || UsingSpecial && HasSecondHit)
- {
- isUsingSpecial = true;
- calcSpecialDamage();
- if (CheckIfDoubleHitter())
- {
- if (!HasSecondHit)
- {
- firstSpecDone = false;
- StartSpecEmote(wepId);
- createPlayerGfx(ReturnPlayerSpecGfx(wepId), ReturnSpecDelay(), ReturnSpecHeight());
- createNpcGfx(ReturnOtherGfx(wepId), ReturnSpecDelay(), attacknpc, ReturnSpecHeightOther());
- specialAmount -= SpecDrainAmount();
- HasSecondHit = true;
- }
- else
- if (HasSecondHit)
- {
- if (wepId == 11730)
- {
- damageHit = Misc.random(10) + 5;
- }
- HasSecondHit = false;
- }
- }
- else
- {
- StartSpecEmote(wepId);
- createPlayerGfx(ReturnPlayerSpecGfx(wepId), ReturnSpecDelay(), ReturnSpecHeight());
- createNpcGfx(ReturnOtherGfx(wepId), ReturnSpecDelay(), attacknpc, ReturnSpecHeightOther());
- if (wepId != 4153)
- specialAmount -= SpecDrainAmount();
- }
- }
- }
- int myAtk = Misc.random(meleeAtk(isUsingSpecial));
- int nDef = Misc.random(npc.DefPower());
- int nHp = npc.CurrentHp;
- if (npc.DefType == 0)
- {
- nDef -= (nDef * 0.15);
- }
- if (myAtk <= nDef)
- {
- if (!FullVeracEquipped())
- damageHit = 0;
- else
- if (Misc.random(6) != 0)
- damageHit = 0;
- }
- if ((nHp - damageHit) <= 0)
- damageHit = nHp;
- if (FullGuthanEquipped())
- {
- if (Misc.random(6) >= 4)
- {
- updateHp(damageHit, true);
- getPA().sendMessage("You drain the enemies health!");
- createNpcGfx(398, 0, attacknpc, 100);
- }
- }
- if (isUsingSpecial && playerEquipment[playerWeapon] == 11698){
- updateHp(damageHit, true);
- }
- if (isUsingSpecial && playerEquipment[playerWeapon] == 11700){
- npc.EntangleDelay = 20;
- }
- applyPoisonNPC(playerEquipment[playerWeapon], -1, attacknpc);
- for (int i = 0; i < 5; i++)
- {
- if (delayedDmgSlot[i] == 0)
- {
- delayedDmgSlot[i] = attacknpc;
- delayedDmgTarget[i] = 0;
- delayedDmgType[i] = 0;
- delayedDmgHit[i] = damageHit;
- delayedDmgTime[i] = 1;
- break;
- }
- }
- if (HasSecondHit)
- {
- meleeDelay = 0;
- attackNpc();
- }
- else
- meleeDelay = getWeaponSpeed(wepId);
- }
- }
- }
- catch(Exception e)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement