In-game tutorial...?

Started by Bandersnatch, Tue 22/01/2013 22:00:19

Previous topic - Next topic

Bandersnatch

Hi,

I'm interested in building a tech demo/intro for a game I'm returning to, that features an in-game tutorial. The idea is as follows:

The game contains a classic Lucasarts 9 Verb GUI, and each verb is covered in the tutorial. This would be done by an NPC giving the player various instructions in relation to each verb in succession. The next verb does not become available until the current instruction is passed. Every 20(?) seconds or so, the NPC repeats the instruction if the player has not done as instructed.

I imagine this could be done by using the counter function - would I be right? And if so, how would I structure the scripting? I'm a serious noob.

Thanks guys.

MurrayL

#1
I did something almost exactly like what you describe at the start of Astroloco (check out the demo here to see it in action at the start of Act 1).

I'd do it like this:

Code: AGS

// Room script
int tutorialState = 0;

function room_AfterFadeIn(){
    if(tutorialState == 0){ // Tutorial hasn't been started yet, so start it
        Display("Hey! You should interact with that hotspot in some meaningful way!");
        tutorialState = 1;
        SetTimer(1, 400); // 10 second timer, GO!
    }
}

function repeatedly_execute(){
    if(IsTimerExpired(1)){
        if(tutorialState==0){
            Display("Reminder");
        }else if(tutorialState==1){
            Display("A different reminder");
        }else if(tutorialState==2){
            Display("Hopefully you get the idea now");
        }
    }
}

function hMeaningfulThing_Look(){
    Display("Awesome! You win at adventure games!");

    if(tutorialState==1){
        Display("Now you should totally do that other cool thing that you can do!");
        tutorialState = 2;
        SetTimer(1, 400); // 10 second timer, GO AGAIN!
    }
}


Fill in more event handlers as you need to, to complete the tutorial. To end the tutorial (at the end, or on room_leave, for example), just stop the timer ( SetTimer(1, 0); ) and set tutorialState to its final number. To reset it, set tutorialState back to 0.

Optional expert difficulty:
You can make the tutorial more readable by replacing the 'raw' numbers of the tutorialState variable with an enumerator at the top of the script like this:

Code: AGS

enum TutorialStates{
eLookAtThing,
eOpenOtherThing,
eTalkToNPC,
...
}; 


Now, instead of 'if(tutorialState==1)', you can use 'if(tutorialState==TutorialStates.eLookAtThing)'. It's longer, but you can use auto-complete, and it makes reading it back later a hell of a lot easier.

Bandersnatch

Thanks Murray! I'll give your demo a look and try applying the format to my demo - once the programming is tight and the artwork/animation is finished I'll give ya a heads up!

MurrayL

Oh, I forgot to add, but I'm sure you can work it out - to make the verbs only appear as they are introduced, simply disable all the verb GUI controls in game_start(), and then re-enable them one-by-one as the tutorial progresses.

Don't forget to make sure they're all turned on if the player skips the tutorial, though!

Bandersnatch

Great idea that last one - though this won't be a skippable tutorial...It'll serve as the beginning of the story and is hopefully integrated fairly seamlessly.

Now, the next step...draw everything!

Bandersnatch

Okay so another question, how can I make the NPC repeat the reminders until I fulfill the objective? After they've said the reminder once, nothing happens.

Also I've had to use room_RepExec() rather than repeatedly_execute. will that be a problem?

MurrayL

Aha - yep, just scrolled back up to my code snippets and saw the problem (I didn't test any of it before posting, sorry).

In room_RepExec, you'll need to reset the timer after the set of if statements, e.g.:

Code: AGS

function repeatedly_execute(){
    if(IsTimerExpired(1)){
        if(tutorialState==0){
            Display("Reminder");
        }else if(tutorialState==1){
            Display("A different reminder");
        }else if(tutorialState==2){
            Display("Hopefully you get the idea now");
        }
        SetTimer(1, 400); // Set the timer back to 10 seconds
    }
}


This makes sure that the reminder timer is reset every time a reminder is given.

And yes, room_RepExec is quite probably the correct function name - just use whatever you're given when you add a 'repeatedly execute' event through the room's properties panel ;)

Bandersnatch

looooool yeah as soon as I'd posted that I thought "let's try this really obvious potential solution" and lo and behold! It worked. I really should stop panicking and asking so many questions so quickly...

SMF spam blocked by CleanTalk