//////////////////////////// /// jumpingFuntions.zh //////////////////////// ///////////////////////////////////////////////// /// Inluding Arrays, Variables and Constants: /// ///////////////////////////////////////////////// /// ZoriaRPG, Release 1.1, on 7th June, 2014. /// /// Alpha, v1.1 /// ///////////////////////////////////////////////// //Note: These are variables, so that you can change their values with items. //You can change them to constants, if not using more than one jump item or jump type. ////////////////////////// // JUMP ARRAY TEMPLATE /// ////////////////////////// //I will be shifting the item sripts, ffc scripts, and global functions to use this in a future version. // HEIGHT MPCOST RUP_COST USER_COST USR_COUNTER JUMP_SFX ERROR_SFX REQ_STATE ITEM TIME DISTANCE //NORMAL_JUMP //Z_JUMP //float jumpArray[22]={ // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //const int JUMP_HEIGHT = 0; //const int JUMP_MPCOST = 1; //const int JUMP_RUP_COST = 2; //const int JUMP_USER_COST = 3; //const int JUMP_USR_COUNTER = 4; //const int JUMP_JUMP_SFX = 5; //const int JUMP_ERROR_SFX = 6; //const int JUMP_REQUIRE = 7; //const int JUMP_ITEM_NEEDED = 8; //const int JUMP_TIME = 9; //const int JUMP_DISTANCE = 10; //const int ARRAY_COLUMN_SIDEVIEW = 0; //const int ARRAY_COLUMN_OVERHEAD = 11; /////////////////////////// /// JUMP ARRAY FUNTIONS /// /////////////////////////// //void changeJumpSettings(float typeToSet, float setJumpHeight, float setJumpMPCost, float setJumpRupees, // float setJumpUserCost, float setJumpCounter, float setJumpSFX, float setJumpErrorFX, // float setJumpRequireAnItem, float setJumpItemNumber, float setJumpTime, float setJumpDistance){ // jumpArray[typeToSet+JUMP_HEIGHT] = setJumpHeight; // jumpArray[typeToSet+JUMP_MPCOST] = setJumpMPCost; // jumpArray[typeToSet+JUMP_RUP_COST] = setJumpRupees; // jumpArray[typeToSet+JUMP_USER_COST] = setJumpUserCost; // jumpArray[typeToSet+JUMP_USR_COUNTER] = setJumpCounter; // jumpArray[typeToSet+JUMP_JUMP_SFX] = JUMP_JUMP_SFX; // jumpArray[typeToSet+JUMP_ERROR_SFX] = setJumpErrorFX; // jumpArray[typeToSet+JUMP_REQUIRE] = setJumpRequireAnItem; // jumpArray[typeToSet+JUMP_ITEM_NEEDED] = setJumpItemNumber; // jumpArray[typeToSet+JUMP_TIME] = setJumpTime; // jumpArray[typeToSet+JUMP_DISTANCE] = setJumpDistance; //} ///////////// /// COSTS /// ///////////// ///Standard float jumpMP = 0; //Set the MP cost for jumping, using jumpButton(). //Multiples of 8, 16, 24, or 32 would be the most logical. //There are 32 MP in one magic block, if using a normal metre. float jumpCostRupees = 0; // Sets the cost in rupees to jump, using jumpButton(). float jumpCostUserDefined = 0; //Sets a user-defined Jump cost, tied to a user-defined counter. ///Overhead float birdseyeJumpMP = 0; //Set the MP cost for jumping with jumpButtonOverhead(), or Z-Axis FFC. //Multiples of 8, 16, 24, or 32 would be the most logical. //There are 32 MP in one magic block, if using a normal metre. float birdseyeJumpCostRupees = 0; // Sets the cost in rupees to jump with overhead jumping by jumpButtonOverhead() or Z-Axis FFC. float birdseyeJumpCostUserDefined = 0; //Sets a user defined Jumo cost, tied to a user-defined counter. ///Custom Counter ///You may use this, to assign a special value, such as 'Energy', or 'Stamina' to jumping, that you an reduce ///with a user-defined cost. const int CR_JUMPCOST = 7; //Counter Script 1 is '7'. //Change this to your desired value for a custom counter, if you're using one. //Reference std_constants.zh to determine the counter value that you want to use. ///////////////////// /// Sound Effects /// ///////////////////// float SFX_JUMP = 62; //Sets jump sound, for jumpButton(); from Quest->Audio->SFX Data. float jumpError = 64; //Sets the SFX error for jumping / items, for jumpButton(). float OVERHEAD_SFX_JUMP = 62; //Sets overhead jump sound, for jumpButtonOverhead(); from Quest->Audio->SFX Data. float overheadJumpError = 64; //Sets the SFX error for overhead jumping / items, for jumpButtonOverhead(). const int CHANGE_JUMP_SETTINGS = 65; //Establishes a *default sound effect* to play, when the player uses an item that *changes the value of* SFX_JUMP. const int CHANGE_JUMP_SETTINGS_OVERHEAD = 66; //Establishes a *default sound effect* to play, when the player uses an item that *changes the value of* OVERHEAD_SFX_JUMP. /////////////// /// METRICS /// /////////////// float JUMP_HEIGHT = 4; //Sets the height of the jump, in TILES (thus, this value * 16, in pixels). float overheadTime = 240; //Sets duration of overhead view jumps at 60FPS. (Nothing is using this, at present.) float overheadHeight = 4; //Sets Z axis height for overhead jumping, using jumpButtonOverhead(), in PIXELS. I believe the eiling for this is '8'. float overheadDistance = 20; //Sets automatic distance of overhead jumps; the X/Y distance that Link will move (in PIXELS) when using the funtion jumpButtonOverhead(). bool inAir = false; //Used to determine of Link is already int he air. This is not in use at present, and is required //only to prevebt the player from Z-axis jumoing, while already Z-axis jumping. the function //jumpButtonOverhead() , or an FFC for Z-axis positioning would NEED/USE this ONLY if the Z-position //of the player is held for a timed DURATION. bool requireOnGround = true; //Set to false overhead jumping with jumpButton(). I should update that funtion to separate //this and isSideView as *separate onditional requirements* that can be established, and //set/hanged/updated as part of an array. ///////////////////////// /// ITEM REQUIREMENTS /// ///////////////////////// float JUMP_ITEM = 91; //Sets the item required for jumping with jumpButton(); use the 'Item Number' value fron the item editor. bool requireJumpItem = false; //For the funtion jumpButton(): Set to false, if player can always jump, or true, if you require an item to jump. bool requireOverheadJumpItem = false; //For the funtion jumpButtonOverhead(): Set to false, if player can always jump, or true, if you require an item to jump. float OVERHEAD_JUMP_ITEM = 92; //Sets the item neded for overhead jumping with jumpButtonOverhead() use the 'Item Number' value fron the item editor. //////////////////// /// FFC SETTINGS /// //////////////////// float jumpBirdseye = 0; //This is an empty int, *not in use*. This is here, beause it will go into an array, //and *act* as a boolen, to determine if the player MAY use birds' eye mode jumping via the FFC. //It is a float, so that it can be neatly tucked into an array, when I complete these sripts. float birdseyeHeight = 4; //the Z-axis height for the Z-Axis *FFC* jumping. I believe the eiling for this is '8'. float birdseyeDistance = 20; //The X/Y distance that Link will move (in pixels) when using the Z-Axis *FFC*. const int jumpZ_FFC = 1; //Set this to the slot of 'ffc script overheadJump'. //This FFC isn't funtional at this time. ///////////////////////// /// JUMPING FUNCTIONS /// ///////////////////////// void jumpButton() { if ( requireOnGround == true ) { if ( requireJumpItem == true ) { if ( Link->Item[JUMP_ITEM] && onGround() ) { if ( Link->PressEx1 && Link->MP >= jumpMP || Link->PressEx1 && jumpMP == 0 ){ if ( Game->Counter[CR_RUPEES] >= jumpCostRupees || jumpCostRupees == 0) { if ( Game->Counter[CR_JUMPCOST] >= jumpCostUserDefined || jumpCostUserDefined == 0 ) { Link->Jump = JUMP_HEIGHT; //Sets height of jump. Game->Counter[CR_MAGIC] -= jumpMP; Game->Counter[CR_RUPEES] -= jumpCostRupees; Game->Counter[CR_JUMPCOST] -= jumpCostUserDefined; if ( SFX_JUMP > 0 ) { Game->PlaySound(SFX_JUMP); //Play sound set as SFX_JUMP. //Play sound set as jumpError. //A sound value of '0' will not produce a sound. } } } } else if ( Link->PressEx1 && Link->MP < jumpMP || Link->PressEx1 && Game->Counter[CR_RUPEES] < jumpCostRupees || Link->PressEx1 && Game->Counter[CR_JUMPCOST] < jumpCostUserDefined ) { if ( jumpError > 0 ) { Game->PlaySound(jumpError); //Play sound set as jumpError. } //A sound value of '0' will not produce a sound. } } } else if ( requireJumpItem == false ) { if ( onGround() ) { if ( Link->PressEx1 && Link->MP >= jumpMP || Link->PressEx1 && jumpMP == 0 ){ if ( Game->Counter[CR_RUPEES] >= jumpCostRupees || jumpCostRupees == 0) { if ( Game->Counter[CR_JUMPCOST] >= jumpCostUserDefined || jumpCostUserDefined == 0 ) { Link->Jump = JUMP_HEIGHT; //Sets height of jump. Game->Counter[CR_MAGIC] -= jumpMP; Game->Counter[CR_RUPEES] -= jumpCostRupees; Game->Counter[CR_JUMPCOST] -= jumpCostUserDefined; if ( SFX_JUMP > 0 ) { Game->PlaySound(SFX_JUMP); //Play sound set as SFX_JUMP. //Play sound set as jumpError. //A sound value of '0' will not produce a sound. } } } } else if ( Link->PressEx1 && Link->MP < jumpMP || Link->PressEx1 && Game->Counter[CR_RUPEES] < jumpCostRupees || Link->PressEx1 && Game->Counter[CR_JUMPCOST] < jumpCostUserDefined ) { Game->PlaySound(jumpError); //Play sound set as jumpError. //A sound value of '0' will not produce a sound. } } } } else if ( requireOnGround == false ) { if ( requireJumpItem == true ) { if ( Link->Item[JUMP_ITEM] ) { if ( Link->PressEx1 && Link->MP >= jumpMP || Link->PressEx1 && jumpMP == 0 ){ if ( Game->Counter[CR_RUPEES] >= jumpCostRupees || jumpCostRupees == 0) { if ( Game->Counter[CR_JUMPCOST] >= jumpCostUserDefined || jumpCostUserDefined == 0 ) { Link->Jump = JUMP_HEIGHT; //Sets height of jump. Game->Counter[CR_MAGIC] -= jumpMP; Game->Counter[CR_RUPEES] -= jumpCostRupees; Game->Counter[CR_JUMPCOST] -= jumpCostUserDefined; if ( SFX_JUMP > 0 ) { Game->PlaySound(SFX_JUMP); //Play sound set as SFX_JUMP. //Play sound set as jumpError. //A sound value of '0' will not produce a sound. } } } } else { if ( SFX_JUMP > 0 ) { Game->PlaySound(jumpError); //Play sound set as jumpError. } //A sound value of '0' will not produce a sound. } } } else if ( requireJumpItem == false ){ if ( Link->PressEx1 && Link->MP >= jumpMP || Link->PressEx1 && jumpMP == 0 ){ if ( Game->Counter[CR_RUPEES] >= jumpCostRupees || jumpCostRupees == 0) { if ( Game->Counter[CR_JUMPCOST] >= jumpCostUserDefined || jumpCostUserDefined == 0 ) { Link->Jump = JUMP_HEIGHT; //Sets height of jump. Game->Counter[CR_MAGIC] -= jumpMP; Game->Counter[CR_RUPEES] -= jumpCostRupees; Game->Counter[CR_JUMPCOST] -= jumpCostUserDefined; if ( SFX_JUMP > 0 ) { Game->PlaySound(SFX_JUMP); //Play sound set as SFX_JUMP. //Play sound set as jumpError. //A sound value of '0' will not produce a sound. } } } } else { Game->PlaySound(jumpError); //Play sound set as jumpError. //A sound value of '0' will not produce a sound. } } } } void jumpButtonOverhead() { int overheadTimer = 0; if ( requireOverheadJumpItem == true ) { if ( Link->Item[JUMP_ITEM] && inAir == false ) { if ( Link->PressEx2 && Link->MP >= birdseyeJumpMP || Link->PressEx2 && birdseyeJumpMP == 0) { if ( Game->Counter[CR_RUPEES] >= birdseyeJumpCostRupees || birdseyeJumpCostRupees == 0) { if ( Game->Counter[CR_JUMPCOST] >= birdseyeJumpCostUserDefined || birdseyeJumpCostUserDefined == 0 ) { Game->Counter[CR_MAGIC] -= birdseyeJumpMP; Game->Counter[CR_RUPEES] -= birdseyeJumpCostRupees; Game->Counter[CR_JUMPCOST] -= birdseyeJumpCostUserDefined; if ( OVERHEAD_SFX_JUMP > 0 ) { Game->PlaySound(OVERHEAD_SFX_JUMP); //Play sound set as OVERHEAD_SFX_JUMP. //Play sound set as overheadJumpError. //A sound value of '0' will not produce a sound. } for (int i=1; i<=overheadTime; i++){ Link->Z = overheadHeight; inAir = true; //Waitframe(); } if ( overheadDistance > 0 ) { if(Link->Dir == DIR_DOWN) { Link->X += overheadDistance; } if(Link->Dir == DIR_UP) { Link->X -= overheadDistance; } if(Link->Dir == DIR_LEFT) { Link->Y -= overheadDistance; } if(Link->Dir == DIR_RIGHT) { Link->Y += overheadDistance; } inAir = false; } } } } } else if ( Link->PressEx2 && Link->MP < birdseyeJumpMP || Link->PressEx2 && Game->Counter[CR_RUPEES] < birdseyeJumpCostRupees || Link->PressEx2 && Game->Counter[CR_JUMPCOST] < birdseyeJumpCostUserDefined ) { if ( overheadJumpError > 0 ) { Game->PlaySound(overheadJumpError); //Play sound set as overheadJumpError. } //A sound value of '0' will not produce a sound. } } else if ( requireOverheadJumpItem == false ) { //if ( inAir == false ) { if ( !IsSideview() ) { if ( Link->PressEx2 && Link->MP >= birdseyeJumpMP || Link->PressEx2 && birdseyeJumpMP == 0) { if ( Game->Counter[CR_RUPEES] >= birdseyeJumpCostRupees || birdseyeJumpCostRupees == 0) { if ( Game->Counter[CR_JUMPCOST] >= birdseyeJumpCostUserDefined || birdseyeJumpCostUserDefined == 0 ) { Game->Counter[CR_MAGIC] -= birdseyeJumpMP; Game->Counter[CR_RUPEES] -= birdseyeJumpCostRupees; Game->Counter[CR_JUMPCOST] -= birdseyeJumpCostUserDefined; if ( OVERHEAD_SFX_JUMP > 0 ) { Game->PlaySound(OVERHEAD_SFX_JUMP); //Play sound set as OVERHEAD_SFX_JUMP. //Play sound set as overheadJumpError. //A sound value of '0' will not produce a sound. } //int overheadTimer = 1; do{ overheadTimer++; Link->Z = overheadHeight; inAir = true; } while(overheadTimer < overheadTime ); Link->Z = 8; inAir = false; //Waitframe(); //if ( overheadDistance > 0 ) { if(Link->Dir == DIR_RIGHT) { Link->X += overheadDistance; } if(Link->Dir == DIR_LEFT) { Link->X -= overheadDistance; } if(Link->Dir == DIR_UP) { Link->Y -= overheadDistance; } if(Link->Dir == DIR_DOWN) { Link->Y += overheadDistance; } inAir = false; //} } } } //} } } //else if ( Link->PressEx2 && // Link->MP < birdseyeJumpMP || // Link->PressEx2 && // Game->Counter[CR_RUPEES] < birdseyeJumpCostRupees || // Link->PressEx2 && // Game->Counter[CR_JUMPCOST] < birdseyeJumpCostUserDefined ) // //{ // if ( overheadJumpError > 0 ) { // Game->PlaySound(overheadJumpError); //Play sound set as overheadJumpError. // } // //A sound value of '0' will not produce a sound. //} } //} //bool onGround(){ // if(!IsSideview()) // return Link->Z == 0; // return // OnSidePlatform(Link->X, Link->Y); //} bool onGround(){ if(!IsSideview()) return Link->Z == 0; return OnSidePlatform(Link->X, Link->Y, Link->HitXOffset, Link->HitYOffset, Link->HitHeight); } /// All of these onGround (and onGround-based) funtions need an expanded definition nfor pink position & offsets, /// to allow jumping when partiallym or mostly OFF a platform. At present, if the entre pixels of Link are not onGround, then /// The game will not onsider him to be onGround. I have some better funtions elsewhere, but they depend on a *custom /// engine for control of movement*, and must be updated / changed, for general use. bool IsSideviewLinkOnGround() { return // If this is a sideview screen. IsSideview() && // and Link is standing on a solid tile. (Screen->isSolid(Link->X + 04, Link->Y + 16) || Screen->isSolid(Link->X + 12, Link->Y + 16)); } int GetHighPortion(int arg) {return arg >> 0;} int GetLowPortion(int arg) {return (arg - (arg >> 0)) * 10000;}