Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.22 KB | None | 0 0
  1. scope ChooseVampire initializer init
  2.     globals
  3.         private constant integer VAMPIRE1_UNIT_ID = 'U000'
  4.         private constant integer VAMPIRE1_ITEM_ID = 'I000'
  5.         private constant integer VAMPIRE2_UNIT_ID = 'U001'
  6.         private constant integer VAMPIRE2_ITEM_ID = 'I001'
  7.         private constant integer VAMPIRE3_UNIT_ID = 'U002'
  8.         private constant integer VAMPIRE3_ITEM_ID = 'I002'
  9.         private constant integer MAX_VAMPIRES = 3
  10.         private integer Get_Vampires = 0
  11.     endglobals
  12.    
  13.     private function Vampire takes item whichItem returns unit
  14.         if (whichItem==VAMPIRE1_ITEM_ID) then
  15.             return VAMPIRE1_UNIT_ID
  16.         elseif (whichItem==VAMPIRE2_ITEM_ID) then
  17.             return VAMPIRE2_UNIT_ID
  18.         elseif (whichItem==VAMPIRE3_ITEM_ID) then
  19.             return VAMPIRE3_UNIT_ID
  20.         endif
  21.         return null
  22.     endfunction
  23.    
  24.     private function Actions takes nothing returns boolean
  25.         local unit u = GetBuyingUnit()
  26.         local unit t = GetSellingUnit()
  27.         local player p = GetOwningPlayer(u)
  28.         local item i = GetSoldItem()
  29.         local real x = GetUnitX(u)
  30.         local real y = GetUnitY(u)
  31.         if (IsPlayerInForce(p,udg_vampires)) then
  32.             call RemoveUnit(u)
  33.             set u=CreateUnit(p,Vampire(i),x,y,GetRandomReal(0.00,360.00))
  34.             call RemoveItem(i)
  35.             set Get_Vampires=Get_Vampires+1
  36.             if (GetLocalPlayer()==p) then
  37.                 call SelectUnit(u,true)
  38.             endif
  39.             if (Get_Vampires>=MAX_VAMPIRES) then
  40.                 call RemoveUnit(t)
  41.             endif
  42.         endif
  43.         set u=null
  44.         set t=null
  45.         set p=null
  46.         set i=null
  47.         return false
  48.     endfunction
  49.  
  50.     //===========================================================================
  51.     private function init takes nothing returns nothing
  52.         local trigger trig = CreateTrigger()
  53.         local integer index = 0
  54.         loop
  55.             exitwhen index>=bj_MAX_PLAYER_SLOTS
  56.             call TriggerRegisterPlayerUnitEvent(trig,Player(index),EVENT_PLAYER_UNIT_SELL_ITEM,null)
  57.             set index=index+1
  58.         endloop
  59.         call TriggerAddCondition(trig,Condition(function Actions))
  60.         set trig=null
  61.     endfunction
  62. endscope
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement