Name | Type | is_array | initial_value |
library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 4.1.0.1.
One map, one hashtable. Welcome to NewTable 4.1.0.1
This newest iteration of Table introduces the new HashTable struct.
You can now instantiate HashTables which enables the use of large
parent and large child keys, just like a standard hashtable. Previously,
the user would have to instantiate a Table to do this on their own which -
while doable - is something the user should not have to do if I can add it
to this resource myself (especially if they are inexperienced).
This library was originally called NewTable so it didn't conflict with
the API of Table by Vexorian. However, the damage is done and it's too
late to change the library name now. To help with damage control, I
have provided an extension library called TableBC, which bridges all
the functionality of Vexorian's Table except for 2-D string arrays &
the ".flush(integer)" method. I use ".flush()" to flush a child hash-
table, because I wanted the API in NewTable to reflect the API of real
hashtables (I thought this would be more intuitive).
API
------------
struct Table
| static method create takes nothing returns Table
| create a new Table
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush all stored values inside of it
|
| method remove takes integer key returns nothing
| remove the value at index "key"
|
| method operator []= takes integer key, $TYPE$ value returns nothing
| assign "value" to index "key"
|
| method operator [] takes integer key returns $TYPE$
| load the value at index "key"
|
| method has takes integer key returns boolean
| whether or not the key was assigned
|
----------------
struct TableArray
| static method operator [] takes integer array_size returns TableArray
| create a new array of Tables of size "array_size"
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush and destroy it
|
| method operator size takes nothing returns integer
| returns the size of the TableArray
|
| method operator [] takes integer key returns Table
| returns a Table accessible exclusively to index "key"
*/
globals
private integer less = 0 //Index generation for TableArrays (below 0).
private integer more = 8190 //Index generation for Tables.
//Configure it if you use more than 8190 "key" variables in your map (this will never happen though).
private hashtable ht = InitHashtable()
private key sizeK
private key listK
endglobals
private struct dex extends array
static method operator size takes nothing returns Table
return sizeK
endmethod
static method operator list takes nothing returns Table
return listK
endmethod
endstruct
private struct handles extends array
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private struct agents extends array
method operator []= takes integer key, agent value returns nothing
call SaveAgentHandle(ht, this, key, value)
endmethod
endstruct
//! textmacro NEW_ARRAY_BASIC takes SUPER, FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSaved$SUPER$(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSaved$SUPER$(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//! textmacro NEW_ARRAY takes FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$Handle(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$Handle(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//Run these textmacros to include the entire hashtable API as wrappers.
//Don't be intimidated by the number of macros - Vexorian's map optimizer is
//supposed to kill functions which inline (all of these functions inline).
//! runtextmacro NEW_ARRAY_BASIC("Real", "Real", "real")
//! runtextmacro NEW_ARRAY_BASIC("Boolean", "Boolean", "boolean")
//! runtextmacro NEW_ARRAY_BASIC("String", "Str", "string")
//New textmacro to allow table.integer[] syntax for compatibility with textmacros that might desire it.
//! runtextmacro NEW_ARRAY_BASIC("Integer", "Integer", "integer")
//! runtextmacro NEW_ARRAY("Player", "player")
//! runtextmacro NEW_ARRAY("Widget", "widget")
//! runtextmacro NEW_ARRAY("Destructable", "destructable")
//! runtextmacro NEW_ARRAY("Item", "item")
//! runtextmacro NEW_ARRAY("Unit", "unit")
//! runtextmacro NEW_ARRAY("Ability", "ability")
//! runtextmacro NEW_ARRAY("Timer", "timer")
//! runtextmacro NEW_ARRAY("Trigger", "trigger")
//! runtextmacro NEW_ARRAY("TriggerCondition", "triggercondition")
//! runtextmacro NEW_ARRAY("TriggerAction", "triggeraction")
//! runtextmacro NEW_ARRAY("TriggerEvent", "event")
//! runtextmacro NEW_ARRAY("Force", "force")
//! runtextmacro NEW_ARRAY("Group", "group")
//! runtextmacro NEW_ARRAY("Location", "location")
//! runtextmacro NEW_ARRAY("Rect", "rect")
//! runtextmacro NEW_ARRAY("BooleanExpr", "boolexpr")
//! runtextmacro NEW_ARRAY("Sound", "sound")
//! runtextmacro NEW_ARRAY("Effect", "effect")
//! runtextmacro NEW_ARRAY("UnitPool", "unitpool")
//! runtextmacro NEW_ARRAY("ItemPool", "itempool")
//! runtextmacro NEW_ARRAY("Quest", "quest")
//! runtextmacro NEW_ARRAY("QuestItem", "questitem")
//! runtextmacro NEW_ARRAY("DefeatCondition", "defeatcondition")
//! runtextmacro NEW_ARRAY("TimerDialog", "timerdialog")
//! runtextmacro NEW_ARRAY("Leaderboard", "leaderboard")
//! runtextmacro NEW_ARRAY("Multiboard", "multiboard")
//! runtextmacro NEW_ARRAY("MultiboardItem", "multiboarditem")
//! runtextmacro NEW_ARRAY("Trackable", "trackable")
//! runtextmacro NEW_ARRAY("Dialog", "dialog")
//! runtextmacro NEW_ARRAY("Button", "button")
//! runtextmacro NEW_ARRAY("TextTag", "texttag")
//! runtextmacro NEW_ARRAY("Lightning", "lightning")
//! runtextmacro NEW_ARRAY("Image", "image")
//! runtextmacro NEW_ARRAY("Ubersplat", "ubersplat")
//! runtextmacro NEW_ARRAY("Region", "region")
//! runtextmacro NEW_ARRAY("FogState", "fogstate")
//! runtextmacro NEW_ARRAY("FogModifier", "fogmodifier")
//! runtextmacro NEW_ARRAY("Hashtable", "hashtable")
struct Table extends array
// Implement modules for intuitive syntax (tb.handle; tb.unit; etc.)
implement realm
implement integerm
implement booleanm
implement stringm
implement playerm
implement widgetm
implement destructablem
implement itemm
implement unitm
implement abilitym
implement timerm
implement triggerm
implement triggerconditionm
implement triggeractionm
implement eventm
implement forcem
implement groupm
implement locationm
implement rectm
implement boolexprm
implement soundm
implement effectm
implement unitpoolm
implement itempoolm
implement questm
implement questitemm
implement defeatconditionm
implement timerdialogm
implement leaderboardm
implement multiboardm
implement multiboarditemm
implement trackablem
implement dialogm
implement buttonm
implement texttagm
implement lightningm
implement imagem
implement ubersplatm
implement regionm
implement fogstatem
implement fogmodifierm
implement hashtablem
method operator handle takes nothing returns handles
return this
endmethod
method operator agent takes nothing returns agents
return this
endmethod
//set this = tb[GetSpellAbilityId()]
method operator [] takes integer key returns Table
return LoadInteger(ht, this, key) //return this.integer[key]
endmethod
//set tb[389034] = 8192
method operator []= takes integer key, Table tb returns nothing
call SaveInteger(ht, this, key, tb) //set this.integer[key] = tb
endmethod
//set b = tb.has(2493223)
method has takes integer key returns boolean
return HaveSavedInteger(ht, this, key) //return this.integer.has(key)
endmethod
//call tb.remove(294080)
method remove takes integer key returns nothing
call RemoveSavedInteger(ht, this, key) //call this.integer.remove(key)
endmethod
//Remove all data from a Table instance
method flush takes nothing returns nothing
call FlushChildHashtable(ht, this)
endmethod
//local Table tb = Table.create()
static method create takes nothing returns Table
local Table this = dex.list[0]
if this == 0 then
set this = more + 1
set more = this
else
set dex.list[0] = dex.list[this]
call dex.list.remove(this) //Clear hashed memory
endif
debug set dex.list[this] = -1
return this
endmethod
// Removes all data from a Table instance and recycles its index.
//
// call tb.destroy()
//
method destroy takes nothing returns nothing
debug if dex.list[this] != -1 then
debug call BJDebugMsg("Table Error: Tried to double-free instance: " + I2S(this))
debug return
debug endif
call this.flush()
set dex.list[this] = dex.list[0]
set dex.list[0] = this
endmethod
//! runtextmacro optional TABLE_BC_METHODS()
endstruct
//! runtextmacro optional TABLE_BC_STRUCTS()
struct TableArray extends array
//Returns a new TableArray to do your bidding. Simply use:
//
// local TableArray ta = TableArray[array_size]
//
static method operator [] takes integer array_size returns TableArray
local Table tb = dex.size[array_size] //Get the unique recycle list for this array size
local TableArray this = tb[0] //The last-destroyed TableArray that had this array size
debug if array_size <= 0 then
debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
debug return 0
debug endif
if this == 0 then
set this = less - array_size
set less = this
else
set tb[0] = tb[this] //Set the last destroyed to the last-last destroyed
call tb.remove(this) //Clear hashed memory
endif
set dex.size[this] = array_size //This remembers the array size
return this
endmethod
//Returns the size of the TableArray
method operator size takes nothing returns integer
return dex.size[this]
endmethod
//This magic method enables two-dimensional[array][syntax] for Tables,
//similar to the two-dimensional utility provided by hashtables them-
//selves.
//
//ta[integer a].unit[integer b] = unit u
//ta[integer a][integer c] = integer d
//
//Inline-friendly when not running in debug mode
//
method operator [] takes integer key returns Table
static if DEBUG_MODE then
local integer i = this.size
if i == 0 then
call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
return 0
elseif key < 0 or key >= i then
call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
return 0
endif
endif
return this + key
endmethod
//Destroys a TableArray without flushing it; I assume you call .flush()
//if you want it flushed too. This is a public method so that you don't
//have to loop through all TableArray indices to flush them if you don't
//need to (ie. if you were flushing all child-keys as you used them).
//
method destroy takes nothing returns nothing
local Table tb = dex.size[this.size]
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
debug return
debug endif
if tb == 0 then
//Create a Table to index recycled instances with their array size
set tb = Table.create()
set dex.size[this.size] = tb
endif
call dex.size.remove(this) //Clear the array size from hash memory
set tb[this] = tb[0]
set tb[0] = this
endmethod
private static Table tempTable
private static integer tempEnd
//Avoids hitting the op limit
private static method clean takes nothing returns nothing
local Table tb = .tempTable
local integer end = tb + 0x1000
if end < .tempEnd then
set .tempTable = end
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
else
set end = .tempEnd
endif
loop
call tb.flush()
set tb = tb + 1
exitwhen tb == end
endloop
endmethod
//Flushes the TableArray and also destroys it. Doesn't get any more
//similar to the FlushParentHashtable native than this.
//
method flush takes nothing returns nothing
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to flush an invalid TableArray instance: " + I2S(this))
debug return
debug endif
set .tempTable = this
set .tempEnd = this + this.size
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
call this.destroy()
endmethod
endstruct
//NEW: Added in Table 4.0. A fairly simple struct but allows you to do more
//than that which was previously possible.
struct HashTable extends array
//Enables myHash[parentKey][childKey] syntax.
//Basically, it creates a Table in the place of the parent key if
//it didn't already get created earlier.
method operator [] takes integer index returns Table
local Table t = Table(this)[index]
if t == 0 then
set t = Table.create()
set Table(this)[index] = t //whoops! Forgot that line. I'm out of practice!
endif
return t
endmethod
//You need to call this on each parent key that you used if you
//intend to destroy the HashTable or simply no longer need that key.
method remove takes integer index returns nothing
local Table t = Table(this)[index]
if t != 0 then
call t.destroy()
call Table(this).remove(index)
endif
endmethod
//Added in version 4.1
method has takes integer index returns boolean
return Table(this).has(index)
endmethod
//HashTables are just fancy Table indices.
method destroy takes nothing returns nothing
call Table(this).destroy()
endmethod
//Like I said above...
static method create takes nothing returns thistype
return Table.create()
endmethod
endstruct
endlibrary
/**************************************************************
*
* RegisterPlayerUnitEvent
* v5.1.0.1
* By Magtheridon96
*
* I would like to give a special thanks to Bribe, azlier
* and BBQ for improving this library. For modularity, it only
* supports player unit events.
*
* Functions passed to RegisterPlayerUnitEvent must either
* return a boolean (false) or nothing. (Which is a Pro)
*
* Warning:
* --------
*
* - Don't use TriggerSleepAction inside registered code.
* - Don't destroy a trigger unless you really know what you're doing.
*
* API:
* ----
*
* - function RegisterPlayerUnitEvent takes playerunitevent whichEvent, code whichFunction returns nothing
* - Registers code that will execute when an event fires.
* - function RegisterPlayerUnitEventForPlayer takes playerunitevent whichEvent, code whichFunction, player whichPlayer returns nothing
* - Registers code that will execute when an event fires for a certain player.
* - function GetPlayerUnitEventTrigger takes playerunitevent whichEvent returns trigger
* - Returns the trigger corresponding to ALL functions of a playerunitevent.
*
**************************************************************/
library RegisterPlayerUnitEvent // Special Thanks to Bribe and azlier
globals
private trigger array t
endglobals
function RegisterPlayerUnitEvent takes playerunitevent p, code c returns nothing
local integer i = GetHandleId(p)
local integer k = 15
if t[i] == null then
set t[i] = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(t[i], Player(k), p, null)
exitwhen k == 0
set k = k - 1
endloop
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function RegisterPlayerUnitEventForPlayer takes playerunitevent p, code c, player pl returns nothing
local integer i = 16 * GetHandleId(p) + GetPlayerId(pl)
if t[i] == null then
set t[i] = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t[i], pl, p, null)
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function GetPlayerUnitEventTrigger takes playerunitevent p returns trigger
return t[GetHandleId(p)]
endfunction
endlibrary
library Shop requires Table, RegisterPlayerUnitEvent, Components
/* --------------------------------------- Shop v1.0 --------------------------------------- */
// Credits:
// Taysen: FDF file and A2S function
// Bribe: Table library
// Magtheridon: RegisterPlayerUnitEvent library
// Hate: Frame border effects
/* -------------------------------------- By Chopinski ------------------------------------- */
/* ----------------------------------------------------------------------------------------- */
/* Configuration */
/* ----------------------------------------------------------------------------------------- */
globals
// Main window
private constant real X = 0.0
private constant real Y = 0.56
private constant real WIDTH = 0.8
private constant real HEIGHT = 0.4
private constant real TOOLBAR_BUTTON_SIZE = 0.02
private constant integer ROWS = 5
private constant integer COLUMNS = 13
private constant integer DETAILED_ROWS = 5
private constant integer DETAILED_COLUMNS = 8
private constant string CLOSE_ICON = "ui\\widgets\\battlenet\\chaticons\\bnet-squelch"
private constant string CLEAR_ICON = "ReplaceableTextures\\CommandButtons\\BTNCancel.blp"
private constant string HELP_ICON = "UI\\Widgets\\EscMenu\\Human\\quest-unknown.blp"
private constant string LOGIC_ICON = "ReplaceableTextures\\CommandButtons\\BTNMagicalSentry.blp"
private constant string UNDO_ICON = "ReplaceableTextures\\CommandButtons\\BTNReplay-Loop.blp"
private constant string DISMANTLE_ICON = "UI\\Feedback\\Resources\\ResourceUpkeep.blp"
// Buyer Panel
private constant real BUYER_WIDTH = WIDTH/2
private constant real BUYER_HEIGHT = 0.08
private constant real BUYER_SIZE = 0.032
private constant real BUYER_GAP = 0.04
private constant real BUYER_SHIFT_BUTTON_SIZE = 0.012
private constant integer BUYER_COUNT = 8
private constant string BUYER_RIGHT = "ReplaceableTextures\\CommandButtons\\BTNReplay-SpeedDown.blp"
private constant string BUYER_LEFT = "ReplaceableTextures\\CommandButtons\\BTNReplay-SpeedUp.blp"
// Inventory Panel
private constant real INVENTORY_WIDTH = 0.23780
private constant real INVENTORY_HEIGHT = 0.03740
private constant real INVENTORY_SIZE = 0.031
private constant real INVENTORY_GAP = 0.04
private constant integer INVENTORY_COUNT = 6
private constant string INVENTORY_TEXTURE = "Inventory.blp"
// Details window
private constant real DETAIL_WIDTH = 0.3125
private constant real DETAIL_HEIGHT = HEIGHT
private constant integer DETAIL_USED_COUNT = 6
private constant real DETAIL_BUTTON_SIZE = 0.035
private constant real DETAIL_BUTTON_GAP = 0.044
private constant real DETAIL_CLOSE_BUTTON_SIZE = 0.02
private constant real DETAIL_SHIFT_BUTTON_SIZE = 0.012
private constant string USED_RIGHT = "ReplaceableTextures\\CommandButtons\\BTNReplay-SpeedDown.blp"
private constant string USED_LEFT = "ReplaceableTextures\\CommandButtons\\BTNReplay-SpeedUp.blp"
// When true, a click in a component in the
// detail panel will detail the clicked component
private constant boolean DETAIL_COMPONENT = false
// Side Panels
private constant real SIDE_WIDTH = 0.075
private constant real SIDE_HEIGHT = HEIGHT
private constant real EDIT_WIDTH = 0.15
private constant real EDIT_HEIGHT = 0.0285
// Category and Favorite buttons
private constant integer CATEGORY_COUNT = 13
private constant real CATEGORY_SIZE = 0.02750
private constant real CATEGORY_GAP = 0.0
// Favorite key
// LSHIT, LCONTROL are buggy on KeyDown event,
// complain to blizzard, not me
private constant oskeytype FAVORITE_KEY = OSKEY_TAB
// Item slots
private constant real SLOT_WIDTH = 0.04
private constant real SLOT_HEIGHT = 0.05
private constant real ITEM_SIZE = 0.04
private constant real GOLD_SIZE = 0.01
private constant real COST_WIDTH = 0.045
private constant real COST_HEIGHT = 0.01
private constant real COST_SCALE = 0.8
private constant real SLOT_GAP_X = 0.018
private constant real SLOT_GAP_Y = 0.022
private constant string GOLD_ICON = "UI\\Feedback\\Resources\\ResourceGold.blp"
// Selected item highlight
private constant string ITEM_HIGHLIGHT = "neon_sprite.mdx"
private constant real HIGHLIGHT_WIDTH = 0.00001
private constant real HIGHLIGHT_HEIGHT = 0.00001
private constant real HIGHLIGHT_SCALE = 0.75
private constant real HIGHLIGHT_XOFFSET = -0.0052
private constant real HIGHLIGHT_YOFFSET = -0.0048
// Tagged item highlight
private constant string TAG_HIGHLIGHT = "crystallid_sprite.mdx"
private constant real TAG_HIGHLIGHT_WIDTH = 0.00001
private constant real TAG_HIGHLIGHT_HEIGHT = 0.00001
private constant real TAG_HIGHLIGHT_SCALE = 0.75
private constant real TAG_HIGHLIGHT_XOFFSET = -0.0052
private constant real TAG_HIGHLIGHT_YOFFSET = -0.0048
// Scroll
private constant real SCROLL_DELAY = 0.01
// Update time
private constant real UPDATE_PERIOD = 0.33
// Buy / Sell sound, model and scale
private constant string SPRITE_MODEL = "UI\\Feedback\\GoldCredit\\GoldCredit.mdl"
private constant real SPRITE_SCALE = 0.0005
private constant string SUCCESS_SOUND = "Abilities\\Spells\\Other\\Transmute\\AlchemistTransmuteDeath1.wav"
private constant string ERROR_SOUND = "Sound\\Interface\\Error.wav"
// Dont touch
private HashTable table
endglobals
/* ----------------------------------------------------------------------------------------- */
/* JASS API */
/* ----------------------------------------------------------------------------------------- */
function CreateShop takes integer id, real aoe, real returnRate returns nothing
call Shop.create(id, aoe, returnRate)
endfunction
function ShopAddCategory takes integer id, string icon, string description returns integer
return Shop.addCategory(id, icon, description)
endfunction
function ShopAddItem takes integer id, integer itemId, integer categories returns nothing
call Shop.addItem(id, itemId, categories)
endfunction
function ItemAddComponents takes integer whichItem, integer a, integer b, integer c, integer d, integer e returns nothing
call Item.addComponents(whichItem, a, b, c, d, e)
endfunction
function UnitHasItemOfType takes unit u, integer id returns boolean
return Item.hasType(u, id)
endfunction
function UnitCountItemOfType takes unit u, integer id returns integer
return Item.countType(u, id)
endfunction
function ShopFilter takes unit u, player owner, unit shop returns boolean
return IsUnitOwnedByPlayer(u, owner) and UnitInventorySize(u) > 0 and not IsUnitType(u, UNIT_TYPE_DEAD) and not IsUnitPaused(u) and not IsUnitIllusion(u) and not IsUnitHidden(u)
endfunction
function A2S takes integer id returns string
local string chars = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
local string s = ""
local integer min = ' '
local integer i
if id >= min then
loop
exitwhen id == 0
set i = ModuloInteger(id, 256) - min
set s = SubString(chars, i, i + 1) + s
set id = id / 256
endloop
endif
return s
endfunction
/* ----------------------------------------------------------------------------------------- */
/* System */
/* ----------------------------------------------------------------------------------------- */
struct Item
private static unit shop
private static rect rect
private static trigger trigger = CreateTrigger()
private static player player = Player(bj_PLAYER_NEUTRAL_EXTRA)
readonly static Table itempool
readonly static HashTable unit
private integer componentCount
string name
string icon
string tooltip
integer id
integer gold
integer charges
integer categories
Table component
Table counter
Table relation
method destroy takes nothing returns nothing
call component.destroy()
call relation.destroy()
call counter.destroy()
call deallocate()
endmethod
method operator components takes nothing returns integer
return componentCount
endmethod
method count takes integer id returns integer
return counter[id]
endmethod
static method get takes integer id returns thistype
return itempool[id]
endmethod
private static method save takes integer id, integer comp returns nothing
local thistype this
local thistype part
local integer i = 0
if comp > 0 and comp != id then
set this = create(id, 0)
set part = create(comp, 0)
set component[componentCount] = comp
set componentCount = componentCount + 1
set counter[comp] = counter[comp] + 1
loop
exitwhen part.relation[i] == id
if not part.relation.has(i) then
set part.relation[i] = id
exitwhen true
endif
set i = i + 1
endloop
endif
endmethod
static method addComponents takes integer id, integer a, integer b, integer c, integer d, integer e returns nothing
local thistype this
if id > 0 then
set this = create(id, 0)
set componentCount = 0
call component.flush()
call counter.flush()
call save(id, a)
call save(id, b)
call save(id, c)
call save(id, d)
call save(id, e)
endif
endmethod
static method cost takes integer id returns integer
local integer old
call AddItemToStock(shop, id, 1, 1)
call SetPlayerState(player, PLAYER_STATE_RESOURCE_GOLD, 9999999)
set old = GetPlayerState(player, PLAYER_STATE_RESOURCE_GOLD)
call IssueNeutralImmediateOrderById(player, shop, id)
call RemoveItemFromStock(shop, id)
call EnumItemsInRect(rect, null, function thistype.clear)
return old - GetPlayerState(player, PLAYER_STATE_RESOURCE_GOLD)
endmethod
private static method clear takes nothing returns nothing
call RemoveItem(GetEnumItem())
endmethod
static method hasType takes unit u, integer id returns boolean
return unit[GetHandleId(u)][id] > 0
endmethod
static method countType takes unit u, integer id returns integer
return unit[GetHandleId(u)][id]
endmethod
static method create takes integer id, integer category returns thistype
local thistype this
local item i
if itempool.has(id) then
set this = itempool[id]
if category > 0 then
set categories = category
endif
return this
else
set i = CreateItem(id, 0, 0)
if i != null then
set this = thistype.allocate()
set .id = id
set categories = category
set name = GetItemName(i)
set icon = BlzGetItemIconPath(i)
set tooltip = BlzGetItemExtendedTooltip(i)
set charges = GetItemCharges(i)
if charges == 0 then
set charges = 1
endif
set gold = cost(id)
set componentCount = 0
set component = Table.create()
set counter = Table.create()
set relation = Table.create()
set itempool[id] = this
call RemoveItem(i)
set i = null
return this
else
return 0
endif
endif
endmethod
private static method onPickup takes nothing returns nothing
local integer u = GetHandleId(GetManipulatingUnit())
local integer i = GetItemTypeId(GetManipulatedItem())
set unit[u][i] = unit[u][i] + 1
endmethod
private static method onDrop takes nothing returns nothing
local integer u = GetHandleId(GetManipulatingUnit())
local integer i = GetItemTypeId(GetManipulatedItem())
set unit[u][i] = unit[u][i] - 1
endmethod
private static method onInit takes nothing returns nothing
set rect = Rect(0, 0, 0, 0)
set itempool = Table.create()
set unit = HashTable.create()
set shop = CreateUnit(player, 'nmrk', 0, 0, 0)
call SetRect(rect, GetUnitX(shop) - 1000, GetUnitY(shop) - 1000, GetUnitX(shop) + 1000, GetUnitY(shop) + 1000)
call UnitAddAbility(shop, 'AInv')
call IssueNeutralTargetOrder(player, shop, "smart", shop)
call ShowUnit(shop, false)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_PICKUP_ITEM, function thistype.onPickup)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DROP_ITEM, function thistype.onDrop)
endmethod
endstruct
struct Slot
private boolean isVisible
private real xPos
private real yPos
readonly framehandle parent
readonly framehandle slot
readonly framehandle gold
readonly framehandle cost
Item item
Button button
method operator x= takes real newX returns nothing
set xPos = newX
call BlzFrameClearAllPoints(slot)
call BlzFrameSetPoint(slot, FRAMEPOINT_TOPLEFT, parent, FRAMEPOINT_TOPLEFT, xPos, yPos)
endmethod
method operator x takes nothing returns real
return xPos
endmethod
method operator y= takes real newY returns nothing
set yPos = newY
call BlzFrameClearAllPoints(slot)
call BlzFrameSetPoint(slot, FRAMEPOINT_TOPLEFT, parent, FRAMEPOINT_TOPLEFT, xPos, yPos)
endmethod
method operator y takes nothing returns real
return yPos
endmethod
method operator visible= takes boolean visibility returns nothing
set isVisible = visibility
call BlzFrameSetVisible(slot, visibility)
endmethod
method operator visible takes nothing returns boolean
return isVisible
endmethod
method operator onClick= takes code c returns nothing
set button.onClick = c
endmethod
method operator onScroll= takes code c returns nothing
set button.onScroll = c
endmethod
method operator onRightClick= takes code c returns nothing
set button.onRightClick = c
endmethod
method operator onDoubleClick= takes code c returns nothing
set button.onDoubleClick = c
endmethod
method destroy takes nothing returns nothing
call BlzDestroyFrame(cost)
call BlzDestroyFrame(gold)
call BlzDestroyFrame(slot)
call button.destroy()
call deallocate()
set slot = null
set gold = null
set cost = null
set parent = null
endmethod
static method create takes framehandle parent, Item i, real x, real y, framepointtype point, boolean simpleTooltip returns thistype
local thistype this = thistype.allocate()
set item = i
set xPos = x
set yPos = y
set .parent = parent
set slot = BlzCreateFrameByType("FRAME", "", parent, "", 0)
set gold = BlzCreateFrameByType("BACKDROP", "", slot, "", 0)
set cost = BlzCreateFrameByType("TEXT", "", gold, "", 0)
set button = Button.create(slot, ITEM_SIZE, ITEM_SIZE, 0, 0, simpleTooltip)
set button.tooltip.point = point
call BlzFrameSetPoint(slot, FRAMEPOINT_TOPLEFT, parent, FRAMEPOINT_TOPLEFT, x, y)
call BlzFrameSetSize(slot, SLOT_WIDTH, SLOT_HEIGHT)
call BlzFrameSetPoint(gold, FRAMEPOINT_TOPLEFT, slot, FRAMEPOINT_TOPLEFT, 0.0000, - 0.040000)
call BlzFrameSetSize(gold, GOLD_SIZE, GOLD_SIZE)
call BlzFrameSetTexture(gold, GOLD_ICON, 0, true)
call BlzFrameSetPoint(cost, FRAMEPOINT_TOPLEFT, gold, FRAMEPOINT_TOPLEFT, 0.013250, - 0.0019300)
call BlzFrameSetSize(cost, COST_WIDTH, COST_HEIGHT)
call BlzFrameSetEnable(cost, false)
call BlzFrameSetScale(cost, COST_SCALE)
call BlzFrameSetTextAlignment(cost, TEXT_JUSTIFY_CENTER, TEXT_JUSTIFY_LEFT)
if item != 0 then
set button.icon = item.icon
set button.tooltip.text = item.tooltip
set button.tooltip.name = item.name
set button.tooltip.icon = item.icon
call BlzFrameSetText(cost, "|cffFFCC00" + I2S(item.gold) + "|r")
endif
return this
endmethod
endstruct
private struct ShopSlot extends Slot
Shop shop
Slot next
Slot prev
Slot right
Slot left
integer row
integer column
method destroy takes nothing returns nothing
call table.remove(GetHandleId(button.frame))
call deallocate()
endmethod
method move takes integer row, integer column returns nothing
set .row = row
set .column = column
set x = 0.030000 + ((SLOT_WIDTH + SLOT_GAP_X) * column)
set y = - (0.030000 + ((SLOT_HEIGHT + SLOT_GAP_Y) * row))
call update()
endmethod
method update takes nothing returns nothing
if column <= (shop.columns / 2) and row < 3 then
set button.tooltip.point = FRAMEPOINT_TOPLEFT
elseif column >= ((shop.columns / 2) + 1) and row < 3 then
set button.tooltip.point = FRAMEPOINT_TOPRIGHT
elseif column <= (shop.columns / 2) and row >= 3 then
set button.tooltip.point = FRAMEPOINT_BOTTOMLEFT
else
set button.tooltip.point = FRAMEPOINT_BOTTOMRIGHT
endif
endmethod
static method create takes Shop shop, Item i, integer row, integer column returns thistype
local thistype this = thistype.allocate(shop.main, i, 0.030000 + ((SLOT_WIDTH + SLOT_GAP_X) * column), - (0.030000 + ((SLOT_HEIGHT + SLOT_GAP_Y) * row)), FRAMEPOINT_TOPLEFT, false)
set .shop = shop
set next = 0
set prev = 0
set right = 0
set left = 0
set .row = row
set .column = column
set onClick = function thistype.onClicked
set onScroll = function thistype.onScrolled
set onDoubleClick = function thistype.onDoubleClicked
set onRightClick = function thistype.onRightClicked
set table[GetHandleId(button.frame)][0] = this
call update()
return this
endmethod
static method onScrolled takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())][0]
if this != 0 then
if GetLocalPlayer() == GetTriggerPlayer() then
call shop.scroll(BlzGetTriggerFrameValue() < 0)
endif
endif
endmethod
static method onClicked takes nothing returns nothing
local player p = GetTriggerPlayer()
local framehandle frame = BlzGetTriggerFrame()
local thistype this = table[GetHandleId(frame)][0]
local integer id = GetPlayerId(p)
if this != 0 then
call BlzFrameSetEnable(frame, false)
call BlzFrameSetEnable(frame, true)
if Shop.tag[id] then
call shop.favorites.add(item, p)
else
call shop.detail(item, p)
// if GetLocalPlayer() == p then
// if shop.lastClicked[id] != 0 then
// call Button(shop.lastClicked[id]).display(null, 0, 0, 0, null, null, 0, 0)
// endif
// call button.display(ITEM_HIGHLIGHT, HIGHLIGHT_WIDTH, HIGHLIGHT_HEIGHT, HIGHLIGHT_SCALE, FRAMEPOINT_BOTTOMLEFT, FRAMEPOINT_BOTTOMLEFT, HIGHLIGHT_XOFFSET, HIGHLIGHT_YOFFSET)
// set shop.lastClicked[id] = button
// endif
endif
endif
set p = null
set frame = null
endmethod
static method onDoubleClicked takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())][0]
if this != 0 then
if shop.buy(item, GetTriggerPlayer()) then
if GetLocalPlayer() == GetTriggerPlayer() then
call button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
endif
endmethod
static method onRightClicked takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())][0]
if this != 0 then
if shop.buy(item, GetTriggerPlayer()) then
if GetLocalPlayer() == GetTriggerPlayer() then
call button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
endif
endmethod
endstruct
private struct Transaction
private integer index
Shop shop
Item item
unit unit
player player
string type
integer gold
Table component
method destroy takes nothing returns nothing
call component.destroy()
call deallocate()
set unit = null
set player = null
endmethod
method rollback takes nothing returns nothing
local integer i = 0
local integer j = 0
local integer id = GetPlayerId(player)
if IsUnitInGroup(unit, shop.group[id]) then
if type == "buy" then
if UnitHasItemOfType(unit, item.id) then
loop
exitwhen i == UnitInventorySize(unit)
if GetItemTypeId(UnitItemInSlot(unit, i)) == item.id then
call RemoveItem(UnitItemInSlot(unit, i))
exitwhen true
endif
set i = i + 1
endloop
set i = 0
loop
exitwhen i == index
call UnitAddItemById(unit, Item(component[i]).id)
set i = i + 1
endloop
call SetPlayerState(player, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(player, PLAYER_STATE_RESOURCE_GOLD) + gold)
if not GetSoundIsPlaying(shop.success) then
call StartSoundForPlayerBJ(player, shop.success)
endif
else
if not GetSoundIsPlaying(shop.error) then
call StartSoundForPlayerBJ(player, shop.error)
endif
endif
elseif type == "sell" then
call UnitAddItemById(unit, item.id)
call SetPlayerState(player, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(player, PLAYER_STATE_RESOURCE_GOLD) - gold)
if not GetSoundIsPlaying(shop.success) then
call StartSoundForPlayerBJ(player, shop.success)
endif
else
loop
exitwhen i == item.components
set j = 0
loop
exitwhen j == UnitInventorySize(unit)
if GetItemTypeId(UnitItemInSlot(unit, j)) == Item.get(item.component[i]).id then
call RemoveItem(UnitItemInSlot(unit, j))
exitwhen true
endif
set j = j + 1
endloop
set i = i + 1
endloop
call UnitAddItemById(unit, item.id)
if not GetSoundIsPlaying(shop.success) then
call StartSoundForPlayerBJ(player, shop.success)
endif
endif
else
if not GetSoundIsPlaying(shop.error) then
call StartSoundForPlayerBJ(player, shop.error)
endif
endif
set shop.transactionCount[id] = shop.transactionCount[id] - 1
call shop.transaction[id].remove(shop.transactionCount[id])
call destroy()
endmethod
method add takes Item i returns nothing
if i != 0 then
set component[index] = i
set index = index + 1
endif
endmethod
static method create takes Shop shop, unit u, Item i, string transaction returns thistype
local thistype this = thistype.allocate()
set item = i
set unit = u
set .shop = shop
set type = transaction
set index = 0
set player = GetOwningPlayer(u)
set component = Table.create()
return this
endmethod
endstruct
private struct Detail
readonly static trigger trigger = CreateTrigger()
private boolean isVisible
Shop shop
Table item
Table main
Table center
Table left1
Table left2
Table right1
Table right2
Table count
HashTable used
HashTable button
Button close
Button left
Button right
framehandle frame
framehandle tooltip
framehandle topSeparator
framehandle bottomSeparator
framehandle usedIn
framehandle scrollFrame
framehandle horizontalRight
framehandle horizontalLeft
framehandle verticalMain
framehandle verticalCenter
framehandle verticalLeft1
framehandle verticalLeft2
framehandle verticalRight1
framehandle verticalRight2
method operator visible= takes boolean visibility returns nothing
set isVisible = visibility
call BlzFrameSetVisible(frame, visibility)
endmethod
method operator visible takes nothing returns boolean
return isVisible
endmethod
method destroy takes nothing returns nothing
local integer i = 0
local integer j = 0
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
call table.remove(GetHandleId(Slot(main[i]).button.frame))
call table.remove(GetHandleId(Slot(center[i]).button.frame))
call table.remove(GetHandleId(Slot(left1[i]).button.frame))
call table.remove(GetHandleId(Slot(left2[i]).button.frame))
call table.remove(GetHandleId(Slot(right1[i]).button.frame))
call table.remove(GetHandleId(Slot(right2[i]).button.frame))
call Slot(main[i]).destroy()
call Slot(center[i]).destroy()
call Slot(left1[i]).destroy()
call Slot(left2[i]).destroy()
call Slot(right1[i]).destroy()
call Slot(right2[i]).destroy()
set j = 0
loop
exitwhen j == DETAIL_USED_COUNT
call table.remove(GetHandleId(Button(button[i][j]).frame))
call Button(button[i][j]).destroy()
set j = j + 1
endloop
call button.remove(i)
call used.remove(i)
set i = i + 1
endloop
call main.destroy()
call center.destroy()
call left1.destroy()
call left2.destroy()
call right1.destroy()
call right2.destroy()
call count.destroy()
call item.destroy()
call used.destroy()
call button.destroy()
call BlzDestroyFrame(topSeparator)
call BlzDestroyFrame(bottomSeparator)
call BlzDestroyFrame(usedIn)
call BlzDestroyFrame(scrollFrame)
call BlzDestroyFrame(horizontalRight)
call BlzDestroyFrame(horizontalLeft)
call BlzDestroyFrame(verticalMain)
call BlzDestroyFrame(verticalCenter)
call BlzDestroyFrame(verticalLeft1)
call BlzDestroyFrame(verticalLeft2)
call BlzDestroyFrame(verticalRight1)
call BlzDestroyFrame(verticalRight2)
call BlzDestroyFrame(tooltip)
call BlzDestroyFrame(frame)
call deallocate()
set frame = null
set tooltip = null
set topSeparator = null
set bottomSeparator = null
set usedIn = null
set scrollFrame = null
set horizontalRight = null
set horizontalLeft = null
set verticalMain = null
set verticalCenter = null
set verticalLeft1 = null
set verticalLeft2 = null
set verticalRight1 = null
set verticalRight2 = null
endmethod
method update takes framehandle frame, framepointtype point, framehandle parent, framepointtype relative, real width, real height, real x, real y, boolean visible returns nothing
if visible then
call BlzFrameClearAllPoints(frame)
call BlzFrameSetPoint(frame, point, parent, relative, x, y)
call BlzFrameSetSize(frame, width, height)
endif
call BlzFrameSetVisible(frame, visible)
endmethod
method shift takes boolean left, player p returns nothing
local Item i
local integer j
local integer id = GetPlayerId(p)
if left then
if Item(item[id]).relation.has(count[id]) and count[id] >= DETAIL_USED_COUNT then
set j = 0
loop
exitwhen j == DETAIL_USED_COUNT - 1
set used[id][j] = used[id][j + 1]
if GetLocalPlayer() == p then
set Button(button[id][j]).icon = Item(used[id][j]).icon
set Button(button[id][j]).tooltip.text = Item(used[id][j]).tooltip
set Button(button[id][j]).tooltip.name = Item(used[id][j]).name
set Button(button[id][j]).tooltip.icon = Item(used[id][j]).icon
set Button(button[id][j]).available = shop.has(Item(used[id][j]).id)
set Button(button[id][j]).visible = true
endif
set j = j + 1
endloop
set i = Item.get(Item(item[id]).relation[count[id]])
if i != 0 then
set count[id] = count[id] + 1
set used[id][j] = i
if GetLocalPlayer() == p then
set Button(button[id][j]).icon = i.icon
set Button(button[id][j]).tooltip.text = i.tooltip
set Button(button[id][j]).tooltip.name = i.name
set Button(button[id][j]).tooltip.icon = i.icon
set Button(button[id][j]).available = shop.has(i.id)
set Button(button[id][j]).visible = true
endif
endif
endif
else
if count.integer[id] > DETAIL_USED_COUNT then
set j = DETAIL_USED_COUNT - 1
loop
exitwhen j == 0
set used[id][j] = used[id][j - 1]
if GetLocalPlayer() == p then
set Button(button[id][j]).icon = Item(used[id][j]).icon
set Button(button[id][j]).tooltip.text = Item(used[id][j]).tooltip
set Button(button[id][j]).tooltip.name = Item(used[id][j]).name
set Button(button[id][j]).tooltip.icon = Item(used[id][j]).icon
set Button(button[id][j]).available = shop.has(Item(used[id][j]).id)
set Button(button[id][j]).visible = true
endif
set j = j - 1
endloop
set i = Item.get(Item(item[id]).relation[count[id] - DETAIL_USED_COUNT - 1])
if i != 0 then
set count[id] = count[id] - 1
set used[id][j] = i
if GetLocalPlayer() == p then
set Button(button[id][j]).icon = i.icon
set Button(button[id][j]).tooltip.text = i.tooltip
set Button(button[id][j]).tooltip.name = i.name
set Button(button[id][j]).tooltip.icon = i.icon
set Button(button[id][j]).available = shop.has(i.id)
set Button(button[id][j]).visible = true
endif
endif
endif
endif
endmethod
method showUsed takes player p returns nothing
local Item i
local integer j = 0
local integer id = GetPlayerId(p)
if GetLocalPlayer() == p then
loop
exitwhen j == DETAIL_USED_COUNT
set Button(button[id][j]).visible = false
set j = j + 1
endloop
endif
set j = 0
loop
exitwhen not Item(item[id]).relation.has(j) or j == DETAIL_USED_COUNT
set i = Item.get(Item(item[id]).relation[j])
if i != 0 then
set used[id][j] = i
if GetLocalPlayer() == p then
set Button(button[id][count[id]]).icon = i.icon
set Button(button[id][count[id]]).tooltip.text = i.tooltip
set Button(button[id][count[id]]).tooltip.name = i.name
set Button(button[id][count[id]]).tooltip.icon = i.icon
set Button(button[id][count[id]]).visible = true
set Button(button[id][count[id]]).available = shop.has(i.id)
endif
set count[id] = count[id] + 1
endif
set j = j + 1
endloop
endmethod
method refresh takes player p returns nothing
local integer id = GetPlayerId(p)
if isVisible and item[id] != 0 then
call show(item[id], p)
endif
endmethod
method show takes Item i, player p returns nothing
local Item component
local Slot slot
local integer j = 0
local integer k = 0
local integer cost
local integer id = GetPlayerId(p)
local Table counter = Table.create()
if i != 0 then
set item[id] = i
set count[id] = 0
set cost = i.gold
set Slot(main[id]).item = i
call showUsed(p)
if i.components > 0 then
loop
exitwhen j == i.components or k == 5
set component = Item.get(i.component[j])
if component != 0 then
if i.components == 1 then
set slot = center[id]
if GetLocalPlayer() == p then
set Slot(left1[id]).visible = false
set Slot(left2[id]).visible = false
set Slot(right1[id]).visible = false
set Slot(right2[id]).visible = false
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.13625, - 0.10200, true)
call update(verticalMain, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.15600, - 0.082500, true)
call update(verticalCenter, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.15600, - 0.092500, true)
call BlzFrameSetVisible(horizontalLeft, false)
call BlzFrameSetVisible(horizontalRight, false)
call BlzFrameSetVisible(verticalLeft1, false)
call BlzFrameSetVisible(verticalLeft2, false)
call BlzFrameSetVisible(verticalRight1, false)
call BlzFrameSetVisible(verticalRight2, false)
endif
elseif i.components == 2 then
if j == 0 then
set slot = left1[id]
if GetLocalPlayer() == p then
set Slot(center[id]).visible = false
set Slot(left2[id]).visible = false
set Slot(right2[id]).visible = false
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.087250, - 0.10200, true)
call update(verticalMain, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.15600, - 0.082500, true)
call update(horizontalLeft, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.048, 0.001, 0.10700, - 0.091500, true)
call update(verticalLeft1, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.10700, - 0.092500, true)
call BlzFrameSetVisible(verticalCenter, false)
call BlzFrameSetVisible(verticalLeft2, false)
endif
else
set slot = right1[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.18525, - 0.10200, true)
call update(horizontalRight, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.048, 0.001, 0.15700, - 0.091500, true)
call update(verticalRight1, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.20500, - 0.092500, true)
call BlzFrameSetVisible(verticalRight2, false)
endif
endif
elseif i.components == 3 then
if j == 0 then
set slot = left2[id]
if GetLocalPlayer() == p then
set Slot(left1[id]).visible = false
set Slot(right1[id]).visible = false
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.038250, - 0.10200, true)
call update(verticalMain, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.15600, - 0.082500, true)
call update(horizontalLeft, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.1, 0.001, 0.057000, - 0.091500, true)
call update(verticalLeft2, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.057000, - 0.092500, true)
call BlzFrameSetVisible(verticalLeft1, false)
endif
elseif j == 1 then
set slot = center[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.13625, - 0.10200, true)
call update(verticalCenter, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.15600, - 0.092500, true)
endif
else
set slot = right2[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.23425, - 0.10200, true)
call update(horizontalRight, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.1, 0.001, 0.15700, - 0.091500, true)
call update(verticalRight2, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.25600, - 0.092500, true)
call BlzFrameSetVisible(verticalRight1, false)
endif
endif
elseif i.components == 4 then
if j == 0 then
set slot = left2[id]
if GetLocalPlayer() == p then
set Slot(right2[id]).visible = false
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.038250, - 0.10200, true)
call update(verticalMain, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.15600, - 0.082500, true)
call update(horizontalLeft, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.1, 0.001, 0.057000, - 0.091500, true)
call update(verticalLeft2, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.057000, - 0.092500, true)
endif
elseif j == 1 then
set slot = left1[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.10350, - 0.10200, true)
call update(verticalLeft1, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.12250, - 0.092500, true)
endif
elseif j == 2 then
set slot = center[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.16875, - 0.10200, true)
call update(verticalRight1, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.18950, - 0.092500, true)
call BlzFrameSetVisible(verticalCenter, false)
endif
else
set slot = right1[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.23400, - 0.10200, true)
call update(horizontalRight, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.1, 0.001, 0.15700, - 0.091500, true)
call update(verticalRight2, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.25600, - 0.092500, true)
endif
endif
else
if j == 0 then
set slot = left2[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.038250, - 0.10200, true)
call update(verticalMain, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.15600, - 0.082500, true)
call update(horizontalLeft, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.1, 0.001, 0.057000, - 0.091500, true)
call update(verticalLeft2, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.057000, - 0.092500, true)
endif
elseif j == 1 then
set slot = left1[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.087250, - 0.10200, true)
call update(verticalLeft1, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.10700, - 0.092500, true)
endif
elseif j == 2 then
set slot = center[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.13625, - 0.10200, true)
call update(verticalCenter, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.15600, - 0.092500, true)
endif
elseif j == 3 then
set slot = right1[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.18525, - 0.10200, true)
call update(verticalRight1, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.20500, - 0.092500, true)
endif
else
set slot = right2[id]
if GetLocalPlayer() == p then
call update(slot.slot, FRAMEPOINT_TOPLEFT, slot.parent, FRAMEPOINT_TOPLEFT, SLOT_WIDTH, SLOT_HEIGHT, 0.23425, - 0.10200, true)
call update(horizontalRight, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.1, 0.001, 0.15700, - 0.091500, true)
call update(verticalRight2, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.001, 0.01, 0.25600, - 0.092500, true)
endif
endif
endif
set slot.item = component
set slot.button.icon = component.icon
set slot.button.tooltip.text = component.tooltip
set slot.button.tooltip.name = component.name
set slot.button.tooltip.icon = component.icon
set slot.button.available = shop.has(component.id)
call BlzFrameSetText(slot.cost, "|cffFFCC00" + I2S(component.gold) + "|r")
if shop.buyer.selected.unit[id] != null then
if UnitHasItemOfType(shop.buyer.selected.unit[id], component.id) then
if UnitCountItemOfType(shop.buyer.selected.unit[id], component.id) >= i.count(component.id) then
set slot.button.checked = true
else
set counter[component.id] = counter[component.id] + 1
set slot.button.checked = counter[component.id] <= UnitCountItemOfType(shop.buyer.selected.unit[id], component.id)
endif
else
set slot.button.checked = false
endif
else
set slot.button.checked = false
endif
if slot.button.checked then
set cost = cost - component.gold
endif
if GetLocalPlayer() == p then
set slot.visible = true
endif
set j = j + 1
endif
set k = k + 1
endloop
else
if GetLocalPlayer() == p then
set Slot(center[id]).visible = false
set Slot(left1[id]).visible = false
set Slot(left2[id]).visible = false
set Slot(right1[id]).visible = false
set Slot(right2[id]).visible = false
call BlzFrameSetVisible(horizontalLeft, false)
call BlzFrameSetVisible(horizontalRight, false)
call BlzFrameSetVisible(verticalMain, false)
call BlzFrameSetVisible(verticalCenter, false)
call BlzFrameSetVisible(verticalLeft1, false)
call BlzFrameSetVisible(verticalLeft2, false)
call BlzFrameSetVisible(verticalRight1, false)
call BlzFrameSetVisible(verticalRight2, false)
endif
endif
set Slot(main[id]).button.icon = i.icon
set Slot(main[id]).button.tooltip.text = i.tooltip
set Slot(main[id]).button.tooltip.name = i.name
set Slot(main[id]).button.tooltip.icon = i.icon
set Slot(main[id]).button.available = shop.has(i.id)
if GetLocalPlayer() == p then
call BlzFrameSetText(Slot(main[id]).cost, "|cffFFCC00" + I2S(cost) + "|r")
call BlzFrameSetText(tooltip, i.tooltip)
set visible = true
endif
endif
call counter.destroy()
endmethod
static method create takes Shop shop returns thistype
local thistype this = thistype.allocate()
local integer i = 0
local integer j
set .shop = shop
set isVisible = false
set item = Table.create()
set count = Table.create()
set main = Table.create()
set center = Table.create()
set left1 = Table.create()
set left2 = Table.create()
set right1 = Table.create()
set right2 = Table.create()
set used = HashTable.create()
set button = HashTable.create()
set frame = BlzCreateFrame("EscMenuBackdrop", shop.main, 0, 0)
set topSeparator = BlzCreateFrameByType("BACKDROP", "", frame, "", 0)
set bottomSeparator = BlzCreateFrameByType("BACKDROP", "", frame, "", 0)
set tooltip = BlzCreateFrame("DescriptionArea", frame, 0, 0)
set horizontalLeft = BlzCreateFrameByType("BACKDROP", "", frame, "", 0)
set horizontalRight = BlzCreateFrameByType("BACKDROP", "", frame, "", 0)
set verticalMain = BlzCreateFrameByType("BACKDROP", "", frame, "", 0)
set verticalCenter = BlzCreateFrameByType("BACKDROP", "", frame, "", 0)
set verticalLeft1 = BlzCreateFrameByType("BACKDROP", "", frame, "", 0)
set verticalLeft2 = BlzCreateFrameByType("BACKDROP", "", frame, "", 0)
set verticalRight1 = BlzCreateFrameByType("BACKDROP", "", frame, "", 0)
set verticalRight2 = BlzCreateFrameByType("BACKDROP", "", frame, "", 0)
set scrollFrame = BlzCreateFrameByType("BUTTON", "", frame, "", 0)
set usedIn = BlzCreateFrameByType("TEXT", "", scrollFrame, "", 0)
set close = Button.create(frame, DETAIL_CLOSE_BUTTON_SIZE, DETAIL_CLOSE_BUTTON_SIZE, 0.26676, - 0.025000, true)
set close.icon = CLOSE_ICON
set close.onClick = function thistype.onClick
set close.tooltip.text = "Close"
set left = Button.create(scrollFrame, DETAIL_SHIFT_BUTTON_SIZE, DETAIL_SHIFT_BUTTON_SIZE, 0.0050000, - 0.0025000, true)
set left.icon = USED_LEFT
set left.onClick = function thistype.onClick
set left.tooltip.text = "Scroll Left"
set right = Button.create(scrollFrame, DETAIL_SHIFT_BUTTON_SIZE, DETAIL_SHIFT_BUTTON_SIZE, 0.24800, - 0.0025000, true)
set right.icon = USED_RIGHT
set right.onClick = function thistype.onClick
set right.tooltip.text = "Scroll Right"
set table[GetHandleId(close.frame)][0] = this
set table[GetHandleId(left.frame)][0] = this
set table[GetHandleId(right.frame)][0] = this
set table[GetHandleId(scrollFrame)][0] = this
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, shop.main, FRAMEPOINT_TOPLEFT, WIDTH - DETAIL_WIDTH, 0.0000)
call BlzFrameSetPoint(scrollFrame, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.022500, - 0.31550)
call BlzFrameSetPoint(topSeparator, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.027500, - 0.15585)
call BlzFrameSetPoint(bottomSeparator, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.027500, - 0.31585)
call BlzFrameSetPoint(usedIn, FRAMEPOINT_TOPLEFT, scrollFrame, FRAMEPOINT_TOPLEFT, 0.11500, - 0.0025000)
call BlzFrameSetPoint(tooltip, FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPLEFT, 0.027500, - 0.15950)
call BlzFrameSetSize(frame, DETAIL_WIDTH, DETAIL_HEIGHT)
call BlzFrameSetSize(scrollFrame, 0.26750, 0.06100)
call BlzFrameSetSize(topSeparator, 0.255, 0.001)
call BlzFrameSetSize(bottomSeparator, 0.255, 0.001)
call BlzFrameSetSize(usedIn, 0.04, 0.012)
call BlzFrameSetSize(tooltip, 0.31, 0.16)
call BlzFrameSetText(tooltip, "")
call BlzFrameSetText(usedIn, "|cffFFCC00 Used in|r")
call BlzFrameSetEnable(usedIn, false)
call BlzFrameSetScale(usedIn, 1.00)
call BlzFrameSetTextAlignment(usedIn, TEXT_JUSTIFY_TOP, TEXT_JUSTIFY_LEFT)
call BlzFrameSetTexture(bottomSeparator, "replaceabletextures\\teamcolor\\teamcolor08", 0, true)
call BlzFrameSetTexture(topSeparator, "replaceabletextures\\teamcolor\\teamcolor08", 0, true)
call BlzFrameSetTexture(horizontalLeft, "replaceabletextures\\teamcolor\\teamcolor08", 0, true)
call BlzFrameSetTexture(horizontalRight, "replaceabletextures\\teamcolor\\teamcolor08", 0, true)
call BlzFrameSetTexture(verticalMain, "replaceabletextures\\teamcolor\\teamcolor08", 0, true)
call BlzFrameSetTexture(verticalCenter, "replaceabletextures\\teamcolor\\teamcolor08", 0, true)
call BlzFrameSetTexture(verticalLeft1, "replaceabletextures\\teamcolor\\teamcolor08", 0, true)
call BlzFrameSetTexture(verticalLeft2, "replaceabletextures\\teamcolor\\teamcolor08", 0, true)
call BlzFrameSetTexture(verticalRight1, "replaceabletextures\\teamcolor\\teamcolor08", 0, true)
call BlzFrameSetTexture(verticalRight2, "replaceabletextures\\teamcolor\\teamcolor08", 0, true)
call BlzTriggerRegisterFrameEvent(trigger, scrollFrame, FRAMEEVENT_MOUSE_WHEEL)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set j = 0
set main[i] = Slot.create(frame, 0, 0.13625, - 0.030000, FRAMEPOINT_TOPRIGHT, false)
set Slot(main[i]).visible = GetLocalPlayer() == Player(i)
set Slot(main[i]).onClick = function thistype.onClick
set Slot(main[i]).onRightClick = function thistype.onRightClick
set Slot(main[i]).onDoubleClick = function thistype.onDoubleClick
set center[i] = Slot.create(frame, 0, 0.13625, - 0.10200, FRAMEPOINT_TOPRIGHT, false)
set Slot(center[i]).visible = false
set Slot(center[i]).onClick = function thistype.onClick
set Slot(center[i]).onRightClick = function thistype.onRightClick
set Slot(center[i]).onDoubleClick = function thistype.onDoubleClick
set left1[i] = Slot.create(frame, 0, 0.087250, - 0.10200, FRAMEPOINT_TOPRIGHT, false)
set Slot(left1[i]).visible = false
set Slot(left1[i]).onClick = function thistype.onClick
set Slot(left1[i]).onRightClick = function thistype.onRightClick
set Slot(left1[i]).onDoubleClick = function thistype.onDoubleClick
set left2[i] = Slot.create(frame, 0, 0.038250, - 0.10200, FRAMEPOINT_TOPRIGHT, false)
set Slot(left2[i]).visible = false
set Slot(left2[i]).onClick = function thistype.onClick
set Slot(left2[i]).onRightClick = function thistype.onRightClick
set Slot(left2[i]).onDoubleClick = function thistype.onDoubleClick
set right1[i] = Slot.create(frame, 0, 0.18525, - 0.10200, FRAMEPOINT_TOPRIGHT, false)
set Slot(right1[i]).visible = false
set Slot(right1[i]).onClick = function thistype.onClick
set Slot(right1[i]).onRightClick = function thistype.onRightClick
set Slot(right1[i]).onDoubleClick = function thistype.onDoubleClick
set right2[i] = Slot.create(frame, 0, 0.23425, - 0.10200, FRAMEPOINT_TOPRIGHT, false)
set Slot(right2[i]).visible = false
set Slot(right2[i]).onClick = function thistype.onClick
set Slot(right2[i]).onRightClick = function thistype.onRightClick
set Slot(right2[i]).onDoubleClick = function thistype.onDoubleClick
set table[GetHandleId(Slot(main[i]).button.frame)][0] = this
set table[GetHandleId(Slot(center[i]).button.frame)][0] = this
set table[GetHandleId(Slot(left1[i]).button.frame)][0] = this
set table[GetHandleId(Slot(left2[i]).button.frame)][0] = this
set table[GetHandleId(Slot(right1[i]).button.frame)][0] = this
set table[GetHandleId(Slot(right2[i]).button.frame)][0] = this
loop
exitwhen j == DETAIL_USED_COUNT
set button[i][j] = Button.create(scrollFrame, DETAIL_BUTTON_SIZE, DETAIL_BUTTON_SIZE, 0.0050000 + DETAIL_BUTTON_GAP*j, - 0.019500, false)
set Button(button[i][j]).onClick = function thistype.onClick
set Button(button[i][j]).onScroll = function thistype.onScroll
set Button(button[i][j]).onRightClick = function thistype.onRightClick
set Button(button[i][j]).tooltip.point = FRAMEPOINT_BOTTOMRIGHT
set Button(button[i][j]).visible = false
set table[GetHandleId(Button(button[i][j]).frame)][0] = this
set table[GetHandleId(Button(button[i][j]).frame)][1] = j
set j = j + 1
endloop
set i = i + 1
endloop
call BlzFrameSetVisible(frame, false)
return this
endmethod
static method onScroll takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())][0]
if this != 0 then
call shift(BlzGetTriggerFrameValue() < 0, GetTriggerPlayer())
endif
endmethod
static method onClick takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local thistype this = table[GetHandleId(frame)][0]
local integer i = table[GetHandleId(frame)][1]
local integer id = GetPlayerId(GetTriggerPlayer())
if this != 0 then
call BlzFrameSetEnable(frame, false)
call BlzFrameSetEnable(frame, true)
if frame == close.frame then
call shop.detail(0, GetTriggerPlayer())
elseif frame == left.frame then
call shift(false, GetTriggerPlayer())
elseif frame == right.frame then
call shift(true, GetTriggerPlayer())
elseif frame == Slot(center[id]).button.frame then
if Shop.tag[id] then
call shop.favorites.add(Slot(center[id]).item, GetTriggerPlayer())
else
static if DETAIL_COMPONENT then
call shop.detail(Slot(center[id]).item, GetTriggerPlayer())
endif
endif
elseif frame == Slot(left1[id]).button.frame then
if Shop.tag[id] then
call shop.favorites.add(Slot(left1[id]).item, GetTriggerPlayer())
else
static if DETAIL_COMPONENT then
call shop.detail(Slot(left1[id]).item, GetTriggerPlayer())
endif
endif
elseif frame == Slot(left2[id]).button.frame then
if Shop.tag[id] then
call shop.favorites.add(Slot(left2[id]).item, GetTriggerPlayer())
else
static if DETAIL_COMPONENT then
call shop.detail(Slot(left2[id]).item, GetTriggerPlayer())
endif
endif
elseif frame == Slot(right1[id]).button.frame then
if Shop.tag[id] then
call shop.favorites.add(Slot(right1[id]).item, GetTriggerPlayer())
else
static if DETAIL_COMPONENT then
call shop.detail(Slot(right1[id]).item, GetTriggerPlayer())
endif
endif
elseif frame == Slot(right2[id]).button.frame then
if Shop.tag[id] then
call shop.favorites.add(Slot(right2[id]).item, GetTriggerPlayer())
else
static if DETAIL_COMPONENT then
call shop.detail(Slot(right2[id]).item, GetTriggerPlayer())
endif
endif
elseif frame != Slot(main[id]).button.frame then
if Shop.tag[id] then
call shop.favorites.add(used[id][i], GetTriggerPlayer())
else
call shop.detail(used[id][i], GetTriggerPlayer())
endif
elseif frame == Slot(main[id]).button.frame then
if Shop.tag[id] then
call shop.favorites.add(Slot(main[id]).item, GetTriggerPlayer())
else
call shop.select(Slot(main[id]).item, GetTriggerPlayer())
endif
endif
endif
set frame = null
endmethod
static method onRightClick takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local player p = GetTriggerPlayer()
local thistype this = table[GetHandleId(frame)][0]
local integer i = table[GetHandleId(frame)][1]
local integer id = GetPlayerId(p)
if this != 0 then
if frame == Slot(main[id]).button.frame then
if shop.buy(Slot(main[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(main[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
elseif frame == Slot(center[id]).button.frame then
if shop.buy(Slot(center[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(center[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
elseif frame == Slot(left1[id]).button.frame then
if shop.buy(Slot(left1[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(left1[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
elseif frame == Slot(left2[id]).button.frame then
if shop.buy(Slot(left2[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(left2[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
elseif frame == Slot(right1[id]).button.frame then
if shop.buy(Slot(right1[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(right1[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
elseif frame == Slot(right2[id]).button.frame then
if shop.buy(Slot(right2[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(right2[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
else
if shop.buy(used[id][i], p) then
if GetLocalPlayer() == p then
call Button(button[id][i]).play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
endif
endif
set p =null
set frame = null
endmethod
static method onDoubleClick takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local player p = GetTriggerPlayer()
local thistype this = table[GetHandleId(frame)][0]
local integer i = table[GetHandleId(frame)][1]
local integer id = GetPlayerId(p)
if this != 0 then
if frame == Slot(main[id]).button.frame then
if shop.buy(Slot(main[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(main[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
elseif frame == Slot(center[id]).button.frame then
if shop.buy(Slot(center[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(center[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
elseif frame == Slot(left1[id]).button.frame then
if shop.buy(Slot(left1[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(left1[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
elseif frame == Slot(left2[id]).button.frame then
if shop.buy(Slot(left2[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(left2[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
elseif frame == Slot(right1[id]).button.frame then
if shop.buy(Slot(right1[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(right1[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
elseif frame == Slot(right2[id]).button.frame then
if shop.buy(Slot(right2[id]).item, p) then
if GetLocalPlayer() == p then
call Slot(right2[id]).button.play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
else
if shop.buy(used[id][i], p) then
if GetLocalPlayer() == p then
call Button(button[id][i]).play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
endif
endif
set p =null
set frame = null
endmethod
static method onInit takes nothing returns nothing
call TriggerAddAction(trigger, function thistype.onScroll)
endmethod
endstruct
private struct Inventory
private boolean isVisible
Shop shop
framehandle frame
framehandle scrollFrame
Table selected
HashTable item
HashTable button
method operator visible= takes boolean visibility returns nothing
set isVisible = visibility
call BlzFrameSetVisible(frame, visibility)
endmethod
method operator visible takes nothing returns boolean
return isVisible
endmethod
method destroy takes nothing returns nothing
local integer i = 0
local integer j
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set j = 0
loop
exitwhen j == INVENTORY_COUNT
call table.remove(GetHandleId(Button(button[i][j]).frame))
call Button(button[i][j]).destroy()
set j = j + 1
endloop
call button.remove(i)
call item.remove(i)
set i = i + 1
endloop
call BlzDestroyFrame(frame)
call BlzDestroyFrame(scrollFrame)
call selected.destroy()
call button.destroy()
call item.destroy()
call deallocate()
set frame = null
set scrollFrame = null
endmethod
method move takes framepointtype point, framehandle relative, framepointtype relativePoint returns nothing
call BlzFrameClearAllPoints(frame)
call BlzFrameSetPoint(frame, point, relative, relativePoint, 0, 0)
endmethod
method show takes unit u returns nothing
local item i
local integer j = 0
local integer id = GetPlayerId(GetOwningPlayer(u))
if u != null then
loop
exitwhen j == INVENTORY_COUNT
set i = UnitItemInSlot(u, j)
if i != null then
set item[id][j] = Item.get(GetItemTypeId(i))
if GetLocalPlayer() == GetOwningPlayer(u) then
set Button(button[id][j]).icon = Item(item[id][j]).icon
set Button(button[id][j]).tooltip.icon = Item(item[id][j]).icon
set Button(button[id][j]).tooltip.name = Item(item[id][j]).name
set Button(button[id][j]).tooltip.text = Item(item[id][j]).tooltip
set Button(button[id][j]).visible = true
endif
else
set item[id][j] = 0
if GetLocalPlayer() == GetOwningPlayer(u) then
set Button(button[id][j]).visible = false
endif
endif
set j = j + 1
endloop
else
loop
exitwhen j == INVENTORY_COUNT
set item[id][j] = 0
if GetLocalPlayer() == GetOwningPlayer(u) then
set Button(button[id][j]).visible = false
endif
set j = j + 1
endloop
endif
set i = null
endmethod
static method create takes Shop shop returns thistype
local thistype this = thistype.allocate()
local integer i = 0
local integer j = 0
set .shop = shop
set isVisible = true
set selected = Table.create()
set item = HashTable.create()
set button = HashTable.create()
set frame = BlzCreateFrameByType("BACKDROP", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
set scrollFrame = BlzCreateFrameByType("BUTTON", "", frame, "", 0)
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, shop.buyer.frame, FRAMEPOINT_TOPLEFT, 0, 0)
call BlzFrameSetSize(frame, INVENTORY_WIDTH, INVENTORY_HEIGHT)
call BlzFrameSetTexture(frame, INVENTORY_TEXTURE, 0, false)
call BlzFrameSetAllPoints(scrollFrame, frame)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set j = 0
loop
exitwhen j == INVENTORY_COUNT
set button[i][j] = Button.create(scrollFrame, INVENTORY_SIZE, INVENTORY_SIZE, 0.0033700 + INVENTORY_GAP*j, - 0.0037500, false)
set Button(button[i][j]).tooltip.point = FRAMEPOINT_BOTTOM
set Button(button[i][j]).onClick = function thistype.onClick
set Button(button[i][j]).onDoubleClick = function thistype.onDoubleClick
set Button(button[i][j]).onRightClick = function thistype.onRightClick
set Button(button[i][j]).visible = false
set table[GetHandleId(Button(button[i][j]).frame)][0] = this
set table[GetHandleId(Button(button[i][j]).frame)][1] = j
set j = j + 1
endloop
set i = i + 1
endloop
return this
endmethod
static method onClick takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local thistype this = table[GetHandleId(frame)][0]
local integer i = table[GetHandleId(frame)][1]
if this != 0 then
set selected[GetPlayerId(GetTriggerPlayer())] = i
endif
set frame = null
endmethod
static method onDoubleClick takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local player p = GetTriggerPlayer()
local thistype this = table[GetHandleId(frame)][0]
local integer i = table[GetHandleId(frame)][1]
local integer id = GetPlayerId(p)
if this != 0 then
if shop.sell(item[id][i], p, i) then
call show(shop.buyer.selected.unit[id])
endif
endif
set p = null
set frame = null
endmethod
static method onRightClick takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local player p = GetTriggerPlayer()
local thistype this = table[GetHandleId(frame)][0]
local integer i = table[GetHandleId(frame)][1]
local integer id = GetPlayerId(p)
if this != 0 then
if shop.sell(item[id][i], p, i) then
call show(shop.buyer.selected.unit[id])
endif
endif
set p = null
set frame = null
endmethod
endstruct
private struct Buyer
private static Table current
readonly static trigger trigger = CreateTrigger()
private boolean isVisible
Shop shop
Inventory inventory
Button left
Button right
Table last
Table index
Table size
Table selected
HashTable button
HashTable unit
framehandle frame
framehandle scrollFrame
method operator visible= takes boolean visibility returns nothing
local integer i = 0
local integer id = GetPlayerId(GetLocalPlayer())
set isVisible = visibility
set inventory.visible = visibility
if isVisible then
loop
exitwhen i == BUYER_COUNT
if unit[id].unit[i] == selected.unit[id] then
call inventory.move(FRAMEPOINT_TOP, Button(button[id][i]).frame, FRAMEPOINT_BOTTOM)
exitwhen true
endif
set i = i + 1
endloop
endif
call BlzFrameSetVisible(frame, visibility)
endmethod
method operator visible takes nothing returns boolean
return isVisible
endmethod
method destroy takes nothing returns nothing
local integer i = 0
local integer j
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set j = 0
loop
exitwhen j == BUYER_COUNT
call table.remove(GetHandleId(Button(button[i][j]).frame))
call Button(button[i][j]).destroy()
set j = j + 1
endloop
call button.remove(i)
call unit.remove(i)
set i = i + 1
endloop
call BlzDestroyFrame(frame)
call BlzDestroyFrame(scrollFrame)
call button.destroy()
call unit.destroy()
call last.destroy()
call index.destroy()
call size.destroy()
call selected.destroy()
call left.destroy()
call right.destroy()
call inventory.destroy()
call deallocate()
set frame = null
set scrollFrame = null
endmethod
method shift takes boolean left, player p returns nothing
local integer id = GetPlayerId(p)
local boolean flag = false
local integer i
local unit u
if left then
if (index[id] + 1 + BUYER_COUNT) <= size[id] and size[id] > 0 then
set index[id] = index[id] + 1
set i = 0
loop
exitwhen i == BUYER_COUNT - 1
set unit[id].unit[i] = unit[id].unit[i + 1]
if GetLocalPlayer() == p then
set Button(button[id][i]).icon = Button(button[id][i + 1]).icon
set Button(button[id][i]).tooltip.text = Button(button[id][i + 1]).tooltip.text
set Button(button[id][i]).highlighted = selected.unit[id] == unit[id].unit[i]
set Button(button[id][i]).visible = true
if Button(button[id][i]).highlighted then
set flag = true
call inventory.move(FRAMEPOINT_TOP, Button(button[id][i]).frame, FRAMEPOINT_BOTTOM)
endif
endif
set i = i + 1
endloop
set u = BlzGroupUnitAt(shop.group[id], index[id] + BUYER_COUNT)
if u != null then
set unit[id].unit[i] = u
if GetLocalPlayer() == p then
set Button(button[id][i]).icon = BlzGetAbilityIcon(GetUnitTypeId(u))
set Button(button[id][i]).tooltip.text = GetUnitName(u)
set Button(button[id][i]).visible = true
set Button(button[id][i]).highlighted = selected.unit[id] == unit[id].unit[i]
if Button(button[id][i]).highlighted then
set flag = true
call inventory.move(FRAMEPOINT_TOP, Button(button[id][i]).frame, FRAMEPOINT_BOTTOM)
endif
endif
endif
if GetLocalPlayer() == p then
set inventory.visible = flag
endif
endif
else
if index[id] - 1 >= 0 and size[id] > 0 then
set index[id] = index[id] - 1
set i = BUYER_COUNT - 1
loop
exitwhen i == 0
set unit[id].unit[i] = unit[id].unit[i - 1]
if GetLocalPlayer() == p then
set Button(button[id][i]).icon = Button(button[id][i - 1]).icon
set Button(button[id][i]).tooltip.text = Button(button[id][i - 1]).tooltip.text
set Button(button[id][i]).highlighted = selected.unit[id] == unit[id].unit[i]
set Button(button[id][i]).visible = true
if Button(button[id][i]).highlighted then
set flag = true
call inventory.move(FRAMEPOINT_TOP, Button(button[id][i]).frame, FRAMEPOINT_BOTTOM)
endif
endif
set i = i - 1
endloop
set u = BlzGroupUnitAt(shop.group[id], index[id])
if u != null then
set unit[id].unit[i] = u
if GetLocalPlayer() == p then
set Button(button[id][i]).icon = BlzGetAbilityIcon(GetUnitTypeId(u))
set Button(button[id][i]).tooltip.text = GetUnitName(u)
set Button(button[id][i]).visible = true
set Button(button[id][i]).highlighted = selected.unit[id] == unit[id].unit[i]
if Button(button[id][i]).highlighted then
set flag = true
call inventory.move(FRAMEPOINT_TOP, Button(button[id][i]).frame, FRAMEPOINT_BOTTOM)
endif
endif
endif
if GetLocalPlayer() == p then
set inventory.visible = flag
endif
endif
endif
endmethod
method update takes group g, integer id returns nothing
local integer i = 0
local integer j
local unit u
set size[id] = BlzGroupGetSize(g)
if size[id] > 0 then
if (index.integer[id] + BUYER_COUNT) > size.integer[id] then
set index[id] = 0
endif
if not IsUnitInGroup(selected.unit[id], g) then
set index[id] = 0
call current.remove(GetHandleId(selected.unit[id]))
set selected.unit[id] = FirstOfGroup(g)
set current[GetHandleId(selected.unit[id])] = this
call IssueNeutralTargetOrder(Player(id), shop.current[id], "smart", selected.unit[id])
call inventory.show(selected.unit[id])
if GetLocalPlayer() == Player(id) then
call inventory.move(FRAMEPOINT_TOP, Button(button[id][0]).frame, FRAMEPOINT_BOTTOM)
call shop.details.refresh(Player(id))
endif
endif
set j = index[id]
loop
exitwhen i == BUYER_COUNT
if j >= size[id] then
set unit[id].unit[i] = null
if GetLocalPlayer() == Player(id) then
set Button(button[id][i]).visible = false
endif
else
set u = BlzGroupUnitAt(g, j)
set unit[id].unit[i] = u
if selected.unit[id] == u then
set last[id] = button[id][i]
endif
if GetLocalPlayer() == Player(id) then
set Button(button[id][i]).icon = BlzGetAbilityIcon(GetUnitTypeId(u))
set Button(button[id][i]).tooltip.text = GetUnitName(u)
set Button(button[id][i]).highlighted = selected.unit[id] == u
set Button(button[id][i]).visible = true
if Button(button[id][i]).highlighted then
set inventory.visible = true
call inventory.move(FRAMEPOINT_TOP, Button(button[id][i]).frame, FRAMEPOINT_BOTTOM)
endif
endif
set j = j + 1
endif
set i = i + 1
endloop
else
call current.remove(GetHandleId(selected.unit[id]))
set index[id] = 0
call selected.unit.remove(id)
if GetLocalPlayer() == Player(id) then
set inventory.visible = false
loop
exitwhen i == BUYER_COUNT
set unit[id].unit[i] = null
set Button(button[id][i]).highlighted = false
set Button(button[id][i]).visible = false
set i = i + 1
endloop
call shop.details.refresh(Player(id))
endif
endif
endmethod
static method create takes Shop shop returns thistype
local thistype this = thistype.allocate()
local integer i = 0
local integer j = 0
set .shop = shop
set isVisible = true
set last = Table.create()
set size = Table.create()
set index = Table.create()
set selected = Table.create()
set button = HashTable.create()
set unit = HashTable.create()
set frame = BlzCreateFrame("EscMenuBackdrop", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
set scrollFrame = BlzCreateFrameByType("BUTTON", "", frame, "", 0)
set left = Button.create(scrollFrame, BUYER_SHIFT_BUTTON_SIZE, BUYER_SHIFT_BUTTON_SIZE, 0.027500, - 0.032500, true)
set left.onClick = function thistype.onClick
set left.icon = BUYER_LEFT
set left.tooltip.text = "Scroll Left"
set right = Button.create(scrollFrame, BUYER_SHIFT_BUTTON_SIZE, BUYER_SHIFT_BUTTON_SIZE, 0.36350, - 0.032500, true)
set right.onClick = function thistype.onClick
set right.icon = BUYER_RIGHT
set right.tooltip.text = "Scroll Right"
set inventory = Inventory.create(shop)
set table[GetHandleId(left.frame)][0] = this
set table[GetHandleId(right.frame)][0] = this
set table[GetHandleId(scrollFrame)][0] = this
call BlzFrameSetPoint(frame, FRAMEPOINT_TOP, shop.base, FRAMEPOINT_BOTTOM, 0, 0.02750)
call BlzFrameSetSize(frame, BUYER_WIDTH, BUYER_HEIGHT)
call BlzFrameSetAllPoints(scrollFrame, frame)
call BlzTriggerRegisterFrameEvent(trigger, scrollFrame, FRAMEEVENT_MOUSE_WHEEL)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set j = 0
loop
exitwhen j == BUYER_COUNT
set button[i][j] = Button.create(scrollFrame, BUYER_SIZE, BUYER_SIZE, 0.045000 + BUYER_GAP*j, - 0.023000, true)
set Button(button[i][j]).onClick = function thistype.onClick
set Button(button[i][j]).onScroll = function thistype.onScroll
set Button(button[i][j]).visible = false
set table[GetHandleId(Button(button[i][j]).frame)][0] = this
set table[GetHandleId(Button(button[i][j]).frame)][1] = j
set j = j + 1
endloop
set i = i + 1
endloop
return this
endmethod
static method onScroll takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())][0]
if this != 0 then
call shift(BlzGetTriggerFrameValue() < 0, GetTriggerPlayer())
endif
endmethod
static method onClick takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local thistype this = table[GetHandleId(frame)][0]
local integer i = table[GetHandleId(frame)][1]
local integer id = GetPlayerId(GetTriggerPlayer())
if this != 0 then
if frame == left.frame then
call shift(false, GetTriggerPlayer())
elseif frame == right.frame then
call shift(true, GetTriggerPlayer())
else
call current.remove(GetHandleId(selected.unit[id]))
set selected.unit[id] = unit[id].unit[i]
set current[GetHandleId(selected.unit[id])] = this
call IssueNeutralTargetOrder(GetTriggerPlayer(), shop.current[id], "smart", selected.unit[id])
call inventory.show(selected.unit[id])
call inventory.selected.remove(id)
if GetLocalPlayer() == GetTriggerPlayer() then
set Button(last[id]).highlighted = false
set Button(button[id][i]).highlighted = true
set last[id] = button[id][i]
call inventory.move(FRAMEPOINT_TOP, Button(button[id][i]).frame, FRAMEPOINT_BOTTOM)
call shop.details.refresh(GetTriggerPlayer())
endif
endif
call BlzFrameSetEnable(frame, false)
call BlzFrameSetEnable(frame, true)
endif
set frame = null
endmethod
private static method onPickup takes nothing returns nothing
local unit u = GetManipulatingUnit()
local integer i = GetPlayerId(GetOwningPlayer(u))
local thistype this = current[GetHandleId(u)]
if this != 0 then
if shop.current[i] != null then
if selected.unit[i] == u and IsUnitInRange(u, shop.current[i], shop.aoe) then
call inventory.show(u)
call shop.details.refresh(GetOwningPlayer(u))
endif
endif
endif
set u = null
endmethod
private static method onDrop takes nothing returns nothing
local unit u = GetManipulatingUnit()
local integer i = GetPlayerId(GetOwningPlayer(u))
local thistype this = current[GetHandleId(u)]
if this != 0 then
if shop.current[i] != null then
if selected.unit[i] == u and IsUnitInRange(u, shop.current[i], shop.aoe) then
call shop.details.refresh(GetOwningPlayer(u))
endif
endif
endif
set u = null
endmethod
static method onInit takes nothing returns nothing
set current = Table.create()
call TriggerAddAction(trigger, function thistype.onScroll)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_PICKUP_ITEM, function thistype.onPickup)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DROP_ITEM, function thistype.onDrop)
endmethod
endstruct
private struct Favorites
Shop shop
Table count
HashTable item
HashTable button
method destroy takes nothing returns nothing
local integer i = 0
local integer j
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set j = 0
loop
exitwhen j == CATEGORY_COUNT
call table.remove(GetHandleId(Button(button[i][j]).frame))
call Button(button[i][j]).destroy()
set j = j + 1
endloop
call button.remove(i)
call item.remove(i)
set i = i + 1
endloop
call count.destroy()
call item.destroy()
call button.destroy()
call deallocate()
endmethod
method has takes integer id, player p returns boolean
local integer i = 0
local integer pid = GetPlayerId(p)
loop
exitwhen i > count.integer[pid]
if Item(item[pid][i]).id == id then
return true
endif
set i = i + 1
endloop
return false
endmethod
method clear takes player p returns nothing
local integer id = GetPlayerId(p)
loop
exitwhen count[id] == -1
if GetLocalPlayer() == p then
set Button(button[id][count[id]]).visible = false
call ShopSlot(table[shop][Item(item[id][count[id]]).id]).button.tag(null, 0, 0, 0, null, null, 0, 0)
endif
set count[id] = count[id] - 1
endloop
endmethod
method remove takes integer i, player p returns nothing
local integer id = GetPlayerId(p)
if GetLocalPlayer() == p then
call ShopSlot(table[shop][Item(item[id][i]).id]).button.tag(null, 0, 0, 0, null, null, 0, 0)
endif
loop
exitwhen i >= count[id]
set item[id][i] = item[id][i + 1]
if GetLocalPlayer() == p then
set Button(button[id][i]).icon = Item(item[id][i]).icon
set Button(button[id][i]).tooltip.text = Item(item[id][i]).tooltip
set Button(button[id][i]).tooltip.name = Item(item[id][i]).name
set Button(button[id][i]).tooltip.icon = Item(item[id][i]).icon
endif
set i = i + 1
endloop
if GetLocalPlayer() == p then
set Button(button[id][count[id]]).visible = false
endif
set count[id] = count[id] - 1
endmethod
method add takes Item i, player p returns nothing
local integer id = GetPlayerId(p)
if count.integer[id] < CATEGORY_COUNT - 1 then
if not has(i.id, p) then
set count[id] = count[id] + 1
set item[id][count[id]] = i
if GetLocalPlayer() == p then
set Button(button[id][count[id]]).icon = i.icon
set Button(button[id][count[id]]).tooltip.text = i.tooltip
set Button(button[id][count[id]]).tooltip.name = i.name
set Button(button[id][count[id]]).tooltip.icon = i.icon
set Button(button[id][count[id]]).visible = true
call ShopSlot(table[shop][i.id]).button.tag(TAG_HIGHLIGHT, TAG_HIGHLIGHT_WIDTH, TAG_HIGHLIGHT_HEIGHT, TAG_HIGHLIGHT_SCALE, FRAMEPOINT_BOTTOMLEFT, FRAMEPOINT_BOTTOMLEFT, TAG_HIGHLIGHT_XOFFSET, TAG_HIGHLIGHT_YOFFSET)
endif
endif
endif
endmethod
static method create takes Shop shop returns thistype
local thistype this = thistype.allocate()
local integer i = 0
local integer j
set .shop = shop
set count = Table.create()
set item = HashTable.create()
set button = HashTable.create()
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set j = 0
set count[i] = -1
loop
exitwhen j == CATEGORY_COUNT
set button[i][j] = Button.create(shop.rightPanel, CATEGORY_SIZE, CATEGORY_SIZE, 0.023750, - (0.021500 + CATEGORY_SIZE*j + CATEGORY_GAP), false)
set Button(button[i][j]).visible = false
set Button(button[i][j]).onClick = function thistype.onClick
set Button(button[i][j]).onDoubleClick = function thistype.onDoubleClick
set Button(button[i][j]).tooltip.point = FRAMEPOINT_TOPRIGHT
set table[GetHandleId(Button(button[i][j]).frame)][0] = this
set table[GetHandleId(Button(button[i][j]).frame)][1] = j
if j > 6 then
set Button(button[i][j]).tooltip.point = FRAMEPOINT_BOTTOMRIGHT
endif
set j = j + 1
endloop
set i = i + 1
endloop
return this
endmethod
static method onClick takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local thistype this = table[GetHandleId(frame)][0]
local integer i = table[GetHandleId(frame)][1]
local integer id = GetPlayerId(GetTriggerPlayer())
if this != 0 then
call BlzFrameSetEnable(frame, false)
call BlzFrameSetEnable(frame, true)
if Shop.tag[id] then
call remove(i, GetTriggerPlayer())
else
call shop.detail(item[id][i], GetTriggerPlayer())
endif
endif
set frame = null
endmethod
static method onDoubleClick takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local player p = GetTriggerPlayer()
local thistype this = table[GetHandleId(frame)][0]
local integer i = table[GetHandleId(frame)][1]
local integer id = GetPlayerId(p)
if this != 0 then
if shop.buy(item[id][i], p) then
if GetLocalPlayer() == p then
call Button(button[id][i]).play(SPRITE_MODEL, SPRITE_SCALE, 0)
endif
endif
endif
set p = null
set frame = null
endmethod
endstruct
private struct Category
Shop shop
integer count
integer active
boolean andLogic
integer array value[CATEGORY_COUNT]
Button array button[CATEGORY_COUNT]
method destroy takes nothing returns nothing
loop
exitwhen count == -1
call table.remove(GetHandleId(button[count].frame))
call button[count].destroy()
set count = count - 1
endloop
call deallocate()
endmethod
method clear takes nothing returns nothing
local integer i = 0
set active = 0
loop
exitwhen i == CATEGORY_COUNT
set button[i].enabled = false
set i = i + 1
endloop
call shop.filter(active, andLogic)
endmethod
method add takes string icon, string description returns integer
if count < CATEGORY_COUNT then
set count = count + 1
set value[count] = R2I(Pow(2, count))
set button[count] = Button.create(shop.leftPanel, CATEGORY_SIZE, CATEGORY_SIZE, 0.023750, - (0.021500 + CATEGORY_SIZE*count + CATEGORY_GAP), true)
set button[count].icon = icon
set button[count].enabled = false
set button[count].onClick = function thistype.onClick
set button[count].tooltip.text = description
set table[GetHandleId(button[count].frame)][0] = this
set table[GetHandleId(button[count].frame)][1] = count
return value[count]
else
call BJDebugMsg("Maximum number os categories reached.")
endif
return 0
endmethod
static method create takes Shop shop returns thistype
local thistype this = thistype.allocate()
set count = -1
set active = 0
set andLogic = true
set .shop = shop
return this
endmethod
static method onClick takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local thistype this = table[GetHandleId(frame)][0]
local integer i = table[GetHandleId(frame)][1]
if this != 0 then
if GetLocalPlayer() == GetTriggerPlayer() then
set button[i].enabled = not button[i].enabled
if button[i].enabled then
set active = active + value[i]
else
set active = active - value[i]
endif
call shop.filter(active, andLogic)
endif
call BlzFrameSetEnable(frame, false)
call BlzFrameSetEnable(frame, true)
endif
set frame = null
endmethod
endstruct
struct Shop
private static trigger trigger = CreateTrigger()
private static trigger search = CreateTrigger()
private static trigger keyPress = CreateTrigger()
private static trigger escPressed = CreateTrigger()
private static timer update = CreateTimer()
private static integer count = -1
private static HashTable itempool
readonly static sound success
readonly static sound error
readonly static sound array noGold
readonly static group array group
readonly static timer array timer
readonly static boolean array canScroll
readonly static boolean array tag
readonly static unit array current
private boolean isVisible
readonly framehandle base
readonly framehandle main
readonly framehandle edit
readonly framehandle leftPanel
readonly framehandle rightPanel
readonly Category category
readonly Favorites favorites
readonly Detail details
readonly Buyer buyer
readonly Button close
readonly Button break
readonly Button revert
readonly Button logic
readonly Button clearCategory
readonly Button clearFavorites
readonly ShopSlot first
readonly ShopSlot last
readonly ShopSlot head
readonly ShopSlot tail
readonly integer id
readonly integer index
readonly integer size
readonly integer rows
readonly integer columns
readonly boolean detailed
readonly real aoe
readonly real tax
Table lastClicked
HashTable transaction
Table transactionCount
method operator visible= takes boolean visibility returns nothing
set isVisible = visibility
set buyer.visible = visibility
if not visibility then
set buyer.index = 0
else
if details.visible then
call details.refresh(GetLocalPlayer())
endif
endif
call BlzFrameSetVisible(base, visibility)
endmethod
method operator visible takes nothing returns boolean
return isVisible
endmethod
method destroy takes nothing returns nothing
local integer i = 0
local ShopSlot slot = itempool[this][0]
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
call transaction[i].flush()
set i = i + 1
endloop
loop
exitwhen slot == 0
call slot.destroy()
set slot = slot.next
endloop
call table.remove(id)
call table.remove(this)
call itempool.remove(this)
call BlzDestroyFrame(rightPanel)
call BlzDestroyFrame(leftPanel)
call BlzDestroyFrame(main)
call BlzDestroyFrame(base)
call lastClicked.destroy()
call transaction.destroy()
call transactionCount.destroy()
call break.destroy()
call revert.destroy()
call category.destroy()
call favorites.destroy()
call details.destroy()
call buyer.destroy()
call deallocate()
set base = null
set main = null
set leftPanel = null
set rightPanel = null
endmethod
method buy takes Item i, player p returns boolean
local unit u
local item new
local Item component
local Transaction t
local integer cost
local integer gold
local integer j = 0
local integer k = 0
local integer id = GetPlayerId(p)
local boolean canBuy = false
local Table counter = Table.create()
if i != 0 and buyer.selected.unit.has(id) then
if has(i.id) then
set canBuy = true
set u = buyer.selected.unit[id]
set gold = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
set cost = i.gold
if i.components > 0 then
loop
exitwhen j == i.components or not canBuy
set component = Item.get(i.component[j])
if UnitHasItemOfType(u, component.id) and counter.integer[component.id] < UnitCountItemOfType(u, component.id) then
set cost = cost - component.gold
set counter[component.id] = counter[component.id] + 1
else
set canBuy = has(component.id)
endif
set j = j + 1
endloop
endif
if canBuy and gold >= cost then
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, gold - cost)
set t = Transaction.create(this, u, i, "buy")
set t.gold = cost
set j = 0
if i.components > 0 then
loop
exitwhen j == i.components
set k = 0
loop
exitwhen k == UnitInventorySize(u)
if GetItemTypeId(UnitItemInSlot(u, k)) == i.component[j] then
call t.add(Item.get(GetItemTypeId(UnitItemInSlot(u, k))))
call RemoveItem(UnitItemInSlot(u, k))
exitwhen true
endif
set k = k + 1
endloop
set j = j + 1
endloop
endif
set transaction[id][transactionCount[id]] = t
set transactionCount[id] = transactionCount[id] + 1
set new = CreateItem(i.id, GetUnitX(u), GetUnitY(u))
if not UnitAddItem(u, new) then
call IssueTargetItemOrder(u, "smart", new)
endif
if not GetSoundIsPlaying(success) then
call StartSoundForPlayerBJ(p, success)
endif
call buyer.inventory.show(u)
call details.refresh(p)
else
set canBuy = false
if gold < cost then
if not GetSoundIsPlaying(noGold[GetHandleId(GetPlayerRace(p))]) then
call StartSoundForPlayerBJ(p, noGold[GetHandleId(GetPlayerRace(p))])
endif
else
if not GetSoundIsPlaying(error) then
call StartSoundForPlayerBJ(p, error)
endif
endif
endif
else
if not GetSoundIsPlaying(error) then
call StartSoundForPlayerBJ(p, error)
endif
endif
else
if not GetSoundIsPlaying(error) then
call StartSoundForPlayerBJ(p, error)
endif
endif
call counter.destroy()
set new = null
return canBuy
endmethod
method sell takes Item i, player p, integer slot returns boolean
local unit u
local Transaction t
local integer cost
local integer gold
local integer charges
local integer id = GetPlayerId(p)
local boolean sold = false
if i != 0 and buyer.selected.unit.has(id) then
set u = buyer.selected.unit[id]
set charges = GetItemCharges(UnitItemInSlot(u, slot))
if charges == 0 then
set charges = 1
endif
set gold = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
set cost = R2I(R2I(i.gold / i.charges) * charges * tax)
if GetItemTypeId(UnitItemInSlot(u, slot)) == i.id then
set sold = true
set t = Transaction.create(this, u, i, "sell")
set t.gold = cost
set transaction[id][transactionCount[id]] = t
set transactionCount[id] = transactionCount[id] + 1
call RemoveItem(UnitItemInSlot(u, slot))
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, gold + cost)
call buyer.inventory.show(u)
call details.refresh(p)
endif
if not GetSoundIsPlaying(success) then
call StartSoundForPlayerBJ(p, success)
endif
else
if not GetSoundIsPlaying(error) then
call StartSoundForPlayerBJ(p, error)
endif
endif
return sold
endmethod
method dismantle takes Item i, player p, integer slot returns nothing
local unit u
local Transaction t
local integer slots = 0
local integer j = 0
local integer id = GetPlayerId(p)
if i != 0 and buyer.selected.unit.has(id) then
if i.components > 0 then
set u = buyer.selected.unit[id]
loop
exitwhen j == UnitInventorySize(u)
if UnitItemInSlot(u, j) == null then
set slots = slots + 1
endif
set j = j + 1
endloop
if (slots + 1) >= i.components then
set j = 0
set t = Transaction.create(this, u, i, "dismantle")
set transaction[id][transactionCount[id]] = t
set transactionCount[id] = transactionCount[id] + 1
call RemoveItem(UnitItemInSlot(u, slot))
loop
exitwhen j == i.components
call UnitAddItemById(u, Item.get(i.component[j]).id)
set j = j + 1
endloop
if not GetSoundIsPlaying(success) then
call StartSoundForPlayerBJ(p, success)
endif
call buyer.inventory.show(u)
call details.refresh(p)
else
if not GetSoundIsPlaying(error) then
call StartSoundForPlayerBJ(p, error)
endif
endif
else
if not GetSoundIsPlaying(error) then
call StartSoundForPlayerBJ(p, error)
endif
endif
else
if not GetSoundIsPlaying(error) then
call StartSoundForPlayerBJ(p, error)
endif
endif
set u = null
endmethod
method undo takes player p returns nothing
local integer id = GetPlayerId(p)
if transactionCount[id] > 0 then
call Transaction(transaction[id][transactionCount[id] - 1]).rollback()
call buyer.inventory.show(buyer.selected.unit[id])
call details.refresh(p)
else
if not GetSoundIsPlaying(error) then
call StartSoundForPlayerBJ(p, error)
endif
endif
endmethod
method scroll takes boolean down returns nothing
local ShopSlot slot = first
if (down and tail != last) or (not down and head != first) then
loop
exitwhen slot == 0
if down then
call slot.move(slot.row - 1, slot.column)
else
call slot.move(slot.row + 1, slot.column)
endif
set slot.visible = slot.row >= 0 and slot.row <= rows - 1 and slot.column >= 0 and slot.column <= columns - 1
if slot.row == 0 and slot.column == 0 then
set head = slot
endif
if (slot.row == rows - 1 and slot.column == columns - 1) or (slot == last and slot.visible) then
set tail = slot
endif
set slot = slot.right
endloop
endif
endmethod
method filter takes integer categories, boolean andLogic returns nothing
local ShopSlot slot = itempool[this][0]
local string text = BlzFrameGetText(edit)
local boolean process
local integer i = -1
set size = 0
set first = 0
set last = 0
set head = 0
set tail = 0
loop
exitwhen slot == 0
if andLogic then
set process = categories == 0 or BlzBitAnd(slot.item.categories, categories) >= categories
else
set process = categories == 0 or BlzBitAnd(slot.item.categories, categories) > 0
endif
if text != "" and text != null then
set process = process and find(StringCase(slot.item.name, false), StringCase(text, false))
endif
if process then
set i = i + 1
set size = size + 1
call slot.move(R2I(i/columns), ModuloInteger(i, columns))
set slot.visible = slot.row >= 0 and slot.row <= rows - 1 and slot.column >= 0 and slot.column <= columns - 1
if i > 0 then
set slot.left = last
set last.right = slot
else
set first = slot
set head = first
endif
if slot.visible then
set tail = slot
endif
set last = slot
else
set slot.visible = false
endif
set slot = slot.next
endloop
endmethod
method select takes Item i, player p returns nothing
local integer id = GetPlayerId(p)
if i != 0 and GetLocalPlayer() == p then
if lastClicked[id] != 0 then
call Button(lastClicked[id]).display(null, 0, 0, 0, null, null, 0, 0)
endif
set lastClicked[id] = ShopSlot(table[this][i.id]).button
call Button(lastClicked[id]).display(ITEM_HIGHLIGHT, HIGHLIGHT_WIDTH, HIGHLIGHT_HEIGHT, HIGHLIGHT_SCALE, FRAMEPOINT_BOTTOMLEFT, FRAMEPOINT_BOTTOMLEFT, HIGHLIGHT_XOFFSET, HIGHLIGHT_YOFFSET)
endif
endmethod
method detail takes Item i, player p returns nothing
if i != 0 then
if GetLocalPlayer() == p then
set rows = DETAILED_ROWS
set columns = DETAILED_COLUMNS
if not detailed then
set detailed = true
call filter(category.active, category.andLogic)
endif
endif
call select(i, p)
call details.show(i, p)
else
if GetLocalPlayer() == p then
set rows = ROWS
set columns = COLUMNS
set detailed = false
set details.visible = false
call filter(category.active, category.andLogic)
endif
endif
endmethod
method has takes integer id returns boolean
return table[this].has(id)
endmethod
method clearTransactions takes player p returns nothing
local integer i = 0
local integer id = GetPlayerId(p)
loop
exitwhen i == transactionCount[id]
call Transaction(transaction[id][i]).destroy()
set i = i + 1
endloop
set transactionCount[id] = 0
call transaction[id].flush()
endmethod
private method find takes string source, string target returns boolean
local integer sourceLength = StringLength(source)
local integer targetLenght = StringLength(target)
local integer i = 0
if targetLenght <= sourceLength then
loop
exitwhen i > sourceLength - targetLenght
if SubString(source, i, i + targetLenght) == target then
return true
endif
set i = i + 1
endloop
endif
return false
endmethod
static method addCategory takes integer id, string icon, string description returns integer
local thistype this = table[id][0]
if this != 0 then
return category.add(icon, description)
endif
return 0
endmethod
static method addItem takes integer id, integer itemId, integer categories returns nothing
local thistype this = table[id][0]
local ShopSlot slot
local Item i
if this != 0 then
if not table[this].has(itemId) then
set i = Item.create(itemId, categories)
if i != 0 then
set size = size + 1
set index = index + 1
set slot = ShopSlot.create(this, i, R2I(index/COLUMNS), ModuloInteger(index, COLUMNS))
set slot.visible = slot.row >= 0 and slot.row <= ROWS - 1 and slot.column >= 0 and slot.column <= COLUMNS - 1
if index > 0 then
set slot.prev = last
set slot.left = last
set last.next = slot
set last.right = slot
else
set first = slot
set head = slot
endif
if slot.visible then
set tail = slot
endif
set last = slot
set table[this][itemId] = slot
set itempool[this][index] = slot
else
call BJDebugMsg("Invalid item code: " + A2S(itemId))
endif
else
call BJDebugMsg("The item " + GetObjectName(itemId) + " is already registered for the shop " + GetObjectName(id))
endif
endif
endmethod
static method create takes integer id, real aoe, real returnRate returns thistype
local thistype this
local integer i = 0
if not table[id].has(0) then
set this = thistype.allocate()
set .id = id
set .aoe = aoe
set tax = returnRate
set first = 0
set last = 0
set head = 0
set tail = 0
set size = 0
set index = -1
set rows = ROWS
set columns = COLUMNS
set count = count + 1
set detailed = false
set lastClicked = Table.create()
set transactionCount = Table.create()
set transaction = HashTable.create()
set base = BlzCreateFrame("EscMenuBackdrop", BlzGetFrameByName("ConsoleUIBackdrop", 0), 0, 0)
set main = BlzCreateFrameByType("BUTTON", "main", base, "", 0)
set edit = BlzCreateFrame("EscMenuEditBoxTemplate", main, 0, 0)
set leftPanel = BlzCreateFrame("EscMenuBackdrop", base, 0, 0)
set rightPanel = BlzCreateFrame("EscMenuBackdrop", base, 0, 0)
set category = Category.create(this)
set favorites = Favorites.create(this)
set details = Detail.create(this)
set buyer = Buyer.create(this)
set close = Button.create(main, TOOLBAR_BUTTON_SIZE, TOOLBAR_BUTTON_SIZE, (WIDTH - 2*TOOLBAR_BUTTON_SIZE), 0.015000, true)
set close.icon = CLOSE_ICON
set close.onClick = function thistype.onClose
set close.tooltip.text = "Close"
set break = Button.create(main, TOOLBAR_BUTTON_SIZE, TOOLBAR_BUTTON_SIZE, (WIDTH - 2*TOOLBAR_BUTTON_SIZE - 0.0205), 0.015000, true)
set break.icon = DISMANTLE_ICON
set break.onClick = function thistype.onDismantle
set break.tooltip.text = "Dismantle"
set revert = Button.create(main, TOOLBAR_BUTTON_SIZE, TOOLBAR_BUTTON_SIZE, (WIDTH - 2*TOOLBAR_BUTTON_SIZE - 0.0410), 0.015000, true)
set revert.icon = UNDO_ICON
set revert.onClick = function thistype.onUndo
set revert.tooltip.text = "Undo"
set clearCategory = Button.create(leftPanel, TOOLBAR_BUTTON_SIZE, TOOLBAR_BUTTON_SIZE, 0.028000, 0.015000, true)
set clearCategory.icon = CLEAR_ICON
set clearCategory.onClick = function thistype.onClear
set clearCategory.tooltip.text = "Clear Category"
set clearFavorites = Button.create(rightPanel, TOOLBAR_BUTTON_SIZE, TOOLBAR_BUTTON_SIZE, 0.027000, 0.015000, true)
set clearFavorites.icon = CLEAR_ICON
set clearFavorites.onClick = function thistype.onClear
set clearFavorites.tooltip.text = "Clear Favorites"
set logic = Button.create(leftPanel, TOOLBAR_BUTTON_SIZE, TOOLBAR_BUTTON_SIZE, 0.049000, 0.015000, true)
set logic.icon = LOGIC_ICON
set logic.onClick = function thistype.onLogic
set logic.enabled = false
set logic.tooltip.text = "AND Logic"
set table[id][0] = this
set table[GetHandleId(main)][0] = this
set table[GetHandleId(close.frame)][0] = this
set table[GetHandleId(break.frame)][0] = this
set table[GetHandleId(revert.frame)][0] = this
set table[GetHandleId(clearCategory.frame)][0] = this
set table[GetHandleId(clearFavorites.frame)][0] = this
set table[GetHandleId(logic.frame)][0] = this
set table[GetHandleId(edit)][0] = this
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set timer[i] = CreateTimer()
set group[i] = CreateGroup()
set canScroll[i] = true
set table[GetHandleId(Player(i))][id] = this
set table[GetHandleId(Player(i))][count] = id
set i = i + 1
endloop
call BlzFrameSetAbsPoint(base, FRAMEPOINT_TOPLEFT, X, Y)
call BlzFrameSetSize(base, WIDTH, HEIGHT)
call BlzFrameSetPoint(main, FRAMEPOINT_TOPLEFT, base, FRAMEPOINT_TOPLEFT, 0.0000, 0.0000)
call BlzFrameSetSize(main, WIDTH, HEIGHT)
call BlzFrameSetPoint(edit, FRAMEPOINT_TOPLEFT, main, FRAMEPOINT_TOPLEFT, 0.021000, 0.020000)
call BlzFrameSetSize(edit, EDIT_WIDTH, EDIT_HEIGHT)
call BlzFrameSetPoint(leftPanel, FRAMEPOINT_TOPLEFT, base, FRAMEPOINT_TOPLEFT, -0.04800, 0.0000)
call BlzFrameSetSize(leftPanel, SIDE_WIDTH, SIDE_HEIGHT)
call BlzFrameSetPoint(rightPanel, FRAMEPOINT_TOPLEFT, base, FRAMEPOINT_TOPLEFT, (WIDTH - 0.027), 0.0000)
call BlzFrameSetSize(rightPanel, SIDE_WIDTH, SIDE_HEIGHT)
call BlzTriggerRegisterFrameEvent(trigger, main, FRAMEEVENT_MOUSE_WHEEL)
call BlzTriggerRegisterFrameEvent(search, edit, FRAMEEVENT_EDITBOX_TEXT_CHANGED)
set visible = false
endif
return this
endmethod
private static method onExpire takes nothing returns nothing
set canScroll[GetPlayerId(GetLocalPlayer())] = true
endmethod
private static method onPeriod takes nothing returns nothing
local thistype this
local unit shop
local unit u
local group g
local integer i = 0
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set g = CreateGroup()
set shop = current[i]
set this = table[GetUnitTypeId(shop)][0]
if this != 0 then
call GroupClear(group[i])
call GroupEnumUnitsInRange(g, GetUnitX(shop), GetUnitY(shop), aoe, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if ShopFilter(u, Player(i), shop) then
call GroupAddUnit(group[i], u)
endif
call GroupRemoveUnit(g, u)
endloop
call buyer.update(group[i], i)
endif
call DestroyGroup(g)
set i = i + 1
endloop
set g = null
set shop = null
endmethod
private static method onSearch takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())][0]
if this != 0 then
if GetLocalPlayer() == GetTriggerPlayer() then
call filter(category.active, category.andLogic)
endif
endif
endmethod
private static method onLogic takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())][0]
if this != 0 then
if GetLocalPlayer() == GetTriggerPlayer() then
set logic.enabled = not logic.enabled
set category.andLogic = not category.andLogic
if category.andLogic then
set logic.tooltip.text = "AND Logic"
else
set logic.tooltip.text = "OR Logic"
endif
call filter(category.active, category.andLogic)
endif
call BlzFrameSetEnable(logic.frame, false)
call BlzFrameSetEnable(logic.frame, true)
endif
endmethod
private static method onClear takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local thistype this = table[GetHandleId(frame)][0]
if this != 0 then
if frame == clearCategory.frame then
if GetLocalPlayer() == GetTriggerPlayer() then
call category.clear()
endif
else
call favorites.clear(GetTriggerPlayer())
endif
call BlzFrameSetEnable(frame, false)
call BlzFrameSetEnable(frame, true)
endif
set frame = null
endmethod
private static method onClose takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())][0]
local player p = GetTriggerPlayer()
local integer id = GetPlayerId(p)
if this != 0 then
if GetLocalPlayer() == p then
set visible = false
endif
set current[id] = null
call clearTransactions(p)
endif
set p = null
endmethod
private static method onDismantle takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local thistype this = table[GetHandleId(frame)][0]
local player p = GetTriggerPlayer()
local integer id = GetPlayerId(p)
if this != 0 then
call BlzFrameSetEnable(frame, false)
call BlzFrameSetEnable(frame, true)
if buyer.inventory.selected.has(id) then
call dismantle(Item(buyer.inventory.item[id][buyer.inventory.selected[id]]), p, buyer.inventory.selected[id])
else
if not GetSoundIsPlaying(error) then
call StartSoundForPlayerBJ(p, error)
endif
endif
endif
set p = null
set frame = null
endmethod
private static method onUndo takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
local thistype this = table[GetHandleId(frame)][0]
if this != 0 then
call BlzFrameSetEnable(frame, false)
call BlzFrameSetEnable(frame, true)
call undo(GetTriggerPlayer())
endif
set frame = null
endmethod
private static method onScroll takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())][0]
local integer i = GetPlayerId(GetLocalPlayer())
if this != 0 then
if GetLocalPlayer() == GetTriggerPlayer() then
if canScroll[i] then
if SCROLL_DELAY > 0 then
set canScroll[i] = false
endif
call scroll(BlzGetTriggerFrameValue() < 0)
endif
endif
endif
if SCROLL_DELAY > 0 then
call TimerStart(timer[i], TimerGetRemaining(timer[i]), false, function thistype.onExpire)
endif
endmethod
private static method onSelect takes nothing returns nothing
local thistype this = table[GetUnitTypeId(GetTriggerUnit())][0]
local player p = GetTriggerPlayer()
local integer id = GetPlayerId(p)
if this != 0 then
if GetLocalPlayer() == p then
set visible = GetTriggerEventId() == EVENT_PLAYER_UNIT_SELECTED
endif
if GetTriggerEventId() == EVENT_PLAYER_UNIT_SELECTED then
set current[id] = GetTriggerUnit()
call buyer.inventory.show(buyer.selected.unit[id])
else
set current[id] = null
call clearTransactions(p)
endif
endif
set p = null
endmethod
private static method onKey takes nothing returns nothing
set tag[GetPlayerId(GetTriggerPlayer())] = BlzGetTriggerPlayerIsKeyDown()
endmethod
private static method onEsc takes nothing returns nothing
local thistype this
local player p = GetTriggerPlayer()
local integer i = 0
local integer id = GetHandleId(p)
loop
exitwhen i > count
set this = table[id][table[id][i]]
if this != 0 then
if GetLocalPlayer() == p then
set visible = false
endif
set current[GetPlayerId(p)] = null
call clearTransactions(p)
endif
set i = i + 1
endloop
set p = null
endmethod
private static method onInit takes nothing returns nothing
local integer i = 0
local integer id
set table = HashTable.create()
set itempool = HashTable.create()
set success = CreateSound(SUCCESS_SOUND, false, false, false, 10, 10, "")
call SetSoundDuration(success, 1600)
set error = CreateSound(ERROR_SOUND, false, false, false, 10, 10, "")
call SetSoundDuration(error, 614)
set id = GetHandleId(RACE_HUMAN)
set noGold[id] = CreateSound("Sound\\Interface\\Warning\\Human\\KnightNoGold1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(noGold[id], "NoGoldHuman")
call SetSoundDuration(noGold[id], 1618)
set id = GetHandleId(RACE_ORC)
set noGold[id] = CreateSound("Sound\\Interface\\Warning\\Orc\\GruntNoGold1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(noGold[id], "NoGoldOrc")
call SetSoundDuration(noGold[id], 1450)
set id = GetHandleId(RACE_NIGHTELF)
set noGold[id] = CreateSound("Sound\\Interface\\Warning\\NightElf\\SentinelNoGold1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(noGold[id], "NoGoldNightElf")
call SetSoundDuration(noGold[id], 1229)
set id = GetHandleId(RACE_UNDEAD)
set noGold[id] = CreateSound("Sound\\Interface\\Warning\\Undead\\NecromancerNoGold1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(noGold[id], "NoGoldUndead")
call SetSoundDuration(noGold[id], 2005)
set id = GetHandleId(ConvertRace(11))
set noGold[id] = CreateSound("Sound\\Interface\\Warning\\Naga\\NagaNoGold1.wav", false, false, false, 10, 10, "")
call SetSoundParamsFromLabel(noGold[id], "NoGoldNaga")
call SetSoundDuration(noGold[id], 2690)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set tag[i] = false
call BlzTriggerRegisterPlayerKeyEvent(keyPress, Player(i), FAVORITE_KEY, 0, true)
call BlzTriggerRegisterPlayerKeyEvent(keyPress, Player(i), FAVORITE_KEY, 0, false)
call TriggerRegisterPlayerEventEndCinematic(escPressed, Player(i))
set i = i + 1
endloop
call BlzLoadTOCFile("Shop.toc")
call TimerStart(update, UPDATE_PERIOD, true, function thistype.onPeriod)
call TriggerAddAction(trigger, function thistype.onScroll)
call TriggerAddCondition(search, Condition(function thistype.onSearch))
call TriggerAddCondition(keyPress, Condition(function thistype.onKey))
call TriggerAddCondition(escPressed, Condition(function thistype.onEsc))
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SELECTED, function thistype.onSelect)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DESELECTED, function thistype.onSelect)
endmethod
endstruct
endlibrary
library Components requires Table
/* ------------------------------------ Components v1.0 ------------------------------------ */
// Credits:
// Taysen: FDF file
// Bribe: Table library
/* -------------------------------------- By Chopinski ------------------------------------- */
/* ----------------------------------------------------------------------------------------- */
/* Configuration */
/* ----------------------------------------------------------------------------------------- */
globals
private constant real TOOLTIP_SIZE = 0.2
private constant real SCROLL_DELAY = 0.01
private constant real DOUBLE_CLICK_DELAY = 0.25
private constant string HIGHLIGHT = "UI\\Widgets\\Glues\\GlueScreen-Button-KeyboardHighlight"
private constant string CHECKED_BUTTON = "UI\\Widgets\\EscMenu\\Human\\checkbox-check.blp"
private constant string UNAVAILABLE_BUTTON = "ui\\widgets\\battlenet\\chaticons\\bnet-squelch"
endglobals
/* ----------------------------------------------------------------------------------------- */
/* System */
/* ----------------------------------------------------------------------------------------- */
struct Tooltip
private framehandle box
private framehandle line
private framehandle tooltip
private framehandle iconFrame
private framehandle nameFrame
private framehandle parent
private framepointtype pointType
private real widthSize
private string texture
private boolean isVisible
private boolean simple
readonly framehandle frame
method operator text= takes string description returns nothing
call BlzFrameSetText(tooltip, description)
endmethod
method operator text takes nothing returns string
return BlzFrameGetText(tooltip)
endmethod
method operator name= takes string newName returns nothing
call BlzFrameSetText(nameFrame, newName)
endmethod
method operator name takes nothing returns string
return BlzFrameGetText(nameFrame)
endmethod
method operator icon= takes string texture returns nothing
set .texture = texture
call BlzFrameSetTexture(iconFrame, texture, 0, false)
endmethod
method operator icon takes nothing returns string
return texture
endmethod
method operator width= takes real newWidth returns nothing
set widthSize = newWidth
if not simple then
call BlzFrameClearAllPoints(tooltip)
call BlzFrameSetSize(tooltip, newWidth, 0)
endif
endmethod
method operator width takes nothing returns real
return widthSize
endmethod
method operator point= takes framepointtype newPoint returns nothing
set pointType = newPoint
if not simple then
call BlzFrameClearAllPoints(tooltip)
if newPoint == FRAMEPOINT_TOPLEFT then
call BlzFrameSetPoint(tooltip, newPoint, parent, FRAMEPOINT_TOPRIGHT, 0.005, -0.05)
elseif newPoint == FRAMEPOINT_TOPRIGHT then
call BlzFrameSetPoint(tooltip, newPoint, parent, FRAMEPOINT_TOPLEFT, -0.005, -0.05)
elseif newPoint == FRAMEPOINT_BOTTOMLEFT then
call BlzFrameSetPoint(tooltip, newPoint, parent, FRAMEPOINT_BOTTOMRIGHT, 0.005, 0.0)
elseif newPoint == FRAMEPOINT_BOTTOM then
call BlzFrameSetPoint(tooltip, newPoint, parent, FRAMEPOINT_TOP, 0.0, 0.005)
elseif newPoint == FRAMEPOINT_TOP then
call BlzFrameSetPoint(tooltip, newPoint, parent, FRAMEPOINT_BOTTOM, 0.0, -0.05)
else
call BlzFrameSetPoint(tooltip, newPoint, parent, FRAMEPOINT_BOTTOMLEFT, -0.005, 0.0)
endif
endif
endmethod
method operator point takes nothing returns framepointtype
return pointType
endmethod
method operator visible= takes boolean visibility returns nothing
set isVisible = visibility
call BlzFrameSetVisible(box, visibility)
endmethod
method operator visible takes nothing returns boolean
return isVisible
endmethod
method destroy takes nothing returns nothing
call BlzDestroyFrame(nameFrame)
call BlzDestroyFrame(iconFrame)
call BlzDestroyFrame(tooltip)
call BlzDestroyFrame(line)
call BlzDestroyFrame(box)
call BlzDestroyFrame(frame)
call deallocate()
set frame = null
set box = null
set line = null
set tooltip = null
set iconFrame = null
set nameFrame = null
set pointType = null
set parent = null
endmethod
static method create takes framehandle owner, real width, framepointtype point, boolean simpleTooltip returns thistype
local thistype this = thistype.allocate()
set parent = owner
set simple = simpleTooltip
set widthSize = width
set pointType = point
set isVisible = true
if simpleTooltip then
set frame = BlzCreateFrameByType("FRAME", "", owner, "", 0)
set box = BlzCreateFrame("Leaderboard", frame, 0, 0)
set tooltip = BlzCreateFrameByType("TEXT", "", box, "", 0)
call BlzFrameSetPoint(tooltip, FRAMEPOINT_BOTTOM, owner, FRAMEPOINT_TOP, 0, 0.008)
call BlzFrameSetPoint(box, FRAMEPOINT_TOPLEFT, tooltip, FRAMEPOINT_TOPLEFT, -0.008, 0.008)
call BlzFrameSetPoint(box, FRAMEPOINT_BOTTOMRIGHT, tooltip, FRAMEPOINT_BOTTOMRIGHT, 0.008, -0.008)
else
set frame = BlzCreateFrame("TooltipBoxFrame", owner, 0, 0)
set box = BlzGetFrameByName("TooltipBox", 0)
set line = BlzGetFrameByName("TooltipSeperator", 0)
set tooltip = BlzGetFrameByName("TooltipText", 0)
set iconFrame = BlzGetFrameByName("TooltipIcon", 0)
set nameFrame = BlzGetFrameByName("TooltipName", 0)
if point == FRAMEPOINT_TOPLEFT then
call BlzFrameSetPoint(tooltip, point, owner, FRAMEPOINT_TOPRIGHT, 0.005, -0.05)
elseif point == FRAMEPOINT_TOPRIGHT then
call BlzFrameSetPoint(tooltip, point, owner, FRAMEPOINT_TOPLEFT, -0.005, -0.05)
elseif point == FRAMEPOINT_BOTTOMLEFT then
call BlzFrameSetPoint(tooltip, point, owner, FRAMEPOINT_BOTTOMRIGHT, 0.005, 0.0)
else
call BlzFrameSetPoint(tooltip, point, owner, FRAMEPOINT_BOTTOMLEFT, -0.005, 0.0)
endif
call BlzFrameSetPoint(box, FRAMEPOINT_TOPLEFT, iconFrame, FRAMEPOINT_TOPLEFT, -0.005, 0.005)
call BlzFrameSetPoint(box, FRAMEPOINT_BOTTOMRIGHT, tooltip, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
call BlzFrameSetSize(tooltip, width, 0)
endif
return this
endmethod
endstruct
struct Button
private static trigger clicked = CreateTrigger()
private static trigger scrolled = CreateTrigger()
private static trigger rightClicked = CreateTrigger()
private static timer double = CreateTimer()
private static timer array timer
private static boolean array canScroll
private static Table table
private static HashTable doubleTime
private static HashTable time
private trigger click
private trigger scroll
private trigger doubleClick
private trigger rightClick
private framehandle iconFrame
private framehandle availableFrame
private framehandle checkedFrame
private framehandle highlightFrame
private framehandle spriteFrame
private framehandle displayFrame
private framehandle tagFrame
private framehandle parent
private boolean isVisible
private boolean isAvailable
private boolean isChecked
private boolean isHighlighted
private boolean isEnabled
private string texture
private real widhtSize
private real heightSize
private real xPos
private real yPos
readonly framehandle frame
Tooltip tooltip
method operator x= takes real newX returns nothing
set xPos = newX
call BlzFrameClearAllPoints(iconFrame)
call BlzFrameSetPoint(iconFrame, FRAMEPOINT_TOPLEFT, parent, FRAMEPOINT_TOPLEFT, xPos, yPos)
endmethod
method operator x takes nothing returns real
return xPos
endmethod
method operator y= takes real newY returns nothing
set yPos = newY
call BlzFrameClearAllPoints(iconFrame)
call BlzFrameSetPoint(iconFrame, FRAMEPOINT_TOPLEFT, parent, FRAMEPOINT_TOPLEFT, xPos, yPos)
endmethod
method operator y takes nothing returns real
return yPos
endmethod
method operator icon= takes string texture returns nothing
set .texture = texture
call BlzFrameSetTexture(iconFrame, texture, 0, true)
endmethod
method operator icon takes nothing returns string
return texture
endmethod
method operator width= takes real newWidth returns nothing
set widhtSize = newWidth
call BlzFrameClearAllPoints(iconFrame)
call BlzFrameSetSize(iconFrame, newWidth, heightSize)
endmethod
method operator width takes nothing returns real
return widhtSize
endmethod
method operator height= takes real newHeight returns nothing
set heightSize = newHeight
call BlzFrameClearAllPoints(iconFrame)
call BlzFrameSetSize(iconFrame, widhtSize, newHeight)
endmethod
method operator height takes nothing returns real
return heightSize
endmethod
method operator visible= takes boolean visibility returns nothing
set isVisible = visibility
call BlzFrameSetVisible(iconFrame, visibility)
endmethod
method operator visible takes nothing returns boolean
return isVisible
endmethod
method operator available= takes boolean flag returns nothing
set isAvailable = flag
if flag then
call BlzFrameSetVisible(availableFrame, false)
else
call BlzFrameSetVisible(availableFrame, true)
call BlzFrameSetTexture(availableFrame, UNAVAILABLE_BUTTON, 0, true)
endif
endmethod
method operator available takes nothing returns boolean
return isAvailable
endmethod
method operator checked= takes boolean flag returns nothing
set isChecked = flag
if flag then
call BlzFrameSetVisible(checkedFrame, true)
call BlzFrameSetTexture(checkedFrame, CHECKED_BUTTON, 0, true)
else
call BlzFrameSetVisible(checkedFrame, false)
endif
endmethod
method operator checked takes nothing returns boolean
return isChecked
endmethod
method operator highlighted= takes boolean flag returns nothing
set isHighlighted = flag
if flag then
call BlzFrameSetVisible(highlightFrame, true)
call BlzFrameSetTexture(highlightFrame, HIGHLIGHT, 0, true)
else
call BlzFrameSetVisible(highlightFrame, false)
endif
endmethod
method operator highlighted takes nothing returns boolean
return isHighlighted
endmethod
method operator enabled= takes boolean flag returns nothing
local string t = texture
set isEnabled = flag
if not flag then
if SubString(t, 34, 35) == "\\" then
set t = SubString(t, 0, 34) + "Disabled\\DIS" + SubString(t, 35, StringLength(t))
endif
endif
call BlzFrameSetTexture(iconFrame, t, 0, true)
endmethod
method operator enabled takes nothing returns boolean
return isEnabled
endmethod
method operator onClick= takes code c returns nothing
call DestroyTrigger(click)
set click = null
if c != null then
set click = CreateTrigger()
call TriggerAddCondition(click, Condition(c))
endif
endmethod
method operator onScroll= takes code c returns nothing
call DestroyTrigger(scroll)
set scroll = null
if c != null then
set scroll = CreateTrigger()
call TriggerAddCondition(scroll, Condition(c))
endif
endmethod
method operator onDoubleClick= takes code c returns nothing
call DestroyTrigger(doubleClick)
set doubleClick = null
if c != null then
set doubleClick = CreateTrigger()
call TriggerAddCondition(doubleClick, Condition(c))
endif
endmethod
method operator onRightClick= takes code c returns nothing
call DestroyTrigger(rightClick)
set rightClick = null
if c != null then
set rightClick = CreateTrigger()
call TriggerAddCondition(rightClick, Condition(c))
endif
endmethod
method destroy takes nothing returns nothing
call table.remove(GetHandleId(frame))
call DestroyTrigger(click)
call DestroyTrigger(scroll)
call DestroyTrigger(doubleClick)
call DestroyTrigger(rightClick)
call BlzDestroyFrame(displayFrame)
call BlzDestroyFrame(spriteFrame)
call BlzDestroyFrame(tagFrame)
call BlzDestroyFrame(frame)
call BlzDestroyFrame(iconFrame)
call BlzDestroyFrame(availableFrame)
call BlzDestroyFrame(checkedFrame)
call tooltip.destroy()
call deallocate()
set availableFrame = null
set checkedFrame = null
set spriteFrame = null
set displayFrame = null
set iconFrame = null
set tagFrame = null
set doubleClick = null
set rightClick = null
set parent = null
set scroll = null
set frame = null
set click = null
endmethod
method play takes string model, real scale, integer animation returns nothing
if model != "" and model != null then
call BlzFrameClearAllPoints(spriteFrame)
call BlzFrameSetPoint(spriteFrame, FRAMEPOINT_CENTER, frame, FRAMEPOINT_CENTER, 0, 0)
call BlzFrameSetSize(spriteFrame, widhtSize, heightSize)
call BlzFrameSetModel(spriteFrame, model, 0)
call BlzFrameSetScale(spriteFrame, scale)
call BlzFrameSetSpriteAnimate(spriteFrame, animation, 0)
endif
endmethod
method display takes string model, real width, real height, real scale, framepointtype point, framepointtype relativePoint, real offsetX, real offsetY returns nothing
if model != "" and model != null then
call BlzFrameClearAllPoints(displayFrame)
call BlzFrameSetPoint(displayFrame, point, frame, relativePoint, offsetX, offsetY)
call BlzFrameSetSize(displayFrame, width, height)
call BlzFrameSetScale(displayFrame, scale)
call BlzFrameSetModel(displayFrame, model, 0)
call BlzFrameSetVisible(displayFrame, true)
else
call BlzFrameSetVisible(displayFrame, false)
endif
endmethod
method tag takes string model, real width, real height, real scale, framepointtype point, framepointtype relativePoint, real offsetX, real offsetY returns nothing
if model != "" and model != null then
call BlzFrameClearAllPoints(tagFrame)
call BlzFrameSetPoint(tagFrame, point, frame, relativePoint, offsetX, offsetY)
call BlzFrameSetSize(tagFrame, width, height)
call BlzFrameSetScale(tagFrame, scale)
call BlzFrameSetModel(tagFrame, model, 0)
call BlzFrameSetVisible(tagFrame, true)
else
call BlzFrameSetVisible(tagFrame, false)
endif
endmethod
static method create takes framehandle owner, real width, real height, real x, real y, boolean simpleTooltip returns thistype
local thistype this = thistype.allocate()
local integer i = 0
set parent = owner
set xPos = x
set yPos = y
set widhtSize = width
set heightSize = height
set isVisible = true
set isAvailable = true
set isChecked = false
set isHighlighted = false
set iconFrame = BlzCreateFrameByType("BACKDROP", "", owner, "", 0)
set availableFrame = BlzCreateFrameByType("BACKDROP", "", iconFrame, "", 0)
set checkedFrame = BlzCreateFrameByType("BACKDROP", "", iconFrame, "", 0)
set highlightFrame = BlzCreateFrame("HighlightFrame", iconFrame, 0, 0)
set frame = BlzCreateFrame("IconButtonTemplate", iconFrame, 0, 0)
set displayFrame = BlzCreateFrameByType("SPRITE", "", frame, "WarCraftIIILogo", 0)
set tagFrame = BlzCreateFrameByType("SPRITE", "", frame, "WarCraftIIILogo", 0)
set spriteFrame = BlzCreateFrameByType("SPRITE", "", frame, "", 0)
set tooltip = Tooltip.create(frame, TOOLTIP_SIZE, FRAMEPOINT_TOPLEFT, simpleTooltip)
set table[GetHandleId(frame)] = this
call BlzFrameSetPoint(iconFrame, FRAMEPOINT_TOPLEFT, owner, FRAMEPOINT_TOPLEFT, x, y)
call BlzFrameSetSize(iconFrame, width, height)
call BlzFrameSetAllPoints(frame, iconFrame)
call BlzFrameSetTooltip(frame, tooltip.frame)
call BlzFrameSetAllPoints(availableFrame, iconFrame)
call BlzFrameSetVisible(availableFrame, false)
call BlzFrameSetAllPoints(checkedFrame, iconFrame)
call BlzFrameSetVisible(checkedFrame, false)
call BlzFrameSetPoint(highlightFrame, FRAMEPOINT_TOPLEFT, iconFrame, FRAMEPOINT_TOPLEFT, - 0.0040000, 0.0045000)
call BlzFrameSetSize(highlightFrame, width + 0.0085, height + 0.0085)
call BlzFrameSetVisible(highlightFrame, false)
call BlzTriggerRegisterFrameEvent(clicked, frame, FRAMEEVENT_CONTROL_CLICK)
call BlzTriggerRegisterFrameEvent(scrolled, frame, FRAMEEVENT_MOUSE_WHEEL)
call BlzTriggerRegisterFrameEvent(rightClicked, frame, FRAMEEVENT_MOUSE_UP)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
set timer[i] = CreateTimer()
set canScroll[i] = true
set i = i + 1
endloop
return this
endmethod
private static method onExpire takes nothing returns nothing
set canScroll[GetPlayerId(GetLocalPlayer())] = true
endmethod
private static method onScrolled takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())]
local integer i = GetPlayerId(GetLocalPlayer())
if this != 0 then
if canScroll[i] and scroll != null then
if SCROLL_DELAY > 0 then
set canScroll[i] = false
endif
call TriggerEvaluate(scroll)
endif
endif
if SCROLL_DELAY > 0 then
call TimerStart(timer[i], TimerGetRemaining(timer[i]), false, function thistype.onExpire)
endif
endmethod
private static method onRightClicked takes nothing returns nothing
local thistype this = table[GetHandleId(BlzGetTriggerFrame())]
if this != 0 then
if BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_RIGHT and rightClick != null then
call TriggerEvaluate(rightClick)
endif
endif
endmethod
private static method onClicked takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
local integer j = GetHandleId(BlzGetTriggerFrame())
local thistype this = table[j]
if this != 0 then
set time[i].real[j] = TimerGetElapsed(double)
if click != null then
call TriggerEvaluate(click)
endif
if time[i].real[j] - doubleTime[i].real[j] <= DOUBLE_CLICK_DELAY then
set doubleTime[i][j] = 0
if doubleClick != null then
call TriggerEvaluate(doubleClick)
endif
else
set doubleTime[i].real[j] = time[i].real[j]
endif
endif
endmethod
private static method onInit takes nothing returns nothing
set table = Table.create()
set time = HashTable.create()
set doubleTime = HashTable.create()
call TimerStart(double, 9999999999, false, null)
call TriggerAddAction(clicked, function thistype.onClicked)
call TriggerAddAction(scrolled, function thistype.onScrolled)
call TriggerAddAction(rightClicked, function thistype.onRightClicked)
endmethod
endstruct
endlibrary
scope Test
struct Items
static constant integer BOOTS_OF_SPEED = 'I00A'
static constant integer ANKH_OF_REINCARNATION = 'I00N'
static constant integer POTION_OF_RESTORATION = 'I00P'
static constant integer MASK_OF_DEATH = 'I00U'
static constant integer CLOAK_OF_FLAMES = 'I00V'
static constant integer COMMOM_SHIELD = 'I016'
static constant integer HEAVY_HAMMER = 'I01Q'
static constant integer ASSASSINS_DAGGER = 'I01R'
static constant integer IRON_AXE = 'I01S'
static constant integer SIMPLE_BOW = 'I01T'
static constant integer SUMMONING_BOOK = 'I01U'
static constant integer COURIER = 'I01Z'
static constant integer LIFE_CRYSTAL = 'I00B'
static constant integer MANA_CRYSTAL = 'I00J'
static constant integer LIFE_ESSENCE_CRYSTAL = 'I00L'
static constant integer CRYSTAL_RING = 'I00K'
static constant integer HOMECOMING_STONE = 'I00D'
static constant integer BRACELET_OF_INTELLIGENCE = 'I00H'
static constant integer CLAWS_OF_AGILITY = 'I00I'
static constant integer GAUNTLET_OF_STRENGTH = 'I00G'
static constant integer GLOVES_OF_HASTE = 'I00C'
static constant integer PLATEMAIL = 'I00F'
static constant integer RUSTY_SWORD = 'I00E'
static constant integer ORB_OF_FIRE = 'I01J'
static constant integer ORB_OF_FROST = 'I01L'
static constant integer ORB_OF_LIGHT = 'I01X'
static constant integer ORB_OF_LIGHTNING = 'I01N'
static constant integer ORB_OF_SANDS = 'I01V'
static constant integer ORB_OF_SOULS = 'I01O'
static constant integer ORB_OF_THORNS = 'I01W'
static constant integer ORB_OF_VENOM = 'I01K'
static constant integer ORB_OF_WATER = 'I01M'
static constant integer ORB_OF_WIND = 'I01P'
static constant integer ORB_OF_DARKNESS = 'I01Y'
static constant integer BOOTS_OF_THE_BRAVES = 'I009'
static constant integer BOOTS_OF_AGILITY = 'I00O'
static constant integer BOOTS_OF_INTELLIGENCE = 'I00Q'
static constant integer BOOTS_OF_STRENGTH = 'I00M'
static constant integer BOOTS_OF_RESTORATION = 'I00Y'
static constant integer BOOTS_OF_FLAMES = 'I010'
static constant integer GOLDEN_BOOTS = 'I014'
static constant integer HEAVY_BOOTS = 'I00W'
static constant integer SILVER_BOOTS = 'I012'
static constant integer BERSERKER_BOOTS = 'I020'
static constant integer RUNIC_BOOTS = 'I022'
static constant integer GOLDEN_SWORD = 'I01A'
static constant integer GOLDEN_PLATEMAIL = 'I01D'
static constant integer FUSED_LIFE_CRYSTALS = 'I01G'
static constant integer INFUSED_MANA_CRYSTAL = 'I027'
static constant integer ELEMENTAL_SHARD = 'I00T'
static constant integer HARDENED_SHIELD = 'I017'
static constant integer MASK_OF_MADNESS = 'I024'
static constant integer GLOVES_OF_SPEED = 'I02A'
static constant integer GLAIVE_SCYTHE = 'I02D'
static constant integer MAGE_STICK = 'I02G'
static constant integer SORCERER_RING = 'I02J'
static constant integer WARRIOR_BLADE = 'I02M'
static constant integer BLACK_NAVAJA = 'I02P'
static constant integer ORCISH_AXE = 'I02S'
static constant integer ENHANCED_HAMMER = 'I02V'
static constant integer EMERALD_SHOULDER_PLATE = 'I02Y'
static constant integer STEEL_ARMOR = 'I031'
static constant integer WARRIOR_HELMET = 'I034'
static constant integer SOUL_SCYTHER = 'I037'
static constant integer GLOVES_OF_SILVER = 'I03A'
static constant integer WARRIOR_SHIELD = 'I03D'
static constant integer MAGE_STAFF = 'I03G'
static constant integer DEMONIC_MASK = 'I03J'
static constant integer MAGMA_HELMET = 'I03M'
static constant integer CHILLING_AXE = 'I03P'
static constant integer HOLY_BOW = 'I03S'
static constant integer LIGHTNING_SPEAR = 'I03V'
static constant integer DESERT_RING = 'I03Y'
static constant integer SOUL_SWORD = 'I041'
static constant integer NATURE_STAFF = 'I044'
static constant integer TOXIC_DAGGER = 'I047'
static constant integer OCEANIC_MACE = 'I04A'
static constant integer WIND_SWORD = 'I04D'
static constant integer SPHERE_OF_POWER = 'I04G'
static constant integer SPHERE_OF_FIRE = 'I04H'
static constant integer SPHERE_OF_WATER = 'I04K'
static constant integer SPHERE_OF_NATURE = 'I04N'
static constant integer SPHERE_OF_DIVINITY = 'I04Q'
static constant integer SPHERE_OF_LIGHTNING = 'I04T'
static constant integer SPHERE_OF_DARKNESS = 'I04W'
static constant integer SPHERE_OF_AIR = 'I050'
static constant integer ETERNITY_STONE = 'I052'
static constant integer FUSION_CRYSTAL = 'I057'
static constant integer WIZARD_STONE = 'I05A'
static constant integer KNIGHT_BLADE = 'I05K'
static constant integer RITUAL_DAGGER = 'I05N'
static constant integer GIANTS_HAMMER = 'I05E'
static constant integer AXE_OF_THE_GREEDY = 'I05H'
static constant integer SAPHIRE_SHOULDER_PLATE = 'I05Q'
static constant integer FLAMING_ARMOR = 'I05T'
static constant integer DRAGON_HELMET = 'I05W'
static constant integer REAPERS_EDGE = 'I05Z'
static constant integer GLOVES_OF_GOLD = 'I062'
static constant integer COMMANDERS_SHIELD = 'I065'
static constant integer SORCERER_STAFF = 'I068'
static constant integer BOOK_OF_FLAMES = 'I06B'
static constant integer BOOK_OF_OCEANS = 'I06E'
static constant integer BOOK_OF_NATURE = 'I06H'
static constant integer BOOK_OF_LIGHT = 'I06K'
static constant integer BOOK_OF_CHAOS = 'I06N'
static constant integer BOOK_OF_ICE = 'I055'
static constant integer HELLISH_MASK = 'I06R'
static constant integer ENFLAMED_BOW = 'I06U'
static constant integer RING_OF_CONVERSION = 'I06X'
static constant integer ANCIENT_STONE = 'I05D'
static constant integer ANCIENT_SPHERE = 'I070'
static constant integer LEGENDARY_BLADE_I = 'I073'
static constant integer TRIEDGE_SWORD = 'I076'
static constant integer CROWN_OF_RIGHTEOUSNESS = 'I079'
static constant integer HEATING_CLOAK = 'I07C'
static constant integer HAMMER_OF_NATURE = 'I07F'
static constant integer ELEMENTAL_SPIN = 'I07I'
static constant integer NECKLACE_OF_VIGOR = 'I07L'
static constant integer THUNDERGOD_SPEAR = 'I07O'
static constant integer WIZARD_STAFF = 'I07R'
static constant integer PHILOSOPHERS_STONE = 'I07U'
static constant integer ENTITY_SCYTHE = 'I07X'
static constant integer LEGENDARY_BLADE_II = 'I080'
static constant integer DOOMBRINGER = 'I083'
static constant integer DUAL_ELEMENTAL_DAGGER = 'I086'
static constant integer APOCALYPTIC_MASK = 'I089'
static constant integer RADIANT_HELMET = 'I08C'
static constant integer JADEN_SHOULDER_PLATE = 'I08F'
static constant integer MOONCHANT_RING = 'I08I'
static constant integer BLOODBOURNE_SHIELD = 'I08L'
static constant integer NATURE_GODDESS_STAFF = 'I08O'
static constant integer PHOENIX_AXE = 'I08R'
static constant integer WEAVER_I = 'I08U'
static constant integer LEGENDARY_BLADE_III = 'I08X'
static constant integer REDEMPTION_SWORD = 'I090'
static constant integer ELEMENTAL_STONE = 'I093'
static constant integer SAPPHIRE_HAMMER = 'I096'
static constant integer FIRE_BOW = 'I099'
static constant integer WARLOCK_RING = 'I09C'
static constant integer TWIN_PHANTOM_SPEAR = 'I09F'
static constant integer RED_MOON_SCYTH = 'I09I'
static constant integer HOLY_SCEPTER = 'I09L'
static constant integer MAGUS_ORB = 'I09O'
static constant integer WEAVER_II = 'I09R'
static constant integer LEGENDARY_BLADE_IV = 'I09U'
static constant integer SWORD_OF_DOMINATION = 'I09X'
static constant integer ARC_TRINITY = 'I0A0'
static constant integer HOLY_HAMMER = 'I0A3'
static constant integer GLUTTONOUS_AXE = 'I0A6'
static constant integer CROWN_OF_GODS = 'I0A9'
static constant integer BLACK_ARMOR = 'I0AC'
static constant integer ANGELIC_SHIELD = 'I0AF'
static constant integer HELMET_OF_ETERNITY = 'I0AI'
static constant integer ARCANA_SCEPTER = 'I0AL'
static constant integer ELEMENTAL_SPHERE = 'I0AO'
static constant integer LEGENDARY_BLADE_V = 'I0AR'
static constant integer CROWN_OF_ICE = 'I0AU'
static constant integer GOLDEN_HEART = 'I0AV'
static constant integer LIGHTNING_SWORD = 'I0AY'
static constant integer SAKURA_BLADE = 'I0AZ'
private static method configure takes nothing returns nothing
call ItemAddComponents(BOOTS_OF_THE_BRAVES, BOOTS_OF_SPEED, HOMECOMING_STONE, GLOVES_OF_HASTE, LIFE_CRYSTAL, 0)
call ItemAddComponents(BOOTS_OF_AGILITY, BOOTS_OF_SPEED, CLAWS_OF_AGILITY, HOMECOMING_STONE, 0, 0)
call ItemAddComponents(BOOTS_OF_INTELLIGENCE, BOOTS_OF_SPEED, BRACELET_OF_INTELLIGENCE, HOMECOMING_STONE, 0, 0)
call ItemAddComponents(BOOTS_OF_STRENGTH, BOOTS_OF_SPEED, GAUNTLET_OF_STRENGTH, HOMECOMING_STONE, 0, 0)
call ItemAddComponents(BOOTS_OF_RESTORATION, BOOTS_OF_SPEED, LIFE_CRYSTAL, HOMECOMING_STONE, LIFE_ESSENCE_CRYSTAL, 0)
call ItemAddComponents(BOOTS_OF_FLAMES, BOOTS_OF_SPEED, HOMECOMING_STONE, CLOAK_OF_FLAMES, 0, 0)
call ItemAddComponents(GOLDEN_BOOTS, BOOTS_OF_SPEED, HOMECOMING_STONE, RUSTY_SWORD, MASK_OF_DEATH, 0)
call ItemAddComponents(HEAVY_BOOTS, BOOTS_OF_SPEED, HOMECOMING_STONE, RUSTY_SWORD, GLOVES_OF_HASTE, 0)
call ItemAddComponents(SILVER_BOOTS, BOOTS_OF_SPEED, HOMECOMING_STONE, PLATEMAIL, LIFE_CRYSTAL, 0)
call ItemAddComponents(BERSERKER_BOOTS, BOOTS_OF_SPEED, GLOVES_OF_HASTE, GLOVES_OF_HASTE, ASSASSINS_DAGGER, 0)
call ItemAddComponents(RUNIC_BOOTS, BOOTS_OF_SPEED, LIFE_CRYSTAL, MANA_CRYSTAL, 0, 0)
call ItemAddComponents(GOLDEN_SWORD, RUSTY_SWORD, RUSTY_SWORD, RUSTY_SWORD, 0, 0)
call ItemAddComponents(GOLDEN_PLATEMAIL, LIFE_CRYSTAL, PLATEMAIL, PLATEMAIL, 0, 0)
call ItemAddComponents(FUSED_LIFE_CRYSTALS, LIFE_CRYSTAL, LIFE_CRYSTAL, LIFE_CRYSTAL, 0, 0)
call ItemAddComponents(INFUSED_MANA_CRYSTAL, MANA_CRYSTAL, MANA_CRYSTAL, MANA_CRYSTAL, 0, 0)
call ItemAddComponents(ELEMENTAL_SHARD, LIFE_CRYSTAL, MANA_CRYSTAL, LIFE_ESSENCE_CRYSTAL, CRYSTAL_RING, 0)
call ItemAddComponents(HARDENED_SHIELD, COMMOM_SHIELD, LIFE_CRYSTAL, PLATEMAIL, 0, 0)
call ItemAddComponents(MASK_OF_MADNESS, MASK_OF_DEATH, 0, 0, 0, 0)
call ItemAddComponents(GLOVES_OF_SPEED, GLOVES_OF_HASTE, GLOVES_OF_HASTE, 0, 0, 0)
call ItemAddComponents(GLAIVE_SCYTHE, BRACELET_OF_INTELLIGENCE, GAUNTLET_OF_STRENGTH, CLAWS_OF_AGILITY, 0, 0)
call ItemAddComponents(MAGE_STICK, MANA_CRYSTAL, MANA_CRYSTAL, CRYSTAL_RING, 0, 0)
call ItemAddComponents(SORCERER_RING, MANA_CRYSTAL, CRYSTAL_RING, CRYSTAL_RING, 0, 0)
call ItemAddComponents(WARRIOR_BLADE, GOLDEN_SWORD, GLOVES_OF_HASTE, 0, 0, 0)
call ItemAddComponents(BLACK_NAVAJA, RUSTY_SWORD, RUSTY_SWORD, ASSASSINS_DAGGER, 0, 0)
call ItemAddComponents(ORCISH_AXE, IRON_AXE, GOLDEN_SWORD, 0, 0, 0)
call ItemAddComponents(ENHANCED_HAMMER, RUSTY_SWORD, HEAVY_HAMMER, HEAVY_HAMMER, 0, 0)
call ItemAddComponents(EMERALD_SHOULDER_PLATE, GAUNTLET_OF_STRENGTH, GAUNTLET_OF_STRENGTH, FUSED_LIFE_CRYSTALS, 0, 0)
call ItemAddComponents(STEEL_ARMOR, FUSED_LIFE_CRYSTALS, GOLDEN_PLATEMAIL, 0, 0, 0)
call ItemAddComponents(WARRIOR_HELMET, GAUNTLET_OF_STRENGTH, LIFE_ESSENCE_CRYSTAL, LIFE_ESSENCE_CRYSTAL, 0, 0)
call ItemAddComponents(SOUL_SCYTHER, RUSTY_SWORD, GLAIVE_SCYTHE, 0, 0, 0)
call ItemAddComponents(GLOVES_OF_SILVER, GLOVES_OF_SPEED, GLOVES_OF_SPEED, 0, 0, 0)
call ItemAddComponents(WARRIOR_SHIELD, FUSED_LIFE_CRYSTALS, GOLDEN_PLATEMAIL, HARDENED_SHIELD, 0, 0)
call ItemAddComponents(MAGE_STAFF, BRACELET_OF_INTELLIGENCE, FUSED_LIFE_CRYSTALS, MAGE_STICK, 0, 0)
call ItemAddComponents(DEMONIC_MASK, ORB_OF_DARKNESS, MASK_OF_MADNESS, GOLDEN_SWORD, 0, 0)
call ItemAddComponents(MAGMA_HELMET, ORB_OF_FIRE, WARRIOR_HELMET, 0, 0, 0)
call ItemAddComponents(CHILLING_AXE, ORB_OF_FROST, ORCISH_AXE, 0, 0, 0)
call ItemAddComponents(HOLY_BOW, ORB_OF_LIGHT, SIMPLE_BOW, 0, 0, 0)
call ItemAddComponents(LIGHTNING_SPEAR, ORB_OF_LIGHTNING, GLOVES_OF_SILVER, 0, 0, 0)
call ItemAddComponents(DESERT_RING, ORB_OF_SANDS, SORCERER_RING, 0, 0 ,0)
call ItemAddComponents(SOUL_SWORD, ORB_OF_SOULS, GOLDEN_SWORD, 0, 0, 0)
call ItemAddComponents(NATURE_STAFF, ORB_OF_THORNS, MAGE_STAFF, 0, 0, 0)
call ItemAddComponents(TOXIC_DAGGER, ORB_OF_VENOM, GOLDEN_SWORD, 0, 0 ,0)
call ItemAddComponents(OCEANIC_MACE, ORB_OF_WATER, ENHANCED_HAMMER, 0, 0, 0)
call ItemAddComponents(WIND_SWORD, ORB_OF_WIND, GOLDEN_SWORD, 0, 0, 0)
call ItemAddComponents(SPHERE_OF_FIRE, ORB_OF_FIRE, SPHERE_OF_POWER, 0, 0, 0)
call ItemAddComponents(SPHERE_OF_WATER, ORB_OF_WATER, SPHERE_OF_POWER, 0, 0, 0)
call ItemAddComponents(SPHERE_OF_NATURE, ORB_OF_THORNS, SPHERE_OF_POWER, 0, 0, 0)
call ItemAddComponents(SPHERE_OF_DIVINITY, ORB_OF_LIGHT, SPHERE_OF_POWER, 0, 0, 0)
call ItemAddComponents(SPHERE_OF_LIGHTNING, ORB_OF_LIGHTNING, SPHERE_OF_POWER, 0, 0, 0)
call ItemAddComponents(SPHERE_OF_DARKNESS, ORB_OF_DARKNESS, SPHERE_OF_POWER, 0, 0, 0)
call ItemAddComponents(SPHERE_OF_AIR, ORB_OF_WIND, SPHERE_OF_POWER, 0, 0, 0)
call ItemAddComponents(ETERNITY_STONE, FUSED_LIFE_CRYSTALS, LIFE_ESSENCE_CRYSTAL, 0, 0, 0)
call ItemAddComponents(FUSION_CRYSTAL, FUSED_LIFE_CRYSTALS, INFUSED_MANA_CRYSTAL, 0, 0, 0)
call ItemAddComponents(WIZARD_STONE, ELEMENTAL_SHARD, 0, 0, 0, 0)
call ItemAddComponents(ANCIENT_STONE, WIZARD_STONE, 0, 0, 0, 0)
call ItemAddComponents(KNIGHT_BLADE, WARRIOR_BLADE, ORCISH_AXE, 0, 0, 0)
call ItemAddComponents(RITUAL_DAGGER, BLACK_NAVAJA, MASK_OF_MADNESS, 0, 0, 0)
call ItemAddComponents(GIANTS_HAMMER, OCEANIC_MACE, 0, 0, 0, 0)
call ItemAddComponents(AXE_OF_THE_GREEDY, ORCISH_AXE, ORCISH_AXE, 0, 0, 0)
call ItemAddComponents(SAPHIRE_SHOULDER_PLATE, FUSED_LIFE_CRYSTALS, EMERALD_SHOULDER_PLATE, 0, 0, 0)
call ItemAddComponents(FLAMING_ARMOR, CLOAK_OF_FLAMES, FUSED_LIFE_CRYSTALS, STEEL_ARMOR, 0, 0)
call ItemAddComponents(DRAGON_HELMET, WARRIOR_HELMET, ETERNITY_STONE, 0, 0, 0)
call ItemAddComponents(REAPERS_EDGE, SOUL_SCYTHER, SPHERE_OF_POWER, 0, 0, 0)
call ItemAddComponents(GLOVES_OF_GOLD, GLOVES_OF_SILVER, GLOVES_OF_SILVER, 0, 0, 0)
call ItemAddComponents(COMMANDERS_SHIELD, FUSED_LIFE_CRYSTALS, WARRIOR_SHIELD, 0, 0, 0)
call ItemAddComponents(SORCERER_STAFF, MAGE_STAFF, SPHERE_OF_POWER, 0, 0, 0)
call ItemAddComponents(BOOK_OF_FLAMES, SUMMONING_BOOK, SPHERE_OF_FIRE, 0, 0, 0)
call ItemAddComponents(BOOK_OF_OCEANS, SUMMONING_BOOK, SPHERE_OF_WATER, 0, 0, 0)
call ItemAddComponents(BOOK_OF_NATURE, SUMMONING_BOOK, SPHERE_OF_NATURE, 0, 0, 0)
call ItemAddComponents(BOOK_OF_LIGHT, SUMMONING_BOOK, SPHERE_OF_DIVINITY, 0, 0, 0)
call ItemAddComponents(BOOK_OF_CHAOS, SUMMONING_BOOK, SPHERE_OF_DARKNESS, 0, 0, 0)
call ItemAddComponents(BOOK_OF_ICE, SUMMONING_BOOK, SPHERE_OF_AIR, 0, 0, 0)
call ItemAddComponents(HELLISH_MASK, DEMONIC_MASK, SPHERE_OF_DARKNESS, 0, 0, 0)
call ItemAddComponents(ENFLAMED_BOW, HOLY_BOW, SPHERE_OF_FIRE, 0, 0, 0)
call ItemAddComponents(RING_OF_CONVERSION, DESERT_RING, SPHERE_OF_POWER, SPHERE_OF_POWER, 0, 0)
call ItemAddComponents(ANCIENT_SPHERE, SPHERE_OF_POWER, ANCIENT_STONE, 0, 0, 0)
call ItemAddComponents(LEGENDARY_BLADE_I, WARRIOR_BLADE, SPHERE_OF_FIRE, 0, 0, 0)
call ItemAddComponents(TRIEDGE_SWORD, ORCISH_AXE, KNIGHT_BLADE, 0, 0, 0)
call ItemAddComponents(CROWN_OF_RIGHTEOUSNESS, DESERT_RING, SPHERE_OF_DIVINITY, 0, 0, 0)
call ItemAddComponents(HEATING_CLOAK, ORB_OF_FIRE, ORB_OF_FROST, CLOAK_OF_FLAMES, 0, 0)
call ItemAddComponents(HAMMER_OF_NATURE, SPHERE_OF_NATURE, GIANTS_HAMMER, 0, 0, 0)
call ItemAddComponents(ELEMENTAL_SPIN, ORB_OF_FIRE, ORB_OF_WATER, ORB_OF_VENOM, ORB_OF_LIGHT, 0)
call ItemAddComponents(NECKLACE_OF_VIGOR, ANCIENT_STONE, 0, 0, 0, 0)
call ItemAddComponents(THUNDERGOD_SPEAR, LIGHTNING_SPEAR, SPHERE_OF_LIGHTNING, 0, 0, 0)
call ItemAddComponents(WIZARD_STAFF, SPHERE_OF_POWER, SORCERER_STAFF, 0, 0, 0)
call ItemAddComponents(PHILOSOPHERS_STONE, ELEMENTAL_SHARD, ANCIENT_STONE, 0, 0, 0)
call ItemAddComponents(ENTITY_SCYTHE, SOUL_SWORD, REAPERS_EDGE, 0, 0, 0)
call ItemAddComponents(LEGENDARY_BLADE_II, SPHERE_OF_DIVINITY, LEGENDARY_BLADE_I, 0, 0, 0)
call ItemAddComponents(DOOMBRINGER, SPHERE_OF_FIRE, TRIEDGE_SWORD, 0, 0, 0)
call ItemAddComponents(DUAL_ELEMENTAL_DAGGER, RITUAL_DAGGER, SPHERE_OF_FIRE, SPHERE_OF_WATER, 0, 0)
call ItemAddComponents(APOCALYPTIC_MASK, HELLISH_MASK, SPHERE_OF_DARKNESS, 0, 0, 0)
call ItemAddComponents(RADIANT_HELMET, DRAGON_HELMET, PHILOSOPHERS_STONE, 0, 0, 0)
call ItemAddComponents(JADEN_SHOULDER_PLATE, EMERALD_SHOULDER_PLATE, SAPHIRE_SHOULDER_PLATE, 0, 0, 0)
call ItemAddComponents(MOONCHANT_RING, FUSION_CRYSTAL, RING_OF_CONVERSION, 0, 0, 0)
call ItemAddComponents(BLOODBOURNE_SHIELD, COMMANDERS_SHIELD, PHILOSOPHERS_STONE, 0, 0, 0)
call ItemAddComponents(NATURE_GODDESS_STAFF, SPHERE_OF_NATURE, NATURE_STAFF, 0, 0, 0)
call ItemAddComponents(PHOENIX_AXE, SPHERE_OF_FIRE, AXE_OF_THE_GREEDY, 0, 0, 0)
call ItemAddComponents(WEAVER_I, BOOK_OF_CHAOS, ANCIENT_SPHERE, 0, 0, 0)
call ItemAddComponents(LEGENDARY_BLADE_III, SPHERE_OF_WATER, LEGENDARY_BLADE_II, 0, 0, 0)
call ItemAddComponents(REDEMPTION_SWORD, SPHERE_OF_DIVINITY, DOOMBRINGER, 0, 0, 0)
call ItemAddComponents(ELEMENTAL_STONE, ELEMENTAL_SHARD, PHILOSOPHERS_STONE, 0, 0, 0)
call ItemAddComponents(SAPPHIRE_HAMMER, HAMMER_OF_NATURE, SAPHIRE_SHOULDER_PLATE, 0, 0, 0)
call ItemAddComponents(FIRE_BOW, SPHERE_OF_FIRE, ENFLAMED_BOW, 0, 0, 0)
call ItemAddComponents(WARLOCK_RING, SPHERE_OF_DARKNESS, MOONCHANT_RING, 0, 0, 0)
call ItemAddComponents(TWIN_PHANTOM_SPEAR, GLOVES_OF_GOLD, THUNDERGOD_SPEAR, 0, 0, 0)
call ItemAddComponents(RED_MOON_SCYTH, HELLISH_MASK, ENTITY_SCYTHE, 0, 0, 0)
call ItemAddComponents(HOLY_SCEPTER, WIZARD_STAFF, CROWN_OF_RIGHTEOUSNESS, 0, 0, 0)
call ItemAddComponents(MAGUS_ORB, ELEMENTAL_SPIN, ANCIENT_SPHERE, 0, 0, 0)
call ItemAddComponents(WEAVER_II, WEAVER_I, 0, 0, 0, 0)
call ItemAddComponents(LEGENDARY_BLADE_IV, SPHERE_OF_DARKNESS, LEGENDARY_BLADE_III, 0, 0, 0)
call ItemAddComponents(SWORD_OF_DOMINATION, REDEMPTION_SWORD, 0, 0, 0, 0)
call ItemAddComponents(ARC_TRINITY, TRIEDGE_SWORD, TRIEDGE_SWORD, TRIEDGE_SWORD, 0, 0)
call ItemAddComponents(HOLY_HAMMER, SPHERE_OF_DIVINITY, SAPPHIRE_HAMMER, 0, 0, 0)
call ItemAddComponents(GLUTTONOUS_AXE, APOCALYPTIC_MASK, PHOENIX_AXE, 0, 0, 0)
call ItemAddComponents(CROWN_OF_GODS, CROWN_OF_RIGHTEOUSNESS, WARLOCK_RING, 0, 0, 0)
call ItemAddComponents(BLACK_ARMOR, SPHERE_OF_DARKNESS, FLAMING_ARMOR, 0, 0, 0)
call ItemAddComponents(ANGELIC_SHIELD, SPHERE_OF_DIVINITY, BLOODBOURNE_SHIELD, 0, 0, 0)
call ItemAddComponents(HELMET_OF_ETERNITY, ETERNITY_STONE, RADIANT_HELMET, 0, 0, 0)
call ItemAddComponents(ARCANA_SCEPTER, HOLY_SCEPTER, ANCIENT_SPHERE, 0, 0, 0)
call ItemAddComponents(ELEMENTAL_SPHERE, SPHERE_OF_FIRE, SPHERE_OF_WATER, SPHERE_OF_NATURE, SPHERE_OF_AIR, SPHERE_OF_DARKNESS)
call ItemAddComponents(LEGENDARY_BLADE_V, SPHERE_OF_AIR, LEGENDARY_BLADE_IV, 0, 0, 0)
endmethod
static method create takes integer shop, real aoe, real tax returns thistype
local integer damage
local integer armor
local integer strength
local integer agility
local integer intelligence
local integer health
local integer mana
local integer attackSpeed
local integer movement
local integer spellPower
local integer cooldown
local integer regeneration
local integer consumable
call CreateShop(shop, aoe, tax)
set damage = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNSteelMelee", "Damage")
set armor = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNHumanArmorUpOne", "Armor")
set strength = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNGauntletsOfOgrePower", "Strength")
set agility = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNSlippersOfAgility", "Agility")
set intelligence = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNMantleOfIntelligence", "Intelligence")
set health = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNFireCrystalElement", "Health")
set mana = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNItem_Gem_Aquamarine.blp", "Mana")
set attackSpeed = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNGlove.blp", "Attack Speed")
set movement = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNBootsOfSpeed", "Movement")
set spellPower = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNControlMagic", "Spell Power")
set cooldown = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNSpin.blp", "Cooldown")
set regeneration = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNTowerRegen.blp", "Regeneration")
set consumable = ShopAddCategory(shop, "ReplaceableTextures\\CommandButtons\\BTNPotionGreenSmall", "Consumable")
call ShopAddItem(shop, BOOTS_OF_SPEED, movement)
call ShopAddItem(shop, ANKH_OF_REINCARNATION, consumable)
call ShopAddItem(shop, POTION_OF_RESTORATION, consumable)
call ShopAddItem(shop, MASK_OF_DEATH, regeneration)
call ShopAddItem(shop, CLOAK_OF_FLAMES, damage)
call ShopAddItem(shop, COMMOM_SHIELD, armor)
call ShopAddItem(shop, HEAVY_HAMMER, damage)
call ShopAddItem(shop, ASSASSINS_DAGGER, damage)
call ShopAddItem(shop, IRON_AXE, damage)
call ShopAddItem(shop, SIMPLE_BOW, agility)
call ShopAddItem(shop, SUMMONING_BOOK, spellPower + cooldown)
call ShopAddItem(shop, COURIER, consumable)
call ShopAddItem(shop, LIFE_CRYSTAL, health)
call ShopAddItem(shop, MANA_CRYSTAL, mana)
call ShopAddItem(shop, LIFE_ESSENCE_CRYSTAL, regeneration)
call ShopAddItem(shop, CRYSTAL_RING, regeneration + spellPower)
call ShopAddItem(shop, HOMECOMING_STONE, movement)
call ShopAddItem(shop, BRACELET_OF_INTELLIGENCE, intelligence)
call ShopAddItem(shop, CLAWS_OF_AGILITY, agility)
call ShopAddItem(shop, GAUNTLET_OF_STRENGTH, strength)
call ShopAddItem(shop, GLOVES_OF_HASTE, attackSpeed)
call ShopAddItem(shop, PLATEMAIL, armor)
call ShopAddItem(shop, RUSTY_SWORD, damage)
call ShopAddItem(shop, ORB_OF_FIRE, damage)
call ShopAddItem(shop, ORB_OF_FROST, damage)
call ShopAddItem(shop, ORB_OF_LIGHT, damage)
call ShopAddItem(shop, ORB_OF_LIGHTNING, damage)
call ShopAddItem(shop, ORB_OF_SANDS, damage)
call ShopAddItem(shop, ORB_OF_SOULS, damage + regeneration)
call ShopAddItem(shop, ORB_OF_THORNS, damage)
call ShopAddItem(shop, ORB_OF_VENOM, damage)
call ShopAddItem(shop, ORB_OF_WATER, damage)
call ShopAddItem(shop, ORB_OF_WIND, damage + movement)
call ShopAddItem(shop, ORB_OF_DARKNESS, damage)
call ShopAddItem(shop, SPHERE_OF_POWER, spellPower)
call ShopAddItem(shop, BOOTS_OF_THE_BRAVES, movement + health + attackSpeed + cooldown)
call ShopAddItem(shop, BOOTS_OF_AGILITY, movement + agility)
call ShopAddItem(shop, BOOTS_OF_INTELLIGENCE, movement + intelligence)
call ShopAddItem(shop, BOOTS_OF_STRENGTH, movement + strength)
call ShopAddItem(shop, BOOTS_OF_RESTORATION, movement + regeneration + health)
call ShopAddItem(shop, BOOTS_OF_FLAMES, movement + damage)
call ShopAddItem(shop, GOLDEN_BOOTS, movement + regeneration + damage)
call ShopAddItem(shop, HEAVY_BOOTS, movement + attackSpeed + damage)
call ShopAddItem(shop, SILVER_BOOTS, movement + armor + health)
call ShopAddItem(shop, BERSERKER_BOOTS, movement + attackSpeed + damage)
call ShopAddItem(shop, RUNIC_BOOTS, movement + health + mana + spellPower)
call ShopAddItem(shop, GOLDEN_SWORD, damage)
call ShopAddItem(shop, GOLDEN_PLATEMAIL, armor + health)
call ShopAddItem(shop, FUSED_LIFE_CRYSTALS, health)
call ShopAddItem(shop, INFUSED_MANA_CRYSTAL, mana)
call ShopAddItem(shop, ELEMENTAL_SHARD, health + mana + regeneration)
call ShopAddItem(shop, HARDENED_SHIELD, health + armor)
call ShopAddItem(shop, MASK_OF_MADNESS, regeneration)
call ShopAddItem(shop, GLOVES_OF_SPEED, attackSpeed)
call ShopAddItem(shop, GLAIVE_SCYTHE, agility + strength + intelligence)
call ShopAddItem(shop, MAGE_STICK, spellPower + mana + regeneration)
call ShopAddItem(shop, SORCERER_RING, mana + regeneration + spellPower)
call ShopAddItem(shop, WARRIOR_BLADE, damage + attackSpeed)
call ShopAddItem(shop, BLACK_NAVAJA, damage)
call ShopAddItem(shop, ORCISH_AXE, damage)
call ShopAddItem(shop, ENHANCED_HAMMER, damage)
call ShopAddItem(shop, EMERALD_SHOULDER_PLATE, health + strength)
call ShopAddItem(shop, STEEL_ARMOR, health + armor)
call ShopAddItem(shop, WARRIOR_HELMET, strength + regeneration)
call ShopAddItem(shop, SOUL_SCYTHER, damage + strength + agility + intelligence)
call ShopAddItem(shop, GLOVES_OF_SILVER, attackSpeed)
call ShopAddItem(shop, WARRIOR_SHIELD, health + armor)
call ShopAddItem(shop, MAGE_STAFF, spellPower + intelligence + health + regeneration)
call ShopAddItem(shop, DEMONIC_MASK, damage + regeneration)
call ShopAddItem(shop, MAGMA_HELMET, strength + regeneration)
call ShopAddItem(shop, CHILLING_AXE, damage)
call ShopAddItem(shop, HOLY_BOW, damage + agility)
call ShopAddItem(shop, LIGHTNING_SPEAR, damage + attackSpeed)
call ShopAddItem(shop, DESERT_RING, mana + regeneration + spellPower)
call ShopAddItem(shop, SOUL_SWORD, damage + regeneration)
call ShopAddItem(shop, NATURE_STAFF, spellPower + intelligence + health)
call ShopAddItem(shop, TOXIC_DAGGER, damage)
call ShopAddItem(shop, OCEANIC_MACE, damage)
call ShopAddItem(shop, WIND_SWORD, damage + movement)
call ShopAddItem(shop, SPHERE_OF_FIRE, spellPower)
call ShopAddItem(shop, SPHERE_OF_WATER, spellPower)
call ShopAddItem(shop, SPHERE_OF_NATURE, spellPower)
call ShopAddItem(shop, SPHERE_OF_DIVINITY, spellPower)
call ShopAddItem(shop, SPHERE_OF_LIGHTNING, spellPower)
call ShopAddItem(shop, SPHERE_OF_DARKNESS, spellPower)
call ShopAddItem(shop, SPHERE_OF_AIR, spellPower)
call ShopAddItem(shop, ETERNITY_STONE, health + regeneration)
call ShopAddItem(shop, FUSION_CRYSTAL, health + mana + regeneration)
call ShopAddItem(shop, WIZARD_STONE, health + mana + regeneration)
call ShopAddItem(shop, ANCIENT_STONE, health + mana + regeneration + spellPower)
call ShopAddItem(shop, KNIGHT_BLADE, damage + attackSpeed)
call ShopAddItem(shop, RITUAL_DAGGER, damage + regeneration)
call ShopAddItem(shop, GIANTS_HAMMER, damage)
call ShopAddItem(shop, AXE_OF_THE_GREEDY, damage)
call ShopAddItem(shop, SAPHIRE_SHOULDER_PLATE, health + strength)
call ShopAddItem(shop, FLAMING_ARMOR, health + armor)
call ShopAddItem(shop, DRAGON_HELMET, health + strength + regeneration)
call ShopAddItem(shop, REAPERS_EDGE, spellPower + strength + agility + intelligence)
call ShopAddItem(shop, GLOVES_OF_GOLD, attackSpeed)
call ShopAddItem(shop, COMMANDERS_SHIELD, armor + health)
call ShopAddItem(shop, SORCERER_STAFF, spellPower + health + intelligence + regeneration)
call ShopAddItem(shop, BOOK_OF_FLAMES, spellPower + damage + intelligence)
call ShopAddItem(shop, BOOK_OF_OCEANS, spellPower + intelligence + mana)
call ShopAddItem(shop, BOOK_OF_NATURE, spellPower + intelligence + regeneration)
call ShopAddItem(shop, BOOK_OF_LIGHT, spellPower + intelligence + regeneration)
call ShopAddItem(shop, BOOK_OF_CHAOS, spellPower + intelligence + health)
call ShopAddItem(shop, BOOK_OF_ICE, spellPower + intelligence + armor)
call ShopAddItem(shop, HELLISH_MASK, damage + regeneration)
call ShopAddItem(shop, ENFLAMED_BOW, damage + agility)
call ShopAddItem(shop, RING_OF_CONVERSION, mana + regeneration)
call ShopAddItem(shop, ANCIENT_SPHERE, spellPower + mana + health + regeneration)
call ShopAddItem(shop, LEGENDARY_BLADE_I, spellPower + damage + attackSpeed)
call ShopAddItem(shop, TRIEDGE_SWORD, damage)
call ShopAddItem(shop, CROWN_OF_RIGHTEOUSNESS, mana + regeneration + spellPower)
call ShopAddItem(shop, HEATING_CLOAK, mana + health + damage)
call ShopAddItem(shop, HAMMER_OF_NATURE, damage + strength + spellPower)
call ShopAddItem(shop, ELEMENTAL_SPIN, regeneration + spellPower + intelligence)
call ShopAddItem(shop, NECKLACE_OF_VIGOR, health + mana + spellPower)
call ShopAddItem(shop, THUNDERGOD_SPEAR, attackSpeed + damage + spellPower)
call ShopAddItem(shop, WIZARD_STAFF, intelligence + regeneration + spellPower + health)
call ShopAddItem(shop, PHILOSOPHERS_STONE, regeneration + mana + health)
call ShopAddItem(shop, ENTITY_SCYTHE, spellPower + movement + agility + strength + intelligence)
call ShopAddItem(shop, LEGENDARY_BLADE_II, spellPower + damage + attackSpeed)
call ShopAddItem(shop, DOOMBRINGER, damage)
call ShopAddItem(shop, DUAL_ELEMENTAL_DAGGER, damage + spellPower + regeneration)
call ShopAddItem(shop, APOCALYPTIC_MASK, damage + regeneration)
call ShopAddItem(shop, RADIANT_HELMET, health + mana + strength + regeneration)
call ShopAddItem(shop, JADEN_SHOULDER_PLATE, health + strength)
call ShopAddItem(shop, MOONCHANT_RING, health + mana + regeneration + intelligence)
call ShopAddItem(shop, BLOODBOURNE_SHIELD, health + armor)
call ShopAddItem(shop, NATURE_GODDESS_STAFF, spellPower + health + intelligence)
call ShopAddItem(shop, PHOENIX_AXE, spellPower + damage)
call ShopAddItem(shop, WEAVER_I, mana + health + regeneration + spellPower + intelligence + cooldown)
call ShopAddItem(shop, LEGENDARY_BLADE_III, damage + spellPower + attackSpeed)
call ShopAddItem(shop, REDEMPTION_SWORD, damage + spellPower)
call ShopAddItem(shop, ELEMENTAL_STONE, mana + health + regeneration)
call ShopAddItem(shop, SAPPHIRE_HAMMER, damage + spellPower + strength)
call ShopAddItem(shop, FIRE_BOW, damage + spellPower + agility)
call ShopAddItem(shop, WARLOCK_RING, health + spellPower + mana + regeneration + intelligence)
call ShopAddItem(shop, TWIN_PHANTOM_SPEAR, attackSpeed + spellPower + damage + movement)
call ShopAddItem(shop, RED_MOON_SCYTH, regeneration + spellPower + damage + movement + agility + strength + intelligence)
call ShopAddItem(shop, HOLY_SCEPTER, spellPower + intelligence + regeneration)
call ShopAddItem(shop, MAGUS_ORB, spellPower + intelligence + regeneration)
call ShopAddItem(shop, WEAVER_II, mana + health + regeneration + spellPower + intelligence + cooldown)
call ShopAddItem(shop, LEGENDARY_BLADE_IV, spellPower + damage + attackSpeed)
call ShopAddItem(shop, SWORD_OF_DOMINATION, spellPower + damage)
call ShopAddItem(shop, ARC_TRINITY, damage + regeneration)
call ShopAddItem(shop, HOLY_HAMMER, spellPower + damage + strength + regeneration)
call ShopAddItem(shop, GLUTTONOUS_AXE, damage + regeneration)
call ShopAddItem(shop, CROWN_OF_GODS, health + mana + regeneration + intelligence + spellPower)
call ShopAddItem(shop, BLACK_ARMOR, health + armor)
call ShopAddItem(shop, ANGELIC_SHIELD, health + armor)
call ShopAddItem(shop, HELMET_OF_ETERNITY, health + mana + regeneration + strength)
call ShopAddItem(shop, ARCANA_SCEPTER, health + mana + regeneration + intelligence + spellPower)
call ShopAddItem(shop, ELEMENTAL_SPHERE, health + mana + regeneration + spellPower + damage)
call ShopAddItem(shop, LEGENDARY_BLADE_V, damage + spellPower + attackSpeed + movement)
call ShopAddItem(shop, CROWN_OF_ICE, spellPower + damage + strength + agility + intelligence)
call ShopAddItem(shop, GOLDEN_HEART, health + armor)
call ShopAddItem(shop, LIGHTNING_SWORD, damage + attackSpeed)
call ShopAddItem(shop, SAKURA_BLADE, damage + attackSpeed + movement)
return 0
endmethod
private static method onInit takes nothing returns nothing
call configure()
call create('ngme', 600, 0.5)
call SetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD, 9999999)
// call BlzFrameSetAlpha(BlzGetFrameByName("SimpleInventoryCover", 0), 0)
// call BlzFrameSetScale(BlzGetFrameByName("InventoryText", 0), 0.0001)
// call BlzFrameSetAbsPoint(BlzGetFrameByName("ConsoleUI", 0), FRAMEPOINT_TOPLEFT, 0.0, 0.633)
// call BlzFrameSetVisible(BlzGetFrameByName("ResourceBarFrame", 0), false)
// call BlzFrameSetVisible(BlzGetFrameByName("UpperButtonBarFrame", 0), false)
// call BlzFrameSetVisible(BlzFrameGetChild(BlzGetFrameByName("ConsoleUI", 0), 7), false)
// call BlzFrameSetVisible(BlzFrameGetChild(BlzFrameGetChild(BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 5),0), false)
// call BlzFrameSetParent(BlzGetFrameByName("MiniMapFrame", 0), BlzGetFrameByName("ConsoleUIBackdrop", 0))
// call BlzFrameSetVisible(BlzGetOriginFrame(ORIGIN_FRAME_PORTRAIT, 0), false)
endmethod
endstruct
endscope