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

Solved [L4D2] How to make AI Tank die instantly on climb sequence?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
philipjfry
Junior Member
Join Date: Sep 2019
Location: Somewhere in europe
Old 05-22-2021 , 14:15   [L4D2] How to make AI Tank die instantly on climb sequence?
Reply With Quote #1

Hi,

When a bot Tank starts to climb over something and you've managed to already damage him to 10-30% HP, there is a moment of few seconds in the climb sequence where he becomes invulnerable (the tanks health gets set to 1) and you won't be able to kill him TILL this sequence is finished and you deliver a final blow.

Tanks health is low only few shots needed anymore -> *tank climbs* he gets shot "dead", but he isn't allowed to die, his health is set to 1. -> *tank finished climbing* his HP is still 1, needs 1 hit to die.

How to make it so he CAN be killed during the climb sequence?

Last edited by philipjfry; 05-22-2021 at 19:33.
philipjfry is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 05-22-2021 , 14:46   Re: [L4D2] How to make AI Tank die instantly on climb sequence?
Reply With Quote #2

Quote:
Originally Posted by philipjfry View Post
Hi,

When a bot Tank starts to climb over something and you've managed to already damage him to 10-30% HP, there is a moment of few seconds in the climb sequence where he becomes invulnerable (the tanks health gets set to 1) and you won't be able to kill him TILL this sequence is finished and you deliver a final blow.

Tanks health is low only few shots needed anymore -> *tank climbs* he gets shot "dead", but he isn't allowed to die, his health is set to 1. -> *tank finished climbing* his HP is still 1, needs 1 hit to die.

How to make it so he CAN be killed during the climb sequence?
Track In Sdkhook OnTakeDamage if he should have died(Damage greater than health), if so, use ForcePlayerSuicide function to force kill him.
MasterMind420 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 05-22-2021 , 14:53   Re: [L4D2] How to make AI Tank die instantly on climb sequence?
Reply With Quote #3

Something like this...

Code:
public void OnClientPutInServer(int client)
{
	SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}

public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3])
{
	if (IsValidClient(victim) && IsClientInGame(victim) && GetClientTeam(victim) == 3)
	{
		if (GetEntProp(victim, Prop_Send, "m_zombieClass") == 8 && damage > float(GetEntProp(victim, Prop_Data, "m_iHealth")))
			ForcePlayerSuicide(victim);
	}
}

stock bool IsValidClient(int client)
{
	return (client > 0 && client <= MaxClients);
}
You can also check for MoveType Ladder but in all honesty I dont think it will matter, this will always guarantee the tank dies when taking more damage than health. You'd have to test this because forcing suicide on a ledge may look weird, or not, i dunno...Also survivors have the entprop isfallingfromledge, not sure if the tanks one will work but if there is an issue killing it during the climb it may be necessary to set that as well.

Last edited by MasterMind420; 05-22-2021 at 14:58.
MasterMind420 is offline
philipjfry
Junior Member
Join Date: Sep 2019
Location: Somewhere in europe
Old 05-22-2021 , 19:35   Re: [L4D2] How to make AI Tank die instantly on climb sequence?
Reply With Quote #4

Quote:
Originally Posted by MasterMind420 View Post
Something like this...

Code:
public void OnClientPutInServer(int client)
{
	SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}

public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3])
{
	if (IsValidClient(victim) && IsClientInGame(victim) && GetClientTeam(victim) == 3)
	{
		if (GetEntProp(victim, Prop_Send, "m_zombieClass") == 8 && damage > float(GetEntProp(victim, Prop_Data, "m_iHealth")))
			ForcePlayerSuicide(victim);
	}
}

stock bool IsValidClient(int client)
{
	return (client > 0 && client <= MaxClients);
}
You can also check for MoveType Ladder but in all honesty I dont think it will matter, this will always guarantee the tank dies when taking more damage than health. You'd have to test this because forcing suicide on a ledge may look weird, or not, i dunno...Also survivors have the entprop isfallingfromledge, not sure if the tanks one will work but if there is an issue killing it during the climb it may be necessary to set that as well.
Thanks, got it working okay with this method.
philipjfry is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 05-23-2021 , 14:30   Re: [L4D2] How to make AI Tank die instantly on climb sequence?
Reply With Quote #5

Quote:
Originally Posted by philipjfry View Post
Thanks, got it working okay with this method.
np, as a side note, anything tracking tank kills and such will not get a kill for it, because of the suicide function under this scenario. It may be possible within OnTakeDamage instead of forcing the suicide setting the damage value instead to force kill them, effectively fixing that issue...although i suspect that setting the damage value with return Plugin_changed wont change anything, maybe instead use SDKHook_OnTakeDamageAlivePost hook and set the damage value from there to fix it, with return Plugin_changed. Just some thoughts...

Also as an optimization, i would instead hook ontakedamage from within tank_spawn/player_spawn event hook, that way it just hooks the tank and no one else.

Last edited by MasterMind420; 05-23-2021 at 14:33.
MasterMind420 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 11:33.


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