Topic: Special stage object

This objects allows you to implement a special stage in your games. If you finish the level with 50 or more rings, it will load a special stage. It's neccesary to create a "special stage object" for every special stage.


- Level config

//Object for special stage 1
object ".1tspecial"
{
    requires 0.2.0
    always_active
    state "main"
    {
        let "$_special = 1"
    }
}

//Object for special stage 2
object ".2tspecial"
{
    requires 0.2.0
    always_active
    state "main"
    {
        let "$_special = 2"
    }
}

//Object for special stage 3
object ".3tspecial"
{
    requires 0.2.0
    always_active
    state "main"
    {
        let "$_special = 3"
    }
}

//ADD MORE IF YOU NEED

//Launcher
object "special_launcher"
{
    requires 0.2.0
    always_active

        //Check which special will launch
    state "main"
    {
        if "$_special == 1" "t1"
        if "$_special == 2" "t2"
        if "$_special == 3" "t3"
                //ADD MORE IF YOU NEED
    }

        //Launchers for every level
    state "t1"
    {
        push_quest "quests/special_stage_t1.qst"
        change_state "finish"
    }
    
    state "t2"
    {
        push_quest "quests/special_stage_t2.qst"
        change_state "finish"
    }

    state "t3"
    {
        push_quest "quests/special_stage_t3.qst"
        change_state "finish"
    }

       //ADD MORE IF YOU NEED

    state "finish"
    {
        destroy
    }
}    

-- Level launcher:

object "special_state_launcher"
{
    requires 0.2.0
    hide_unless_in_editor_mode
    category "CustomCont"

    state "main"
    {
        set_animation "SD_RING" 0
        on_level_cleared "launch"
        let "$_globalVar=112"
    }
        
    state "launch"
    {
        if "collectibles() >= 50" "wait"
        change_state "finish"
    }

    state "wait"
    {
         show_dialog_box "<color=00ff00>+50 RINGS!</color>" "GET READY FOR <color=ff0000>SPECIAL STAGE! </color> (Please don't press ENTER...)"
        on_timeout 8 "push"
    }

    state "push"
    {
        add_lives "200"
        create_child "special_launcher"
        change_state "finish"
    }

    state "finish"
    {
        destroy
    }

}

Finally we need an object to jump and go to the next level of the quest, because if we simply pop_quest, we will start again the same level. That's why I added the strange condition "add 200 lives". See:

-- Jumper:

object ".go_special"
{
    requires 0.2.0
    always_active

    state "main"
    {
        hide
       if "lives() >= 200" "next_level"
        destroy
    }

    state "next_level"
    {
        add_lives  "-200"
        next_level
    }
}

If you start a level with 200 lives of more, it means you come from a special level, and that means that the player has completed already the level the game is going to load, so we skip it -and load the next level.

The special stage should contain a object which pop_quest at the end. For example, here's an special stage where the player has to get 100 rings to win:

object "extra1_stage"
{
    requires 0.2.0
    hide_unless_in_editor_mode
    always_active
    category "special_stage"

    state "main"
    {
        set_animation "SD_RING" 0
        if "collectibles() >= 100" "win"
        on_level_cleared "lose"
        on_player_death "lose"
    }
        

    state "win"
    {
        disable_player_movement
                //The dialog creator shows a dialogbox depending on which stage we are. Not neccesary for your game :D
        create_child "dialog_creator" 
        on_timeout 4.5 "pop"
    }

    state "lose"
    {
        disable_player_movement
         show_dialog_box "<color=ff0000>FAILED!</color>" "Try again!(Please don't press ENTER...)"
        on_timeout 2.5 "pop"
    }
    

    state "pop"
    {
        pop_quest 
        change_state "finish"
    }

    state "finish"
    {
        enable_player_movement
        destroy
    }

}

The startup of your special level should be

startup ".default_startup" "extra1_stage"

and the NORMAL level has to be

startup ".go_special" ".1tspecial" ".default_startup" 

.

And that's all smile

Last edited by TheSeventhEmerald (2015-10-24 13:52:41)

Piece of cake...!

Re: Special stage object

That's really cool, TheSeventhEmerald. cool

What if, in your special stage, you set at startup a global variable telling the user has just entered a special stage. Perhaps the logic could be simplified?

the special stage object sets a global variable telling that the user has just entered a special stage. Then, in your main quest, acessible after pop_quest, you check if this global is on (in a startup object). If it is, you disable it and go to the next level automatically.

The startup of your special levels could be

startup .default_startup .special_stage_startup

The startup of your regular levels could be

startup .default_startup .special_stage_startup .1tspecial

Re: Special stage object

Alexandre wrote:

That's really cool, TheSeventhEmerald. cool

What if, in your special stage, you set at startup a global variable telling the user has just entered a special stage. Perhaps the logic could be simplified?

the special stage object sets a global variable telling that the user has just entered a special stage. Then, in your main quest, acessible after pop_quest, you check if this global is on (in a startup object). If it is, you disable it and go to the next level automatically.

The startup of your special levels could be

startup .default_startup .special_stage_startup

The startup of your regular levels could be

startup .default_startup .special_stage_startup .1tspecial

I know this is way later, but i did not know you could have multiple startup scripts, i just learned something. tongue

Last edited by aronthehedgehog (2015-11-26 20:37:57)

www.facebook.com/24XFSAL  Hasn't been updated anytime recently, don't bother.
I'm on SoundCloud: https://soundcloud.com/rain-new-holy - I plan to upload one soon.
Name change from 24XFSAL coming soon. Currently studying for Information Technology and Game development. (Also studying game theory in spare time.)