Search the Community
Showing results for tags 'switch'.
Found 16 results
-
So my source is a bit different in its class system. It is separated into many sub classes. So i need to add a chaos alter in order to switch the prayers from regular to curses and back. I have the case implemented into my action handler and I seem to be getting these two errors. Here is the code. Only 2 errors Fixed Code: [CODE] case 411: if (c.getFields().getPrayerBook() == PrayerBook.NORMAL) { c.getFields().setPrayerBook(PrayerBook.CURSES); c.setSidebarInterface(5, PrayerBook.CURSES.getInterfaceId()); c.getCombat.resetPrayers(); c.sendMessage("Prayers Switched to Curses"); } else if (c.getFields().getPrayerBook() == PrayerBook.CURSES) { c.setSidebarInterface(5, PrayerBook.NORMAL.getInterfaceId()); c.getFields().setPrayerBook(PrayerBook.NORMAL); c.getPA().resetCurse(); c.sendMessage("Back to regular prayers"); } break; [/CODE] Errors: [CODE] src\org\pandemonium\game\entity\ActionHandler.java:78: error: cannot find symbol c.getCombat.resetPrayers(); ^ symbol: variable getCombat location: variable c of type Player src\org\pandemonium\game\entity\ActionHandler.java:83: error: cannot find symbol c.getPA().resetCurse(); ^ symbol: method resetCurse() location: class PlayerAssistant 2 errors Press any key to continue . . . [/CODE] So i looked at a few other previous other sources and it works because the resetCurse and resetPrayer are in PlayerAssistant and CombatAssistant. Mine are located here and i don't know how to call them in actionhandler nor can I transfer them to PA or CA. I can import those classes but I still don't know how. CombatPrayer.Java [CODE] package org.pandemonium.game.content.combat.prayer; import org.pandemonium.game.GameConstants; import org.pandemonium.game.entity.player.Player; /** * Handles combat prayers */ public class CombatPrayer extends PrayerData { public static void handlePrayerDrain(Player p) { p.usingPrayer = false; double toRemove = 0.0; for (int j = 0; j < prayerData.length; j++) { if (p.prayerActive[j]) { toRemove += prayerData[j] / 20; p.usingPrayer = true; } } for (int j = 0; j < PrayerData.curseData.length; j++) { if (p.curseActive[j]) { toRemove += PrayerData.curseData[j] / 20; p.usingPrayer = true; } } if (toRemove > 0) toRemove /= (1 + (0.035 * p.playerBonus[11])); p.prayerPoint -= toRemove; if (p.prayerPoint <= 0) { p.prayerPoint = 1.0 + p.prayerPoint; reducePrayerLevel(p); } } public static void reducePrayerLevel(Player p) { if (p.playerLevel[5] - 1 > 0) { p.playerLevel[5] -= 1; } else { p.sendMessage("You have run out of prayer points!"); p.playerLevel[5] = 0; Curses.resetCurse(p); resetPrayers(p); p.prayerId = -1; } p.getPA().refreshSkill(5); } public static void resetGlow(Player p, RegularPrayers pray) { p.getPA().sendFrame36(pray.getGlowId(), 0); p.prayerActive[pray.ordinal()] = false; } [COLOR="#FF0000"] public static void resetPrayers(Player p) { for (RegularPrayers r : RegularPrayers.values()) { p.prayerActive[r.ordinal()] = false; p.getPA().sendFrame36(r.getGlowId(), 0); } p.headIcon = -1; p.getPA().requestUpdates(); }[/COLOR] public static boolean CombatPrayers(RegularPrayers pray) { if (pray == RegularPrayers.RAPID_RESTORE || pray == RegularPrayers.RAPID_HEAL || pray == RegularPrayers.PROTECT_ITEM || pray == RegularPrayers.RETRIBUTION || pray == RegularPrayers.REDEMPTION || pray == RegularPrayers.SMITE) return true; return false; } public static void resetOtherPrayers(Player p, RegularPrayers pray) { switch (pray) { case THICK_SKIN: resetGlow(p, RegularPrayers.ROCK_SKIN); resetGlow(p, RegularPrayers.STEEL_SKIN); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case BURST_OF_STRENGTH: resetGlow(p, RegularPrayers.SUPERHUMAN_STRENGTH); resetGlow(p, RegularPrayers.ULTIMATE_STRENGTH); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case CLARITY_OF_THOUGHT: resetGlow(p, RegularPrayers.IMPROVED_REFLEXES); resetGlow(p, RegularPrayers.INCREDIBLE_REFLEXES); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case SHARP_EYE: resetGlow(p, RegularPrayers.HAWK_EYE); resetGlow(p, RegularPrayers.EAGLE_EYE); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case MYSTIC_WILL: resetGlow(p, RegularPrayers.MYSTIC_LORE); resetGlow(p, RegularPrayers.MYSTIC_MIGHT); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case ROCK_SKIN: resetGlow(p, RegularPrayers.THICK_SKIN); resetGlow(p, RegularPrayers.STEEL_SKIN); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case SUPERHUMAN_STRENGTH: resetGlow(p, RegularPrayers.BURST_OF_STRENGTH); resetGlow(p, RegularPrayers.ULTIMATE_STRENGTH); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case IMPROVED_REFLEXES: resetGlow(p, RegularPrayers.CLARITY_OF_THOUGHT); resetGlow(p, RegularPrayers.INCREDIBLE_REFLEXES); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case HAWK_EYE: resetGlow(p, RegularPrayers.SHARP_EYE); resetGlow(p, RegularPrayers.EAGLE_EYE); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case MYSTIC_LORE: resetGlow(p, RegularPrayers.MYSTIC_WILL); resetGlow(p, RegularPrayers.MYSTIC_MIGHT); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case ULTIMATE_STRENGTH: resetGlow(p, RegularPrayers.BURST_OF_STRENGTH); resetGlow(p, RegularPrayers.SUPERHUMAN_STRENGTH); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case INCREDIBLE_REFLEXES: resetGlow(p, RegularPrayers.CLARITY_OF_THOUGHT); resetGlow(p, RegularPrayers.IMPROVED_REFLEXES); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case EAGLE_EYE: resetGlow(p, RegularPrayers.SHARP_EYE); resetGlow(p, RegularPrayers.HAWK_EYE); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case MYSTIC_MIGHT: resetGlow(p, RegularPrayers.MYSTIC_WILL); resetGlow(p, RegularPrayers.MYSTIC_LORE); resetGlow(p, RegularPrayers.CHIVALRY); resetGlow(p, RegularPrayers.PIETY); break; case PROTECT_FROM_MAGIC: case PROTECT_FROM_MISSILES: case PROTECT_FROM_MELEE: case RETRIBUTION: case REDEMPTION: case SMITE: for (RegularPrayers r : RegularPrayers.values()) if (r.getHeadIcon() > -1 && r != pray) resetGlow(p, r); break; case CHIVALRY: case PIETY: for (RegularPrayers r : RegularPrayers.values()) if (!CombatPrayers(r) && r != pray) resetGlow(p, r); break; default: break; } } public static void activatePrayer(Player p, int buttonId) { RegularPrayers r = RegularPrayers.forButton(buttonId); int i = r.ordinal(); if (p.isDead || p.getConstitution() <= 0) return; if (p.playerRights == 5) p.sendMessage("Pray Name: " + r.getPrayerName()); if (p.playerLevel[5] <= 0 && GameConstants.PRAYER_POINTS_REQUIRED) { p.getPA().sendFrame36(r.getGlowId(), 0); p.sendMessage("You have run out of prayer points!"); return; } if (p.getPA().getLevelForXP(p.playerXP[5]) < r.getLevelReq() && GameConstants.PRAYER_LEVEL_REQUIRED) { p.getPA().sendFrame36(r.getGlowId(), 0); p.getDH().sendStatement( "You need a @[email protected] level of " + r.getLevelReq() + " to use " + r.getPrayerName() + "."); return; } boolean headIcon = false; switch (r) { case THICK_SKIN: case BURST_OF_STRENGTH: case CLARITY_OF_THOUGHT: case SHARP_EYE: case MYSTIC_WILL: case ROCK_SKIN: case SUPERHUMAN_STRENGTH: case IMPROVED_REFLEXES: case HAWK_EYE: case MYSTIC_LORE: case STEEL_SKIN: case ULTIMATE_STRENGTH: case INCREDIBLE_REFLEXES: case EAGLE_EYE: case MYSTIC_MIGHT: case CHIVALRY: case PIETY: resetOtherPrayers(p, r); break; case PROTECT_FROM_MAGIC: case PROTECT_FROM_MISSILES: case PROTECT_FROM_MELEE: if (System.currentTimeMillis() - p.stopPrayerDelay < 5000) { p.sendMessage("You have been injured and can't use this prayer!"); p.getPA().sendFrame36(r.getGlowId(), 0); return; } headIcon = true; break; case RETRIBUTION: case REDEMPTION: case SMITE: headIcon = true; resetOtherPrayers(p, r); break; default: break; } if (!headIcon) { if (p.prayerActive[i] == false) { p.prayerActive[i] = true; p.getPA().sendFrame36(r.getGlowId(), 1); } else { p.prayerActive[i] = false; p.getPA().sendFrame36(r.getGlowId(), 0); } } else { if (p.prayerActive[i] == false) { p.prayerActive[i] = true; p.getPA().sendFrame36(r.getGlowId(), 1); p.headIcon = r.getHeadIcon(); p.getPA().requestUpdates(); } else { p.prayerActive[i] = false; p.getPA().sendFrame36(r.getGlowId(), 0); p.headIcon = -1; p.getPA().requestUpdates(); } } } } [/CODE] Curses.java [CODE] package org.pandemonium.game.content.combat.prayer; import org.pandemonium.game.GameConstants; import org.pandemonium.game.content.PrayerBook; import org.pandemonium.game.content.combat.util.ProjectileHandler; import org.pandemonium.game.entity.Animation; import org.pandemonium.game.entity.Entity; import org.pandemonium.game.entity.Entity.AttackTypes; import org.pandemonium.game.entity.Graphic; import org.pandemonium.game.entity.player.Player; import org.pandemonium.utility.Misc; public class Curses extends PrayerData { [COLOR="#FF0000"]public static void resetCurse(Player p) { for (CursedPrayers c : CursedPrayers.values()) { p.curseActive[c.ordinal()] = false; p.getPA().sendFrame36(c.getGlowId(), 0); } p.headIcon = -1; p.getPA().requestUpdates(); }[/COLOR] public static void resetGlow(Player p, CursedPrayers curse) { p.getPA().sendFrame36(curse.getGlowId(), 0); p.curseActive[curse.ordinal()] = false; } public static boolean CombatPrayers(CursedPrayers curse) { if (curse == CursedPrayers.PROTECT_ITEM || curse == CursedPrayers.BERSERKER || curse == CursedPrayers.WRATH || curse == CursedPrayers.SOULSPLIT) return false; return true; } public static void resetOtherPrayers(Player p, CursedPrayers curses) { switch (curses) { case SAP_WARRIOR: resetGlow(p, CursedPrayers.LEECH_ATTACK); resetGlow(p, CursedPrayers.LEECH_DEFENCE); resetGlow(p, CursedPrayers.LEECH_STRENGTH); resetGlow(p, CursedPrayers.TURMOIL); break; case SAP_MAGE: resetGlow(p, CursedPrayers.LEECH_MAGIC); resetGlow(p, CursedPrayers.TURMOIL); break; case SAP_RANGER: resetGlow(p, CursedPrayers.LEECH_RANGED); resetGlow(p, CursedPrayers.TURMOIL); break; case SAP_SPIRIT: resetGlow(p, CursedPrayers.LEECH_SPECIAL_ATTACK); resetGlow(p, CursedPrayers.TURMOIL); break; case DEFLECT_SUMMONING: case DEFLECT_MAGIC: case DEFLECT_MISSILES: case DEFLECT_MELEE: case WRATH: case SOULSPLIT: for (CursedPrayers c : CursedPrayers.values()) if (c.getHeadIcon() > -1 && c != curses) resetGlow(p, c); break; case LEECH_ATTACK: resetGlow(p, CursedPrayers.SAP_WARRIOR); resetGlow(p, CursedPrayers.TURMOIL); break; case LEECH_MAGIC: resetGlow(p, CursedPrayers.SAP_MAGE); resetGlow(p, CursedPrayers.TURMOIL); break; case LEECH_RANGED: resetGlow(p, CursedPrayers.SAP_RANGER); resetGlow(p, CursedPrayers.TURMOIL); break; case LEECH_DEFENCE: resetGlow(p, CursedPrayers.SAP_WARRIOR); resetGlow(p, CursedPrayers.TURMOIL); break; case LEECH_STRENGTH: resetGlow(p, CursedPrayers.SAP_WARRIOR); resetGlow(p, CursedPrayers.TURMOIL); break; case LEECH_SPECIAL_ATTACK: resetGlow(p, CursedPrayers.SAP_SPIRIT); resetGlow(p, CursedPrayers.TURMOIL); break; case TURMOIL: resetGlow(p, CursedPrayers.SAP_WARRIOR); resetGlow(p, CursedPrayers.SAP_MAGE); resetGlow(p, CursedPrayers.SAP_RANGER); resetGlow(p, CursedPrayers.SAP_SPIRIT); resetGlow(p, CursedPrayers.LEECH_ATTACK); resetGlow(p, CursedPrayers.LEECH_MAGIC); resetGlow(p, CursedPrayers.LEECH_RANGED); resetGlow(p, CursedPrayers.LEECH_DEFENCE); resetGlow(p, CursedPrayers.LEECH_STRENGTH); resetGlow(p, CursedPrayers.LEECH_SPECIAL_ATTACK); break; default: break; } } public static void activateCurse(Player p, int buttonId) { CursedPrayers curses = CursedPrayers.forButton(buttonId); if (p.playerRights == 5) p.sendMessage("[Debug] Curse Id: " + curses.getPrayerName()); if (p.inRFD) { p.sendMessage("You can't use prayer on this minigame."); return; } if (p.playerLevel[1] < 28) { p.getPA().sendFrame36(curses.getGlowId(), 0); p.getDH().sendStatement( "You need a @[email protected] level of 28 to use " + curses.getPrayerName() + "."); return; } if (p.getFields().getPrayerBook() != PrayerBook.CURSES) { resetCurse(p); p.sendMessage("You are not on the right prayer book to activate this curse."); return; } if (p.getConstitution() <= 0) { p.getPA().sendFrame36(curses.getGlowId(), 0); p.sendMessage("You can't activate this curse when you are dead."); return; } if (p.playerLevel[5] <= 0 && GameConstants.PRAYER_POINTS_REQUIRED) { p.getPA().sendFrame36(curses.getGlowId(), 0); p.sendMessage("You have run out of Prayer points!"); p.sendMessage("You can recharge at an altar."); return; } if (p.getPA().getLevelForXP(p.playerXP[5]) <= curses.getLevelReq() && GameConstants.PRAYER_LEVEL_REQUIRED) { p.getPA().sendFrame36(curses.getGlowId(), 0); p.getDH().sendStatement( "You need a @[email protected] level of " + curses.getLevelReq() + " to use " + curses.getPrayerName() + "."); return; } boolean headIcon = false; int i = curses.ordinal(); switch (curses) { case PROTECT_ITEM: p.performAnimation(new Animation(12567)); p.performGraphic(new Graphic(2213)); p.lastProtItem = System.currentTimeMillis(); break; case BERSERKER: p.performAnimation(new Animation(12589)); p.performGraphic(new Graphic(2266)); break; case DEFLECT_SUMMONING: case DEFLECT_MAGIC: case DEFLECT_MISSILES: case DEFLECT_MELEE: if (System.currentTimeMillis() - p.stopPrayerDelay < 5000) { p.sendMessage("You have been injured and can't use this prayer!"); p.getPA().sendFrame36(curses.getGlowId(), 0); return; } headIcon = true; if (p.curseActive[curses.ordinal()] == false) resetOtherPrayers(p, curses); break; case SAP_WARRIOR: case LEECH_ATTACK: case SAP_RANGER: case LEECH_RANGED: case SAP_MAGE: case LEECH_MAGIC: case SAP_SPIRIT: case LEECH_SPECIAL_ATTACK: case LEECH_DEFENCE: case LEECH_STRENGTH: if (p.curseActive[curses.ordinal()] == false) resetOtherPrayers(p, curses); break; case WRATH: case SOULSPLIT: headIcon = true; if (p.curseActive[curses.ordinal()] == false) resetOtherPrayers(p, curses); break; case TURMOIL: p.performAnimation(new Animation(12565)); p.performGraphic(new Graphic(2226)); if (p.curseActive[curses.ordinal()] == false) resetOtherPrayers(p, curses); break; default: break; } if (!headIcon) { if (p.curseActive[i] == false) { p.curseActive[i] = true; p.getPA().sendFrame36(curses.getGlowId(), 1); } else { p.curseActive[i] = false; p.getPA().sendFrame36(curses.getGlowId(), 0); } } else { if (p.curseActive[i] == false) { p.curseActive[i] = true; p.getPA().sendFrame36(curses.getGlowId(), 1); p.headIcon = curses.getHeadIcon(); p.getPA().requestUpdates(); } else { p.curseActive[i] = false; p.getPA().sendFrame36(curses.getGlowId(), 0); p.headIcon = -1; p.getPA().requestUpdates(); } } } public static void applyCurses(Entity attacker, Entity target, int damage) { if (attacker.isPlayer()) { Player p = (Player) attacker; if (p.curseActive[1] || p.curseActive[2] || p.curseActive[3] || p.curseActive[10] || p.curseActive[11] || p.curseActive[12] || p.curseActive[13] || p.curseActive[14] || p.curseActive[16]) applyLeeches(p, target); if (p.curseActive[18]) handleSoulSplit(attacker, target, damage); } if (damage > 0) if (target.isPlayer()) if (((Player) target).curseActive[7] && attacker.getAttackType() == AttackTypes.MAGIC) handleDeflectPrayers(attacker, target, damage, 0); else if (((Player) target).curseActive[8] && attacker.getAttackType() == AttackTypes.RANGED) handleDeflectPrayers(attacker, target, damage, 1); else if (((Player) target).curseActive[9] && attacker.getAttackType() == AttackTypes.MELEE) handleDeflectPrayers(attacker, target, damage, 2); } public static int[] deflectData = { 2228, 2229, 2230 }; public static void handleDeflectPrayers(Entity attacker, Entity target, int damage, int i) { if (attacker.getConstitution() <= 0) return; if (target == null) return; if (!((Player) target).curseActive[i + 7]) return; int deflectDamage = (int) (damage * 0.05) + 1; target.performGraphic(new Graphic(deflectData[i])); target.performAnimation(new Animation(12573)); attacker.setDoubleHit(deflectDamage, 0, 3); } public static void applyLeeches(Player attacker, Entity target) { if (target == null) return; int[] projectileGfx = { 2252, 2236, 2240, 2242, 2248 }; int[] targetGfx = { 2253, 2238, 2242, 2246, 2250 }; String[] curseName = { "attack", "ranged", "magic", "defense", "strength" }; for (int i = 0; i < 17; i++) { if (i >= 10 && i < 15) { if (attacker.curseActive[i]) { int failed = Misc.random(8); int id = i - 10; if (failed == 8) { double targetEffect = target.prayerEffects[id]; double attackerEffect = attacker.prayerEffects[id]; if (targetEffect > 0.75 && attackerEffect < 1.1) { if (targetEffect - 0.1 < 0.75) target.prayerEffects[id] = 0.75; else target.prayerEffects[id] -= 0.1; if (attackerEffect + 0.05 > 1.1) attacker.prayerEffects[id] = 1.1; else attacker.prayerEffects[id] += 0.05; } if (target.isPlayer()) ((Player) target).sendMessage("Your " + curseName[id] + " has been leeched by " + attacker.playerName.toLowerCase() + "."); ProjectileHandler.curseProjectile(attacker, target, projectileGfx[id]); attacker.sendMessage("Your curse leechs the enemy's " + curseName[id] + "."); target.performGraphic(new Graphic(targetGfx[id])); attacker.performAnimation(new Animation(12575)); } } } } if (attacker.curseActive[16]) { int failed = Misc.random(10); if (failed == 10) { if (target.isPlayer()) { Player t = (Player) target; if (t.specAmount > 1.0) { if (attacker.specAmount <= 9.0) { attacker.specAmount += 1.0; t.specAmount -= 1.0; t.sendMessage("Your special attack has been leeched by " + attacker.playerName.toLowerCase() + "."); } } } ProjectileHandler.curseProjectile(attacker, target, 2256); target.performGraphic(new Graphic(2258)); attacker.performAnimation(new Animation(12575)); } } if (attacker.curseActive[1]) { int failed = Misc.random(8); if (failed == 8) { if (target.prayerEffects[0] > 0.8 && target.prayerEffects[0] - 0.1 > 0.8) target.prayerEffects[0] -= 0.1; if (target.prayerEffects[3] > 0.8 && target.prayerEffects[3] - 0.1 > 0.8) target.prayerEffects[3] -= 0.1; if (target.prayerEffects[4] > 0.8 && target.prayerEffects[4] - 0.1 > 0.8) target.prayerEffects[4] -= 0.1; if (target.isPlayer()) ((Player) target) .sendMessage("Your attack has been drained by " + attacker.playerName.toLowerCase() + "."); } attacker.performGraphic(new Graphic(2214)); ProjectileHandler.curseProjectile(attacker, target, 2215); attacker.sendMessage("Your curse drains the enemy's attack."); target.performGraphic(new Graphic(2234)); attacker.performAnimation(new Animation(12569)); } if (attacker.curseActive[2]) { int failed = Misc.random(8); if (failed == 8) { if (target.prayerEffects[1] > 0.8 && target.prayerEffects[1] - 0.1 > 0.8) target.prayerEffects[1] -= 0.1; if (target.isPlayer()) ((Player) target) .sendMessage("Your ranged has been drained by " + Misc.optimizeText(attacker.playerName) .toLowerCase() + "."); attacker.sendMessage("Your curse drains the enemy's ranged."); attacker.performGraphic(new Graphic(2217)); ProjectileHandler.curseProjectile(attacker, target, 2218); target.performGraphic(new Graphic(2235)); attacker.performAnimation(new Animation(12569)); } } if (attacker.curseActive[3]) { int failed = Misc.random(8); if (failed == 8) { if (target.prayerEffects[2] > 0.8 && target.prayerEffects[2] - 0.1 > 0.8) target.prayerEffects[2] -= 0.1; if (target.isPlayer()) ((Player) target) .sendMessage("Your magic has been drained by " + Misc.optimizeText(attacker.playerName) .toLowerCase() + "."); attacker.sendMessage("Your curse drains the enemy's magic."); attacker.performGraphic(new Graphic(2220)); ProjectileHandler.curseProjectile(attacker, target, 2221); target.performGraphic(new Graphic(2239)); attacker.performAnimation(new Animation(12569)); } } } public static void handleSoulSplit(Entity attacker, Entity target, int damage) { Player a = (Player) attacker; int form = damage / 4; if (form <= 0 || target == null || target.getConstitution() <= 0) return; if (attacker.getConstitution() + form >= attacker.getMaxConstitution()) attacker.setConstitution(attacker.getMaxConstitution()); else attacker.setConstitution(attacker.getConstitution() + form); if (target.isPlayer()) if (target.getPrayer() - form > 0) target.setPrayer(target.getPrayer() - form); else target.setPrayer(0); target.performGraphic(new Graphic(2264)); a.getPA().refreshSkill(3); ProjectileHandler.soulsplitProjectile(attacker, target); } public static void applyWrath(Player attacker, Entity target) { int wrathDamage = (attacker.playerLevel[5] / 100) * 26; if (target == null) return; if (attacker.inDuelArena() || target.inDuelArena()) return; attacker.performGraphic(new Graphic(2259)); attacker.performAnimation(new Animation(12583)); target.performGraphic(new Graphic(2260)); target.setSingleHit(wrathDamage, 0, 3); } } [/CODE]
-
Well tbh I realize that this is a java tutorial really but at the end of the day I'm sick of seeing code else if(int) else if(int) over and over :S Use a switch statement ffs :S Here's how to do it: Example: (This code will obviously not work if you put it into your source its just an example.) [CODE] if (npc.id == 1) { do.something; } else if (npc.id == 2) { do.something; } else if (npc.id == 3) { do.something; } else if (npc.id == 4) { do.something; } else if (npc.id == 5) { do.something; } else if (npc.id == 6) { do.something; } else if (npc.id == 7) { do.something; And so on for about 100 npcs or for what ever else. } [/CODE] Don't you think this is allot more tidier and more easier to read? [CODE]switch(npc.id) { case 1: do.something; break; case 2: do.something; break; case 3: do.something; break; case 4: do.something; break; case 5: do.something; break; case 6: do.something; break; case 7: do.something; break; default: if (none of the npcs do anything) return; else do.something. break; }[/CODE] You can also do this for string values, which is very useful: example [CODE]String example; if(example.equalsIgnorecase("what ever") else if repeat like before [/CODE] You can just use [CODE]switch(example) { case "what ever": do.something; break; default: break; [/CODE] and so on for what ever the String example contains.
-
Whenever a player clicks for example on the minimap to walk somewhere, and if he halfway switches his weapon slot, the player stops moving further to its destination. Is there a way to fix this so the player keeps moving no matter what items he switches. Thanks in advance!
-
- 637
- dementhium
-
(and 2 more)
Tagged with:
-
Hybrid fails when i switch my character is not stopping attacking (auto retaliate is off ) does some one know how to let the character stop hitting after switching gear. I am using PI
-
[SIZE=7][B][COLOR="#FF0000"][U][FONT=Comic Sans MS]-Close please.[/FONT][/U][/COLOR][/B][/SIZE] ------------------------ I'm trying to code the Altar to switch back to the modern spell book but I can't seem to find the if statement I need to complete it. my code is: [code] case 6552: player.setSpellBook(193); player.sendMessage("You switch to Ancient Magicks!"); break; [/code] But I need something like (IS NOT CORRECT): [code] case 6552: if (player.[COLOR="#FF0000"]SpellBook()[/COLOR] == 193) { player.setSpellBook(192); } else { player.setSpellBook(193); } break;[/code] Text that needs to be changed in [COLOR="#FF0000"]RED[/COLOR]. Thanks if anyone can help, have been trying to get the if statement correct but can't find the correct method.
-
Hey guys, how can i make the switches on my server instant..?
-
[B][SIZE=5][CENTER]Switch Statements[/CENTER][/SIZE][/B] [CENTER]I had a friend ask me what switch statements are, and why they should be used. So, I decided to make a small tutorial explaining Switch Statements, to help everyone who might be confused.[/CENTER] In most servers, packets are programmed using and 'if' and 'else' statements. Example: [code] public void tutorialStuff(int playerID) { if (playerID == 0) { callFunction0(); } else if (playerID == 1) { callFunction1(); } else if (playerID == 2) { callFunction2(); } else if (playerID == 3) { callFunction3(); } else if (playerID == 4) { callFunction4(); } else if (playerID == 5) { callFunction5(); } } [/code] The code above will work fine, but it looks bad, and it can get confusing. Unlike if-then and if-then-else statements, the switch statement can have a number of possible execution paths, instead of reading everything down the 'ladder'. A switch works with the byte, short, char, and int primitive data types. It also works with enumerated types , the String class, and a few special classes that wrap certain primitive types: Character, Byte, Short, and Integer. Now you're probably wondering,"Well how would I make that code into a switch statement?" Here's how: [code] public static void tutorialStuff(int playerID) { switch (playerID) { case 0: callFunction0(); break; case 1: callFunction1(); break; case 2: callFunction2(); break; case 3: callFunction3(); break; case 4: callFunction4(); break; case 5: callFunction5(); break; } } [/code] To better explain, the case represents the integer playerID. Switch statements also don't allow duplicate cases. We can also have similar cases call the same method. Here's how: [code] public static void tutorialStuff(int playerID) { switch (playerID) { case 0: callFunction0(); break; case 1: callFunction1(); break; case 2: callFunction2(); break; case 3: callFunction3(); break; case 4: case 5: callFunction5(); break; default: System.out.println("Tutorials are fun."); } } [/code] When you click on playerID's four and five, the same thing will happen because it falls under the same statement. Also, you can have a default: statement. When you use a default, anything not equal to the declared statements in the method will be display or call whatever you put as the default: statement.
-
hey guys in my server i need to make the switch hybrid work wich means that when i start attacking a player and switch to dds my player will stop attack and i need to click again to the player i need when attack player and change to dds no need to click again
-
i want to make switch hybrid work that means when i fight someone and i change wepon it complete att dont stop i will pay rsgp for that
-
in the server my wepons when i switch them and i am attacking it dont complete attacking i need to click again so if anyone can fix this i will pay some cash and there is the wild loot i need make it 3 items i will pay too help
-
hi guys, on my server (562 loading 659 cache), you can't hybrid switch properly. when you try to switch fast it most of the times moves the items. does anyone know how i can make the switches better? thanks, startcode
-
in my server i wanna to make the switching works mean when i attack monster then change wepon i need to complete attack not press again on the monster is that hard please help please
-
hey i am having issues getting my spell books switch in the donator tab to work for anything after the first donator rank i type here is the code to do with switching [CODE] case 107230: if(c.isDonator == 0 && c.isRDonator == 0 && c.isSDonator == 0 && c.inWild()) { c.sendMessage("You cannot be in the wilderness when using this!"); return; } if (c.playerMagicBook == 0 && c.isDonator == 1 || c.isRDonator == 1 || c.isSDonator == 1 && !c.inWild()) { c.playerMagicBook = 1; c.setSidebarInterface(6, 12855); c.setSidebarInterface(0, 328); c.sendMessage("You switch your magic to : Ancients."); c.getPA().resetAutocast(); return; } if (c.playerMagicBook == 1 && c.isDonator == 1 || c.isRDonator == 1 || c.isSDonator == 1 && !c.inWild()) { c.playerMagicBook = 2; c.setSidebarInterface(0, 328); c.setSidebarInterface(6, 16640); c.sendMessage("You switch your magic to : Lunar."); c.getPA().resetAutocast(); return; }[/CODE] In everyplace it says "c.isDonator == 1" is the only spot that works like if i put "c.isSDonator == 1" there then it will work but if i dont when i click switch i jsut get this message and nothing happens [CODE]"You switch your magic to : Ancients."[/CODE] if you know whats wrong please help