Im trying to add a random damage is delt when the Enemy attacks here is the code i have
onClipEvent (load)
{
var scale = this._xscale;
}
onClipEvent (enterFrame)
{
var distance = 150;
var tx = this._x;
var ty = this._y;
var sx = _root.content.window.hero._x;
var sy = _root.content.window.hero._y;
if (Math.sqrt((sx - tx) * (sx - tx) + (sy - ty) * (sy - ty)) < distance)
{
if (tx < sx)
{
this.gotoAndStop(3);
this._xscale = scale;
} // end if
if (tx > sx)
{
this.gotoAndStop(3);
this._xscale = -scale;
} // end if
} // end if
if (Math.sqrt((sx - tx) * (sx - tx) + (sy - ty) * (sy - ty)) > distance)
{
_root.content.window.enemy.gotoAndStop(1);
} // end if
if((_currentframe==3)and(this.hitTest(_root.content.window.hero))) {
_root.content.window.hp.health--
} // end if
}
As you can see _root.content.window.hp.health-- is only dealing -1 per hit the enemy makes Lets say i want the damage to be random and between 5-10 how would i do this?
Thanks in advance!