Raised This Month: $32 Target: $400
 8% 

Proper way to deal damage without extensions


Post New Thread Reply   
 
Thread Tools Display Modes
API
Veteran Member
Join Date: May 2006
Old 12-14-2009 , 17:35   Re: Proper way to deal damage without extensions
Reply With Quote #11

Why are you creating the event? It will automatically occur if you use DealDamage()
Also, I don't think you can make it headshot unfortunately, maybe a hook inside player_hurt to force a headshot might?
__________________
API is offline
Send a message via AIM to API
psychonic

BAFFLED
Join Date: May 2008
Old 12-14-2009 , 17:39   Re: Proper way to deal damage without extensions
Reply With Quote #12

Quote:
Originally Posted by TerroriZe View Post
I got 2 questions :

1.) Can you fake headshot damage as well? I basically want to create fake damage which kills somebody with a headshot...
Probably not. Most games rely on hitgroup for that from a trace. There does not appear to be any hitgroup key to set on the point_hurt entity.
http://developer.valvesoftware.com/wiki/Point_hurt

Quote:
Originally Posted by TerroriZe View Post
I got 2 questions :
2.) Im a bit confused... why is this method failing? ->

Code:
new Handle:event_hurt = CreateEvent("player_hurt");
SetEventInt(event_hurt, "userid", GetClientUserId(victim));
SetEventInt(event_hurt, "attacker", GetClientUserId(client));
SetEventInt(event_hurt, "dmg_health", health+1);
SetEventString(event_hurt, "weapon", weapon);
SetEventBool(event_hurt, "headshot", headshot);
FireEvent(event_hurt);
And how to use it, if not like that?
Events are just notifications. They get fired after the event actually happens and only exist to notify the server, client, and/or any plugins with event listeners that the event occurred. Firing the player_hurt event manually would lie that the player was hurt, but they would not actually take damage or lose health.
psychonic is offline
TerroriZe
Member
Join Date: Dec 2009
Old 12-14-2009 , 17:58   Re: Proper way to deal damage without extensions
Reply With Quote #13

ah ok thanks both of you.. that helped alot ^_^

This got me confused: http://wiki.alliedmods.net/Events_%2...d_Scripting%29

Last edited by TerroriZe; 12-14-2009 at 18:05.
TerroriZe is offline
voogru
Inspector Javert
Join Date: Oct 2004
Old 12-17-2009 , 19:30   Re: Proper way to deal damage without extensions
Reply With Quote #14

Quote:
Originally Posted by pimpinjuice View Post
Because I love you.

Code:
#define DMG_GENERIC			0
#define DMG_CRUSH			(1 << 0)
#define DMG_BULLET			(1 << 1)
#define DMG_SLASH			(1 << 2)
#define DMG_BURN			(1 << 3)
#define DMG_VEHICLE			(1 << 4)
#define DMG_FALL			(1 << 5)
#define DMG_BLAST			(1 << 6)
#define DMG_CLUB			(1 << 7)
#define DMG_SHOCK			(1 << 8)
#define DMG_SONIC			(1 << 9)
#define DMG_ENERGYBEAM			(1 << 10)
#define DMG_PREVENT_PHYSICS_FORCE	(1 << 11)
#define DMG_NEVERGIB			(1 << 12)
#define DMG_ALWAYSGIB			(1 << 13)
#define DMG_DROWN			(1 << 14)
#define DMG_TIMEBASED			(DMG_PARALYZE | DMG_NERVEGAS | DMG_POISON | DMG_RADIATION | DMG_DROWNRECOVER | DMG_ACID | DMG_SLOWBURN)
#define DMG_PARALYZE			(1 << 15)
#define DMG_NERVEGAS			(1 << 16)
#define DMG_POISON			(1 << 17)
#define DMG_RADIATION			(1 << 18)
#define DMG_DROWNRECOVER		(1 << 19)
#define DMG_ACID			(1 << 20)
#define DMG_SLOWBURN			(1 << 21)
#define DMG_REMOVENORAGDOLL		(1 << 22)
#define DMG_PHYSGUN			(1 << 23)
#define DMG_PLASMA			(1 << 24)
#define DMG_AIRBOAT			(1 << 25)
#define DMG_DISSOLVE			(1 << 26)
#define DMG_BLAST_SURFACE		(1 << 27)
#define DMG_DIRECT			(1 << 28)
#define DMG_BUCKSHOT			(1 << 29)

DealDamage(victim,damage,attacker=0,dmg_type=DMG_GENERIC,String:weapon[]="")
{
	if(victim>0 && IsValidEdict(victim) && IsClientInGame(victim) && IsPlayerAlive(victim) && damage>0)
	{
		new String:dmg_str[16];
		IntToString(damage,dmg_str,16);
		new String:dmg_type_str[32];
		IntToString(dmg_type,dmg_type_str,32);
		new pointHurt=CreateEntityByName("point_hurt");
		if(pointHurt)
		{
			DispatchKeyValue(victim,"targetname","war3_hurtme");
			DispatchKeyValue(pointHurt,"DamageTarget","war3_hurtme");
			DispatchKeyValue(pointHurt,"Damage",dmg_str);
			DispatchKeyValue(pointHurt,"DamageType",dmg_type_str);
			if(!StrEqual(weapon,""))
			{
				DispatchKeyValue(pointHurt,"classname",weapon);
			}
			DispatchSpawn(pointHurt);
			AcceptEntityInput(pointHurt,"Hurt",(attacker>0)?attacker:-1);
			DispatchKeyValue(pointHurt,"classname","point_hurt");
			DispatchKeyValue(victim,"targetname","war3_donthurtme");
			RemoveEdict(pointHurt);
		}
	}
}
Example usage:
Code:
DealDamage(victim_index,50,attacker_index,DMG_BULLET,"weapon_ak47");
Works for CSS and TF2, should work for all games.
Creating and deleting an entity every time you do a damage call is a little inefficient IMO.

If you really wanted to use this method, I'd spawn a point_hurt one time at map start and then always use that entity rather than constantly respawning them.

And even then, I'd only do that in the absence of the extension that does it properly.

Just my opinion dont mind me
voogru is offline
Sammy-ROCK!
Senior Member
Join Date: Jun 2008
Location: Near Mrs.Lag
Old 12-17-2009 , 20:56   Re: Proper way to deal damage without extensions
Reply With Quote #15

Then it would need to be integrated with your plugin and not a simple snippet.
Sammy-ROCK! is offline
Darkimmortal
Senior Member
Join Date: Aug 2008
Old 12-23-2009 , 00:32   Re: Proper way to deal damage without extensions
Reply With Quote #16

I take it there's no way to deal damage from the client to themselves with this?

Specifically in conjunction with pyro flamethrower to create a jetpack effect in PropHunt.
__________________
Darkimmortal is offline
CrancK
Senior Member
Join Date: Jan 2009
Location: Netherlands
Old 12-23-2009 , 11:43   Re: Proper way to deal damage without extensions
Reply With Quote #17

if you kill people using damage like this, making the attacker another client, what kill-message would come up (tf2 particularly?)

the weapon the attacker is currently holding? or a world kill message?

also, i'm guessing this way painsounds automatically play?
(my previous method of dealing damage made use of SetEntityHealth, and thus had no sound, which i had to provide for it )

edit: ohw, also... does this damage push a player?
CrancK is offline
Sammy-ROCK!
Senior Member
Join Date: Jun 2008
Location: Near Mrs.Lag
Old 12-23-2009 , 16:07   Re: Proper way to deal damage without extensions
Reply With Quote #18

A suicide message like when a soldier kills himself with a rocket?
Sammy-ROCK! is offline
Dragonshadow
BANNED
Join Date: Jun 2008
Old 12-24-2009 , 09:39   Re: Proper way to deal damage without extensions
Reply With Quote #19

Quote:
Originally Posted by Darkimmortal View Post
I take it there's no way to deal damage from the client to themselves with this?

Specifically in conjunction with pyro flamethrower to create a jetpack effect in PropHunt.

When I kill myself with damage from myself to myself with the demoman bottle it gives me a kill message like this:

|Bottle Icon| |My name|
Dragonshadow is offline
API
Veteran Member
Join Date: May 2006
Old 12-24-2009 , 15:14   Re: Proper way to deal damage without extensions
Reply With Quote #20

Quote:
Originally Posted by CrancK View Post
if you kill people using damage like this, making the attacker another client, what kill-message would come up (tf2 particularly?)

the weapon the attacker is currently holding? or a world kill message?

also, i'm guessing this way painsounds automatically play?
(my previous method of dealing damage made use of SetEntityHealth, and thus had no sound, which i had to provide for it )

edit: ohw, also... does this damage push a player?
Yes, with this function proper death messages occur, as well as stat plugin compatibility.
DealDamage(victim_index,50,attacker_index,DMG _BULLET,"weapon_ak47");

That would make the engine think victim_index was shot for 50 damage (armor distribution works too) with an AK47 used by attacker_index. You can have alot of fun experimenting with Damage type as well.
__________________
API is offline
Send a message via AIM to API
Reply


Thread Tools
Display Modes

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


All times are GMT -4. The time now is 15:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode