VScripts: Cleaning some more code.

This commit is contained in:
zaCade 2018-12-08 18:03:02 +01:00
parent 3e0b6eba5b
commit d4378f6476

View File

@ -589,35 +589,27 @@ public void math_counter_11288_display(const char[] output, int caller, int acti
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void Display(int amount) public void Display(int iTimer)
{ {
float fOrigin[3]; int iRelay = CreateEntityByName("logic_relay");
fOrigin[0] = 0.0;
fOrigin[1] = 0.0;
fOrigin[2] = 0.0;
int iRelay = CreateEntityAtOrigin("logic_relay", fOrigin);
DispatchKeyFormat(iRelay, "targetname", "vscript_countdown_relay"); DispatchKeyFormat(iRelay, "targetname", "vscript_countdown_relay");
DispatchKeyFormat(iRelay, "spawnflags", "0"); DispatchKeyFormat(iRelay, "spawnflags", "0");
DispatchKeyFormat(iRelay, "OnTrigger", "seconds_left,AddOutput,message seconds left,0,-1"); DispatchKeyFormat(iRelay, "OnSpawn", "seconds_left,AddOutput,message seconds left,0,-1");
DispatchKeyFormat(iRelay, "OnTrigger", "text_sec,AddOutput,message %d,0,-1", amount - 1); DispatchKeyFormat(iRelay, "OnSpawn", "text_sec,AddOutput,message %d,0,-1", iTimer - 1);
int iBackup = amount; int iBackup = iTimer;
for (int j = 0; j <= iTimer; j++)
for (int j = 0; j <= amount; j++)
{ {
iBackup--; iBackup--;
DispatchKeyFormat(iRelay, "OnTrigger", "text_sec,AddOutput,message %d,%d,-1", iBackup, j); DispatchKeyFormat(iRelay, "OnSpawn", "text_sec,AddOutput,message %d,%d,-1", iBackup, j);
DispatchKeyFormat(iRelay, "OnTrigger", "seconds_left,Display,,%d,-1",j); DispatchKeyFormat(iRelay, "OnSpawn", "seconds_left,Display,,%d,-1", j);
DispatchKeyFormat(iRelay, "OnTrigger", "text_sec,Display,,%d,-1",j); DispatchKeyFormat(iRelay, "OnSpawn", "text_sec,Display,,%d,-1", j);
} }
DispatchKeyFormat(iRelay, "OnTrigger", "seconds_left,AddOutput,message ,%d,-1",amount + 1); DispatchKeyFormat(iRelay, "OnSpawn", "seconds_left,AddOutput,message ,%d,-1", iTimer + 1);
DispatchKeyFormat(iRelay, "OnTrigger", "text_sec,AddOutput,message ,%d,-1",amount + 1); DispatchKeyFormat(iRelay, "OnSpawn", "text_sec,AddOutput,message ,%d,-1", iTimer + 1);
DispatchKeyFormat(iRelay, "OnTrigger", "!self,Kill,,%d,-1",amount + 2); DispatchKeyFormat(iRelay, "OnSpawn", "!self,Kill,,%d,-1", iTimer + 2);
SpawnAndActivate(iRelay); SpawnAndActivate(iRelay);
AcceptEntityInput(iRelay, "Trigger");
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -659,18 +651,6 @@ public int FindEntityByHammerID(int iHammerID)
return INVALID_ENT_REFERENCE; return INVALID_ENT_REFERENCE;
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock int CreateEntityAtOrigin(const char[] classname, const float origin[3])
{
int entity = CreateEntityByName(classname);
TeleportEntity(entity, origin, NULL_VECTOR, NULL_VECTOR);
return entity;
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------