Raised This Month: $51 Target: $400
 12% 

Proper way to deal damage without extensions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
API
Veteran Member
Join Date: May 2006
Old 12-13-2009 , 00:42   Proper way to deal damage without extensions
Reply With Quote #1

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.
__________________
API is offline
Send a message via AIM to API
Downtown1
Veteran Member
Join Date: Mar 2004
Old 12-13-2009 , 01:14   Re: Proper way to deal damage without extensions
Reply With Quote #2

war3_hurtme ?
Downtown1 is offline
API
Veteran Member
Join Date: May 2006
Old 12-13-2009 , 01:17   Re: Proper way to deal damage without extensions
Reply With Quote #3

Its the targetname I use because of war3source... point_hurt works by looking up a target name. You can make it whatever you want really.
__________________
API is offline
Send a message via AIM to API
Dragonshadow
BANNED
Join Date: Jun 2008
Old 12-13-2009 , 09:18   Re: Proper way to deal damage without extensions
Reply With Quote #4

Oooh cool
Dragonshadow is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 12-13-2009 , 10:17   Re: Proper way to deal damage without extensions
Reply With Quote #5

Pretty useful. Thank you!
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
TerroriZe
Member
Join Date: Dec 2009
Old 12-13-2009 , 10:34   Re: Proper way to deal damage without extensions
Reply With Quote #6

Dang I was so close ^_^ Anyways ty so much..thats gonna help..
TerroriZe is offline
Damizean
SourceMod Donor
Join Date: Mar 2009
Old 12-13-2009 , 12:24   Re: Proper way to deal damage without extensions
Reply With Quote #7

Quote:
Originally Posted by pimpinjuice View Post
Its the targetname I use because of war3source... point_hurt works by looking up a target name. You can make it whatever you want really.
What if you use !activator and pass that to the activator in the AcceptEntityInput? Does that work?
__________________
Dat annoying guy
Damizean is offline
Send a message via AIM to Damizean Send a message via MSN to Damizean
API
Veteran Member
Join Date: May 2006
Old 12-13-2009 , 12:53   Re: Proper way to deal damage without extensions
Reply With Quote #8

I'm not sure, I'm assuming your using EventScripts. Give it a try.
__________________
API is offline
Send a message via AIM to API
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 12-14-2009 , 17:21   Re: Proper way to deal damage without extensions
Reply With Quote #9

Quote:
Originally Posted by Damizean View Post
What if you use !activator and pass that to the activator in the AcceptEntityInput? Does that work?
I have been doing that in alot of scenarios; it works fine.
Wazz is offline
TerroriZe
Member
Join Date: Dec 2009
Old 12-14-2009 , 17:31   Re: Proper way to deal damage without extensions
Reply With Quote #10

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

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?
TerroriZe is offline
Reply



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 05:00.


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