mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- floatified CanHitPlayer and sanitized its overcomplicated and broken math.
This commit is contained in:
parent
bc5a92bcc9
commit
072cb5ccdf
2 changed files with 13 additions and 29 deletions
|
@ -207,7 +207,7 @@ int DoActorNoise(ANIMATOR* Action, DSWActor* actor)
|
|||
PlaySpriteSound(actor, attr_extra5, v3df_follow);
|
||||
}
|
||||
else if (Action == InitActorExtra6Noise)
|
||||
{
|
||||
{
|
||||
PlaySpriteSound(actor, attr_extra6, v3df_follow);
|
||||
}
|
||||
|
||||
|
@ -222,37 +222,15 @@ bool CanSeePlayer(DSWActor* actor)
|
|||
int CanHitPlayer(DSWActor* actor)
|
||||
{
|
||||
HitInfo hit{};
|
||||
int xvect,yvect,zvect;
|
||||
int ang;
|
||||
DVector3 vect;
|
||||
// if actor can still see the player
|
||||
int zhs, zhh;
|
||||
|
||||
zhs = actor->int_pos().Z - (int_ActorSizeZ(actor) >> 1);
|
||||
DSWActor* targ = actor->user.targetActor;
|
||||
DVector3 apos = actor->spr.pos.plusZ(-ActorSizeZ(actor) * 0.5);
|
||||
DVector3 tpos = targ->spr.pos.plusZ(-ActorSizeZ(targ) * 0.5);
|
||||
auto vec = (tpos - apos).Unit() * 1024;
|
||||
|
||||
|
||||
auto targ = actor->user.targetActor;
|
||||
|
||||
// get angle to target
|
||||
ang = getangle(targ->spr.pos - actor->spr.pos);
|
||||
|
||||
// get x,yvect
|
||||
xvect = bcos(ang);
|
||||
yvect = bsin(ang);
|
||||
|
||||
// get zvect
|
||||
zhh = targ->int_pos().Z - (int_ActorSizeZ(targ) >> 1);
|
||||
if (targ->int_pos().X - actor->int_pos().X != 0)
|
||||
zvect = xvect * ((zhh - zhs) / (targ->int_pos().X - actor->int_pos().X));
|
||||
else if (targ->int_pos().Y - actor->int_pos().Y != 0)
|
||||
zvect = yvect * ((zhh - zhs) / (targ->int_pos().Y - actor->int_pos().Y));
|
||||
else
|
||||
return false;
|
||||
|
||||
FAFhitscan(actor->int_pos().X, actor->int_pos().Y, zhs, actor->sector(),
|
||||
xvect,
|
||||
yvect,
|
||||
zvect,
|
||||
hit, CLIPMASK_MISSILE);
|
||||
FAFhitscan(apos, actor->sector(), vec, hit, CLIPMASK_MISSILE);
|
||||
|
||||
if (hit.hitSector == nullptr)
|
||||
return false;
|
||||
|
|
|
@ -1770,6 +1770,12 @@ void FAFhitscan(int32_t x, int32_t y, int32_t z, sectortype* sect,
|
|||
int32_t xvect, int32_t yvect, int32_t zvect,
|
||||
HitInfo& hit, int32_t clipmask);
|
||||
|
||||
inline void FAFhitscan(const DVector3& start, sectortype* sect, const DVector3& vect, HitInfo& hit, int32_t clipmask)
|
||||
{
|
||||
FAFhitscan(int(start.X * worldtoint), int(start.Y * worldtoint), int(start.Z * zworldtoint), sect,
|
||||
int(vect.X * worldtoint), int(vect.Y * worldtoint), int(vect.Z * zworldtoint), hit, clipmask);
|
||||
}
|
||||
|
||||
bool FAFcansee_(int32_t xs, int32_t ys, int32_t zs, sectortype* sects, int32_t xe, int32_t ye, int32_t ze, sectortype* secte);
|
||||
inline bool FAFcansee(const DVector3& start, sectortype* sects, const DVector3& end, sectortype* secte)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue