.:: 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
Reducing damage
Old
  (#1)
Austin
Moderator
 
Austin's Avatar
 
Status: Offline
Posts: 403
Join Date: Nov 2003
Default Reducing damage - 16-08-2004

I have been using the following code to deny headshots to humans.
How would i modify this to reduce damage taken?
What I would like to do is deny all headshots and reduce all other damage to humans by half.

Code:
// ---------------------------------------------------------------------------------------
// TraceLine()
//
// Disallow headshot damange to human players 
// ---------------------------------------------------------------------------------------
void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)
{
  TRACE_LINE(v1, v2, fNoMonsters, pentToSkip, ptr);
  if ( ((1<<HITGROUP_HEAD) & (1<<ptr->iHitgroup)) && 
		!(ptr->pHit->v.flags & FL_FAKECLIENT)	   )
  {
	// return no damage
	ptr->flFraction = 1.0;
	RETURN_META(MRES_SUPERCEDE);
  }
  else
  {
	RETURN_META(MRES_IGNORED);
  }
}

Last edited by Austin; 16-08-2004 at 00:28..
  
Reply With Quote
Re: Reducing damage
Old
  (#2)
MusicMan
Member
 
Status: Offline
Posts: 236
Join Date: Feb 2004
Default Re: Reducing damage - 16-08-2004

try and take a look at PMB's damage, headshot and no-headshot metamod plugins' source code.

Hope this helps
  
Reply With Quote
Re: Reducing damage
Old
  (#3)
Austin
Moderator
 
Austin's Avatar
 
Status: Offline
Posts: 403
Join Date: Nov 2003
Default Re: Reducing damage - 17-08-2004

Quote:
Originally Posted by MusicMan
try and take a look at PMB's damage, headshot and no-headshot metamod plugins' source code.

Hope this helps
tx, but that is exactly the opposite of what I am trying to do!

I guess I will look inthe sdk to see how the results of TraceLine() are used to inflict damage...

>Edit<
Hey, wait, Daaaaaa!
I will change a "-" to a "+" and use this to do exactly what I want!
Thanks again, and of course thanks PMB!

Last edited by Austin; 17-08-2004 at 01:44..
  
Reply With Quote
Re: Reducing damage
Old
  (#4)
voogru
Guest
 
Status:
Posts: n/a
Default Re: Reducing damage - 17-08-2004

Hook the Damage message.

It would look something like this:

Code:
void NSAMessage_Damage(void *buf, bool &bSend)
{
static int CurrentArg = 0;
if(buf == NULL)
{
CurrentArg = 0;
return;
}
float flDamage = 0;
CPlayer *pAttacker = NULL;
CPlayer *pVictim = NULL;
switch(CurrentArg)
{
case 1:
flDamage = (float)M_INT(buf);
if(UTIL_IsPlayerValid(CurrentMessageEdict) 
&& CurrentMessageEdict->v.dmg_inflictor != NULL
&& UTIL_IsPlayerValid(CurrentMessageEdict->v.dmg_inflictor->v.owner)
&& flDamage > 0)
{
pAttacker = GetPlayerPointer(CurrentMessageEdict->v.dmg_inflictor->v.owner);
pVictim = GetPlayerPointer(CurrentMessageEdict);
 
if(pAttacker == NULL || pVictim == NULL)
{
	CurrentArg++;
	break;
}
pVictim->pev->health += flDamage * 0.5;
M_INT(buf) = (int)flDamage * 0.5;
}
CurrentArg++;
break;
default:
CurrentArg++;
break;
}
}
That would make everyone take about half damage. The problem with this however is anything that does more damage than the player has health for wont work, since this is done after the fact. As far as I know theres no real way to limit the damage before its done.
  
Reply With Quote
Re: Reducing damage
Old
  (#5)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Reducing damage - 18-08-2004

Is it possible to override the player class' takedamage function, modifiy the incoming data, then send it back?
  
Reply With Quote
Re: Reducing damage
Old
  (#6)
sPlOrYgOn
<-- He did it.
 
sPlOrYgOn's Avatar
 
Status: Offline
Posts: 1,558
Join Date: Jan 2004
Location: Los Angeles, California, USA, North America, Earth, Solar System, Milky Way.
Default Re: Reducing damage - 18-08-2004

I don't think so..
cs does it's own kind of damage stuff.. all internal so unless you start memory hacking you probably won't beable to intercept it..
then after all that it sends the packet message just to update the HUD of the player and sets pEdict->v.health...
  
Reply With Quote
Re: Reducing damage
Old
  (#7)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: Reducing damage - 18-08-2004

Quote:
Originally Posted by sfx1999
Is it possible to override the player class' takedamage function, modifiy the incoming data, then send it back?
Maybe, if you could find the address of it first. I think thats why its so hard to do in the first place, I could be mistaken though.
  
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