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

Solved [L4D] How to force mission lost


Post New Thread Reply   
 
Thread Tools Display Modes
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-24-2018 , 10:04   Re: [L4D] How to force mission lost
Reply With Quote #11

Anyway, I see no point to dig deeper.
I can emulate everything myself. Missing events, screen fading... and with your help "endround" cmd.

By the way, screen fading is not always happen in normal "mission_lost" behaviour. It is also random =)
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 10-24-2018 , 10:27   Re: [L4D] How to force mission lost
Reply With Quote #12

Quote:
Originally Posted by Dragokas View Post
eyal282, interesting idea.

Human player is CTerrorPlayer in L4D. I didn't found *Alive properties in map.

To be sure:


However, I found several related properties.

The differeces are:
Alive state:


Dead state:



On round start I ran code:

Code:
public OnPluginStart()
{
	RegAdminCmd("sm_dead", ForceDead, ADMFLAG_BAN, "");
}

public Action ForceDead(int client, int args)
{
	for (int i = 1; i <= MaxClients; i++)
	{
		if (IsClientInGame(i) && GetClientTeam(i) == 2)
		{
			SetEntProp(i, Prop_Send, "m_lifeState", 1); // like ghost (model become invisible)
			//SetEntData(client, FindDataMapInfo(client, "m_lifeState"), 1, 4, true);

			SetEntProp(i, Prop_Send, "deadflag", 1); // unknown (m_bIsAlive analogue?)
			SetEntProp(i, Prop_Send, "m_fFlags", 128); // unknown (hands up animation)
			SetEntProp(i, Prop_Send, "m_iPlayerState", 4); // freeze
		}
	}

	ShowStateInt(client, "deadflag");
	ShowStateInt(client, "m_lifeState");
	ShowStateInt(client, "m_iPlayerState");
	ShowStateInt(client, "m_isGoingToDie");
	ShowStateInt(client, "m_isCalm");
	ShowStateInt(client, "m_isGhost");
	ShowStateInt(client, "m_fFlags");
	ShowStateFloat(client, "m_flDeathTime");
	ShowStateFloat(client, "m_flStamina");
	
	PrintToChat(client, "Player alive? %b", IsPlayerAlive(client));
	
	CreateTimer(5.0, Timer_Stage_3, client);
	
	return Plugin_Handled;
}

public Action Timer_Stage_3(Handle timer, int client)
{
	ServerExecuteCmd("endround");
}

void ShowStateInt(int client, char[] sProp)
{
	int iValue = GetEntProp(client, Prop_Send, sProp);
	PrintToChat(client, "%s = %i", sProp, iValue);
}
void ShowStateFloat(int client, char[] sProp)
{
	float fValue = GetEntPropFloat(client, Prop_Send, sProp);
	PrintToChat(client, "%s = %f", sProp, fValue);
}
and we are almost there: even without ServerExecuteCmd("endround"); screen is fading, "award_earned" and "mission_lost" are fired and round ends in ~ 4-6 sec.

Unfortunately, that is not always happen. Randomly, after executing above code (without "endround" cmd) round is not end automatically. Dunno why. I checked: we only need these two prop: m_lifeState + deadflag. It's enough. I tried set these prop in vice versa order and with 0.5 sec. delay between each other, but no luck. Game randomly ends the round or not.

Adding "endround" cmd not help to recover correct events sequence. It's just a signal for instant round_end.
If setting death check trigger's round end, try setting all survivors as dead, set no death check to 0 and redo.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-24-2018 , 12:14   Re: [L4D] How to force mission lost
Reply With Quote #13

ahh, nice catch. It was "No Death Check Until Dead" plugin who randomly broke round end behaviour.
After disabling it, normal events sequence happen always after changing m_lifeState + deadflag props.

Looks like this topic is totally resolved.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-25-2018 , 02:21   Re: [L4D] How to force mission lost
Reply With Quote #14

So, the final version of force mission lost for L4D that is always work.

Minimal code:
Code:
stock void GameOver()
{
	for (int i = 1; i <= MaxClients; i++)
		if (IsClientInGame(i) && GetClientTeam(i) == 2) {
			SetEntProp(i, Prop_Send, "m_lifeState", 1);
			SetEntProp(i, Prop_Send, "deadflag", 1);
		}

}
Code to consider case when "No Death Check Until Dead" plugin is installed on the server:

Code:
stock void GameOver_2()
{
	int iDeathCheck;
	ConVar hDeathCheck = FindConVar("deathcheck_enable");
	if (hDeathCheck != null) {
		iDeathCheck = hDeathCheck.IntValue;
		if (iDeathCheck != 0) hDeathCheck.SetInt(0, false, false);
	}
	
	for (int i = 1; i <= MaxClients; i++)
		if (IsClientInGame(i) && GetClientTeam(i) == 2) {
			SetEntProp(i, Prop_Send, "m_lifeState", 1);
			SetEntProp(i, Prop_Send, "deadflag", 1);
		}

	if (hDeathCheck != null && iDeathCheck != 0)
		CreateTimer(3.0, Timer_DeathCheckRevert, iDeathCheck);
}

public Action Timer_DeathCheckRevert(Handle timer, int iDeathCheck)
{
	ConVar hDeathCheck = FindConVar("deathcheck_enable");
	hDeathCheck.SetInt(iDeathCheck, false, false);
}
offtopic.
hmm, last parameter of SetInt method is false, but client receive a msg "Variable 'deathcheck_enable' is changed"
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 10-25-2018 at 06:55. Reason: added m_lifeState prop
Dragokas is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 10-25-2018 , 02:23   Re: [L4D] How to force mission lost
Reply With Quote #15

Quote:
Originally Posted by Dragokas View Post
ahh, nice catch. It was "No Death Check Until Dead" plugin who randomly broke round end behaviour.
After disabling it, normal events sequence happen always after changing m_lifeState + deadflag props.

Looks like this topic is totally resolved.
....

Your final code is bad. You need to save the cvar on a variable, set it to 0 and then set it to original based on your variable. such thing will work with or without the plugin.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 10-25-2018 at 02:24.
eyal282 is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-25-2018 , 02:58   Re: [L4D] How to force mission lost
Reply With Quote #16

Quote:
Your final code is bad.
Why you think so?

Quote:
such thing will work with or without the plugin.
My code will work with and without plugin.

Quote:
You need to save the cvar on a variable
I could. But, what is a point.
+1 global variable mean "no stock". Current variant is easy to reuse: 1 copy-paste. +1 glob. var = 2 copy-paste.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-25-2018 , 06:57   Re: [L4D] How to force mission lost
Reply With Quote #17

I updated above code. "m_lifeState" prop is required.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 10-31-2018 , 05:37   Re: [L4D] How to force mission lost
Reply With Quote #18

Quote:
Originally Posted by Dragokas View Post
Why you think so?


My code will work with and without plugin.


I could. But, what is a point.
+1 global variable mean "no stock". Current variant is easy to reuse: 1 copy-paste. +1 glob. var = 2 copy-paste.
Does it not work if you don't add a delay and restore the cvar in the same function? Also remember that the game will consider the survivors to be dead.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 10-31-2018 at 05:37.
eyal282 is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-31-2018 , 05:47   Re: [L4D] How to force mission lost
Reply With Quote #19

Even with 2 delays, after changing deatcheck value and before restoring it, sometimes round is not end.

I returned to ForcePlayerSuicide() version when DreathCheck cvar is 1.
Just don't want to waste more time on investigations.

Code:
ConVar g_hCvar_DeathCheck;

public void OnPluginStart()
{
	g_hCvar_DeathCheck = FindConVar("deathcheck_enable");
}

void GameOver()
{
	CPrintHintTextToAll("%t", "Ryan_Lost"); // "Ryan is lost. Game over!"
	
	if (g_hCvar_DeathCheck != null) {
		if (g_hCvar_DeathCheck.IntValue != 0) {
			for (int i = 1; i <= MaxClients; i++) {
				if (IsClientInGame(i) && GetClientTeam(i) == 2) {
					ForcePlayerSuicide(i);
				}
			}
			return;
		}
	}
	CreateTimer(1.0, Timer_MakeDead);
	CreateTimer(3.0, Timer_ForceRoundEnd, _, TIMER_FLAG_NO_MAPCHANGE);
}

public Action Timer_MakeDead(Handle timer)
{
	for (int i = 1; i <= MaxClients; i++) {
		if (IsClientInGame(i) && GetClientTeam(i) == 2) {
			// ForcePlayerSuicide(i);
			SetEntProp(i, Prop_Send, "m_lifeState", 1);
			SetEntProp(i, Prop_Send, "deadflag", 1);		// make dead
			SetEntProp(i, Prop_Send, "m_iPlayerState", 4);	// freeze
			SetEntProp(i, Prop_Send, "m_fFlags", 128); 		// hands up animation
		}
	}
}
public Action Timer_ForceRoundEnd(Handle timer, int iDeathCheck)
{
	if (!g_bRoundEnded)
		ServerExecuteCmd("endround");
}
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-31-2018 , 05:49   Re: [L4D] How to force mission lost
Reply With Quote #20

eyal282, thank for help.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas 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 12:05.


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