Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Custom Link Death Animation
- //ZoriaRPG
- int LinkInvisibleEvents[20]; //An array to store the conditions that cause Link to be invisible.
- //THese could all be binary flags in one array index, but that is *potentially* slower.
- const int INVIS_DYING = 1; //an invisible cause condition.
- const int FFC_LINK_DEATH_DATA = 100; //Freeze all, except ffcs.
- const int SFX_DEATH = 0; //Death Sound
- const int MUS_DEATH_STRING = 1000; //String ID of Death Music Filename
- const int MUS_DEATH_TRK = 1; //Track of enhanced music file to play.
- const int MIDI_DEATH = 50; //Fallback MIDI if the music file is missing, or corrupt.
- const int DEATH_ANIM_DUR = 3; //cycles of frames * number_of * this, so 3 == 240 frames.
- const int DEATH_ANIM_FRAMES_PER_TILE = 10; //The number of frames each tile state of the death animation is sequentially drawn.
- const int DEATH_ANIM_TILE_BASE = 12000; //The base tile of the death sequece/
- const int DEATH_ANIM_TILE_NUMBER_OF = 8; //8 tiles?
- const int DEATH_RECT_LAYER = 7; //Should be 7.
- const int DEATH_RECT_X = 0; const int DEATH_RECT_X2 = 256;
- const int DEATH_RECT_Y = 0; const int DEATH_RECT_Y2 = 176;
- const int DEATH_RECT_COLOUR = 0x01; //Set colour here.
- const int DEATH_RECT_SCALE = 100;
- const int DEATH_RECT_RX = 0; const int DEATH_RECT_RY = 0; const int DEATH_RECT_RANGLE = 0;
- const int DEATH_RECT_OPACITY = 64;
- const int DEATH_LINK_LAYER = 7; //Should be 7 and enqueued to draw over the fade rect.
- const int SPRITE_DEATH_WINK_OUT = 70; //Weapon Sprite of Death Wink Out
- const int LINK_CONTINUE_HEALTH_PERCENT = 100; //Percentage of HP to restore on death
- const int LINK_CONTINUE_MAGIC_PERCENT = 100; //Percentage of MP to restore on death
- //IsInvisible(LinkInvisibleEvents);
- void IsInvisible(int ptr){
- for ( int q = SizeOfArray(ptr); q > 0; q-- ){
- if ( ptr[q] ) Link->Invisible = true;
- return;
- }
- Link->Invisible = false;
- }
- //Sets a single invisible cause condition.
- void IsInvisible(int ptr, int indx, bool state){
- if ( state ) ptr[indx] = 1;
- else ptr[indx] = 0;
- }
- //Checks if a specific source for invisibility is enabled.
- bool IsInvisible(int ptr, int indx){
- return (ptr[indx] != 0);
- }
- //Sets Link as Not Invisible, disabling all Invis Flags
- void NotInvisible(int ptr){
- for ( int q = SizeOfArray(ptr); q > 0; q-- ){
- ptr[q] = 0;
- }
- Link->Invisible = false;
- }
- //Link Death Animation Sequence
- ffc script FFC_LinKDeath{
- //Play the death music.
- int mus[200]; //change filename as needed.
- Game->GetMessage(MUS_DEATH_STRING, mus);
- for ( int q = 199; q > 0; q-- ) {
- if ( mus[q] == ' ' ) mus[q] = 0; //Trim the trailing spaces.
- else break;
- }
- if ( !Game->PlayEnhancedMusic(mus,MUS_TRK_DEATH) ) { //if the enhance music file is absent,
- Game->PlayMIDI(MIDI_DEATH); //play the fallthrough midi.
- }
- int til[4]; //Array to hold animation variables.
- til[0] = DEATH_ANIM_TILE_BASE;
- //til[1] = 0; // count
- til[2] = 1; //layers
- til[3] = 128; //Link death tile opacity
- for ( int q = ( DEATH_ANIM_DUR * DEATH_ANIM_FRAMES_PER_TILE * DEATH_ANIM_TILE_NUMBER_OF ) ; q > 0; q-- ) {
- //Fade to Red
- if ( q % ( DEATH_ANIM_DUR * DEATH_ANIM_FRAMES_PER_TILE ) == 0 ) {
- tile[2]++; //Every leg of the process, add another layer to the red fade.
- }
- for ( int w = til[2]; w > 0; w-- ) {
- Screen->Rectangle(
- //Red or other fade colour rect.
- DEATH_RECT_LAYER, DEATH_RECT_X, DEATH_RECT_Y, DEATH_RECT_X2, DEATH_RECT_Y2,
- DEATH_RECT_COLOUR, DEATH_RECT_SCALE,
- DEATH_RECT_RX, DEATH_RECT_RY, DEATH_RECT_RANGLE,
- true, DEATH_RECT_OPACITY
- );
- }
- if ( q % DEATH_ANIM_FRAMES_PER_TILE == 0 ) til[1]++; //Increment the tile used by the draw.
- if ( til[1] >= DEATH_ANIM_TILE_NUMBER_OF ) til[1] = 0; //or reset and rollover to base tile.
- if ( q <= DEATH_ANIM_FRAMES_PER_TILE * DEATH_ANIM_TILE_NUMBER_OF ) til[3] = 64; //Fade Link
- //Draw Link Spinning
- //This, alternatively, could be a weapon sprite, however, that still requires drawing the
- //weapon tile to the proper layer, and in the correct enqueueing order.
- Screen->DrawTile
- ( DEATH_LINK_LAYER, Link->X, Link->Y,
- DEATH_ANIM_TILE_BASE + til[1], 1, 1,
- DEATH_ANIM_TILE_CSET, -1, -1,
- 0, 0, 0,
- 0,
- true, til[3]
- );
- Waitframe(); continue();
- }
- //Draw Win Out Sprite
- lweapon dsprite = Screen->CreateLWeapon(LW_SPARKLE);
- dsprite->HitYOffset = -1000;
- dsprite->X = Link->X;
- dsprite->Y = Link->Y;
- //Do menu here.
- int choice = DeathMenu();
- if ( choice == 1 ) {
- //Quit
- Game->End();
- }
- if ( choice == 2 ) {
- //Save
- Game->Save();
- Game->End();
- }
- if ( choice == 3 ) {
- //Continue
- //Needs custom reload function **callback signal** to the global active script.
- }
- }
- //The menu function ( template, at this time ).
- int DeathMenu(){
- int choice;
- //Draw the menu here. Are you using Tango?
- return choice;
- }
- //Mandatory to clear some variables on reload.
- global script OnContinue(){
- void run(){
- Resume_Ghost_ZH();
- NotInvisible(LinkInvisibleEvents);
- }
- }
- //Called if Link factually dies, and we want to run the custom death sequence.
- void LinKDeath(){
- Suspend_Ghost_ZH();
- ffc f; int ff[]="FFC_LinKDeath";
- Link->HP = Lin->MaxHP;
- for ( int q = 32; q > 1; q-- ) {
- f = Screen->LoadFFC(q);
- if ( q->Data == 0 ) {
- if ( q->Script == 0 ) {
- f-Data = FFC_LINK_DEATH_DATA;
- f->Script = Game->GetFFCScript(ff);
- }
- }
- }
- }
- //Call before Waitdraw
- void DoDeath(){
- if ( Link->HP <= 0 ) { LinkDeath(); }
- }
- //Example structure and procedure for a continue game function.
- //This clearly would never compile as-is. --Lazy
- void ContinueGame(){
- Screen->Rectangle(//black)]
- OpeningWipe();
- Link->HP = ( Link->MaxHP / 100 ) * LINK_CONTINUE_HEALTH_PERCENT;
- Link->MP = ( Link->MaxMP / 100 ) * LINK_CONTINUE_MAGIC_PERCENT;
- Link->Warp(LastEntranceDMap,LastEntranceScreen);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement