TopDefenders: Rework crown logic, to hopefully fix random error.
`Exception reported: Entity 320 (320) is not a CBaseEntity`
This commit is contained in:
parent
e7e73c77a0
commit
2aaf2c11fd
@ -28,7 +28,7 @@ ConVar g_hCVar_ProtectionMinimal2;
|
||||
ConVar g_hCVar_ProtectionMinimal3;
|
||||
|
||||
/* INTERGERS */
|
||||
int g_iCrownEntity = -1;
|
||||
int g_iCrownEntity = INVALID_ENT_REFERENCE;
|
||||
int g_iDialogLevel = 100000;
|
||||
|
||||
int g_iPlayerWinner[3];
|
||||
@ -534,6 +534,7 @@ public void OnClientSpawn(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
if (g_iPlayerWinner[0] == GetSteamAccountID(client) && !g_bHideCrown[client])
|
||||
{
|
||||
CreateTimer(7.0, OnClientSpawnPost, client, TIMER_FLAG_NO_MAPCHANGE);
|
||||
KillCrown();
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,38 +546,8 @@ public Action OnClientSpawnPost(Handle timer, int client)
|
||||
if (!IsClientInGame(client) || IsFakeClient(client) || !IsPlayerAlive(client))
|
||||
return;
|
||||
|
||||
if ((g_iCrownEntity = CreateEntityByName("prop_dynamic")) == INVALID_ENT_REFERENCE)
|
||||
return;
|
||||
|
||||
SetEntityModel(g_iCrownEntity, "models/unloze/crown_v2.mdl");
|
||||
|
||||
DispatchKeyValue(g_iCrownEntity, "solid", "0");
|
||||
DispatchKeyValue(g_iCrownEntity, "modelscale", "1.5");
|
||||
DispatchKeyValue(g_iCrownEntity, "disableshadows", "1");
|
||||
DispatchKeyValue(g_iCrownEntity, "disablereceiveshadows", "1");
|
||||
DispatchKeyValue(g_iCrownEntity, "disablebonefollowers", "1");
|
||||
|
||||
float fVector[3];
|
||||
float fAngles[3];
|
||||
GetClientAbsOrigin(client, fVector);
|
||||
GetClientAbsAngles(client, fAngles);
|
||||
|
||||
fVector[2] += 80.0;
|
||||
fAngles[0] = 8.0;
|
||||
fAngles[2] = 5.5;
|
||||
|
||||
TeleportEntity(g_iCrownEntity, fVector, fAngles, NULL_VECTOR);
|
||||
|
||||
float fDirection[3];
|
||||
fDirection[0] = 0.0;
|
||||
fDirection[1] = 0.0;
|
||||
fDirection[2] = 1.0;
|
||||
|
||||
TE_SetupSparks(fVector, fDirection, 1000, 200);
|
||||
TE_SendToAll();
|
||||
|
||||
SetVariantString("!activator");
|
||||
AcceptEntityInput(g_iCrownEntity, "SetParent", client);
|
||||
KillCrown();
|
||||
SpawnCrown(client);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -587,12 +558,58 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
|
||||
if (g_iPlayerWinner[0] == GetSteamAccountID(client) && !IsPlayerAlive(client))
|
||||
{
|
||||
if (g_iCrownEntity != INVALID_ENT_REFERENCE && AcceptEntityInput(g_iCrownEntity, "Kill"))
|
||||
{
|
||||
g_iCrownEntity = INVALID_ENT_REFERENCE;
|
||||
}
|
||||
}
|
||||
KillCrown();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void SpawnCrown(int client)
|
||||
{
|
||||
int iCrownEntity = INVALID_ENT_REFERENCE;
|
||||
if ((iCrownEntity = CreateEntityByName("prop_dynamic")) == INVALID_ENT_REFERENCE)
|
||||
return;
|
||||
|
||||
SetEntityModel(iCrownEntity, "models/unloze/crown_v2.mdl");
|
||||
|
||||
DispatchKeyValue(iCrownEntity, "solid", "0");
|
||||
DispatchKeyValue(iCrownEntity, "modelscale", "1.5");
|
||||
DispatchKeyValue(iCrownEntity, "disableshadows", "1");
|
||||
DispatchKeyValue(iCrownEntity, "disablereceiveshadows", "1");
|
||||
DispatchKeyValue(iCrownEntity, "disablebonefollowers", "1");
|
||||
|
||||
float fVector[3];
|
||||
float fAngles[3];
|
||||
GetClientAbsOrigin(client, fVector);
|
||||
GetClientAbsAngles(client, fAngles);
|
||||
|
||||
fVector[2] += 80.0;
|
||||
fAngles[0] = 8.0;
|
||||
fAngles[2] = 5.5;
|
||||
|
||||
TeleportEntity(iCrownEntity, fVector, fAngles, NULL_VECTOR);
|
||||
|
||||
float fDirection[3];
|
||||
fDirection[0] = 0.0;
|
||||
fDirection[1] = 0.0;
|
||||
fDirection[2] = 1.0;
|
||||
|
||||
TE_SetupSparks(fVector, fDirection, 1000, 200);
|
||||
TE_SendToAll();
|
||||
|
||||
SetVariantString("!activator");
|
||||
AcceptEntityInput(iCrownEntity, "SetParent", client);
|
||||
|
||||
g_iCrownEntity = iCrownEntity;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void KillCrown()
|
||||
{
|
||||
if ((IsValidEntity(g_iCrownEntity) && AcceptEntityInput(g_iCrownEntity, "Kill")) || g_iCrownEntity != INVALID_ENT_REFERENCE)
|
||||
g_iCrownEntity = INVALID_ENT_REFERENCE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user