mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- adapted hitscan calls in Exhumed.
This commit is contained in:
parent
10dce7dd2d
commit
4bfb03b6b3
5 changed files with 44 additions and 68 deletions
|
@ -444,19 +444,19 @@ MOVEEND:
|
|||
else
|
||||
{
|
||||
vec3_t startPos = { x, y, z };
|
||||
hitdata_t hitData;
|
||||
HitInfo hit;
|
||||
int dz;
|
||||
if (bVanilla)
|
||||
dz = -bsin(pBullet->nPitch, 3);
|
||||
else
|
||||
dz = -pBullet->nPitch * 512;
|
||||
hitscan(&startPos, pSprite->sectnum, bcos(pSprite->ang), bsin(pSprite->ang), dz, &hitData, CLIPMASK1);
|
||||
x2 = hitData.pos.x;
|
||||
y2 = hitData.pos.y;
|
||||
z2 = hitData.pos.z;
|
||||
hitactor = GetActor(hitData);
|
||||
pHitSect = hitData.sect >= 0? §or[hitData.sect] : nullptr;
|
||||
pHitWall = hitData.wall >= 0? &wall[hitData.wall] : nullptr;
|
||||
hitscan(startPos, pSprite->sector(), { bcos(pSprite->ang), bsin(pSprite->ang), dz }, hit, CLIPMASK1);
|
||||
x2 = hit.hitpos.x;
|
||||
y2 = hit.hitpos.y;
|
||||
z2 = hit.hitpos.z;
|
||||
hitactor = hit.actor();
|
||||
pHitSect = hit.hitSector;
|
||||
pHitWall = hit.hitWall;
|
||||
}
|
||||
|
||||
lasthitx = x2;
|
||||
|
|
|
@ -140,6 +140,15 @@ inline int Collision::actorIndex(DExhumedActor* a)
|
|||
|
||||
inline DExhumedActor* DExhumedActor::base() { return exhumedActors; }
|
||||
|
||||
// subclassed to add a game specific actor() method
|
||||
struct HitInfo : public HitInfoBase
|
||||
{
|
||||
DExhumedActor* actor() const
|
||||
{
|
||||
return static_cast<DExhumedActor*>(hitActor);
|
||||
}
|
||||
};
|
||||
|
||||
// Iterator wrappers that return an actor pointer, not an index.
|
||||
class ExhumedStatIterator : public StatIterator
|
||||
{
|
||||
|
@ -254,9 +263,4 @@ inline void setActorPos(DExhumedActor* actor, vec3_t* pos)
|
|||
setsprite(actor->GetSpriteIndex(), pos);
|
||||
}
|
||||
|
||||
inline DExhumedActor* GetActor(const hitdata_t& hitData)
|
||||
{
|
||||
return hitData.sprite < 0? nullptr : &exhumedActors[hitData.sprite];
|
||||
}
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -243,29 +243,19 @@ void ResetSwordSeqs()
|
|||
|
||||
Collision CheckCloseRange(int nPlayer, int *x, int *y, int *z, sectortype* *ppSector)
|
||||
{
|
||||
int hitSect, hitWall, hitSprite;
|
||||
int hitX, hitY, hitZ;
|
||||
|
||||
auto pActor = PlayerList[nPlayer].Actor();
|
||||
|
||||
int ang = pActor->s().ang;
|
||||
int xVect = bcos(ang);
|
||||
int yVect = bsin(ang);
|
||||
|
||||
vec3_t startPos = { *x, *y, *z };
|
||||
hitdata_t hitData;
|
||||
hitscan(&startPos, sectnum(*ppSector), xVect, yVect, 0, &hitData, CLIPMASK1);
|
||||
hitX = hitData.pos.x;
|
||||
hitY = hitData.pos.y;
|
||||
hitZ = hitData.pos.z;
|
||||
hitSprite = hitData.sprite;
|
||||
hitSect = hitData.sect;
|
||||
hitWall = hitData.wall;
|
||||
HitInfo hit;
|
||||
hitscan({ *x, *y, *z }, *ppSector, { xVect, yVect, 0 }, hit, CLIPMASK1);
|
||||
|
||||
int ecx = bsin(150, -3);
|
||||
|
||||
uint32_t xDiff = abs(hitX - *x);
|
||||
uint32_t yDiff = abs(hitY - *y);
|
||||
uint32_t yDiff = abs(hit.hitpos.y - *y);
|
||||
uint32_t xDiff = abs(hit.hitpos.x - *x);
|
||||
|
||||
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
|
||||
|
||||
|
@ -279,16 +269,16 @@ Collision CheckCloseRange(int nPlayer, int *x, int *y, int *z, sectortype* *ppSe
|
|||
if (ksqrt(sqrtNum) >= ecx)
|
||||
return c;
|
||||
|
||||
*x = hitX;
|
||||
*y = hitY;
|
||||
*z = hitZ;
|
||||
*ppSector = §or[hitSect];
|
||||
*x = hit.hitpos.x;
|
||||
*y = hit.hitpos.y;
|
||||
*z = hit.hitpos.z;
|
||||
*ppSector = hit.hitSector;
|
||||
|
||||
if (hitSprite > -1) {
|
||||
c.setSprite(&exhumedActors[hitSprite]);
|
||||
if (hit.actor()) {
|
||||
c.setSprite(hit.actor());
|
||||
}
|
||||
if (hitWall > -1) {
|
||||
c.setWall(hitWall);
|
||||
if (hit.hitWall) {
|
||||
c.setWall(wallnum(hit.hitWall));
|
||||
}
|
||||
|
||||
return c;
|
||||
|
|
|
@ -400,21 +400,14 @@ void AILion::Tick(RunListEvent* ev)
|
|||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
int hitwall;
|
||||
int hitx, hity;
|
||||
vec3_t startPos = { x, y, z };
|
||||
hitdata_t hitData;
|
||||
HitInfo hit;
|
||||
|
||||
hitscan(&startPos, pSprite->sectnum, bcos(nScanAngle), bsin(nScanAngle), 0, &hitData, CLIPMASK1);
|
||||
hitscan({ x, y, z }, pSprite->sector(), { bcos(nScanAngle), bsin(nScanAngle), 0 }, hit, CLIPMASK1);
|
||||
|
||||
hitx = hitData.pos.x;
|
||||
hity = hitData.pos.y;
|
||||
hitwall = hitData.wall;
|
||||
|
||||
if (hitwall > -1)
|
||||
if (hit.hitWall)
|
||||
{
|
||||
int theX = abs(hitx - x);
|
||||
int theY = abs(hity - y);
|
||||
int theX = abs(hit.hitpos.x - x);
|
||||
int theY = abs(hit.hitpos.y - y);
|
||||
|
||||
if ((theX + theY) < nCheckDist)
|
||||
{
|
||||
|
|
|
@ -130,22 +130,11 @@ void BuildSnake(int nPlayer, int zVal)
|
|||
int z = (pPlayerSprite->z + zVal) - 2560;
|
||||
int nAngle = pPlayerSprite->ang;
|
||||
|
||||
int hitsect;
|
||||
int hitx, hity, hitz;
|
||||
DExhumedActor* hitactor;
|
||||
HitInfo hit;
|
||||
hitscan({ x, y, z }, pPlayerSprite->sector(), { bcos(nAngle), bsin(nAngle), 0 }, hit, CLIPMASK1);
|
||||
|
||||
vec3_t pos = { x, y, z };
|
||||
hitdata_t hitData;
|
||||
hitscan(&pos, pPlayerSprite->sectnum, bcos(nAngle), bsin(nAngle), 0, &hitData, CLIPMASK1);
|
||||
|
||||
hitx = hitData.pos.x;
|
||||
hity = hitData.pos.y;
|
||||
hitz = hitData.pos.z;
|
||||
hitsect = hitData.sect;
|
||||
hitactor = hitData.sprite == -1? nullptr : &exhumedActors[hitData.sprite];
|
||||
|
||||
uint32_t xDiff = abs(hitx - x);
|
||||
uint32_t yDiff = abs(hity - y);
|
||||
uint32_t yDiff = abs(hit.hitpos.y - y);
|
||||
uint32_t xDiff = abs(hit.hitpos.x - x);
|
||||
|
||||
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
|
||||
|
||||
|
@ -159,12 +148,12 @@ void BuildSnake(int nPlayer, int zVal)
|
|||
|
||||
if (nSqrt < bsin(512, -4))
|
||||
{
|
||||
BackUpBullet(&hitx, &hity, nAngle);
|
||||
auto pActor = insertActor(hitsect, 202);
|
||||
BackUpBullet(&hit.hitpos.x, &hit.hitpos.y, nAngle);
|
||||
auto pActor = insertActor(hit.hitSector, 202);
|
||||
auto pSprite = &pActor->s();
|
||||
pSprite->x = hitx;
|
||||
pSprite->y = hity;
|
||||
pSprite->z = hitz;
|
||||
pSprite->x = hit.hitpos.x;
|
||||
pSprite->y = hit.hitpos.y;
|
||||
pSprite->z = hit.hitpos.z;
|
||||
|
||||
ExplodeSnakeSprite(pActor, nPlayer);
|
||||
DeleteActor(pActor);
|
||||
|
@ -173,7 +162,7 @@ void BuildSnake(int nPlayer, int zVal)
|
|||
else
|
||||
{
|
||||
DExhumedActor* pTarget = nullptr;
|
||||
|
||||
auto hitactor = hit.actor();
|
||||
if (hitactor && hitactor->s().statnum >= 90 && hitactor->s().statnum <= 199) {
|
||||
pTarget = hitactor;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue