IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Working With Waypoints, A couple of modification questions...
Swoop
post Mar 22 2006, 12:50 AM
Post #1


Newbie
*

Group: Members
Posts: 9
Joined: 22-March 06
From: Colorado
Member No.: 702



Hi.

I had two questions about waypointing.

1. I have taken the commandmenu.txt file from Sven Coop and have added some functions for quickly adding waypoints, entering into "edit mode (authenticate, godmode, noclip, waypoints on...), etc, and was wondering how I either send a command to choose the menu items from the waypoint_menu OR actually send the command to perform the same function. For example, in command_menu.txt, I have a whole section on adding flasg to existing waypoints. I tried to say "waypoint_menu; 2; 1" and the waypoint menu fails to catch the keystroke to add a JUMP flag. What's the best way to do this? Is there a function I could replace all of that with, such as "addflag wl_jump"?

2. Second Question: I think it would be AWESOME if you could use the crosshair from your weapon to select and view individual waypoints in the vicinity, exactly the same way you would do it now by walking up to the waypoint, but you wouldn't have to ncessarily move around as much; just aim and seloect. wink.gif

So, how hard would it be to check what the crosshair is centered on and show the paths to that waypoint in focus? I would even try it myself if it isn't too much of a doozie to code. wink.gif


Thanks for your time,
Swoop
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Mar 22 2006, 01:27 PM
Post #2


Admin
*****

Group: Admin
Posts: 3,066
Joined: 11-September 03
From: uk
Member No.: 1



try "rcbot waypoint_menu; menuselect 2; menuselect <value>"

showng waypoint properties by looking at them wouldnt be too hard but because of the way its done you getta ass around with the client code to change the current waypoint to the one being looked at instead of nearby, or create some kind of command to override the waypoint your are looking at but you still gotta add some handling code for displaying the waypoint looked at neatly in conjunction with the other methods
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swoop
post Mar 23 2006, 07:33 AM
Post #3


Newbie
*

Group: Members
Posts: 9
Joined: 22-March 06
From: Colorado
Member No.: 702



Hi Cheeseh.

Thanks for the reply.

-menuselect was the ticket. That worked great! The only thing I needed to add was an extra 'menuselect' for the exit function of the menu, since it stayed open after choosing my commands (ie, "rcbot waypoint_menu; menuselect 2; menuselect 1" chooses the right options but the menu doesn't close afterwards.)

So, thanks for the help there.

I am still trying to read over everything to see how I could show waypoint info by simply facing it (under reticle/crosshair on screen), like in what the UTIL_FacingEnt function SEEMS to do, at first glance.

It would be ideal if I could find where the code is for getting back the info on a player in view, which displays in green text in the lower left of the screen in multiplayer. This data shows the player name, score, health, and "friendly status." I am not sure if this is built into the engine or is available in the SDK as well.

Any additional ideas?

Thanks again for your help,
Alan

User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Mar 23 2006, 04:57 PM
Post #4


Admin
*****

Group: Admin
Posts: 3,066
Joined: 11-September 03
From: uk
Member No.: 1



to get the facing waypoint you need to find the nearest waypoint where the player is looking, otherwise if you are looking through a line of waypoints you'll get confused as to what waypoint you want to manipulate.

The method will become a little more complicated because I hash waypoints in another structure for fast retrival, so if you want to makeuse of that then this would be the best algorithm (LAST METHOD .. i think -- been thinking through all these)

the first method uses the waypointLocations hash table, the other methods do simple looping through every single waypoint.

//// hashing technique
// go through several steps from facing vector
// find nearest waypoint to facing vector at several stages
// each stage is fStep units

1. generate facing vector i.e. UTIL_MakeVectors(pPlayer->v.v_angle)
2. create the source vector (where player is) and the destination vector (where player is looking)
i.e.

Vector v_src = pPlayer->v.origin+pPlayer->v.view_ofs;
Vector v_dest = v_src + (gpGlobals->v_forward*8192); // far enough to possibly reach end of map

3. run a traceline to get the actual end point

TraceResult tr;

UTIL_TraceLine (v_src,v_dest, ......)

Vector v_endpoint = tr.endPos; // something like that anyway
float fEndDistance = (v_endpoint - v_src).Length(); // distance to stop

this is the end vector to stop searching

4.
start at say
CODE

class CCompareWaypoint
{
public:
 int iWptId;
 float fDistance;
}

class CCompareWaypointDistance
{
   bool operator () (CCompareWaypoint a, CCompareWaypoint b )
   {
         return a.fDistance<b.fDistance;
   }
}


....

// fStep should be around 256

int nearestFacingWpt(float fStep, edict_t *pPlayer )
{

priority_queue<CCompareWaypoint,vector<CCompareWaypoint>,CCompareWaypointDistance> wptList;
float fDistanceSoFar = (fStep/2); // start a little bit ahead
Vector v_iter = v_src + gpGlobals->v_forward*fDistanceSoFar;

while (fDistanceSoFar <fEndDistance )
{
 int waypoint = WaypointLocations.NearestWaypoint(v_iter,...);

 if ( waypoint != -1 ) // if exists
 {
    CCompareWaypoint wpt;

    wpt.iWptId = waypoint;
    wpt.fDistance = WaypointDistance(waypoint,v_iter); // think i made this function
// recalculate distance :(
    wptList.push(wpt);
   
 }

 v_iter = v_iter + gpGlobals->v_forward*fStep;
 fDistanceSoFar += fStep; // going another fStep units
}

if ( wptList.empty() )
  return -1;

return wptList.top();


advantages :
uses hash table and priority queue (fast)

disadvantages :
worst case greater than version below if Step is too small (can solve by storing bit mask of all waypoints --(CBits class)and if they have been evaluated or not and take this into account in finding nearest waypoint in waypointlocations)
fStep must be a value not too small, not too large
uses a traceline
naive method !! (see last method)



//////////////////////
// angle technique

run through each waypoint

find angle between player and waypoint

store waypoint with nearest angle and distance
(overwrite best waypoint each time)
CODE

int i;

float lowestYaw = 180;
int iBestWpt = -1;

for ( i = 0; i < MAX_WAYPOINTS; i ++ )
{
 if ( !(waypoints[i].flags & FL_DELETED) )
 {
    float yaw = UTIL_YawAngleBetweenEdict(pPlayer,WaypointOrigin(i)) // made a function like this somewhere
    if ( yaw<lowestYaw )
    {
       lowestYaw  = yaw;
       iBestWpt = i;
    }
 }
}

return iBestWpt;

advantages:
simple calculations
more robust than other algorithm
disadvantages:
differentiation between distance difficult (not done here)
runs though every single waypoint

-------------
possible distance calculation method for the above

CODE

int i;

float fBestDistance = 8192;
int iBestWpt = -1;
float fDistance;

Vector v_src = pPlayer->v.origin+pPlayer->v.view_ofs;
UTIL_MakeVectors(pPlayer->v.v_angle);
Vector v_temp;

for ( i = 0; i < MAX_WAYPOINTS; i ++ )
{
 if ( !(waypoints[i].flags & FL_DELETED) )
 {
   
// radial distance
    float fWptDist = WaypointDistance(i,v_src);
    v_temp = v_src+(gpGlobals->v_forward*fWptDist);

    fDistance = WaypointDistance(i,v_temp);

    if ( fDistance<fBestDistance )
    {
      fBestDistance = fDistance;
       iBestWpt = i;
    }
 }
}

return iBestWpt;

advantages:
simple calculations
more robust than other algorithm
takes distance into account aswell
disadvantages:
runs though every single waypoint available
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swoop
post Mar 23 2006, 08:48 PM
Post #5


Newbie
*

Group: Members
Posts: 9
Joined: 22-March 06
From: Colorado
Member No.: 702



These are great solutions to what I need. I am going to try and work with them today some. I also saw something in the SDK code somewhere, called GetGunPosition, and wondered if it might be useful as well? Maybe all it does is creates the vector from my position, just as you have listed above...

Thanks again for the helpful information. I have a lot to keep me busy for awhile. wink.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Mar 24 2006, 12:25 AM
Post #6


Admin
*****

Group: Admin
Posts: 3,066
Joined: 11-September 03
From: uk
Member No.: 1



get gun position = same as v_src vector I made in the examples
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swoop
post Mar 24 2006, 12:38 AM
Post #7


Newbie
*

Group: Members
Posts: 9
Joined: 22-March 06
From: Colorado
Member No.: 702



Excellent.

I have one question about the code in the final code example above:

What does this line do? I don't see anything being returned or used by it, so could you explain what it does?

CODE
UTIL_MakeVectors(pPlayer->v.v_angle);


Thanks!
-Swoop
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Mar 24 2006, 12:43 AM
Post #8


Admin
*****

Group: Admin
Posts: 3,066
Joined: 11-September 03
From: uk
Member No.: 1



it updates gpGlobals->v_forward/v_right/v_up to vectors relative to the vector input, in this case the players view angles

(so we can then use gpGlobals->forward to add to the players position to get a vector in the world)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swoop
post Mar 24 2006, 06:17 PM
Post #9


Newbie
*

Group: Members
Posts: 9
Joined: 22-March 06
From: Colorado
Member No.: 702



Excellent! That makes complete sense now.
Thanks again,
Swoop
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th July 2025 - 05:00 PM