|
Senior Member
Join Date: Jun 2018
Location: Somewhere
|
02-07-2020
, 22:55
Re: Restore boss plugin trouble
|
#8
|
Quote:
Originally Posted by WhiteFalcon
Code:
int BossIndex;
bool respawn[MAXPLAYERS+1];
public void On_RoundStart(Event hevent, const char[] name, bool dontBroadcast)
{
for(int n=1; n <= MaxClients; n++)
{
if(!IsClientInGame(n)) continue;
respawn[n]=true;
}
GetBossIndex();
}
public void GetBossIndex()
{
BossIndex = 0;
for (int client = 1; client <= MaxClients; client++)
{
if(!IsClientInGame(client)) continue;
int boss = FF2_GetBossIndex(client);
if (boss < 0) continue;
BossIndex = boss;
break;
}
}
public Action Command_spawn (int client, int args)
{
if(!IsClientInGame(client))
{
//InGame Only
return Plugin_Handled;
}
if(FF2_GetRoundState() != 1)
{
//Round Is not in progress "yet"
return Plugin_Handled;
}
static int CurHealth, CurDamage, CurLives;
CurLives = FF2_GetBossLives(BossIndex);
CurHealth = FF2_GetBossHealth(BossIndex);
CurDamage = FF2_GetClientDamage(client);
if(IsPlayerAlive(client))
{
//You are alive
return Plugin_Handled;
}
if(!respawn[client])
{
//Used your spawn ticket
return Plugin_Handled;
}
if(CurHealth <= 0 || CurLives <= 0)
{
//boss already dead
return Plugin_Handled;
}
TF2_RespawnPlayer(client);
if(CurDamage <=0)
{
//no damage therefore no restore
return Plugin_Handled;
}
if(FF2_GetBossMaxLives(BossIndex) > 1)
{
int CalcDmg, Lives;
CalcDmg = CurDamage;
for(int n= 1; n <= FF2_GetBossMaxLives(BossIndex); n++)
{
if(CalcDmg > FF2_GetBossMaxHealth(BossIndex))
{
CalcDmg -= FF2_GetBossMaxHealth(BossIndex);
Lives++;
} else break;
}
FF2_SetBossLives(BossIndex, CurLives + Lives);
FF2_SetBossHealth(BossIndex, FF2_GetBossMaxHealth(BossIndex) - CalcDmg);
//restore lives wasted by this client
//and health
respawn[client] = false;
return Plugin_Handled;
}
FF2_SetBossHealth(BossIndex, CurHealth + CurDamage);
//all done
respawn[client] = false;
return Plugin_Handled;
}
|
Reason: wait wat
Ummmmm
|
|
|
|