start a script when a npc cross an area

Started by Blondbraid, Tue 28/03/2017 22:25:09

Previous topic - Next topic

Blondbraid

Hi!
What I'm trying to achieve is a scene where a character who is not the player walks from point A to B, and if they reach point B, the player loses the game,
so that the player has to be able to interact with the character before they reach that point.

But all scripts and functions I find are about the player character, so I wonder if it's possible
to have a script trigger when a specific non player character cross a region or walkable area?


Snarky

Code: ags
#define TRIGGER_REGION 3 // whatever number that region has

function repeatedly_execute()
{
  if(Region.GetAtRoomXY(walkingCharacter.X, walkingCharacter.Y) == region[TRIGGER_REGION] && Game.DoOnceOnly("Reached point B"))
  {
    // do stuff
  }
}

Blondbraid

I tried the script, but I get the error message:
room2.asc(27): Error (line 27): undefined symbol 'walkingCharacter'

What shall I do?


dayowlron

#3
Where he put walkingcharacter you need to supply the character object such as cEgo

If your NPC character is named Charlie then use cCharlie.
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

Blondbraid

Everything seems to be working, thank you both!


SMF spam blocked by CleanTalk