I just ported some code from mw2, credits to @Killingdyl for original code.
Math_cs:
Math_cs:
Code:
public static float Difference(float loc, float loc2)
{
return Math.Abs(loc - loc2);
}
Code:
public int roundUp( float floatVal )
{
if ( (int) floatVal!= floatVal )
return (int) floatVal+1;
else
return (int)floatVal;
}
public void CreateModel(string name, Vector pos)
{
Entity ent = SpawnModel("script_model", name, pos);
}
public void Ramps(Vector top, Vector bottom, int bb)
{
float top1 = top.X;
int blocks = bb;//roundUp(D/30);
float CX = top.X - bottom.X;
float CY = top.Y - bottom.Y;
float CZ = top.Z - bottom.Z;
int XA = (int)CX/blocks;
int YA = (int)CY/blocks;
int ZA = (int)CZ/blocks;
//CXY = Distance((top[0], top[1], 0), (bottom[0], bottom[1], 0));
for(int b = 0; b < blocks; b++){
Vector pos;
float x1 = bottom.X;
float y1 = bottom.Y;
float z1 = bottom.Z;
float x2 = XA * b;
float y2 = YA * b;
float z2 = ZA * b;
pos = new Vector(x1+x2, y1+y2, z1+z2);
Entity ent = SpawnModel("script_model", "com_plasticcase_trap_friendly", pos);
Extensions.CloneBrushModelToScriptModel(ent, Extensions.FindAirdropCrateCollisionId());
//Extensions.SetAngles(ent, pos);
//ServerPrint(Extensions.GetAngles(ent).X + " " + Extensions.GetAngles(ent).Y + " " + Extensions.GetAngles(ent).Z);
}
}
public void CreateGrids(Vector corner1, Vector corner2, int howmuch, int rows)
{
float W = Math_.Difference(corner1.X, corner2.X);//Distance((corner1[0], 0, 0), (corner2[0], 0, 0));
float L = Math_.Difference(corner1.Y, corner2.Y);
float H = 100;//Math_.Difference(corner1.Z, corner2.Z);
int CX = (int)corner2.X - (int)corner1.X;
int CY = (int)corner2.Y - (int)corner1.Y;
int CZ = (int)corner2.Z - (int)corner1.Z;
int ROWS = rows;//roundUp(W/55);
int COLUMNS = howmuch;//roundUp(L/30);
int XA = CX/ROWS;
int YA = CY/COLUMNS;
int ZA = CZ/COLUMNS;
for(int r = 0; r <= ROWS; r++){
for(int c = 0; c <= COLUMNS; c++){
//for(int h = 0; h <= HEIGHT; h++){
int x1 = XA*r;
int y1 = YA*c;
int z1 = ZA;
int x2 = (int)corner1.X + x1;
int y2 = (int)corner1.Y + y1;
int z2 = (int)corner1.Z + z1;
Entity block = SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(x2, y2, z2));
Extensions.CloneBrushModelToScriptModel(block, Extensions.FindAirdropCrateCollisionId());
//}
}
}
}