AreaSpecificView for NPC

Started by monkey424, Thu 26/06/2014 04:33:18

Previous topic - Next topic

monkey424

Is there any way for a non-player character to reap the benefit of the AreaSpecificView setting of a walkable area? I want my NPC to follow the main character and change views as the main character does (i.e. using AreaSpecificView). I suspect I may need to use regions instead?
    

Secret Fawful

I've considered trying this myself, but possibly one way to do it would be to update the views based on the characters X or Y coordinates?

Code: ags

if ((cPlayer.x => cNPC.x) && (cNPC.x >= 50) && (cNPC.x <= 100))
{
  cNPC.ChangeView(90);
}

//If the NPC is behind the player or next to them, and if the NPC's coordinates are between 50x and 100x, then update the NPC's view to view 90


Stuff like that?

Eastwing

You can get ID of Walkable area using GetWalkableAreaAt. It uses SCREEN coordinates so you must calculate ROOM coordinates using Viewports.

Like that:
Code: ags
if (GetWalkableAreaAt(cChar.x-GetViewportX(), cChar.y-GetViewportY()) == 1)
    cChar.ChangeView(12);


monkey424

Thanks Eastwing. That is a very logical approach and I don't know why I didn't think of that earlier. I had a brain fart!
    

SMF spam blocked by CleanTalk