Advertisement
Guest User

Untitled

a guest
Apr 15th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
J 2.73 KB | None | 0 0
  1. trigger t=CreateTrigger()
  2. timer tm[]
  3. hashtable h_bt
  4. define  {TN='I000'
  5.          TR='I001'
  6.                   }
  7.  
  8. function end_block_taraska takes nothing returns nothing
  9. timer t=GetExpiredTimer()
  10. integer id=GetHandleId(t)
  11. unit a=LoadUnitHandle(h_bt,id,StringHash("a"))
  12. timerdialog ts=LoadTimerDialogHandle(h_bt,id,StringHash("ts"))
  13. DestroyTimerDialog(ts)
  14. BJDebugMsg(I2S(id))
  15. integer index=0
  16.     loop
  17.         if GetItemTypeId(UnitItemInSlot(a, index))==TN
  18.             RemoveItem(UnitItemInSlot(a,index))
  19.             UnitAddSwappedItem(TR,a)
  20.         endif
  21.         exitwhen index==5
  22.         index++
  23.     endloop
  24. DestroyTimer(t)
  25. FlushChildHashtable(h_bt,id)
  26. tm[GetHandleId(a)-1048000]=null
  27. flush locals
  28. endfunction
  29.  
  30. function damage_block_item takes nothing returns nothing
  31. unit a=GetTriggerUnit()
  32. unit d=GetEventDamageSource()
  33. integer id=GetHandleId(a)-1048500
  34. BJDebugMsg(I2S(id))
  35. integer index=0
  36. if IsUnitEnemy(d,GetOwningPlayer(a))==true && IsUnitType(d,UNIT_TYPE_HERO)==true then
  37.     loop
  38.         if GetItemTypeId(UnitItemInSlot(a, index))==TR
  39.             RemoveItem(UnitItemInSlot(a,index))
  40.             UnitAddSwappedItem(TN,a)
  41.         endif
  42.     exitwhen index==5
  43.     index++
  44.     endloop
  45.     if tm[id]==null then
  46.         tm[id]=CreateTimer()
  47.         TimerStart(tm[id],4.,false,function end_block_taraska)
  48.         timerdialog ts=CreateDialogTimer(tm[id],"proverka")
  49.         SaveTimerDialogHandle(h_bt,GetHandleId(tm[id]),StringHash("ts"),ts)
  50.         BJDebugMsg("sozdalos")
  51.     else
  52.         TimerStart(tm[id],4.,false,function end_block_taraska)
  53.         BJDebugMsg("ne sozdalos")
  54.  
  55.     endif
  56.        
  57.     SaveUnitHandle(h_bt,GetHandleId(tm[id]),StringHash("a"),a)
  58. endif
  59. flush locals
  60. endfunction
  61.  
  62. function entern_map_rect takes nothing returns nothing
  63. unit a=GetTriggerUnit()
  64. TriggerRegisterUnitEvent( t, a, EVENT_UNIT_DAMAGED )
  65. flush locals
  66. endfunction
  67.  
  68. function Trig_Block_Item_Actions takes nothing returns nothing
  69. group g=CreateGroup()
  70. unit a
  71. GroupEnumUnitsInRect(g,GetPlayableMapRect(),null)
  72. loop
  73. a=FirstOfGroup(g)
  74. exitwhen a==null
  75. GroupRemoveUnit(g,a)
  76. TriggerRegisterUnitEvent( t, a, EVENT_UNIT_DAMAGED )
  77. a=null
  78. endloop
  79. TriggerAddAction(t,function damage_block_item)
  80. DestroyGroup(g)
  81. flush locals
  82. endfunction
  83.  
  84. //===========================================================================
  85. function InitTrig_Block_Item takes nothing returns nothing
  86.     trigger Block_Item = CreateTrigger(  )
  87.     trigger trig=CreateTrigger()
  88.     TriggerRegisterEnterRect(trig,GetPlayableMapRect())
  89.     TriggerRegisterTimerEvent(Block_Item,0,false)
  90.     TriggerAddAction( Block_Item, function Trig_Block_Item_Actions )
  91.     TriggerAddAction( trig, function entern_map_rect )
  92.     Block_Item=null
  93.     trig=null
  94. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement