mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- Distance in SW
This commit is contained in:
parent
84f690654e
commit
b3d9320d54
9 changed files with 38 additions and 28 deletions
|
@ -518,7 +518,7 @@ ANIMATOR* DoActorActionDecide(DSWActor* actor)
|
|||
DoActorOperate(actor);
|
||||
|
||||
// if far enough away and cannot see the player
|
||||
dist = Distance(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actor->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist > 30000 && !ICanSee)
|
||||
{
|
||||
|
@ -609,7 +609,7 @@ ANIMATOR* DoActorActionDecide(DSWActor* actor)
|
|||
DoActorPickClosePlayer(actor);
|
||||
|
||||
// if close by
|
||||
dist = Distance(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actor->spr.pos, actor->user.targetActor->spr.pos);
|
||||
if (dist < 15000 || ICanSee)
|
||||
{
|
||||
if ((Facing(actor, actor->user.targetActor) && dist < 10000) || ICanSee)
|
||||
|
@ -1273,7 +1273,7 @@ int InitActorDuck(DSWActor* actor)
|
|||
actor->user.ActorActionFunc = DoActorDuck;
|
||||
NewStateGroup(actor, actor->user.ActorActionSet->Duck);
|
||||
|
||||
dist = Distance(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actor->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist > 8000)
|
||||
{
|
||||
|
@ -1561,7 +1561,7 @@ int InitActorReposition(DSWActor* actor)
|
|||
actor->user.Dist = 0;
|
||||
|
||||
rnum = RANDOM_P2(8<<8)>>8;
|
||||
dist = Distance(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actor->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist < PlayerDist[rnum] || (actor->user.Flags & SPR_RUN_AWAY))
|
||||
{
|
||||
|
|
|
@ -569,7 +569,7 @@ int DoCoolieMove(DSWActor* actor)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (Distance(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y) < 1200)
|
||||
if (DistanceI(actor->spr.pos, actor->user.targetActor->spr.pos) < 1200)
|
||||
{
|
||||
UpdateSinglePlayKills(actor);
|
||||
DoActorDie(actor, actor, 0);
|
||||
|
|
|
@ -1580,6 +1580,16 @@ extern SECTOR_OBJECT SectorObject[MAX_SECTOR_OBJECTS];
|
|||
ANIMATOR NullAnimator;
|
||||
|
||||
int Distance(int x1, int y1, int x2, int y2);
|
||||
int DistanceI(const DVector2& pos1, const DVector2& pos2)
|
||||
{
|
||||
return Distance(int(pos1.X * worldtoint), int(pos1.Y * worldtoint), int(pos2.X * worldtoint), int(pos2.Y * worldtoint));
|
||||
}
|
||||
/*
|
||||
double Distance(const DVector2& pos1, const DVector2& pos2)
|
||||
{
|
||||
return (pos2 - pos1).Length();
|
||||
}
|
||||
*/
|
||||
|
||||
int NewStateGroup(DSWActor* actor, STATE* SpriteGroup[]);
|
||||
void SectorMidPoint(sectortype* sect, int *xmid, int *ymid, int *zmid);
|
||||
|
|
|
@ -3632,7 +3632,7 @@ DSWActor* FindNearSprite(DSWActor* actor, short stat)
|
|||
SWStatIterator it(stat);
|
||||
while (auto itActor = it.Next())
|
||||
{
|
||||
dist = Distance(actor->int_pos().X, actor->int_pos().Y, itActor->int_pos().X, itActor->int_pos().Y);
|
||||
dist = DistanceI(actor->spr.pos, itActor->spr.pos);
|
||||
|
||||
if (dist < near_dist)
|
||||
{
|
||||
|
|
|
@ -938,7 +938,7 @@ int InitRipperHang(DSWActor* actor)
|
|||
if (hit.hitSector == nullptr)
|
||||
continue;
|
||||
|
||||
dist = Distance(actor->int_pos().X, actor->int_pos().Y, hit.int_hitpos().X, hit.int_hitpos().Y);
|
||||
dist = DistanceI(actor->spr.pos, hit.hitpos);
|
||||
|
||||
if (hit.hitWall == nullptr || dist < 2000 || dist > 7000)
|
||||
{
|
||||
|
|
|
@ -947,7 +947,7 @@ int InitRipper2Hang(DSWActor* actor)
|
|||
if (hit.hitSector == nullptr)
|
||||
continue;
|
||||
|
||||
dist = Distance(actor->int_pos().X, actor->int_pos().Y, hit.int_hitpos().X, hit.int_hitpos().Y);
|
||||
dist = DistanceI(actor->spr.pos, hit.hitpos);
|
||||
|
||||
if (hit.hitWall == nullptr || dist < 2000 || dist > 7000)
|
||||
{
|
||||
|
|
|
@ -326,7 +326,7 @@ int DoRotator(DSWActor* actor)
|
|||
{
|
||||
if (itActor->spr.lotag == actor->spr.lotag)
|
||||
{
|
||||
dist = Distance(actor->int_pos().X, actor->int_pos().Y, itActor->int_pos().X, itActor->int_pos().Y);
|
||||
dist = DistanceI(actor->spr.pos, itActor->spr.pos);
|
||||
if (dist < closest)
|
||||
{
|
||||
closest = dist;
|
||||
|
|
|
@ -4262,7 +4262,7 @@ bool SpriteOverlap(DSWActor* actor_a, DSWActor* actor_b)
|
|||
int spa_tos, spa_bos, spb_tos, spb_bos, overlap_z;
|
||||
|
||||
if (!actor_a->hasU() || !actor_b->hasU()) return false;
|
||||
if ((unsigned)Distance(actor_a->int_pos().X, actor_a->int_pos().Y, actor_b->int_pos().X, actor_b->int_pos().Y) > actor_a->user.Radius + actor_b->user.Radius)
|
||||
if ((unsigned)DistanceI(actor_a->spr.pos, actor_b->spr.pos) > actor_a->user.Radius + actor_b->user.Radius)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -11414,7 +11414,7 @@ int InitLavaThrow(DSWActor* actor)
|
|||
MissileSetPos(actorNew, DoLavaBoulder, 1200);
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
actorNew->user.change.Z = actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
@ -11690,7 +11690,7 @@ int InitEnemyNapalm(DSWActor* actor)
|
|||
}
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
@ -11780,7 +11780,7 @@ int InitEnemyMirv(DSWActor* actor)
|
|||
MissileSetPos(actorNew, DoMirv, 600);
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
actorNew->user.change.Z = actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
@ -12210,7 +12210,7 @@ int InitSumoNapalm(DSWActor* actor)
|
|||
}
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
@ -12298,7 +12298,7 @@ int InitSumoStompAttack(DSWActor* actor)
|
|||
if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY))
|
||||
continue;
|
||||
|
||||
dist = Distance(actor->int_pos().X, actor->int_pos().Y, itActor->int_pos().X, itActor->int_pos().Y);
|
||||
dist = DistanceI(actor->spr.pos, itActor->spr.pos);
|
||||
|
||||
reach = 16384;
|
||||
|
||||
|
@ -12322,7 +12322,7 @@ int InitMiniSumoClap(DSWActor* actor)
|
|||
auto targetActor = actor->user.targetActor;
|
||||
if (!targetActor) return 0;
|
||||
|
||||
dist = Distance(actor->int_pos().X, actor->int_pos().Y, targetActor->int_pos().X, targetActor->int_pos().Y);
|
||||
dist = DistanceI(actor->spr.pos, targetActor->spr.pos);
|
||||
|
||||
reach = 10000;
|
||||
|
||||
|
@ -13725,7 +13725,7 @@ int InitMicro(PLAYER* pp)
|
|||
|
||||
if (picked)
|
||||
{
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, picked->int_pos().X, picked->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, picked->spr.pos);
|
||||
if (dist != 0)
|
||||
{
|
||||
int zh;
|
||||
|
@ -14096,7 +14096,7 @@ int InitSerpSpell(DSWActor* actor)
|
|||
actorNew->set_int_ang(NORM_ANGLE(actorNew->int_ang() - lat_ang[i]));
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
if (dist != 0)
|
||||
actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
||||
|
@ -14194,7 +14194,7 @@ int InitSerpMonstSpell(DSWActor* actor)
|
|||
actorNew->set_int_ang(NORM_ANGLE(actorNew->int_ang() - lat_ang[i]));
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
if (dist != 0)
|
||||
actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
||||
|
@ -14273,7 +14273,7 @@ int InitEnemyRocket(DSWActor* actor)
|
|||
MissileSetPos(actorNew, DoBoltThinMan, 400);
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
actorNew->user.change.Z = actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
@ -14354,7 +14354,7 @@ int InitEnemyRail(DSWActor* actor)
|
|||
}
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
actorNew->user.change.Z = actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
@ -14429,7 +14429,7 @@ int InitZillaRocket(DSWActor* actor)
|
|||
MissileSetPos(actorNew, DoBoltThinMan, mp[i].dist_out);
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
actorNew->user.change.Z = actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
@ -14468,7 +14468,7 @@ int InitEnemyStar(DSWActor* actor)
|
|||
MissileSetPos(actorNew, DoStar, 400);
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
actorNew->user.change.Z = actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
@ -14512,7 +14512,7 @@ int InitEnemyCrossbow(DSWActor* actor)
|
|||
MissileSetPos(actorNew, DoStar, 400);
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
actorNew->user.change.Z = actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - actorNew->int_pos().Z)) / dist;
|
||||
|
@ -14550,7 +14550,7 @@ int InitSkelSpell(DSWActor* actor)
|
|||
actorNew->spr.cstat |= (CSTAT_SPRITE_YCENTER);
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(nx, ny, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
actorNew->spr.zvel = (actorNew->spr.xvel * (ActorUpperZ(actor->user.targetActor) - nz)) / dist;
|
||||
|
@ -14603,7 +14603,7 @@ int InitCoolgFire(DSWActor* actor)
|
|||
PlaySound(DIGI_MAGIC1, actorNew, v3df_follow|v3df_doppler);
|
||||
|
||||
// find the distance to the target (player)
|
||||
dist = Distance(nx, ny, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, actor->user.targetActor->spr.pos);
|
||||
|
||||
if (dist != 0)
|
||||
// (velocity * difference between the target and the throwing star) /
|
||||
|
@ -15457,7 +15457,7 @@ int InitTurretMicro(DSWActor* actor, PLAYER* pp)
|
|||
|
||||
if (picked)
|
||||
{
|
||||
dist = Distance(actorNew->int_pos().X, actorNew->int_pos().Y, picked->int_pos().X, picked->int_pos().Y);
|
||||
dist = DistanceI(actorNew->spr.pos, picked->spr.pos);
|
||||
if (dist != 0)
|
||||
{
|
||||
int zh;
|
||||
|
@ -17689,7 +17689,7 @@ DSWActor* QueueWallBlood(DSWActor* actor, short ang)
|
|||
return nullptr;
|
||||
|
||||
const int WALLBLOOD_DIST_MAX = 2500;
|
||||
if (Distance(hit.int_hitpos().X, hit.int_hitpos().Y, actor->int_pos().X, actor->int_pos().Y) > WALLBLOOD_DIST_MAX)
|
||||
if (DistanceI(hit.hitpos, actor->spr.pos) > WALLBLOOD_DIST_MAX)
|
||||
return nullptr;
|
||||
|
||||
// hit a sprite?
|
||||
|
|
Loading…
Reference in a new issue