- Joined
- May 11, 2008
- Messages
- 1,198
Nothing special, just dealing with Items of the "Powerup" type. Not sure if it's efficient or not, but it deals with memory leaks and that can't be a bad thing.
JASS:
scope powerupSENTINEL initializer I//by SanKakU, original made by Vexorian
//his version is not even vJASS and i changed some parts of it besides translating,
// but he had the right idea first//to quote him:
/* Powerup items don't get removed automatically by the game, they instead
just leave a small item in the map, this caused memory leaks but - worse -
it also makes areas of your map where a lot of tomes have been used lag a lot.*/
private function F takes nothing returns nothing
if GetWidgetLife(GetManipulatedItem()) == 0 then
call RemoveItem(GetManipulatedItem())
endif
endfunction
private function I takes nothing returns nothing
local trigger T = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( T, EVENT_PLAYER_UNIT_PICKUP_ITEM )//because it works on item pickup, it only works on modern style powerups that are immediately used instead of also the old ones which had to be clicked after picking them up to use them
call TriggerAddAction( T, function F)
endfunction
endscope
Last edited: