123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772 |
- # DH_Inventory
- !! Format for variables is Variable[CharacterInv_ItemType]
- !!~~ Checks
- !!~~ Check if inventory exists
- !!if $.character = '' or ARRPOS($dhInv_, $.character) = -1:
- !! $RESULT = $DhInv_Msg_['InventoryFull']
- !! jump 'AutoKill '
- !!end
- !!~~#
-
- !!~~#
- if $ARGS[0] = 'Init':
- !!~~ Gear Slots
- $DhInv_ArmSlot_[0] = 'Head'
- $DhInv_ArmSlot_[1] = 'Suit'
- $DhInv_ArmSlot_[2] = 'Chest'
- $DhInv_ArmSlot_[3] = 'Legs'
- $DhInv_ArmSlot_[4] = 'Gloves'
- $DhInv_ArmSlot_[5] = 'Feet'
- $DhInv_ArmSlot_[6] = 'ShoulderL'
- $DhInv_ArmSlot_[7] = 'ShoulderR'
- $DhInv_ArmSlot_[8] = 'Cloak'
- $DhInv_ArmSlot_[9] = 'Wings'
- $DhInv_ArmSlot_[10] = 'Shield'
-
- $DhInv_WepSlot_[0] = 'MainHand'
- $DhInv_WepSlot_[1] = 'Offhand'
-
- $DhInv_AccSlot_[0] = 'RingL'
- $DhInv_AccSlot_[1] = 'RingR'
- $DhInv_AccSlot_[2] = 'Necklace'
- $DhInv_AccSlot_[3] = 'Earrings'
- !!~~#
-
- !!~~ Item Grades
- $DhInv_Grade_[0] = 'Junk' &! Grey
- $DhInv_Grade_[1] = 'Common' &! White/Black (depends on bg)
- $DhInv_Grade_[2] = 'Uncommon' &! Green
- $DhInv_Grade_[3] = 'Rare' &! Blue
- $DhInv_Grade_[4] = 'Epic' &! Purple
- $DhInv_Grade_[5] = 'Legendary' &! Orange
- $DhInv_Grade_[6] = 'Godlike' &! Red
- $DhInv_Grade_[7] = 'Cheat' &! Pink
- !!~~#
-
- !!~~ Messages
- $DhInv_Msg_['Error'] = 'Something went wrong. Contact WinkyFace on <a href="tfgamessite.com">tfgamessite.com</a>'
- $DhInv_Msg_['ReqsNotMet'] = 'You do not meet the requirements to equip this item.'
- $DhInv_Msg_['InventoryFull'] = 'There are too many items in ''{0}''''s Inventory!'
- $DhInv_Msg_['NoInventory'] = 'No Inventory exists for the character ''{0}''!'
- $DhInv_Msg_['InventoryExists'] = 'An Inventory for the character ''{0}'' already exists!'
- $DhInv_Msg_['InvalidSlot'] = 'No Equipment Slot by the name of ''{0}'' exists!'
- !!~~#
-
- DhInv_DefSlots = 8 &!The default number of slots for any Inventory
- end
- if $ARGS[0] = 'NewInventory':
- $.character = $ARGS[1]
- .slots = iif(ARGS[2] > 0, ARGS[2], DhInv_DefSlots)
-
- !! Check if inventory exists
- if ARRPOS($dhInv_, $.character) ! -1:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryExists'], $.character)
- exit
- end
-
- !! Create the inventory
- $dhInv_[] = $.character
- dhInv_Slots[$.character + 'Inv'] = .slots
-
- _i = 0
- :Loop DH_Inventory_NewInventory_GenerateSlots
- if _i < dhInv_Slots[$.character + 'Inv']
- $dhInv_Slot[$.character + 'Inv_Slot' + _i] = 'Empty'
- _i += 1
- jump 'Loop DH_Inventory_NewInventory_GenerateSlots'
- end
-
- gs 'DH_Inventory', 'Unequip', $.character, 'All'
- gs 'DH_Inventory', 'RemoveItem', $.character, 'All'
-
- end
- if $ARGS[0] = 'DeleteInventory':
- !! Check if inventory exists
- if ARRPOS($dhInv_, $.character) = -1:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['NoInventory'], $.character)
- exit
- end
-
- $.character = $ARGS[1]
- _invPos = ARRPOS('$dhInv_', $.character)
-
- !!~~ Kill Slots
- _i = 0
- _slotStart = 0
- :Loop DH_Inventory_DeleteInventory_GetSlotStart
- if _i < _invPos:
- _slotStart += dhInv_Slots[$dhInv_[_invPos] + 'Inv']
- _i += 1
- jump 'Loop DH_Inventory_DeleteInventory_GetSlotStart'
- end
-
- _i = 0
- :Loop DH_Inventory_DeleteInventory_KillSlots
- if _i < dhInv_Slots[$.character + 'Inv']
- KILLVAR '$dhInv_Slot', (_slotStart + _i)
- _i += 1
- jump 'Loop DH_Inventory_DeleteInventory_KillSlots'
- end
-
- KILLVAR 'dhInv_Slots', _invPos
- !!~~#
-
- _ArmorSlots = _invPos * ARRSIZE('$DhInv_ArmSlot_')
- _WeaponSlots = _invPos * ARRSIZE('$DhInv_WepSlot_')
- !!~~ Kill Equip Slots
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots)
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 1
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 2
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 3
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 4
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 5
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 6
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 7
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 8
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 9
- KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 10
- KILLVAR 'dhEqW_Name_', (_invPos * _WeaponSlots)
- KILLVAR 'dhEqW_Name_', (_invPos * _WeaponSlots) + 1
- !!~~#
-
- !!~~ Kill Durability
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots)
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 1
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 2
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 3
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 4
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 5
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 6
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 7
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 8
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 9
- KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 10
- KILLVAR 'dhEqW_Dur_', (_invPos * _WeaponSlots)
- KILLVAR 'dhEqW_Dur_', (_invPos * _WeaponSlots) + 1
- !!~~#
-
- !! Kill Inventory
- KILLVAR 'dhInv_', _invPos
-
- end
- if $ARGS[0] = 'Equip':
- $.character = $ARGS[1]
- $.slotType = $ARGS[2]
- $.itemName = $ARGS[3]
- $.durability = $ARGS[4]
-
- !! Check if inventory exists
- if ARRPOS($dhInv_, $.character) = -1:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['NoInventory'], $.character)
- exit
- end
-
- $_GearSlot = $.character + 'Inv_' + $.slotType
-
- if ARRPOS('$DhInv_ArmSlot_', $.slotType) ! -1:
- if $.slotType = 'Head' :
- !! Do I need a free slot?
- if $dhEqA_Name_[$.character + 'Inv_Head'] ! 'Empty':
- !! Do I have a free slot?
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- !! Free slot so unequip!
- FUNC('DH_Inventory', 'Unequip', $.character, 'Head')
- end
-
- !! Equip!
- gs 'DH_Gear_Heads', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
-
- elseif $.slotType = 'Suit' :
- _slotsToFree = 0
- if $dhEqA_Name_[$.character + 'Inv_Suit'] ! 'Empty': _slotsToFree = 1
- else
- if $dhEqA_Name_[$.character + 'Inv_Chest'] ! 'Empty': _slotsToFree += 1 & end
- if $dhEqA_Name_[$.character + 'Inv_Legs'] ! 'Empty': _slotsToFree += 1 & end
- end
-
- !! If 0 slotsToFree, nothing is equipped
- if _slotsToFree > 0:
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character, _slotsToFree) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- FUNC('DH_Inventory', 'Unequip', $.character, 'Suit')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Chest')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Legs')
- end
-
- gs 'DH_Gear_Suits', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
-
- elseif $.slotType = 'Chest' :
- !! Do I need a free slot?
- if $dhEqA_Name_[$.character + 'Inv_Chest'] ! 'Empty' or $dhEqA_Name_[$.character + 'Inv_Suit'] ! 'Empty':
- !! Do I have a free slot?
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- !! Free slot so unequip!
- FUNC('DH_Inventory', 'Unequip', $.character, 'Suit')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Chest')
- end
-
- !! Equip!
- gs 'DH_Gear_Chests', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
-
- elseif $.slotType = 'Legs' :
- !! Do I need a free slot?
- if $dhEqA_Name_[$.character + 'Inv_Legs'] ! 'Empty' or $dhEqA_Name_[$.character + 'Inv_Suit'] ! 'Empty':
- !! Do I have a free slot?
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- !! Free slot so unequip!
- FUNC('DH_Inventory', 'Unequip', $.character, 'Suit')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Legs')
- end
-
- !! Equip!
- gs 'DH_Gear_Legs', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
-
- elseif $.slotType = 'Gloves' :
- !! Do I need a free slot?
- if $dhEqA_Name_[$.character + 'Inv_Gloves'] ! 'Empty':
- !! Do I have a free slot?
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- !! Free slot so unequip!
- FUNC('DH_Inventory', 'Unequip', $.character, 'Gloves')
- end
-
- !! Equip!
- gs 'DH_Gear_Gloves', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
-
- elseif $.slotType = 'Feet' :
- !! Do I need a free slot?
- if $dhEqA_Name_[$.character + 'Inv_Feet'] ! 'Empty':
- !! Do I have a free slot?
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- !! Free slot so unequip!
- FUNC('DH_Inventory', 'Unequip', $.character, 'Feet')
- end
-
- !! Equip!
- gs 'DH_Gear_Feet', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
-
- elseif $.slotType = 'ShoulderL' :
- !! Do I need a free slot?
- if $dhEqA_Name_[$.character + 'Inv_ShoulderL'] ! 'Empty':
- !! Do I have a free slot?
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- !! Free slot so unequip!
- FUNC('DH_Inventory', 'Unequip', $.character, 'ShoulderL')
- end
-
- !! Equip!
- gs 'DH_Gear_Shoulders', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
-
- elseif $.slotType = 'ShoulderR' :
- !! Do I need a free slot?
- if $dhEqA_Name_[$.character + 'Inv_ShoulderR'] ! 'Empty':
- !! Do I have a free slot?
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- !! Free slot so unequip!
- FUNC('DH_Inventory', 'Unequip', $.character, 'ShoulderR')
- end
-
- !! Equip!
- gs 'DH_Gear_Shoulders', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
-
- elseif $.slotType = 'Cloak' :
- !! Do I need a free slot?
- if $dhEqA_Name_[$.character + 'Inv_Cloak'] ! 'Empty' or $dhEqA_Name_[$.character + 'Inv_Wings'] ! 'Empty':
- !! Do I have a free slot?
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- !! Free slot so unequip!
- FUNC('DH_Inventory', 'Unequip', $.character, 'Cloak')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Wings')
- end
-
- !! Equip!
- gs 'DH_Gear_Cloaks', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
-
- elseif $.slotType = 'Wings' :
- !! Do I need a free slot?
- if $dhEqA_Name_[$.character + 'Inv_Wings'] ! 'Empty' or $dhEqA_Name_[$.character + 'Inv_Cloak'] ! 'Empty':
- !! Do I have a free slot?
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- !! Free slot so unequip!
- FUNC('DH_Inventory', 'Unequip', $.character, 'Wings')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Cloak')
- end
-
- !! Equip!
- gs 'DH_Gear_Wings', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
-
- elseif $.slotType = 'Shield' :
- _offHandOnly = True
- _needsFreeSlot = False
- if $dhEqA_Name_[$.character + 'Inv_Shield'] ! 'Empty': _needsFreeSlot = True
- elseif $dhEqW_Name_[$.character + 'Inv_Offhand'] ! 'Empty': _needsFreeSlot = True
- elseif $dhEqW_Name_[$.character + 'Inv_MainHand'] ! 'Empty':
- if FUNC('DH_Gear_Weapons', 'IsOneHanded', $dhEqW_Name_[$.character + 'Inv_MainHand']) = False:
- _needsFreeSlot = True
- _offHandOnly = False
- end
- end
-
- if _needsFreeSlot:
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- if _offHandOnly:
- FUNC('DH_Inventory', 'Unequip', $.character, 'Shield')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand')
- else
- FUNC('DH_Inventory', 'Unequip', $.character, 'MainHand')
- end
- end
-
- gs 'DH_Gear_Shields', $.itemName
- $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
- $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
- jump 'DH_Inventory_Equip_AddArmorStats'
- end
-
- elseif ARRPOS('$DhInv_WepSlot_', $.slotType) ! -1:
- if $.slotType = 'MainHand' :
- !! Check if main equipped
- if $dhEqW_Name_[$.character + 'Inv_MainHand'] ! 'Empty':
- !! Check if 2 handed
- if FUNC('DH_Gear_Weapons', 'IsOneHanded', $dhEqW_Name_[$.character + 'Inv_MainHand']) = False:
- !! Check if shield or offhand equipped
- if $dhEqW_Name_[$.character + 'Inv_Offhand'] ! 'Empty': _needsFreeSlot = True
- elseif $dhEqW_Name_[$.character + 'Inv_Shield'] ! 'Empty': _needsFreeSlot = True
- end
-
- !! Unequip shield/offhand
- if _needsFreeSlot:
- FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Shield')
- end
- end
-
- !! Unequip main
- FUNC('DH_Inventory', 'Unequip', $.character, 'MainHand')
-
- else
- !! Check if 2 handed
- if FUNC('DH_Gear_Weapons', 'IsOneHanded', $dhEqW_Name_[$.character + 'Inv_MainHand']) = False:
- !! Check if shield or offhand equipped
- if $dhEqW_Name_[$.character + 'Inv_Offhand'] ! 'Empty': _needsFreeSlot = True
- elseif $dhEqW_Name_[$.character + 'Inv_Shield'] ! 'Empty': _needsFreeSlot = True
- end
-
- !! Unequip shield/offhand
- if _needsFreeSlot:
- FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Shield')
- end
- end
- end
-
- !! Unequip shield/offhand
- if _needsFreeSlot:
- FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Shield')
- end
-
- gs 'DH_Gear_Weapons', $.itemName
- $dhEqW_Name_[$.character + 'Inv_' + $.slotType] = $dhWep_Name
- $dhEqW_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhWep_DurMax)
- jump 'DH_Inventory_Equip_AddWeaponStats'
-
- elseif $.slotType = 'Offhand' :
- _offHandOnly = True
- _needsFreeSlot = False
- if $dhEqW_Name_[$.character + 'Inv_Offhand'] ! 'Empty': _needsFreeSlot = True
- elseif $dhEqA_Name_[$.character + 'Inv_Shield'] ! 'Empty': _needsFreeSlot = True
- elseif $dhEqW_Name_[$.character + 'Inv_MainHand'] ! 'Empty':
- if FUNC('DH_Gear_Weapons', 'IsOneHanded', $dhEqW_Name_[$.character + 'Inv_MainHand']) = False:
- _needsFreeSlot = True
- _offHandOnly = False
- end
- end
-
- if _needsFreeSlot:
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- if _offHandOnly:
- FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Shield')
- else
- FUNC('DH_Inventory', 'Unequip', $.character, 'MainHand')
- end
- end
-
- gs 'DH_Gear_Weapons', $.itemName
- $dhEqW_Name_[$.character + 'Inv_' + $.slotType] = $dhWep_Name
- $dhEqW_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhWep_DurMax)
- jump 'DH_Inventory_Equip_AddWeaponStats'
- end
-
- else
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InvalidSlot'], $.slotType)
- exit
- end
-
- !!~~ Add Armor stats
- :DH_Inventory_Equip_AddArmorStats
- dhCh_Health += dhArm_Health
- dhCh_Stamina += dhArm_Stamina
- dhCh_Mana += dhArm_Mana
-
- dhCh_Agi += dhArm_Agi
- dhCh_Cha += dhArm_Cha
- dhCh_Int += dhArm_Int
- dhCh_Lore += dhArm_Lore
- dhCh_Luck += dhArm_Luck
- dhCh_Per += dhArm_Per
- dhCh_Str += dhArm_Str
-
- dhCh_Defense += dhArm_Defense
-
- dhCh_ResPhys += dhArm_ResPhys
- dhCh_ResPoison += dhArm_ResPoison
- dhCh_ResFire += dhArm_ResFire
- dhCh_ResEarth += dhArm_ResEarth
- dhCh_ResMetal += dhArm_ResMetal
- dhCh_ResWater += dhArm_ResWater
- dhCh_ResWood += dhArm_ResWood
-
- dhCh_EnExp += dhArm_EnExp
- exit
- !!~~#
-
- !!~~ Add Weapon stats
- :DH_Inventory_Equip_AddWeaponStats
- dhCh_Health += dhWep_Health
- dhCh_Stamina += dhWep_Stamina
- dhCh_Mana += dhWep_Mana
-
- dhCh_Agi += dhWep_Agi
- dhCh_Cha += dhWep_Cha
- dhCh_Int += dhWep_Int
- dhCh_Lore += dhWep_Lore
- dhCh_Luck += dhWep_Luck
- dhCh_Per += dhWep_Per
- dhCh_Str += dhWep_Str
-
- dhCh_DmgMin += dhWep_DmgMin
- dhCh_DmgMax += dhWep_DmgMax
- dhCh_CritMod += dhWep_CritMod
- dhCh_CritChance += dhWep_CritChance
-
- dhCh_DmgPhys += dhWep_DmgPhys
- dhCh_DmgPoison += dhWep_DmgPoison
- dhCh_DmgFire += dhWep_DmgFire
- dhCh_DmgEarth += dhWep_DmgEarth
- dhCh_DmgMetal += dhWep_DmgMetal
- dhCh_DmgWater += dhWep_DmgWater
- dhCh_DmgWood += dhWep_DmgWood
-
- dhCh_EnExp += dhWep_EnExp
- exit
- !!~~#
- end
- if $ARGS[0] = 'Unequip':
- $.character = $ARGS[1]
- $.slotType = $ARGS[2]
-
- !! Check if inventory exists
- if ARRPOS('$dhInv_', $.character) ! -1:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['NoInventory'], $.character)
- exit
- end
-
- !! Check if there is enough space to unequip items
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character):
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
- $_GearSlot = $.character + 'Inv_' + $.slotType
-
- if $.slotType = 'All':
- FUNC('DH_Inventory', 'Unequip', $.character, 'Armor' )
- FUNC('DH_Inventory', 'Unequip', $.character, 'Weapons')
-
- elseif $.slotType = 'Armor':
- FUNC('DH_Inventory', 'Unequip', $.character, 'Head' )
- FUNC('DH_Inventory', 'Unequip', $.character, 'Chest' )
- FUNC('DH_Inventory', 'Unequip', $.character, 'Legs' )
- FUNC('DH_Inventory', 'Unequip', $.character, 'Gloves' )
- FUNC('DH_Inventory', 'Unequip', $.character, 'Feet' )
- FUNC('DH_Inventory', 'Unequip', $.character, 'ShoulderL')
- FUNC('DH_Inventory', 'Unequip', $.character, 'ShoulderR')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Cloak' )
- FUNC('DH_Inventory', 'Unequip', $.character, 'Wings' )
- FUNC('DH_Inventory', 'Unequip', $.character, 'Shield' )
-
- elseif $.slotType = 'Weapons':
- FUNC('DH_Inventory', 'Unequip', $.character, 'MainHand')
- FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand' )
-
- elseif ARRPOS($DhInv_ArmSlot_, $.slotType) ! -1:
- !! If the armor slot is already empty, don't bother re-emptying it
- if $dhEqA_Name_[$_GearSlot] = 'Empty':
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['EmptySlot'], $.character, $.slotType)
- exit
- end
- !!~~ Get Armor stats
- if $.slotType = 'Head' : gs 'DH_Gear_Heads', $dhEqA_Name_[$_GearSlot]
- elseif $.slotType = 'Suit' : gs 'DH_Gear_Suits', $dhEqA_Name_[$_GearSlot]
- elseif $.slotType = 'Chest' : gs 'DH_Gear_Chests', $dhEqA_Name_[$_GearSlot]
- elseif $.slotType = 'Legs' : gs 'DH_Gear_Legs', $dhEqA_Name_[$_GearSlot]
- elseif $.slotType = 'Gloves' : gs 'DH_Gear_Gloves', $dhEqA_Name_[$_GearSlot]
- elseif $.slotType = 'Feet' : gs 'DH_Gear_Feet', $dhEqA_Name_[$_GearSlot]
- elseif $.slotType = 'ShoulderL' : gs 'DH_Gear_Shoulders', $dhEqA_Name_[$_GearSlot]
- elseif $.slotType = 'ShoulderR' : gs 'DH_Gear_Shoulders', $dhEqA_Name_[$_GearSlot]
- elseif $.slotType = 'Cloak' : gs 'DH_Gear_Cloaks', $dhEqA_Name_[$_GearSlot]
- elseif $.slotType = 'Wings' : gs 'DH_Gear_Wings', $dhEqA_Name_[$_GearSlot]
- elseif $.slotType = 'Shield' : gs 'DH_Gear_Shields', $dhEqA_Name_[$_GearSlot]
- end
- !!~~#
-
- !!~~ Remove stats from character
- dhCh_Health -= dhArm_Health
- dhCh_Stamina -= dhArm_Stamina
- dhCh_Mana -= dhArm_Mana
-
- dhCh_Agi -= dhArm_Agi
- dhCh_Cha -= dhArm_Cha
- dhCh_Int -= dhArm_Int
- dhCh_Lore -= dhArm_Lore
- dhCh_Luck -= dhArm_Luck
- dhCh_Per -= dhArm_Per
- dhCh_Str -= dhArm_Str
-
- dhCh_Defense -= dhArm_Defense
-
- dhCh_ResPhys -= dhArm_ResPhys
- dhCh_ResPoison -= dhArm_ResPoison
- dhCh_ResFire -= dhArm_ResFire
- dhCh_ResEarth -= dhArm_ResEarth
- dhCh_ResMetal -= dhArm_ResMetal
- dhCh_ResWater -= dhArm_ResWater
- dhCh_ResWood -= dhArm_ResWood
-
- dhCh_EnExp -= dhArm_EnExp
- !!~~#
-
- !! Pass Armor to Inventory
- gs 'DH_Inventory', 'AddItem', 'Armor', $dhEqA_Name_[$_GearSlot], dhEqA_Dur_[$_GearSlot]
-
- !! Remove Armor from Armor Slot
- $dhEqA_Name_[$_GearSlot] = 'Empty'
- dhEqA_Dur_[$_GearSlot] = 0
-
- elseif ARRPOS($DhInv_WepSlot_, $.character) ! -1:
- !! If the weapon slot is already empty, don't bother re-emptying it
- if $dhEqW_Name_[_GearSlot] = 'Empty':
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['EmptySlot'], $.character, $.slotType)
- exit
- end
-
- !! Get Weapon stats
- gs 'DH_Gear_Weapons', $dhEqW_Name_[$_GearSlot]
-
- !!~~ Remove stats from character
- dhCh_Health -= dhWep_Health
- dhCh_Stamina -= dhWep_Stamina
- dhCh_Mana -= dhWep_Mana
-
- dhCh_Agi -= dhWep_Agi
- dhCh_Cha -= dhWep_Cha
- dhCh_Int -= dhWep_Int
- dhCh_Lore -= dhWep_Lore
- dhCh_Luck -= dhWep_Luck
- dhCh_Per -= dhWep_Per
- dhCh_Str -= dhWep_Str
-
- dhCh_DmgMin -= dhWep_DmgMin
- dhCh_DmgMax -= dhWep_DmgMax
- dhCh_CritMod -= dhWep_CritMod
- dhCh_CritChance -= dhWep_CritChance
-
- dhCh_DmgPhys -= dhWep_DmgPhys
- dhCh_DmgPoison -= dhWep_DmgPoison
- dhCh_DmgFire -= dhWep_DmgFire
- dhCh_DmgEarth -= dhWep_DmgEarth
- dhCh_DmgMetal -= dhWep_DmgMetal
- dhCh_DmgWater -= dhWep_DmgWater
- dhCh_DmgWood -= dhWep_DmgWood
-
- dhCh_EnExp -= dhWep_EnExp
- !!~~#
-
- !! Pass Weapon to Inventory
- gs 'DH_Inventory', 'AddItem', $dhEqW_Name_[$_GearSlot], $dhEqW_Dur_[$_GearSlot]
-
- !! Remove Weapon from Armor Slot
- $dhEqW_Name_[$_GearSlot] = 'Empty'
- dhEqW_Dur_[$_GearSlot] = 0
- end
- end
- if $ARGS[0] = 'AddItem':
- $.character = $ARGS[1]
- $.itemType = $ARGS[2]
- $.itemName = $ARGS[3]
- $.slotNo = $ARGS[4]
-
- !! Check if inventory exists
- if ARRPOS('$dhInv_', $.character) ! -1:
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['NoInventory'], $.character)
- exit
- end
-
- !! Check if there is enough space to unequip items
- if FUNC('DH_Inventory', 'HasFreeSlots', $.character):
- $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
- exit
- end
-
-
-
- end
- if $ARGS[0] = 'RemoveItem':
- if ARRPOS($dh_Inventories, $ARGS[1]) ! -1: exit & end
-
- $.character = $ARGS[1]
- $.itemType = $ARGS[2]
- $.itemName = $ARGS[3]
- $.slotNo = $ARGS[4]
-
- end
- if $ARGS[0] = 'AddMoney':
- if ARRPOS($dh_Inventories, $ARGS[1]) ! -1: exit & end
-
- end
- if $ARGS[0] = 'RemoveMoney':
- if ARRPOS($dh_Inventories, $ARGS[1]) ! -1: exit & end
-
- end
- if $ARGS[0] = 'GetFreeSlots':
- !! Returns the number of free slots in inventory
- !! If inventory does not exist, returns 0
-
- $.character = $ARGS[1]
- if ARRPOS($dhInv_, $.character) = -1:
- RESULT = 0
- jump 'AutoKill DH_Inventory_GetFreeSlots'
- end
-
- _i = 0
- _slotStart = 0
- :Loop DH_Inventory_GetFreeSlots_GetSlotStart
- if _i < _invPos:
- _slotStart += dhInv_Slots[$dhInv_[_invPos] + 'Inv']
- _i += 1
- jump 'Loop DH_Inventory_GetFreeSlots_GetSlotStart'
- end
-
- _i = 0
- _freeSlots = 0
- :Loop DH_Inventory_GetFreeSlots
- if _i < dhInv_Slots[$.character + 'Inv_']:
- if dhInv_Slot[_slotStart + _i] = 'Empty': _freeSlots += 1 & end
- jump 'Loop DH_Inventory_GetFreeSlots'
- end
-
- RESULT = _freeSlots
-
- end
- if $ARGS[0] = 'HasFreeSlots':
- !!$ARGS[1] = character
- !! ARGS[2] = free slots to check for
- RESULT = iif(FUNC('DH_Inventory', 'GetFreeSlots', $ARGS[1]) >= MAX(1, ARGS[2]), True, False)
- end
- !! TODO: Each inventory should have a currency associated with it
- !! Perhaps a special currency as well
- --- DH_Inventory ---------------------------------
|