Westend
10th March 2010, 08:53 PM
Hi,
I'm pretty new to programming my CH MFP. I have a problem where in my FPS you have to hold the crouch key and the sprint key down to perform those actions.
I wrote a script so that I can toggle the crouch key status and the sprint key status. To keep things in check each sequence checks the status of the other key and if it is set it first releases the other key. I.e When the sprint kye is pressed set the crouch key to false if it is currently set.
This is what I have.
// CMS Script File
//
// Game Title: BF2CC
// Written By: PEter West
// Date: 3/8/2010
//
script
//RESET VARIABLES
IF ( FIRSTSCAN ) THEN
B1 = FALSE;
B2 = FALSE;
B3 = FALSE;
ENDIF
///////////////////////////////////////////////////////
//Toggle Crouch
SEQUENCE
WAIT ( JS1.B6 );
// IF THE SPRINT BIT IS SET THEN TURN IT OFF
IF ( B2 ) THEN
B2 = FALSE;
CMS.B2 = B2; //TOGGLE SPRINT KEY
ENDIF
//TOGGLE CROUCH BIT
IF ( B1 ) THEN
B1 = FALSE;
ELSE
B1 = TRUE;
ENDIF
CMS.B1 = B1; //TOGGLE CROUCH KEY
ENDSEQUENCE
///////////////////////////////////////////////////////
//Toggle sprint
SEQUENCE
WAIT ( JS1.B7 );
// IF THE CROUCH BIT IS SET THEN TURN IT OFF
IF ( B1 ) THEN
B1 = FALSE;
CMS.B1 = B1; //TOGGLE CROUCH KEY
ENDIF
// TOGGLE SPRINT BIT
IF ( B2 ) THEN
B2 = FALSE;
ELSE
B2 = TRUE;
ENDIF
CMS.B2 = B2; //TOGGLE SPRINT KEY
ENDSEQUENCE
endScript
This works fine. However, after forgetting to tap the sprint key to stop sprinting or pressing another key that cancels sprinting I decided that I want to manually hold the sprint key down.
So my challenge is that now when I press the sprint key I still need to detect that the crouch is set and toggle it off. If I set my sprint key button back to the CMC command for sprint then the CMS script no longer detects that button. So I gather that I still need to script the button to set the sprint key to TRUE when it is pressed and set it to FALSE after releasing it.
So whats the best way to script my JS1.B7 so that when it is pressed it sets CMS.B2 to TRUE and when it is released it sets CMS.B1 to FALSE?
Using WHILE() I can set the CMS key to TRUE when the button is pressed. But how to I toggle the state when the key is released?
Best regards,
Pete.
I'm pretty new to programming my CH MFP. I have a problem where in my FPS you have to hold the crouch key and the sprint key down to perform those actions.
I wrote a script so that I can toggle the crouch key status and the sprint key status. To keep things in check each sequence checks the status of the other key and if it is set it first releases the other key. I.e When the sprint kye is pressed set the crouch key to false if it is currently set.
This is what I have.
// CMS Script File
//
// Game Title: BF2CC
// Written By: PEter West
// Date: 3/8/2010
//
script
//RESET VARIABLES
IF ( FIRSTSCAN ) THEN
B1 = FALSE;
B2 = FALSE;
B3 = FALSE;
ENDIF
///////////////////////////////////////////////////////
//Toggle Crouch
SEQUENCE
WAIT ( JS1.B6 );
// IF THE SPRINT BIT IS SET THEN TURN IT OFF
IF ( B2 ) THEN
B2 = FALSE;
CMS.B2 = B2; //TOGGLE SPRINT KEY
ENDIF
//TOGGLE CROUCH BIT
IF ( B1 ) THEN
B1 = FALSE;
ELSE
B1 = TRUE;
ENDIF
CMS.B1 = B1; //TOGGLE CROUCH KEY
ENDSEQUENCE
///////////////////////////////////////////////////////
//Toggle sprint
SEQUENCE
WAIT ( JS1.B7 );
// IF THE CROUCH BIT IS SET THEN TURN IT OFF
IF ( B1 ) THEN
B1 = FALSE;
CMS.B1 = B1; //TOGGLE CROUCH KEY
ENDIF
// TOGGLE SPRINT BIT
IF ( B2 ) THEN
B2 = FALSE;
ELSE
B2 = TRUE;
ENDIF
CMS.B2 = B2; //TOGGLE SPRINT KEY
ENDSEQUENCE
endScript
This works fine. However, after forgetting to tap the sprint key to stop sprinting or pressing another key that cancels sprinting I decided that I want to manually hold the sprint key down.
So my challenge is that now when I press the sprint key I still need to detect that the crouch is set and toggle it off. If I set my sprint key button back to the CMC command for sprint then the CMS script no longer detects that button. So I gather that I still need to script the button to set the sprint key to TRUE when it is pressed and set it to FALSE after releasing it.
So whats the best way to script my JS1.B7 so that when it is pressed it sets CMS.B2 to TRUE and when it is released it sets CMS.B1 to FALSE?
Using WHILE() I can set the CMS key to TRUE when the button is pressed. But how to I toggle the state when the key is released?
Best regards,
Pete.