Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname FyTyTweaks:AAAFyTy_ItemPhysics_HotkeyQuestScript extends Quest
- ActorBase property PlayerActorBase Auto Const
- Actor Property PlayerRef Auto Const
- FormList Property AAAFyTy_PhysicsItemsMasterFormList Auto Const
- FormList Property AAAFyTy_WorkshopWorkbenchFormList Auto Const
- Message Property AAAFyTy_Choice_AddToWorkBench_ItemPhysics Auto Const
- Keyword Property WorkshopItemKeyword Auto Const
- int iNestedFormListCount = 0
- int iDistance = 500
- int iCreatedFormIDMin = -16777216; FF000000
- int iCreatedFormIDMax = -1048576; FFF00000
- bool bIterating = false
- bool bInWorkshopMenu = false
- string strWorkshopMenu = "WorkshopMenu"
- Event OnQuestInit()
- iNestedFormListCount = AAAFyTy_PhysicsItemsMasterFormList.GetSize()
- SetStage(10)
- EndEvent
- Event OnMenuOpenCloseEvent(string strMenuName, bool bOpenedMenu)
- if (strMenuName == strWorkshopMenu)
- bInWorkshopMenu = bOpenedMenu
- EndIf
- EndEvent
- Function RegisterEventsForScript()
- Debug.MessageBox("Registering")
- RegisterForKey(35)
- RegisterForKey(36)
- RegisterForMenuOpenCloseEvent(strWorkshopMenu)
- EndFunction
- Function DeRegisterEventsForScript()
- Debug.MessageBox("De-Registering")
- UnRegisterForKey(35)
- unRegisterForKey(36)
- UnRegisterForMenuOpenCloseEvent(strWorkshopMenu)
- EndFunction
- Event OnStageSet(int iStageID, int iItemID)
- Debug.MessageBox("Stage Changed")
- if (iStageID == 10)
- RegisterEventsForScript()
- Debug.MessageBox("Stage set to 10")
- elseif (iStageID == 20)
- DeRegisterEventsForScript()
- Debug.MessageBox("Stage set to 20")
- EndIf
- EndEvent
- Function ChangeMotionTypeItems(bool bFreeze)
- bIterating = true
- int iFormListIndex = 0
- While iFormListIndex < iNestedFormlistCount
- FormList formlistCurrent = AAAFyTy_PhysicsItemsMasterFormList.GetAt(iFormListIndex) as FormList
- ObjectReference[] objrefarrayFoundItems = PlayerRef.FindAllReferencesOfType(formlistCurrent, iDistance)
- int iFoundItemsCount = objrefarrayFoundItems.Length
- int iFoundItemIndex = 0
- ;Debug.MessageBox("Found items: "+ iFoundItemsCount as string)
- if iFoundItemsCount > 0
- While iFoundItemIndex < iFoundItemsCount
- ;Debug.MessageBox("Setting Motion Type on Index: "+ iFoundItemIndex as string)
- ObjectReference objrefFoundItem = objrefarrayFoundItems[iFoundItemIndex] as ObjectReference
- if bFreeze
- objrefFoundItem.SetMotionType(objrefFoundItem.Motion_Keyframed, false)
- else
- objrefFoundItem.SetMotionType(objrefFoundItem.Motion_Dynamic, true)
- EndIf
- iFoundItemIndex += 1
- EndWhile
- EndIf
- iFormListIndex += 1
- EndWhile
- bIterating = false
- EndFunction
- Function LinkItemsToWorkbench()
- bIterating = true
- int iFormListIndex = 0
- ObjectReference objrefWorkshop = Game.FindClosestReferenceOfAnyTypeInListFromRef(AAAFyTy_WorkshopWorkbenchFormList, PlayerRef, 20000)
- While iFormListIndex < iNestedFormlistCount
- FormList formlistCurrent = AAAFyTy_PhysicsItemsMasterFormList.GetAt(iFormListIndex) as FormList
- ObjectReference[] objrefarrayFoundItems = PlayerRef.FindAllReferencesOfType(formlistCurrent, iDistance)
- int iFoundItemsCount = objrefarrayFoundItems.Length
- int iFoundItemIndex = 0
- ;Debug.MessageBox("Found items: "+ iFoundItemsCount as string)
- if iFoundItemsCount > 0
- While iFoundItemIndex < iFoundItemsCount
- ;Debug.MessageBox("Adding Item To Workshop At Index: "+ iFoundItemIndex as string)
- ObjectReference objrefFoundItem = objrefarrayFoundItems[iFoundItemIndex] as ObjectReference
- ;Debug.MessageBox(objrefFoundItem.GetBaseObject().GetName() + " " + objrefFoundItem.GetFormID() as string)
- int iItemFormID = objrefFoundItem.GetFormID()
- if (iItemFormID > iCreatedFormIDMin) && (iItemFormID < iCreatedFormIDMax)
- ;Debug.MessageBox("Linking Item To Workshop")
- objrefFoundItem.SetLinkedRef(objrefWorkshop, WorkshopItemKeyword)
- EndIf
- iFoundItemIndex += 1
- EndWhile
- EndIf
- iFormListIndex += 1
- EndWhile
- bIterating = false
- EndFunction
- Event OnKeyDown(int iKeyCode)
- Debug.MessageBox("End Key Pressed")
- if (iKeyCode == 35) && (bIterating == false) && (bInWorkshopMenu == false)
- ;Debug.MessageBox("Iterating")
- if AAAFyTy_Choice_AddToWorkBench_ItemPhysics.Show() == 0
- ChangeMotionTypeItems(true)
- else
- LinkItemsToWorkbench()
- Endif
- ;Debug.MessageBox("Done, reseting variables")
- EndIf
- if (iKeyCode == 36) && (bIterating == false) && (bInWorkshopMenu == false)
- ;Debug.MessageBox("Reverting")
- ChangeMotionTypeItems(false)
- ;Debug.MessageBox("Done, reseting variables")
- EndIf
- EndEvent
Add Comment
Please, Sign In to add comment