PHP Code:
#include <sourcemod>
#include <sdktools>
//code by darwin2154
int g_Glow;
int g_Laser;
public void OnPluginStart(){
RegConsoleCmd("sm_cube", Cube);
}
public void OnMapStart()
{
g_Glow = PrecacheModel("particle/particle_glow_10.vmt");
g_Laser = PrecacheModel("materials/sprites/laserbeam.vmt");
}
public Action Cube(int client, int args)
{
float center[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", center);
float one[3], two[3], three[3], four[3];
float oneh[3], twoh[3], threeh[3], fourh[3];
int Num = 4; // Number of points around a given position
int Degrees = 360; //Degrees in a circle
int Coeff = 0; //coefficient
int Mul = 50;
float point;
point = DegToRad(float(0 * (Degrees / Num) + Coeff));
//calculate the top first point
oneh[0] = center[0] + Sine(point) * Mul; //Honestly, I don’t know how he calculates. In geometry is not strong. Ask the tail, this is its code.
oneh[1] = center[1] + Cosine(point) * Mul;
oneh[2] = center[2] + 100.0; // 50.0 - Cell height
one[0] = oneh[0]; //We get the bottom point
one[1] = oneh[1];
one[2] = center[2]; //Because if it’s lower, then the height will be like the center.
TE_SetupBeamPoints(one, oneh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30); //We create vertical lasers connecting our 2 points.
TE_SendToAll();
point = DegToRad(float(1 * (Degrees / Num) + Coeff));
//calculate 2 points
twoh[0] = center[0] + Sine(point) * Mul;
twoh[1] = center[1] + Cosine(point) * Mul;
twoh[2] = center[2] + 100.0;
two[0] = twoh[0];
two[1] = twoh[1];
two[2] = center[2];
TE_SetupBeamPoints(two, twoh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30); //We create vertical lasers connecting our 2 points.
TE_SendToAll();
point = DegToRad(float(2 * (Degrees / Num) + Coeff));
//calculate 3 point
threeh[0] = center[0] + Sine(point) * Mul;
threeh[1] = center[1] + Cosine(point) * Mul;
threeh[2] = center[2] + 100.0;
three[0] = threeh[0];
three[1] = threeh[1];
three[2] = center[2];
TE_SetupBeamPoints(three, threeh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
point = DegToRad(float(3 * (Degrees / Num) + Coeff));
//calculate 4 point
fourh[0] = center[0] + Sine(point) * Mul;
fourh[1] = center[1] + Cosine(point) * Mul;
fourh[2] = center[2] + 100.0;
four[0] = fourh[0];
four[1] = fourh[1];
four[2] = center[2];
TE_SetupBeamPoints(four, fourh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(one, two, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30); //We connect the lower points in a circle: 1 with 2, 2 with 3, 3 with 4, 4 with 1.
TE_SendToAll();
TE_SetupBeamPoints(two, three, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(three, four, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(four, one, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(oneh, twoh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30); //We connect the lower points in a circle: 1 with 2, 2 with 3, 3 with 4.4 s 1.
TE_SendToAll();
TE_SetupBeamPoints(twoh, threeh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(threeh, fourh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(fourh, oneh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
//Connect the points of the side faces with each other with a cross.
TE_SetupBeamPoints(oneh, two, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30); //We connect the lower points in a circle: 1 with 2, 2 with 3, 3 with 4.4 s 1.
TE_SendToAll();
TE_SetupBeamPoints(twoh, one, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(twoh, three, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(threeh, two, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(threeh, four, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(fourh, three, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(fourh, one, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(oneh, four, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
//Now the top points (get a cross)
TE_SetupBeamPoints(oneh, threeh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(twoh, fourh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
//And the lower ones also cross
TE_SetupBeamPoints(one, three, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(two, four, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
// Who needs it, you can also connect everything inside.
TE_SetupBeamPoints(oneh, three, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(twoh, four, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(one, threeh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupBeamPoints(two, fourh, g_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0, 100, 255, 255},30);
TE_SendToAll();
TE_SetupSparks(oneh, one, 500, 10); // Create sparks in vertical lines
TE_SendToAll();
TE_SetupSparks(twoh, two, 500, 10);
TE_SendToAll();
TE_SetupSparks(threeh, three, 500, 10);
TE_SendToAll();
TE_SetupSparks(fourh, four, 500, 10);
TE_SendToAll();
center[2] = center[2] + 40.0;
TE_SetupGlowSprite(center, g_Glow, 5.0, 5.0, 20); //Make the glow in the center
TE_SendToAll();
return Plugin_Handled;
}