Raised This Month: $32 Target: $400
 8% 

Solved [L4D2] Witch target override in better way?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 12-27-2020 , 22:00   [L4D2] Witch target override in better way?
Reply With Quote #1

As the title says, I need a function like this
PHP Code:

//entitiy: witch
//client: a target that witch will chase 
//return true if succeed, return false if can't change witch target

bool WitchAttackTargetint entityint client
Change target when the witch incapacitates or kills victim,
I know some plugins already did this before, but there are still some problems.

Example:
1. [L4D & L4D2] Evil Witch
Spawns a new witch and give a hurt point. I think that is not good.

2. [L4D2] Relentless Witch
He uses signature "@_ZN8Infected15OnHitByVomitJarEP20CBaseComba tCharacter" on witch, but the director will call a horde.

Edit:
Thanks BHaType, xZk, cravenge and silvers, I write code here for myself
__________________

Last edited by HarryPotter; 01-10-2021 at 09:53. Reason: see solution
HarryPotter is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 12-28-2020 , 00:23   Re: [L4D2] Witch target override in better way?
Reply With Quote #2

Is not exactly what you asked...

Maybe you can force the target with CommandABot

Usually, we use that for bots (clients) (Scavenge Bots use this, I think).

I have never seen a plugin to common infected/witch.

Didn't test but here are some examples.

https://gist.github.com/Rectus/8d760...c5ce378ed09264 (steamworkshop source)

https://github.com/search?q=commanda...3Asp&type=code
__________________

Last edited by Marttt; 12-28-2020 at 00:26.
Marttt is offline
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 12-28-2020 , 03:27   Re: [L4D2] Witch target override in better way?
Reply With Quote #3

My old practices, they work but as far as I remember the server will crash if you change the target when the witch is not scared yet

You can also literally change the target to any entity and patch the WitchAttack::IsValidEnemy function so the witch can run after anyone and not just survivors

Spoiler


Note:
If this still works then I might try to make a more advanced version and this is for windows only
__________________
cry

Last edited by BHaType; 12-28-2020 at 03:29.
BHaType is offline
Send a message via AIM to BHaType
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 12-28-2020 , 04:27   Re: [L4D2] Witch target override in better way?
Reply With Quote #4

I will give a try and report
__________________
HarryPotter is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 12-28-2020 , 07:45   Re: [L4D2] Witch target override in better way?
Reply With Quote #5

Quote:
Originally Posted by BHaType View Post
Note:
If this still works then I might try to make a more advanced version and this is for windows only
I just tested,
Everything works fine in windows server,
no crash, no wired behavior.

I just have a little wish,
It could be better if we can force witch to attack another target again even after witch had lost her target or killed survivor already.
__________________

Last edited by HarryPotter; 12-28-2020 at 08:27.
HarryPotter is offline
larrybrains
Senior Member
Join Date: May 2017
Old 12-29-2020 , 22:47   Re: [L4D2] Witch target override in better way?
Reply With Quote #6

Quote:
Originally Posted by BHaType View Post
If this still works then I might try to make a more advanced version and this is for windows only
Would love to see a Linux version of this.
larrybrains is offline
xZk
Senior Member
Join Date: Nov 2017
Location: cl
Old 01-02-2021 , 20:15   Re: [L4D2] Witch target override in better way?
Reply With Quote #7

ago I was looking for something like that, and maybe this can be useful when the witch loses her objective, but I think it only works for survivors :/:
PHP Code:
stock void WitchChangeTarget(int witchint target)
{
    
//PrintToChatAll("attacking target %N", target);
    
if(GetEntProp(witchProp_Send"m_bIsBurning") == 1){
        
ExtinguishEntity(witch);
        
SDKHooks_TakeDamage(witchtargettarget0.0DMG_BURN);
    }else{
        
int anim GetEntProp(witchProp_Send"m_nSequence");
        
SDKHooks_TakeDamage(witchtargettarget0.0DMG_BURN);
        
SetEntProp(witchProp_Send"m_nSequence"anim);
        
SetVariantFloat(0.0);
        
AcceptEntityInput(witch"IgniteLifetime");
        
//ExtinguishEntity(witch);// no works
        
SetEntProp(witchProp_Send"m_bIsBurning"0);
        
int ent GetEntPropEnt(witchProp_Data"m_hMoveChild");
        if(
IsValidEnt(ent)){
            
char classname[32];
            
GetEntityClassname(entclassnamesizeof(classname));
            if(
strcmp(classname"entityflame") == 0){
                
SDKHook(entSDKHook_SetTransmitSetTransmit_Fire);
            }
        }
    }
}

public 
Action SetTransmit_Fire(int entityint client)
{
    return 
Plugin_Handled;

xZk is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 01-04-2021 , 21:30   Re: [L4D2] Witch target override in better way?
Reply With Quote #8

Quote:
Originally Posted by xZk View Post
ago I was looking for something like that, and maybe this can be useful when the witch loses her objective, but I think it only works for survivors :/:
Working for survivors is enough to me, I will give a try
__________________
HarryPotter is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 01-10-2021 , 07:21   Re: [L4D2] Witch target override in better way?
Reply With Quote #9

Thanks BHaType, xZk, cravenge and silvers, I write a script for myself

Witch target override Improved version 1.8 [2022/11/14]
Change target when the witch incapacitates or kills victim + witchs auto follow survivors

Feature
* Witch is allowed to chase another target after she incapacitates a survivor.
* Witch is allowed to chase another target after she kills a survivor.
* Witch will not follow survivor if there is a wall between witch and survivor.
* Witch will not follow survivor if survivor standing on the higher place.
* Witch burns for a set amount of time and die. ("z_witch_burn_time" is 15 seconds)

apply to:
L4D1/2


-Source Code Download-
Latest version always here
__________________

Last edited by HarryPotter; 07-31-2023 at 15:44. Reason: v1.7 release
HarryPotter is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 01-10-2021 , 08:47   Re: [L4D2] Witch target override in better way?
Reply With Quote #10

You might improve the method on completely removing the fire from the Witch. You could take a look at the Bots Trigger Witch plugin by Silvers.
cravenge 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 07:02.


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