[SOLVED] Change/disable certain things when inventory item was used

Started by Yoru Chinmoku, Thu 24/04/2014 10:41:39

Previous topic - Next topic

Yoru Chinmoku

Hey there!

I didn't find an answer to my question, and I couldn't figure it out all alone.
I don't even know if it actually works :-\

I wonder if it's possible to change (or/and disable) certain things, when an certain inventory item was used.

To explain it a little better;
cEgo uses iRedmarker on cChar1
cChar1 gets angry, telling cEgo to get out of the room, the game restarts

That's working just fine.

cEgo uses iBlacktape on cChar1
cChar1 has his mouth covered with the black tape

Works fine as well.
But now
cEgo uses iRedmarker AFTER he used iBlacktape
cChar1 will have red drawings in his face, the game continues
Every dialog of cChar1 is disabled (or changed), because his mouth is covered by the black tape (= he's unable to speek)


Is something like that even possible? :-D

I'd just make a whole new room, cChar1 having his mouth covered. And make the same hotspots, same objects, etc. like in the actual room. But change everything a little bit (e.g. no dialogs with cChar1). And if cEgo uses iBlacktape on cChar1, he'll be moved to this new room.
But that's pretty much work (not too much though, since I really want to make that game for a friend).
So, I wanted to ask if there's a more simple way to do that? :)
ãâ,¬Å'京さんと邪神様ãâ,¬ÂÃ£â,¬â,¬Ã£Æ'ȋÆ'ȋÆ'ȋâ,¬â,¬Ã¥Æ'•ã®å‘½

AnasAbdin

This is easily solved with if statements.

Code: ags

function cChar1_UseInv()
{
    if ( cEgo.ActiveInventory == iBlacktape )
    {
        cChar1.ChangeView(x); //x is the view number with cChar1 having the black tape on...
        //or animate a specific loop in the same view...
        return;
    }

    if ( cEgo.ActiveInventory == iRedmarker )
    {
        if ( cChar1.View == x ) //x is the view number with cChar1 having the black tape on...
                                            //or in case you are using loops: if ( cChar1.Loop ==...)
            {
                cChar1.ChangeView(y); //y is the view number with cChar1 having the red marks...
                //or animate a specific loop in the same view...
                return;
            }
        else
            {
                //whatever...
                return;
            }
    }
}


So now when you talk to cChar1, the first thing is you have to check his view number to determine what dialog you want to use.

Yoru Chinmoku

Thank you very much, AnasAbdin :)
I tried it immediatly, and it's working perfect!

Now I feel stupid for not coming to this idea earier haha (laugh)
ãâ,¬Å'京さんと邪神様ãâ,¬ÂÃ£â,¬â,¬Ã£Æ'ȋÆ'ȋÆ'ȋâ,¬â,¬Ã¥Æ'•ã®å‘½

Khris

In general, this is done with variables. Whenever you can use some built-in, existing property that actually reflects the change, use that (like the View of a Character).
But in other cases, when you simply want to store the game state, you use variables.

Code: ags
// declare boolean room variable, can only be true or false
bool tape_on_mouth = false;

function cChar1_UseInv() {
  if (player.ActiveInventory == iBlackTape) {
    ...
    tape_on_mouth = true;
  }
  if (player.ActiveInventory == iRedMarker) {
    if (tape_on_mouth) {  // short for: if (tape_on_mouth == true)
      ...
    }
    else {
      ...
    }
  }
}


You can also create global variables that can be accessed and changed in every room. That's what the Global Variables pane is for.

SMF spam blocked by CleanTalk