Fixed zone offset being wrong for point 1 (#585)

This commit is contained in:
shavit 2018-01-22 18:33:47 +02:00
parent 271f2ea9ed
commit 757e9de8c6
2 changed files with 18 additions and 13 deletions

View File

@ -2275,7 +2275,7 @@ public Action Shotgun_Shot(const char[] te_name, const int[] Players, int numCli
TE_WriteFloat("m_vecAngles[0]", TE_ReadFloat("m_vecAngles[0]"));
TE_WriteFloat("m_vecAngles[1]", TE_ReadFloat("m_vecAngles[1]"));
if(gEV_Type == Engine_CSS)
if(IsSource2013(gEV_Type))
{
TE_WriteNum("m_iWeaponID", TE_ReadNum("m_iWeaponID"));
}

View File

@ -2143,31 +2143,36 @@ void DrawZone(float points[8][3], int color[4], float life, float width, bool fl
}
}
// by blacky
// original by blacky
// creates 3d box from 2 points
void CreateZonePoints(float point[8][3], float offset = 0.0)
{
float center[2];
center[0] = ((point[0][0] + point[7][0]) / 2);
center[1] = ((point[0][1] + point[7][1]) / 2);
for(int i = 0; i < 8; i++)
// calculate all zone edges
for(int i = 1; i < 7; i++)
{
for(int j = 0; j < 3; j++)
{
if(i > 0 && i < 7)
{
point[i][j] = point[((i >> (2 - j)) & 1) * 7][j];
}
point[i][j] = point[((i >> (2 - j)) & 1) * 7][j];
}
}
if(offset != 0.0 && j < 2)
// apply beam offset
if(offset != 0.0)
{
float center[2];
center[0] = ((point[0][0] + point[7][0]) / 2);
center[1] = ((point[0][1] + point[7][1]) / 2);
for(int i = 0; i < 8; i++)
{
for(int j = 0; j < 2; j++)
{
if(point[i][j] < center[j])
{
point[i][j] += offset;
}
else
else if(point[i][j] > center[j])
{
point[i][j] -= offset;
}