.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Condition Zero TraceLine() weirdness
Old
  (#1)
Austin
Moderator
 
Austin's Avatar
 
Status: Offline
Posts: 403
Join Date: Nov 2003
Default Condition Zero TraceLine() weirdness - 20-08-2004

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?

Last edited by Austin; 20-08-2004 at 07:46..
  
Reply With Quote
Re: Condition Zero TraceLine() weirdness
Old
  (#2)
dstruct2k
 
dstruct2k's Avatar
 
Status: Offline
Posts: 225
Join Date: Feb 2004
Default Re: Condition Zero TraceLine() weirdness - 20-08-2004

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.
  
Reply With Quote
Re: Condition Zero TraceLine() weirdness
Old
  (#3)
Austin
Moderator
 
Austin's Avatar
 
Status: Offline
Posts: 403
Join Date: Nov 2003
Default Re: Condition Zero TraceLine() weirdness - 20-08-2004

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..
  
Reply With Quote
Re: Condition Zero TraceLine() weirdness
Old
  (#4)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: Condition Zero TraceLine() weirdness - 20-08-2004

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.

Last edited by Cheeseh; 20-08-2004 at 19:55..
  
Reply With Quote
Re: Condition Zero TraceLine() weirdness
Old
  (#5)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Condition Zero TraceLine() weirdness - 20-08-2004

Why are you writing a CZ bot, anyway? What's the point?
  
Reply With Quote
Re: Condition Zero TraceLine() weirdness
Old
  (#6)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Condition Zero TraceLine() weirdness - 20-08-2004

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).



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Condition Zero TraceLine() weirdness
Old
  (#7)
Austin
Moderator
 
Austin's Avatar
 
Status: Offline
Posts: 403
Join Date: Nov 2003
Default Re: Condition Zero TraceLine() weirdness - 24-08-2004

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.

Last edited by Austin; 24-08-2004 at 08:17..
  
Reply With Quote
Re: Condition Zero TraceLine() weirdness
Old
  (#8)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Condition Zero TraceLine() weirdness - 24-08-2004

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 ?



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Condition Zero TraceLine() weirdness
Old
  (#9)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: Condition Zero TraceLine() weirdness - 24-08-2004

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.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com