mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- wallmove.cpp
This commit is contained in:
parent
10ea8b0fb5
commit
21af63dfcc
3 changed files with 22 additions and 27 deletions
|
@ -2136,7 +2136,7 @@ void ScaleRandomPoint(SECTOR_OBJECTp sop,short k,short ang,int x,int y,int *dx,i
|
|||
void CopySectorMatch(short match); // copysect.c
|
||||
|
||||
int DoWallMoveMatch(short match); // wallmove.c
|
||||
int DoWallMove(SPRITEp sp); // wallmove.c
|
||||
int DoWallMove(DSWActor* sp); // wallmove.c
|
||||
bool CanSeeWallMove(SPRITEp wp,short match); // wallmove.c
|
||||
|
||||
void DoSpikeOperate(short sectnum); // spike.c
|
||||
|
|
|
@ -38,16 +38,17 @@ BEGIN_SW_NS
|
|||
|
||||
SECTOR_OBJECTp DetectSectorObjectByWall(WALLp);
|
||||
|
||||
void SOwallmove(SECTOR_OBJECTp sop, SPRITEp sp, WALLp find_wallp, int dist, int *nx, int *ny)
|
||||
void SOwallmove(SECTOR_OBJECTp sop, DSWActor* actor, WALLp find_wallp, int dist, int *nx, int *ny)
|
||||
{
|
||||
int j,k,wallcount;
|
||||
WALLp wp;
|
||||
short startwall,endwall;
|
||||
SECTORp *sectp;
|
||||
|
||||
if (TEST(sop->flags, SOBJ_SPRITE_OBJ))
|
||||
if (!actor->hasU() || TEST(sop->flags, SOBJ_SPRITE_OBJ))
|
||||
return;
|
||||
|
||||
auto u = actor->u();
|
||||
wallcount = 0;
|
||||
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
||||
{
|
||||
|
@ -62,8 +63,7 @@ void SOwallmove(SECTOR_OBJECTp sop, SPRITEp sp, WALLp find_wallp, int dist, int
|
|||
{
|
||||
short ang;
|
||||
// move orig x and y in saved angle
|
||||
ASSERT(User[sp - sprite].Data());
|
||||
ang = User[sp - sprite]->sang;
|
||||
ang = u->sang;
|
||||
|
||||
*nx = MulScale(dist, bcos(ang), 14);
|
||||
*ny = MulScale(dist, bsin(ang), 14);
|
||||
|
@ -80,7 +80,7 @@ void SOwallmove(SECTOR_OBJECTp sop, SPRITEp sp, WALLp find_wallp, int dist, int
|
|||
}
|
||||
}
|
||||
|
||||
int DoWallMove(SPRITEp sp)
|
||||
int DoWallMove(DSWActor* actor)
|
||||
{
|
||||
int dist,nx,ny;
|
||||
short shade1,shade2,ang,picnum1,picnum2;
|
||||
|
@ -90,6 +90,8 @@ int DoWallMove(SPRITEp sp)
|
|||
short dang;
|
||||
bool SOsprite = false;
|
||||
|
||||
auto sp = &actor->s();
|
||||
|
||||
dist = SP_TAG13(sp);
|
||||
ang = SP_TAG4(sp);
|
||||
picnum1 = SP_TAG5(sp);
|
||||
|
@ -115,7 +117,7 @@ int DoWallMove(SPRITEp sp)
|
|||
SECTOR_OBJECTp sop;
|
||||
sop = DetectSectorObjectByWall(wallp);
|
||||
ASSERT(sop);
|
||||
SOwallmove(sop, sp, wallp, dist, &nx, &ny);
|
||||
SOwallmove(sop, actor, wallp, dist, &nx, &ny);
|
||||
|
||||
SOsprite = true;
|
||||
}
|
||||
|
@ -143,15 +145,15 @@ int DoWallMove(SPRITEp sp)
|
|||
SP_TAG9(sp)--;
|
||||
if ((signed char)SP_TAG9(sp) <= 0)
|
||||
{
|
||||
KillSprite(short(sp - sprite));
|
||||
KillActor(actor);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SOsprite)
|
||||
{
|
||||
// move the sprite offset from center
|
||||
User[sp - sprite]->sx -= nx;
|
||||
User[sp - sprite]->sy -= ny;
|
||||
actor->u()->sx -= nx;
|
||||
actor->u()->sy -= ny;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -169,44 +171,37 @@ bool CanSeeWallMove(SPRITEp wp, short match)
|
|||
bool found = false;
|
||||
SPRITEp sp;
|
||||
|
||||
StatIterator it(STAT_WALL_MOVE_CANSEE);
|
||||
while ((i = it.NextIndex()) >= 0)
|
||||
SWStatIterator it(STAT_WALL_MOVE_CANSEE);
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
sp = &sprite[i];
|
||||
sp = &actor->s();
|
||||
|
||||
if (SP_TAG2(sp) == match)
|
||||
{
|
||||
found = true;
|
||||
|
||||
if (cansee(wp->x,wp->y,wp->z,wp->sectnum,sp->x,sp->y,sp->z,sp->sectnum))
|
||||
if (cansee(wp->x, wp->y, wp->z, wp->sectnum, sp->x, sp->y, sp->z, sp->sectnum))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return !found;
|
||||
}
|
||||
|
||||
int DoWallMoveMatch(short match)
|
||||
{
|
||||
SPRITEp sp;
|
||||
int i;
|
||||
bool found = false;
|
||||
|
||||
// just all with the same matching tags
|
||||
StatIterator it(STAT_WALL_MOVE);
|
||||
while ((i = it.NextIndex()) >= 0)
|
||||
SWStatIterator it(STAT_WALL_MOVE);
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
sp = &sprite[i];
|
||||
|
||||
if (SP_TAG2(sp) == match)
|
||||
if (SP_TAG2(&actor->s()) == match)
|
||||
{
|
||||
found = true;
|
||||
DoWallMove(sp);
|
||||
DoWallMove(actor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7846,7 +7846,7 @@ int DoExpDamageTest(DSWActor* actor)
|
|||
if (SP_TAG2(found_sp) == 0)
|
||||
{
|
||||
// just do one
|
||||
DoWallMove(found_sp);
|
||||
DoWallMove(&swActors[found_sp - sprite]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue