B
bte_lead
Guest
Right now, I am using this script to determine whether a character in a xcom-like RTS will be able to hit their target.
However, it doesn't work as I intended. The distance seems wonky, (the soldier can be a few pixels away with a 17% chance) and I am not sure what to do with the crouch modifier.
How would you improve/write this code?
Thanks
Ian
Code:
/// @function scrCalculateHitChance()
/// @description Returns the chance that the soldier will hit
/// @params Soldier
var s = argument0;
var distance = point_distance(s.x, s.y, s.target.x, s.target.y);
if(s.crouch){
distance = distance * (3/4);
}
if(200/distance * 100 < 99){
return 200/distance * 100;
}
else{
return 99;
}
How would you improve/write this code?
Thanks
Ian