GFreak45
I didnt slap you, i high 5'd your face.
- Reaction score
- 130
i made a custom function that is all custom text, and this is what i put in it:
first of all, would this work in jass with the proper substitutions?
second of all, will this work in sc2 to store a unit and get a integer back from the unit and visa-versa, then recycle them 60 seconds after they die if they are still dead?
PS. if you would like to use this as a resource you can use:
JASS:
struct AdvancedIndexing
unit Index_Unit
endstruct
//below is the function you call to get the unit from an index
library AdvancedIndexLib
function GetUnitIndex takes integer i returns unit
return udg_Indexed_Unit = i.Index_Unit
endfucntion
endlibrary
//below are the triggers saving units and refreshing them
scope
private function Actions1 takes nothing returns nothing
local AdvancedIndexing t = AdvancedIndexing.create
set t.Index = EventUnit//like GetTriggerUnit
endfunction
private function Actions2 takes nothing returns nothing
call Wait(60.0, c_timeReal)
if ((UnitIsAlive(EventUnit)), ==, false)
call UnitGetCustomValue((EventUnit()), 0).destroy//destroys this unit's instance of the struct
call UnitSetCustomValue((EventUnit()), 0, 0.0)//sets the custom value of the unit to 0 again
endif
endfunction
private function Conditions1 takes nothing returns bool//condition for checking if a unit is already saved
if ((UnitGetCustomValue((EventUnit()), 0)), ==, 0.0)), ==, true)//custom value = 0 condition
return true
endif
return false
endfunction
private function Conditions2 takes nothing returns bool//conditions for removing non-hero units
if ((UnitTypeTestFlag((UnitGetType((EventUnit()))), c_unitFlagHero)), ==, false)//unit is a hero condition
return true
endif
return false
endfunction
function OnInit takes nothing returns nothing
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
call TriggerAddEventUnitRegion(t1, (RegionEntireMap()), true)//event: any unit enters playable map area
call TriggerAddCondition(t1, Filter(function Conditions1))
call TriggerAddAction(t1, Actions1)
call TriggerAddEventUnitDied(t2, null)//event: any unit dies
call TriggerAddCondition(t2, Filter(function Conditions2)
call TriggerAddAction(t2, function Actions2)
endfunction
endscope
first of all, would this work in jass with the proper substitutions?
second of all, will this work in sc2 to store a unit and get a integer back from the unit and visa-versa, then recycle them 60 seconds after they die if they are still dead?
PS. if you would like to use this as a resource you can use:
Trigger:
- Custom Script: set udg_(your variables code) = GetUnitIndex(whatever number you are using)