scn CWxPanelQuestScript ; 0 - disabled ; 1 - launched, wait for menu mode ; 2 - arrived in menu mode short initPhase ; NOTE: Left/right w.r.t. to the cyberboy perspective, so left=right side, right = left side ; 0 - none ; 1 - head ; 2 - torso ; 3 - right arm ; 4 - left arm ; 5 - right leg ; 6 - left leg short selectedRegion short lastSelectedRegion short refreshRegion ; 0 - none ; 1 - right 1 ; 2 - left 1 ; 3 - right 2 ; 4 - left 2 short selectedSlot ; instantly reset, thats why theres currentSlot to save the value short currentSlot ref rCurrentMessage ; Empty ref variable for using in UDF calls ref rEmptyRef short changedSlots short showRightSlot1 short showRightSlot2 short showLeftSlot1 short showLeftSlot2 ref newHeadImplant1 ref newHeadImplant2 ref newHeadImplant3 ref newHeadImplant4 ref newTorsoImplant1 ref newTorsoImplant2 ref newTorsoImplant3 ref newTorsoImplant4 ref newRightArmImplant1 ref newRightArmImplant2 ref newLeftArmImplant1 ref newLeftArmImplant2 ref newRightLegImplant1 ref newRightLegImplant2 ref newLeftLegImplant1 ref newLeftLegImplant2 ref rightSlotImplant1 ref rightSlotImplant2 ref leftSlotImplant1 ref leftSlotImplant2 short iButton ref selectedImplant float price short i short size ref regionList ref element float fTemp int iPage int pageCount short menuSize short t1 short t2 string_var sTemp int bPerformSurgery ref rTemp int bMenuImplantsPage int bShowImplantsBox ;----------------------------------------------------------------------------------------------------------------------------------------------------------------------- begin GameMode if initPhase == 0 set initPhase to 1 imod CWxControlPanelISFX ShowTutorialMenu CWxSurgeryDummyMsg ; Hide Tutorial Menu and show custom one instead - Try #1 SetUIFloat "TutorialMenu\_PNxImplantsPanelEnabled" 1 SetUIFloat "TutorialMenu\NOGLOW_BRANCH\visible" 0 return elseif initPhase == 1 return endif ; Back after close, menu was exited printd "Cyberware: Panel exited" rimod CWxControlPanelISFX RemoveEventHandler "OnButtonDown:4111" CWxPanelOnButtonDown if bPerformSurgery set bPerformSurgery to 0 DisablePlayerControls 1 1 1 1 1 1 ; Update perks call CWxFnCallFormList CWxImplantsWorkerList 0 printd "Starting surgery sequence" ; We use CWxImplants for persistence, so we can safely reset this quest ResetQuest CWxImplantsPanel printd "Cyberware: Panel quest has been reset" StopQuest CWxImplantsPanel printd "Cyberware: Panel quest stopped" playerRef.PlaySound3D NPCHumanDoctorHealTap playerRef.PlaySound3D NPCRobotMrHandyAttackSaw imod FadeToBlack4sISFX SetGameMainLoopCallback CWxPanelPostSurgery 1 320 1 else printd "No accept - undo any inventory changes" call CWxPanelSwapImplants CWxImplants.headImplant1 newHeadImplant1 call CWxPanelSwapImplants CWxImplants.headImplant2 newHeadImplant2 call CWxPanelSwapImplants CWxImplants.headImplant3 newHeadImplant3 call CWxPanelSwapImplants CWxImplants.headImplant4 newHeadImplant4 call CWxPanelSwapImplants CWxImplants.torsoImplant1 newTorsoImplant1 call CWxPanelSwapImplants CWxImplants.torsoImplant2 newTorsoImplant2 call CWxPanelSwapImplants CWxImplants.torsoImplant3 newTorsoImplant3 call CWxPanelSwapImplants CWxImplants.torsoImplant4 newTorsoImplant4 call CWxPanelSwapImplants CWxImplants.rightArmImplant1 newRightArmImplant1 call CWxPanelSwapImplants CWxImplants.rightArmImplant2 newRightArmImplant2 call CWxPanelSwapImplants CWxImplants.leftArmImplant1 newLeftArmImplant1 call CWxPanelSwapImplants CWxImplants.leftArmImplant2 newLeftArmImplant2 call CWxPanelSwapImplants CWxImplants.rightLegImplant1 newRightLegImplant1 call CWxPanelSwapImplants CWxImplants.rightLegImplant2 newRightLegImplant2 call CWxPanelSwapImplants CWxImplants.leftLegImplant1 newLeftLegImplant1 call CWxPanelSwapImplants CWxImplants.leftLegImplant2 newLeftLegImplant2 ResetQuest CWxImplantsPanel StopQuest CWxImplantsPanel printd "Cyberware: Panel quest has been reset" endif End begin MenuMode 1001 if GetUIFloat "TutorialMenu\_PNxCyberboyMenuActive" != 1 SetUIFloat "TutorialMenu\_PNxCyberboyMenuActive" 1 endif end Begin MenuMode 1059 if MenuMode 1001 return endif if initPhase < 2 set initPhase to 2 printd "Panel init" ; Check if the Project Nevada panel has been injected by UIO if GetUIFloat "TutorialMenu\_PNxImplants" > 0 ResetQuest CWxImplantsPanel StopQuest CWxImplantsPanel rimod CWxControlPanelISFX showMessage CWxErrorPNDetectedMsg return endif ; Check if the implants panel is even there if GetUIFloat "TutorialMenu\_CWxImplants" < 1 ResetQuest CWxImplantsPanel StopQuest CWxImplantsPanel rimod CWxControlPanelISFX showMessage CWxErrorNoPanelMsg return endif set refreshRegion to 1 set newHeadImplant1 to CWxImplants.headImplant1 set newHeadImplant2 to CWxImplants.headImplant2 set newHeadImplant3 to CWxImplants.headImplant3 set newHeadImplant4 to CWxImplants.headImplant4 set newTorsoImplant1 to CWxImplants.torsoImplant1 set newTorsoImplant2 to CWxImplants.torsoImplant2 set newTorsoImplant3 to CWxImplants.torsoImplant3 set newTorsoImplant4 to CWxImplants.torsoImplant4 set newRightArmImplant1 to CWxImplants.rightArmImplant1 set newRightArmImplant2 to CWxImplants.rightArmImplant2 set newLeftArmImplant1 to CWxImplants.leftArmImplant1 set newLeftArmImplant2 to CWxImplants.leftArmImplant2 set newRightLegImplant1 to CWxImplants.rightLegImplant1 set newRightLegImplant2 to CWxImplants.rightLegImplant2 set newLeftLegImplant1 to CWxImplants.leftLegImplant1 set newLeftLegImplant2 to CWxImplants.leftLegImplant2 ; Hide Tutorial Menu and show custom one instead - Try #2 setUIFloat "TutorialMenu\_PNxImplantsPanelEnabled" 1 setUIFloat "TutorialMenu\NOGLOW_BRANCH\visible" 0 setUIString "TutorialMenu\_PNxImplantsPanelCaps" "0" setUIString "TutorialMenu\_PNxImplantsPanelPrice" "0" call CWxPanelUpdatePrice set selectedRegion to 0 SetEventHandler "OnButtonDown:4111" CWxPanelOnButtonDown if CWxPanelGamepadHintShown == 0 && GetController MessageBoxEx "Use D-pad to navigate:%rUP/DOWN - select a body part%rLEFT/RIGHT - select an implant slot%rA - show an implant menu" set CWxPanelGamepadHintShown to 1 endif if ListGetCount CWxImplantsAllList != ListGetCount CWxImplantsDescList print "Cyberware: Number of elements in CWxImplantsAllList and CWxImplantsDescList is not equal!" endif return elseif rCurrentMessage == CWxSurgeryConfirmMsg set iButton to GetButtonPressed if iButton == -1 return endif set rCurrentMessage to 0 if iButton == 0 printd "Accept pressed Yes" player.removeItem Caps001 price 1 ; Commit implant changes set CWxImplants.headImplant1 to newHeadImplant1 set CWxImplants.headImplant2 to newHeadImplant2 set CWxImplants.headImplant3 to newHeadImplant3 set CWxImplants.headImplant4 to newHeadImplant4 set CWxImplants.torsoImplant1 to newTorsoImplant1 set CWxImplants.torsoImplant2 to newTorsoImplant2 set CWxImplants.torsoImplant3 to newTorsoImplant3 set CWxImplants.torsoImplant4 to newTorsoImplant4 set CWxImplants.rightArmImplant1 to newRightArmImplant1 set CWxImplants.rightArmImplant2 to newRightArmImplant2 set CWxImplants.leftArmImplant1 to newLeftArmImplant1 set CWxImplants.leftArmImplant2 to newLeftArmImplant2 set CWxImplants.rightLegImplant1 to newRightLegImplant1 set CWxImplants.rightLegImplant2 to newRightLegImplant2 set CWxImplants.leftLegImplant1 to newLeftLegImplant1 set CWxImplants.leftLegImplant2 to newLeftLegImplant2 set bPerformSurgery to 1 set t1 to GameDaysPassed if GameHour + changedSlots < 24 set GameHour to GameHour + changedSlots set GameDaysPassed to (t1 + (GameHour / 24)) else set t2 to ((GameHour + changedSlots) / 24) set GameHour to GameHour + changedSlots set GameDaysPassed to (t1 + t2 + ((GameHour % 24) / 24)) endif ; Replaced unsafe con_closeAllMenus with emulated click on the close button ClickMenuButton "TutorialMenu\PNxImplantsPanel\PNxImplantsPanelCloseButton" 1 return endif ; No printd "Accept pressed No" return elseif (GetUIFloat "TutorialMenu\_PNxImplantsPanelAcceptSelected") || (GetUIFloat "TutorialMenu\_PNxImplantsPanelAcceptEnabled" && MenuMode 1059 && (isKeyPressed 30 || IsButtonPressed 32768)) printd "Accept confirmation" set rCurrentMessage to CWxSurgeryConfirmMsg ShowMessage CWxSurgeryConfirmMsg return elseif refreshRegion == 1 printd "Refreshing regions" set refreshRegion to 0 set showRightSlot1 to (selectedRegion == 1 || selectedRegion == 2 || selectedRegion == 3 || selectedRegion == 5) set showLeftSlot1 to (selectedRegion == 1 || selectedRegion == 2 || selectedRegion == 4 || selectedRegion == 6) set showRightSlot2 to ((selectedRegion == 1 && player.hasPerk CWxExtraHeadSlotsPerk) || (selectedRegion == 2 && player.hasPerk CWxExtraTorsoSlotsPerk)) set showLeftSlot2 to showRightSlot2 set showRightSlot2 to showRightSlot2 || ((selectedRegion == 3 && player.hasPerk CWxExtraArmSlotsPerk) || (selectedRegion == 5 && player.hasPerk CWxExtraLegSlotsPerk)) set showLeftSlot2 to showLeftSlot2 || ((selectedRegion == 4 && player.hasPerk CWxExtraArmSlotsPerk) || (selectedRegion == 6 && player.hasPerk CWxExtraLegSlotsPerk)) setUIFloat "TutorialMenu\_PNxCyberboyShowRightSlot1" showRightSlot1 setUIFloat "TutorialMenu\_PNxCyberboyShowLeftSlot1" showLeftSlot1 setUIFloat "TutorialMenu\_PNxCyberboyShowRightSlot2" showRightSlot2 setUIFloat "TutorialMenu\_PNxCyberboyShowLeftSlot2" showLeftSlot2 setUIFloat "TutorialMenu\_PNxCyberboyRegion" selectedRegion if selectedRegion == 1 ;head call CWxPanelShowRegion selectedRegion newHeadImplant1 newHeadImplant2 newHeadImplant3 newHeadImplant4 showRightSlot2 elseif selectedRegion == 2 ; torso call CWxPanelShowRegion selectedRegion newTorsoImplant1 newTorsoImplant2 newTorsoImplant3 newTorsoImplant4 showRightSlot2 elseif selectedRegion == 3 ; right arm call CWxPanelShowRegion selectedRegion newRightArmImplant1 rEmptyRef newRightArmImplant2 rEmptyRef showRightSlot2 elseif selectedRegion == 4 ; left arm call CWxPanelShowRegion selectedRegion rEmptyRef newLeftArmImplant1 rEmptyRef newLeftArmImplant2 showLeftSlot2 elseif selectedRegion == 5 ; right leg call CWxPanelShowRegion selectedRegion newRightLegImplant1 rEmptyRef newRightLegImplant2 rEmptyRef showRightSlot2 elseif selectedRegion == 6 ; left leg call CWxPanelShowRegion selectedRegion rEmptyRef newLeftLegImplant1 rEmptyRef newLeftLegImplant2 showLeftSlot2 endif elseif bShowImplantsBox set fTemp to ListGetCount CWxImplantsAvailableList set fTemp to fTemp / CWxImplantsPerPage set pageCount to ceil fTemp printd "Implant list, page " + $iPage + ", page count " + $pageCount set i to iPage * CWxImplantsPerPage set menuSize to 1 let sTemp := "" while (menuSize <= CWxImplantsPerPage) && (rTemp := ListGetNthForm CWxImplantsAvailableList i) let sTemp := $sTemp + "|" + $(GetName rTemp) set i to i + 1 set menuSize to menuSize + 1 loop if (iPage + 1) < pageCount let sTemp := $sTemp + "|Next page >" set menuSize to menuSize + 1 endif let sTemp := $sTemp + "|<<< Back" set bShowImplantsBox to 0 set bMenuImplantsPage to 1 MessageBoxEx $sTemp sv_destruct sTemp return elseif rCurrentMessage == CWxPanelInstallMsg set iButton to GetButtonPressed if iButton == -1 return endif set rCurrentMessage to 0 if iButton == 0 ; Install call CWxPanelSetSlot selectedRegion currentSlot selectedImplant player.removeItem selectedImplant 1 1 set refreshRegion to 1 call CWxPanelUpdatePrice endif return elseif bMenuImplantsPage set iButton to GetButtonPressed if iButton == -1 ;printd "Waiting for implant button" return endif set bMenuImplantsPage to 0 printd "Pressed item in implant list" ; Handle "<<< Back" if iButton == menuSize - 1 if iPage > 0 set iPage to iPage - 1 set bShowImplantsBox to 1 endif return endif ; Handle "Next page >" if (iPage + 1) < pageCount if iButton == menuSize - 2 set iPage to iPage + 1 set bShowImplantsBox to 1 return endif endif set i to iPage * CWxImplantsPerPage + iButton set selectedImplant to ListGetNthForm CWxImplantsAvailableList i if eval call CWxPanelIsNotUnique selectedRegion selectedImplant currentSlot ShowMessage CWxErrorUniqueImplantMsg return endif call CWxPanelSetMessageData CWxPanelInstallMsg selectedImplant set rCurrentMessage to CWxPanelInstallMsg ShowMessage CWxPanelInstallMsg return elseif rCurrentMessage == CWxPanelRemoveMsg set iButton to GetButtonPressed if iButton == -1 printd "Waiting for removal confirmation" return endif set rCurrentMessage to 0 printd "Pressed button " + $iButton if iButton == 0 ; Yes printd "Confirmed removing implant" call CWxPanelSetSlot selectedRegion currentSlot rEmptyRef player.addItem selectedImplant 1 1 set refreshRegion to 1 call CWxPanelUpdatePrice endif return elseif selectedSlot > 0 set selectedSlot to 0 printd "Selected slot " + $currentSlot if currentSlot == 1 set selectedImplant to rightSlotImplant1 elseif currentSlot == 2 set selectedImplant to leftSlotImplant1 elseif currentSlot == 3 set selectedImplant to rightSlotImplant2 elseif currentSlot == 4 set selectedImplant to leftSlotImplant2 else return endif if selectedImplant == 0 ; Empty slot printd "Slot is empty" ; Select region list if selectedRegion == 1 set rTemp to CWxImplantsHeadList elseif selectedRegion == 2 set rTemp to CWxImplantsTorsoList elseif selectedRegion == 3 || selectedRegion == 4 set rTemp to CWxImplantsArmsList elseif selectedRegion == 5 || selectedRegion == 6 set rTemp to CWxImplantsLegsList endif ; Clear the list of available implants ListClear CWxImplantsAvailableList set i to 0 while element := ListGetNthForm rTemp i if player.GetItemCount element > 0 && ListGetFormIndex CWxImplantsAvailableList element == -1 ListAddForm CWxImplantsAvailableList element endif set i to i + 1 loop if ListGetCount CWxImplantsAvailableList <= 0 ShowMessage CWxErrorNoImplantsMsg return endif set iPage to 0 set bShowImplantsBox to 1 else ; Filled slot printd "Slot is not empty" call CWxPanelSetMessageData CWxPanelRemoveMsg selectedImplant set rCurrentMessage to CWxPanelRemoveMsg ShowMessage CWxPanelRemoveMsg endif return elseif rCurrentMessage != 0 printd "Cyberware: Current message was not empty, but not processed." let rCurrentMessage := 0 else ;printd "Idling" SetUIFloat "TutorialMenu\_PNxCyberboyMenuActive" 0 if getUIFloat "TutorialMenu\_PNxCyberboyHeadSelected" set selectedRegion to 1 elseif getUIFloat "TutorialMenu\_PNxCyberboyTorsoSelected" set selectedRegion to 2 elseif getUIFloat "TutorialMenu\_PNxCyberboyRightArmSelected" set selectedRegion to 3 elseif getUIFloat "TutorialMenu\_PNxCyberboyLeftArmSelected" set selectedRegion to 4 elseif getUIFloat "TutorialMenu\_PNxCyberboyRightLegSelected" set selectedRegion to 5 elseif getUIFloat "TutorialMenu\_PNxCyberboyLeftLegSelected" set selectedRegion to 6 else set selectedRegion to 0 endif if lastSelectedRegion != selectedRegion set lastSelectedRegion to selectedRegion set refreshRegion to 1 printd "New region selected" endif if GetUIFloat "TutorialMenu\_PNxCyberboyRightImplant1Selected" set selectedSlot to 1 elseif GetUIFloat "TutorialMenu\_PNxCyberboyLeftImplant1Selected" set selectedSlot to 2 elseif GetUIFloat "TutorialMenu\_PNxCyberboyRightImplant2Selected" set selectedSlot to 3 elseif GetUIFloat "TutorialMenu\_PNxCyberboyLeftImplant2Selected" set selectedSlot to 4 else set selectedSlot to 0 endif if selectedSlot > 0 set currentSlot to selectedSlot endif endif end