Some1Sneakin
New Member
- Reaction score
- 5
I just did my first trigger in jass. Its supossed to be a spell that shoots a bullet in a targeted location. And if it hits it dissapears. But theres a problem. I need to check if it hits your own units or enemy units. So i did a trigger that looked like this:
And converted that to custom text and got:
I added that to the code but then it didnt work to run the code.
I get this error: Expected a function name!
Any ideas why?
If you're intressted, my whple trigger looks like this:
Code:
Set X = Get Units in Range Matching Condition: Units within 200 of "Bullet" matching ((Owner of Matching Unit) not equal to (Triggering Player))
And converted that to custom text and got:
Code:
GetUnitsInRangeOfLocMatching(200.00, GetUnitLoc(bullet), Condition(function Trig_Cannon_Func001002003))
I added that to the code but then it didnt work to run the code.
I get this error: Expected a function name!
Any ideas why?
If you're intressted, my whple trigger looks like this:
Code:
function Trig_Cannon_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A006' ) ) then
return false
endif
return true
endfunction
function Trig_Cannon_Actions takes nothing returns nothing
local integer time
local location target
local location caster_loc
local unit caster
local unit bullet
local real angle
local boolean hit
local location slide
local unit victim
local group hitarea
local integer hitarea_count
set caster = GetTriggerUnit ()
set caster_loc = GetUnitLoc (caster)
set target = GetSpellTargetLoc ()
set angle = AngleBetweenPoints(caster_loc, target)
call CreateUnitAtLoc (GetTriggerPlayer (), 'h001', GetUnitLoc(caster), bj_UNIT_FACING)
set bullet = GetLastCreatedUnit ()
call SetUnitFacingToFaceLocTimed (bullet, target, 0)
set time = 40
loop
exitwhen hit == true
set time = time - 1
set slide = PolarProjectionBJ (GetUnitLoc (bullet), 50, angle)
call SetUnitPositionLoc( bullet, slide )
if time == 0 then
set hit = true
endif
set hitarea = GetUnitsInRangeOfLocMatching(200.00, GetUnitLoc(bullet), Condition(function Trig_Cannon_Func001002003))
set hitarea_count = CountUnitsInGroup (hitarea)
if hitarea_count > 0 then
set victim = GroupPickRandomUnit (hitarea)
call UnitDamageTargetBJ(caster, victim, 100, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
set hit = true
endif
call TriggerSleepAction (0.05)
endloop
call RemoveUnit (bullet)
call RemoveLocation (target)
call RemoveLocation (caster_loc)
endfunction
//===========================================================================
function InitTrig_Cannon takes nothing returns nothing
set gg_trg_Cannon = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Cannon, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Cannon, Condition( function Trig_Cannon_Conditions ) )
call TriggerAddAction( gg_trg_Cannon, function Trig_Cannon_Actions )
endfunction