DH_Inventory.qsrc 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. # DH_Inventory
  2. !! Format for variables is Variable[CharacterInv_ItemType]
  3. !!~~ Checks
  4. !!~~ Check if inventory exists
  5. !!if $.character = '' or ARRPOS($dhInv_, $.character) = -1:
  6. !! $RESULT = $DhInv_Msg_['InventoryFull']
  7. !! jump 'AutoKill '
  8. !!end
  9. !!~~#
  10. !!~~#
  11. if $ARGS[0] = 'Init':
  12. !!~~ Gear Slots
  13. $DhInv_ArmSlot_[0] = 'Head'
  14. $DhInv_ArmSlot_[1] = 'Suit'
  15. $DhInv_ArmSlot_[2] = 'Chest'
  16. $DhInv_ArmSlot_[3] = 'Legs'
  17. $DhInv_ArmSlot_[4] = 'Gloves'
  18. $DhInv_ArmSlot_[5] = 'Feet'
  19. $DhInv_ArmSlot_[6] = 'ShoulderL'
  20. $DhInv_ArmSlot_[7] = 'ShoulderR'
  21. $DhInv_ArmSlot_[8] = 'Cloak'
  22. $DhInv_ArmSlot_[9] = 'Wings'
  23. $DhInv_ArmSlot_[10] = 'Shield'
  24. $DhInv_WepSlot_[0] = 'MainHand'
  25. $DhInv_WepSlot_[1] = 'Offhand'
  26. $DhInv_AccSlot_[0] = 'RingL'
  27. $DhInv_AccSlot_[1] = 'RingR'
  28. $DhInv_AccSlot_[2] = 'Necklace'
  29. $DhInv_AccSlot_[3] = 'Earrings'
  30. !!~~#
  31. !!~~ Item Grades
  32. $DhInv_Grade_[0] = 'Junk' &! Grey
  33. $DhInv_Grade_[1] = 'Common' &! White/Black (depends on bg)
  34. $DhInv_Grade_[2] = 'Uncommon' &! Green
  35. $DhInv_Grade_[3] = 'Rare' &! Blue
  36. $DhInv_Grade_[4] = 'Epic' &! Purple
  37. $DhInv_Grade_[5] = 'Legendary' &! Orange
  38. $DhInv_Grade_[6] = 'Godlike' &! Red
  39. $DhInv_Grade_[7] = 'Cheat' &! Pink
  40. !!~~#
  41. !!~~ Messages
  42. $DhInv_Msg_['Error'] = 'Something went wrong. Contact WinkyFace on <a href="tfgamessite.com">tfgamessite.com</a>'
  43. $DhInv_Msg_['ReqsNotMet'] = 'You do not meet the requirements to equip this item.'
  44. $DhInv_Msg_['InventoryFull'] = 'There are too many items in ''{0}''''s Inventory!'
  45. $DhInv_Msg_['NoInventory'] = 'No Inventory exists for the character ''{0}''!'
  46. $DhInv_Msg_['InventoryExists'] = 'An Inventory for the character ''{0}'' already exists!'
  47. $DhInv_Msg_['InvalidSlot'] = 'No Equipment Slot by the name of ''{0}'' exists!'
  48. !!~~#
  49. DhInv_DefSlots = 8 &!The default number of slots for any Inventory
  50. end
  51. if $ARGS[0] = 'NewInventory':
  52. $.character = $ARGS[1]
  53. .slots = iif(ARGS[2] > 0, ARGS[2], DhInv_DefSlots)
  54. !! Check if inventory exists
  55. if ARRPOS($dhInv_, $.character) ! -1:
  56. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryExists'], $.character)
  57. exit
  58. end
  59. !! Create the inventory
  60. $dhInv_[] = $.character
  61. dhInv_Slots[$.character + 'Inv'] = .slots
  62. _i = 0
  63. :Loop DH_Inventory_NewInventory_GenerateSlots
  64. if _i < dhInv_Slots[$.character + 'Inv']
  65. $dhInv_Slot[$.character + 'Inv_Slot' + _i] = 'Empty'
  66. _i += 1
  67. jump 'Loop DH_Inventory_NewInventory_GenerateSlots'
  68. end
  69. gs 'DH_Inventory', 'Unequip', $.character, 'All'
  70. gs 'DH_Inventory', 'RemoveItem', $.character, 'All'
  71. end
  72. if $ARGS[0] = 'DeleteInventory':
  73. !! Check if inventory exists
  74. if ARRPOS($dhInv_, $.character) = -1:
  75. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['NoInventory'], $.character)
  76. exit
  77. end
  78. $.character = $ARGS[1]
  79. _invPos = ARRPOS('$dhInv_', $.character)
  80. !!~~ Kill Slots
  81. _i = 0
  82. _slotStart = 0
  83. :Loop DH_Inventory_DeleteInventory_GetSlotStart
  84. if _i < _invPos:
  85. _slotStart += dhInv_Slots[$dhInv_[_invPos] + 'Inv']
  86. _i += 1
  87. jump 'Loop DH_Inventory_DeleteInventory_GetSlotStart'
  88. end
  89. _i = 0
  90. :Loop DH_Inventory_DeleteInventory_KillSlots
  91. if _i < dhInv_Slots[$.character + 'Inv']
  92. KILLVAR '$dhInv_Slot', (_slotStart + _i)
  93. _i += 1
  94. jump 'Loop DH_Inventory_DeleteInventory_KillSlots'
  95. end
  96. KILLVAR 'dhInv_Slots', _invPos
  97. !!~~#
  98. _ArmorSlots = _invPos * ARRSIZE('$DhInv_ArmSlot_')
  99. _WeaponSlots = _invPos * ARRSIZE('$DhInv_WepSlot_')
  100. !!~~ Kill Equip Slots
  101. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots)
  102. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 1
  103. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 2
  104. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 3
  105. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 4
  106. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 5
  107. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 6
  108. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 7
  109. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 8
  110. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 9
  111. KILLVAR 'dhEqA_Name_', (_invPos * _ArmorSlots) + 10
  112. KILLVAR 'dhEqW_Name_', (_invPos * _WeaponSlots)
  113. KILLVAR 'dhEqW_Name_', (_invPos * _WeaponSlots) + 1
  114. !!~~#
  115. !!~~ Kill Durability
  116. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots)
  117. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 1
  118. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 2
  119. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 3
  120. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 4
  121. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 5
  122. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 6
  123. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 7
  124. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 8
  125. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 9
  126. KILLVAR 'dhEqA_Dur_', (_invPos * _ArmorSlots) + 10
  127. KILLVAR 'dhEqW_Dur_', (_invPos * _WeaponSlots)
  128. KILLVAR 'dhEqW_Dur_', (_invPos * _WeaponSlots) + 1
  129. !!~~#
  130. !! Kill Inventory
  131. KILLVAR 'dhInv_', _invPos
  132. end
  133. if $ARGS[0] = 'Equip':
  134. $.character = $ARGS[1]
  135. $.slotType = $ARGS[2]
  136. $.itemName = $ARGS[3]
  137. $.durability = $ARGS[4]
  138. !! Check if inventory exists
  139. if ARRPOS($dhInv_, $.character) = -1:
  140. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['NoInventory'], $.character)
  141. exit
  142. end
  143. $_GearSlot = $.character + 'Inv_' + $.slotType
  144. if ARRPOS('$DhInv_ArmSlot_', $.slotType) ! -1:
  145. if $.slotType = 'Head' :
  146. !! Do I need a free slot?
  147. if $dhEqA_Name_[$.character + 'Inv_Head'] ! 'Empty':
  148. !! Do I have a free slot?
  149. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  150. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  151. exit
  152. end
  153. !! Free slot so unequip!
  154. FUNC('DH_Inventory', 'Unequip', $.character, 'Head')
  155. end
  156. !! Equip!
  157. gs 'DH_Gear_Heads', $.itemName
  158. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  159. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  160. jump 'DH_Inventory_Equip_AddArmorStats'
  161. elseif $.slotType = 'Suit' :
  162. _slotsToFree = 0
  163. if $dhEqA_Name_[$.character + 'Inv_Suit'] ! 'Empty': _slotsToFree = 1
  164. else
  165. if $dhEqA_Name_[$.character + 'Inv_Chest'] ! 'Empty': _slotsToFree += 1 & end
  166. if $dhEqA_Name_[$.character + 'Inv_Legs'] ! 'Empty': _slotsToFree += 1 & end
  167. end
  168. !! If 0 slotsToFree, nothing is equipped
  169. if _slotsToFree > 0:
  170. if FUNC('DH_Inventory', 'HasFreeSlots', $.character, _slotsToFree) = False:
  171. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  172. exit
  173. end
  174. FUNC('DH_Inventory', 'Unequip', $.character, 'Suit')
  175. FUNC('DH_Inventory', 'Unequip', $.character, 'Chest')
  176. FUNC('DH_Inventory', 'Unequip', $.character, 'Legs')
  177. end
  178. gs 'DH_Gear_Suits', $.itemName
  179. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  180. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  181. jump 'DH_Inventory_Equip_AddArmorStats'
  182. elseif $.slotType = 'Chest' :
  183. !! Do I need a free slot?
  184. if $dhEqA_Name_[$.character + 'Inv_Chest'] ! 'Empty' or $dhEqA_Name_[$.character + 'Inv_Suit'] ! 'Empty':
  185. !! Do I have a free slot?
  186. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  187. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  188. exit
  189. end
  190. !! Free slot so unequip!
  191. FUNC('DH_Inventory', 'Unequip', $.character, 'Suit')
  192. FUNC('DH_Inventory', 'Unequip', $.character, 'Chest')
  193. end
  194. !! Equip!
  195. gs 'DH_Gear_Chests', $.itemName
  196. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  197. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  198. jump 'DH_Inventory_Equip_AddArmorStats'
  199. elseif $.slotType = 'Legs' :
  200. !! Do I need a free slot?
  201. if $dhEqA_Name_[$.character + 'Inv_Legs'] ! 'Empty' or $dhEqA_Name_[$.character + 'Inv_Suit'] ! 'Empty':
  202. !! Do I have a free slot?
  203. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  204. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  205. exit
  206. end
  207. !! Free slot so unequip!
  208. FUNC('DH_Inventory', 'Unequip', $.character, 'Suit')
  209. FUNC('DH_Inventory', 'Unequip', $.character, 'Legs')
  210. end
  211. !! Equip!
  212. gs 'DH_Gear_Legs', $.itemName
  213. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  214. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  215. jump 'DH_Inventory_Equip_AddArmorStats'
  216. elseif $.slotType = 'Gloves' :
  217. !! Do I need a free slot?
  218. if $dhEqA_Name_[$.character + 'Inv_Gloves'] ! 'Empty':
  219. !! Do I have a free slot?
  220. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  221. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  222. exit
  223. end
  224. !! Free slot so unequip!
  225. FUNC('DH_Inventory', 'Unequip', $.character, 'Gloves')
  226. end
  227. !! Equip!
  228. gs 'DH_Gear_Gloves', $.itemName
  229. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  230. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  231. jump 'DH_Inventory_Equip_AddArmorStats'
  232. elseif $.slotType = 'Feet' :
  233. !! Do I need a free slot?
  234. if $dhEqA_Name_[$.character + 'Inv_Feet'] ! 'Empty':
  235. !! Do I have a free slot?
  236. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  237. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  238. exit
  239. end
  240. !! Free slot so unequip!
  241. FUNC('DH_Inventory', 'Unequip', $.character, 'Feet')
  242. end
  243. !! Equip!
  244. gs 'DH_Gear_Feet', $.itemName
  245. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  246. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  247. jump 'DH_Inventory_Equip_AddArmorStats'
  248. elseif $.slotType = 'ShoulderL' :
  249. !! Do I need a free slot?
  250. if $dhEqA_Name_[$.character + 'Inv_ShoulderL'] ! 'Empty':
  251. !! Do I have a free slot?
  252. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  253. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  254. exit
  255. end
  256. !! Free slot so unequip!
  257. FUNC('DH_Inventory', 'Unequip', $.character, 'ShoulderL')
  258. end
  259. !! Equip!
  260. gs 'DH_Gear_Shoulders', $.itemName
  261. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  262. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  263. jump 'DH_Inventory_Equip_AddArmorStats'
  264. elseif $.slotType = 'ShoulderR' :
  265. !! Do I need a free slot?
  266. if $dhEqA_Name_[$.character + 'Inv_ShoulderR'] ! 'Empty':
  267. !! Do I have a free slot?
  268. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  269. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  270. exit
  271. end
  272. !! Free slot so unequip!
  273. FUNC('DH_Inventory', 'Unequip', $.character, 'ShoulderR')
  274. end
  275. !! Equip!
  276. gs 'DH_Gear_Shoulders', $.itemName
  277. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  278. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  279. jump 'DH_Inventory_Equip_AddArmorStats'
  280. elseif $.slotType = 'Cloak' :
  281. !! Do I need a free slot?
  282. if $dhEqA_Name_[$.character + 'Inv_Cloak'] ! 'Empty' or $dhEqA_Name_[$.character + 'Inv_Wings'] ! 'Empty':
  283. !! Do I have a free slot?
  284. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  285. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  286. exit
  287. end
  288. !! Free slot so unequip!
  289. FUNC('DH_Inventory', 'Unequip', $.character, 'Cloak')
  290. FUNC('DH_Inventory', 'Unequip', $.character, 'Wings')
  291. end
  292. !! Equip!
  293. gs 'DH_Gear_Cloaks', $.itemName
  294. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  295. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  296. jump 'DH_Inventory_Equip_AddArmorStats'
  297. elseif $.slotType = 'Wings' :
  298. !! Do I need a free slot?
  299. if $dhEqA_Name_[$.character + 'Inv_Wings'] ! 'Empty' or $dhEqA_Name_[$.character + 'Inv_Cloak'] ! 'Empty':
  300. !! Do I have a free slot?
  301. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  302. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  303. exit
  304. end
  305. !! Free slot so unequip!
  306. FUNC('DH_Inventory', 'Unequip', $.character, 'Wings')
  307. FUNC('DH_Inventory', 'Unequip', $.character, 'Cloak')
  308. end
  309. !! Equip!
  310. gs 'DH_Gear_Wings', $.itemName
  311. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  312. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  313. jump 'DH_Inventory_Equip_AddArmorStats'
  314. elseif $.slotType = 'Shield' :
  315. _offHandOnly = True
  316. _needsFreeSlot = False
  317. if $dhEqA_Name_[$.character + 'Inv_Shield'] ! 'Empty': _needsFreeSlot = True
  318. elseif $dhEqW_Name_[$.character + 'Inv_Offhand'] ! 'Empty': _needsFreeSlot = True
  319. elseif $dhEqW_Name_[$.character + 'Inv_MainHand'] ! 'Empty':
  320. if FUNC('DH_Gear_Weapons', 'IsOneHanded', $dhEqW_Name_[$.character + 'Inv_MainHand']) = False:
  321. _needsFreeSlot = True
  322. _offHandOnly = False
  323. end
  324. end
  325. if _needsFreeSlot:
  326. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  327. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  328. exit
  329. end
  330. if _offHandOnly:
  331. FUNC('DH_Inventory', 'Unequip', $.character, 'Shield')
  332. FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand')
  333. else
  334. FUNC('DH_Inventory', 'Unequip', $.character, 'MainHand')
  335. end
  336. end
  337. gs 'DH_Gear_Shields', $.itemName
  338. $dhEqA_Name_[$.character + 'Inv_' + $.slotType] = $dhArm_Name
  339. $dhEqA_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhArm_DurMax)
  340. jump 'DH_Inventory_Equip_AddArmorStats'
  341. end
  342. elseif ARRPOS('$DhInv_WepSlot_', $.slotType) ! -1:
  343. if $.slotType = 'MainHand' :
  344. !! Check if main equipped
  345. if $dhEqW_Name_[$.character + 'Inv_MainHand'] ! 'Empty':
  346. !! Check if 2 handed
  347. if FUNC('DH_Gear_Weapons', 'IsOneHanded', $dhEqW_Name_[$.character + 'Inv_MainHand']) = False:
  348. !! Check if shield or offhand equipped
  349. if $dhEqW_Name_[$.character + 'Inv_Offhand'] ! 'Empty': _needsFreeSlot = True
  350. elseif $dhEqW_Name_[$.character + 'Inv_Shield'] ! 'Empty': _needsFreeSlot = True
  351. end
  352. !! Unequip shield/offhand
  353. if _needsFreeSlot:
  354. FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand')
  355. FUNC('DH_Inventory', 'Unequip', $.character, 'Shield')
  356. end
  357. end
  358. !! Unequip main
  359. FUNC('DH_Inventory', 'Unequip', $.character, 'MainHand')
  360. else
  361. !! Check if 2 handed
  362. if FUNC('DH_Gear_Weapons', 'IsOneHanded', $dhEqW_Name_[$.character + 'Inv_MainHand']) = False:
  363. !! Check if shield or offhand equipped
  364. if $dhEqW_Name_[$.character + 'Inv_Offhand'] ! 'Empty': _needsFreeSlot = True
  365. elseif $dhEqW_Name_[$.character + 'Inv_Shield'] ! 'Empty': _needsFreeSlot = True
  366. end
  367. !! Unequip shield/offhand
  368. if _needsFreeSlot:
  369. FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand')
  370. FUNC('DH_Inventory', 'Unequip', $.character, 'Shield')
  371. end
  372. end
  373. end
  374. !! Unequip shield/offhand
  375. if _needsFreeSlot:
  376. FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand')
  377. FUNC('DH_Inventory', 'Unequip', $.character, 'Shield')
  378. end
  379. gs 'DH_Gear_Weapons', $.itemName
  380. $dhEqW_Name_[$.character + 'Inv_' + $.slotType] = $dhWep_Name
  381. $dhEqW_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhWep_DurMax)
  382. jump 'DH_Inventory_Equip_AddWeaponStats'
  383. elseif $.slotType = 'Offhand' :
  384. _offHandOnly = True
  385. _needsFreeSlot = False
  386. if $dhEqW_Name_[$.character + 'Inv_Offhand'] ! 'Empty': _needsFreeSlot = True
  387. elseif $dhEqA_Name_[$.character + 'Inv_Shield'] ! 'Empty': _needsFreeSlot = True
  388. elseif $dhEqW_Name_[$.character + 'Inv_MainHand'] ! 'Empty':
  389. if FUNC('DH_Gear_Weapons', 'IsOneHanded', $dhEqW_Name_[$.character + 'Inv_MainHand']) = False:
  390. _needsFreeSlot = True
  391. _offHandOnly = False
  392. end
  393. end
  394. if _needsFreeSlot:
  395. if FUNC('DH_Inventory', 'HasFreeSlots', $.character) = False:
  396. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  397. exit
  398. end
  399. if _offHandOnly:
  400. FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand')
  401. FUNC('DH_Inventory', 'Unequip', $.character, 'Shield')
  402. else
  403. FUNC('DH_Inventory', 'Unequip', $.character, 'MainHand')
  404. end
  405. end
  406. gs 'DH_Gear_Weapons', $.itemName
  407. $dhEqW_Name_[$.character + 'Inv_' + $.slotType] = $dhWep_Name
  408. $dhEqW_Dur_[$.character + 'Inv_' + $.slotType] = iif($.durability > 0, $.durability, $dhWep_DurMax)
  409. jump 'DH_Inventory_Equip_AddWeaponStats'
  410. end
  411. else
  412. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InvalidSlot'], $.slotType)
  413. exit
  414. end
  415. !!~~ Add Armor stats
  416. :DH_Inventory_Equip_AddArmorStats
  417. dhCh_Health += dhArm_Health
  418. dhCh_Stamina += dhArm_Stamina
  419. dhCh_Mana += dhArm_Mana
  420. dhCh_Agi += dhArm_Agi
  421. dhCh_Cha += dhArm_Cha
  422. dhCh_Int += dhArm_Int
  423. dhCh_Lore += dhArm_Lore
  424. dhCh_Luck += dhArm_Luck
  425. dhCh_Per += dhArm_Per
  426. dhCh_Str += dhArm_Str
  427. dhCh_Defense += dhArm_Defense
  428. dhCh_ResPhys += dhArm_ResPhys
  429. dhCh_ResPoison += dhArm_ResPoison
  430. dhCh_ResFire += dhArm_ResFire
  431. dhCh_ResEarth += dhArm_ResEarth
  432. dhCh_ResMetal += dhArm_ResMetal
  433. dhCh_ResWater += dhArm_ResWater
  434. dhCh_ResWood += dhArm_ResWood
  435. dhCh_EnExp += dhArm_EnExp
  436. exit
  437. !!~~#
  438. !!~~ Add Weapon stats
  439. :DH_Inventory_Equip_AddWeaponStats
  440. dhCh_Health += dhWep_Health
  441. dhCh_Stamina += dhWep_Stamina
  442. dhCh_Mana += dhWep_Mana
  443. dhCh_Agi += dhWep_Agi
  444. dhCh_Cha += dhWep_Cha
  445. dhCh_Int += dhWep_Int
  446. dhCh_Lore += dhWep_Lore
  447. dhCh_Luck += dhWep_Luck
  448. dhCh_Per += dhWep_Per
  449. dhCh_Str += dhWep_Str
  450. dhCh_DmgMin += dhWep_DmgMin
  451. dhCh_DmgMax += dhWep_DmgMax
  452. dhCh_CritMod += dhWep_CritMod
  453. dhCh_CritChance += dhWep_CritChance
  454. dhCh_DmgPhys += dhWep_DmgPhys
  455. dhCh_DmgPoison += dhWep_DmgPoison
  456. dhCh_DmgFire += dhWep_DmgFire
  457. dhCh_DmgEarth += dhWep_DmgEarth
  458. dhCh_DmgMetal += dhWep_DmgMetal
  459. dhCh_DmgWater += dhWep_DmgWater
  460. dhCh_DmgWood += dhWep_DmgWood
  461. dhCh_EnExp += dhWep_EnExp
  462. exit
  463. !!~~#
  464. end
  465. if $ARGS[0] = 'Unequip':
  466. $.character = $ARGS[1]
  467. $.slotType = $ARGS[2]
  468. !! Check if inventory exists
  469. if ARRPOS('$dhInv_', $.character) ! -1:
  470. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['NoInventory'], $.character)
  471. exit
  472. end
  473. !! Check if there is enough space to unequip items
  474. if FUNC('DH_Inventory', 'HasFreeSlots', $.character):
  475. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  476. exit
  477. end
  478. $_GearSlot = $.character + 'Inv_' + $.slotType
  479. if $.slotType = 'All':
  480. FUNC('DH_Inventory', 'Unequip', $.character, 'Armor' )
  481. FUNC('DH_Inventory', 'Unequip', $.character, 'Weapons')
  482. elseif $.slotType = 'Armor':
  483. FUNC('DH_Inventory', 'Unequip', $.character, 'Head' )
  484. FUNC('DH_Inventory', 'Unequip', $.character, 'Chest' )
  485. FUNC('DH_Inventory', 'Unequip', $.character, 'Legs' )
  486. FUNC('DH_Inventory', 'Unequip', $.character, 'Gloves' )
  487. FUNC('DH_Inventory', 'Unequip', $.character, 'Feet' )
  488. FUNC('DH_Inventory', 'Unequip', $.character, 'ShoulderL')
  489. FUNC('DH_Inventory', 'Unequip', $.character, 'ShoulderR')
  490. FUNC('DH_Inventory', 'Unequip', $.character, 'Cloak' )
  491. FUNC('DH_Inventory', 'Unequip', $.character, 'Wings' )
  492. FUNC('DH_Inventory', 'Unequip', $.character, 'Shield' )
  493. elseif $.slotType = 'Weapons':
  494. FUNC('DH_Inventory', 'Unequip', $.character, 'MainHand')
  495. FUNC('DH_Inventory', 'Unequip', $.character, 'Offhand' )
  496. elseif ARRPOS($DhInv_ArmSlot_, $.slotType) ! -1:
  497. !! If the armor slot is already empty, don't bother re-emptying it
  498. if $dhEqA_Name_[$_GearSlot] = 'Empty':
  499. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['EmptySlot'], $.character, $.slotType)
  500. exit
  501. end
  502. !!~~ Get Armor stats
  503. if $.slotType = 'Head' : gs 'DH_Gear_Heads', $dhEqA_Name_[$_GearSlot]
  504. elseif $.slotType = 'Suit' : gs 'DH_Gear_Suits', $dhEqA_Name_[$_GearSlot]
  505. elseif $.slotType = 'Chest' : gs 'DH_Gear_Chests', $dhEqA_Name_[$_GearSlot]
  506. elseif $.slotType = 'Legs' : gs 'DH_Gear_Legs', $dhEqA_Name_[$_GearSlot]
  507. elseif $.slotType = 'Gloves' : gs 'DH_Gear_Gloves', $dhEqA_Name_[$_GearSlot]
  508. elseif $.slotType = 'Feet' : gs 'DH_Gear_Feet', $dhEqA_Name_[$_GearSlot]
  509. elseif $.slotType = 'ShoulderL' : gs 'DH_Gear_Shoulders', $dhEqA_Name_[$_GearSlot]
  510. elseif $.slotType = 'ShoulderR' : gs 'DH_Gear_Shoulders', $dhEqA_Name_[$_GearSlot]
  511. elseif $.slotType = 'Cloak' : gs 'DH_Gear_Cloaks', $dhEqA_Name_[$_GearSlot]
  512. elseif $.slotType = 'Wings' : gs 'DH_Gear_Wings', $dhEqA_Name_[$_GearSlot]
  513. elseif $.slotType = 'Shield' : gs 'DH_Gear_Shields', $dhEqA_Name_[$_GearSlot]
  514. end
  515. !!~~#
  516. !!~~ Remove stats from character
  517. dhCh_Health -= dhArm_Health
  518. dhCh_Stamina -= dhArm_Stamina
  519. dhCh_Mana -= dhArm_Mana
  520. dhCh_Agi -= dhArm_Agi
  521. dhCh_Cha -= dhArm_Cha
  522. dhCh_Int -= dhArm_Int
  523. dhCh_Lore -= dhArm_Lore
  524. dhCh_Luck -= dhArm_Luck
  525. dhCh_Per -= dhArm_Per
  526. dhCh_Str -= dhArm_Str
  527. dhCh_Defense -= dhArm_Defense
  528. dhCh_ResPhys -= dhArm_ResPhys
  529. dhCh_ResPoison -= dhArm_ResPoison
  530. dhCh_ResFire -= dhArm_ResFire
  531. dhCh_ResEarth -= dhArm_ResEarth
  532. dhCh_ResMetal -= dhArm_ResMetal
  533. dhCh_ResWater -= dhArm_ResWater
  534. dhCh_ResWood -= dhArm_ResWood
  535. dhCh_EnExp -= dhArm_EnExp
  536. !!~~#
  537. !! Pass Armor to Inventory
  538. gs 'DH_Inventory', 'AddItem', 'Armor', $dhEqA_Name_[$_GearSlot], dhEqA_Dur_[$_GearSlot]
  539. !! Remove Armor from Armor Slot
  540. $dhEqA_Name_[$_GearSlot] = 'Empty'
  541. dhEqA_Dur_[$_GearSlot] = 0
  542. elseif ARRPOS($DhInv_WepSlot_, $.character) ! -1:
  543. !! If the weapon slot is already empty, don't bother re-emptying it
  544. if $dhEqW_Name_[_GearSlot] = 'Empty':
  545. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['EmptySlot'], $.character, $.slotType)
  546. exit
  547. end
  548. !! Get Weapon stats
  549. gs 'DH_Gear_Weapons', $dhEqW_Name_[$_GearSlot]
  550. !!~~ Remove stats from character
  551. dhCh_Health -= dhWep_Health
  552. dhCh_Stamina -= dhWep_Stamina
  553. dhCh_Mana -= dhWep_Mana
  554. dhCh_Agi -= dhWep_Agi
  555. dhCh_Cha -= dhWep_Cha
  556. dhCh_Int -= dhWep_Int
  557. dhCh_Lore -= dhWep_Lore
  558. dhCh_Luck -= dhWep_Luck
  559. dhCh_Per -= dhWep_Per
  560. dhCh_Str -= dhWep_Str
  561. dhCh_DmgMin -= dhWep_DmgMin
  562. dhCh_DmgMax -= dhWep_DmgMax
  563. dhCh_CritMod -= dhWep_CritMod
  564. dhCh_CritChance -= dhWep_CritChance
  565. dhCh_DmgPhys -= dhWep_DmgPhys
  566. dhCh_DmgPoison -= dhWep_DmgPoison
  567. dhCh_DmgFire -= dhWep_DmgFire
  568. dhCh_DmgEarth -= dhWep_DmgEarth
  569. dhCh_DmgMetal -= dhWep_DmgMetal
  570. dhCh_DmgWater -= dhWep_DmgWater
  571. dhCh_DmgWood -= dhWep_DmgWood
  572. dhCh_EnExp -= dhWep_EnExp
  573. !!~~#
  574. !! Pass Weapon to Inventory
  575. gs 'DH_Inventory', 'AddItem', $dhEqW_Name_[$_GearSlot], $dhEqW_Dur_[$_GearSlot]
  576. !! Remove Weapon from Armor Slot
  577. $dhEqW_Name_[$_GearSlot] = 'Empty'
  578. dhEqW_Dur_[$_GearSlot] = 0
  579. end
  580. end
  581. if $ARGS[0] = 'AddItem':
  582. $.character = $ARGS[1]
  583. $.itemType = $ARGS[2]
  584. $.itemName = $ARGS[3]
  585. $.slotNo = $ARGS[4]
  586. !! Check if inventory exists
  587. if ARRPOS('$dhInv_', $.character) ! -1:
  588. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['NoInventory'], $.character)
  589. exit
  590. end
  591. !! Check if there is enough space to unequip items
  592. if FUNC('DH_Inventory', 'HasFreeSlots', $.character):
  593. $RESULT = FUNC('DH_Functions', 'FormatStr', $DhInv_Msg_['InventoryFull'], $.character)
  594. exit
  595. end
  596. end
  597. if $ARGS[0] = 'RemoveItem':
  598. if ARRPOS($dh_Inventories, $ARGS[1]) ! -1: exit & end
  599. $.character = $ARGS[1]
  600. $.itemType = $ARGS[2]
  601. $.itemName = $ARGS[3]
  602. $.slotNo = $ARGS[4]
  603. end
  604. if $ARGS[0] = 'AddMoney':
  605. if ARRPOS($dh_Inventories, $ARGS[1]) ! -1: exit & end
  606. end
  607. if $ARGS[0] = 'RemoveMoney':
  608. if ARRPOS($dh_Inventories, $ARGS[1]) ! -1: exit & end
  609. end
  610. if $ARGS[0] = 'GetFreeSlots':
  611. !! Returns the number of free slots in inventory
  612. !! If inventory does not exist, returns 0
  613. $.character = $ARGS[1]
  614. if ARRPOS($dhInv_, $.character) = -1:
  615. RESULT = 0
  616. jump 'AutoKill DH_Inventory_GetFreeSlots'
  617. end
  618. _i = 0
  619. _slotStart = 0
  620. :Loop DH_Inventory_GetFreeSlots_GetSlotStart
  621. if _i < _invPos:
  622. _slotStart += dhInv_Slots[$dhInv_[_invPos] + 'Inv']
  623. _i += 1
  624. jump 'Loop DH_Inventory_GetFreeSlots_GetSlotStart'
  625. end
  626. _i = 0
  627. _freeSlots = 0
  628. :Loop DH_Inventory_GetFreeSlots
  629. if _i < dhInv_Slots[$.character + 'Inv_']:
  630. if dhInv_Slot[_slotStart + _i] = 'Empty': _freeSlots += 1 & end
  631. jump 'Loop DH_Inventory_GetFreeSlots'
  632. end
  633. RESULT = _freeSlots
  634. end
  635. if $ARGS[0] = 'HasFreeSlots':
  636. !!$ARGS[1] = character
  637. !! ARGS[2] = free slots to check for
  638. RESULT = iif(FUNC('DH_Inventory', 'GetFreeSlots', $ARGS[1]) >= MAX(1, ARGS[2]), True, False)
  639. end
  640. !! TODO: Each inventory should have a currency associated with it
  641. !! Perhaps a special currency as well
  642. --- DH_Inventory ---------------------------------