Scriptname dcur_yokeScript extends zadRestraintScript

dcur_yokeQuestScript Property yqs Auto

; Messages
Message Property zad_YokePreEquipMsg Auto
Message Property zad_YokeEquipPostMsg Auto
Message Property zad_YokeDisableLocksMsg Auto
Message Property zad_YokeEnableLocksMsg Auto

Function OnEquippedPre(actor akActor, bool silent=false)
	if !silent
		if akActor == libs.PlayerRef
			zad_YokeEquipPostMsg.Show()
		Else
			;libs.NotifyActor("You lock "+GetMessageName(akActor)+"'s neck and wrists into the heavy yoke.", akActor, true)
			libs.NotifyActor("あなたは "+GetMessageName(akActor)+"　の首と手首に重ヨークを填めます。", akActor, true)
		EndIf
	EndIf
	Parent.OnEquippedPre(akActor, silent)
EndFunction


Function OnEquippedPost(actor akActor)
	;akActor.UnequipItemSlot(36) ; Unequip ring to avoid clipping
	if akActor == libs.PlayerRef
		libs.UpdateControls()				
	EndIf	
EndFunction

int Function OnEquippedFilter(actor akActor, bool silent=false)	
	if ! akActor.IsEquipped(deviceRendered)
		if akActor!=libs.PlayerRef && ShouldEquipSilently(akActor)
			libs.Log("Avoiding FTM duplication bug (Yoke).")
			return 0
		EndIf
		if akActor.WornHasKeyword(libs.zad_DeviousArmbinder)
			MultipleItemFailMessage("Armbinder")
			return 2
		EndIf	
	EndIf
	if akActor != libs.PlayerRef || silent
		return 0 ; Proceed.
	EndIf
        int interaction = zad_yokePreEquipMsg.show()
        if interaction == 0 ; Equip Device		
			return 0 ; Proceed
		ElseIf interaction == 1 ; Put it away
			return 2
		EndIf
	;libs.Error("Invalid menu option selected for Yoke Script")
	libs.Error("ヨークスクリプトで不正なオプションが選択されています")
	return 0
EndFunction


Function DeviceMenu(Int msgChoice = 0)
	msgChoice = yqs.ShowArmbinderMenu(msgChoice)
	DeviceMenuExt(msgChoice)
	SyncInventory()
EndFunction


Function OnRemoveDevice(actor akActor)	
	if !libs.IsAnimating(akActor)
		Debug.SendAnimationEvent(akActor, "IdleForceDefaultState")
	EndIf
EndFunction
