Can anyone point me in the right direction for scripting this?
I have the NPC randomly walking left or right in the room. If the NPC turns either to their right or left and the player is their then display something like you are dead.
I tried using something like
if (cJIm.x<=cEgo.x)
{
Display("You are dead");
}
but doesn't seem to do the trick with detecting if the NPC is facing the player.
thanks for any help.
check for player.Loop as well. :)
Thanks the loop worked
if ((cJIm.Loop==1) && (cEgo.x<=cJIm.x))
{
cJIm.Say("I see you player on LEFT. You are no dead");
}
if ((cJIm.Loop==2) && (cEgo.x>=cJIm.x))
{
cJIm.Say("I see you player on RIGHT. You are no dead");
}
Note that you may use existing constants instead of bare numbers, they correspond to the walking loop values:
enum CharacterDirection {
eDirectionDown,
eDirectionLeft,
eDirectionRight,
eDirectionUp,
eDirectionDownRight,
eDirectionUpRight,
eDirectionDownLeft,
eDirectionUpLeft,
eDirectionNone
};
So, like
if ((cJIm.Loop==eDirectionLeft) && (cEgo.x<=cJIm.x))
and so on.
It's more text, but may be easier to understand what it means.