Making a character respond to item being used?

Started by LeChuck, Thu 09/09/2004 02:21:58

Previous topic - Next topic

LeChuck

No need to introduce myself - I'll jump right to the problem:


I'm making a game where, when I give an item to a character, this character should change behaviour completely. When I look at this character after I've given the item, it should give a different response than before. The same goes for talking to the character. I have solved this by running the script:

Quote
character[CHARACTERBEFOREITEM].room = -1;
character[CHARACTERAFTERITEM].room = 5;

Basically it replaces the old character with a new one. Maybe this is a bit amateur-ish, but I'm pretty new to all of this.

Here's the dilemma: When I give the original character the item that will transform him into the new one, it's set to run a dialog at the same time. But, as the old character is deleted at this very moment, the text he speaks moves to the center of the room (as the original character is no longer in the room!), and is not hovering over the head of the new character.


So what I'm asking is, how do I, when I give an item to a character, make *another* character respond to this?

Gilbert

I think you should use the same character instead, just use ChangeCharacterView() to change his view (appearance).

And, as you want different behaviours, you can just keep tracking it with a global variable (you can use GlobalInt, check the functions SetGlobalInt() and GetGlobalInt() ), for example when the character's appearance changes, set the variable to 1, and you can script his behaviour differently according to the value of the variable.

LeChuck

#2
Quote from: Gilbot V7000a on Thu 09/09/2004 02:34:43
And, as you want different behaviours, you can just keep tracking it with a global variable (you can use GlobalInt, check the functions SetGlobalInt() and GetGlobalInt() ), for example when the character's appearance changes, set the variable to 1, and you can script his behaviour differently according to the value of the variable.

I couldn't find any info either in the manual or anywhere on the forums on how to use this function...

Would you be as kind as to explain how this is done?  I really didn't understand anything of what you just said.Ã,  :(

Gilbert

Yeah, see Text Script Functions --> Game/Global functions from the manusl.

Example on how to use it:
When you need to change the character's look and behaviour, do something like:
ChangeCharacterView(EGO, 10); //Say the character is called EGO and his new view is 10
SetGlobalInt(5,1); //Set GlobalInt #5 to 1 (there're 500 global ints available for you to use, they're all 0 when the game starts initially)

When in an interaction which you want the character behave differently, just check the value of the Global Int:
if (GetGlobalInt(5)==1) {
Ã,  //behaviour AFTER changing here
} else {
Ã,  //behaviour BEFORE changing here
}

Edwin Xie

Well, global variables are VERY useful, at least it is something like this (I don't know if you scripted it better):

if varname == 1
//do something

if varname == 2
//do something else
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

LeChuck

It works perfectly now! Thanks everyone!  :)
Global variables actually *are* useful!

R4L

Oh boy! Global Ints and Varibles! I hate those so much... because I DON'T KNOW HOW TO USE THEM! ahem, sorry.

I agree about using ChangeCharacterView(EGO,X);

SMF spam blocked by CleanTalk