Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Demo Graphics:
- //Menu tiles page 150
- //backdrop tile 39000
- //cursor tile 39005
- //cursor combo 888
- import "std.zh"
- import "string.zh"
- import "ghost.zh"
- import "LinksAwakening.z"
- import "CustomTango.zh"
- import "ffcscript.zh"
- //Global RAM Array to save global registers.
- int ____GlobRAM[256];
- //Indices of the array.
- const int DIFFICULTY_SETTING = 0; //Do not change.
- const int BLINK_TEXT = 1; //Do not change.
- //Arbitrary difficulty setting values. Do not change.
- const int DIFF_EASY = 1;
- const int DIFF_NORMAL = 2;
- const int DIFF_MED = 2;
- const int DIFF_HARD = 3;
- const int DIFF_INSANE = 4;
- //! Boolean Settings : Config Options
- const int DRAW_DIFFICULTY = 1; //Set to 1 to display the present difficulty rating for testing purposes.
- //! If enabled, the difficulty rating will be drawn to the upper-left corner of the display.
- const int DIFF_AUTOSTART = 1; //Set to 1 to auto-start after selecting a difficulty.
- const int PRESS_START_TEXT_DISPLAY = 1; //Set to 1 to display 'Press Start' as a drawn string.
- //! Script Variable Settings
- const int NPC_MISC_DIFF = 15; //The Misc[index] to use for npc buffs.
- const int START_SCREEN_DMAP = 0; //The DMap for the 'Title Screen'
- const int START_SCREEN_SCREEN = 0; //The Screen ID for the 'Title Screen'
- const int START_SCREEN_SFX = 35; //The sound to play after the player presses Start on the title screen/
- const int START_SCREEN_DELAY = 100; //Delay time in frames, for playing sound.
- //! The following two settings are the DMap and Screen to send the player, when starting a
- //! new game, after pressing 'Start' on the title screen.
- const int START_SCREEN_WARP_TO_DMAP = 2; //The initial DMap of the game.
- const int START_SCREEN_WARP_TO_SCREEN = 0; //The initial screen of the game.
- const int DIFF_MENU_TILE = 39000; //Upper-left corner of menu frame, tile ID.
- const int DIFF_MENU_WIDTH = 4; //Width of menu, in tiles.
- const int DIFF_MENU_HEIGHT = 4; //Height of menu, in tiles.
- const int DIFF_MENU_CURSOR_COMBO = 888; //Combo of the menu cursor.
- const int DIFF_MENU_X_POS = 100; //Menu positions (X)
- const int DIFF_MENU_Y_POS = 100; //Menu positions (Y)
- const int DIFF_MENU_CURSOR_CSET = 0; //CSet for the cursor
- const int DIFF_MENU_CURSOR_WIDTH = 2; //Width of the cursor, in pixels.
- const int DIFF_MENU_CURSOR_MOVE_SFX = 5; //Sound effect for moving the cursor.
- const int DIFF_MENU_CURSOR_SELECT_SFX = 44; //Sound effect for selecting a difficulty.
- const int MENU_SELECT_SFX_DURATION = 22; //Delay after making a selection, to permit the
- //sound to fully play.
- //Settings for 'Press Start' blinking text.
- const int PRESS_START_TEXT_LAYER = 2;
- const int PRESS_START_TEXT_X = 102;
- const int PRESS_START_TEXT_Y = 50;
- const int PRESS_START_TEXT_FONT = 1; //Z3
- const int PRESS_START_TEXT_COLOUR = 0x01;
- const int PRESS_START_TEXT_BGCOLOUR = 0;
- const int PRESS_START_TEXT_FORMAT = 0;
- const int PRESS_START_TEXT_OPACITY = 128;
- const int PRESS_START_TEXT_BLINK = 20; //Timer duration
- const int BLINK_INTERVAL1 = 8; //Visible during this frame interval:
- const int BLINK_INTERVAL2 = 18; //Invisible after this frame interval.
- //Tango Settings: These are arbitrary values to permit style settings.
- //Do not change.
- const int WINDOW_SLOT_1 = 0;
- const int WINDOW_SLOT_2 = 1;
- const int WINDOW_SLOT_3 = 2;
- const int WINDOW_SLOT_4 = 3;
- const int WINDOW_SLOT_5 = 4;
- const int WINDOW_STYLE_1 = 0;
- const int WINDOW_STYLE_2 = 1;
- const int WINDOW_STYLE_3 = 2;
- const int SIZE_SMALL = 0;
- const int SIZE_LARGE = 1;
- const int SIZE_WIDE = 2;
- const int SIZE_DIFFMENU = 3;
- //This script auto-loads into slot ~Init when compiling.
- //It is used to set up the basic tango styles.
- global script Init {
- void run() {
- SetCommonStyleData(WINDOW_STYLE_1); //Sets 'Style 1' Tango settings.
- SetCommonStyleData(WINDOW_STYLE_2); //Sets 'Style 2' Tango settings.
- SetCommonStyleData(WINDOW_STYLE_3); //Sets 'Style 1' Tango settings.
- }
- }
- //! This FFC Script is called by the global active script.
- //! It WILL NOT WORK if manually placed.
- //////////////////////////
- /// Title Screen FFC ///
- /// with Tango Menu ///
- /// By: ZoriaRPG ///
- //////////////////////////////////////////////////////////////////////////////
- /// ............... ///
- /// FFC ARGUMENTS ///
- /// ............... ///
- ///---------------------------{ D0: Start SFX }----------------------------///
- /// D0: SFX to play when the player presses 'START'. ///
- /// Set from Quest->Audio->SFX Data. ///
- ///---------------------------{ D1: Delay Time }---------------------------///
- /// D1: Length of time, between pressing start, and the game starting. ///
- /// Time this to match your SFX, where 60 = 1-second. ///
- /// (240, would therefore be four-seconds, and is my default value.) ///
- ///----------------------{ D2/D3: Warp Destinations }----------------------///
- /// D2: If using a direct warp, set this to the DMAP number for the warp ///
- /// (not the 'Map' number, but the 'DMAP' number), stating at 0. ///
- /// D3: If using direct warps, set this to the screen number for the ///
- /// warp destination. This will use WARP RETURN 'A'. ///
- ///------------------------{ D4: Secret Warp Mode }------------------------///
- /// D4: If you are going to use a SENSITIVE WARP tile, placed under the ///
- /// player, to control the warp (and thus, control fade effects), then ///
- /// set this to a value of '1' (or greater). Set warp destinations from ///
- /// Screen->Tilewarp, and set your tile warp combo in Screen->Secrets, as ///
- /// SECRET TILE 0, then place Flag-16 over where the player is caged on ///
- /// your title screen. ///
- //////////////////////////////////////////////////////////////////////////////
- ffc script titleScreen {
- void run(int SFX, int timeValue, int W_DMAP_NUMBER, int W_SREEN_NUMBER, int secrets) {
- Link->InputStart = false; //present subscreen from falling.
- bool waiting = true; //Establish main while loop.
- bool pressed = false; //Establish timer requirements.
- int timer = 0; //Set timer to exist.
- if ( GetDifficulty() < 1 ) SetDifficulty(difficultyMenu());
- while(true){ //The main while loop
- //This was our old start screen code. We will be integrating the
- //value of the menu choice into it.
- if (Link->InputStart || ( DIFF_AUTOSTART && GetDifficulty() > 0 ) && !pressed ) { //Is the player presses START
- Waitframes(5); //Sound delay.
- Link->InputStart = false; //Keep subscreen from falling.
- pressed = true; //Initiate countdown timer.
- if ( SFX ) Game->PlaySound(SFX); //Play SFX set in D0.
- }
- if(pressed){ //Run Timer
- timer++; //Timer counts up, until it reaches amount set in D1.
- }
- if(timer >= timeValue){ //if timer is equal to, or greater than value of D1.
- if ( secrets > 0 ) { //If D4 is set to 1 or higher...
- Screen->TriggerSecrets(); //Trigger secret combos. Use this if using a warp combo.
- }
- else { //If D4 is set to 0, and we are using direct warps...
- Link->Warp(W_DMAP_NUMBER, W_SREEN_NUMBER); //Warp Link to the DMAP set in D2, and the screen set in D3, using Warp Return A.
- }
- }
- Waitframe(); //Pause, to cycle the loop.
- }
- }
- //Called by the ffc. Opens the difficulty select menu if no difficulty has been set.
- int difficultyMenu(){
- //These are the strings that we will be using. Each is given a
- //'choice' value. These values will be returned to the interface,
- //when selected.
- int line1[]="@choice(1)@tab(6)Easy@26@26";
- int line2[]="@choice(2)@tab(6)Normal@26@26";
- int line3[]="@choice(3)@tab(6)Hard@26@26";
- int line4[]="@choice(4)@tab(6)Insane@domenu(1)@suspend()";
- //This set of calls generates the Tango bitmap, parsing the strings
- //and drawing them.
- SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_1, 16, 16, SIZE_DIFFMENU);
- Tango_SetSlotPosition(WINDOW_SLOT_1, DIFF_MENU_X_POS, DIFF_MENU_Y_POS);
- Tango_LoadString(WINDOW_SLOT_1, line1);
- Tango_AppendString(WINDOW_SLOT_1, line2);
- Tango_AppendString(WINDOW_SLOT_1, line3);
- Tango_AppendString(WINDOW_SLOT_1, line4);
- Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_STYLE_BACKDROP_TILE, DIFF_MENU_TILE);
- Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_STYLE_BACKDROP_WIDTH, DIFF_MENU_WIDTH);
- Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_STYLE_BACKDROP_HEIGHT, DIFF_MENU_HEIGHT);
- Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_STYLE_TEXT_FONT, TANGO_FONT_LTTP_SMALL);
- Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_STYLE_MENU_CURSOR_COMBO, DIFF_MENU_CURSOR_COMBO);
- Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_STYLE_MENU_CURSOR_CSET, DIFF_MENU_CURSOR_CSET);
- Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_STYLE_MENU_CURSOR_WIDTH, DIFF_MENU_CURSOR_WIDTH);
- Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, DIFF_MENU_CURSOR_MOVE_SFX);
- Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_STYLE_MENU_SELECT_SFX, DIFF_MENU_CURSOR_SELECT_SFX);
- //Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_TILE_X, 40);
- //Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_TILE_Y, 10);
- //Tango_SetStyleAttribute(WINDOW_STYLE_1, TANGO_STYLE_MENU_CANCEL_SFX, 46);
- //This activates the slot, drawing it to the screen.
- Tango_ActivateSlot(WINDOW_SLOT_1);
- while(!Tango_MenuIsActive()){
- Waitframe();
- }
- int slotState[278];
- int menuState[960];
- int cursorPos;
- Tango_SaveSlotState(WINDOW_SLOT_1, slotState);
- Tango_SaveMenuState(menuState);
- bool done = false; //Handles determinaton on closing the menu.
- int choice; //Handles the choice input for the menu/
- //This handles cursor movement, and selection.
- while(true){
- while(Tango_MenuIsActive()){
- cursorPos=Tango_GetMenuCursorPosition();
- Waitframe();
- }
- choice=Tango_GetLastMenuChoice();
- //SetDifficulty(choice); //Set the difficulty mode based on the choice.
- if ( choice > 0 ) { done = true; }
- if ( done ) {
- Waitframes(MENU_SELECT_SFX_DURATION);
- break;
- }
- else {
- //Refreshes the bitmap.
- Tango_RestoreSlotState(WINDOW_SLOT_1, slotState);
- Tango_RestoreMenuState(menuState);
- Tango_SetMenuCursorPosition(cursorPos);
- }
- Waitframe();
- }
- Tango_ClearSlot(WINDOW_SLOT_1); //clear the menu.
- return choice;
- }
- }
- //The global active script.
- global script activeslot
- {
- void run()
- {
- StartGhostZH();
- while (true)
- {
- UpdateGhostZH1();
- if ( Game->GetCurDMap() == START_SCREEN_DMAP ) {
- if ( Game->GetCurScreen() == START_SCREEN_SCREEN ) {
- if ( PRESS_START_TEXT_DISPLAY &&
- ( ( DIFF_AUTOSTART && !GetDifficulty() ) || !DIFF_AUTOSTART )
- )
- { BlinkText(); }
- if( ( Link->PressA || Link->PressStart ) && !Tango_SlotIsActive(WINDOW_SLOT_1))
- StartMenu();
- }
- }
- Tango_Update1(); //Do initial Tango bitn=map updating.
- TestDifficulty(); //Press Ex1/Ex2 to modify the present setting, to test them.
- ReduceBuffTimers();
- LinksAwakeningItems();
- DifficultyAdjust(); //Handles adjusting npc values for difficulty settings.
- Waitdraw();
- UpdateGhostZH2();
- Tango_Update2(); //Post Waitdraw refreshing.
- Waitframe();
- }
- }
- }
- //Called by the global active script, if the game is on the title screen.
- void StartMenu(){
- int args[8]={START_SCREEN_SFX,START_SCREEN_DELAY,START_SCREEN_WARP_TO_DMAP,START_SCREEN_WARP_TO_SCREEN,0,0,0,0};
- int ff[]="titleScreen";
- int f = Game->GetFFCScript(ff);
- RunFFCScript(f, args); // Menu script
- }
- //A test function to determine if npc values are changing.
- void TestDifficulty(){
- if ( Link->PressEx1 && GetDifficulty() > DIFF_EASY ) {
- SetDifficulty( GetDifficulty() - 1 );
- }
- if ( Link->PressEx2 && GetDifficulty() < DIFF_HARD+1 ){
- SetDifficulty( GetDifficulty() + 1 );
- }
- if ( DRAW_DIFFICULTY ) Screen->DrawInteger(7,0,0,2,0x01, 0, -1, -1, GetDifficulty(), 0,128);
- }
- //Adjusts the npc difficulty based on the global setting.
- void DifficultyAdjust(){
- //Difficulty adjustment
- if ( GetDifficulty() != DIFF_MED ){ //If not medium (default)
- //Check each enemy
- for ( int i = Screen->NumNPCs(); i > 0; i-- ){
- npc enem = Screen->LoadNPC(i);
- //If difficulty not adjusted
- if ( enem->Misc[NPC_MISC_DIFF] == 0 ){
- if ( GetDifficulty() == DIFF_EASY ){ //Easy
- //Can't set health or damage lower than 1
- enem->HP = Max(enem->HP * .5, 1); //HP = 50%
- enem->Damage = Max(enem->Damage * .5, 1); //Damage = 50%
- enem->WeaponDamage = Max(enem->WeaponDamage * .5, 1); //WeaponDamage = 50%
- enem->Step *= .85; //Step speed = 85%
- }
- else if ( GetDifficulty() == DIFF_HARD){ //Hard
- enem->HP *= 1.5; //HP = 150%
- enem->Damage *= 2; //Damage = 200%
- enem->WeaponDamage *= 2;
- enem->Step *= 1.2; //Step speed = 120%
- }
- else if ( GetDifficulty() == DIFF_INSANE ) { //Insane (!!!!!)
- enem->HP *= 1.5; //HP = 150%
- enem->Damage *= 3; //Damage = 400%
- enem->WeaponDamage *= 4; //WeaponDamage = 400%
- enem->Step *= 1.5; //Step speed = 150%
- enem->Haltrate += 2; //Halt/fire rate increased by 2
- }
- enem->Misc[NPC_MISC_DIFF] = 1; //Mark as adjusted
- }
- }
- }
- }
- //Generates Blinking 'Press Start' text on the title screen.
- void BlinkText(){
- int ps[]="Press Start";
- //____GlobRAM[BLINK_TEXT]--;
- if ( ____GlobRAM[BLINK_TEXT] <= 0 )
- ____GlobRAM[BLINK_TEXT] = PRESS_START_TEXT_BLINK;
- if ( ____GlobRAM[BLINK_TEXT]-- > BLINK_INTERVAL1 && ____GlobRAM[BLINK_TEXT] < BLINK_INTERVAL2 ) {
- Screen->DrawString(PRESS_START_TEXT_LAYER,
- PRESS_START_TEXT_X, PRESS_START_TEXT_Y,
- PRESS_START_TEXT_FONT, PRESS_START_TEXT_COLOUR,
- PRESS_START_TEXT_BGCOLOUR, PRESS_START_TEXT_FORMAT,
- ps, PRESS_START_TEXT_OPACITY);
- }
- }
- //Accessors
- void SetDifficulty(int diff){
- ____GlobRAM[DIFFICULTY_SETTING] = diff;
- }
- int GetDifficulty(){ return ____GlobRAM[DIFFICULTY_SETTING]; }
- //Tango Functions
- void SetUpWindow(int slot, int style, int x, int y, int size)
- {
- SetStyleSize(style, size);
- Tango_ClearSlot(slot);
- Tango_SetSlotStyle(slot, style);
- Tango_SetSlotPosition(slot, x, y);
- }
- void ShowString(int string, int slot, int style, int x, int y)
- {
- SetUpWindow(slot, style, x, y, SIZE_LARGE);
- Tango_LoadString(slot, string);
- Tango_ActivateSlot(slot);
- while(Tango_SlotIsActive(slot))
- Waitframe();
- }
- void SetCommonStyleData(int style)
- {
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TYPE, TANGO_BACKDROP_TILE);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_CSET, 0);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_FONT, TANGO_FONT_MATRIX);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_CSET, 0);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_COLOR, 1);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_X, 8);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_Y, 8);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_SPEED, 2);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_SFX, 105);
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_COMBO, 888);
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_CSET, 0);
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_WIDTH, 8);
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_SELECT_SFX, 44);
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CANCEL_SFX, 46);
- }
- void SetStyleSize(int style, int size)
- {
- if(size==SIZE_DIFFMENU)
- {
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 39000);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 3);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 4);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 60);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 24);
- }
- if(size==SIZE_SMALL)
- {
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 29380);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 8);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 3);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 112);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 24);
- }
- else if (size==SIZE_WIDE)
- {
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 29440);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 14);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 3);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 112);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 24);
- }
- else
- {
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 104);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 29768);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 8);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 5);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 112);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 64);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement