.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Condition Zero TraceLine() weirdness (http://forums.bots-united.com/showthread.php?t=2484)

Austin 20-08-2004 07:43

Condition Zero TraceLine() weirdness
 
I am creating a plugin that keeps humans from taking headshot damage and 1/2 the normal damage. I am trying to do all this in TraceLine()
The head shot part works fine.
Code:

void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)
{
 TRACE_LINE(v1, v2, fNoMonsters, pentToSkip, ptr);
 // is a human taking headshot damage?
 if ( !(ptr->pHit->v.flags & FL_FAKECLIENT) && ((1<<HITGROUP_HEAD) & (1<<ptr->iHitgroup)) )
 {
  // disallow head shots to humans, return no damage
  ptr->flFraction = 1.0;
  RETURN_META(MRES_SUPERCEDE);
 }
 else
 {
  // bot is taking damage let it rip
  RETURN_META(MRES_IGNORED);
 }
}

But if I add in this part that ignores every other damage hit to humans the CZ bots go nuts and fire at weird things like doors and walls and only about 1/2 the time attack humans with guns. Very weird!
Code:

// ---------------------------------------------------------------------------------------
// TraceLine()
//
// Disallow headshot damange and skip every other hit to human players
// ---------------------------------------------------------------------------------------
void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)
{
 static bool skipHit = false;
 TRACE_LINE(v1, v2, fNoMonsters, pentToSkip, ptr);
 // is a human taking damage?
 if ( !(ptr->pHit->v.flags & FL_FAKECLIENT) )
 {
  // is it a head shot?
  if( (1<<HITGROUP_HEAD) & (1<<ptr->iHitgroup) )
  {
  // disallow head shots to humans, return no damage
  ptr->flFraction = 1.0;
  RETURN_META(MRES_SUPERCEDE);
  }
  else if(skipHit)
  {
  // skip ever other shot!
  skipHit = false;
  ptr->flFraction = 1.0;
  RETURN_META(MRES_SUPERCEDE);
  }
  else
  {
  //skipHit = true;
  RETURN_META(MRES_IGNORED);
  }
 }
 else
 {
  // bot is taking damage let it rip
  RETURN_META(MRES_IGNORED);
 }
}

Does anyone know why this would happen?

dstruct2k 20-08-2004 08:41

Re: Condition Zero TraceLine() weirdness
 
Don't the bots use tracelines to find targets within their field of view?

Try halving the amount of damage done instead of the number of shots that hit.

Austin 20-08-2004 19:18

Re: Condition Zero TraceLine() weirdness
 
Quote:

Originally Posted by dstruct2k
Don't the bots use tracelines to find targets within their field of view?

Try halving the amount of damage done instead of the number of shots that hit.

Thanks for the reply.
Can I do that from traceline?
If so How?
Thanks.

P.S.
The plugin actually works as expected.
No head shots to humans and only every other shot does damage.
It is just the bots get weird when the every other hit section is enabled..

Cheeseh 20-08-2004 19:54

Re: Condition Zero TraceLine() weirdness
 
I don't think you can do that from a traceline unless you knew that the traceline was only used for a TraceAttack() command.

I'd hook the damage function like voogru suggested in the other post. You may be able to edit the network message info that has been sent.

The bots probably go weird becuase they use the traceline function to see if their enemy is visible and will look for their head.

sfx1999 20-08-2004 20:13

Re: Condition Zero TraceLine() weirdness
 
Why are you writing a CZ bot, anyway? What's the point?

Pierre-Marie Baty 20-08-2004 20:54

Re: Condition Zero TraceLine() weirdness
 
You can't change the amount of damage taken from the TraceLine that the bullet calls. You may be able to do it from a plugin by 1°) intercepting and changing on the fly all the "damage" network messages that the server sends and 2°) NOT FORGETTING to adapt the victim edict's health and armor on the server side too when you change one of them (but only after the messages are sent).

Austin 24-08-2004 08:08

Re: Condition Zero TraceLine() weirdness
 
Thanks for all the suggestions.
I figured out what was wrong...

The weird problems happen when you,
1) check if it is NOT a bot being traced lined and
2) you DON"T check for a body part hit and
3) you deny the damage!
If it isn't a FL_FAKECLIENT it doesn't mean it IS a human.
It could be anything! And when it ISN"T a HUMAN and you refuse the TraceLine() weird thigns will happen because ALL tracelines on
most everything will fail. (as everyone was indicating...)

To get done what I am trying to do:
1) no head shots to human and
2) every 4th bullet doesn't do damage, here is the code:
This works fine.
Code:

// ---------------------------------------------------------------------------------------
// TraceLine()
// Disallow headshot damange to human players + skip damge from every 4th shot
// ---------------------------------------------------------------------------------------
void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)
{
static int skipHit = 0;
 
TRACE_LINE(v1, v2, fNoMonsters, pentToSkip, ptr);
// is a human taking damage?
if ( !(ptr->pHit->v.flags & FL_FAKECLIENT) )
{
        // is it a head shot?
        if( (1<<HITGROUP_HEAD) & (1<<ptr->iHitgroup) )
        {       
                // disallow head shots to humans, return no damage
                ptr->flFraction = 1.0;
                RETURN_META(MRES_SUPERCEDE);
        }
        else if ( (1<<HITGROUP_ANY) & (1<<ptr->iHitgroup) )
        {
                if(skipHit >= 4)
                {                       
                        // skip damage from every 4th shot!
                        skipHit = 0;
                        ptr->flFraction = 1.0;
                        RETURN_META(MRES_SUPERCEDE);
                }
                else
                {
                        skipHit++;
                }
        }
}// not a human
RETURN_META(MRES_IGNORED);
}

The weird problems were fixed when I added a check to see what if any body part was hit and then only refuse it.

Pierre-Marie Baty 24-08-2004 14:07

Re: Condition Zero TraceLine() weirdness
 
If you want to be SURE it's a human client the target of the TraceLine (and not a bot nor anything else), you can do this:
Code:

// is a human taking damage?
if ( (ptr->pHit->v.flags & FL_CLIENT) && !(ptr->pHit->v.flags & FL_FAKECLIENT) )

Maybe this is what you were looking for ?

Cheeseh 24-08-2004 15:48

Re: Condition Zero TraceLine() weirdness
 
you could possibly tell if a bot is trying to use a traceline by checking "pentToSkip" and see if that is a bot. Incase you want to ignore any tracelines a bot wants to make incase it's just checking for visibles.


All times are GMT +2. The time now is 00:36.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.