NighTragEl4d Posted June 15, 2011 Share Posted June 15, 2011 Well im wondering how to make a script (quest) that has detection of pressed keys that activates/deactivates ability,in other words i want that users customize in game or in ini file new keys. This is a script i maked: scn BTQ float fquestdelaytime Begin GameMode set fQuestDelayTime to 0.08 if iskeypressed 18 ;Activate BT trigger script endif if iskeypressed 19 ;Deactivate BT trigger script endif end Also i wonder if this script with ini file is good: scn BTQ float BTstartKey float BTendKey float fquestdelaytime Begin GameMode set fquestdelaytime to 0.08 runbatchscript "data/BTQsetting/BTSetting.ini" if iskeypressed BTstartkey ;activate BTtrigger script else ;deactivate BTtrigger script endif if iskeypressed BTendkey ;Deactivate BTtrigger script endif end This scripts i have now are a test ones but im wondering how the script should look so people can choose own keys IN GAME but not in ini file.Also i wanna know if those 2 scripts i have are good ones.Ty. Link to comment Share on other sites More sharing options...
fg109 Posted June 15, 2011 Share Posted June 15, 2011 (edited) With an ini file, your script would be like this: scn BTQ short BTstartKey short BTendKey float fquestdelaytime Begin GameMode if (GetGameLoaded) set fquestdelaytime to 0.08 runbatchscript "data/BTQsetting/BTSetting.ini" endif if iskeypressed BTstartkey ;activate BTtrigger script endif if iskeypressed BTendkey ;Deactivate BTtrigger script endif end Using an ini file is probably easier for you since you won't have to code a configuration menu. The only trouble is that you have to explain all the key codes in the ini file so the user can choose. If you decide to use a configuration menu, I suggest using IsKeyPressed2 instead of IsKeyPressed because IsKeyPressed uses Windows key codes. I don't seem to see any OBSE commands to get the Windows key codes. But there is one for DX scan codes using GetKeyPressed, which would work for IsKeyPressed2. Configuration menus are long and could be very hard to code. Here is a script I made for a menu to set some control keys: scriptname RLSConfigSubMenu1Script ;by fg109 float fquestdelaytime short menu short choice short tempshort1 short tempshort2 short tempshort3 short tempshort4 short tempshort5 short tempshort6 string_var tempstring1 Begin MenuMode if (menu == 0) Return elseif (menu == 2) let menu := 3 if (RLSMainQuest.autoscale == 0) let tempstring1 := "Disabled" elseif (RLSMainQuest.autoscale == 1) let tempstring1 := "Player to Partner" elseif (RLSMainQuest.autoscale == 2) let tempstring1 := "Partner to Player" endif MessageBoxEX "Controls%r|Control Keys >|Player Offset Keys >|Auto-Scaling: %z|< Back|Close" tempstring1 Return elseif (menu == 3) let choice := GetButtonPressed if (choice < 0) Return elseif (choice == 0) Label 0 let menu := 9 let tempshort1 := RLSMainQuest.switchkey let tempshort2 := RLSMainQuest.endkey MessageBoxEX "Control Keys%r|Switch Position: %k key|End: %k key|< Back|Close" tempshort1 tempshort2 Return elseif (choice == 1) Label 10 let menu := 10 let tempshort1 := RLSMainQuest.incxkey let tempshort2 := RLSMainQuest.decxkey let tempshort3 := RLSMainQuest.incykey let tempshort4 := RLSMainQuest.decykey let tempshort5 := RLSMainQuest.inczkey let tempshort6 := RLSMainQuest.deczkey MessageBoxEX "Player Offset%r|X-axis Increase: %k key|X-axis Decrease: %k key|Y-axis Increase: %k key|Y-axis Decrease: %k key|Z-axis Increase: %k key|Z-axis decrease: %k key|< Back|Close" tempshort1 tempshort2 tempshort3 tempshort4 tempshort5 tempshort6 Return elseif (choice == 2) Label 20 let menu := 11 if (RLSMainQuest.autoscale == 0) let tempstring1 := "Disabled" elseif (RLSMainQuest.autoscale == 1) let tempstring1 := "Player to NPC" elseif (RLSMainQuest.autoscale == 2) let tempstring1 := "NPC to Player" endif MessageBoxEX "Auto-Scaling:%r%z%r|Player to NPC|NPC to Player|Disable|< Back|Close" tempstring1 Return elseif (choice == 3) let menu := 1 StopQuest RLSConfigSubMenu1 Return elseif (choice == 4) let menu := 0 StopQuest RLSConfigSubMenu1 Return endif elseif (menu == 9) let choice := GetButtonPressed if (choice < 0) Return elseif (choice == 0) let menu := 27 MessageBoxEX "Switch Position%rHold down a key and press %qSet Key%q|Set Key" Return elseif (choice == 1) let menu := 28 MessageBoxEX "End%rHold down a key and press %qSet Key%q|Set Key" Return elseif (choice == 2) let menu := 2 Return elseif (choice == 3) let menu := 0 StopQuest RLSConfigSubMenu1 Return endif elseif (menu == 10) let choice := GetButtonPressed if (choice < 0) Return elseif (choice == 0) let menu := 29 MessageBoxEX "X-axis Increase%rHold down a key and press %qSet Key%q|Set Key" Return elseif (choice == 1) let menu := 30 MessageBoxEX "X-axis Decrease%rHold down a key and press %qSet Key%q|Set Key" Return elseif (choice == 2) let menu := 31 MessageBoxEX "Y-axis Increase%rHold down a key and press %qSet Key%q|Set Key" Return elseif (choice == 3) let menu := 32 MessageBoxEX "Y-axis Decrease%rHold down a key and press %qSet Key%q|Set Key" Return elseif (choice == 4) let menu := 33 MessageBoxEX "Z-axis Increase%rHold down a key and press %qSet Key%q|Set Key" Return elseif (choice == 5) let menu := 34 MessageBoxEX "Z-axis Decrease%rHold down a key and press %qSet Key%q|Set Key" Return elseif (choice == 6) let menu := 2 Return elseif (choice == 7) let menu := 0 StopQuest RLSConfigSubMenu1 Return endif elseif (menu == 11) let choice := GetButtonPressed if (choice < 0) Return elseif (choice == 0) let RLSMainQuest.autoscale := 1 GoTo 20 elseif (choice == 1) let RLSMainQuest.autoscale := 2 GoTo 20 elseif (choice == 2) let RLSMainQuest.autoscale := 0 GoTo 20 elseif (choice == 3) let menu := 2 Return elseif (choice == 4) let menu := 0 StopQuest RLSConfigSubMenu1 Return endif elseif (menu == 27) let choice := GetButtonPressed if (choice < 0) let RLSMainQuest.switchkey := GetKeyPress 0 Return elseif (choice == 0) GoTo 0 endif elseif (menu == 28) let choice := GetButtonPressed if (choice < 0) let RLSMainQuest.endkey := GetKeyPress 0 Return elseif (choice == 0) GoTo 0 endif elseif (menu == 29) let choice := GetButtonPressed if (choice < 0) let RLSMainQuest.incxkey := GetKeyPress 0 Return elseif (choice == 0) GoTo 10 endif elseif (menu == 30) let choice := GetButtonPressed if (choice < 0) let RLSMainQuest.decxkey := GetKeyPress 0 Return elseif (choice == 0) GoTo 10 endif elseif (menu == 31) let choice := GetButtonPressed if (choice < 0) let RLSMainQuest.incykey := GetKeyPress 0 Return elseif (choice == 0) GoTo 10 endif elseif (menu == 32) let choice := GetButtonPressed if (choice < 0) let RLSMainQuest.decykey := GetKeyPress 0 Return elseif (choice == 0) GoTo 10 endif elseif (menu == 33) let choice := GetButtonPressed if (choice < 0) let RLSMainQuest.inczkey := GetKeyPress 0 Return elseif (choice == 0) GoTo 10 endif elseif (menu == 34) let choice := GetButtonPressed if (choice < 0) let RLSMainQuest.deczkey := GetKeyPress 0 Return elseif (choice == 0) GoTo 10 endif endif End Edited June 15, 2011 by fg109 Link to comment Share on other sites More sharing options...
NighTragEl4d Posted June 15, 2011 Author Share Posted June 15, 2011 (edited) So on the second script there is a menu with choices of any keys right? But may i ask when config is done where should i pop in the trigger script?Im modifying more Enrage State so people can choose between automatic trigger or this one =). EDIT: Btw LogicDragon (my friend) has said about this solution: Message by LogicDragon: Just put the bullet time trigger in a quest script and have the quest set to start automatically. If it's too slow then try setting the fGlobalTimeMultiplier to a higher value to make it faster. To detect when someone has pressed a key you can use the OnKeyDown command. ; Q key pressed if OnKeyDown 16 ;do something endif So tell me what you think? Edited June 15, 2011 by NighTragEl4d Link to comment Share on other sites More sharing options...
fg109 Posted June 15, 2011 Share Posted June 15, 2011 He has it right, that's exactly how you do it. So just use your other scripts, remove all the timers and stuff, and change the trigger conditions from health or random to OnKeyDown. Link to comment Share on other sites More sharing options...
NighTragEl4d Posted June 15, 2011 Author Share Posted June 15, 2011 (edited) So the trigger script should look like this:Quest script scn EnragedStateTrigger float fquestdelaytime float timer Begin GameMode set fquestdelaytime to 0.08 if OnKeyDown 18 playsound TRPBluntObjectSwish con_SetIniSetting "fGlobalTimeMultiplier:General" 0.3500 con_SetCameraFOV 90 ; You can't set fov multiple times in the same frame TriggerHitShader 2 Message "You gained Enraged State" player.addspell EnragedStateBonus endif if OnKeyDown 19 TriggerHitShader 0.75 con_SetIniSetting "fGlobalTimeMultiplier:General" 1.0000 con_SetCameraFOV 75 player.removespell EnragedStateBonus player.addspell EnragedStateExhaustion set timer to 5 set timer to timer - GetSecondsPassed if timer <= 0 player.removespell EnragedStateExhaustion endif endif EndSomething like this? Edited June 15, 2011 by NighTragEl4d Link to comment Share on other sites More sharing options...
fg109 Posted June 15, 2011 Share Posted June 15, 2011 scn EnragedStateTrigger short EnrageState float fquestdelaytime float timer Begin GameMode set fquestdelaytime to 0.08 if (OnKeyDown 18) && (EnrageState == 0) playsound TRPBluntObjectSwish con_SetIniSetting "fGlobalTimeMultiplier:General" 0.3500 con_SetCameraFOV 90 TriggerHitShader 2 Message "You gained Enraged State" player.addspell EnragedStateBonus set EnrageState to 1 endif if (OnKeyDown 19) && (EnrageState == 1) TriggerHitShader 0.75 con_SetIniSetting "fGlobalTimeMultiplier:General" 1.0000 con_SetCameraFOV 75 player.removespell EnragedStateBonus player.addspell EnragedStateExhaustion set timer to 5 set EnrageState to 2 endif if (EnrageState == 2) set timer to timer - GetSecondsPassed if timer <= 0 player.removespell EnragedStateExhaustion set EnrageState to 0 endif endif End Link to comment Share on other sites More sharing options...
NighTragEl4d Posted June 15, 2011 Author Share Posted June 15, 2011 Y exactly i did it before you post the solution,i got it work but ty :P hehe. Also ty very much for all help you provided ^^. Link to comment Share on other sites More sharing options...
Recommended Posts