Pathfinder Troubles

Started by Maestro, Tue 26/07/2005 16:26:11

Previous topic - Next topic

Maestro

I was wondering can i make a check in AGS like this:

if (IsPathFree(cEGO, cBADGUY)==1) do blabla;
else blablabla;

and the function checks if a straight line can be drawn from EGO to BADGUY on any walkable area, and if there is no obstructions like other chars, objects,no walkable area or anything that makes the pathfinder search for a path through walkable areas, thus making the straight line not straight, in the room and then returns one or zero.

My english is bad, so I am having a hard time explaining this, so maybe an example can help...

I have a room with 2 chars. You control Ego. You click on BADGUY. AGS checks if a bullet can travel from EGO to BADGUY(the above function)and returns 1 or 0 if he can-cannot.
The game is in overhead perspective.
depending on the result, it runs script blah blah and so on...

So if there was a wall painted between them(with no walkable area there) the bullet could not travel through it, and i could script it from there...

I know Characters make a "hole" in a walkable area beneath them internaly so characters don't walk through each other, so the same method could be used to do the check.

I hope you understand the problem...
any help will be appriciated.

Bernie

I'd have a solution, but it's a bit messy. And you'd have to write your own function. You need it for a straight line, right?

Create a new character and set its speed to 0 (makes it move instantly to a position), we'll let it be the bullet. Write a function with the variables 'fromchar' and 'tochar' or similar.

In the function, do these things, and make sure to execute them in this order:

1. Set the bullet chara position to x and y of the character specified with variable 'fromchar'.

2. Use MoveStraight with the bullet character and use the x and y values of 'tochar' as your destination.

3. Check if the character overlaps the 'tochar' character. Character.GetAtScreenXY() would work, and maybe character[].IsCollidingWithChar(), too. Return 1 if it overlaps, or 0 if it doesn't.

SMF spam blocked by CleanTalk