- Joined
- Jun 19, 2010
- Messages
- 49
im in a situation where i need to refer to a unit which i cant refer normally through any event responses. i want to know of ways how i can refer to it on a multiplayer map, so the solution must be multiinstanceable. gamecache isnt liked, because it is quite slow & do the natives "StoreUnit" & "RestoreUnit" even work in multiplayer? hashtables are limited to 256(?), so what can i use instead of them? in the following example i already show a possible solution, but unfortunately i already use the UnitUserData for another system...
here's also a never expiring link to pastebin where i originally wrote the code example.
JASS:
scope BuildTower initializer onInit
private function GridSimBuild takes nothing returns nothing
// HERE I NEED TO REFER TO ORIGINAL BUILDER UNIT "u_builder"
// BUT HOW???
// I COULD USE A STRUCT LIKE:
// private struct Data
// unit u
// endstruct
// & IN FUNC "Ability2Unit":
// local Data d = d.create()
// set d.u = u_builder
// call SetUnitUserData(u_dummyBuilder, d)
// & IN THIS FUNC ("GridSimBuild"):
// local Data d = Data(GetUnitUserData(GetTriggerUnit()))
// local unit u_YAY = d.u
// !!! BUT !!!
// I ALREADY USE THE UNITUSERDATA FOR ANOTHER SYSTEM,
// SO WHAT ELSE CAN I USE?
endfunction
private function Ability2Unit takes nothing returns nothing
local trigger tri
local unit u_builder = GetTriggerUnit()
local unit u_dummyBuilder
local player p = GetOwningPlayer(u_builder)
set u_dummyBuilder = CreateUnit( p, 'hpea', 0, 0, 0 )
set tri = CreateTrigger()
call TriggerRegisterUnitEvent( tri, u_dummyBuilder, EVENT_UNIT_ISSUED_POINT_ORDER )
call TriggerAddAction( tri, function GridSimBuild )
set tri = null
set p = null
set u_builder = null
set u_dummyBuilder = null
endfunction
private function onInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i_player
set i_player = 0
loop
exitwhen i_player > 11
call TriggerRegisterPlayerUnitEvent(t, Player(i_player), EVENT_PLAYER_UNIT_SPELL_CHANNEL, null)
set i_player = i_player+1
endloop
call TriggerAddAction(t, function Ability2Unit)
set t = null
endfunction
endscope
here's also a never expiring link to pastebin where i originally wrote the code example.