Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;This event handles auto-adding newly equipped items to the left, right and shout slots
- Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
- debug.trace("iEquip_PlayerEventHandler OnObjectEquipped called")
- if WC.bAutoAddNewItems
- int equippedSlot = -1
- if PlayerRef.GetEquippedObject(0) == akBaseObject
- equippedSlot = 0
- elseIf PlayerRef.GetEquippedObject(1) == akBaseObject
- equippedSlot = 1
- elseIf PlayerRef.GetEquippedObject(2) == akBaseObject
- equippedSlot = 2
- endIf
- ;If the item has been equipped in the left, right or shout slot
- if equippedSlot != -1
- bool blockCall = false
- bool formFound = iEquip_AllCurrentItemsFLST.HasForm(akBaseObject)
- string itemName = akBaseObject.GetName()
- ;Check if we've just manually equipped an item that is already in this iEquip queue
- int targetIndex = -1
- if formFound
- ;If it's been found in the queue for the equippedSlot it's been equipped to
- targetIndex = WC.findInQueue(equippedSlot, itemName)
- if targetIndex != -1
- ;If it's already shown in the widget do nothing
- if WC.aiCurrentQueuePosition[equippedSlot] == targetIndex
- blockCall = true
- ;Otherwise update the position and name, then update the widget
- else
- WC.aiCurrentQueuePosition[equippedSlot] = targetIndex
- WC.asCurrentlyEquipped[equippedSlot] = itemName
- if equippedSlot < 2 || WC.bShoutEnabled
- WC.updateWidget(equippedSlot, targetIndex, false, true)
- endIf
- endIf
- endIf
- endIf
- ;If it isn't already contained in the AllCurrentItems formlist, or it is but findInQueue has returned -1 meaning it's a 1H item contained in the other hand queue
- if !formFound || targetIndex == -1
- ;First check if the target Q has space or can grow organically - ie bHardLimitQueueSize is disabled
- bool freeSpace = true
- targetIndex = jArray.count(WC.aiTargetQ[equippedSlot])
- if targetIndex >= WC.iMaxQueueLength
- if WC.bHardLimitQueueSize
- freeSpace = false
- blockCall = true
- else
- WC.iMaxQueueLength += 1
- endIf
- endIf
- if freeSpace
- ;If there is space in the target queue create a new jMap object and add it to the queue
- debug.trace("iEquip_PlayerEventHandler OnObjectEquipped - akBaseObject: " + akBaseObject + " - " + itemName + ", equippedSlot: " + equippedSlot)
- int itemID = WC.createItemID(itemName, akBaseObject.GetFormID())
- int itemType = akBaseObject.GetType()
- if itemType == 41 ;if it is a weapon get the weapon type
- itemType = (akBaseObject as Weapon).GetWeaponType()
- endIf
- int iEquipItem = jMap.object()
- jMap.setForm(iEquipItem, "Form", akBaseObject)
- jMap.setInt(iEquipItem, "ID", itemID)
- jMap.setInt(iEquipItem, "Type", itemType)
- jMap.setStr(iEquipItem, "Name", itemName)
- jMap.setStr(iEquipItem, "Icon", WC.GetItemIconName(akBaseObject, itemType, itemName))
- if equippedSlot < 2
- jMap.setInt(iEquipItem, "isEnchanted", 0)
- jMap.setInt(iEquipItem, "isPoisoned", 0)
- endIf
- jArray.addObj(WC.aiTargetQ[equippedSlot], iEquipItem)
- ;If it's not already in the AllItems formlist because it's in the other hand queue add it now
- if !formFound
- iEquip_AllCurrentItemsFLST.AddForm(akBaseObject)
- endIf
- ;Send to moreHUD if loaded
- if WC.bMoreHUDLoaded
- if formFound
- AhzMoreHudIE.AddIconItem(itemID, WC.asMoreHUDIcons[3]) ;Both queues
- else
- AhzMoreHudIE.AddIconItem(itemID, WC.asMoreHUDIcons[equippedSlot])
- endIf
- endIf
- ;Now update the widget to show the equipped item
- WC.aiCurrentQueuePosition[equippedSlot] = targetIndex
- WC.asCurrentlyEquipped[equippedSlot] = itemName
- if equippedSlot < 2 || WC.bShoutEnabled
- WC.updateWidget(equippedSlot, targetIndex, false, true)
- endIf
- endIf
- endIf
- ;And run the rest of the hand equip cycle without actually equipping to toggle ammo mode if needed and update count, poison and charge info
- if !blockCall && equippedSlot < 2
- WC.checkAndEquipShownHandItem(equippedSlot, false, true)
- endIf
- endIf
- endIf
- endEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement