Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scope ChooseVampire initializer init
- globals
- private constant integer VAMPIRE1_UNIT_ID = 'U000'
- private constant integer VAMPIRE1_ITEM_ID = 'I000'
- private constant integer VAMPIRE2_UNIT_ID = 'U001'
- private constant integer VAMPIRE2_ITEM_ID = 'I001'
- private constant integer VAMPIRE3_UNIT_ID = 'U002'
- private constant integer VAMPIRE3_ITEM_ID = 'I002'
- private constant integer MAX_VAMPIRES = 3
- private integer Get_Vampires = 0
- endglobals
- private function Vampire takes item whichItem returns unit
- if (whichItem==VAMPIRE1_ITEM_ID) then
- return VAMPIRE1_UNIT_ID
- elseif (whichItem==VAMPIRE2_ITEM_ID) then
- return VAMPIRE2_UNIT_ID
- elseif (whichItem==VAMPIRE3_ITEM_ID) then
- return VAMPIRE3_UNIT_ID
- endif
- return null
- endfunction
- private function Actions takes nothing returns boolean
- local unit u = GetBuyingUnit()
- local unit t = GetSellingUnit()
- local player p = GetOwningPlayer(u)
- local item i = GetSoldItem()
- local real x = GetUnitX(u)
- local real y = GetUnitY(u)
- if (IsPlayerInForce(p,udg_vampires)) then
- call RemoveUnit(u)
- set u=CreateUnit(p,Vampire(i),x,y,GetRandomReal(0.00,360.00))
- call RemoveItem(i)
- set Get_Vampires=Get_Vampires+1
- if (GetLocalPlayer()==p) then
- call SelectUnit(u,true)
- endif
- if (Get_Vampires>=MAX_VAMPIRES) then
- call RemoveUnit(t)
- endif
- endif
- set u=null
- set t=null
- set p=null
- set i=null
- return false
- endfunction
- //===========================================================================
- private function init takes nothing returns nothing
- local trigger trig = CreateTrigger()
- local integer index = 0
- loop
- exitwhen index>=bj_MAX_PLAYER_SLOTS
- call TriggerRegisterPlayerUnitEvent(trig,Player(index),EVENT_PLAYER_UNIT_SELL_ITEM,null)
- set index=index+1
- endloop
- call TriggerAddCondition(trig,Condition(function Actions))
- set trig=null
- endfunction
- endscope
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement