Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger t=CreateTrigger()
- timer tm[]
- hashtable h_bt
- define {TN='I000'
- TR='I001'
- }
- function end_block_taraska takes nothing returns nothing
- timer t=GetExpiredTimer()
- integer id=GetHandleId(t)
- unit a=LoadUnitHandle(h_bt,id,StringHash("a"))
- timerdialog ts=LoadTimerDialogHandle(h_bt,id,StringHash("ts"))
- DestroyTimerDialog(ts)
- BJDebugMsg(I2S(id))
- integer index=0
- loop
- if GetItemTypeId(UnitItemInSlot(a, index))==TN
- RemoveItem(UnitItemInSlot(a,index))
- UnitAddSwappedItem(TR,a)
- endif
- exitwhen index==5
- index++
- endloop
- DestroyTimer(t)
- FlushChildHashtable(h_bt,id)
- tm[GetHandleId(a)-1048000]=null
- flush locals
- endfunction
- function damage_block_item takes nothing returns nothing
- unit a=GetTriggerUnit()
- unit d=GetEventDamageSource()
- integer id=GetHandleId(a)-1048500
- BJDebugMsg(I2S(id))
- integer index=0
- if IsUnitEnemy(d,GetOwningPlayer(a))==true && IsUnitType(d,UNIT_TYPE_HERO)==true then
- loop
- if GetItemTypeId(UnitItemInSlot(a, index))==TR
- RemoveItem(UnitItemInSlot(a,index))
- UnitAddSwappedItem(TN,a)
- endif
- exitwhen index==5
- index++
- endloop
- if tm[id]==null then
- tm[id]=CreateTimer()
- TimerStart(tm[id],4.,false,function end_block_taraska)
- timerdialog ts=CreateDialogTimer(tm[id],"proverka")
- SaveTimerDialogHandle(h_bt,GetHandleId(tm[id]),StringHash("ts"),ts)
- BJDebugMsg("sozdalos")
- else
- TimerStart(tm[id],4.,false,function end_block_taraska)
- BJDebugMsg("ne sozdalos")
- endif
- SaveUnitHandle(h_bt,GetHandleId(tm[id]),StringHash("a"),a)
- endif
- flush locals
- endfunction
- function entern_map_rect takes nothing returns nothing
- unit a=GetTriggerUnit()
- TriggerRegisterUnitEvent( t, a, EVENT_UNIT_DAMAGED )
- flush locals
- endfunction
- function Trig_Block_Item_Actions takes nothing returns nothing
- group g=CreateGroup()
- unit a
- GroupEnumUnitsInRect(g,GetPlayableMapRect(),null)
- loop
- a=FirstOfGroup(g)
- exitwhen a==null
- GroupRemoveUnit(g,a)
- TriggerRegisterUnitEvent( t, a, EVENT_UNIT_DAMAGED )
- a=null
- endloop
- TriggerAddAction(t,function damage_block_item)
- DestroyGroup(g)
- flush locals
- endfunction
- //===========================================================================
- function InitTrig_Block_Item takes nothing returns nothing
- trigger Block_Item = CreateTrigger( )
- trigger trig=CreateTrigger()
- TriggerRegisterEnterRect(trig,GetPlayableMapRect())
- TriggerRegisterTimerEvent(Block_Item,0,false)
- TriggerAddAction( Block_Item, function Trig_Block_Item_Actions )
- TriggerAddAction( trig, function entern_map_rect )
- Block_Item=null
- trig=null
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement