.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 1 SDK (http://forums.bots-united.com/forumdisplay.php?f=33)
-   -   cs weapons modification (http://forums.bots-united.com/showthread.php?t=4017)

sPlOrYgOn 10-09-2005 01:16

Re: cs weapons modification
 
I believe you can look at the war3mod made for amx and see how Orcs do more damage with nades..

sfx1999 10-09-2005 02:21

Re: cs weapons modification
 
Yes that can be done. Anyway, I don't think grenades would have a detonation event. They would probably spawn a sprite, make a sound, and be removed.It's the damage you need to look at.

BotUser 10-09-2005 23:41

Re: cs weapons modification
 
Quote:

Originally Posted by sfx1999
It's the damage you need to look at.

Yes, that's what i found out. I'll try and go with the damage and have a look at this war3mod thing. Maybe it'll help.

Lazy 12-09-2005 02:53

Re: cs weapons modification
 
I hope this is not too late but I think you can find out when a HE grenade detonates by hooking pfnRemoveEntity and checking if edict_t*->classname is the grenade.
Its been a while since I played with CS so I'm not sure of the name.
What you could do is hook the pfnRemoveEntity function and log the entities passed to it to either the server log or your local console with CLIENT_PRINT.

Note, coded in the quick reply box - may not be accurate
Code:

void RemoveEntity( edict_t* pEntity ) {
  static char szClassname[ 64 ];

  if ( ! FNullEnt( pEntity ) ) {
          _snprintf( szClassname, sizeof( szClassname ), "Entity %s being removed from the world!", STRING( pEntity->v.classname );
          CLIENT_PRINTF( INDEXENT( 1 ), print_console, szClassname );
  }

  RETURN_META( MRES_IGNORED );

In game - throw a grenade and see what output you get.

BotUser 12-09-2005 10:19

Re: cs weapons modification
 
interesting ... thanks Lazy. Will check this out.

Meanwhile, I had a look at the AMX-X framework. Nice thing.
A lot can be done using their PAWN script language, and quite easily.

BotUser 14-09-2005 01:04

Re: cs weapons modification
 
Ok folks,

I think I almost made it. The HE grenades' strength in CS can now be adjusted at will.
Here's what I did:

- Intercepted "Damage" message to player entity
- checked pPlayer->v.dmg_inflictor for grenade entity
- if yes, then adjust pPlayer->v.health accordingly to do more damage
- send message to all other players about changed health

Don't do the last two steps if adjusting the health would result in
pPlayer->v.health <= 0.

And that's the problem. If, say, player health is 49, and health would be reduced by 50, I can't do it. I would have to let the player die.

How can one make a player die ? Is there something like pEntity->kill ?





Lazy 14-09-2005 01:22

Re: cs weapons modification
 
As far as I know it's impossible to inflict real damage to a player outside the mod unless you have the source.

Although, a while ago I posted an extremely cheap hack to cause real damage to entities.
It involved creating a trigger_hurt entity with the right settings and forcing the target player to touch it.

The one I posted on here had a few careless bugs that crept in due to lack of sleep but this one should work.

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 Pain( 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 = pInflictor;                        // Who's attacking me?
          pEnt->v.owner = pInflictor;                                        // ^^^^^
          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 );
  }
}

It does cause damage but I'm not 100% sure that the inflicting entity gets credit for it.
Good luck on your plugin.

sPlOrYgOn 14-09-2005 03:06

Re: cs weapons modification
 
well if you look in the war3 mod it also simulates death of a player..
http://amxmod.net/showplugin.php?id=130081
search for do_damage

BotUser 14-09-2005 20:42

Re: cs weapons modification
 
Man, you guys are great, thanks for all the suggestions ! :)

@Lazy:
That's exactly the point. I could kill a player by just calling MDLL_ClientKill, but then this looks like suicide for the player and the attacker doesn't get any credit. Just one line, works nicely, except for the credit situation.

@sPlOrYgOn:
I checked out that code. It's basically setting the health of the player accordingly, and setting a flag if player is dead (i. e. health <= 0).
But in this case, just setting health = 0 and killed = 1 is not sufficient.
I need to make the player die "naturally" in terms of the engine if I detect that healt <= 0.

There's a method TakeDamage for an entity, however I would need to make a CBasePlayer* or somethink like that out of the edict_t* I've got in order to call this.

There must be a way to do this, I'll keep searching ...8)

Lazy 14-09-2005 20:54

Re: cs weapons modification
 
You can get a CBaseEntity pointer from an edict_t pointer by calling CBaseEntity::Instance( edict_t* ).
BUT, don't expect it to work or not crash since almost every mod makes changes to the top of the CBaseEntity class which breaks compatibility by changing the positions of variables inside the class.
One exception is natural selection which does allow you to call CBaseEntity::TakeDamage.

I'll think for a bit and see if theres any way to cause damage to a player but as far as I know no other entities can have variable damage amounts.


All times are GMT +2. The time now is 10:35.

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