float Samus[214747]; const int ETANKS = 500; const int ETANKS_FULL = 501; int Etanks()return Samus[ETANKS];} int ETanksFilled(){return Samus[ETANKS_FULL];} void FillETanks(){ Samus[ETANKS_FULL] = Samus[ETANKS];} void UseEtank(){ Samus[ETANKS_FULL]--;} //Returns if Samus still hyas energy, refillng from etanks in the process, as needed. bool HasEnergy(){ if ( Link->HP <= 0 ){ if ( ETanksFilled() ) { Link->HP = Link->MaxHP; UseEtank(); return true; } return false; } else return true; } //Pickup script item script Etank{ void run(){ Samus[ETANKS]++; Samus[ETANKS_FULL]++; } } const int HP_REFILL_RATE =30; const int SFX_ETANK_REFILL = 60; //Refills hp and etanks void RefillHealth(bool silent) { Link->HP = Link->MaxHP; do { if ( !silent ) Game->PlaySound(SFX_ETANK_REFILL); Samus[ETANKS_FULL]++; if ( !silent ) Waitframes(HP_REFILL_RATE); } while ( ETanksFilled() < Etanks() ); } void ShowETanks(){ if ( Link->MP != EtanksFilled() *32 ) Link->MP = EtanksFilled() * 32; } int IsDead(){ return Samus[ISDEAD]; } void IsDead(bool state){ if (state) Metroid[ISDEAD] = 1; else Metroid[ISDEAD] = 0; } const int ISDEAD = 214746; global script Init{ void run(){ IsDead(false); } } global script OnContinue{ void run() { IsDead(false); } } global script Death{ void run(){ while( !IsDead() ){ Detect250_1_Phase1(); //Check to see if we are using 2.50.1... Detect250_1_Phase2(); //2.50.1 Checking confirmed to work at this point (v0.4.2) Detect250_2(); //Check for v2.50.2 ia Jumping mechanics. Version_Check_Cleanup(); if ( !HasEnergy() ){ Link->HP = Link->MaxHP; IsDead(true); break; } Waitdraw(); if ( DEBUG_VERSION_FUNCTIONS && Link->PressEx2 ) { //If debugging is on and Link presses Ex2 TraceNL(); //Put some useful traces in allegro.log. Trace(Version[ZC_VERSION]); } //Safety net post-waitdraw call: if ( !HasEnergy )){ Link->HP = Link->MaxHP; IsDead(true); break; } Waitframe(); } while ( IsDead() ) { //display screen, or do wipe Death(); //GAME OVER MENU Waitdraw(); Waitframe(); } } } void ResumeGame(){ ResumeGhostZHScripts(); } const int DEATH_WIPE_DUR = 120; //4 seconds const int MIDI_DEATH = 10; void Death() { SuspendGhostZHScripts(); int q; int radius = DEATH_WIPE_DUR; bool refilled; Samus->HP = Samus->MaxHP; WarpSamus( GetGameRestoreStation(), 0 ); InvertedCircle(1, 6, Link->X + 8, Link->Y, radius, -1, 0x0F); Game->PlaySound(SFX_MET_DEATH); for ( q = 0; q < DEATH_WIPE_DUR; q++ ) { Link->HP = Link->MaxHP; NoAction(); InvertedCircle(1, 6, Link->X + 8, Link->Y, --radius, -1, 0x0F); if ( Game->GetMIDI() != MIDI_DEATH ) Game-PlayMIDI(MIDI_DEATH); Waitframe(); } for ( q = 0; q < DEATH_WIPE_DUR; q++ ) { if ( !refilled ) { RefillHealth(true); refilled = true; } NoAction(); InvertedCircle(1, 6, Link->X + 8, Link->Y, ++radius, -1, 0x0F); Waitframe(); } }