private function BuildBase takes real GetX,real GetY,integer i returns nothing
local integer c = 0
local integer r = 0
local integer position = 0
local trackable t
local real x = GetX -(offset*cols)+offset
local real y = (GetY - 2*offset)
local string Type = TYPE[0]
local primeData pd
local trackyData temp
call CreateDestructableZ(background,PlayerX[i],PlayerY[i],0,0,1.50,1)
loop
exitwhen r >= rows
loop
exitwhen c >= cols
set t = CreateTrackable(model,x,y,0)
call TriggerRegisterTrackableTrackEvent(TrackTrk,t)
call TriggerRegisterTrackableHitEvent(ClickTrk,t)
set pd = primeData(primeIndex[i])
set temp = pd.td[position].create()
call SaveInteger(StructData,GetHandleId(t),0,integer(temp))
set temp.pos = position
set temp.x = x
set temp.y = y
set x = x + offset
set c = c+1
set position = position + 1
endloop
if r < rows then
set c = 0
set y = y - offset
set x = PlayerX[i] -(offset*cols) +offset
endif
set r=r+1
endloop
endfunction
// ch5.3 A help function used to shorten the code and make other stuff more user friendly
function BuildHelp takes real x,real y,integer i,integer position returns nothing
local trackable t = CreateTrackable(model,x,y,0)
local primeData pd = primeData(primeIndex[i])
local trackyData td = pd.td[position].create()
call TriggerRegisterTrackableTrackEvent(TrackTrk,t)
call TriggerRegisterTrackableHitEvent(ClickTrk,t)
call SaveInteger(StructData,GetHandleId(t),0,integer(td))
set td.pos = position
set td.x = x
set td.y = y
endfunction
// ch5.4 Defining Merchant Inventory, mainly it's X/Y
private function BuildMerc takes real GetX,real GetY,integer i returns nothing
local integer c = 0
local integer r = 0
local integer position = (rows*cols)+reserved_space
local trackable t
local real x = GetX
local real y = (GetY - mrows*offset)
local string Type = TYPE[0]
local primeData pd = primeData(primeIndex[i])
local trackyData td
loop
exitwhen r >= mrows
loop
exitwhen c >= mcols
set t = CreateTrackable(model,x,y,0)
call TriggerRegisterTrackableTrackEvent(TrackTrk,t)
call TriggerRegisterTrackableHitEvent(ClickTrk,t)
set td = pd.td[position].create()
call SaveInteger(StructData,GetHandleId(t),0,integer(td))
set td.pos = position
set td.x = x
set td.y = y
set x = x + offset
set c = c+1
set position = position + 1
endloop
if r < mrows then
set c = 0
set y = y - offset
set x = PlayerX[i]+(offset*mcols)-(mcols/2*offset)
endif
set r=r+1
endloop
endfunction
// ch5.5 Defining Equipment Location via offset constant, 1*offset = 1.7 X/Y displacement meaning if you add +1*(offset) to a slot
// you move it for 1 slot right
private function BuildEquip takes real GetX,real GetY,integer i returns nothing
local integer position = (rows*cols)
local real bx = (GetX-(offset*cols)+offset)+((cols/2)*offset)
local real by = GetY+(6*offset)
local real x
local real y
// exit inventory button
set x = bx + (19*offset)
set y = by - (12*offset)
call BuildHelp(x,y,i,position)
set position = position + 1
// end of button
// drop item button
set x = bx + (17*offset)
set y = by - (12*offset)
call BuildHelp(x,y,i,position)
set position = position + 1
//end of button
// trade item button
set x = bx + (9*offset)
set y = by - (4*offset)
call BuildHelp(x,y,i,position)
set position = position + 1
// end of button
// helm slot
set x = bx
set y = by
call BuildHelp(x,y,i,position)
set position = position + 1
// end of slot
// armor slot
set y = by - (2*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// belt slot
set y = by - (4*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// boots slot
set y = by - (6*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// weapon slot
set y = by - (2*offset)
set x = bx - (3*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// offhand slot
set x = bx + (3*offset)
set y = by - (2*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// gloves slot
set x = bx - (1.5*offset)
set y = by - (2.5*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// amulet slot
set x = bx + (1.5*offset)
set y = by + (0.5*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// ring slot
set x = bx - (3*offset)
set y = by - (5*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// ring slot
set x = bx - (2*offset)
set y = by - (5*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// consumable slot
set x = bx + (3*offset)
set y = by - (5*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// consumable slot
set x = bx + (4*offset)
set y = by - (5*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// consumable slot
set x = bx + (5*offset)
set y = by - (5*offset)
call BuildHelp(x,y,i,position)
set position = position+1
// end of slot
// desirable slot that you want added goes here
// end of desirable slot
endfunction
private function Build takes nothing returns nothing
local trigger t = CreateTrigger()
local trigger t2 = CreateTrigger()
local trigger t3 = CreateTrigger()
local trigger t4 = CreateTrigger()
local trigger t5 = CreateTrigger()
local integer i = 0
local item Item = CreateItem('IXXX',0,0)
local real x
local real y
local primeData pd
set MinY = GetRectMinY(bj_mapInitialPlayableArea)
set MinX = GetRectMinX(bj_mapInitialPlayableArea)
set MaxY = GetRectMaxY(bj_mapInitialPlayableArea)
set MaxX = GetRectMaxX(bj_mapInitialPlayableArea)
set x =MinX-StartX -(offset*cols) +offset
set item_index = reserved_space+1
set y = MinY+StartY
call CreateItemSimple(Item)
call RemoveItem(Item)
call SetCameraBounds(x,y,x, MaxY, MaxX, MaxY, MaxX,y)
set i = 0
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
if GetLocalPlayer() == Player(i) then
set pd = primeData.create()
set primeIndex[i] = integer(pd)
call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerEvent(t3,Player(i),EVENT_PLAYER_END_CINEMATIC)
call TriggerRegisterPlayerUnitEvent(t4,Player(i),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(t5,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(t2,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
set PlayerX[i] = x + (i*100)
set PlayerY[i] = y
call BuildBase(PlayerX[i],PlayerY[i],i)
call BuildEquip(PlayerX[i],PlayerY[i],i)
call BuildMerc(PlayerX[i]+(offset*mcols)-(mcols/2*offset),y+(offset*mrows)+(mrows/2*offset),i)
set Multiboard[i] = null
set vem[i] = CreateFogModifierRadius(Player(i),FOG_OF_WAR_VISIBLE,PlayerX[i],PlayerY[i],200,false,false)
call FogModifierStop(vem[i])
set camtimer[i] = CreateTimer()
endif
set i=i+1
endloop
call SetCameraBounds(MinX, MinY, MinX, MaxY, MaxX, MaxY, MaxX, MinY)
call AddAbilsPreload()
call TriggerAddAction(TrackTrk,function OnTrack)
call TriggerAddAction(ClickTrk,function OnHit)
call TriggerAddCondition(t,Condition(function ItemCondition))
call TriggerAddAction(t,function ExecAction)
call TriggerRegisterAnyUnitEventBJ(t2,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(t2, function OpenThisInventory)
call TriggerAddCondition(t2,Condition(function Condition2Open))
call TriggerAddCondition(t3,Condition(function Condition2Close))
call TriggerAddAction(t3,function CloseThisInventory)
call TriggerAddCondition(t4,Condition(function Conditional))
call TriggerAddAction(t4,function Actions)
call TriggerAddCondition(t5,function Condition2Browse)
call TriggerAddAction(t5,function InitBrowse)
call DefineTypes()
endfunction