GameMaker Transition from one stage to the next.

Hi

I've been having trouble with an aspect of my game. There levels of which each is level is made of 4 stages and a Boss stage.
For each stage you must fight a mini-boss. It is set up so that boss fades away when he is finished. The problerm is sort of
logistic. I want the boss to fade away, but somehow the boss is invisible and the stage invisible. I think. I think I need to
change the way the boss end game comes about. So I'm going to show some code and maybe get some suggestions?
ALso I didn't mention that it isn't consistent. Sometimes I beat the boss and just get zapped back to the game map. The boss
usually fades away. But sometimes it just vanishes and it doesn't transition to either the game map or the next stage. This is a
major part of the game that isn't finished. I could really use some help.

I'll give you the code for the transition from one stage or one level below:

This is the boss transition code (when the boss has died)

GML:
if (hp <= 1000)
{
    if (image_alpha >= 0)
    {
        image_alpha -= 0.01;
    }
        //GO ONTO THE NEXT LEVEL
    show_debug_message("Global Game Map is " + string(global.game_map));
    room_persistent = false;
    
      
    
    with (PharoahObject)
    {
        show_debug_message("In PharoahObject")   
        
        sprite_index = FrankensteinYouWin;
        //audio_stop_sound(ConsumingShadows);
        show_debug_message("completed level1 false, completed level2 true");
        //if (global.game_win_flag == false)
        //{
            audio_stop_all();
            audio_play_sound(WinMusic, 10, false);
            global.completed_level1 = false;
            global.completed_level2 = false;
            global.completed_level3 = false;
            global.completed_level4 = false;
            global.completed_level5 = false;
            global.completed_level6 = true;
            global.completed_level7 = false;               
            global.completed_level8 = false;               
            global.completed_level9 = false;               

            global.completed_level0 = false;
            global.completed_level11 = false;
            global.completed_level12 = false;
            sprite_index = FrankensteinYouWin;
                
            if hp <= 0 //And whatever other conditions / timers / effects etc etc that need to finish before transitioning
            {
                if !room_change
                {
                    room_change = true;
                    scr_transition();
                }
            }
    
                
                //with (LumberjackDracula)
                //{
                    //show_debug_message("DraculaWin");
                    sprite_index = DraculaWin
                //}
            //}
        }
You see the scr_transition()? That loads up the next stage:

audio_stop_all()
var target = noone;
global.game_map++;

switch(global.game_map)
{

case 1: target = FirstLevel; break;
case 2: target = FirstLevel1B; break;
case 3: target = FirstLevel1C; break;
case 4: target = FirstLevel1D; break;
case 5: target = FirstLevelBOSS; break;
//case 6: target = GrasslandToForestMap; break; //travel to forest map
//case 6: target = ; break; ///ForestMap
//case 6: target = VideoMap; break;
case 6: target = GrasslandToForestMap;break;

case 7: target = SecondLevel; break;
case 8: target = SecondLevelB; break;
case 9: target = SecondLevelC; break;
case 10: target = SecondLevelD; break;
case 11: target = SecondLevelBOSS; break;
case 12: target = ForestToSnowMap; break; //forest map travel to snow map

case 20: target = ThirdLevel; break;
case 21: target = ThirdLevelB; break;
case 22: target = ThirdLevelC; break;
case 23: target = ThirdLevelD; break;
case 24: target = ThirdLevelBOSS; break;
case 25: target = SnowToLavaMap; break; //LavaMap

case 30: target = FourthLevel;break;
case 31: target = FourthLevelB;break;
case 32: target = FourthLevelC;break;
case 33: target = FourthLevelD;break;
case 34: target = FourthLevelBOSS;break;
case 35: target = LavaToJungleMap; break; //JungleMap

case 40: target = FifthLevel; break;
case 41: target = FIfthLevelB; break;
case 42: target = FifthLevelC; break;
case 43: target = FifthLevelD; break;
case 44: target = FifthLevelBOSS; break;
case 45: target = JungleToDesertMap; break; //DesertMap

case 50: target = SixthLevel; break;
case 51: target = SixthLevelB; break;
case 52: target = SixthLevelC; break;
case 53: target = SixthLevelD; break;
case 54: target = SixthLevelBOSS; break;
case 55: target = DesertToLagoonMap; break; //LagoonMap

case 60: target = SeventhLevelB;break;//SeventhLevel; break;
case 61: target = SeventhLevelB; break;
case 62: target = SeventhLevelC; break;
case 63: target = SeventhLevelD; break;
case 64: target = SeventhLevelBOSS; break;
case 65: target = SwampToRuinsMap; break; //SwampMap

case 70: target = EightLevel; break;
case 71: target = EightLevelB; break;
case 72: target = EightLevelC; break;
case 73: target = EightLevel1D; break;
case 74: target = EightLevel1BOSS; break;
case 75: target = RuinsToStormMap;break; //RuinsMap

case 80: target = NinthLevel;break;
case 81: target = NinthLevelB;break;
case 82: target = NinthLevelC;break;
case 83: target = NinthLevelD;break;
case 84: target = NinthLevelBOSS;break;
case 85: target = RuinsToStormMap;break; //StormMap

case 90: target = TenthLevel; break;
case 91: target = TenthLevelB;break;
case 92: target = TenthLevelC;break;
case 93: target = TenthLevelD;break;
case 94: target = TenthLevelBOSS;break;
case 95: target = StormToSktyMap;break; //SkyMap

case 100: target = EleventhLevel;break;
case 101: target = EleventhLevelB;break;
case 102: target = EleventhLevelC;break;
case 103: target = EleventhLevelD;break;
case 104: target = EleventhLevelBOSS;break;
//case 105: target = SciFi;break; //SciFiMap
case 105: target = SkyToSciFiMap;break;

case 110: target = TwelfthLevel;break;
case 111: target = TwelfthLevelB;break;
case 112: target = TwelfthLevelC;break;
case 113: target = TwelfthLevelD;break;
case 114: target = TwelfthLevelBOSS;break;
//case 115: target = LastMap;break;
//case 116: target = OutsideTime;break;
//default: show_debug_message("Target is not being assigned a value as global.game_map was not set to one of the cases in the switch");
//default: target = GrasslandToForestMap;break;
}

room_goto(target);
//
//0 is the indicator , the map
//target is the map to go to

Thanks ahead of time and stay safe. :cool:
 

Nidoking

Member
You really need to remove those commented out lines. You're changing the same sprite_index three times in the same event, and the first two don't count.

If there's no PharoahObject with hp <= 0, there will be no transition. You haven't disclosed what conditions cause this event/script/block to execute, so maybe that's what's happening.
 
Yeah. Sorry about the comments I need to do cleanup duty on some of my scripts.

I admit this could be done more elegantly but it serves for the time being.

The Pharoah Object is a mini boss for the Desert Level's stages. As the player you can attack the Pharoah Object and do damage to its
hp. When the hp reaches 0 in the pharoah object it triggers the scr_transition script. So walk through example. I have a Sentry Bat available
to use. The enemy is attacking with the Desert Brain. You send your sentry to kill his desert brain. You send the sentry to attack the Pharoah
who is standing on the far right. After a few blows one of these things happens:

//stages
1. Sentry Bat deals damage to Pharoah. After a few blows, the Pharoah loses and fades away. You are transitioned to the next stage..

2. Sentry Bat deals damage to Pharoah. After a few blows, the Pharoah loses and fades away. The level doesn't end and you are stuck

3. Sentry Bat deals damage to Pharoah. After a few blows, the Pharoah loses but doesn't smoothly fade away but zaps to the next stage.

//BOSS

4. Sentry Bat deals damage to Desert BOSS. After a few blows, the Desert BOSS loses and fades away. You are transition to the game map.

5. Sentry Bat deals damage to Desert BOSS. After a few blows, the Desert BOSS loses and fades away. THe level doesn't end and you are stuck.

6. Sentry Bat deals damage to Desert BOSS. After a few blows, the Desert BOSS loses but doesn't smoothly fade away f but zaps and you are stuck.

I'd prefer stage types 1 and 4. But 1,2,3,4,5, and 6 are hapenning to various degrees.
 
Top