Raised This Month: $ Target: $400
 0% 

[solved] replicate eventscript's corelib/es damage || damage screen effect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
paegus
Senior Member
Join Date: Nov 2004
Location: Extreme low earth orbit
Old 08-26-2008 , 18:07   [solved] replicate eventscript's corelib/es damage || damage screen effect
Reply With Quote #1

I've been trying to port over my hidden:source server from Mani admin mod, Eventscripts and ES_Tools to just Sourcemod but, among other things I have yet to work out, I can't figure out how to properly replicate damage screen effects. In es I use corelib's damage function to get a nice screen flash for direct feedback but without es_fire I can't find a way to target !self and thus get the point_hurt to hit on a certain player.

So is there infact a way to do so?

Alternatively if there's another way to get those nifty damage effects, that would be cool too.

Cheers in advance.
__________________
Live and learn or die and teach by example.
Plugins Mine | Hidden:SourceMod

Last edited by paegus; 09-09-2008 at 20:01. Reason: i forgot to write the bit where i ask the actual question... silly me.
paegus is offline
The JCS
AlliedModders Donor
Join Date: Jan 2007
Location: Brazil
Old 08-26-2008 , 18:19   Re: replicate eventscript's corelib/es damage || damage screen effect
Reply With Quote #2

The visual effects? I think you can use something like this of course, you will need the Particles names.

If you want a "Fake event", you will need the CreateEvent, FireEvent and SetEvent functions. Try looking here.
The JCS is offline
Send a message via MSN to The JCS
paegus
Senior Member
Join Date: Nov 2004
Location: Extreme low earth orbit
Old 08-26-2008 , 18:25   Re: replicate eventscript's corelib/es damage || damage screen effect
Reply With Quote #3

all i want is the screen flash you get from lets say drowning or being poisoned, etc.

i think i've been through both of those already but thanks, i'll take another look-see.
paegus is offline
strontiumdog
Veteran Member
Join Date: Jan 2007
Location: BC, Canada
Old 08-26-2008 , 20:24   Re: replicate eventscript's corelib/es damage || damage screen effect
Reply With Quote #4

Fire up the code...we can usually translate it quickly!
__________________
Plugins | TheVille
Zombie Mod for DoD:S - l4dod.theville.org
strontiumdog is offline
paegus
Senior Member
Join Date: Nov 2004
Location: Extreme low earth orbit
Old 08-27-2008 , 06:55   Re: replicate eventscript's corelib/es damage || damage screen effect
Reply With Quote #5

oki doki...

my hdn_mirror.txt
Code:
...
// vic's reply
// audio
es_xrand md_rand 1 5
es_format md_reply "player/iris/IRIS-ff0%1.wav" server_var(md_rand)
es_emitsound player event_var(userid) server_var(md_reply) server_var(md_replyvol) server_var(md_replyattenuation)
// text
if (server_var(md_rand) == 1) then es_format md_reply "say_team Cease fire, cease fire, %1" event_var(es_attackername)
...
es_cexec event_var(userid) server_var(md_reply)
...
es damage event_var(attacker) server_var(md_damage) 16384
...
corelib/es_damage.txt
Code:
// damage corelib command, version 2 for ES 1.5
// usage:
//   damage <target user> <damage> <damage type> <source userid>
//     target user = the player(s) to be hurt,
//       supports foreach player flags, if preceeded with !, makes source userid immune, eg. !#all
//     damage = the amount of damage to do to player
//     damage type = (OPTIONAL) the type of the damage (number or "explosion")
//     source userid = (OPTIONAL) the player that causes the damage
//       REQUIRED when using user flags! Otherwise a random user gets credit...
//
// DAMAGE TYPES (if not "explosion")
// 0 		GENERIC
// 1 		CRUSH
// 2 		BULLET
// 4 		SLASH
// 8 		BURN
// 16 		FREEZE
// 32 		FALL   (recommended for CSS!)
// 64 		BLAST
// 128 		CLUB
// 256 		SHOCK
// 512 		SONIC
// 1024 	ENERGYBEAM
// 16384 	DROWN
// 32768 	PARALYSE
// 65536 	NERVEGAS
// 131072 	POISON
// 262144 	RADIATION
// 524288 	DROWNRECOVER
// 1048576 	CHEMICAL
// 2097152 	SLOWBURN
// 4194304 	SLOWFREEZE
//
block load
{
  es_xdoblock corelib/damage/damage_register
}

block damage_register
{
  // damage variables
  es_xset _core_dmg_args 0
  es_xset _core_dmg_exists 0
  es_xset _core_dmg_output 0
  es_xset _core_dmg_pending 0
  es_xset _core_dmg_active 0
  es_xset _core_dmg_c1 0
  es_xset _core_dmg_c2 0
  es_xset _core_dmg_player 0
  es_xexists _core_dmg_exists command damage
  if (server_var(_core_dmg_exists) == 0) do
  {
    es_xregcmd damage corelib/damage/command "Cause damage to a player."
  }
} 

block command
{
  es_xgetargc _core_dmg_args
  if (server_var(_core_dmg_args) < 3) do
  {
    es_xdbgmsg 0 "usage:"
    es_xdbgmsg 0 " damage <userid> <damage> [<type> [<source>]]"
  }
  else do
  {
    es_xset _core_dmg_target 0
    es_xset _core_dmg_damage 0
    es_xset _core_dmg_damagetype 32
    es_xset _core_dmg_pendarg 1
    es_xgetargv _core_dmg_damage 2
    es_xgetargv _core_dmg_target 1
    es_xset _core_dmg_source 0
    if (server_var(_core_dmg_args) >= 6) do
    {
      es_xgetargv _core_dmg_pendarg 5
      es_xmath _core_dmg_pendarg + 1
    }
    if (server_var(_core_dmg_args) >= 5) do
    {
      es_xgetargv _core_dmg_source 4
    }
    if (server_var(_core_dmg_args) >= 4) do
    {
      es_xgetargv _core_dmg_damagetype 3
    }
    es_xdoblock corelib/damage/dodamage
  }
}

block dodamage
{
  es_xcopy _core_dmg_c1 _core_dmg_target
  es_xcopy _core_dmg_c2 _core_dmg_target
  es_xstring _core_dmg_c1 section 0 1
  if (server_var(_core_dmg_c1) == "!") do
  {
    es_strlen _tempcore server_var(_core_dmg_c2)
    es_string _core_dmg_c2 section 1 server_var(_tempcore)
  }
  es foreach player _core_dmg_player server_var(_core_dmg_c2) "es_xdoblock corelib/damage/marktarget"
  ifx false(_core_dmg_source) do
  {
    es_getuserid _core_dmg_source server_var(_core_dmg_target)
    ifx false(_core_dmg_source) do
    {
      getrandplayer _core_dmg_source #all
    }
  }
  if (server_var(_core_dmg_c1) == "!") do
  {
    es_fire server_var(_core_dmg_source) !self addoutput "targetname mrhuman"
  }
  ifx false(_core_dmg_active) do
  {
    // es_give server_var(_core_dmg_source) point_hurt
    es_xtrick entity point_hurt
    es_xset _core_dmg_active 1
    es_xdelayed 0 es_xset _core_dmg_active 0
    es_fire server_var(_core_dmg_source) point_hurt Kill
  }
  es_xformatv _core_dmg_output "Damage %1" _core_dmg_damage
  es_fire server_var(_core_dmg_source) point_hurt addoutput server_var(_core_dmg_output)
  es_xformatv _core_dmg_output "DamageType %1" _core_dmg_damagetype
  es_fire server_var(_core_dmg_source) point_hurt addoutput server_var(_core_dmg_output)
  es_fire server_var(_core_dmg_source) point_hurt addoutput "DamageTarget mrdamage"
  es_fire server_var(_core_dmg_source) point_hurt Hurt
  es_fire server_var(_core_dmg_source) player addoutput "targetname mrhuman"
}

block marktarget
{
  es_fire server_var(_core_dmg_player) !self addoutput "targetname mrdamage"
}

what i have so far...
hdn_damageman.sm
Code:
...
			// Get attacker's origin
			new Float:attackerOrigin[3];
			GetClientAbsOrigin(attacker, attackerOrigin);

			new String:originData[64];
			Format(pointOrigin, sizeof(pointOrigin), "%f %f %f", attackerOrigin[0], attackerOrigin[1], attackerOrigin[2]+10);

			new String:pointDamage[64];
			Format(pointDamage, sizeof(pointDamage), "%f", damageNew);

			// Create the PointHurt

			PrintToServer("[DM] o:%s d:%s", pointOrigin, pointDamage)

			new pointHurt = CreateEntityByName("point_hurt");
			DispatchKeyValue(pointHurt,"Origin", pointOrigin);
			DispatchKeyValue(pointHurt,"Damage", pointDamage);
			DispatchKeyValue(pointHurt,"DamageRadius", "10");
			DispatchKeyValue(pointHurt,"DamageDelay", "0");
			DispatchKeyValue(pointHurt,"DamageType", "16384");
			DispatchSpawn(pointHurt);
			AcceptEntityInput(pointHurt, "TurnOn");
			// need a delay here
			//AcceptEntityInput(pointHurt, "TurnOff");
			//AcceptEntityInput(pointHurt, "Kill");

			new ffReply = GetRandomInt(1,5);

			if (victim)
			{
				// Victim is still alive, reply with voice.
				new String:replySound[32];
				Format(replySound, sizeof(replySound), "player/iris/IRIS-ff0%i.wav", ffReply);
				EmitSoundToClient(attacker, replySound);
				PrintToServer("[DM] a: %i, r: %s", attacker, replySound)

			}

			if (attacker)
			{
				// Attacker is still alive, reply with text.
				SaveHealth(attacker);

				new String:replyString[64];
				new String:attackerName[16];

				GetClientName(attacker, attackerName, sizeof(attackerName));
				Format(replyString, sizeof(replyString), "say_team %s, %s!", ffMsgs[ffReply-1], attackerName);
				FakeClientCommand(victim, replyString);
			}
...
but the point_hurt targets indiscriminately because i can't figure out how to name a target player without the likes of...
Code:
es_fire USER_TO_HURT !self addoutput "targetname mrdamage"
it also doesn't apply the correct damage type (16384, drowning) and doesn't actually cause any damage at all until the player moves. the origin data from the intended target is off by a few decimal points but should still be within range of the attacker. though that's not a very satisfactory solution as there may just be another player up close to receive that damage as well.

additionally, i haven't got the sound emitter working properly yet as it used to be emitted vocally from the victim but i can only guess that EmitSoundToAll() also needs to have a specific entity name (in this case a player) targetted and since i can't figure out how to tag a specific player for point_hurt's DamageTarget, i assume it's the same problem for EmitSoundToAll().

thanks in advance...
__________________
Live and learn or die and teach by example.
Plugins Mine | Hidden:SourceMod

Last edited by paegus; 08-27-2008 at 06:57.
paegus is offline
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 08-27-2008 , 10:51   Re: replicate eventscript's corelib/es damage || damage screen effect
Reply With Quote #6

DispatchKeyValue(USER_TO_HURT, "targetname", "mrdamage");
is the same as you're addoutput line.

You could also do
SetVariantString("targetname", "mrdamage");
followed by
AcceptEntityInput(USER_TO_HURT, "addoutput");
which would accomplish the exact same thing.
__________________
"Good grammar is essential, Robin."
- Batman
L. Duke is offline
paegus
Senior Member
Join Date: Nov 2004
Location: Extreme low earth orbit
Old 08-27-2008 , 10:57   Re: replicate eventscript's corelib/es damage || damage screen effect
Reply With Quote #7

cheers. i'll give that a try tonight.
__________________
Live and learn or die and teach by example.
Plugins Mine | Hidden:SourceMod
paegus is offline
strontiumdog
Veteran Member
Join Date: Jan 2007
Location: BC, Canada
Old 08-27-2008 , 10:57   Re: replicate eventscript's corelib/es damage || damage screen effect
Reply With Quote #8

LDuke beat me to it


Don't forget the DamageTarget keyvalue!
__________________
Plugins | TheVille
Zombie Mod for DoD:S - l4dod.theville.org
strontiumdog is offline
paegus
Senior Member
Join Date: Nov 2004
Location: Extreme low earth orbit
Old 09-09-2008 , 20:01   Re: replicate eventscript's corelib/es damage || damage screen effect
Reply With Quote #9

yeah i got it working nicely thanks guys.
__________________
Live and learn or die and teach by example.
Plugins Mine | Hidden:SourceMod
paegus 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 18:39.


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