function Trig_PotionCraft_Conditions takes nothing returns boolean
return GetUnitTypeId(GetSellingUnit()) == 'n000'
endfunction
function Trig_PotionCraft_Actions takes nothing returns nothing
local item it = GetSoldItem()
local integer id = GetItemTypeId(it)
local unit u = GetBuyingUnit()
local unit s = GetSellingUnit()
local integer cv = GetUnitUserData(s)
local integer ilv = GetItemLevel(it)
local player p = GetOwningPlayer(u)
call RemoveItem( it )
set udg_Craft_Client[cv] = u
if CountCharge(u,udg_H_Items[0]) >= 1 and CountCharge(u,udg_H_Items[1]) >= 1 and CountCharge(u,udg_H_Items[2]) >= 1 and ilv >= 2000 and ilv < 2011 then
call SetPlayerTechMaxAllowed( p, 'h00O', 1 )
call IssueImmediateOrderById( s, 'h00O' )
call SetPlayerTechMaxAllowed( p, 'h00O', 0)
call DecreaseCharge(u,udg_H_Items[0], 1)
call DecreaseCharge(u,udg_H_Items[1], 1)
call DecreaseCharge(u,udg_H_Items[2], 1)
set udg_Craft_Item[cv] = id
else
call DisplayTextToPlayer( p, 0, 0, "Missing from components. This item need 1 lumber, 1 iron, 1 stone.")
endif
set it = null
set u = null
set s = null
set p = null
endfunction
//===========================================================================
function InitTrig_Training_for_potion takes nothing returns nothing
set gg_trg_Training_for_potion = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Training_for_potion, EVENT_PLAYER_UNIT_SELL_ITEM )
call TriggerAddCondition( gg_trg_Training_for_potion, Condition( function Trig_PotionCraft_Conditions ) )
call TriggerAddAction( gg_trg_Training_for_potion, function Trig_PotionCraft_Actions )
endfunction