Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Sun 13/02/2005 13:28:11

Title: Need help with global/character values, in paticular booleans [SOLVED]
Post by: on Sun 13/02/2005 13:28:11
My problem is thus: I need to make it so that my character can be either marked as human or cat (and no, there's no strange shape-shifting in this. I like the laws of physics) and depending on if the value is true or false, different things should react in different ways, such as the all he views changing between cat and human, or starting different topics. The player can't change constantly, just after certain triggers, such as the first time he puts on the suit. (cat --> human) I looked through the help and tutorial, but I'm still not quite sure how to do it. Any hints?
Title: Re: Need help with global/character values, in paticular booleans
Post by: DoorKnobHandle on Sun 13/02/2005 13:46:24
You'd realize things like this with variables.

You add a variable "int playerishuman = 1" which is 1 if the player is human and 0 if the player is a cat.

Then you change the characters appearance depending on this var.

If you have further questions, ask...
Title: Re: Need help with global/character values, in paticular booleans
Post by: on Sun 13/02/2005 13:54:04
I know the principle, but not the specifics.
Should it be character? Global?
What commands do I use, and where?
How do I structure the tree?
Can someone make me a short example?
Title: Re: Need help with global/character values, in paticular booleans
Post by: Scorpiorus on Sun 13/02/2005 13:55:46
Are you using the Interaction Editor commands or scripting it?
Title: Re: Need help with global/character values, in paticular booleans
Post by: DoorKnobHandle on Sun 13/02/2005 14:01:34
okok.

at the beginning of your script you add:


int playerishuman;


This introduces a global int variable which holds 0 or 1 depending on whether the player is a human or a cat right now.

Then you code the initial value of this var (lets say your player begins the game being a human...).

You add in the game_start func:


playerishuman = 1;


ok, then you have a inventory item which you can use and it changes your appearance...

so you go to the inventory item editor, select your item and click "on use:"

in this script you write simply:


if (playerishuman = 0)
{
Ã, playerishuman = 1;
Ã, SetCharacterView (EGO, NUM_OF_VIEW_WITH_PLAYER_AS_HUMAN);
}
else
{
Ã, playerishuman = 0;
Ã, SetCharacterView (EGO, NUM_OF_VIEW_WITH_PLAYER_AS_CAT);
}



which basically just changes the variable to 0 if its 1 or to 1 if it used to be 0 and then changes your view.

now you have this var set up correctly.

now lets say you want the player to only be able to do something if he's a cat. then you would write:


if (playerishuman == 0)
{
Ã, // what the player should do...
}


thats it.

hope it helps.
Title: Re: Need help with global/character values, in paticular booleans
Post by: on Sun 13/02/2005 14:05:00
Thanks. That's oh-so-helpful. I shall add your name to my credits list under "special thanks". And a thumbs-up.
Title: Re: Need help with global/character values, in paticular booleans
Post by: DoorKnobHandle on Sun 13/02/2005 14:06:03
not necessary... :) and welcome to the ags forum...
Title: Re: Need help with global/character values, in paticular booleans
Post by: on Sun 13/02/2005 14:10:05
Entirely necessary, I'd have left my project as foobar if it wasn't for you, I was about to give up hope on what I hope will be a rather splendiferous adventure game, M'SS.
I think your name goes in "Coding Help".
And I reckon I'll be on the forum a lot... Not so hot with the coding, my mind's still left behind in the days of QB!

Would be nicer not to have to fiddle around in the code, though, but I'm sure I can manage... Oops!