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

BotUser 26-05-2005 01:30

cs weapons modification
 
Hi all,

I'm notoriously annoyed by the low damage HE grenades inflict in CS
(I'm talking of CS 1.6).

Hence, I decided to tackle on this on my own, such as to write an own metamod plugin in order to modify the HE grenades' damage.

Now the question: can this be done at all ?

How would one do it ? Modify the grenade's damage somehow or alter the damage that is inflicted on a player entity ?

Thanks and regards,

BotUser

Lazy 26-05-2005 02:06

Re: cs weapons modification
 
You can't modify the damage it does but it is possible to fake it by adding more damage after it's been done.
You need to look for the server->client messages that say a grenade is exploding, get the origin and apply damage to people in that radius.
To find out who threw it, do a FindEntityInSphere at the origin and check for grenade entities. The grenade's owner should be in edict_t*->v.owner.

Somewhere on here I posted a function to do damage on players using trigger_hurts, can't find it for some reason but if you can that should work well enough.

BotUser 08-09-2005 16:04

Re: cs weapons modification
 
Thanks for your input. I browsed through the SDK and I think I could gather what I need (function RadiusDamage to inflict damage, just needs the Vector of the nade, the inflictor, the attacker etc etc).

However, I did not get how to determine if a grenade is exploding to trigger the RadiusDamage function. You're writing about a server->client messages thing. Could you elaborate that a bit more for me poor newbie ? How do I catch the event of an exploding nade ?

Thanks a lot

botuser

PS: yes, I'm, still on the hunt concerning this, though it's a long time I posted my question :-)

Pierre-Marie Baty 08-09-2005 16:16

Re: cs weapons modification
 
All grenades explode after the same amount of time. You could start a timer when the grenade is fired? (that's the simplest of the solutions, perhaps not the most elegant, ok).

BotUser 08-09-2005 17:00

Re: cs weapons modification
 
Hi PMB,but that seems to boil down to the same problem. Finding out the point of time when a grenade is thrown would require me to react to a "throw-event" as well.

Maybe I didn't get it right. Please bear with me.

On the other hand, I'd like to not just make it work, but do it in the "right" way.
So if someone could kindly enlighten me concerning this message interception from server to client regarding an explosion event.

Thanks

botuser

Pierre-Marie Baty 08-09-2005 21:38

Re: cs weapons modification
 
I don't know by heart the type of message that is fired when a grenade explodes, but if I were you, here's what I'd do:

First, I'd download PMTools (get it from the filebase) and I'd set it to log all network messages to a text file with full details on.

Then, I'd run a game, spawn, buy a grenade, throw it, let it explode and after that I'd quit.

All the details about the network message that is involved when a grenade explodes will be in the PMTools log file you specified.

Then, in order to know how to hook a network message, I'd just look at the PMTools source code, since that's basically what it does :)

BotUser 09-09-2005 09:06

Re: cs weapons modification
 
Hi PMB,


many thanks for your suggestions. Well, that sounds like a plan. I'll try that and report back :)

botuser

The Storm 09-09-2005 11:33

Re: cs weapons modification
 
I have one question,
PMB where I can find the log file that is exported by PMtools?

BotUser 09-09-2005 13:47

Re: cs weapons modification
 
Hi,

I just used the PMTools plugin to log the messages.

Just enter
logfile "C:\msg.txt"
(for example) in the console to set the logfile output to C:\msg.txt

botuser

BotUser 09-09-2005 16:59

Re: cs weapons modification
 
So, I had a look at the log which PMTools was spitting out.
Since I didn't know which message to hook into, I had to change the source code a little to have it hook into every message. I didn't find a way to tell PMTools to log just any message. But nevertheless.

What I found is that there seems no special message associated with the detonation of a HE grenade. The only message I got was a "Damage" message since I dropped the nade directly in front of me. Hmmm .....

Well, but if I can get a "Damage" message for an entity, might it be possible to determine the damage inflictor, and if the inflictor is a HE grenade, just modify the damage/health of the respective entity ?

Input more than welcome.

botuser

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.

sPlOrYgOn 15-09-2005 04:49

Re: cs weapons modification
 
actually in war3mod it first sees if the damage kills the player then it sets the dead flag and health to 0 and sends the damage message and death message and updates the frags and deaths and gives the killer $300 then sends a message to update the money on the HUD of the killer..
basicly covers what CS does when a player kills another player..

BotUser 15-09-2005 22:22

Re: cs weapons modification
 
@sPlOrYgOn:
yes, you're right. However, if I just set health to 0 and the dead flag to 1 in CS, the killed player just freezes in an awkward position. So, what misses here is triggering the "death sequence" for a player getting killed. I dunno how this works in war3mod. Must check this further.

@Lazy:
who's the pityful creature you have in your sig picture ?

Lazy 16-09-2005 20:10

Re: cs weapons modification
 
First:
http://www.thatvideosite.com/view/518.html
http://www.thatvideosite.com/view/525.html

As for doing damage, it does seem that even though trigger_hurt->v.owner is set the damage inflictor does not get credit for the kill.
There may be other hacks to do damage but I'll have to look around for them when I get the chance.

Rusty Le Cyborg 23-09-2005 01:44

Re: cs weapons modification
 
2 Attachment(s)
Apologies for temporarily hijacking this thread, but I was wondering if this has been covered before.

Gas Grenades in CS or CZ?

I know there is a plugin for AMXMod that allows gas grenades. The problem being that they replace smoke grenades.

My question is... (to my hero Lazy!)

Is it possible to write a plugin which would enable them in CS? We have all the necessary models for them, and some sprites I believe.

Forum thread about Gas Nades

Cheers for now

PS - I will create another thread if you would rather :)

Lazy 23-09-2005 01:59

Re: cs weapons modification
 
Short answer:
It is not possible to add new weapons to an existing mod.

Long answer:
It can be hacked in, the flipside of tfc did this by giving every player a medkit and forcing them to select it when a custom weapon was used.
Unfortunately, CS and CZ do not have silent weapons so I don't think its possible that way.

It may however be possible to convert smoke grenades into gas grenades if the user presses the secondary attack button to change modes.

Since that only changes the behaviour of the entity rather than adding a new one it is probably possible.

I'll take a look at this tomorrow and see how it goes, I still have to finish a plugin for tfc that someone wanted.

Rusty Le Cyborg 23-09-2005 02:33

Re: cs weapons modification
 
Quote:

Originally Posted by Lazy
It may however be possible to convert smoke grenades into gas grenades if the user presses the secondary attack button to change modes.

Now that I'd like to see :)

Crikey... is there anything you don't know? ;)

Cheers for now

Lazy 02-10-2005 23:39

Re: cs weapons modification
 
Sorry for the delay of response, I'm still looking for a reliable way to damage players in CS.
Hopefully an idea will come around soon.

BotUser 29-10-2005 02:38

Re: cs weapons modification
 
No advance from my part on this issue. Well ... I guess I'll have to put up with the half-assed solution I have right now.

@Lazy: too bad you changed the your pic in the sig ...

Lazy 31-10-2005 03:37

Re: cs weapons modification
 
I'll take a look again later on when I have enough free space to re-install CS.

[offtopic]
I regularly change my avatar since I don't like to look at the same thing for a long period of time.
I have lots more of them but rotating them manually has been too time consuming.
[/offtopic]

Another crazy idea is to find the location of TakeDamage in memory.
If you do manage to find it you'll have to call it from assembly and figure out how it's arguments are placed on the stack.
For classes I think it's <object ptr> <param> <param> <ect> but I haven't touched that stuff in so long I may have it wrong or it may not be possible.

BotUser 03-11-2005 00:54

Re: cs weapons modification
 
As I can see, Lazy, you're a really devoted HL SDK guy. I highly appreciate your efforts and your input.

As far as the issue in this thread is concerned, I think I can live with what I have right now and I'll consider the case closed, so please don't waste any more of your precious time on this (unless you're interested in that problem yourself).

Thanks for your help, dude

botuser

Lazy 03-11-2005 01:34

Re: cs weapons modification
 
Actually, I am interested in getting the proper damage functions working since it would work properly every time.

But thats for a later project...

Rusty Le Cyborg 05-11-2005 14:38

Re: cs weapons modification
 
Hi Lazy...

Any more thoughts on Gas Grenades? Or is that all linked to the damage system?

Not a nag, just a quick question out of interest :)

Cheers for now

Lazy 06-11-2005 04:58

Re: cs weapons modification
 
Inorder to create gas grenades I will need a proper damage system.
Just faking the deaths/damage is horribly unreliable and can cause a lot of problems down the road.

I have a few ideas on how to inflict damage but quite a bit are insane...

- Try some other entities to inflict damage
- Try and reverse engineer CS's CBaseEntity class ( probably impossible )

I still have to re-install Visual C++ so I can try out some things.
But any other damage ideas are welcome as I'm just guessing here...

[Added]
Totally unrelated to realistic damage but I may have something for gas grenades...
If you want the grenades to do only temporary damage I have a way to do it right now.

Basically, I make the engine think the player is underwater and out of air - that way the lack of oxygen damage is done but the player recovers once out of the affected area.
It's a pretty big hack and oh crap you might not be able to fire some weapons around it...

I just thought about that now while I'm typing this, damn...

Rusty Le Cyborg 06-11-2005 19:43

Re: cs weapons modification
 
The temporary damage thing could be quite cool. In the AMX version of the Gas Grenade plugin they have incorporated a gas mask icon for when you are damaged. Maybe it's a similar thing.

Hopefully the answer will come to you in a blinding flash :)

Here that post again for AMX. Seems it has sounds for "gasps" and uses an icon...

http://djeyl.net/forum/index.php?showtopic=22220&st=180

Cheers for now

Lazy 07-11-2005 22:48

Re: cs weapons modification
 
I'll try another idea I had tonight and see what happens, hopefully I can figure something out.

Rusty Le Cyborg 09-11-2005 12:03

Re: cs weapons modification
 
Well, it would be pretty cool if it can be coded in...

Then all you have to work out is how to put in the camera, radio, molotov, LAW, zipline, syringe... 9_9

Cheers for now

Lazy 09-11-2005 19:22

Re: cs weapons modification
 
Oddly enough all of those are possible...
Still no reliable way of causing damage though.

Rusty Le Cyborg 11-11-2005 09:57

Re: cs weapons modification
 
Heh... You could always make it that using the camera not only triggers a map event, but takes a screenshot too :)

Cheers for now


All times are GMT +2. The time now is 20:04.

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