Hi guys, hope you can help. I'm putting together the interactions for one of my NPCs and I've hit a snag. When I "talk to" the character I want it to trigger dialog 2. I also have a couple of interactions for using a couple of inventory items on the character. My problem is that when I "Talk To" the character the game first displays the part of the script conditional to my using inventory item 6 - from this statement:
if (player.ActiveInventory==inventory[6]){
..before running dialog 2. Where am I going wrong? Full script for the NPC is below.
function cHip_AnyClick()
{
// TALK TO
if (UsedAction(eGA_TalkTo)) {
dDialog2.Start();
}
// LOOK AT
else if(UsedAction(eGA_LookAt)) {
player.Say("That's Thursleigh Worplesdon.");
player.Say("I know him through Michelle, they were on the Creative Writing course together.");
}
// OPEN
else if(UsedAction(eGA_Open)) {
player.Say("I'll move him, alright.");
player.Say("Into the path of a runaway steamroller.");
}
// CLOSE
else if(UsedAction(eGA_Close)) {
Unhandled();
}
// USE
else if(UsedAction(eGA_Use)) {
Unhandled();
}
// Push
else if(UsedAction(eGA_Push)) {
Unhandled();
}
// Pull
else if(UsedAction(eGA_Pull)) {
Unhandled();
}
// PICKUP
else if(UsedAction(eGA_PickUp)) {
player.Say("I'd quite like to ransack his house, but I'll leave this fool here.");
}
// GIVE TO
else if (UsedAction(eGA_GiveTo)) {
Unhandled();
}
}
//USE INV
else if(UsedAction(eGA_UseInv)) {
if (player.ActiveInventory==inventory[5]){
player.Say("It's very tempting, but a little too blatant.");
}
}
if (player.ActiveInventory==inventory[6]){
player.FaceCharacter(cHip);
player.Say("Hey Thursleigh!");
player.Say("I found something really retro and ironic you might like!");
cHip.FaceCharacter(cEgo);
cHip.Say("Oh wow!");
cHip.Say("really?");
}
}
[code]
If you indent correctly, the problem becomes obvious:
//USE INV
else if(UsedAction(eGA_UseInv)) {
if (player.ActiveInventory==inventory[5]){
player.Say("It's very tempting, but a little too blatant.");
}
}
if (player.ActiveInventory==inventory[6]) {
player.FaceCharacter(cHip);
player.Say("Hey Thursleigh!");
player.Say("I found something really retro and ironic you might like!");
cHip.FaceCharacter(cEgo);
cHip.Say("Oh wow!");
cHip.Say("really?");
}
In other words, the if (player.ActiveInventory==inventory[6]) block is not inside the else if(UsedAction(eGA_UseInv)) block, so it runs regardless of which action was used, as long as the active inventory item is inventory[6], which I guess it is. Because dialogs only start after the script has finished, it then runs before the dialog.
Thanks!