.:: 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
Detecting fall damage in a safe way?
Old
  (#1)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Detecting fall damage in a safe way? - 12-01-2004

I am trying to figure out how to get a 100% solid method to know a bot recieved damage due falling. This is to let bots learn from their mistakes in some nodes.

I tried using the DMG_FALL and DMG_CRUSS bits, but they gave me no luck! I saw in the SDK only bits gets sent that require a HUD drawing on the client, this stinks!

My code:
Code:
// This message gets sent when the bots are getting damaged.
void BotClient_Valve_Damage(void *p, int bot_index)
{
 //DebugOut("bot_client: BotClient_Valve_Damage()\n");
   static int state = 0;   // current state machine state
   static int damage_armor;
   static int damage_taken;
   static int damage_bits;  // type of damage being done
   static Vector damage_origin;
   if (state == 0)
   {
	  state++;
	  damage_armor = *(int *)p;
   }
   else if (state == 1)
   {
	  state++;
	  damage_taken = *(int *)p;
   }
   else if (state == 2)
   {
	  state++;
	  damage_bits = *(int *)p;
   }
   else if (state == 3)
   {
	  state++;
	  damage_origin.x = *(float *)p;
   }
   else if (state == 4)
   {
	  state++;
	  damage_origin.y = *(float *)p;
   }
   else if (state == 5)
   {
	  state = 0;
	  damage_origin.z = *(float *)p;
	  if ((damage_armor > 0) || (damage_taken > 0))
	  {
		  // Damage recieved:
		  // - when the prev node was higher (so we are sure we do FIX the correct nodes!)
		  //   we fix it (only when dist > 90)
		  cBot *pBot = &bots[bot_index];
   
		  if ((damage_bits & (DMG_FALL | DMG_CRUSH))
		  {					  
			  LOG_CONSOLE (PLID, "realbot - fixed connection with falling.");			  
			  LOG_MESSAGE (PLID, "realbot - fixed connection with falling.");
			  if (pBot->bot_pathid > 0)
			  {
				  int iNode = NodeMachine.NodeFromPath(pBot->iIndex, (pBot->bot_pathid-1));
				  float fDist = fabs(damage_origin.z - NodeMachine.node_vector(iNode).z);
				  if (fDist > 90)
				  {
					  // we know where we came from, and we know where we went to
					  int iNodeTo = NodeMachine.NodeFromPath(pBot->iIndex, pBot->bot_pathid);
					  // remove connection
					  NodeMachine.remove_neighbour_node(iNode, iNodeTo);
				  }
			  }
		  }
		 // ignore certain types of damage...
		 if (damage_bits & IGNORE_DAMAGE)
			return;
		 // if the bot doesn't have an enemy and someone is shooting at it then
		 // turn in the attacker's direction...
		 if (bots[bot_index].pBotEnemy == NULL)
		 {
			// face the attacker... (yeah yeah, cheating for now ;) )
   // Face danger vector
	  pBot->vHead = damage_origin;
			pBot->vBody = damage_origin;
			
			// move to damage vector
			pBot->f_camp_time = gpGlobals->time; // stop camping
			pBot->iGoalNode = NodeMachine.close(damage_origin, 150, NULL);
			pBot->bot_pathid = -1;
   ///////////// END STEFAN
		 }
	  }
   }
}
Code from sdk (player.cpp, function "UpdateClientdata"),
Code:
if (pev->dmg_take || pev->dmg_save || m_bitsHUDDamage != m_bitsDamageType)
 {
  // Comes from inside me if not set
  Vector damageOrigin = pev->origin;
  // send "damage" message
  // causes screen to flash, and pain compass to show direction of damage
  edict_t *other = pev->dmg_inflictor;
  if ( other )
  {
   CBaseEntity *pEntity = CBaseEntity::Instance(other);
   if ( pEntity )
	damageOrigin = pEntity->Center();
  }
  // only send down damage type that have hud art
  int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD;
  MESSAGE_BEGIN( MSG_ONE, gmsgDamage, NULL, pev );
   WRITE_BYTE( pev->dmg_save );
   WRITE_BYTE( pev->dmg_take );
   WRITE_LONG( visibleDamageBits );
   WRITE_COORD( damageOrigin.x );
   WRITE_COORD( damageOrigin.y );
   WRITE_COORD( damageOrigin.z );
  MESSAGE_END();
 
  pev->dmg_take = 0;
  pev->dmg_save = 0;
  m_bitsHUDDamage = m_bitsDamageType;
  
  // Clear off non-time-based damage indicators
  m_bitsDamageType &= DMG_TIMEBASED;
 }


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Detecting fall damage in a safe way?
Old
  (#2)
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: Detecting fall damage in a safe way? - 13-01-2004

The IGNORE_DAMAGE bits don't work in Counter-Strike.

Do this instead
Code:
// is this player falling fast enough to get some damage ?
if (pEdict->v.flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED)
look in the SDK's player.h:
Code:
#define PLAYER_FATAL_FALL_SPEED 1024// approx 60 feet
#define PLAYER_MAX_SAFE_FALL_SPEED 580// approx 20 feet



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 13-01-2004 at 00:46.. Reason: fixed typo
  
Reply With Quote
Re: Detecting fall damage in a safe way?
Old
  (#3)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default Re: Detecting fall damage in a safe way? - 13-01-2004

I have a similar problem. How to detect if a bot is getting damage from being attacked, and who the attacker is. I tried using the "Damage" message, but it does not indicate what the cause of the damage is, or who (or what) is the source. I ended up doing a traceline back to the source origin to see what it is, but the method is cpu intensive and inaccurate.


Maker of the (mEAn) Bot.Admin Manager

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
  
Reply With Quote
Re: Detecting fall damage in a safe way?
Old
  (#4)
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: Detecting fall damage in a safe way? - 13-01-2004

lol, I feel like I'm your savior for each problem you have

botmeister: already checked: pEdict->v.dmg_inflictor ?




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: Detecting fall damage in a safe way?
Old
  (#5)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default Re: Detecting fall damage in a safe way? - 13-01-2004

Quote:
Originally Posted by Pierre-Marie Baty
lol, I feel like I'm your savior for each problem you have

botmeister: already checked: pEdict->v.dmg_inflictor ?

THANKS!

How in the hell do you find this stuff anyway? ???


Maker of the (mEAn) Bot.Admin Manager

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
  
Reply With Quote
Re: Detecting fall damage in a safe way?
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: Detecting fall damage in a safe way? - 13-01-2004

the hell you're talking about is called "PMTools plugin", and it's available for download with source code on my site, hehe



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: Detecting fall damage in a safe way?
Old
  (#7)
strelok
Member
 
Status: Offline
Posts: 26
Join Date: Jan 2004
Default Re: Detecting fall damage in a safe way? - 13-01-2004

BTW: Whether function UpdateClientData in dll.cpp is necessary? Count Floyd spoke, that she is not necessary.
  
Reply With Quote
Re: Detecting fall damage in a safe way?
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: Detecting fall damage in a safe way? - 13-01-2004

It is not necessary. You can delete it.

This function is used by clients to ask the server to send a network message containing various data about the client, so that the client can update itself and synchronize with the server. It would be useful for a client-side bot. But since your bot is a server-side bot, all the data concerning your bots is available through pBot->pEdict, and you don't need to ask the server to send you anything because you use the same structures as the server.



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: Detecting fall damage in a safe way?
Old
  (#9)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: Detecting fall damage in a safe way? - 13-01-2004

UpdateClientData is only used in the bot code to find out if the bots weapons have been changed and it's weapons haven't been updated yet. You only need to use it if a bot drops its weapon, as it doesnt get removed from the bots weapons bitmask (but it does in the pev->weapons bitmask).

UpdateClientData uses some cpu I think, so I just replaced it by checking pev->weapons instead of cd.weapons that comes from UpdateClientData.
  
Reply With Quote
Re: Detecting fall damage in a safe way?
Old
  (#10)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Detecting fall damage in a safe way? - 15-01-2004

thanks guys, i think i can work with this stuff!


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Reply


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

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