Skip to content

Modifying Overriding Boss Health

Kevin Yonan edited this page Feb 20, 2021 · 7 revisions

Overview

Usually, VSH2 handles boss health calculations as well as the health calculation for multi-bosses. Boss health calculation is handled the same way FF2 does for clarity: Using a familiar boss health formula and then dividing it amongst bosses based on the amount of bosses.

Boss Health Formula

Boss' health formula is as follows...

round( [ ([(a+b) * (b-c)]^d) + x ] / y )

  • a - initial health amount.
  • b - amount of red players.
  • c - subtraction iota.
  • d - exponent iota.
  • x - additional health iota.
  • y - amount of bosses.

This formula is better represented by the stock function CalcBossHealth

stock int CalcBossHealth(const float initial, const int playing, const float subtract, const float exponent, const float additional)
{
	return RoundFloat( Pow((((initial)+playing)*(playing-subtract)), exponent)+additional );
}

and is fully utilized in ArenaRoundStart event...

boss.iMaxHealth = CalcBossHealth(760.8, gamemode.iPlaying, 1.0, 1.0341, 2046.0) / (bosscount);

Changing/Overriding Boss Health

As VSH2 was designed to do, you have full control over every boss' individual data, that includes health and max health!

The preferred way to override boss health for the round is through the event function hook OnBossCalcHealth.

Example, let's say we had a boss that has the total health of ALL players! Let's say red team has 20 players that are all soldiers! (200 x 20 = 4000).

In our Boss module plugin, we hook the function OnBossCalcHealth.

VSH2_Hook(OnBossCalcHealth, MyCustomBoss_OnBossCalcHealth);

For our purposes, the hook OnBossCalcHealth will use the function prototype:

function void (const VSH2Player player, int& max_health, const int boss_count, const int red_players);

So it would look like this in our addon plugin:

public void MyCustomBoss_OnBossCalcHealth(const VSH2Player player, int& max_health, const int boss_count, const int red_players)
{
	int new_health;
	for( int n=MaxClients; n; n-- ) {
		if( !IsClientValid(n) || !IsPlayerAlive(n) || IsClientObserver(n) || VSH2Player(n).GetPropInt("bIsBoss") )
			continue;
		new_health += GetEntProp(n, Prop_Data, "m_iMaxHealth");
	}
	max_health = new_health;
}