Hello,
I've been having difficulty the last few days with a small bit of code that I can't figure out how to get working.
Basically, I have an int called status_player_dmgoutput that I use as percentage (see code). I want to use that to multiply the result (for example 0.5 if its 50) with the int hp_change to get the change I need to add to the last recorded hp.
What I currently am using is not working and old posts are not helping.
The part that is not working is
/**
* damageEnemy - Remove (int value) amount of HP from the enemy.
* Entering a value that causes the enemy to hit 0 or less will cause a win
*/
public void damageEnemy(int hp_change)
{
//Setworld for code
L2Battle l2battle = (L2Battle)getWorld();
World world = getWorld();
double hp_change_ws = hp_change * (status_player_dmgoutput/100);
int hp_change_ws1 = (int) hp_change_ws;
enemyHP = enemyHP - hp_change_ws1;
if(enemyHP < 0)
{
enemyHP = 0;
}
//Execute change
Greenfoot.delay(5);
List<Actor> actors = (List) world.getObjects(RPG_HealthSystem_Enemy.class);
List<Actor> actors2 = (List) world.getObjects(BarInfo_Enemy.class);
world.removeObjects(actors);
world.removeObjects(actors2);
world.addObject(new RPG_HealthSystem_Enemy(enemyHP), 93, 107);
world.addObject(new BarInfo_Enemy(enemyHP, enemyHP_MAX, enemyLVL), 132, 133);
if(enemyHP == 0)
{
gameWin();
}
}double hp_change_ws = hp_change * (status_player_dmgoutput/100);
int hp_change_ws1 = (int) hp_change_ws;
enemyHP = enemyHP - hp_change_ws1;


