emootootoo
Top Banana
- Reaction score
- 51
Not Working + Will it lag?
Hi, I've made an item cleanup system.
EDIT: OK, I fixed the trigger, it actually works now. (I commented the line with the fix)
Questions:
1) Will this trigger lag the game if there are a lot of items on the ground?
2) Resolved.
Brief Explanation: Removes any items that are on the ground after 40-60 seconds after being created on the map. If a hero picks up an item and puts it back on the ground, the item wont be removed.
Sets the struct
Every 20 seconds picks every item and sets a ItemTime +1 if the item hasn't been owned by a unit. When ItemTime is >2 it removes the item (i also want it to free up that struct value)
This one sets the item when a unit picks it up to being owned ( so that if an item has been picked up and dropped again it wont be removed ever), and if it hasnt already had the struct stuff attached to it it sets it up.
Hi, I've made an item cleanup system.
EDIT: OK, I fixed the trigger, it actually works now. (I commented the line with the fix)
Questions:
1) Will this trigger lag the game if there are a lot of items on the ground?
2) Resolved.
Brief Explanation: Removes any items that are on the ground after 40-60 seconds after being created on the map. If a hero picks up an item and puts it back on the ground, the item wont be removed.
Sets the struct
JASS:
Every 20 seconds picks every item and sets a ItemTime +1 if the item hasn't been owned by a unit. When ItemTime is >2 it removes the item (i also want it to free up that struct value)
JASS:
function Trig_Destroy_Items1 takes nothing returns nothing
local item i=GetEnumItem()
local itemData iD=itemData(GetItemUserData(i))
if IsItemOwned(i)!=true or iD.Owned!=true then //Fix: got rid of 'IsItemOwned(i)!=true or'
if iD.ItemTime>0 then
set iD.ItemTime=iD.ItemTime+1
if iD.ItemTime>2 then
call RemoveItem(i)
call iD.destroy()
endif
else
set iD=itemData.create()
set iD.ItemTime=iD.ItemTime+1
call SetItemUserData(i, iD)
endif
endif
endfunction
function Trig_Destroy_Items_Actions takes nothing returns nothing
call EnumItemsInRect(GetPlayableMapRect(),null, function Trig_Destroy_Items1 )
endfunction
//===========================================================================
function InitTrig_Destroy_Items takes nothing returns nothing
set gg_trg_Destroy_Items = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Destroy_Items, 20.00 )
call TriggerAddAction( gg_trg_Destroy_Items, function Trig_Destroy_Items_Actions )
endfunction
This one sets the item when a unit picks it up to being owned ( so that if an item has been picked up and dropped again it wont be removed ever), and if it hasnt already had the struct stuff attached to it it sets it up.
JASS:
function Trig_Set_t<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite12" alt="o_O" title="Er... what? o_O" loading="lazy" data-shortname="o_O" />wned_Actions takes nothing returns nothing
local item i=GetManipulatedItem()
local itemData iD=itemData(GetItemUserData(i))
if iD.ItemTime>0 then
set iD.Owned=true
else
set iD=itemData.create()
set iD.Owned=true
set iD.ItemTime=iD.ItemTime+1
call SetItemUserData(i, iD)
endif
endfunction
//===========================================================================
function InitTrig_Set_t<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite12" alt="o_O" title="Er... what? o_O" loading="lazy" data-shortname="o_O" />wned takes nothing returns nothing
set gg_trg_Set_t<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite12" alt="o_O" title="Er... what? o_O" loading="lazy" data-shortname="o_O" />wned = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Set_t<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite12" alt="o_O" title="Er... what? o_O" loading="lazy" data-shortname="o_O" />wned, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_Set_t<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite12" alt="o_O" title="Er... what? o_O" loading="lazy" data-shortname="o_O" />wned, function Trig_Set_t<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite12" alt="o_O" title="Er... what? o_O" loading="lazy" data-shortname="o_O" />wned_Actions )
endfunction