Name | Type | is_array | initial_value |
All | group | No | |
Dialog | dialog | No | |
Easy | button | No | |
Hard | button | No | |
hero | unit | No | |
hitpoints | real | No | |
load_checkpoint | location | No | |
MurlocAttack | location | No | |
Music_Timer | timer | No | |
NagaPortalDestroyed | boolean | No | |
NAGAS | integer | No | |
UndeadNumber | integer | No | |
UniqueItems | itemcode | Yes | |
weather | weathereffect | No | |
weather_theme | integer | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
function IsUnique takes integer id returns boolean
set bj_forLoopBIndex = 0
set bj_forLoopBIndexEnd = 999
loop
exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
if (udg_UniqueItems[bj_forLoopBIndex] == id) then
return true
endif
set bj_forLoopBIndex = bj_forLoopBIndex + 1
endloop
return false
endfunction
function PlainName takes item Item returns string
local string Name = GetItemName(Item)
local integer L = StringLength(Name)
local string nName = ""
if (SubStringBJ(Name, 1, 2) == "|c") then
if (SubStringBJ(Name, (L - 4), (L - 3)) == " +") then
set nName = SubStringBJ(Name, 11, (L - 5))
else
set nName = SubStringBJ(Name, 11, (L - 2))
endif
else
if (SubStringBJ(Name, (L - 2), (L - 1)) == " +") then
set nName = SubStringBJ(Name, 1, (L - 3))
else
set nName = Name
endif
endif
return nName
endfunction
function Unique_Item_System_Actions takes nothing returns nothing
local string Name1 = ""
local string Name2 = ""
local item Item = null
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 6
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set Item = UnitItemInSlotBJ(GetTriggerUnit(), bj_forLoopAIndex)
set Name1 = PlainName(Item)
set Name2 = PlainName(GetManipulatedItem())
if (Item != GetManipulatedItem() and (GetItemTypeId(Item) == GetItemTypeId(GetManipulatedItem()) or Name1 == Name2)) then
if (IsUnique(GetItemTypeId(Item)) == true or IsUnique(GetItemTypeId(GetManipulatedItem()))) then
call UnitRemoveItemSwapped(GetManipulatedItem(), GetTriggerUnit())
call DisplayTextToPlayer(GetOwningPlayer(GetTriggerUnit()), 0, 0, "You can only carry 1 of that item!")
endif
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set Name1 = ""
set Name2 = ""
set Item = null
endfunction
//===========================================================================
function InitTrig_Unique_Item_System takes nothing returns nothing
set gg_trg_Unique_Item_System = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Unique_Item_System, EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddAction(gg_trg_Unique_Item_System, function Unique_Item_System_Actions)
endfunction