Still need help with this if anyone can
So far I've got this (please don't judge it's the first thing I've wrote in 3 years)
Code:
Item ring = player.getEquipment().getItems()[12];
int damage = player.getLastDamageDealt();
int heal = player.getSkill().getLevels()[3] + damage / 20;
if ((ring != null) && (ring.getId() == 2550)) {
if(player.getSkill().getLevels()[3] < heal){
player.getSkill().setLevel(3, heal);
player.getClient().queueOutgoingPacket(new SendMessage("@blu@Your ring vibrates; Healing you " + damage / 20));
}
}
It heals me; but it doesn't heal me for 20%.. it heals me for all the damage. and it won't stop healing at full health, it'll heal to around 120 then the npc one hits me any help would be great
EDIT: Fixed the healing % just need to stop healing if health is 99
EDIT2: Fixed both issues myself
If anyone was curious this is how I did it
Code:
Item ring = player.getEquipment().getItems()[12];
int damage = player.getLastDamageDealt();
int heal = player.getSkill().getLevels()[3] + damage / 3;
if ((ring != null) && (ring.getId() == 2550)) {
if(player.getSkill().getLevels()[3] >= 99){
player.getClient().queueOutgoingPacket(new SendMessage("@red@Your ring cannot heal at full health "));
} else
if(player.getSkill().getLevels()[3] < heal){
player.getSkill().setLevel(3, heal);
player.getClient().queueOutgoingPacket(new SendMessage("@blu@Your ring vibrates; You hit: " + damage + "@red@ healing you " + damage / 3));
}
}
If theres a better way of doing this or any feedback let me know
Many thanks