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

[Any] Mirror Damage [12.01.2013]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
neatek
AlliedModders Donor
Join Date: Jul 2010
Location: Russia
Plugin ID:
3457
Plugin Version:
1.1rc
Plugin Category:
Gameplay
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    2 
    Plugin Description:
    Prevent friendlyfire damage, and returns it back to attacker. (mirror damage)
    Old 01-10-2013 , 02:11   [Any] Mirror Damage [12.01.2013]
    Reply With Quote #1

    ~ 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 .
    Attached Files
    File Type: sp Get Plugin or Get Source (MirrorDamage.sp - 1050 views - 2.6 KB)
    File Type: smx MirrorDamage.smx (4.8 KB, 879 views)
    __________________

    Last edited by neatek; 01-11-2013 at 15:56. Reason: New version 1.1RC, thx Sheepdude for tips.
    neatek is offline
    Sreaper
    髪を用心
    Join Date: Nov 2009
    Old 01-10-2013 , 02:27   Re: [Any] Mirror Damage (sdkhooks)
    Reply With Quote #2

    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?

    Last edited by Sreaper; 01-10-2013 at 02:31.
    Sreaper is offline
    neatek
    AlliedModders Donor
    Join Date: Jul 2010
    Location: Russia
    Old 01-10-2013 , 02:30   Re: [Any] Mirror Damage (sdkhooks)
    Reply With Quote #3

    Quote:
    Originally Posted by Sreaper View Post
    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 View Post
    What are the differences?
    This is much easier than that.
    __________________

    Last edited by neatek; 01-10-2013 at 03:04.
    neatek is offline
    Sreaper
    髪を用心
    Join Date: Nov 2009
    Old 01-10-2013 , 02:31   Re: [Any] Mirror Damage (sdkhooks)
    Reply With Quote #4

    Great. Would you mind adding an sm_mirrordamage <client> command then?
    Sreaper is offline
    neatek
    AlliedModders Donor
    Join Date: Jul 2010
    Location: Russia
    Old 01-10-2013 , 02:33   Re: [Any] Mirror Damage (sdkhooks)
    Reply With Quote #5

    Quote:
    Originally Posted by Sreaper View Post
    Great. Would you mind adding an sm_mirrordamage <client> command then?
    For what this command? Plugin applies to all players.
    __________________
    neatek is offline
    Sreaper
    髪を用心
    Join Date: Nov 2009
    Old 01-10-2013 , 02:36   Re: [Any] Mirror Damage (sdkhooks)
    Reply With Quote #6

    Quote:
    Originally Posted by neatek View Post
    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!

    Last edited by Sreaper; 01-10-2013 at 02:38.
    Sreaper is offline
    ecca
    Sexy Santa
    Join Date: Jan 2011
    Old 01-10-2013 , 10:51   Re: [Any] Mirror Damage (sdkhooks)
    Reply With Quote #7

    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;

    ecca is offline
    neatek
    AlliedModders Donor
    Join Date: Jul 2010
    Location: Russia
    Old 01-10-2013 , 10:53   Re: [Any] Mirror Damage (sdkhooks)
    Reply With Quote #8

    Quote:
    Originally Posted by ecca View Post
    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...
    __________________

    Last edited by neatek; 01-10-2013 at 10:54.
    neatek is offline
    Sheepdude
    SourceMod Donor
    Join Date: Aug 2012
    Location: Chicago
    Old 01-10-2013 , 15:23   Re: [Any] Mirror Damage (sdkhooks)
    Reply With Quote #9

    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).
    __________________
    Sheepdude is offline
    neatek
    AlliedModders Donor
    Join Date: Jul 2010
    Location: Russia
    Old 01-10-2013 , 19:42   Re: [Any] Mirror Damage (sdkhooks)
    Reply With Quote #10

    Sheepdude, oh, thank you, it very helpful!
    I will take your advice note.
    __________________

    Last edited by neatek; 01-10-2013 at 19:59.
    neatek is offline
    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 05:34.


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