.:: 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
Manually killing in cs...
Old
  (#1)
AssasinoRuso
Member
 
Status: Offline
Posts: 8
Join Date: May 2005
Default Manually killing in cs... - 10-05-2005

I'm having trouble doing manual damage in cs.... if I remember correctly this code is enough to kill in half life but... it bugs out in cs....

pEntity->v.health = -1;

pEntity->v.deadflag = DEAD_DEAD;

pEntity->v.takedamage = DAMAGE_NO;


what happens is, the player takes the idle model animation... err the one where it's hands are sort of up with no weapon.... it becomes nonsolid, there is no death animation... if you do this to yourself then the death cam turns on.... but there is never a message or score changing or anything like that. And also you can't respawn :-/

plz help.
  
Reply With Quote
Re: Manually killing in cs...
Old
  (#2)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: Manually killing in cs... - 10-05-2005

I used ClientKill(or pfnClientKill) in my esf bots.
  
Reply With Quote
Re: Manually killing in cs...
Old
  (#3)
AssasinoRuso
Member
 
Status: Offline
Posts: 8
Join Date: May 2005
Default Re: Manually killing in cs... - 11-05-2005

true but, what I'm doing is trying to get a bot to do "manual" damage and get credit for it.... basically this is in a mod simmilar to wc3 and the bots have their own damages..... basically the bot shoots a temp entity towards player and when the enemy's health goes below 1 I want him to die and the bot who shot to get credit...
  
Reply With Quote
Re: Manually killing in cs...
Old
  (#4)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: Manually killing in cs... - 11-05-2005

Yeah, I made some damaging function too...a bit dodgy though:
Code:
void UTIL_DamagePlayer(edict_t *pKiller, edict_t *pVictim, const char *Weapon, float Damage)
{
	static CBaseEntity *pDamageEnt = NULL;

	CBaseEntity *pEnt = (CBaseEntity *)GET_PRIVATE(pVictim);

	if (!pDamageEnt)
		pDamageEnt = UTIL_CreateEnt("info_target",Vector(0,0,0),Vector(0,0,0),	NULL);

	if ((pDamageEnt) && (pEnt))
	{
		UTIL_MakeVectors(WrapAngles(pVictim->v.angles+Vector(180,180,180)));
		pDamageEnt->pev->velocity = pDamageEnt->pev->velocity.Normalize() * 180 + gpGlobals->v_forward * 10;
		pDamageEnt->pev->origin = pKiller->v.origin;
		pDamageEnt->pev->owner = pKiller;
		pDamageEnt->pev->classname = MAKE_STRING(Weapon);
		pEnt->TakeDamage( pDamageEnt->pev, &pKiller->v,Damage,0);
	}
}
Not sure why I set the velocity...can't remember anymore
  
Reply With Quote
Re: Manually killing in cs...
Old
  (#5)
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: Manually killing in cs... - 11-05-2005

...except that CBaseStuff won't work in Counter-Strike, ain't I right ?

If you have the source code of the mod you're writting this for, do what Rick says ; else I'd say it's pretty much impossible.



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: Manually killing in cs...
Old
  (#6)
AssasinoRuso
Member
 
Status: Offline
Posts: 8
Join Date: May 2005
Default Re: Manually killing in cs... - 11-05-2005

Pierre out of all the people

did you know that it's possible to add entities to cs?

CBaseEntity DOES exist in cs.... this line turns edict_t into a semi workable CBaseEntity...

CBaseEntity *pEnt = (CBaseEntity *)GET_PRIVATE(pVictim);

only difference is that you can't use any functions....
  
Reply With Quote
Re: Manually killing in cs...
Old
  (#7)
AssasinoRuso
Member
 
Status: Offline
Posts: 8
Join Date: May 2005
Default Re: Manually killing in cs... - 11-05-2005

grr sorry for second post so shortly but... TakeDamage don't work for meh I tried before... and I actually have my own entity in cs so dont need to make one... it crashes when I do TakeDamage.... maybe it's where I'm doing it :-/ hmm.
  
Reply With Quote
Re: Manually killing in cs...
Old
  (#8)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: Manually killing in cs... - 11-05-2005

Quote:
Originally Posted by Pierre-Marie Baty
...except that CBaseStuff won't work in Counter-Strike, ain't I right ?

If you have the source code of the mod you're writting this for, do what Rick says ; else I'd say it's pretty much impossible.
At the time I wrote this I didn't had the source code aswell, it was just luck it worked I guess

For the killing...sorry don't know any other way :-/
  
Reply With Quote
Re: Manually killing in cs...
Old
  (#9)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: Manually killing in cs... - 12-05-2005

I tried something like this a while ago but lost the source and forgot how until I remembered 20 minutes ago...

Code:
// Causes pain to someone by using a trigger_hurt to apply damage
// Params:
// pVictim	 - Who takes the damage
// pInflictor  - Who does the damage
// flAmount	- How much damage to do ( TRIGGER_HURT TAKES ARMOR INTO ACCOUNT! )
// iDmgmask	- See DMG_xxx macros, in cbase.h I think
// pszPainname - What should this pain be called? NULL leaves it at trigger_hurt
void Ouch( edict_t* pVictim, edict_t* pInflictor, float flAmount, int iDmgmask, const char* pszPainname ) {
   char		   szKeyValue[ 32 ]; // Will contain iDmgmask as a string  
   edict_t*	   pEnt = NULL;	  // Trigger_hurt entity pointer
   KeyValueData   keyData;		  // Used to setup the damage type on the trigger_hurt entity

   // Create a trigger_hurt entity
   pEnt = CREATE_NAMED_ENTITY( MAKE_STRING( "trigger_hurt" ) );

   // Make sure it's valid
   if ( ! FNullEnt( pEnt ) ) {	
	  if ( pszPainname ) pEnt->v.classname = MAKE_STRING( pszPainname ); // Custom name! ( if set )
	  pEnt->v.dmg_inflictor = INDEXENT( 0 );		  // Who's attacking me?
	  pEnt->v.dmg = flAmount;						 // Take this much damage ( note: goes by trigger_hurt rules! )
	  pEnt->v.dmg_take = 1.0f;					    // TODO: Figure out what this does... later
	  pEnt->v.dmgtime = 2.0f;						 // ^^^^^

	  // Somewhere out of the way
	  SET_ORIGIN( pEnt, Vector( -4000, -4000, -4000 ) );
	  SET_SIZE( pEnt, Vector( -32, -32, -32 ), Vector( 32, 32, 32 ) );

	  // Setup the damage type
	  _snprintf( szKeyValue, sizeof( szKeyValue ), "%d", iDmgmask ); // Setup value string
	  keyData.szClassName = ( char* ) pszPainname; // TODO: ??? 
	  keyData.szKeyName = "damagetype";		    // damagetype key
	  keyData.szValue = szKeyValue;			    // What kind of damage to do
	  keyData.fHandled = FALSE;				    // Not handled yet

	  // Set the key/value pair on the entity
	  MDLL_KeyValue( pEnt, &keyData );

	  // Spawn it and force it to touch us...
	  MDLL_Spawn( pEnt );
	  MDLL_Touch( pEnt, pVictim );

	  // So noone accidentally walks into it later on
	  REMOVE_ENTITY( pEnt );
   }
}

void ClientCommand( edict_t* pEdict ) {
   if ( FStrEq( CMD_ARGV( 0 ), "hurtme" ) ) {
	  Ouch( pEdict, INDEXENT( 0 ), 35.0f, ( 1<< 4 ) /* DMG_FROZEN */, "canadian_winter" );

	  RETURN_META( MRES_SUPERCEDE );
   }

   RETURN_META( MRES_IGNORED );
}
I just tested that locally by myself and it seems to work great, you can even have your custom death message set.
This should work with any mod that has trigger_hurt entities compiled in.
  
Reply With Quote
Re: Manually killing in cs...
Old
  (#10)
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: Manually killing in cs... - 13-05-2005

oh yeah, a trigger_hurt.. that's smart

and lol @ the canadian winter



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