(2 ratings)
Unit Indexer |
v5.3.0.1 by Nestharus | |
__ |
Unit Indexer is a next gen unit indexing system that uses a variety of modern JASS techniques to improve performance and enable cool new features. It is unlike any other unit indexing system out there. The system includes three different types of modules with varying levels of support, ranging from the simplest classic style module to the newest and most complex module. All modules are adaptive and will only include features when those features are used. The classic Unit Indexer system is also included. | |
Features | ||
Powerful EventsIn-Depth Tutorial With Labs
There are 8 tutorials and 15 labs that cover all of the features of Unit Indexer. There is also a quick installation tutorial and all required resources are included in the map. Furthermore, the installation tutorial shows two ways of installing the system into a map. | ||
Additional Information | ||
Change Logv5.xComplete revamp of the entire Unit Indexer system. ____________________________________________________________________________________________________ | ||
. |
Known Issues |
An upload by Nestharus? o.o
Can ye upload the code here?
I dont want to sound like plain hater, but if you need to provide 15 labs to show how to use something as simple as Unit Indexer, there is something wrong
GetUnitUserData
hehehe, but I'd cry if that's all anyone ever did : (this system is very useful,, like
Oh okay.
Set/GetUnitUserData
?library UnitEvent uses Event, Trigger, Init, Type, GroupUtils
globals
constant real HIT_POINT_VERYLOW_PERCENT = 0.1
constant real HIT_POINT_LOW_PERCENT = 0.2
constant real HIT_POINT_MEDIUM_PERCENT = 0.5
constant real HIT_POINT_HIGH_PERCENT = 0.8
endglobals
native UnitAlive takes unit u returns boolean
struct UnitEvent extends array
static Event ENTER_COMBAT
static Event LEAVE_COMBAT
static real LOOP_PERIOD = 0.03125
static unit TriggerUnit
static TypeReal CombatTimer
static real CombatDuration = 5
static timer MainTimer = CreateTimer()
static group CombatGroup
implement GlobalUnitIndex
implement DDS
private method onDamage takes nothing returns nothing
set TriggerUnit = unit
call BJDebugMsg(GetUnitName(unit) + " enter combat!")
if CombatTimer[this] > 0 then
set CombatTimer[this] = CombatDuration
else
call ENTER_COMBAT.fire()
endif
endmethod
private static method onEnumGroup takes nothing returns nothing
local unit enumUnit = GetEnumUnit()
local thistype this = thistype[enumUnit]
if UnitAlive(enumUnit) then
if CombatTimer[this] > 0 then
set CombatTimer[this] = CombatTimer[this] - LOOP_PERIOD
else
set CombatTimer[this] = 0
set TriggerUnit = enumUnit
call LEAVE_COMBAT.fire()
call GroupRemoveUnit(CombatGroup, enumUnit)
endif
endif
endmethod
private static method onLoop takes nothing returns nothing
call ForGroup(CombatGroup, function thistype.onEnumGroup)
endmethod
static method onInit takes nothing returns nothing
set ENTER_COMBAT = Event.create()
set LEAVE_COMBAT = Event.create()
set CombatTimer = TypeReal.create()
set CombatGroup = NewGroup()
call TimerStart(MainTimer, LOOP_PERIOD, true, function thistype.onLoop)
endmethod
endstruct
function IsUnitInCombat takes unit u returns boolean
return UnitEvent.CombatTimer[UnitEvent[u]] > 0
endfunction
function GetTriggerCombatUnit takes nothing returns unit
return UnitEvent.TriggerUnit
endfunction
function RegisterEnterCombatEvent takes boolexpr b returns nothing
call UnitEvent.ENTER_COMBAT.register(b)
endfunction
function RegisterLeaveCombatEvent takes boolexpr b returns nothing
call UnitEvent.LEAVE_COMBAT.register(b)
endfunction
endlibrary
Firstly, whenever there are callbacks, always implement modules at the bottom of the struct ; ).
As for DDS, right now it needs to be rewritten in the backend stuff because the health event doesn't work with very low health amounts. I need to find a good work around. The trigger just doesn't register the changes : \. I will fix it, not to worry ; ). I can certainly detect when the trigger isn't going to register damage. In those cases, I can probably use a timer safely because the damage will be so darn low.
This bug is likely the problem : (. I'll fix it, I promise : ).
I am happy that you decided to give my DDS a try though ^_-.
Some triggers are reversed. Some aren't. All of them return false ; ).
However, the bug with the very low health is still there, so be careful ; (.
Totally:I'll work on this stuff today =)
static method onInit takes nothing returns nothing
set ENTER_COMBAT = Event.create()
set LEAVE_COMBAT = Event.create()
call BJDebugMsg("test")
set CombatTimer = TypeReal.create()
set CombatGroup = CreateGroup()
call TimerStart(MainTimer, LOOP_PERIOD, true, function thistype.onLoop)
endmethod
call BJDebugMsg("test")
static method onInit takes nothing returns nothing
K. I'm waiting for youThis should be private
static method onInit takes nothing returns nothing
I'll be sure to look into Trigger/Event ^_-. Before I do anything, I need to update extremely core resources that they depend on. This will help with debugging and stuff.
So you didn't actually run into a bug with DDS then?