- Joined
- Jun 5, 2008
- Messages
- 2,573
Couldn't you just use Warden's Fan of Knives spell and modify the missile art and max target number (i think there is such a field)?
/*****************************************************************************
*
* Get Closest Widget (light version)
* by Spinnaker v2.0.0.0
*
* Special thanks to Troll-Brain
*
******************************************************************************
*
* This snippet contains several functions which returns closest
* widget to given coordinates and passed filter.
*
******************************************************************************
*
* Important:
* Performance drop depends on amount of units currently on the map
* Snippet functions are designed to reduce the search time as much as
* posible, although it's recommended to use non specific functions
* wisely, especialy if your map contains large numbers of units.
*
******************************************************************************
*
* Functions:
* function GetClosestUnit takes real x, real y, boolexpr filter returns unit
* - Returns closest unit matching specific filter
* function GetClosestUnitInRange takes real x, real y, real radius, boolexpr filter returns unit
* - Gets nearest unit in range matching specific filter
* function GetClosestUnitInGroup takes real x, real y, group g returns unit
* - Retrieves closest unit in given group
*
* function GetClosestNUnitsInRange takes real x, real y, real radius, integer n, group g, boolexpr filter returns nothing
* - Returns up to N nearest units in range of passed coordinates
* function GetClosestNUnitsInGroup takes real x, real y, integer n, group sourceGroup, group destGroup returns nothing
* - Retrieves up to N closest units in passed group
*
*****************************************************************************/
function InitTrig_GetClosestWidget takes nothing returns nothing
endfunction
library GetClosestWidget
private keyword Init
globals
private unit array Q
private real array V
private integer C=0
endglobals
struct ClosestWidget extends array
readonly static real distance=0
readonly static real cX=0
readonly static real cY=0
readonly static unit cUnit=null
static method resetData takes real x, real y returns nothing
set distance=100000
set cUnit=null
set cX=x
set cY=y
endmethod
static method enumUnits takes nothing returns nothing
local unit u=GetEnumUnit()
local real dx=GetUnitX(u)-cX
local real dy=GetUnitY(u)-cY
set dx=(dx*dx+dy*dy)/10000.
if dx<distance then
set cUnit=u
set distance=dx
endif
set u=null
endmethod
static method sortUnits takes integer l, integer r returns nothing
local integer i=l
local integer j=r
local real v=V[(l+r)/2]
loop
loop
exitwhen V[i]>=v
set i=i+1
endloop
loop
exitwhen V[j]<=v
set j=j-1
endloop
if i<=j then
set V[0]=V[i]
set V[i]=V[j]
set V[j]=V[0]
set Q[0]=Q[i]
set Q[i]=Q[j]
set Q[j]=Q[0]
set i=i+1
set j=j-1
endif
exitwhen i>j
endloop
if l<j then
call sortUnits(l,j)
endif
if r>i then
call sortUnits(i,r)
endif
endmethod
static method saveGroup takes nothing returns nothing
local real dx
local real dy
set C=C+1
set Q[C]=GetEnumUnit()
set dx=GetUnitX(Q[C])-cX
set dy=GetUnitY(Q[C])-cY
set V[C]=(dx*dx+dy*dy)/10000.
endmethod
endstruct
function GetClosestUnit takes real x, real y, boolexpr filter returns unit
local real r=800.
call ClosestWidget.resetData(x,y)
loop
if r>3200. then
call GroupEnumUnitsInRect(bj_lastCreatedGroup, bj_mapInitialPlayableArea, filter)
exitwhen true
else
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, r, filter)
exitwhen FirstOfGroup(bj_lastCreatedGroup)!=null
endif
set r=2*r
endloop
call ForGroup(bj_lastCreatedGroup, function ClosestWidget.enumUnits)
return ClosestWidget.cUnit
endfunction
function GetClosestUnitInRange takes real x, real y, real radius, boolexpr filter returns unit
call ClosestWidget.resetData(x,y)
if radius>=0 then
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, radius, filter)
call ForGroup(bj_lastCreatedGroup, function ClosestWidget.enumUnits)
endif
return ClosestWidget.cUnit
endfunction
function GetClosestUnitInGroup takes real x, real y, group g returns unit
call ClosestWidget.resetData(x,y)
call ForGroup(g, function ClosestWidget.enumUnits)
return ClosestWidget.cUnit
endfunction
function GetClosestNUnitsInRange takes real x, real y, real radius, integer n, group g, boolexpr filter returns nothing
local integer q=n+1
call ClosestWidget.resetData(x,y)
if radius>=0 then
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, radius, filter)
call ForGroup(bj_lastCreatedGroup, function ClosestWidget.saveGroup)
call ClosestWidget.sortUnits(1,C)
loop
exitwhen n==0 or Q[-n+q]==null
call GroupAddUnit(g, Q[-n+q])
set n =n-1
endloop
endif
set C=0
endfunction
function GetClosestNUnitsInGroup takes real x, real y, integer n, group sourceGroup, group destGroup returns nothing
local integer q=n+1
call ClosestWidget.resetData(x,y)
call ForGroup(sourceGroup, function ClosestWidget.saveGroup)
call ClosestWidget.sortUnits(1,C)
loop
exitwhen n==0 or Q[-n+q]==null
call GroupAddUnit(destGroup, Q[-n+q])
set n=n-1
endloop
set C=0
endfunction
endlibrary
ffunction TripleShot_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00K' // Your TripleShot Ability Raw ID
endfunction
function TripleShot_GroupActions takes nothing returns nothing
local unit u = CreateUnit(GetTriggerPlayer(), 'h00C', GetUnitX(udg_Unit), GetUnitY(udg_Unit), 0) // The Dummy
call IssueTargetOrder(u, "firebolt", GetEnumUnit()) // Dummy order Firebolt Picked Unit
call UnitApplyTimedLife(u, 'BTLF', 1.00) // Generic Expiration Timer
call GroupRemoveUnit(udg_NearUnits, GetEnumUnit()) // Removing the target from the group
set u = null
endfunction
function TripleShot_Filter takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetTriggerPlayer()) and GetWidgetLife(GetFilterUnit()) > 0.405 // The Condition for units to pick
endfunction
function TripleShot_Actions takes nothing returns nothing
set udg_Unit = GetTriggerUnit() // The triggering unit
call GetClosestNUnitsInRange(GetUnitX(udg_Unit), GetUnitY(udg_Unit), 400, 3, udg_NearUnits, Condition(function TripleShot_Filter)) // Getting Closest Units
call ForGroup( udg_NearUnits, function TripleShot_GroupActions ) // Calling the Group Actions
endfunction
//===========================================================================
function InitTrig_Triple_shot takes nothing returns nothing
set gg_trg_Triple_shot = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Triple_shot, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Triple_shot, Condition( function TripleShot_Conditions ) )
call TriggerAddAction( gg_trg_Triple_shot, function TripleShot_Actions )
endfunction
GetClosestWidget
function TripleShot_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00K' // Your TripleShot Ability Raw ID
endfunction
function TripleShot_GroupActions takes nothing returns nothing
local unit u = CreateUnit(GetTriggerPlayer(), 'h00C', GetUnitX(udg_Unit), GetUnitY(udg_Unit), 0) // The Dummy
call IssueTargetOrder(u, "firebolt", GetEnumUnit()) // Dummy order Firebolt Picked Unit
call UnitApplyTimedLife(u, 'BTLF', 1.00) // Generic Expiration Timer
call GroupRemoveUnit(udg_NearUnits, GetEnumUnit()) // Removing the target from the group
set u = null
endfunction
function TripleShot_Filter takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetTriggerPlayer()) and GetWidgetLife(GetFilterUnit()) > 0.405 // The Condition for units to pick
endfunction
function TripleShot_Actions takes nothing returns nothing
set udg_Unit = GetTriggerUnit() // The triggering unit
call GetClosestNUnitsInRange(GetUnitX(udg_Unit), GetUnitY(udg_Unit), 400, 3, udg_NearUnits, Condition(function TripleShot_Filter)) // Getting Closest Units
call ForGroup( udg_NearUnits, function TripleShot_GroupActions ) // Calling the Group Actions
endfunction
//===========================================================================
function InitTrig_Triple_Shot takes nothing returns nothing
set gg_trg_Triple_Shot = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Triple_Shot, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Triple_Shot, Condition( function TripleShot_Conditions ) )
call TriggerAddAction( gg_trg_Triple_Shot, function TripleShot_Actions )
endfunction
ffunction TripleShot_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00K' // Your TripleShot Ability Raw ID
endfunction
function TripleShot_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00K' // Your TripleShot Ability Raw ID
endfunction
-ahh thx'A00K' is the Raw ID of your TripleShot ability.
Not really... You should focus on fixing your JNPG so it allows all the vJASS and JASS things![]()
And how's that works for the three nearest targets?