User Tools

Site Tools


lua:scripting:examples:findtargets

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
lua:scripting:examples:findtargets [2024/07/04 21:34] astarklua:scripting:examples:findtargets [2024/07/04 21:36] (current) astark
Line 32: Line 32:
  
 </code> </code>
 +
 ====== Using the targets ====== ====== Using the targets ======
 +
 +FIrst we call the 'getTarget()' function to assign our targets. We set variables to find the % of HP our target and healers have. We re-target occasionally (rand 20) to ensure that we're fighting the desired target, and that they weren't rescud by someone else. Last, we have some fighting logic to determine which abilities to use and when.
 +
 +<code lua>
 +getTargets()
 +
 +if target then
 +  targetHp = target.hp / target.maxhp * 100
 +end
 +
 +if healer then
 +  healerHp = healer.hp / healer.maxhp * 100
 +end
 +
 +-- Re-target in case of rescue
 +if rand(20) and not(target == nil) then
 +  mdo("kill "..target.name)
 +end
 +
 +if targetHp <20 or healerHp <20 then
 +  mdo("shield "..healer.name)
 +  mdo("shield "..third.name)
 +  lag = lag + 2
 +  return
 +elseif targetHp <90 then
 +  mdo("fatal "..target.name)
 +end
 +
 +</code>
  
  
lua/scripting/examples/findtargets.txt · Last modified: 2024/07/04 21:36 by astark