public void heroFlee() { //calculate flee chance Damage = HeroCurAGI + (targetControl.Enemy1Data.enemyCurAGI + targetControl.Enemy2Data.enemyCurAGI + targetControl.Enemy3Data.enemyCurAGI + targetControl.Enemy4Data.enemyCurAGI) / 4; DamageMultiplier = Random.Range(0, Damage); if (DamageMultiplier < HeroCurAGI) { //Flee successful UIdetails.ActionPanel.SetActive(false); targetControl.ChatBox.text = targetControl.HeroData.name + " fleed successfully!"; targetControl.Flee(); } else { //Flee unsuccessful UIdetails.ActionPanel.SetActive(false); targetControl.ChatBox.text = targetControl.HeroData.name + " fleed successfully!"; targetControl.StateControl(); Invoke("Delay", 1); } }