Ai that applies damage when in range?

Hi, I'm making a FPS based from the FPS tutorial and has made a basic ai that follows me and maintains a constant distance between it and the character. Does anyone has an idea on how to make the Ai apply damage over time if it is in range with the player? I'm a total noob on scripting and just need a rough guideline to continue it...thanks!

the best way IMO : you gonna need a trigger that will be attached on your enemy. Use the OnTriggerStay function, if statement the object in it have the tag "Player", (set your player object to have that tag) if it does, use SendMessage to call a damage function in your player(this damage function can be found in scripts like CharacterDamage in the FPS tutorial). Now you have it sending the damage. All you gotta do then is limit how often the if statement should be read (example on the rocket launcher script in the FPS tutorial for this). that is, make 2 float variables, one called dmgFrequency and another called hitTime. your if statement gonna end like this

if(col.gameObject.tag ==("player") && hitTime+dmgFrequency < Time.time){

  <p>col.SendMessage("ApplyDamage", 1);</p>
  <p>hitTime= Time.time;</p>


being col the variable that is in contact with the trigger.