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

[L4D & L4D2] Automatic Difficult Balance Base On Intensity


Post New Thread Reply   
 
Thread Tools Display Modes
moekai
Member
Join Date: Jul 2019
Old 07-27-2019 , 20:59   Re: [L4D & L4D2] Automatic Difficult Balance Base On Intensity
Reply With Quote #21

Quote:
Originally Posted by BloodyBlade View Post
Ok. Probably the reason is that the timers starts counting down in the OnMapStart event.
You can try this version:
* Moved timers from the OnMapStart event to the round_start event.
It's still the same thing. Timer started when the map loaded in. I've tried to set the timer to when "player_left_start_area" and it works, timer didn't start until the players left safe area. But the only problem is when all players died, round restart and the timer did not reset and remain active. SI still able to broke when players are in safe area.
moekai is offline
BloodyBlade
Senior Member
Join Date: Feb 2018
Old 08-08-2019 , 20:00   Re: [L4D & L4D2] Automatic Difficult Balance Base On Intensity
Reply With Quote #22

Quote:
Originally Posted by moekai View Post
It's still the same thing. Timer started when the map loaded in. I've tried to set the timer to when "player_left_start_area" and it works, timer didn't start until the players left safe area. But the only problem is when all players died, round restart and the timer did not reset and remain active. SI still able to broke when players are in safe area.
What game do you use it for? L4D? or L4D2?
L4D uses z_spawn. L4D2 uses z_spawn_old to spawn special infected.
player_left_start_area does not always work.
Ok. I added 2 events: player_left_start_area and player_left_checkpoint and moved the timers from round_start to them.
Please test and report to me.
Attached Files
File Type: sp Get Plugin or Get Source (l4d_balance_nv.sp - 477 views - 21.1 KB)

Last edited by BloodyBlade; 09-25-2019 at 17:43. Reason: Updated
BloodyBlade is offline
wyxls
Junior Member
Join Date: Jul 2010
Location: China
Old 02-09-2020 , 02:27   Re: [L4D & L4D2] Automatic Difficult Balance Base On Intensity
Reply With Quote #23

Quote:
Originally Posted by BloodyBlade View Post
What game do you use it for? L4D? or L4D2?
L4D uses z_spawn. L4D2 uses z_spawn_old to spawn special infected.
player_left_start_area does not always work.
Ok. I added 2 events: player_left_start_area and player_left_checkpoint and moved the timers from round_start to them.
Please test and report to me.
Sorry to replay in this thread after such a long time.

I have tested the plugin you posted above. The timers works fine when the players left safe zone. But there's a weird problem.

Both Intensity and Difficulty adjust super rapidly that it makes the Difficulty value always hit the min value and turn on balance. When it hit the max value, the Adjust interval seems to be reset to normal.

It's like the plugin creates lots of timers for Action:TimerUpdatePlayer. Any Idea?

Last edited by wyxls; 02-09-2020 at 02:34.
wyxls is offline
wyxls
Junior Member
Join Date: Jul 2010
Location: China
Old 02-13-2020 , 08:53   Re: [L4D & L4D2] Automatic Difficult Balance Base On Intensity
Reply With Quote #24

Change timers running after any player or bot leaving safe zone.

Update:
1.(2020-05-09) Seperate the plugin into Chinese version and English version.


Alright, I think I've figure out how to set the timer work properly.

The key part is this:
Code:
public void OnMapStart()
{
	if(GameMode != 1) return;
	CreateTimer(1.0, TimerUpdatePlayer, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
	CreateTimer(1.5, TimerShowHud, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
	CreateTimer(30.0, TimerDelayStartAjust, 0, TIMER_FLAG_NO_MAPCHANGE);
	ResetAllState();
}

public Action TimerDelayStartAjust(Handle timer, any data)
{
	CreateTimer(2.0, TimerAjust, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);	
}
TimerUpdatePlayer for updating player's intensity, TimerShowHud for updating !balance information panel, TimerAjust for ajusting difficulty.

The "TimerDelayStartAjust" just delay 30 seconds to create "TimerAjust" timer. Will be no use in the following improvement.

Since those timers are created at OnMapStart(), the TimerAjust will be created at the beginning and be activated at all time in spite of whether player left safe zone. Besides hooking player_left_start_area or player_left_checkpoint will create extra TimerAjust timer which results in rapidly updating the difficulty.

So I look for another way to check whether players leave safe zone and I find one in [L4D & L4D2] Auto Infected Spawner.

It checks for players(or BOT) leaving safe zone with a boolean variable which is based on EntityNetClass "CTerrorPlayerResource" and PropInfo "m_hasAnySurvivorLeftSafeArea".

I intergrate "bool LeftStartArea()" and "LeftSafeRoom" variables. Create additional Handles to bind each timer to them.

While round starts, create "hPlayerLeftStart" timer running per second to check "LeftSafeRoom".
Code:
public Action PlayerLeftStart(Handle Timer, any data)
{
	if (LeftStartArea())
	{
		// We don't care who left, just that at least one did
		if (!LeftSafeRoom)
		{
			LeftSafeRoom = true;
			hTimerUpdatePlayer = CreateTimer(1.0, TimerUpdatePlayer, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
			hTimerAjust = CreateTimer(2.0, TimerAjust, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
		}
	}
	return Plugin_Continue;
}
While round ends (survivors all dead, finale win, map changes), reset "LeftSafeRoom" and kill all timers.
Code:
public Action round_end(Event event, const char[] name, bool dontBroadcast)
{
	ResetAllState();
	LeftSafeRoom = false;
	KillTimer(hPlayerLeftStart);
	KillTimer(hTimerUpdatePlayer);
	KillTimer(hTimerAjust);
	for (int i = 1; i <= MaxClients; i++)
	{
		if (IsClientInGame(i))
		{
			if (GetClientTeam(i) == 3)
			{
				if (IsFakeClient(i))
				{
					KickClient(i);
				}
			}
		}
	}
}
I test it for several campaigns and it works fine. Please let me know if it's not working. [email protected]

Finally, enjoy it.
Attached Files
File Type: sp Get Plugin or Get Source (l4d_balance_fix_cn.sp - 212 views - 22.9 KB)
File Type: sp Get Plugin or Get Source (l4d_balance_fix_en.sp - 306 views - 22.9 KB)

Last edited by wyxls; 08-01-2020 at 21:16.
wyxls is offline
timonenluca
Member
Join Date: Apr 2020
Location: Europe
Old 04-22-2020 , 16:51   Re: [L4D & L4D2] Automatic Difficult Balance Base On Intensity
Reply With Quote #25

I tried this plugin multiple times , it's really interesting. i would think if there was a idle state to a certain value from the start 0 - 10 and then from 10 - 25 it starts balancing instead off spawning infected between 0-25 instantly , would help out with the instant difficulty spikes.

It did work fairly well , this was awesome!
timonenluca is offline
wyxls
Junior Member
Join Date: Jul 2010
Location: China
Old 05-08-2020 , 22:36   Re: [L4D & L4D2] Automatic Difficult Balance Base On Intensity
Reply With Quote #26

Quote:
Originally Posted by timonenluca View Post
I tried this plugin multiple times , it's really interesting. i would think if there was a idle state to a certain value from the start 0 - 10 and then from 10 - 25 it starts balancing instead off spawning infected between 0-25 instantly , would help out with the instant difficulty spikes.

It did work fairly well , this was awesome!
It's possible and the key part is:
Code:
	if(CurrentAverage < difficult) AdustTick--;
	else AdustTick++;
When "AdustTick" hits 0, the SI spawn timer will activate.

the variable "difficult" value equals "l4d_balance_difficulty_min".

Edit to:
Code:
	if(CurrentAverage < difficult) AdustTick--;
	else AdustTick++;
        if(CurrentAverage < idledifficult) AdustTick++;
This should work as an idle state and freeze the SI spawn timer when average intensity is below "idledifficult".
wyxls is offline
NeoTM
AlliedModders Donor
Join Date: Feb 2013
Location: Britain
Old 07-28-2021 , 17:30   Re: [L4D & L4D2] Automatic Difficult Balance Base On Intensity
Reply With Quote #27

I also had the problem of SI spawning in the safe room.
At this moment i only set

l4d_balance_limit_special "0"
and
l4d_balance_limit_special_add "0"

and use Auto infected Spawner to spawn SI.

It worked pretty well with more control on how are the SI.

But since i remade my server after a long period of inactivity i have an other problem, but this time with the size of the hordes in finales.

while i can have a mob spawn of 80 during the campaign, once the final is started the mob spawn is stuck to 20.

So it's strange to have very large hordes during all the campaign and only few zombies during the finale.

I try this:

sm_cvar z_mob_spawn_finale_size 80

but impossible to have large hordes during final

Is anyone know how i can get lots of zombies in the finale?

And i also noticed that if i set "l4d_balance_difficulty_min" too high and the intensity never reach the setting (stay bellow), the tank will not spawn.

it's seems to do that only on l4d1 map.

I fix that problem by setting "l4d_balance_difficulty_min" to 18 (or a number that can be reach even if all players are good and never surrounded) and once the plugin stop increasing difficulty for at least 15 seconds, the tank finally spawn.

Otherwise the tank will never come and the final can stay for hours (and with not enough zombies because of the mob spawn stuck to 20, it's rapidely boring)
__________________
82.66.75.218:27015 - Walk In Dead Nightmare
82.66.75.218:27016 - Walk In Dead Rampage
82.66.75.218:27017 - Walk In Dead Vanilla
NeoTM is offline
santdrback
Member
Join Date: Apr 2020
Old 10-21-2021 , 16:17   Re: [L4D & L4D2] Automatic Difficult Balance Base On Intensity
Reply With Quote #28

Quote:
Originally Posted by wyxls View Post
Change timers running after any player or bot leaving safe zone.

Update:
1.(2020-05-09) Seperate the plugin into Chinese version and English version.


Alright, I think I've figure out how to set the timer work properly.

The key part is this:
Code:
public void OnMapStart()
{
	if(GameMode != 1) return;
	CreateTimer(1.0, TimerUpdatePlayer, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
	CreateTimer(1.5, TimerShowHud, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
	CreateTimer(30.0, TimerDelayStartAjust, 0, TIMER_FLAG_NO_MAPCHANGE);
	ResetAllState();
}

public Action TimerDelayStartAjust(Handle timer, any data)
{
	CreateTimer(2.0, TimerAjust, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);	
}
TimerUpdatePlayer for updating player's intensity, TimerShowHud for updating !balance information panel, TimerAjust for ajusting difficulty.

The "TimerDelayStartAjust" just delay 30 seconds to create "TimerAjust" timer. Will be no use in the following improvement.

Since those timers are created at OnMapStart(), the TimerAjust will be created at the beginning and be activated at all time in spite of whether player left safe zone. Besides hooking player_left_start_area or player_left_checkpoint will create extra TimerAjust timer which results in rapidly updating the difficulty.

So I look for another way to check whether players leave safe zone and I find one in [L4D & L4D2] Auto Infected Spawner.

It checks for players(or BOT) leaving safe zone with a boolean variable which is based on EntityNetClass "CTerrorPlayerResource" and PropInfo "m_hasAnySurvivorLeftSafeArea".

I intergrate "bool LeftStartArea()" and "LeftSafeRoom" variables. Create additional Handles to bind each timer to them.

While round starts, create "hPlayerLeftStart" timer running per second to check "LeftSafeRoom".
Code:
public Action PlayerLeftStart(Handle Timer, any data)
{
	if (LeftStartArea())
	{
		// We don't care who left, just that at least one did
		if (!LeftSafeRoom)
		{
			LeftSafeRoom = true;
			hTimerUpdatePlayer = CreateTimer(1.0, TimerUpdatePlayer, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
			hTimerAjust = CreateTimer(2.0, TimerAjust, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
		}
	}
	return Plugin_Continue;
}
While round ends (survivors all dead, finale win, map changes), reset "LeftSafeRoom" and kill all timers.
Code:
public Action round_end(Event event, const char[] name, bool dontBroadcast)
{
	ResetAllState();
	LeftSafeRoom = false;
	KillTimer(hPlayerLeftStart);
	KillTimer(hTimerUpdatePlayer);
	KillTimer(hTimerAjust);
	for (int i = 1; i <= MaxClients; i++)
	{
		if (IsClientInGame(i))
		{
			if (GetClientTeam(i) == 3)
			{
				if (IsFakeClient(i))
				{
					KickClient(i);
				}
			}
		}
	}
}
I test it for several campaigns and it works fine. Please let me know if it's not working. [email protected]

Finally, enjoy it.
Nice plugin going to test thank you
santdrback 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 15:26.


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