[Question:] Is there an existing function or way to set a person as "obstructed" through the API?
I noticed we have:
IsPersonObstructed(name, x, y)
// returns true if person 'name' would be obstructed at (x, y)
GetObstructingTile(name, x, y)
// returns -1 if name isn't obstructed by a tile at x, y,
- returns the tile index of the tile if name is obstructed at x, y
GetObstructingPerson(name, x, y)
// returns "" if name isn't obstructed by person at x, y,
- returns the name of the person if name is obstructed at x, y
IgnorePersonObstructions(person, ignore)
- Sets whether 'person' should ignore other spriteset bases
IsIgnoringPersonObstructions(person)
- Returns true if 'person' is ignoring person obstructions, else false
IgnoreTileObstructions(person, ignore)
- Sets whether 'person' should ignore tile obstructions
IsIgnoringTileObstructions(person)
- Returns true if 'person' is ignoring tile obstructions, else false
But don't see anything about setting a person
to obstructed.
Should I instead write something like (pseudo-code):
if (GetTileName(Next_tile) == "obstruct_nw" && direction == "south")
{
QueuePersonCommand(Player, COMMAND_FACE_SOUTH, true);
SetPersonFrame(GetInputPerson(),1);
UpdateMapEngine();
}
Will that work?
. . .
[Edit:] Scratch that, doesn't work.
He skips across the tile like a long jumper. Any ideas?
Tried adding:
QueuePersonCommand(Player, COMMAND_WAIT, true);
also, but that didn't work either.
Script is attached in case anyone needs to see it.
. . .
[Edit:] Tried a little something else:
function SetPersonObstructed(name, command)
{
switch(command) {
case North: Move(name, 16, South, Face_north); break;
case South: Move(name, -16, North, Face_south); break;
case East: Move(name, -16, West, Face_east); break;
case West: Move(name, 16, East, Face_west); break;
break;
}
}
. . .
if (GetTileName(Ntile) == "obstruct_n" && direction == "south")
{
SetPersonObstructed(GetInputPerson(), South)
SetPersonFrame(GetInputPerson(),0);
UpdateMapEngine();
}
. . .
function Move(Name, Tiles, Direction, Face)
{
if (Direction == North) {QueuePersonCommand(Name, Face_north, false);} //Makes sprite face its proper direction.
if (Direction == South) {QueuePersonCommand(Name, Face_south, false);}
if (Direction == East) {QueuePersonCommand(Name, Face_east, false);}
if (Direction == West) {QueuePersonCommand(Name, Face_west, false);}
if (Direction != Wait) {QueuePersonCommand(Name, Face, false);} //If Direction commands sprite to Wait. It simply faces
for (var j = 0; j < Tiles; ++j) //For as long as "j" is less than Tiles, +1 is added to variable "j."
{ //The "j" variable will get us to reach our Tile Number. Once Tiles starts to become than "j" we no longer move.
for (var i = 0; i < 16; ++i) { QueuePersonCommand(Name, Direction, false); }
SetPersonFrame(Name, 0); //When Tile for-loop is finished, we reset the sprite's frame of currection direction to "0"
}
//Now we set the sprite's facing direction.
if (Face == undefined) //Checks Face for undefined.
{ //If undefined, sprite faces towards the direction it's commanded to go in.
if (Direction == North) {Face = North;}
if (Direction == South) {Face = South;}
if (Direction == East) {Face = East;}
if (Direction == West) {Face = West;}
}
if (Face == North) {QueuePersonCommand(Name, Face_north, false);} //Makes sprite face its proper direction.
if (Face == South) {QueuePersonCommand(Name, Face_south, false);}
if (Face == East) {QueuePersonCommand(Name, Face_east, false);}
if (Face == West) {QueuePersonCommand(Name, Face_west, false);}
}
But that failed also. Still skips across the tile,
but now he stops and turns around and then stays stuck.
Still working on it.