Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean AttackNPC() {
- int EnemyX = server.npcHandler.npcs[attacknpc].absX;
- int EnemyY = server.npcHandler.npcs[attacknpc].absY;
- int EnemyHP = server.npcHandler.npcs[attacknpc].HP;
- int hitDiff = 0;
- if (EnemyHP < 1) {
- sendMessage("You can't attack that monster!");
- return false;
- }
- int type = server.npcHandler.npcs[attacknpc].npcType;
- int[] staffs = { 2415, 2416, 2417 };
- int[] arrowIds = { 882, 884, 886, 888, 890, 892 };
- int[] arrowGfx = { 10, 9, 11, 12, 13, 15 };
- int[] prem = { 1643, 158, 49, 1613 };
- for (int element : prem) {
- if ((element == type) && !premium) {
- resetPos();
- return false;
- }
- }
- if (type == 1125) {
- if (combatLevel < 70) {
- sendMessage("You must be level 70 or higher to attack Dad");
- ResetAttackNPC();
- return false;
- }
- }
- if ((type == 110) || (type == 936)) {
- if (!playerHasItem(1543)) {
- resetPos();
- ResetAttackNPC();
- return false;
- }
- }
- if ((type == 221) || (type == 1961)) {
- if (!playerHasItem(1544)) {
- resetPos();
- ResetAttackNPC();
- return false;
- }
- }
- if (((type == 941) || (type == 55)) && !premium) {
- resetPos();
- return false;
- }
- for (int element : staffs) {
- if ((playerEquipment[playerWeapon] == element)
- && (autocast_spellIndex >= 0)) {
- if (System.currentTimeMillis() - lastAttack < coolDown[coolDownGroup[autocast_spellIndex]]) {
- return false;
- }
- inCombat = true;
- lastCombat = System.currentTimeMillis();
- lastAttack = System.currentTimeMillis();
- if (playerLevel[6] >= requiredLevel[autocast_spellIndex]) {
- int roll = misc.random(100);
- int hit = misc.random(baseDamage[autocast_spellIndex]
- + playerBonus[11]);
- hitDiff = hit;
- setAnimation(1979);
- updateRequired = true;
- // AnimationReset = true;
- // teleportToX = absX;
- // teleportToY = absY;
- resetWalkingQueue();
- if (ancientType[autocast_spellIndex] == 3) {
- // coolDown[coolDownGroup[autocast_spellIndex]] = 35;
- server.npcHandler.npcs[attacknpc].effects[0] = 15;
- stillgfx(369, EnemyY, EnemyX);
- } else if (ancientType[autocast_spellIndex] == 2) {
- stillgfx(377, EnemyY, EnemyX);
- // coolDown[coolDownGroup[autocast_spellIndex]] = 12;
- currentHealth += (int) (hit / 2);
- if (currentHealth > playerLevel[playerHitpoints])
- currentHealth = playerLevel[playerHitpoints];
- } else
- animation(78, EnemyY, EnemyX);
- } else {
- sendMessage("You need a magic level of "
- + requiredLevel[autocast_spellIndex]);
- }
- // coolDown[coolDownGroup[autocast_spellIndex]] = 12;
- TurnPlayerTo(EnemyX, EnemyY);
- addSkillXP(90 * hitDiff, playerMagic);
- addSkillXP(hitDiff * CombatExpRate, playerHitpoints);
- teleportToX = absX;
- teleportToY = absY;
- server.npcHandler.npcs[attacknpc].StartKilling = localId;
- server.npcHandler.npcs[attacknpc].RandomWalk = false;
- server.npcHandler.npcs[attacknpc].IsUnderAttack = true;
- server.npcHandler.npcs[attacknpc].hitDiff = hitDiff;
- server.npcHandler.npcs[attacknpc].Killing[playerId] += hitDiff;
- server.npcHandler.npcs[attacknpc].updateRequired = true;
- server.npcHandler.npcs[attacknpc].hitUpdateRequired = true;
- server.npcHandler.npcs[attacknpc].hit = true;
- faceNPC(attacknpc);
- updateRequired = true;
- appearanceUpdateRequired = true;
- // server.npcHandler.npcs[attacknpc].TurnNPCTo(absX,absY);
- // server.npcHandler.npcs[attacknpc].FocusUpdateRequired = true;
- return true;
- }
- }
- long thisTime = System.currentTimeMillis();
- if(GetWepAnim(playerEquipment[playerWeapon]) < 0){
- sendMessage("Use another attack style to attack!");
- return false;
- }
- if (thisTime - lastAttack >= getbattleTimer(playerEquipment[playerWeapon])) {
- setAnimation(GetWepAnim(playerEquipment[playerWeapon]));
- hitDiff = misc.random(playerMaxHit);
- if(AttackType == 1 && (misc.randomd(playerLevel[0]+(playerBonus[0]*.515)) >= misc.randomd(server.npcHandler.GetNPCDefence(type)+(server.npcHandler.StabDef[type]*.515)))){
- hitDiff = hitDiff;
- } else if(AttackType == 2 && (misc.randomd(playerLevel[0]+(playerBonus[1]*.515)) >= misc.randomd(server.npcHandler.GetNPCDefence(type)+(server.npcHandler.SlashDef[type]*.515)))){
- hitDiff = hitDiff;
- } else if(AttackType == 3 && (misc.randomd(playerLevel[0]+(playerBonus[2]*.515)) >= misc.randomd(server.npcHandler.GetNPCDefence(type)+(server.npcHandler.CrushDef[type]*.515)))){
- hitDiff = hitDiff;
- } else {
- hitDiff = 0;
- }
- }
- if (server.npcHandler.npcs[attacknpc].npcType == 5 && AttackType != 1) {
- hitDiff = (int)(hitDiff * .5);
- } else {
- hitDiff = hitDiff;
- }
- /*if(playerEquipment[playerWeapon] == 5698){
- server.npcHandler.npcs[attacknpc].poisonTimer = 120;
- server.npcHandler.npcs[attacknpc].poisonDmg = true;
- server.npcHandler.poisonNpc(type);
- PoisonDamage(6.8);
- }*/
- if(hitDiff >= 20){
- hitDiff = hitDiff*(100-server.npcHandler.AbMel[type])/100;
- }
- boolean UseBow = false;
- for (int i = 0; i < shortbow.length; i++) {
- if ((playerEquipment[playerWeapon] == shortbow[i])
- || (playerEquipment[playerWeapon] == longbow[i])) {
- UseBow = true;
- break;
- }
- }
- int arrowgfx = 10;
- for (int i1 = 0; i1 < arrowIds.length; i1++) {
- if (playerEquipment[playerArrows] == arrowIds[i1]) {
- arrowgfx = arrowGfx[i1];
- }
- }
- if (thisTime - lastAttack >= getbattleTimer(playerEquipment[playerWeapon]) && UseBow == true) {
- teleportToX = absX;
- teleportToY = absY;
- CalculateRange();
- hitDiff = misc.random(CalculateRange());
- if (DeleteArrow()) {
- int offsetX = (absY - EnemyY) * -1;
- int offsetY = (absX - EnemyX) * -1;
- for (int a = 0; a < handler.maxPlayers; a++) {
- client temp = (client) handler.players[a];
- if ((temp != null) && (temp.absX > 0) && !temp.disconnected
- && (Math.abs(absX - temp.absX) < 60)
- && (Math.abs(absY - temp.absY) < 60)) {
- temp.createProjectile(absY, absX, offsetY, offsetX, 50,
- 90, arrowgfx, 43, 35, attacknpc + 1);
- }
- }
- server.npcHandler.npcs[attacknpc].hitDiff = hitDiff;
- server.npcHandler.npcs[attacknpc].Killing[playerId] += hitDiff;
- server.npcHandler.npcs[attacknpc].updateRequired = true;
- server.npcHandler.npcs[attacknpc].hitUpdateRequired = true;
- server.npcHandler.npcs[attacknpc].hit = true;
- if ((hitDiff == 0)
- && (server.npcHandler.npcs[attacknpc].npcType == 941)) {
- server.npcHandler.npcs[attacknpc].animNumber = 89;
- server.npcHandler.npcs[attacknpc].animUpdateRequired = true;
- server.npcHandler.npcs[attacknpc].updateRequired = true;
- }
- updateRequired = true;
- appearanceUpdateRequired = true;
- } else {
- ResetAttackNPC();
- sendMessage("You're out of arrows!");
- return false;
- }
- }
- if (thisTime - lastAttack >= getbattleTimer(playerEquipment[playerWeapon])) {
- inCombat = true;
- lastCombat = System.currentTimeMillis();
- } else {
- return false;
- }
- if (UseBow || (GoodDistance(EnemyX, EnemyY, absX, absY, 1) == true)) {
- walkTo_old(absX, absY);
- if (server.npcHandler.npcs[attacknpc].IsDead == true) {
- ResetAttackNPC();
- } else {
- TurnPlayerTo(EnemyX, EnemyY);
- updateRequired = true;
- appearanceUpdateRequired = true;
- actionAmount++;
- setAnimation(playerSEA);
- if ((EnemyHP - hitDiff) < 0) {
- hitDiff = EnemyHP;
- }
- server.npcHandler.npcs[attacknpc].StartKilling = playerId;
- server.npcHandler.npcs[attacknpc].hitDiff = hitDiff;
- server.npcHandler.npcs[attacknpc].Killing[playerId] += hitDiff;
- server.npcHandler.npcs[attacknpc].updateRequired = true;
- server.npcHandler.npcs[attacknpc].hitUpdateRequired = true;
- server.npcHandler.npcs[attacknpc].hit = true;
- attackedNpc = true;
- attackedNpcId = attacknpc;
- double TotalExp = 0;
- if (!UseBow)
- animationReset = System.currentTimeMillis() + 1200;
- if (server.npcHandler.npcs[attacknpc].npcType != 2745){
- server.npcHandler.npcs[attacknpc].animNumber = server.npcHandler.GetNPCBlockAnim(type);
- server.npcHandler.npcs[attacknpc].animUpdateRequired = true;
- if (UseBow) {
- TotalExp = (double) (60 * hitDiff); // added *2 for
- // faster
- // leveling
- // -bakatool
- TotalExp = (double) (TotalExp * CombatExpRate);
- addSkillXP((int) (TotalExp), 4);
- } else if (FightType != 3) {
- TotalExp = (double) (60 * hitDiff); // added *2 for
- // faster
- // leveling
- // -bakatool
- TotalExp = (double) (TotalExp * CombatExpRate);
- addSkillXP((int) (TotalExp), SkillID);
- } else {
- TotalExp = (double) (20 * hitDiff); // added *2 for
- // faster
- // leveling
- // -bakatool2
- TotalExp = (double) (TotalExp * CombatExpRate);
- addSkillXP((int) (TotalExp), playerAttack);
- addSkillXP((int) (TotalExp), playerDefence);
- addSkillXP((int) (TotalExp), playerStrength);
- }
- TotalExp = (double) (20 * hitDiff * 2); // added *2 for
- // faster leveling
- // -bakatool
- TotalExp = (double) (TotalExp * CombatExpRate);
- addSkillXP((int) (TotalExp), playerHitpoints);
- attackTimer = 7;
- if (debug)
- sendMessage("hitDiff=" + hitDiff + ", elapsed="
- + (thisTime - lastAttack));
- lastAttack = System.currentTimeMillis();
- }
- return true;
- }
- }
- if(server.npcHandler.npcs[attacknpc].IsUnderAttack == false){
- walkTo_old(absX, absY);
- setAnimation(GetStandAnim(playerEquipment[playerWeapon]));
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement