Thread: Curses not turning off when processing method

Results 1 to 4 of 4
  1. #1 Curses not turning off when processing method 
    Registered Member dyzes's Avatar
    Join Date
    Sep 2015
    Posts
    40
    Thanks given
    24
    Thanks received
    73
    Rep Power
    11
    So, there is this problem I've recently encountered and I have no clue on how to fix this not working piece of code.


    Video of the error that I'm getting:



    Code:
    private void resetAllCurse() {
    		Misc.println("1");
    		
    		for (int index = 0; index < c.CURSE.length; index++) {
    			c.curseActive[index] = false;
    			c.getPA().sendFrame36(c.CURSE_GLOW[index], 0);
    		}
    		c.headIcon = -1;
    		c.getPA().requestUpdates();
    	}
    Code:
    public void activateCurse(int curseId) {
    		if(c.duelRule[7]) {
    			resetCurse();
    			c.sendMessage("Prayer has been disabled in this duel!");
    			return;
    		}
    		if (curseId == 19 && c.playerLevel[1] < 30) {
    			c.getPA().sendFrame36(c.CURSE_GLOW[curseId], 0);
    			c.getPA().sendFrame126("You need a @[email protected] level of 30 to use " + c.CURSE_NAME[curseId] + ".", 357);
    			c.getPA().sendFrame126("Click here to continue", 358);
    			c.getPA().sendFrame164(356);
    			return;
    		}
    		if (c.altarPrayed != 1) {
    			resetCurse();
    			c.sendMessage("You are not on the right prayer book to activate this curse.");
    			return;
    		}
    		if (c.playerLevel[3] <= 0) {
    			c.getPA().sendFrame36(c.CURSE_GLOW[curseId], 0);
    			c.sendMessage("You can't activate this curse when you are dead.");
    			return;
    		}
    		//0 = pItem//1 = sapWar//2 = sapRng//3 = sapMge//4 = sapSprt
    		//5 = berserk//6 = defSum//7 = defMge//8 = defRng//9 = defMel
    		//10 = leechAtk//11 = leechRng//12 = leechMge//13 = leechDef//14 = leechStr
    		//15 = leechEnrgy//16 = leechSpec//17 = wrath//18 = soul//19 = turmoil
    		
    		if(c.playerLevel[5] > 0 || !Config.PRAYER_POINTS_REQUIRED) {
    			if(c.getLevelForXP(c.playerXP[5]) >= c.CURSE_LEVEL_REQUIRED[curseId] || !Config.PRAYER_LEVEL_REQUIRED) {
    				boolean headIcon = false;
    				switch(curseId) {
    					case 0:
    						if(c.curseActive[curseId] == false) {
    							c.startAnimation(12567);
    							c.gfx0(2213);
    							c.lastProtItem = System.currentTimeMillis();
    						}
    					break;
    
    					case 1:
    					case 10:
    						if (c.curseActive[curseId] == false) {
    							atkCurse(curseId);
    						}
    					break;
    					
    					case 2:
    					case 11:
    						if (c.curseActive[curseId] == false) {
    							rngCurse(curseId);
    						}
    					break;
    					
    					case 3:
    					case 12:
    						if (c.curseActive[curseId] == false) {
    							mgeCurse(curseId);
    						}
    					break;
    					
    					case 4:
    					case 16:
    						if (c.curseActive[curseId] == false) {
    							sprtCurse(curseId);
    						}
    					break;
    					case 5:
    						if(c.curseActive[curseId] == false) {
    							c.startAnimation(12589);
    							c.gfx0(2266);
    						}
    
    					break;
    					
    					case 13:
    						if (c.curseActive[curseId] == false) {
    							defCurse(curseId);
    						}
    					break;
    					case 14:
    						if (c.curseActive[curseId] == false) {
    							strCurse(curseId);
    						}
    					break;
    					
    					case 6:	
    					case 7:					
    					case 8:
    					case 9:
    						if(System.currentTimeMillis() - c.stopPrayerDelay < 5000) {
    							c.sendMessage("You have been injured and can't use this prayer!");
    							c.getPA().sendFrame36(c.CURSE_GLOW[7], 0);
    							c.getPA().sendFrame36(c.CURSE_GLOW[8], 0);
    							c.getPA().sendFrame36(c.CURSE_GLOW[9], 0);
    							return;
    						}
    						if (curseId == 7)
    							c.protMageDelay = System.currentTimeMillis();
    						else if (curseId == 8)
    							c.protRangeDelay = System.currentTimeMillis();
    						else if (curseId == 9)
    							c.protMeleeDelay = System.currentTimeMillis();
    					case 17:
    					case 18:
    						headIcon = true;		
    						for(int p = 6; p < 19; p++) {
    							if(curseId != p && p != 10 && p != 11 && p != 10 && p != 12 && p != 13 && p != 14 && p != 15 && p != 16) {
    								c.curseActive[p] = false;
    								c.getPA().sendFrame36(c.CURSE_GLOW[p], 0);
    							}
    						}
    					break;
    					
    					case 19:
    						if (c.curseActive[curseId] == false) {
    							c.startAnimation(12565);
    							c.gfx0(2226);
    							strCurse(curseId);
    							atkCurse(curseId);
    							defCurse(curseId);
    							mgeCurse(curseId);
    							rngCurse(curseId);
    						}
    					break;
    				}
    				if(!headIcon) {
    					if(c.curseActive[curseId] == false) {
    						c.curseActive[curseId] = true;
    						c.getPA().sendFrame36(c.CURSE_GLOW[curseId], 1);					
    					} else {
    						c.curseActive[curseId] = false;
    						c.getPA().sendFrame36(c.CURSE_GLOW[curseId], 0);
    					}
    				} else {
    					if(c.curseActive[curseId] == false) {
    						c.curseActive[curseId] = true;
    						c.getPA().sendFrame36(c.CURSE_GLOW[curseId], 1);
    						c.headIcon = c.CURSE_HEAD_ICONS[curseId];
    						c.getPA().requestUpdates();
    					} else {
    						c.curseActive[curseId] = false;
    						c.getPA().sendFrame36(c.CURSE_GLOW[curseId], 0);
    						c.headIcon = -1;
    						c.getPA().requestUpdates();
    					}
    				}
    			} else {
    				c.getPA().sendFrame36(c.CURSE_GLOW[curseId],0);
    				c.getPA().sendFrame126("You need a @[email protected] level of "+c.CURSE_LEVEL_REQUIRED[curseId]+" to use "+c.CURSE_NAME[curseId]+".", 357);
    				c.getPA().sendFrame126("Click here to continue", 358);
    				c.getPA().sendFrame164(356);
    			}
    		} else {
    			resetAllCurse();
    			c.sendMessage("You have run out of Prayer points!");
    			c.sendMessage("You can recharge at an altar.");
    		}
    	}
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    21
    Posts
    3,754
    Thanks given
    809
    Thanks received
    1,142
    Rep Power
    3912
    Use this I made forever ago: [Only registered and activated users can see links. ]

    Aside from the horrible naming and documenting, the code itself works great.
    Quote Originally Posted by Killapkz View Post
    and I know there is an issue because it's a 317 PI.
    Quote Originally Posted by MyrChivvon View Post
    But I keep failing, and the worse part is that I do not even know why..
    Reply With Quote  
     

  4. #3  
    Donator


    Join Date
    Oct 2012
    Posts
    3,658
    Thanks given
    1,217
    Thanks received
    715
    Rep Power
    593
    I recommend:

    Code:
    package com.model.game.character.combat;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import com.model.game.character.Animation;
    import com.model.game.character.Entity;
    import com.model.game.character.Graphic;
    import com.model.game.character.player.Player;
    import com.model.game.character.player.SkillConstants;
    import com.model.game.character.player.packets.encode.impl.SendConfig;
    import com.model.game.character.player.packets.encode.impl.SendMessagePacket;
    import com.model.utility.Utility;
    
    public class PrayerHandler {
    
    	public static enum Prayer {
    		THICK_SKIN(21233, 1, 0.5, 83), BURST_OF_STRENGTH(21234, 4, 0.5, 84), CLARITY_OF_THOUGHT(21235, 7, 0.5, 85), SHARP_EYE(77100, 8, 0.5, 700), MYSTIC_WILL(77102, 9, 0.5, 701), ROCK_SKIN(21236, 10, 1.0, 86), SUPERHUMAN_STRENGTH(21237, 13, 1.0, 87), IMPROVED_REFLEXES(21238, 16, 1.0, 88), RAPID_RESTORE(21239, 19, (1 / 6), 89), RAPID_HEAL(21240, 22, (1 / 3), 90), PROTECT_ITEM(21241, 25, (1 / 3), 91), HAWK_EYE(77104, 26, 1.0, 702), MYSTIC_LORE(77106, 27, 1.0, 703), STEEL_SKIN(21242, 28, 2.0, 92), ULTIMATE_STRENGTH(21243, 31, 2.0, 93), INCREDIBLE_REFLEXES(21244, 34, 2.0, 94), PROTECT_FROM_MAGIC(21245, 37, 2.0, 95), PROTECT_FROM_MISSILE(21246, 40, 2.0, 96), PROTECT_FROM_MELEE(21247, 43, 2.0, 97), EAGLE_EYE(77109, 44, 2.0, 704), MYSTIC_MIGHT(77111, 45, 2.0, 705), RETRIBUTION(2171, 46, 0.5, 98), REDEMPTION(2172, 49, 1.0, 99), SMITE(2173, 52, (10 / 3), 100), CHIVALRY(77113, 60, 3.0, 706), PIETY(77115, 70, 4.0, 707);
    
    		private int buttonId;
    
    		private int levelRequirement;
    
    		private double drainRate;
    
    		private int configId;
    
    		private Prayer(int buttonId, int level, double drain, int configId) {
    			this.buttonId = buttonId;
    			this.levelRequirement = level;
    			this.drainRate = drain;
    			this.configId = configId;
    		}
    
    		public int getPrayerIndex(Prayer prayer) {
    			for (Prayer data : Prayer.values()) {
    				if (data == prayer) {
    					return data.ordinal();
    				}
    			}
    			return -1;
    		}
    
    		public int getButtonId() {
    			return buttonId;
    		}
    
    		public int getConfigId() {
    			return configId;
    		}
    
    		public int getLevelRequirement() {
    			return levelRequirement;
    		}
    
    		public double getDrainRate() {
    			return drainRate;
    		}
    	}
    
    	public static void togglePrayer(final Player player, final int buttonId) {
    		for (Prayer prayer : Prayer.values()) {
    			if (buttonId == prayer.getButtonId()) {
    				if (player.isActivePrayer(prayer)) {
    					deactivatePrayer(player, prayer);
    					return;
    				} else {
    					activatePrayer(player, prayer);
    					return;
    				}
    			}
    		}
    	}
    
    	private static void activatePrayer(final Player player, final Prayer prayer) {
    		if (player.getSkills().getLevelForExperience(SkillConstants.PRAYER) < prayer.getLevelRequirement()) {
    			player.write(new SendMessagePacket("You need a prayer level of at least " + prayer.getLevelRequirement() + " to use " + prayer.toString().toLowerCase().replaceAll("_", " ") + "."));
    			deactivatePrayer(player, prayer);
    			return;
    		}
    		if (player.getSkills().getLevel(SkillConstants.PRAYER) <= 0) {
    			player.write(new SendMessagePacket("You have run out of prayer points; recharge your prayer points at an altar."));
    			deactivatePrayer(player, prayer);
    			return;
    		}
    		if (prayer != Prayer.PROTECT_ITEM)
    			switchPrayer(player, prayer);
    		if (prayer.equals(Prayer.PROTECT_FROM_MAGIC) || prayer.equals(Prayer.PROTECT_FROM_MISSILE) || prayer.equals(Prayer.PROTECT_FROM_MELEE) || prayer.equals(Prayer.RETRIBUTION) || prayer.equals(Prayer.REDEMPTION) || prayer.equals(Prayer.SMITE)) {
    			int headIcon = -1;
    			switch (prayer) {
    			case PROTECT_FROM_MAGIC:
    				headIcon = 2;
    				break;
    			case PROTECT_FROM_MISSILE:
    				headIcon = 1;
    				break;
    			case PROTECT_FROM_MELEE:
    				headIcon = 0;
    				break;
    			case RETRIBUTION:
    				headIcon = 3;
    				break;
    			case REDEMPTION:
    				headIcon = 5;
    				break;
    			case SMITE:
    				headIcon = 4;
    				break;
    			default:
    				break;
    			}
    			player.setPrayerIcon(headIcon);
    			player.getPA().requestUpdates();
    		}
    		player.setActivePrayer(prayer, true);
    		player.write(new SendConfig(prayer.getConfigId(), 1));
    		player.addPrayerDrainRate(prayer.getDrainRate());
    	}
    
    	public static void deactivatePrayer(final Player player, final Prayer prayer) {
    		player.setActivePrayer(prayer, false);
    		if (prayer.equals(Prayer.PROTECT_FROM_MAGIC) || prayer.equals(Prayer.PROTECT_FROM_MISSILE) || prayer.equals(Prayer.PROTECT_FROM_MELEE) || prayer.equals(Prayer.RETRIBUTION) || prayer.equals(Prayer.REDEMPTION) || prayer.equals(Prayer.SMITE)) {
    			player.setPrayerIcon(-1);
    			player.getPA().requestUpdates();
    		}
    		player.addPrayerDrainRate(-(prayer.getDrainRate()));
    		player.write(new SendConfig(prayer.getConfigId(), 0));
    	}
    
    	private static Prayer[] defensePrayers = { Prayer.THICK_SKIN, Prayer.ROCK_SKIN, Prayer.STEEL_SKIN,
    
    	};
    
    	private static Prayer[] strengthPrayers = { Prayer.BURST_OF_STRENGTH, Prayer.SUPERHUMAN_STRENGTH, Prayer.ULTIMATE_STRENGTH,
    
    	Prayer.CHIVALRY, Prayer.PIETY,
    
    	Prayer.EAGLE_EYE, Prayer.HAWK_EYE, Prayer.SHARP_EYE,
    
    	Prayer.MYSTIC_LORE, Prayer.MYSTIC_MIGHT, Prayer.MYSTIC_WILL
    
    	};
    
    	private static Prayer[] attackPrayers = { Prayer.CLARITY_OF_THOUGHT, Prayer.IMPROVED_REFLEXES, Prayer.INCREDIBLE_REFLEXES,
    
    	Prayer.CHIVALRY, Prayer.PIETY,
    
    	Prayer.EAGLE_EYE, Prayer.HAWK_EYE, Prayer.SHARP_EYE,
    
    	Prayer.MYSTIC_LORE, Prayer.MYSTIC_MIGHT, Prayer.MYSTIC_WILL
    
    	};
    
    	private static Prayer[] restorePrayers = { Prayer.RAPID_RESTORE, Prayer.RAPID_HEAL
    
    	};
    	private static Prayer[] overheadPrayers = { Prayer.PROTECT_FROM_MAGIC, Prayer.PROTECT_FROM_MISSILE, Prayer.PROTECT_FROM_MELEE, Prayer.RETRIBUTION, Prayer.REDEMPTION, Prayer.SMITE
    
    	};
    
    	private static Map<Prayer, Prayer[]> unstackable = new HashMap<Prayer, Prayer[]>();
    
    	static {
    		for (Prayer p : defensePrayers) {
    			unstackable.put(p, defensePrayers);
    		}
    		for (Prayer p : strengthPrayers) {
    			unstackable.put(p, strengthPrayers);
    		}
    		for (Prayer p : attackPrayers) {
    			unstackable.put(p, attackPrayers);
    		}
    		for (Prayer p : restorePrayers) {
    			unstackable.put(p, restorePrayers);
    		}
    		for (Prayer p : overheadPrayers) {
    			unstackable.put(p, overheadPrayers);
    		}
    	}
    
    	/**
    	 * Handles draining the prayer
    	 * 
    	 * @param player
    	 *            The player with active prayers
    	 */
    	public static void handlePrayerDraining(Player player) {
    		double toRemove = 0.0;
    		for (Prayer prayer : Prayer.values()) {
    			if (player.isActivePrayer(prayer)) {
    				toRemove += prayer.getDrainRate() / 20;
    			}
    		}
    		if (toRemove > 0) {
    			toRemove /= (1 + (0.035 * player.playerBonus[11]));
    		}
    		player.setPrayerPoint(player.getPrayerPoint() - toRemove);
    		if (player.getPrayerPoint() <= 0) {
    			player.setPrayerPoint(1.0 + player.getPrayerPoint());
    			if (player.getSkills().getLevel(SkillConstants.PRAYER) > 1) {
    				player.getSkills().setLevel(SkillConstants.PRAYER, player.getSkills().getLevel(SkillConstants.PRAYER) - 1);
    			} else {
    				player.write(new SendMessagePacket("You have run out of prayer points."));
    				player.getSkills().setLevel(SkillConstants.PRAYER, 0);
    				for (Prayer prayer : Prayer.values()) {
    					deactivatePrayer(player, prayer);
    				}
    			}
    		}
    	}
    
    	/**
    	 * deactivates all of the prayers
    	 * 
    	 * @param player
    	 */
    	public static void resetAllPrayers(final Player player) {
    		for (Prayer prayer : Prayer.values()) {
    			deactivatePrayer(player, prayer);
    		}
    	}
    
    	private static void switchPrayer(final Player player, final Prayer prayer) {
    		Prayer[] toDeactivate = unstackable.get(prayer);
    
    		if (player.isActivePrayer(Prayer.ROCK_SKIN) || player.isActivePrayer(Prayer.STEEL_SKIN) || player.isActivePrayer(Prayer.THICK_SKIN)) {
    			if (prayer == Prayer.CHIVALRY || prayer == Prayer.PIETY) {
    				if (player.isActivePrayer(Prayer.THICK_SKIN)) {
    					deactivatePrayer(player, Prayer.THICK_SKIN);
    				} else if (player.isActivePrayer(Prayer.ROCK_SKIN)) {
    					deactivatePrayer(player, Prayer.ROCK_SKIN);
    				} else if (player.isActivePrayer(Prayer.STEEL_SKIN)) {
    					deactivatePrayer(player, Prayer.STEEL_SKIN);
    				}
    			}
    		}
    
    		for (int i = 0; i < toDeactivate.length; i++) {
    			if (player.isActivePrayer(toDeactivate[i]) && toDeactivate[i] != prayer) {
    				deactivatePrayer(player, toDeactivate[i]);
    			}
    		}
    	}
    
    	public static void handleSmite(Player player, Entity entity, int damage) {
    		if (player.isActivePrayer(Prayer.SMITE)) {
    			if (entity instanceof Player) {
    				Player victim = (Player) entity;
    				if (damage <= 0) {
    					return;
    				}
    				victim.getSkills().setLevel(SkillConstants.PRAYER, - damage / 4);
    				if (victim.getSkills().getLevel(SkillConstants.PRAYER) <= 0) {
    					victim.getSkills().setLevel(SkillConstants.PRAYER, 0);
    					resetAllPrayers(victim);
    				}
    			}
    		}
    	}
    	
    	public void appendRedemption(Player player) {
    		if (player.isActivePrayer(Prayer.REDEMPTION)) {
    			player.getSkills().setLevel(SkillConstants.HITPOINTS, (int) (+ player.getSkills().getLevelForExperience(SkillConstants.PRAYER) * .25));
    			player.getSkills().setLevel(SkillConstants.HITPOINTS, 0);
    			player.playGraphics(Graphic.create(436, 0, 0));
    			resetAllPrayers(player);
    		}
    	}
    	
    	public void prayAltar(Player player) {
            if (player.getRights().isBetween(2, 7)) {
    			if (player.getLastAltarPrayer() < 120000) {
    				player.write(new SendMessagePacket("You can only use the altar to restore your special attack every 2 minutes"));
    			} else {
    				player.setSpecialAmount(100);
    				player.setLastAltarPrayer(System.currentTimeMillis());
    			}
            } else if (Utility.random(4) == 0) {
            	player.write(new SendMessagePacket("Did you know if you were a donator you'd restore special energy and hitpoints?"));
            }
    
            if (player.getPrayerPoint() >= player.getSkills().getLevelForExperience(SkillConstants.PRAYER)) {
            	player.write(new SendMessagePacket("You already have full prayer points."));
                return;
            }
            player.getSkills().increaseLevelToMaximum(SkillConstants.HITPOINTS, player.getSkills().getLevelForExperience(SkillConstants.HITPOINTS));
            player.getSkills().setLevel(SkillConstants.PRAYER, player.getSkills().getLevelForExperience(SkillConstants.PRAYER));
            player.getSkills().setPrayerPoints(player.getSkills().getLevelForExperience(SkillConstants.PRAYER), true);
            if (player.getActionSender() != null) {
                player.getActionSender().sendSkills();
            }
            player.playAnimation(Animation.create(645));
            player.getSkills().setLevel(SkillConstants.PRAYER, player.getSkills().getLevelForExperience(SkillConstants.PRAYER));
            player.write(new SendMessagePacket("You pray at the altar..."));
        }
    }
    Took this from Hyperion awhile ago.
    Quote Originally Posted by Velocity View Post
    i'd love to get called in the middle of the night just to hear an indian voice whisper "the nulls are back friend, how i fix"
    Reply With Quote  
     

  5. #4  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,477
    Thanks given
    682
    Thanks received
    889
    Rep Power
    451
    Code:
    for (Prayer prayer : Prayer.values()) {
    					deactivatePrayer(player, prayer);
    				}
    this is the only part you needed, as long as the method removes the icon put this in the prayerDraining method

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 04-04-2013, 01:44 AM
  2. turmoil not turning off when dead
    By mike623030 in forum Help
    Replies: 2
    Last Post: 07-18-2011, 04:47 PM
  3. [PI/SS] Turn Prayers off when teleing [2$]
    By HiImRusty in forum Help
    Replies: 1
    Last Post: 11-28-2010, 07:48 PM
  4. Replies: 18
    Last Post: 08-10-2010, 11:52 AM
  5. headicons dont turn off when skulled
    By Rigged in forum Help
    Replies: 1
    Last Post: 08-16-2009, 10:49 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •