GFreak45
I didnt slap you, i high 5'd your face.
- Reaction score
- 130
Fixed.
also, something nice for you
JASS:
function SS_SetSettings takes nothing returns nothing
set udg_SS_ABIL_ID = 039;A000039; //the id for the ability
set udg_SS_DUMMY_ID = 039;hfoo039; //dummy unit used to cast the ability to bounce
set udg_SS_BUFF_ID = 039;A000039; //the id for the buff that the ability applies
set udg_SS_CAST_STRING = "" //put the cast string inside the ""s (if you dont know it, search the order string of the base ability)
set udg_SS_RADIUS = 500 //distance targets can be from the unit
set udg_SS_FREQUENCY = 0.5 //interval in seconds that it shocks units around it
endfunction
function SS_PERIODIC takes nothing returns nothing
local integer this = udg_SS_NEXT[0]
local unit u
local unit a
local real x
local real y
loop
exitwhen 0 == this
set u = udg_GUI_UI_IndexUnit[this] //<----- replace whichUnit with the variable holding the units for each index
if 0 < GetUnitAbilityLevel(u, udg_SS_BUFF_ID) then
set x = GetUnitX(u)
set y = GetUnitY(u)
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, udg_SS_RADIUS, null)
loop
set a = FirstOfGroup(bj_lastCreatedGroup)
exitwhen a == null
if IsUnitAlly(a, GetOwningPlayer(u)) and IsUnitType(a, UNIT_TYPE_HERO) then
call CreateUnit(udg_SS_CASTER[this], udg_SS_DUMMY_ID, x, y, 0)
call UnitApplyTimedLife(bj_lastCreatedUnit, udg_SS_BUFF_ID, 3.00)
call IssueTargetOrder(bj_lastCreatedUnit, udg_SS_CAST_STRING, a)
endif
call GroupRemoveUnit(bj_lastCreatedGroup, a)
endloop
set this = udg_SS_NEXT[this]
else
set this = udg_SS_NEXT[this]
set udg_SS_SHOCKED[udg_SS_PREV[this]] = false
set udg_SS_NEXT[udg_SS_PREV[udg_SS_PREV[this]]] = this
set udg_SS_PREV[this] = udg_SS_PREV[udg_SS_PREV[this]]
if 0 == udg_SS_NEXT[0] then
call PauseTimer(udg_SS_TIMER)
set udg_SS_PAUSED = true
endif
endif
endloop
set u = null
endfunction
function SS_OnCast takes nothing returns boolean
local integer this = GetUnitUserData(GetTriggerUnit())
if GetSpellAbilityId() == udg_SS_ABIL_ID then
if not udg_SS_PAUSED then
call TimerStart(udg_SS_TIMER, udg_SS_FREQUENCY, true, function SS_PERIODIC)
set udg_SS_PAUSED = false
endif
if not udg_SS_SHOCKED[this] then
set udg_SS_NEXT[this] = 0
set udg_SS_PREV[this] = udg_SS_PREV[0]
set udg_SS_NEXT[udg_SS_PREV[0]] = this
set udg_SS_PREV[0] = this
set udg_SS_SHOCKED[this] = true
endif
set udg_SS_CASTER[this] = GetOwningPlayer(GetTriggerUnit())
endif
return false
endfunction
function InitTrig_StaticShock takes nothing returns nothing
local trigger t = CreateTrigger()
call SS_SetSettings()
set udg_SS_TIMER = CreateTimer()
call TriggerAddCondition(t, Filter(function SS_OnCast))
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
set udg_SS_TIMER = CreateTimer()
call TimerStart(udg_SS_TIMER, udg_SS_FREQUENCY, true, function SS_PERIODIC)
set t = null
endfunction
also, something nice for you
JASS:
// GUI Unit Indexing v1.00
// by G_Freak45
//
// Requires:
//
// -Some GUI knowledge and the attention span to read the "How to"
//
// How to:
//
// Implementation:
//
// -Create a new trigger named "GUIUnitIndexing"
// -Copy and paste this code in there, deleting what is inside
// -Create the unit array variable using an array size of 8191 named "GUI_UI_IndexUnit"
// -Create the integer array variable using an array size of 8191 named "GUI_UI_Recycle"
// -Create the integer variable named "GUI_UI_ListSize"
// -Create the real variable named "GUI_UI_Event_Enter_Map"
// -Create the real variable named "GUI_UI_Event_Decay"
// -Create the unit variable named "GUI_UI_Triggering_Unit"
//
// Using the system:
//
// -The system automatically assigns integers to units that enter the map.
// -Custom value of a unit is it's assigned integer
// -GUI_UI_IndexUnit[number] is the unit for the number selected
// -Replace the event "A unit enters the map" with "Game - GUI_UI_Event_Enter_Map becomes equal to 0.00"
// -The event "Game - GUI_UI_Event_Decay becomes equal to 0.00" refers to when a unit is about to be
// deallocated, this is so that you can get any information on the unit before it is removed
// NOTE: this must only be used with instant triggers, the unit and integer are lost after 0.01 seconds
// -GUI_UI_Triggering_Unit refers to the unit that just entered the map or is being deallocated for
// the above events
//
//============================================================================
//=========================== CONFIGURABLE OPTIONS ===========================
//============================================================================
function GUI_UI_Index_Filter takes nothing returns boolean
return GetUnitAbilityLevel(GetFilterUnit(), 039;Aloc039;) <= 0
//replace this^ line with "return true" if you want to index locusted units
endfunction
function GUI_UI_Deallocate_Filter takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_HERO)
//replace this^ line with "return true" if you want to de-index decaying heroes
endfunction
//============================================================================
//========================= END CONFIGURABLE OPTIONS =========================
//============================================================================
function GUI_UI_Deallocate takes integer this returns boolean
if GUI_UI_Deallocate_Filter(udg_GUI_UI_IndexUnit[this]) then
set udg_GUI_UI_Triggering_Unit = udg_GUI_UI_IndexUnit[this]
set udg_GUI_UI_Event_Decay = 1
set udg_GUI_UI_Event_Decay = 0
call TriggerSleepAction(0.01)
call SetUnitUserData(udg_GUI_UI_IndexUnit[this], 0)
set udg_GUI_UI_Recycle[this] = udg_GUI_UI_Recycle[0]
set udg_GUI_UI_Recycle[0] = this
endif
return false
endfunction
function GUI_UI_Allocate takes nothing returns boolean
local integer i = udg_GUI_UI_Recycle[0]
local unit u = GetTriggerUnit()
if GetUnitUserData(u) != 0 then
if 0 == i then
set udg_GUI_UI_ListSize = udg_GUI_UI_ListSize + 1
call SetUnitUserData(u, udg_GUI_UI_ListSize)
else
call SetUnitUserData(u, udg_GUI_UI_Recycle[0])
set udg_GUI_UI_Recycle[0] = udg_GUI_UI_Recycle[udg_GUI_UI_Recycle[0]]
endif
set udg_GUI_UI_Triggering_Unit = u
set udg_GUI_UI_Event_Enter_Map = 1
set udg_GUI_UI_Event_Enter_Map = 0
endif
set u = null
return false
endfunction
function InitTrig_GUIUnitIndexing takes nothing returns nothing
local trigger t = CreateTrigger()
local region r = CreateRegion()
call RegionAddRect(r, GetWorldBounds())
call TriggerAddCondition(t, Filter(function GUI_UI_Allocate))
call TriggerRegisterEnterRegion(t, r, Filter(function GUI_UI_Index_Filter))
set t = CreateTrigger()
call TriggerAddCondition(t, Filter(function GUI_UI_Deallocate))
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DECAY)
set t = null
set r = null
endfunction