Raised This Month: $ Target: $400
 0% 

[L4D2] Witch Melee Fix


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Plugin ID:
2104
Plugin Version:
1.1.2
Plugin Category:
General Purpose
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Applies melee damage in a correct manner on witches for servers with customized witch health
    Unapprover:
    Reason for Unapproving:
    Author's request.
    Old 11-29-2010 , 11:02   [L4D2] Witch Melee Fix
    Reply With Quote #1

    Witch Melee Fix

    About:
    This is for servers with custom witch health (z_witch_health) whether it be lower or higher than normal.

    By default the witch will ALWAYS die from 4 melee hits, no matter her max health. This is because the way Valve decided to calculate the damage melee weapon does on witch.
    Melee weapons always deal MAX WITCH HEALTH / 4, so even if the Witch had 50000 each melee hit would do 12500 damage, ultimately killing her still in 4 hits.

    This plugin fixes this problem by applying god mode while the original melee damage is being dealt and then restore her health with the fix melee damage done.

    Description:
    Applies melee damage in a correct manner on witches for servers with customized witch health

    Known Problems / Things to Notice:

    Cvars:
    Code:
    // How much damage melee weapons does to the witch (0 will completly block all melee damage to the witch, 250 is the default value).
    // -
    // Default: "250"
    l4d2_witch_melee_fix_damage "250"

    Changelog:
    Code:
    Version 1.1.2 - 01/12/2010
    ~ Fixed witches not taking damage if a survivor hit more than 1 witch in same swing.
    
    Version 1.1.1 - 30/11/2010
    ~ Fixed blunt melee weapons not being included.
    
    Version 1.1.0 - 29/11/2010
    ~ Fixed "Damage done to Witch" stats being affected by god mode.
    
    Version 1.0.0 - 29/11/2010
    Initial release
    Attached Files
    File Type: sp Get Plugin or Get Source (witchmeleefix.sp - 667 views - 8.8 KB)
    File Type: smx witchmeleefix.smx (7.6 KB, 526 views)

    Last edited by Mr. Zero; 12-01-2010 at 04:27.
    Mr. Zero is offline
    MarshalZCC
    Senior Member
    Join Date: Feb 2010
    Location: Alberta, Canada
    Old 11-29-2010 , 22:47   Re: [L4D2] Witch Melee Fix
    Reply With Quote #2

    The damage type you are checking against will only work for some melee weapons (slash). Best you just do a GetEdictClassname on the attacker and if its "weapon_melee" proceed. That way you don't have to track which survivors are holding melee weapons either.

    One other suggestion. You may want to look at AtomicStryker's damage plug-in and see how damage is applied there, rather than modifying the witch's health manually. Will probably cut down on a lot of code.
    MarshalZCC is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 11-30-2010 , 02:34   Re: [L4D2] Witch Melee Fix
    Reply With Quote #3

    Quote:
    Originally Posted by MarshalZCC View Post
    The damage type you are checking against will only work for some melee weapons (slash). Best you just do a GetEdictClassname on the attacker and if its "weapon_melee" proceed. That way you don't have to track which survivors are holding melee weapons either.

    One other suggestion. You may want to look at AtomicStryker's damage plug-in and see how damage is applied there, rather than modifying the witch's health manually. Will probably cut down on a lot of code.
    I will add blunt melee weapons.
    Also if I can't see which survivor I can't stop the OnTakeDamage from being triggered multiple times (all from 1 to as much as 12).

    I took a look at Atomics damage mod. He simply changes damage within the hook.
    I tired changing the damage however if the original melee damage would be enough to kill the witch, it would kill her no matter what I set it to. Might have been a fluke I will test it some more.

    Thanks sir.
    Mr. Zero is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 11-30-2010 , 03:30   Re: [L4D2] Witch Melee Fix
    Reply With Quote #4

    Alright I tested it out.

    Changing damage inside the hook, does NOTHING. I tested this with 100000 hp witches. 4 hits after damage was fixed to 250 and she still died.

    Printing the damage on the post hook, showed the damage was fixed however it still dealt original damage. I could set the damage to 0 and original damage would still be dealt.

    I tried changing the damage type and damage. 4 hits and she dies. Ammo type, 4 hits. Attack and inflictor, 4 hits.
    Doesn't matter what I change inside that hook. Melee weapons clearly have a subsystem for dealing damage to the witch which cannot be overridden.

    I agree this god mode method is a bitch and it is a lot longer than I really want for some this simple, but melee weapons cheats when it comes to dealing damage.

    Anyway, I remove the damage type check since I already check for melee weapon.
    Mr. Zero is offline
    AtomicStryker
    Veteran Member
    Join Date: Apr 2009
    Location: Teutonia!!
    Old 11-30-2010 , 04:01   Re: [L4D2] Witch Melee Fix
    Reply With Quote #5

    Have you tried returning Plugin_Handled for OnTakeDamage? To keep her from dying
    AtomicStryker is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 11-30-2010 , 05:15   Re: [L4D2] Witch Melee Fix
    Reply With Quote #6

    Yes. Works fine.

    That was also what I did first, however then I came to damaging her.

    1. Changing damage inside hook of course didn't work.
    2. point_hurt did nothing to the witch
    3. Blood and pain sounds from the witch wouldn't be played.

    Where the current method solves all the problems above just by applying god mode while the original melee damage is being dealt.
    Mr. Zero is offline
    MarshalZCC
    Senior Member
    Join Date: Feb 2010
    Location: Alberta, Canada
    Old 11-30-2010 , 12:34   Re: [L4D2] Witch Melee Fix
    Reply With Quote #7

    Regarding the damage plug-in written by AtomicStryker, I was referring to the non-SDKHook one. The SDKHook one is known to have issues since you can't change the damage within OnTakeDamage for Left 4 Dead 2. The non-SDKHook one applies point_hurt to the witch - this indeed does work (I have tried it successfully myself).

    Concerning determining which Survivor to stop the multiple OnTakeDamage calls from triggering, you could simply grab the m_hOwner netprop from the melee weapon entity, rather than track weapon pick-ups via events and such, which seems more complicated to me. However, if you want to make it really slick, why bother adding a cooldown per survivor but rather per witch? You could use an adt array to dynamically track which witches have been recently melee'd. Here is a portion of what I came up with:

    Code:
    public Action:OnWitchTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
    {
        static const WITCH_MELEE_DAMAGE = 250;
        
        decl String:name[64];
        GetEdictClassname(attacker, name, sizeof(name));
        
        if (StrEqual(name, "weapon_melee"))
        {    
            if (FindValueInArray(adtWitchMelee, victim) > -1)
            {
                return Plugin_Continue;
            }
            
            PushArrayCell(adtWitchMelee, victim);
            CreateTimer(0.2, Timer_MeleeCooldown, victim);
        
            new owner = GetEntPropEnt(attacker, Prop_Data, "m_hOwner");
            
            applyDamage(WITCH_MELEE_DAMAGE, victim, owner); //see Atomic's damage plugin
            
            return Plugin_Handled;
        }
        
        return Plugin_Continue;
    }
    
    public Action:Timer_MeleeCooldown(Handle:timer, any:witch)
    {
        new index = FindValueInArray(adtWitchMelee, witch);
        
        if (index > -1)
        {
            RemoveFromArray(adtWitchMelee, index);
        }
    }
    MarshalZCC is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 11-30-2010 , 13:34   Re: [L4D2] Witch Melee Fix
    Reply With Quote #8

    Quote:
    Originally Posted by MarshalZCC View Post
    Regarding the damage plug-in written by AtomicStryker, I was referring to the non-SDKHook one. The SDKHook one is known to have issues since you can't change the damage within OnTakeDamage for Left 4 Dead 2. The non-SDKHook one applies point_hurt to the witch - this indeed does work (I have tried it successfully myself).

    Concerning determining which Survivor to stop the multiple OnTakeDamage calls from triggering, you could simply grab the m_hOwner netprop from the melee weapon entity, rather than track weapon pick-ups via events and such, which seems more complicated to me. However, if you want to make it really slick, why bother adding a cooldown per survivor but rather per witch? You could use an adt array to dynamically track which witches have been recently melee'd. Here is a portion of what I came up with:...
    I appropriate your help, but I have some doubts about point_hurt.
    applyDamage is just a wrapper for creating a point hurt and my testing showed Wiitch did not take any damage.

    Even IF the witch was hurt by a point_hurt, she wouldn't play the witch pain sound nor would the blood animation play.

    Right now I can't think of any other way to hurt her, as such I just do it in reverse.
    Allow her to be hit, but with god mode on.

    That way we solve a number of problems.
    1. Witch plays hurt sound.
    2. Client sees the Witch blood.
    3. The Witch gets harassed on first melee attack (which she wouldn't be if we just blocked the melee).

    I tracked melee owners through item pickups instead of netprops because I assumed it would be cheaper to use than call a netprop every time someone hurts the Witch.
    However I'm not sure, so if anyone could back up whether would be better than I will of course change.
    I highly doubth the memory usage for storing 32 cells is that high and compared to getting a prop every time the witch is hurt is neither that high.
    Either way I don't think changing to one or another will make a big difference.

    I track per survivor instead of per witch as their can be many survivor hitting the same witch, however each survivor can't do more than 1 melee attack at a time.
    Assuming I used per witch, what happens if 2 survivors hit within the same melee cooldown? Someone gets their damage denied.
    While tracking for each survivor, no one gets denied no matter how close of time, they hurt the Witch.

    Also why would you use a dynamic array? You know max and min, and you can easy jump to index by client index (or entity index in your example). Doing a dynamic array for this seems impractical.

    I feel you are trying to compact it without purpose. Have you tested the current version? It is working flawlessly and running it on a 16 map coop, no lag what so ever.
    Mr. Zero is offline
    MarshalZCC
    Senior Member
    Join Date: Feb 2010
    Location: Alberta, Canada
    Old 11-30-2010 , 15:02   Re: [L4D2] Witch Melee Fix
    Reply With Quote #9

    You may have your doubts, but it works flawlessly for me, damage, screams, blood, and all. Yes, applyDamage is just a wrapper to a common piece of code that many people use. The owner netprop is only retrieved if the witch is hit by a melee weapon (that's the entire point anyway), and only after the cooldown. I don't see why you would think its an expensive operation given the situation. Its not about the memory storage, its about the complication of your solution, which tends to lead to harder to maintain software. I'm just trying to help out with a more elegant solution.

    If two survivors hit a witch with a melee weapon within 0.2 seconds, then yes that is the downside to the solution. But I could also argue that a Survivor hitting 2 witches at the same time, causing 1 witch to not take any damage is the disadvantage of yours. I guess I felt I would rather my situation happen.

    The dynamic array is not for survivors, its for witches. A dynamic array for survivors would seem impractical, you are right.

    If you don't like my solution, that's fair. I don't expect you to change your code if you don't want to - its your code. However, I figured I'd try to help you out. If you don't want it, that's cool.

    Last edited by MarshalZCC; 11-30-2010 at 15:14.
    MarshalZCC is offline
    Skorpion1976
    Veteran Member
    Join Date: Jun 2009
    Location: Austria
    Old 12-01-2010 , 03:10   Re: [L4D2] Witch Melee Fix
    Reply With Quote #10

    Hey Mr. Zero, thanks for creating this! Before I start a live "test": I use a witch multiplier plugin on our servers so VERY often the poor survivor gets attacked by half a dozen of them. Does your code handle the witch HP only during a single-witch attack or also during situations where 1 survivor gets attacked by 2-n witches at the same time? So if the victim is under attack of 5 witches and 2-n survivors fight them off --> does your code reduce the damage being dealt to ALL 5 witches? What happens if 2 survivors melee 2 different witches at the same time, does the code handle this too ?

    Last edited by Skorpion1976; 12-01-2010 at 03:24.
    Skorpion1976 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 20:19.


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