//======SETUP (STUFF YOU CAN CHANGE)========
function Trig_flashbang_Radius takes integer spellLevel returns real
//this is the flash effect radius, depending on the ability level
return 300.0 + 200*spellLevel
endfunction
function Trig_flashbang_Duration takes integer spellLevel returns real
//this calculates the duration
return 2.0*spellLevel
endfunction
function Trig_flashbang_AbilityId takes nothing returns integer
//replace AHtb with the raw code of your flashbang spell.
//to find the raw code value, go to object editor, click the view tab, and click "display values as raw data."
//you should now see the raw values next to the names of everything
return 'AHtb'
endfunction
//=======CONDITIONS===========
function Trig_flashbang_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == Trig_flashbang_AbilityId() )
endfunction
//========ACTIONS==============
//put this next function in your map header if you want to use it outside this trigger
function CinematicFadeForPlayer takes player whichPlayer, integer fadetype, real duration, string tex, real red, real green, real blue, real trans returns nothing
if(GetLocalPlayer() == whichPlayer)then
call CinematicFadeBJ(fadetype, duration, tex, red, green, blue, trans)
endif
endfunction
function Trig_flashbang_filter takes nothing returns boolean
return ( IsPlayerEnemy( GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(GetTriggerUnit()) ) )
endfunction
function Trig_flashbang_ForGroupActions takes nothing returns nothing
local player owningPlayer = GetOwningPlayer(GetEnumUnit())
call CinematicFadeForPlayer(owningPlayer, bj_CINEFADETYPE_FADEOUT, .1, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100, 100, 100, 0)
endfunction
function Trig_flashbang_ForGroupActions2 takes nothing returns nothing
local player owningPlayer = GetOwningPlayer(GetEnumUnit())
call CinematicFadeForPlayer(owningPlayer, bj_CINEFADETYPE_FADEIN, Trig_flashbang_Duration( GetUnitAbilityLevel(GetTriggerUnit(), Trig_flashbang_AbilityId()) )/2, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100, 100, 100, 0)
endfunction
function Trig_flashbang_Actions takes nothing returns nothing
local integer skillLevel = GetUnitAbilityLevel(GetTriggerUnit(), Trig_flashbang_AbilityId())
local unit target = GetSpellTargetUnit()
local real targetX = GetUnitX(target)
local real targetY = GetUnitY(target)
local group affectedUnits = CreateGroup()
call GroupEnumUnitsInRange(affectedUnits, targetX, targetY, Trig_flashbang_Radius(skillLevel), Condition(function Trig_flashbang_filter))
call ForGroup(affectedUnits, function Trig_flashbang_ForGroupActions )
//this next line is a bad function to use, but the alternative method is too much work without using JassNewGenPack (vJass)
call TriggerSleepAction ( .1+Trig_flashbang_Duration(skillLevel)/2 )
call ForGroup(affectedUnits, function Trig_flashbang_ForGroupActions2 )
call DestroyGroup(affectedUnits)
set affectedUnits = null
set target = null
endfunction
//========EVENTS==============
function InitTrig_flashbang takes nothing returns nothing
set gg_trg_flashbang = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_flashbang, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_flashbang, Condition( function Trig_flashbang_Conditions ) )
call TriggerAddAction( gg_trg_flashbang, function Trig_flashbang_Actions )
endfunction