I feel like i've been asking a lot from you guys recently, but im trying to learn jass and so far these functions i wrote have no errors in them but i cannot figure out why it doesn't work. Here is what is suppost to happen in plain english, a few seconds into the game it will choose a target that is a random unit of all the units of 3 different types. It sets this to a variable, now when some super unit comes along, it will bascially order him to keep attacking the location of that unit until he dies. Once he dies, it willl run the findtarget function again to get a new one and chase that guy down until he dies. For testing purposes, i just created a gui trigger that sets the global unit that is doing the attacking to a preplaced unit ( in game it will be spawned towards the end of the game)
this is where it puts the units that it will potentially choose into a group, then choose a random one, and destroy the group. It willl be called in the first second of the game (testing purposes) and will also be called again when the unit it returns dies. (not made yet). Trigger to run this the first time
Now for the actual ordering part of this. Here is the trigger. It finds the location of the previously found target and orders the attacking unit to attack position of its target every few seconds. the udg_king is already defined through gui above for testing purposes
When i test it, i get no errors and it works. Now once im in game, nothing happens. Is there some really stupid mistake i made?
-
Debug
-
Events
- Time - Elapsed game time is 1.00 seconds
- Conditions
-
Actions
- Set king = |c00330033King Kodo 0035 <gen>
-
Events
JASS:
function FindTargetFilter takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == 'hmtt' or GetUnitTypeId(GetFilterUnit()) == 'h000' or GetUnitTypeId(GetFilterUnit()) == 'uC01'
endfunction
function settarget takes nothing returns unit
local group g = CreateGroup()
local unit u
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea,Filter(function FindTargetFilter))
set u = GroupPickRandomUnit(g)
set udg_Kingstar = u
set u = null
set g = null
return udg_Kingstar
endfunction
this is where it puts the units that it will potentially choose into a group, then choose a random one, and destroy the group. It willl be called in the first second of the game (testing purposes) and will also be called again when the unit it returns dies. (not made yet). Trigger to run this the first time
JASS:
function InitTrig_firsttarget takes nothing returns nothing
set gg_trg_firsttarget = CreateTrigger()
//call TriggerRegister__(gg_trg_NewTrigger, )
call TriggerRegisterTimerEventSingle( gg_trg_firsttarget , 3.00 )
call TriggerAddAction(gg_trg_firsttarget, function settarget)
endfunction
Now for the actual ordering part of this. Here is the trigger. It finds the location of the previously found target and orders the attacking unit to attack position of its target every few seconds. the udg_king is already defined through gui above for testing purposes
JASS:
function kingsattack takes nothing returns nothing
local location loc
set loc = GetUnitLoc(udg_Kingstar)
call IssuePointOrderLocBJ(udg_king , "attack" , loc )
call RemoveLocation(loc)
set loc = null
endfunction
function InitTrig_kingsai takes nothing returns nothing
set gg_trg_attacktrig = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_kingsai , 5.00 )
call TriggerAddAction( gg_trg_kingsai, function kingsattack )
endfunction
When i test it, i get no errors and it works. Now once im in game, nothing happens. Is there some really stupid mistake i made?