Raised This Month: $51 Target: $400
 12% 

Trace Flags HELP!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
deadbwoy
Member
Join Date: Mar 2009
Location: The Intarweb
Old 04-26-2010 , 23:26   Trace Flags HELP!
Reply With Quote #1

I'm working on this plugin to search for bots in objective areas so I can run commands on them (get them to stop moving until the point has been captured).
I've made alot of progress so far, but now I need help!
Here's the code I've got plus the info that is spit out in console below the code:
http://pastebin.com/GHgps5t8
Code:
L 04/26/2010 - 22:00:51: Started map "ins_firefight_testmap" (CRC "183502338")
L 04/26/2010 - 22:00:51: BOC: INS_Objective found!  EntityIndex: 26 @ -384.000000 0.000000 40.000000
L 04/26/2010 - 22:00:51: BOC: INS_Objective found!  EntityIndex: 44 @ -1280.000000 0.000000 40.000000
L 04/26/2010 - 22:00:51: BOC: INS_Objective found!  EntityIndex: 65 @ 512.000000 0.000000 40.000000
L 04/26/2010 - 22:00:51: BOC: INS_Objective found!  EntityIndex: 67 @ -384.000000 384.000000 40.000000
L 04/26/2010 - 22:00:51: BOC: INS_Objective found!  EntityIndex: 70 @ -384.000000 -384.000000 40.000000
 
L 04/26/2010 - 22:00:51: "[BOT] Macky49<52><BOT><>" connected, address "none"
L 04/26/2010 - 22:00:51: "<52><BOT><>" entered the game
L 04/26/2010 - 22:00:52: "[BOT] Macky50<53><BOT><>" connected, address "none"
L 04/26/2010 - 22:00:52: "<53><BOT><>" entered the game
L 04/26/2010 - 22:00:52: "[BOT] Macky51<54><BOT><>" connected, address "none"
L 04/26/2010 - 22:00:52: "<54><BOT><>" entered the game
L 04/26/2010 - 22:00:52: "[BOT] Macky52<55><BOT><>" connected, address "none"
L 04/26/2010 - 22:00:52: "<55><BOT><>" entered the game
 
L 04/26/2010 - 22:01:03: BOC: OBJMSG FUNC triggered start_cap c by team: Iraqi Insurgents
L 04/26/2010 - 22:01:03: BOC: Bot Found During Bot Search at 195.165817 -365.736694 -12.960549! BotIndex= 1
L 04/26/2010 - 22:01:03: Entity Found in Trace by bot: BotIndex= 1, EntityIndex= 0, classname= worldspawn
L 04/26/2010 - 22:01:03: BOC: Bot Found During Bot Search at -305.595886 379.089782 0.031250! BotIndex= 2
L 04/26/2010 - 22:01:03: Entity Found in Trace by bot: BotIndex= 2, EntityIndex= 0, classname= worldspawn
L 04/26/2010 - 22:01:03: BOC: Bot Found During Bot Search at -548.709838 347.441314 0.031250! BotIndex= 3
L 04/26/2010 - 22:01:03: Entity Found in Trace by bot: BotIndex= 3, EntityIndex= 0, classname= worldspawn
L 04/26/2010 - 22:01:03: BOC: Bot Found During Bot Search at -606.979309 -392.394989 0.031250! BotIndex= 4
L 04/26/2010 - 22:01:03: Entity Found in Trace by bot: BotIndex= 4, EntityIndex= 0, classname= worldspawn
I'm trying to figure out what the correct trace flag is to find the entity Im looking for: ins_objective
The only entitys the TraceRay has found are "Worldspawn" and "player"

-OR-

Find a way, using the info I already have to figure out if one of the bots is close enough to an ins_objective (like using the bot's origin vs the entity origins).
deadbwoy is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 04-27-2010 , 03:16   Re: Trace Flags HELP!
Reply With Quote #2

IIRC you cant trace for non-solid objects with SourceMod (or something to that effect).

Besides, tracing isnt the best way to do what youre trying to do. My guess is that ins_objective is a brush entity, that has mins and maxs (m_vecMins and m_vecMaxs respectively) that define the box shaped area. Heres a sample code (untested, but should give you a nudge to the right direction):

PHP Code:
GetClientInsideObjectiveArea(client) {
    
decl Float:mins[3], Float:maxs[3], Float:orig[3], Float:playerOrigin[3];
    new 
ent = -1;

    
GetClientAbsOrigin(client,playerOrigin);

    while((
ent FindEntityByClassname(ent,"ins_objective")) != -1) {
        
GetEntPropVector(ent,Prop_Data,"m_vecOrigin",orig);
        
GetEntPropVector(ent,Prop_Data,"m_vecMins",mins);
        
GetEntPropVector(ent,Prop_Data,"m_vecMaxs",maxs);

        
mins[0] += orig[0], maxs[0] += orig[0];
        
mins[1] += orig[1], maxs[1] += orig[1];
        
mins[2] += orig[2], maxs[2] += orig[2];

        if(
mins[0] < playerOrigin[0] < maxs[0] &&
            
mins[1] < playerOrigin[1] < maxs[1] &&
            
mins[2] < playerOrigin[2] < maxs[2]) {
            return 
ent;
        }
    }

    return -
1;

__________________
plop
p3tsin is offline
deadbwoy
Member
Join Date: Mar 2009
Location: The Intarweb
Old 04-27-2010 , 09:32   Re: Trace Flags HELP!
Reply With Quote #3

Hey, thanks a ton for your reply!
I was using a similar example before and seeing it done another way really helped me to understand it better!
Just an update, I got the bots to stop when in an objective area!
Shouldn't be too hard to get em moving again... ;)
I used the following code instead:
Code:
BotSearch()
{
 //Declare:
 decl MaxPlayers;
 //Initialize:
 MaxPlayers = GetMaxClients();
 //Loop:
 for(new client = 1; client <= MaxPlayers; client++)
 {
  if(IsClientInGame(client) && IsPlayerAlive(client) && IsFakeClient(client))
  {
   new ent2=-1;
   while ((ent2 = FindEntityByClassname(ent2,"ins_objective")) != -1)
   {
    new Float:vec[3];
    GetClientAbsOrigin(client, Float:vec);
    decl Float:mins2[3], Float:maxs2[3];
    //decl Float:Ent2Position[3];
    //GetEntPropVector(ent2,Prop_Send,"m_vecOrigin",Ent2Position);
    GetEntPropVector(ent2,Prop_Send,"m_vecMins",mins2);
    GetEntPropVector(ent2,Prop_Send,"m_vecMaxs",maxs2);
    mins2[0] -= 20, maxs2[0] += 20;
    mins2[1] -= 20, maxs2[1] += 20;
    mins2[2] -= 20, maxs2[2] += 20;
    if (mins2[0] < vec[0] < maxs2[0] && mins2[1] < vec[1] < maxs2[1] && mins2[2] < vec[2] < maxs2[2])
    {
     SetEntityMoveType(client, MOVETYPE_NONE);
     LogToGame("BOC SUCCESS: Bot found (index= %i @ %f %f %f) inside an objective area! (Entity index= %i)", client, vec[0], vec[1], vec[2], ent2);
m_vecOrigin is commented out because it kept returning 0 0 0... but I guess I didn't really need that anyways!
Thanks again!
deadbwoy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode