February 4, 201610 yr Checks if your health is above x%: private boolean healthAbovePercent(double p) { boolean flag = false; double dynamicLvl = getSkills().getDynamic(Skill.HITPOINTS); double staticLvl = getSkills().getStatic(Skill.HITPOINTS); if (dynamicLvl >= staticLvl * p) { flag = true; } return flag; } Note: don't flame I like to post basic snippets to help beginning scripters. Being able to search for simple snippets makes it easier to learn at the beginning. Edited February 4, 201610 yr by LoudPacks
March 13, 20169 yr Thanks, just getting into RS Script development myself and this kind of API specificity would have probably taken a couple of minutes to find. You could improve your code! No need to declare the flag variable. private boolean healthAbovePercent(double p) { double dynamicLvl = getSkills().getDynamic(Skill.HITPOINTS); double staticLvl = getSkills().getStatic(Skill.HITPOINTS); return dynamicLvl >= staticLvl * p; } Why not take it one step further? private boolean healthAbovePercent(double p) { return skillAbovePercent(Skill.Hitpoints); } private boolean skillAbovePercent(Skill skill, double p) { double dynamicLvl = getSkills().getDynamic(skill); double staticLvl = getSkills().getStatic(skill); return dynamicLvl >= staticLvl * p; } Edited March 13, 20169 yr by inlustra
Create an account or sign in to comment