AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [Any] Mirror Damage [12.01.2013] (https://forums.alliedmods.net/showthread.php?t=205374)

neatek 01-10-2013 02:11

[Any] Mirror Damage [12.01.2013]
 
2 Attachment(s)
~ Mirror Damage UPDATED 12.01.13
Prevent friendlyfire damage, and returns it back to attacker.

Installation:
put MirrorDamage.smx into addons/sourcemod/plugins/

Cvars:
sm_mirrordamage_version - Version of plugin
sm_mirrordamage_multiplier - Amount of damage to inflict to attacker (Def: 0.7)
sm_mirrordamage_slap - Slap attacker?! or just subtraction health (Def: 0)
sm_mirrordamage_annonce - Type in chat about friendlyfire?! (Def: 0) Example: "NEATEK attacked a teammate"

Requiments:
SDKHooks

Counter-Strike: Source (works fine)
Counter-Strike: Global offensive (must works)
Team Fortrees 2 (must works)

Changelog:
1.1rc: // not tested
  1. added: CS:GO support // Sheepdude ty for tips.
  2. added: cvar: sm_mirrordamage_annonce
  3. added: cvar: sm_mirrordamage_slap
  4. fixed: damage from yourself // Sheepdude ty for tips.
  5. added: support for load plugin in middle of game // Sheepdude ty for tips.
1.0rc: // works
  1. plugin created .

Sreaper 01-10-2013 02:27

Re: [Any] Mirror Damage (sdkhooks)
 
There is another mirror damage plugin. Though that one has issues where the victim could get killed as well as the attacker.

Is that corrected in this one? What are the differences?

neatek 01-10-2013 02:30

Re: [Any] Mirror Damage (sdkhooks)
 
Quote:

Originally Posted by Sreaper (Post 1870717)
There is another mirror damage plugin. Though that one has issues where the victim could get killed as well as the attacker.

Is that corrected in this one? What are the differences?

I just did SDKHooks version. Yes, it fixed.

Quote:

Originally Posted by Sreaper (Post 1870717)
What are the differences?

This is much easier than that.

Sreaper 01-10-2013 02:31

Re: [Any] Mirror Damage (sdkhooks)
 
Great. Would you mind adding an sm_mirrordamage <client> command then? :3

neatek 01-10-2013 02:33

Re: [Any] Mirror Damage (sdkhooks)
 
Quote:

Originally Posted by Sreaper (Post 1870719)
Great. Would you mind adding an sm_mirrordamage <client> command then? :3

For what this command? Plugin applies to all players.

Sreaper 01-10-2013 02:36

Re: [Any] Mirror Damage (sdkhooks)
 
Quote:

Originally Posted by neatek (Post 1870720)
For what this command? Plugin applies to all players.

Nevermind don't worry about it. Though the plugin should probably be renamed "Return Friendly Fire" or something similar since it's specific to friendly fire.

Nice plugin nonetheless!

ecca 01-10-2013 10:51

Re: [Any] Mirror Damage (sdkhooks)
 
Could be good for anti tk. Anyway you could fix this bit.

PHP Code:

if(!victim)
        return 
Plugin_Continue;
    if(!
attacker)
        return 
Plugin_Continue;
    if(!
IsClientInGame(attacker))
        return 
Plugin_Continue;
    if(!
IsClientInGame(inflictor))
        return 
Plugin_Continue

to

PHP Code:

if(!victim || !attacker || !IsClientInGame(attacker) || !IsClientInGame(inflictor))
{
    return 
Plugin_Continue;



neatek 01-10-2013 10:53

Re: [Any] Mirror Damage (sdkhooks)
 
Quote:

Originally Posted by ecca (Post 1870889)
PHP Code:

if(!victim || !attacker || !IsClientInGame(attacker) || !IsClientInGame(inflictor))
{
    return 
Plugin_Continue;



This is was in my plugin, but i prefer to:
PHP Code:

    if(!victim)
        return 
Plugin_Continue;
    if(!
attacker)
        return 
Plugin_Continue;
    if(!
IsClientInGame(attacker))
        return 
Plugin_Continue;
    if(!
IsClientInGame(inflictor))
        return 
Plugin_Continue

this isnt error...

Sheepdude 01-10-2013 15:23

Re: [Any] Mirror Damage (sdkhooks)
 
1. SDKHooks is better, since the victim won't die as well. I like ecca's conditional statement format better, but since it's the same logic it doesn't really make a difference.

2. However, the attacker might not necessarily be a player, so before you check IsClientInGame(attacker), make sure attacker <= MaxClients.

3. Aside from using SDKHooks to avoid killing the victim, this plugin isn't significantly different from MadHamster's Reflect Team Damage plugin. I would recommend adding some extra features, such as convars that can slap or give verbal warnings to team attackers.

4. Also, a player can damage themself, such as with a nade. As it stands, the plugin will double the damage a player inflicts on themself, so make sure that attacker != victim.

5. For compatibility with CS:GO, you cannot use ForcePlayerSuicide directly in the OnTakeDamage function, or else it will cause srcds.exe to crash. Instead, you need to create a timer, such as:

Code:

if(mirrordamage < 0)
{
        CreateTimer(0.0, SlayTimer, attacker);
}

public Action:SlayTimer(Handle:timer, any:client)
{
        ForcePlayerSuicide(client);
}

6. You should also iterate through and hook clients in OnPluginStart or AskPluginLoad2, in case the plugin loaded late (after clients have already been put in the server).

neatek 01-10-2013 19:42

Re: [Any] Mirror Damage (sdkhooks)
 
Sheepdude, oh, thank you, it very helpful! :)
I will take your advice note.


All times are GMT -4. The time now is 07:17.

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