;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname aaaa_GetActor_Perk Extends Perk Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akTargetRef, Actor akActor)
;BEGIN CODE
; 	debug.Notification("Fragment_0")


;****************
bool bDebug = False
;****************


if bBusy
	debug.Notification("busy")
	return
endif
bBusy = True


int index = 0
int max = MCM.SetSlot()

; MCM.Pages[0] = akTargetRef.GetName()
While index < max
	MCM.EquippedItem[index] = GetEquippedItemForm((akTargetRef as Actor), index)
	if MCM.EquippedItem[index]
		MCM.ItemName[index] = MCM.EquippedItem[index].GetName()
	else
		MCM.ItemName[index] = none
	endif
	
	if bDebug
		debug.Trace(DebugMessage((MCM.EquippedItem[index] as bool), index))
	endif

	index += 1
	utility.wait(0.001)
endWhile
bBusy = False
debug.Notification("Equipped Item Checked.")

;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment
aaaa_MCM_Quest Property MCM Auto
bool Property bBusy Auto

Form Function GetEquippedItemForm(Actor akActor, int Slot)
	form fmItem
	if Slot <= 2 ; 武器
		fmItem = akActor.GetEquippedObject(MCM.kSlotMask[slot])
	else
		fmItem = akActor.GetWornForm(MCM.kSlotMask[slot])
	endif
	return fmItem
endFunction


string Function DebugMessage(bool bForm, int No)
	string DebugTrace
	if bForm
		if No >= 10
			DebugTrace = "Mask["+No +"] " + MCM.EquippedItem[No].GetName() + "[" + MCM.EquippedItem[No] + "]"
		else
			DebugTrace = "Mask[0"+No +"] " + MCM.EquippedItem[No].GetName() + "[" + MCM.EquippedItem[No] + "]"
		endif
	else
		if No >= 10
			DebugTrace = "Mask["+No +"] " + "None"
		else
			DebugTrace = "Mask[0"+No +"] " + "None"
		endif
	endif
	return DebugTrace
endFunction
