SineCosine
I'm still looking for my Tangent
- Reaction score
- 77
Well, I've got this unit called a Felhound.
The felhounds are enemy units that have this ability called 'pounce' (Base ID 'channel')
This AI trigger I was working on selects all felhounds on the map,
checks if they have a certain buff and, if they don't have the buff, orders the felhounds to pounce on any enemy unit that is within 1000.00 range of the felhounds.
This trigger works.
But is buggy.
01) Most of the time, when the felhounds picked can cast their pounce skill, the trigger still does not tell them to cast it.
02) The trigger makes them pounce on the same unit when they are supposed to target separate units, or don't target anything at all (If there aren't any suitable targets nearby)
Yea, I need help with AI, I've never done AI before, lol
The felhounds are enemy units that have this ability called 'pounce' (Base ID 'channel')
This AI trigger I was working on selects all felhounds on the map,
checks if they have a certain buff and, if they don't have the buff, orders the felhounds to pounce on any enemy unit that is within 1000.00 range of the felhounds.
This trigger works.
But is buggy.
01) Most of the time, when the felhounds picked can cast their pounce skill, the trigger still does not tell them to cast it.
02) The trigger makes them pounce on the same unit when they are supposed to target separate units, or don't target anything at all (If there aren't any suitable targets nearby)
Yea, I need help with AI, I've never done AI before, lol
JASS:
scope PounceAI initializer PAI
globals
private constant integer FelhoundId = 039;nfel039;
private constant real AoEDetect = 1000.00
endglobals
struct Fel
private static Fel data = 0
private static Fel data2 = 0
player p
unit FH
group Jump
group Jump2
static method PounceCheck takes nothing returns boolean
local Fel f = Fel.data2
local unit u = GetFilterUnit()
if IsUnitEnemy(u, f.p) == true and GetWidgetLife(u) > 0 and GetUnitAbilityLevel(u, 039;B00C039;) == 0 and IsUnitInGroup(u, f.Jump2) == false then
call IssueTargetOrder(f.FH, "channel", u)
call GroupAddUnit(f.Jump2, u)
endif
set u = null
return false
endmethod
static method AreYouFelHound takes nothing returns boolean
local Fel f = Fel.data
local unit u = GetFilterUnit()
if GetUnitTypeId(u) == FelhoundId and IsUnitInGroup(u, f.Jump) == false then
set f.p = GetOwningPlayer(u)
set f.FH = u
set Fel.data2 = f
call GroupEnumUnitsInRange(GROUP2, GetUnitX(u), GetUnitY(u), AoEDetect, function Fel.PounceCheck)
call GroupAddUnit(f.Jump, u)
endif
set u = null
return false
endmethod
static method PAIAct takes nothing returns nothing
local Fel f = Fel.allocate()
set f.Jump = CreateGroup()
set f.Jump2 = CreateGroup()
set Fel.data = f
call GroupEnumUnitsInRange(GROUP, 0, 0, 9999999.0, function Fel.AreYouFelHound)
call f.destroy()
endmethod
method onDestroy takes nothing returns nothing
set .p = null
set .FH = null
call GroupClear(.Jump)
call DestroyGroup(.Jump)
set .Jump = null
call GroupClear(.Jump2)
call DestroyGroup(.Jump2)
set .Jump2 = null
endmethod
endstruct
private function PAI takes nothing returns nothing
local timer t = CreateTimer()
call TimerStart(t, 1.00, true, function Fel.PAIAct)
set t = null
endfunction
endscope