Shit
unknown
c_cpp
2 years ago
2.5 kB
14
Indexable
// CALLED A BIT LATER AFTER OnMapStart()
stock void CreateZoneEntity( int index )
{
int ent = CreateTrigger( g_zones[index].cordMin, g_zones[index].cordMax );
if ( !ent )
{
PrintToServer("ERROR | Can not create trigger for zone");
return;
}
SetTriggerIndex( ent, index );
SDKHook( ent, SDKHook_Touch, Event_Touch_Zone );
SDKHook( ent, SDKHook_EndTouch, Event_EndTouch_Zone );
g_zones[index].ent = ent;
return;
}
stock int CreateTrigger( float vecMins[3], float vecMaxs[3] )
{
int ent = CreateEntityByName( "trigger_multiple" );
if ( ent < 1 )
{
LogError( "Couldn't create block entity!" );
return 0;
}
DispatchKeyValue( ent, "wait", "0" );
DispatchKeyValue( ent, "StartDisabled", "0" );
DispatchKeyValue( ent, "spawnflags", "1");
if ( !DispatchSpawn( ent ) )
{
LogError("Couldn't spawn block entity!" );
return 0;
}
ActivateEntity( ent );
SetEntityModel( ent, BRUSH_MODEL );
SetEntProp( ent, Prop_Send, "m_fEffects", 32 ); // NODRAW
float vecPos[3];
float vecNewMaxs[3];
// Determine the entity's origin.
// This means the bounds will be just opposite numbers of each other.
vecNewMaxs[0] = ( vecMaxs[0] - vecMins[0] ) / 2;
vecPos[0] = vecMins[0] + vecNewMaxs[0];
vecNewMaxs[1] = ( vecMaxs[1] - vecMins[1] ) / 2;
vecPos[1] = vecMins[1] + vecNewMaxs[1];
vecNewMaxs[2] = ( vecMaxs[2] - vecMins[2] ) / 2;
vecPos[2] = vecMins[2] + vecNewMaxs[2];
TeleportEntity( ent, vecPos, NULL_VECTOR, NULL_VECTOR );
// We then set the mins and maxs of the zone according to the center.
float vecNewMins[3];
vecNewMins[0] = -1 * vecNewMaxs[0];
vecNewMins[1] = -1 * vecNewMaxs[1];
vecNewMins[2] = -1 * vecNewMaxs[2];
SetEntPropVector( ent, Prop_Send, "m_vecMins", vecNewMins );
SetEntPropVector( ent, Prop_Send, "m_vecMaxs", vecNewMaxs );
SetEntProp( ent, Prop_Send, "m_nSolidType", 2 ); // Essential! Use bounding box instead of model's bsp(?) for input.
return ent;
}
public void Event_Touch_Zone( int trigger, int client )
{
...
return;
}
public void Event_EndTouch_Zone( int trigger, int client )
{
...
return;
}
stock void SetTriggerIndex( int ent, int index )
{
SetEntProp( ent, Prop_Data, "m_iHealth", index );
return;
}Editor is loading...
Leave a Comment