mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
- floatified AutoBreakWall and WallBreakPosition
This commit is contained in:
parent
9cd3b3456a
commit
0644add7be
3 changed files with 55 additions and 55 deletions
|
@ -440,21 +440,21 @@ static int CompareBreakInfo(void const * a, void const * b)
|
||||||
return break_info1->picnum - break_info2->picnum;
|
return break_info1->picnum - break_info2->picnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CompareSearchBreakInfo(int *picnum, BREAK_INFO* break_info)
|
int CompareSearchBreakInfo(int* picnum, BREAK_INFO* break_info)
|
||||||
{
|
{
|
||||||
// will return a number less than 0 if picnum < break_info->picnum
|
// will return a number less than 0 if picnum < break_info->picnum
|
||||||
return(*picnum - break_info->picnum);
|
return(*picnum - break_info->picnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
BREAK_INFO* FindWallBreakInfo(int picnum)
|
BREAK_INFO* FindWallBreakInfo(int picnum)
|
||||||
{
|
{
|
||||||
return(BREAK_INFO*)(bsearch(&picnum, &WallBreakInfo, SIZ(WallBreakInfo), sizeof(BREAK_INFO), (int(*)(const void*,const void*))CompareSearchBreakInfo));
|
return(BREAK_INFO*)(bsearch(&picnum, &WallBreakInfo, SIZ(WallBreakInfo), sizeof(BREAK_INFO), (int(*)(const void*, const void*))CompareSearchBreakInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
BREAK_INFO* FindSpriteBreakInfo(int picnum)
|
BREAK_INFO* FindSpriteBreakInfo(int picnum)
|
||||||
{
|
{
|
||||||
return(BREAK_INFO*)(bsearch(&picnum, &SpriteBreakInfo, SIZ(SpriteBreakInfo), sizeof(BREAK_INFO), (int(*)(const void*,const void*))CompareSearchBreakInfo));
|
return(BREAK_INFO*)(bsearch(&picnum, &SpriteBreakInfo, SIZ(SpriteBreakInfo), sizeof(BREAK_INFO), (int(*)(const void*, const void*))CompareSearchBreakInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
// SETUP
|
// SETUP
|
||||||
|
@ -466,6 +466,12 @@ void SortBreakInfo(void)
|
||||||
qsort(&WallBreakInfo, SIZ(WallBreakInfo), sizeof(BREAK_INFO), CompareBreakInfo);
|
qsort(&WallBreakInfo, SIZ(WallBreakInfo), sizeof(BREAK_INFO), CompareBreakInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
BREAK_INFO* SetupWallForBreak(walltype* wallp)
|
BREAK_INFO* SetupWallForBreak(walltype* wallp)
|
||||||
{
|
{
|
||||||
BREAK_INFO* break_info;
|
BREAK_INFO* break_info;
|
||||||
|
@ -490,6 +496,12 @@ BREAK_INFO* SetupWallForBreak(walltype* wallp)
|
||||||
return break_info;
|
return break_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
BREAK_INFO* SetupSpriteForBreak(DSWActor* actor)
|
BREAK_INFO* SetupSpriteForBreak(DSWActor* actor)
|
||||||
{
|
{
|
||||||
int picnum = actor->spr.picnum;
|
int picnum = actor->spr.picnum;
|
||||||
|
@ -544,11 +556,13 @@ DSWActor* FindBreakSpriteMatch(int match)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// WALL
|
// WALL
|
||||||
//
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
int AutoBreakWall(walltype* wallp, int hit_x, int hit_y, int hit_z, int ang, int type)
|
int AutoBreakWall(walltype* wallp, const DVector3& hit_pos, DAngle ang, int type)
|
||||||
{
|
{
|
||||||
BREAK_INFO* break_info;
|
BREAK_INFO* break_info;
|
||||||
walltype* nwp;
|
walltype* nwp;
|
||||||
|
@ -582,14 +596,13 @@ int AutoBreakWall(walltype* wallp, int hit_x, int hit_y, int hit_z, int ang, int
|
||||||
// Check to see if it should break with current weapon type
|
// Check to see if it should break with current weapon type
|
||||||
if (!CheckBreakToughness(break_info, type)) return false;
|
if (!CheckBreakToughness(break_info, type)) return false;
|
||||||
|
|
||||||
if (hit_x != INT32_MAX)
|
if (hit_pos.X != INT32_MAX)
|
||||||
{
|
{
|
||||||
DVector3 hit_pos( hit_x * inttoworld, hit_y * inttoworld, hit_z * zinttoworld);
|
|
||||||
// need correct location for spawning shrap
|
// need correct location for spawning shrap
|
||||||
auto breakActor = insertActor(0, STAT_DEFAULT);
|
auto breakActor = insertActor(0, STAT_DEFAULT);
|
||||||
breakActor->spr.cstat = 0;
|
breakActor->spr.cstat = 0;
|
||||||
breakActor->spr.extra = 0;
|
breakActor->spr.extra = 0;
|
||||||
breakActor->set_int_ang(ang);
|
breakActor->spr.angle = ang;
|
||||||
breakActor->spr.picnum = ST1;
|
breakActor->spr.picnum = ST1;
|
||||||
breakActor->spr.xrepeat = breakActor->spr.yrepeat = 64;
|
breakActor->spr.xrepeat = breakActor->spr.yrepeat = 64;
|
||||||
SetActorZ(breakActor, hit_pos);
|
SetActorZ(breakActor, hit_pos);
|
||||||
|
@ -724,24 +737,21 @@ bool UserBreakWall(walltype* wp)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WallBreakPosition(walltype* wp, sectortype** sectp, int *x, int *y, int *z, int *ang)
|
int WallBreakPosition(walltype* wp, sectortype** sectp, DVector3& pos, DAngle& ang)
|
||||||
{
|
{
|
||||||
int nx,ny;
|
int nx,ny;
|
||||||
int wall_ang;
|
DAngle wall_ang = VecToAngle(wp->delta()) + DAngle90;
|
||||||
|
|
||||||
wall_ang = NORM_ANGLE(getangle(wp->delta())+512);
|
|
||||||
|
|
||||||
*sectp = wp->sectorp();
|
*sectp = wp->sectorp();
|
||||||
ASSERT(*sectp);
|
ASSERT(*sectp);
|
||||||
|
|
||||||
// midpoint of wall
|
// midpoint of wall
|
||||||
*x = (wp->wall_int_pos().X + wp->wall_int_pos().X) >> 1;
|
pos.XY() = wp->center();
|
||||||
*y = (wp->wall_int_pos().Y + wp->wall_int_pos().Y) >> 1;
|
|
||||||
|
|
||||||
if (!wp->twoSided())
|
if (!wp->twoSided())
|
||||||
{
|
{
|
||||||
// white wall
|
// white wall
|
||||||
*z = ((*sectp)->int_floorz() + (*sectp)->int_ceilingz()) >> 1;
|
pos.Z = ((*sectp)->floorz + (*sectp)->ceilingz) * 0.5;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -752,29 +762,25 @@ int WallBreakPosition(walltype* wp, sectortype** sectp, int *x, int *y, int *z,
|
||||||
|
|
||||||
// floor and ceiling meet
|
// floor and ceiling meet
|
||||||
if (next_sect->floorz == next_sect->ceilingz)
|
if (next_sect->floorz == next_sect->ceilingz)
|
||||||
*z = ((*sectp)->int_floorz() + (*sectp)->int_ceilingz()) >> 1;
|
pos.Z = ((*sectp)->floorz + (*sectp)->ceilingz) * 0.5;
|
||||||
else
|
else
|
||||||
// floor is above other sector
|
// floor is above other sector
|
||||||
if (next_sect->floorz < (*sectp)->floorz)
|
if (next_sect->floorz < (*sectp)->floorz)
|
||||||
*z = (next_sect->int_floorz() + (*sectp)->int_floorz()) >> 1;
|
pos.Z = (next_sect->floorz + (*sectp)->floorz) * 0.5;
|
||||||
else
|
else
|
||||||
// ceiling is below other sector
|
// ceiling is below other sector
|
||||||
if (next_sect->ceilingz > (*sectp)->ceilingz)
|
if (next_sect->ceilingz > (*sectp)->ceilingz)
|
||||||
*z = (next_sect->int_ceilingz() + (*sectp)->int_ceilingz()) >> 1;
|
pos.Z = (next_sect->ceilingz + (*sectp)->ceilingz) * 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ang = wall_ang;
|
ang = wall_ang;
|
||||||
|
|
||||||
nx = MOVEx(128, wall_ang);
|
pos.XY() += wall_ang.ToVector() * 16;
|
||||||
ny = MOVEy(128, wall_ang);
|
|
||||||
|
|
||||||
*x += nx;
|
updatesectorz(pos, sectp);
|
||||||
*y += ny;
|
|
||||||
|
|
||||||
updatesectorz(*x,*y,*z,sectp);
|
|
||||||
if (*sectp == nullptr)
|
if (*sectp == nullptr)
|
||||||
{
|
{
|
||||||
*x = INT32_MAX; // don't spawn shrap, just change wall
|
pos.X = INT32_MAX; // don't spawn shrap, just change wall
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,7 +788,7 @@ int WallBreakPosition(walltype* wp, sectortype** sectp, int *x, int *y, int *z,
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the tough parameter is not set, then it can't break tough walls and sprites
|
// If the tough parameter is not set, then it can't break tough walls and sprites
|
||||||
bool HitBreakWall(walltype* wp, int hit_x, int hit_y, int hit_z, int ang, int type)
|
bool HitBreakWall(walltype* wp, DVector3 hitpos, DAngle ang, int type)
|
||||||
{
|
{
|
||||||
int match = wp->hitag;
|
int match = wp->hitag;
|
||||||
|
|
||||||
|
@ -795,10 +801,10 @@ bool HitBreakWall(walltype* wp, int hit_x, int hit_y, int hit_z, int ang, int ty
|
||||||
//if (hit_x == INT32_MAX)
|
//if (hit_x == INT32_MAX)
|
||||||
{
|
{
|
||||||
sectortype* sect = nullptr;
|
sectortype* sect = nullptr;
|
||||||
WallBreakPosition(wp, §, &hit_x, &hit_y, &hit_z, &ang);
|
WallBreakPosition(wp, §, hitpos, ang);
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoBreakWall(wp, hit_x, hit_y, hit_z, ang, type);
|
AutoBreakWall(wp, hitpos, ang, type);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1020,17 +1026,17 @@ int HitBreakSprite(DSWActor* breakActor, int type)
|
||||||
void DoWallBreakMatch(int match)
|
void DoWallBreakMatch(int match)
|
||||||
{
|
{
|
||||||
sectortype* sect = nullptr;
|
sectortype* sect = nullptr;
|
||||||
int x,y,z;
|
DVector3 hitpos;
|
||||||
int wall_ang;
|
DAngle wall_ang;
|
||||||
|
|
||||||
for(auto& wal : wall)
|
for(auto& wal : wall)
|
||||||
{
|
{
|
||||||
if (wal.hitag == match)
|
if (wal.hitag == match)
|
||||||
{
|
{
|
||||||
WallBreakPosition(&wal, §, &x, &y, &z, &wall_ang);
|
WallBreakPosition(&wal, §, hitpos, wall_ang);
|
||||||
|
|
||||||
wal.hitag = 0; // Reset the hitag
|
wal.hitag = 0; // Reset the hitag
|
||||||
AutoBreakWall(&wal, x, y, z, wall_ang, 0);
|
AutoBreakWall(&wal, hitpos, wall_ang, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,13 +50,9 @@ BREAK_INFO* FindSpriteBreakInfo(int picnum);
|
||||||
void SortBreakInfo(void);
|
void SortBreakInfo(void);
|
||||||
BREAK_INFO* SetupWallForBreak(walltype* wallp);
|
BREAK_INFO* SetupWallForBreak(walltype* wallp);
|
||||||
BREAK_INFO* SetupSpriteForBreak(DSWActor* actor);
|
BREAK_INFO* SetupSpriteForBreak(DSWActor* actor);
|
||||||
bool HitBreakWall(walltype* wp, int, int, int, int ang, int type);
|
bool HitBreakWall(walltype* wp, DVector3 pos, DAngle angle, int type);
|
||||||
inline bool HitBreakWall(walltype* wp, const DVector3& pos, DAngle angle, int type)
|
|
||||||
{
|
|
||||||
return HitBreakWall(wp, pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint, angle.Buildang(), type);
|
|
||||||
}
|
|
||||||
bool CheckBreakToughness(BREAK_INFO* break_info, int ID);
|
bool CheckBreakToughness(BREAK_INFO* break_info, int ID);
|
||||||
int WallBreakPosition(walltype* wp, sectortype** sectp, int* x, int* y, int* z, int* ang);
|
int WallBreakPosition(walltype* wp, sectortype** sectp, DVector3& pos, DAngle& ang);
|
||||||
void SortBreakInfo(void);
|
void SortBreakInfo(void);
|
||||||
void DoWallBreakMatch(int match);
|
void DoWallBreakMatch(int match);
|
||||||
|
|
||||||
|
|
|
@ -7148,10 +7148,6 @@ void TraverseBreakableWalls(sectortype* start_sect, int x, int y, int z, short a
|
||||||
int dist;
|
int dist;
|
||||||
int break_count;
|
int break_count;
|
||||||
|
|
||||||
int wall_ang;
|
|
||||||
int hit_x,hit_y,hit_z;
|
|
||||||
|
|
||||||
|
|
||||||
// limit radius
|
// limit radius
|
||||||
if (radius > 2000)
|
if (radius > 2000)
|
||||||
radius = 2000;
|
radius = 2000;
|
||||||
|
@ -7177,11 +7173,13 @@ void TraverseBreakableWalls(sectortype* start_sect, int x, int y, int z, short a
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sectortype* sectp = nullptr;
|
sectortype* sectp = nullptr;
|
||||||
if (WallBreakPosition(&wal, §p, &hit_x, &hit_y, &hit_z, &wall_ang))
|
DVector3 hitpos;
|
||||||
|
DAngle wall_ang;
|
||||||
|
if (WallBreakPosition(&wal, §p, hitpos, wall_ang))
|
||||||
{
|
{
|
||||||
if (hit_x != INT32_MAX && sectp != nullptr && FAFcansee_(x, y, z, start_sect, hit_x, hit_y, hit_z, sectp))
|
if (sectp != nullptr && FAFcansee(DVector3(x* inttoworld, y* inttoworld, z* zinttoworld), start_sect, hitpos, sectp))
|
||||||
{
|
{
|
||||||
HitBreakWall(&wal, INT32_MAX, INT32_MAX, INT32_MAX, ang, 0);
|
HitBreakWall(&wal, DVector3(INT32_MAX, INT32_MAX, INT32_MAX), DAngle::fromBuild(ang), 0);
|
||||||
|
|
||||||
break_count++;
|
break_count++;
|
||||||
if (break_count > 4)
|
if (break_count > 4)
|
||||||
|
@ -12528,7 +12526,7 @@ int ContinueHitscan(PLAYER* pp, sectortype* sect, int x, int y, int z, short ang
|
||||||
|
|
||||||
if (hit.hitWall->lotag == TAG_WALL_BREAK)
|
if (hit.hitWall->lotag == TAG_WALL_BREAK)
|
||||||
{
|
{
|
||||||
HitBreakWall(hit.hitWall, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, ang, actor->user.ID);
|
HitBreakWall(hit.hitWall, hit.hitpos, DAngle::fromBuild(ang), actor->user.ID);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12683,7 +12681,7 @@ int InitShotgun(PLAYER* pp)
|
||||||
|
|
||||||
if (hit.hitWall->lotag == TAG_WALL_BREAK)
|
if (hit.hitWall->lotag == TAG_WALL_BREAK)
|
||||||
{
|
{
|
||||||
HitBreakWall(hit.hitWall, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, ndaang, actor->user.ID);
|
HitBreakWall(hit.hitWall, hit.hitpos, DAngle::fromBuild(ndaang), actor->user.ID);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14782,7 +14780,7 @@ int InitUzi(PLAYER* pp)
|
||||||
|
|
||||||
if (hit.hitWall->lotag == TAG_WALL_BREAK)
|
if (hit.hitWall->lotag == TAG_WALL_BREAK)
|
||||||
{
|
{
|
||||||
HitBreakWall(hit.hitWall, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang, actor->user.ID);
|
HitBreakWall(hit.hitWall, hit.hitpos, DAngle::fromBuild(daang), actor->user.ID);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15610,7 +15608,7 @@ int InitTurretMgun(SECTOR_OBJECT* sop)
|
||||||
|
|
||||||
if (hit.hitWall->lotag == TAG_WALL_BREAK)
|
if (hit.hitWall->lotag == TAG_WALL_BREAK)
|
||||||
{
|
{
|
||||||
HitBreakWall(hit.hitWall, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang, 0);
|
HitBreakWall(hit.hitWall, hit.hitpos, DAngle::fromBuild(daang), 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue