mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-14 08:30:50 +00:00
Merge branch 'zmaster' into edf-gl
Conflicts: src/actor.h
This commit is contained in:
commit
d5cf31f821
44 changed files with 330 additions and 231 deletions
|
@ -119,7 +119,7 @@ Rect SkylineBinPack::Insert(int width, int height)
|
||||||
return newNode;
|
return newNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InsertMinWaste(width, height);
|
return InsertBottomLeft(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkylineBinPack::RectangleFits(int skylineNodeIndex, int width, int height, int &y) const
|
bool SkylineBinPack::RectangleFits(int skylineNodeIndex, int width, int height, int &y) const
|
||||||
|
@ -254,6 +254,73 @@ void SkylineBinPack::MergeSkylines()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect SkylineBinPack::InsertBottomLeft(int width, int height)
|
||||||
|
{
|
||||||
|
int bestHeight;
|
||||||
|
int bestWidth;
|
||||||
|
int bestIndex;
|
||||||
|
Rect newNode = FindPositionForNewNodeBottomLeft(width, height, bestHeight, bestWidth, bestIndex);
|
||||||
|
|
||||||
|
if (bestIndex != -1)
|
||||||
|
{
|
||||||
|
assert(disjointRects.Disjoint(newNode));
|
||||||
|
// Perform the actual packing.
|
||||||
|
AddSkylineLevel(bestIndex, newNode);
|
||||||
|
|
||||||
|
usedSurfaceArea += width * height;
|
||||||
|
#ifdef _DEBUG
|
||||||
|
disjointRects.Add(newNode);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
memset(&newNode, 0, sizeof(Rect));
|
||||||
|
|
||||||
|
return newNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect SkylineBinPack::FindPositionForNewNodeBottomLeft(int width, int height, int &bestHeight, int &bestWidth, int &bestIndex) const
|
||||||
|
{
|
||||||
|
bestHeight = INT_MAX;
|
||||||
|
bestIndex = -1;
|
||||||
|
// Used to break ties if there are nodes at the same level. Then pick the narrowest one.
|
||||||
|
bestWidth = INT_MAX;
|
||||||
|
Rect newNode = { 0, 0, 0, 0 };
|
||||||
|
for(unsigned i = 0; i < skyLine.Size(); ++i)
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
if (RectangleFits(i, width, height, y))
|
||||||
|
{
|
||||||
|
if (y + height < bestHeight || (y + height == bestHeight && skyLine[i].width < bestWidth))
|
||||||
|
{
|
||||||
|
bestHeight = y + height;
|
||||||
|
bestIndex = i;
|
||||||
|
bestWidth = skyLine[i].width;
|
||||||
|
newNode.x = skyLine[i].x;
|
||||||
|
newNode.y = y;
|
||||||
|
newNode.width = width;
|
||||||
|
newNode.height = height;
|
||||||
|
assert(disjointRects.Disjoint(newNode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* if (RectangleFits(i, height, width, y))
|
||||||
|
{
|
||||||
|
if (y + width < bestHeight || (y + width == bestHeight && skyLine[i].width < bestWidth))
|
||||||
|
{
|
||||||
|
bestHeight = y + width;
|
||||||
|
bestIndex = i;
|
||||||
|
bestWidth = skyLine[i].width;
|
||||||
|
newNode.x = skyLine[i].x;
|
||||||
|
newNode.y = y;
|
||||||
|
newNode.width = height;
|
||||||
|
newNode.height = width;
|
||||||
|
assert(disjointRects.Disjoint(newNode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/ }
|
||||||
|
|
||||||
|
return newNode;
|
||||||
|
}
|
||||||
|
|
||||||
Rect SkylineBinPack::InsertMinWaste(int width, int height)
|
Rect SkylineBinPack::InsertMinWaste(int width, int height)
|
||||||
{
|
{
|
||||||
int bestHeight;
|
int bestHeight;
|
||||||
|
|
|
@ -72,7 +72,10 @@ private:
|
||||||
bool useWasteMap;
|
bool useWasteMap;
|
||||||
GuillotineBinPack wasteMap;
|
GuillotineBinPack wasteMap;
|
||||||
|
|
||||||
|
Rect InsertBottomLeft(int width, int height);
|
||||||
Rect InsertMinWaste(int width, int height);
|
Rect InsertMinWaste(int width, int height);
|
||||||
|
|
||||||
|
Rect FindPositionForNewNodeBottomLeft(int width, int height, int &bestHeight, int &bestWidth, int &bestIndex) const;
|
||||||
Rect FindPositionForNewNodeMinWaste(int width, int height, int &bestHeight, int &bestWastedArea, int &bestIndex) const;
|
Rect FindPositionForNewNodeMinWaste(int width, int height, int &bestHeight, int &bestWastedArea, int &bestIndex) const;
|
||||||
|
|
||||||
bool RectangleFits(int skylineNodeIndex, int width, int height, int &y) const;
|
bool RectangleFits(int skylineNodeIndex, int width, int height, int &y) const;
|
||||||
|
|
58
src/actor.h
58
src/actor.h
|
@ -611,7 +611,8 @@ extern FDropItemPtrArray DropItemList;
|
||||||
|
|
||||||
void FreeDropItemChain(FDropItem *chain);
|
void FreeDropItemChain(FDropItem *chain);
|
||||||
int StoreDropItemChain(FDropItem *chain);
|
int StoreDropItemChain(FDropItem *chain);
|
||||||
|
fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); // since we cannot include p_local here...
|
||||||
|
angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2); // same reason here with r_defs.h
|
||||||
|
|
||||||
|
|
||||||
// Map Object definition.
|
// Map Object definition.
|
||||||
|
@ -853,6 +854,61 @@ public:
|
||||||
return bloodcls;
|
return bloodcls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'absolute' is reserved for a linked portal implementation which needs
|
||||||
|
// to distinguish between portal-aware and portal-unaware distance calculation.
|
||||||
|
fixed_t AproxDistance(AActor *other, bool absolute = false)
|
||||||
|
{
|
||||||
|
return P_AproxDistance(x - other->x, y - other->y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// same with 'ref' here.
|
||||||
|
fixed_t AproxDistance(fixed_t otherx, fixed_t othery, AActor *ref = NULL)
|
||||||
|
{
|
||||||
|
return P_AproxDistance(x - otherx, y - othery);
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false)
|
||||||
|
{
|
||||||
|
return P_AproxDistance(x - other->x + xadd, y - other->y + yadd);
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed_t AproxDistance3D(AActor *other, bool absolute = false)
|
||||||
|
{
|
||||||
|
return P_AproxDistance(AproxDistance(other), z - other->z);
|
||||||
|
}
|
||||||
|
|
||||||
|
// more precise, but slower version, being used in a few places
|
||||||
|
fixed_t Distance2D(AActor *other, bool absolute = false)
|
||||||
|
{
|
||||||
|
return xs_RoundToInt(FVector2(x - other->x, y - other->y).Length());
|
||||||
|
}
|
||||||
|
|
||||||
|
// a full 3D version of the above
|
||||||
|
fixed_t Distance3D(AActor *other, bool absolute = false)
|
||||||
|
{
|
||||||
|
return xs_RoundToInt(FVector3(x - other->x, y - other->y, z - other->z).Length());
|
||||||
|
}
|
||||||
|
|
||||||
|
angle_t AngleTo(AActor *other, bool absolute = false) const
|
||||||
|
{
|
||||||
|
return R_PointToAngle2(x, y, other->x, other->y);
|
||||||
|
}
|
||||||
|
|
||||||
|
angle_t AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const
|
||||||
|
{
|
||||||
|
return R_PointToAngle2(x, y, other->x + oxofs, other->y + oyofs);
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed_t AngleTo(fixed_t otherx, fixed_t othery, AActor *ref = NULL)
|
||||||
|
{
|
||||||
|
return R_PointToAngle2(x, y, otherx, othery);
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed_t AngleXYTo(fixed_t myx, fixed_t myy, AActor *other, bool absolute = false)
|
||||||
|
{
|
||||||
|
return R_PointToAngle2(myx, myy, other->x, other->y);
|
||||||
|
}
|
||||||
|
|
||||||
inline void SetFriendPlayer(player_t *player);
|
inline void SetFriendPlayer(player_t *player);
|
||||||
|
|
||||||
bool IsVisibleToPlayer() const;
|
bool IsVisibleToPlayer() const;
|
||||||
|
|
|
@ -37,7 +37,7 @@ bool DBot::Reachable (AActor *rtarget)
|
||||||
|
|
||||||
sector_t *last_s = player->mo->Sector;
|
sector_t *last_s = player->mo->Sector;
|
||||||
fixed_t last_z = last_s->floorplane.ZatPoint (player->mo->x, player->mo->y);
|
fixed_t last_z = last_s->floorplane.ZatPoint (player->mo->x, player->mo->y);
|
||||||
fixed_t estimated_dist = P_AproxDistance (player->mo->x - rtarget->x, player->mo->y - rtarget->y);
|
fixed_t estimated_dist = player->mo->AproxDistance(rtarget);
|
||||||
bool reachable = true;
|
bool reachable = true;
|
||||||
|
|
||||||
FPathTraverse it(player->mo->x+player->mo->velx, player->mo->y+player->mo->vely, rtarget->x, rtarget->y, PT_ADDLINES|PT_ADDTHINGS);
|
FPathTraverse it(player->mo->x+player->mo->velx, player->mo->y+player->mo->vely, rtarget->x, rtarget->y, PT_ADDLINES|PT_ADDTHINGS);
|
||||||
|
@ -123,7 +123,7 @@ bool DBot::Check_LOS (AActor *to, angle_t vangle)
|
||||||
if (vangle == 0)
|
if (vangle == 0)
|
||||||
return false; //Looker seems to be blind.
|
return false; //Looker seems to be blind.
|
||||||
|
|
||||||
return absangle(R_PointToAngle2 (player->mo->x, player->mo->y, to->x, to->y) - player->mo->angle) <= vangle/2;
|
return absangle(player->mo->AngleTo(to) - player->mo->angle) <= vangle/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
@ -165,10 +165,8 @@ void DBot::Dofire (ticcmd_t *cmd)
|
||||||
//MAKEME: Decrease the rocket suicides even more.
|
//MAKEME: Decrease the rocket suicides even more.
|
||||||
|
|
||||||
no_fire = true;
|
no_fire = true;
|
||||||
//angle = R_PointToAngle2(player->mo->x, player->mo->y, player->enemy->x, player->enemy->y);
|
|
||||||
//Distance to enemy.
|
//Distance to enemy.
|
||||||
dist = P_AproxDistance ((player->mo->x + player->mo->velx) - (enemy->x + enemy->velx),
|
dist = player->mo->AproxDistance(enemy, player->mo->velx - enemy->velx, player->mo->vely - enemy->vely);
|
||||||
(player->mo->y + player->mo->vely) - (enemy->y + enemy->vely));
|
|
||||||
|
|
||||||
//FIRE EACH TYPE OF WEAPON DIFFERENT: Here should all the different weapons go.
|
//FIRE EACH TYPE OF WEAPON DIFFERENT: Here should all the different weapons go.
|
||||||
if (player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON)
|
if (player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON)
|
||||||
|
@ -219,17 +217,17 @@ void DBot::Dofire (ticcmd_t *cmd)
|
||||||
}
|
}
|
||||||
// prediction aiming
|
// prediction aiming
|
||||||
shootmissile:
|
shootmissile:
|
||||||
dist = P_AproxDistance (player->mo->x - enemy->x, player->mo->y - enemy->y);
|
dist = player->mo->AproxDistance (enemy);
|
||||||
m = dist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->Speed;
|
m = dist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->Speed;
|
||||||
bglobal.SetBodyAt (enemy->x + enemy->velx*m*2, enemy->y + enemy->vely*m*2, enemy->z, 1);
|
bglobal.SetBodyAt (enemy->x + enemy->velx*m*2, enemy->y + enemy->vely*m*2, enemy->z, 1);
|
||||||
angle = R_PointToAngle2 (player->mo->x, player->mo->y, bglobal.body1->x, bglobal.body1->y);
|
angle = player->mo->AngleTo(bglobal.body1);
|
||||||
if (Check_LOS (enemy, SHOOTFOV))
|
if (Check_LOS (enemy, SHOOTFOV))
|
||||||
no_fire = false;
|
no_fire = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Other weapons, mostly instant hit stuff.
|
//Other weapons, mostly instant hit stuff.
|
||||||
angle = R_PointToAngle2 (player->mo->x, player->mo->y, enemy->x, enemy->y);
|
angle = player->mo->AngleTo(enemy);
|
||||||
aiming_penalty = 0;
|
aiming_penalty = 0;
|
||||||
if (enemy->flags & MF_SHADOW)
|
if (enemy->flags & MF_SHADOW)
|
||||||
aiming_penalty += (pr_botdofire()%25)+10;
|
aiming_penalty += (pr_botdofire()%25)+10;
|
||||||
|
@ -265,7 +263,6 @@ shootmissile:
|
||||||
cmd->ucmd.buttons |= BT_ATTACK;
|
cmd->ucmd.buttons |= BT_ATTACK;
|
||||||
}
|
}
|
||||||
//Prevents bot from jerking, when firing automatic things with low skill.
|
//Prevents bot from jerking, when firing automatic things with low skill.
|
||||||
//player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, player->enemy->x, player->enemy->y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FCajunMaster::IsLeader (player_t *player)
|
bool FCajunMaster::IsLeader (player_t *player)
|
||||||
|
@ -331,8 +328,7 @@ AActor *DBot::Choose_Mate ()
|
||||||
{
|
{
|
||||||
if (P_CheckSight (player->mo, client->mo, SF_IGNOREVISIBILITY))
|
if (P_CheckSight (player->mo, client->mo, SF_IGNOREVISIBILITY))
|
||||||
{
|
{
|
||||||
test = P_AproxDistance (client->mo->x - player->mo->x,
|
test = client->mo->AproxDistance(player->mo);
|
||||||
client->mo->y - player->mo->y);
|
|
||||||
|
|
||||||
if (test < closest_dist)
|
if (test < closest_dist)
|
||||||
{
|
{
|
||||||
|
@ -402,8 +398,7 @@ AActor *DBot::Find_enemy ()
|
||||||
if (Check_LOS (client->mo, vangle)) //Here's a strange one, when bot is standing still, the P_CheckSight within Check_LOS almost always returns false. tought it should be the same checksight as below but.. (below works) something must be fuckin wierd screded up.
|
if (Check_LOS (client->mo, vangle)) //Here's a strange one, when bot is standing still, the P_CheckSight within Check_LOS almost always returns false. tought it should be the same checksight as below but.. (below works) something must be fuckin wierd screded up.
|
||||||
//if(P_CheckSight(player->mo, players[count].mo))
|
//if(P_CheckSight(player->mo, players[count].mo))
|
||||||
{
|
{
|
||||||
temp = P_AproxDistance (client->mo->x - player->mo->x,
|
temp = client->mo->AproxDistance(player->mo);
|
||||||
client->mo->y - player->mo->y);
|
|
||||||
|
|
||||||
//Too dark?
|
//Too dark?
|
||||||
if (temp > DARK_DIST &&
|
if (temp > DARK_DIST &&
|
||||||
|
@ -505,7 +500,7 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd)
|
||||||
|
|
||||||
actor = bglobal.body2;
|
actor = bglobal.body2;
|
||||||
|
|
||||||
dist = P_AproxDistance (actor->x-enemy->x, actor->y-enemy->y);
|
dist = actor->AproxDistance (enemy);
|
||||||
if (dist < SAFE_SELF_MISDIST)
|
if (dist < SAFE_SELF_MISDIST)
|
||||||
return 0;
|
return 0;
|
||||||
//Predict.
|
//Predict.
|
||||||
|
@ -522,7 +517,7 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd)
|
||||||
{
|
{
|
||||||
if (bglobal.FakeFire (actor, bglobal.body1, cmd) >= SAFE_SELF_MISDIST)
|
if (bglobal.FakeFire (actor, bglobal.body1, cmd) >= SAFE_SELF_MISDIST)
|
||||||
{
|
{
|
||||||
ang = R_PointToAngle2 (actor->x, actor->y, bglobal.body1->x, bglobal.body1->y);
|
ang = actor->AngleTo(bglobal.body1);
|
||||||
return ang;
|
return ang;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -532,7 +527,7 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd)
|
||||||
{
|
{
|
||||||
if (bglobal.FakeFire (player->mo, enemy, cmd) >= SAFE_SELF_MISDIST)
|
if (bglobal.FakeFire (player->mo, enemy, cmd) >= SAFE_SELF_MISDIST)
|
||||||
{
|
{
|
||||||
ang = R_PointToAngle2(player->mo->x, player->mo->y, enemy->x, enemy->y);
|
ang = player->mo->AngleTo(enemy);
|
||||||
return ang;
|
return ang;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ void DBot::Roam (ticcmd_t *cmd)
|
||||||
|
|
||||||
if (Reachable(dest))
|
if (Reachable(dest))
|
||||||
{ // Straight towards it.
|
{ // Straight towards it.
|
||||||
angle = R_PointToAngle2(player->mo->x, player->mo->y, dest->x, dest->y);
|
angle = player->mo->AngleTo(dest);
|
||||||
}
|
}
|
||||||
else if (player->mo->movedir < 8) // turn towards movement direction if not there yet
|
else if (player->mo->movedir < 8) // turn towards movement direction if not there yet
|
||||||
{
|
{
|
||||||
|
@ -347,7 +347,7 @@ void DBot::Pitch (AActor *target)
|
||||||
double diff;
|
double diff;
|
||||||
|
|
||||||
diff = target->z - player->mo->z;
|
diff = target->z - player->mo->z;
|
||||||
aim = atan (diff / (double)P_AproxDistance (player->mo->x - target->x, player->mo->y - target->y));
|
aim = atan(diff / (double)player->mo->AproxDistance(target));
|
||||||
player->mo->pitch = -(int)(aim * ANGLE_180/M_PI);
|
player->mo->pitch = -(int)(aim * ANGLE_180/M_PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
stuck = false;
|
stuck = false;
|
||||||
dist = dest ? P_AproxDistance(player->mo->x-dest->x, player->mo->y-dest->y) : 0;
|
dist = dest ? player->mo->AproxDistance(dest) : 0;
|
||||||
|
|
||||||
if (missile &&
|
if (missile &&
|
||||||
((!missile->velx || !missile->vely) || !Check_LOS(missile, SHOOTFOV*3/2)))
|
((!missile->velx || !missile->vely) || !Check_LOS(missile, SHOOTFOV*3/2)))
|
||||||
|
@ -96,14 +96,14 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
|
||||||
player->mo->pitch += 80;
|
player->mo->pitch += 80;
|
||||||
|
|
||||||
//HOW TO MOVE:
|
//HOW TO MOVE:
|
||||||
if (missile && (P_AproxDistance(player->mo->x-missile->x, player->mo->y-missile->y)<AVOID_DIST)) //try avoid missile got from P_Mobj.c thinking part.
|
if (missile && (player->mo->AproxDistance(missile)<AVOID_DIST)) //try avoid missile got from P_Mobj.c thinking part.
|
||||||
{
|
{
|
||||||
Pitch (missile);
|
Pitch (missile);
|
||||||
angle = R_PointToAngle2(player->mo->x, player->mo->y, missile->x, missile->y);
|
angle = player->mo->AngleTo(missile);
|
||||||
cmd->ucmd.sidemove = sleft ? -SIDERUN : SIDERUN;
|
cmd->ucmd.sidemove = sleft ? -SIDERUN : SIDERUN;
|
||||||
cmd->ucmd.forwardmove = -FORWARDRUN; //Back IS best.
|
cmd->ucmd.forwardmove = -FORWARDRUN; //Back IS best.
|
||||||
|
|
||||||
if ((P_AproxDistance(player->mo->x-oldx, player->mo->y-oldy)<50000)
|
if ((player->mo->AproxDistance(oldx, oldy)<50000)
|
||||||
&& t_strafe<=0)
|
&& t_strafe<=0)
|
||||||
{
|
{
|
||||||
t_strafe = 5;
|
t_strafe = 5;
|
||||||
|
@ -156,7 +156,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
|
||||||
t_fight = AFTERTICS;
|
t_fight = AFTERTICS;
|
||||||
|
|
||||||
if (t_strafe <= 0 &&
|
if (t_strafe <= 0 &&
|
||||||
(P_AproxDistance(player->mo->x-oldx, player->mo->y-oldy)<50000
|
(player->mo->AproxDistance(oldx, oldy)<50000
|
||||||
|| ((pr_botmove()%30)==10))
|
|| ((pr_botmove()%30)==10))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -165,10 +165,10 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
|
||||||
sleft = !sleft;
|
sleft = !sleft;
|
||||||
}
|
}
|
||||||
|
|
||||||
angle = R_PointToAngle2(player->mo->x, player->mo->y, enemy->x, enemy->y);
|
angle = player->mo->AngleTo(enemy);
|
||||||
|
|
||||||
if (player->ReadyWeapon == NULL ||
|
if (player->ReadyWeapon == NULL ||
|
||||||
P_AproxDistance(player->mo->x-enemy->x, player->mo->y-enemy->y) >
|
player->mo->AproxDistance(enemy) >
|
||||||
player->ReadyWeapon->MoveCombatDist)
|
player->ReadyWeapon->MoveCombatDist)
|
||||||
{
|
{
|
||||||
// If a monster, use lower speed (just for cooler apperance while strafing down doomed monster)
|
// If a monster, use lower speed (just for cooler apperance while strafing down doomed monster)
|
||||||
|
@ -206,9 +206,9 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
|
||||||
goto roam;
|
goto roam;
|
||||||
}
|
}
|
||||||
|
|
||||||
angle = R_PointToAngle2(player->mo->x, player->mo->y, mate->x, mate->y);
|
angle = player->mo->AngleTo(mate);
|
||||||
|
|
||||||
matedist = P_AproxDistance(player->mo->x - mate->x, player->mo->y - mate->y);
|
matedist = player->mo->AproxDistance(mate);
|
||||||
if (matedist > (FRIEND_DIST*2))
|
if (matedist > (FRIEND_DIST*2))
|
||||||
cmd->ucmd.forwardmove = FORWARDRUN;
|
cmd->ucmd.forwardmove = FORWARDRUN;
|
||||||
else if (matedist > FRIEND_DIST)
|
else if (matedist > FRIEND_DIST)
|
||||||
|
@ -241,7 +241,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
|
||||||
(pr_botmove()%100)>skill.isp) && player->ReadyWeapon != NULL && !(player->ReadyWeapon->WeaponFlags & WIF_WIMPY_WEAPON))
|
(pr_botmove()%100)>skill.isp) && player->ReadyWeapon != NULL && !(player->ReadyWeapon->WeaponFlags & WIF_WIMPY_WEAPON))
|
||||||
dest = enemy;//Dont let enemy kill the bot by supressive fire. So charge enemy.
|
dest = enemy;//Dont let enemy kill the bot by supressive fire. So charge enemy.
|
||||||
else //hide while t_fight, but keep view at enemy.
|
else //hide while t_fight, but keep view at enemy.
|
||||||
angle = R_PointToAngle2(player->mo->x, player->mo->y, enemy->x, enemy->y);
|
angle = player->mo->AngleTo(enemy);
|
||||||
} //Just a monster, so kill it.
|
} //Just a monster, so kill it.
|
||||||
else
|
else
|
||||||
dest = enemy;
|
dest = enemy;
|
||||||
|
|
|
@ -3145,8 +3145,8 @@ void FParser::SF_MoveCamera(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// set step variables based on distance and speed
|
// set step variables based on distance and speed
|
||||||
mobjangle = R_PointToAngle2(cam->x, cam->y, target->x, target->y);
|
mobjangle = cam->AngleTo(target);
|
||||||
xydist = R_PointToDist2(target->x - cam->x, target->y - cam->y);
|
xydist = cam->Distance2D(target);
|
||||||
|
|
||||||
xstep = FixedMul(finecosine[mobjangle >> ANGLETOFINESHIFT], movespeed);
|
xstep = FixedMul(finecosine[mobjangle >> ANGLETOFINESHIFT], movespeed);
|
||||||
ystep = FixedMul(finesine[mobjangle >> ANGLETOFINESHIFT], movespeed);
|
ystep = FixedMul(finesine[mobjangle >> ANGLETOFINESHIFT], movespeed);
|
||||||
|
|
|
@ -59,10 +59,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch)
|
||||||
if (linetarget)
|
if (linetarget)
|
||||||
{
|
{
|
||||||
S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM);
|
S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM);
|
||||||
self->angle = R_PointToAngle2 (self->x,
|
self->angle = self->AngleTo(linetarget);
|
||||||
self->y,
|
|
||||||
linetarget->x,
|
|
||||||
linetarget->y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,8 +215,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
|
||||||
// turn to face target
|
// turn to face target
|
||||||
if (!(Flags & SF_NOTURN))
|
if (!(Flags & SF_NOTURN))
|
||||||
{
|
{
|
||||||
angle = R_PointToAngle2(self->x, self->y,
|
angle = self->AngleTo(linetarget);
|
||||||
linetarget->x, linetarget->y);
|
|
||||||
if (angle - self->angle > ANG180)
|
if (angle - self->angle > ANG180)
|
||||||
{
|
{
|
||||||
if (angle - self->angle < (angle_t)(-ANG90 / 20))
|
if (angle - self->angle < (angle_t)(-ANG90 / 20))
|
||||||
|
|
|
@ -36,7 +36,7 @@ void A_SkullAttack(AActor *self, fixed_t speed)
|
||||||
an = self->angle >> ANGLETOFINESHIFT;
|
an = self->angle >> ANGLETOFINESHIFT;
|
||||||
self->velx = FixedMul (speed, finecosine[an]);
|
self->velx = FixedMul (speed, finecosine[an]);
|
||||||
self->vely = FixedMul (speed, finesine[an]);
|
self->vely = FixedMul (speed, finesine[an]);
|
||||||
dist = P_AproxDistance (dest->x - self->x, dest->y - self->y);
|
dist = self->AproxDistance (dest);
|
||||||
dist = dist / speed;
|
dist = dist / speed;
|
||||||
|
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
|
|
|
@ -77,7 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// change angle
|
// change angle
|
||||||
exact = R_PointToAngle2 (self->x, self->y, dest->x, dest->y);
|
exact = self->AngleTo(dest);
|
||||||
|
|
||||||
if (exact != self->angle)
|
if (exact != self->angle)
|
||||||
{
|
{
|
||||||
|
@ -102,10 +102,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer)
|
||||||
if (!(self->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)))
|
if (!(self->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)))
|
||||||
{
|
{
|
||||||
// change slope
|
// change slope
|
||||||
dist = P_AproxDistance (dest->x - self->x,
|
dist = self->AproxDistance (dest) / self->Speed;
|
||||||
dest->y - self->y);
|
|
||||||
|
|
||||||
dist = dist / self->Speed;
|
|
||||||
|
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
dist = 1;
|
dist = 1;
|
||||||
|
|
|
@ -276,7 +276,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw)
|
||||||
S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM);
|
S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM);
|
||||||
|
|
||||||
// turn to face target
|
// turn to face target
|
||||||
angle = R_PointToAngle2 (self->x, self->y, linetarget->x, linetarget->y);
|
angle = self->AngleTo(linetarget);
|
||||||
if (angle - self->angle > ANG180)
|
if (angle - self->angle > ANG180)
|
||||||
{
|
{
|
||||||
if (angle - self->angle < (angle_t)(-ANG90/20))
|
if (angle - self->angle < (angle_t)(-ANG90/20))
|
||||||
|
@ -326,7 +326,8 @@ static void MarinePunch(AActor *self, int damagemul)
|
||||||
if (linetarget)
|
if (linetarget)
|
||||||
{
|
{
|
||||||
S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM);
|
S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM);
|
||||||
self->angle = R_PointToAngle2 (self->x, self->y, linetarget->x, linetarget->y);
|
self->angle = self->AngleTo(linetarget);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1479,8 +1479,7 @@ static fixed_t PlayersRangeFromSpot (FPlayerStart *spot)
|
||||||
if (!playeringame[i] || !players[i].mo || players[i].health <= 0)
|
if (!playeringame[i] || !players[i].mo || players[i].health <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
distance = P_AproxDistance (players[i].mo->x - spot->x,
|
distance = players[i].mo->AproxDistance (spot->x, spot->y);
|
||||||
players[i].mo->y - spot->y);
|
|
||||||
|
|
||||||
if (distance < closest)
|
if (distance < closest)
|
||||||
closest = distance;
|
closest = distance;
|
||||||
|
|
|
@ -178,8 +178,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1)
|
||||||
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &linetarget);
|
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &linetarget);
|
||||||
if (linetarget)
|
if (linetarget)
|
||||||
{
|
{
|
||||||
player->mo->angle = R_PointToAngle2 (player->mo->x,
|
player->mo->angle = player->mo->AngleTo(linetarget);
|
||||||
player->mo->y, linetarget->x, linetarget->y);
|
|
||||||
}
|
}
|
||||||
P_PlayPeck (player->mo);
|
P_PlayPeck (player->mo);
|
||||||
player->chickenPeck = 12;
|
player->chickenPeck = 12;
|
||||||
|
@ -211,8 +210,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2)
|
||||||
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &linetarget);
|
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &linetarget);
|
||||||
if (linetarget)
|
if (linetarget)
|
||||||
{
|
{
|
||||||
player->mo->angle = R_PointToAngle2 (player->mo->x,
|
player->mo->angle = player->mo->AngleTo(linetarget);
|
||||||
player->mo->y, linetarget->x, linetarget->y);
|
|
||||||
}
|
}
|
||||||
P_PlayPeck (player->mo);
|
P_PlayPeck (player->mo);
|
||||||
player->chickenPeck = 12;
|
player->chickenPeck = 12;
|
||||||
|
|
|
@ -90,8 +90,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack)
|
||||||
{
|
{
|
||||||
//S_StartSound(player->mo, sfx_stfhit);
|
//S_StartSound(player->mo, sfx_stfhit);
|
||||||
// turn to face target
|
// turn to face target
|
||||||
self->angle = R_PointToAngle2 (self->x,
|
self->angle = self->AngleTo(linetarget);
|
||||||
self->y, linetarget->x, linetarget->y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,8 +306,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
|
||||||
S_Sound (self, CHAN_AUTO, "weapons/gauntletshit", 1, ATTN_NORM);
|
S_Sound (self, CHAN_AUTO, "weapons/gauntletshit", 1, ATTN_NORM);
|
||||||
}
|
}
|
||||||
// turn to face target
|
// turn to face target
|
||||||
angle = R_PointToAngle2 (self->x, self->y,
|
angle = self->AngleTo(linetarget);
|
||||||
linetarget->x, linetarget->y);
|
|
||||||
if (angle-self->angle > ANG180)
|
if (angle-self->angle > ANG180)
|
||||||
{
|
{
|
||||||
if ((int)(angle-self->angle) < -ANG90/20)
|
if ((int)(angle-self->angle) < -ANG90/20)
|
||||||
|
@ -648,8 +646,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Seek
|
{ // Seek
|
||||||
angle = R_PointToAngle2(self->x, self->y,
|
self->angle = self->AngleTo(target);
|
||||||
target->x, target->y);
|
|
||||||
newAngle = true;
|
newAngle = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,8 +659,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact)
|
||||||
if (linetarget && self->target != linetarget)
|
if (linetarget && self->target != linetarget)
|
||||||
{
|
{
|
||||||
self->tracer = linetarget;
|
self->tracer = linetarget;
|
||||||
angle = R_PointToAngle2 (self->x, self->y,
|
angle = self->AngleTo(linetarget);
|
||||||
linetarget->x, linetarget->y);
|
|
||||||
newAngle = true;
|
newAngle = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack)
|
||||||
P_TraceBleed (newdam > 0 ? newdam : damage, target, self);
|
P_TraceBleed (newdam > 0 ? newdam : damage, target, self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dist = P_AproxDistance (self->x-target->x, self->y-target->y)
|
dist = self->AproxDistance (target) > 8*64*FRACUNIT;
|
||||||
> 8*64*FRACUNIT;
|
|
||||||
randAttack = pr_atk ();
|
randAttack = pr_atk ();
|
||||||
if (randAttack < atkResolve1[dist])
|
if (randAttack < atkResolve1[dist])
|
||||||
{ // Ice ball
|
{ // Ice ball
|
||||||
|
|
|
@ -33,13 +33,13 @@ void BlastActor (AActor *victim, fixed_t strength, fixed_t speed, AActor * Owner
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
angle = R_PointToAngle2 (Owner->x, Owner->y, victim->x, victim->y);
|
angle = Owner->AngleTo(victim);
|
||||||
angle >>= ANGLETOFINESHIFT;
|
angle >>= ANGLETOFINESHIFT;
|
||||||
victim->velx = FixedMul (speed, finecosine[angle]);
|
victim->velx = FixedMul (speed, finecosine[angle]);
|
||||||
victim->vely = FixedMul (speed, finesine[angle]);
|
victim->vely = FixedMul (speed, finesine[angle]);
|
||||||
|
|
||||||
// Spawn blast puff
|
// Spawn blast puff
|
||||||
ang = R_PointToAngle2 (victim->x, victim->y, Owner->x, Owner->y);
|
ang = victim->AngleTo(Owner);
|
||||||
ang >>= ANGLETOFINESHIFT;
|
ang >>= ANGLETOFINESHIFT;
|
||||||
x = victim->x + FixedMul (victim->radius+FRACUNIT, finecosine[ang]);
|
x = victim->x + FixedMul (victim->radius+FRACUNIT, finecosine[ang]);
|
||||||
y = victim->y + FixedMul (victim->radius+FRACUNIT, finesine[ang]);
|
y = victim->y + FixedMul (victim->radius+FRACUNIT, finesine[ang]);
|
||||||
|
@ -141,7 +141,7 @@ DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast)
|
||||||
{ // Must be monster, player, missile, touchy or vulnerable
|
{ // Must be monster, player, missile, touchy or vulnerable
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dist = P_AproxDistance (self->x - mo->x, self->y - mo->y);
|
dist = self->AproxDistance (mo);
|
||||||
if (dist > radius)
|
if (dist > radius)
|
||||||
{ // Out of range
|
{ // Out of range
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -262,14 +262,12 @@ static void CHolyTailFollow (AActor *actor, fixed_t dist)
|
||||||
child = actor->tracer;
|
child = actor->tracer;
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
an = R_PointToAngle2(actor->x, actor->y, child->x,
|
an = actor->AngleTo(child) >> ANGLETOFINESHIFT;
|
||||||
child->y)>>ANGLETOFINESHIFT;
|
oldDistance = child->AproxDistance (actor);
|
||||||
oldDistance = P_AproxDistance (child->x-actor->x, child->y-actor->y);
|
|
||||||
if (P_TryMove (child, actor->x+FixedMul(dist, finecosine[an]),
|
if (P_TryMove (child, actor->x+FixedMul(dist, finecosine[an]),
|
||||||
actor->y+FixedMul(dist, finesine[an]), true))
|
actor->y+FixedMul(dist, finesine[an]), true))
|
||||||
{
|
{
|
||||||
newDistance = P_AproxDistance (child->x-actor->x,
|
newDistance = child->AproxDistance (actor)-FRACUNIT;
|
||||||
child->y-actor->y)-FRACUNIT;
|
|
||||||
if (oldDistance < FRACUNIT)
|
if (oldDistance < FRACUNIT)
|
||||||
{
|
{
|
||||||
if (child->z < actor->z)
|
if (child->z < actor->z)
|
||||||
|
@ -425,7 +423,7 @@ static void CHolySeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax)
|
||||||
deltaZ = -15*FRACUNIT;
|
deltaZ = -15*FRACUNIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dist = P_AproxDistance (target->x-actor->x, target->y-actor->y);
|
dist = actor->AproxDistance (target);
|
||||||
dist = dist / actor->Speed;
|
dist = dist / actor->Speed;
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
|
||||||
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"), false, &linetarget);
|
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"), false, &linetarget);
|
||||||
if (linetarget != NULL)
|
if (linetarget != NULL)
|
||||||
{
|
{
|
||||||
pmo->angle = R_PointToAngle2 (pmo->x, pmo->y, linetarget->x, linetarget->y);
|
pmo->angle = pmo->AngleTo(linetarget);
|
||||||
if (((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0))|| linetarget->flags3&MF3_ISMONSTER)
|
if (((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0))|| linetarget->flags3&MF3_ISMONSTER)
|
||||||
&& (!(linetarget->flags2&(MF2_DORMANT|MF2_INVULNERABLE))))
|
&& (!(linetarget->flags2&(MF2_DORMANT|MF2_INVULNERABLE))))
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
|
||||||
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"), false, &linetarget);
|
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"), false, &linetarget);
|
||||||
if (linetarget != NULL)
|
if (linetarget != NULL)
|
||||||
{
|
{
|
||||||
pmo->angle = R_PointToAngle2 (pmo->x, pmo->y, linetarget->x, linetarget->y);
|
pmo->angle = pmo->AngleTo(linetarget);
|
||||||
if ((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0)) || linetarget->flags3&MF3_ISMONSTER)
|
if ((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0)) || linetarget->flags3&MF3_ISMONSTER)
|
||||||
{
|
{
|
||||||
newLife = player->health+(damage>>4);
|
newLife = player->health+(damage>>4);
|
||||||
|
|
|
@ -59,28 +59,21 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax)
|
||||||
angle = actor->angle>>ANGLETOFINESHIFT;
|
angle = actor->angle>>ANGLETOFINESHIFT;
|
||||||
actor->velx = FixedMul (actor->Speed, finecosine[angle]);
|
actor->velx = FixedMul (actor->Speed, finecosine[angle]);
|
||||||
actor->vely = FixedMul (actor->Speed, finesine[angle]);
|
actor->vely = FixedMul (actor->Speed, finesine[angle]);
|
||||||
|
dist = actor->AproxDistance (target) / actor->Speed;
|
||||||
if (actor->z+actor->height < target->z ||
|
if (actor->z+actor->height < target->z ||
|
||||||
target->z+target->height < actor->z)
|
target->z+target->height < actor->z)
|
||||||
{
|
{
|
||||||
dist = P_AproxDistance(target->x-actor->x, target->y-actor->y);
|
|
||||||
dist = dist/actor->Speed;
|
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
{
|
{
|
||||||
dist = 1;
|
dist = 1;
|
||||||
}
|
}
|
||||||
actor->velz = (target->z - actor->z)/dist;
|
actor->velz = (target->z - actor->z)/dist;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
dist = P_AproxDistance (target->x-actor->x, target->y-actor->y);
|
|
||||||
dist = dist/actor->Speed;
|
|
||||||
}
|
|
||||||
if (target->flags&MF_SHOOTABLE && pr_dragonseek() < 64)
|
if (target->flags&MF_SHOOTABLE && pr_dragonseek() < 64)
|
||||||
{ // attack the destination mobj if it's attackable
|
{ // attack the destination mobj if it's attackable
|
||||||
AActor *oldTarget;
|
AActor *oldTarget;
|
||||||
|
|
||||||
if (absangle(actor->angle-R_PointToAngle2(actor->x, actor->y,
|
if (absangle(actor->angle - actor->AngleTo(target)) < ANGLE_45/2)
|
||||||
target->x, target->y)) < ANGLE_45/2)
|
|
||||||
{
|
{
|
||||||
oldTarget = actor->target;
|
oldTarget = actor->target;
|
||||||
actor->target = target;
|
actor->target = target;
|
||||||
|
@ -105,8 +98,7 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax)
|
||||||
{
|
{
|
||||||
AActor *bestActor = NULL;
|
AActor *bestActor = NULL;
|
||||||
bestAngle = ANGLE_MAX;
|
bestAngle = ANGLE_MAX;
|
||||||
angleToTarget = R_PointToAngle2(actor->x, actor->y,
|
angleToTarget = actor->AngleTo(actor->target);
|
||||||
actor->target->x, actor->target->y);
|
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
if (!target->args[i])
|
if (!target->args[i])
|
||||||
|
@ -119,8 +111,7 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
angleToSpot = R_PointToAngle2(actor->x, actor->y,
|
angleToSpot = actor->AngleTo(mo);
|
||||||
mo->x, mo->y);
|
|
||||||
if (absangle(angleToSpot-angleToTarget) < bestAngle)
|
if (absangle(angleToSpot-angleToTarget) < bestAngle)
|
||||||
{
|
{
|
||||||
bestAngle = absangle(angleToSpot-angleToTarget);
|
bestAngle = absangle(angleToSpot-angleToTarget);
|
||||||
|
@ -196,8 +187,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight)
|
||||||
self->target = NULL;
|
self->target = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
angle = R_PointToAngle2(self->x, self->y, self->target->x,
|
angle = self->AngleTo(self->target);
|
||||||
self->target->y);
|
|
||||||
if (absangle(self->angle-angle) < ANGLE_45/2 && self->CheckMeleeRange())
|
if (absangle(self->angle-angle) < ANGLE_45/2 && self->CheckMeleeRange())
|
||||||
{
|
{
|
||||||
int damage = pr_dragonflight.HitDice (8);
|
int damage = pr_dragonflight.HitDice (8);
|
||||||
|
|
|
@ -30,7 +30,7 @@ void AdjustPlayerAngle (AActor *pmo, AActor *linetarget)
|
||||||
angle_t angle;
|
angle_t angle;
|
||||||
int difference;
|
int difference;
|
||||||
|
|
||||||
angle = R_PointToAngle2 (pmo->x, pmo->y, linetarget->x, linetarget->y);
|
angle = pmo->AngleTo(linetarget);
|
||||||
difference = (int)angle - (int)pmo->angle;
|
difference = (int)angle - (int)pmo->angle;
|
||||||
if (abs(difference) > MAX_ANGLE_ADJUST)
|
if (abs(difference) > MAX_ANGLE_ADJUST)
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,12 +158,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase)
|
||||||
{
|
{
|
||||||
self->special2 = 0;
|
self->special2 = 0;
|
||||||
self->velx = self->vely = 0;
|
self->velx = self->vely = 0;
|
||||||
dist = P_AproxDistance (self->x - target->x, self->y - target->y);
|
dist = self->AproxDistance (target);
|
||||||
if (dist < FIREDEMON_ATTACK_RANGE)
|
if (dist < FIREDEMON_ATTACK_RANGE)
|
||||||
{
|
{
|
||||||
if (pr_firedemonchase() < 30)
|
if (pr_firedemonchase() < 30)
|
||||||
{
|
{
|
||||||
ang = R_PointToAngle2 (self->x, self->y, target->x, target->y);
|
ang = self->AngleTo(target);
|
||||||
if (pr_firedemonchase() < 128)
|
if (pr_firedemonchase() < 128)
|
||||||
ang += ANGLE_90;
|
ang += ANGLE_90;
|
||||||
else
|
else
|
||||||
|
|
|
@ -79,7 +79,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlyBuzz)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
angle_t ang = R_PointToAngle2(self->x, self->y, targ->x, targ->y);
|
angle_t ang = self->AngleTo(targ);
|
||||||
self->angle = ang;
|
self->angle = ang;
|
||||||
self->args[0]++;
|
self->args[0]++;
|
||||||
ang >>= ANGLETOFINESHIFT;
|
ang >>= ANGLETOFINESHIFT;
|
||||||
|
|
|
@ -37,7 +37,7 @@ bool AArtiHealingRadius::Use (bool pickup)
|
||||||
if (playeringame[i] &&
|
if (playeringame[i] &&
|
||||||
players[i].mo != NULL &&
|
players[i].mo != NULL &&
|
||||||
players[i].mo->health > 0 &&
|
players[i].mo->health > 0 &&
|
||||||
P_AproxDistance (players[i].mo->x - Owner->x, players[i].mo->y - Owner->y) <= HEAL_RADIUS_DIST)
|
players[i].mo->AproxDistance (Owner) <= HEAL_RADIUS_DIST)
|
||||||
{
|
{
|
||||||
// Q: Is it worth it to make this selectable as a player property?
|
// Q: Is it worth it to make this selectable as a player property?
|
||||||
// A: Probably not - but it sure doesn't hurt.
|
// A: Probably not - but it sure doesn't hurt.
|
||||||
|
|
|
@ -665,8 +665,7 @@ void A_SorcOffense2(AActor *actor)
|
||||||
if (mo)
|
if (mo)
|
||||||
{
|
{
|
||||||
mo->special2 = 35*5/2; // 5 seconds
|
mo->special2 = 35*5/2; // 5 seconds
|
||||||
dist = P_AproxDistance(dest->x - mo->x, dest->y - mo->y);
|
dist = mo->AproxDistance(dest) / mo->Speed;
|
||||||
dist = dist/mo->Speed;
|
|
||||||
if(dist < 1) dist = 1;
|
if(dist < 1) dist = 1;
|
||||||
mo->velz = (dest->z - mo->z) / dist;
|
mo->velz = (dest->z - mo->z) / dist;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryCheck)
|
||||||
if (playeringame[i])
|
if (playeringame[i])
|
||||||
{
|
{
|
||||||
AActor *pmo = players[i].mo;
|
AActor *pmo = players[i].mo;
|
||||||
if (P_CheckSight (self, pmo) && (absangle(R_PointToAngle2 (pmo->x,
|
if (P_CheckSight (self, pmo) && (absangle(pmo->AngleTo(self) - pmo->angle) <= ANGLE_45))
|
||||||
pmo->y, self->x, self->y) - pmo->angle) <= ANGLE_45))
|
|
||||||
{ // Previous state (pottery bit waiting state)
|
{ // Previous state (pottery bit waiting state)
|
||||||
self->SetState (self->state - 1);
|
self->SetState (self->state - 1);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -388,8 +388,7 @@ void A_KSpiritSeeker (AActor *actor, angle_t thresh, angle_t turnMax)
|
||||||
deltaZ = -15*FRACUNIT;
|
deltaZ = -15*FRACUNIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dist = P_AproxDistance (target->x-actor->x, target->y-actor->y);
|
dist = actor->AproxDistance (target) / actor->Speed;
|
||||||
dist = dist/actor->Speed;
|
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
{
|
{
|
||||||
dist = 1;
|
dist = 1;
|
||||||
|
@ -486,7 +485,7 @@ AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z,
|
||||||
z -= source->floorclip;
|
z -= source->floorclip;
|
||||||
th = Spawn (type, x, y, z, ALLOW_REPLACE);
|
th = Spawn (type, x, y, z, ALLOW_REPLACE);
|
||||||
th->target = source; // Originator
|
th->target = source; // Originator
|
||||||
an = R_PointToAngle2(x, y, dest->x, dest->y);
|
an = source->AngleXYTo(x, y, dest);
|
||||||
if (dest->flags & MF_SHADOW)
|
if (dest->flags & MF_SHADOW)
|
||||||
{ // Invisible target
|
{ // Invisible target
|
||||||
an += pr_kmissile.Random2()<<21;
|
an += pr_kmissile.Random2()<<21;
|
||||||
|
@ -495,8 +494,7 @@ AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z,
|
||||||
an >>= ANGLETOFINESHIFT;
|
an >>= ANGLETOFINESHIFT;
|
||||||
th->velx = FixedMul (th->Speed, finecosine[an]);
|
th->velx = FixedMul (th->Speed, finecosine[an]);
|
||||||
th->vely = FixedMul (th->Speed, finesine[an]);
|
th->vely = FixedMul (th->Speed, finesine[an]);
|
||||||
dist = P_AproxDistance (dest->x - x, dest->y - y);
|
dist = dest->AproxDistance (x, y, source) / th->Speed;
|
||||||
dist = dist/th->Speed;
|
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
{
|
{
|
||||||
dist = 1;
|
dist = 1;
|
||||||
|
|
|
@ -190,7 +190,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self->angle = R_PointToAngle2(self->x, self->y, target->x, target->y);
|
self->angle = self->AngleTo(target);
|
||||||
self->velx = 0;
|
self->velx = 0;
|
||||||
self->vely = 0;
|
self->vely = 0;
|
||||||
P_ThrustMobj (self, self->angle, self->Speed>>1);
|
P_ThrustMobj (self, self->angle, self->Speed>>1);
|
||||||
|
|
|
@ -185,7 +185,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide)
|
||||||
{
|
{
|
||||||
S_Sound (self, CHAN_WEAPON, "minotaur/sight", 1, ATTN_NORM);
|
S_Sound (self, CHAN_WEAPON, "minotaur/sight", 1, ATTN_NORM);
|
||||||
}
|
}
|
||||||
dist = P_AproxDistance (self->x-target->x, self->y-target->y);
|
dist = self->AproxDistance (target);
|
||||||
if (target->z+target->height > self->z
|
if (target->z+target->height > self->z
|
||||||
&& target->z+target->height < self->z+self->height
|
&& target->z+target->height < self->z+self->height
|
||||||
&& dist < (friendly ? 16*64*FRACUNIT : 8*64*FRACUNIT)
|
&& dist < (friendly ? 16*64*FRACUNIT : 8*64*FRACUNIT)
|
||||||
|
@ -390,7 +390,7 @@ void P_MinotaurSlam (AActor *source, AActor *target)
|
||||||
fixed_t thrust;
|
fixed_t thrust;
|
||||||
int damage;
|
int damage;
|
||||||
|
|
||||||
angle = R_PointToAngle2 (source->x, source->y, target->x, target->y);
|
angle = source->AngleTo(target);
|
||||||
angle >>= ANGLETOFINESHIFT;
|
angle >>= ANGLETOFINESHIFT;
|
||||||
thrust = 16*FRACUNIT+(pr_minotaurslam()<<10);
|
thrust = 16*FRACUNIT+(pr_minotaurslam()<<10);
|
||||||
target->velx += FixedMul (thrust, finecosine[angle]);
|
target->velx += FixedMul (thrust, finecosine[angle]);
|
||||||
|
@ -489,7 +489,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurLook)
|
||||||
mo = player->mo;
|
mo = player->mo;
|
||||||
if (mo == master) continue;
|
if (mo == master) continue;
|
||||||
if (mo->health <= 0) continue;
|
if (mo->health <= 0) continue;
|
||||||
dist = P_AproxDistance(self->x - mo->x, self->y - mo->y);
|
dist = self->AproxDistance(mo);
|
||||||
if (dist > MINOTAUR_LOOK_DIST) continue;
|
if (dist > MINOTAUR_LOOK_DIST) continue;
|
||||||
self->target = mo;
|
self->target = mo;
|
||||||
break;
|
break;
|
||||||
|
@ -514,7 +514,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurLook)
|
||||||
if (!(mo->flags3 & MF3_ISMONSTER)) continue;
|
if (!(mo->flags3 & MF3_ISMONSTER)) continue;
|
||||||
if (mo->health <= 0) continue;
|
if (mo->health <= 0) continue;
|
||||||
if (!(mo->flags & MF_SHOOTABLE)) continue;
|
if (!(mo->flags & MF_SHOOTABLE)) continue;
|
||||||
dist = P_AproxDistance (self->x - mo->x, self->y - mo->y);
|
dist = self->AproxDistance(mo);
|
||||||
if (dist > MINOTAUR_LOOK_DIST) continue;
|
if (dist > MINOTAUR_LOOK_DIST) continue;
|
||||||
if ((mo == master) || (mo == self)) continue;
|
if ((mo == master) || (mo == self)) continue;
|
||||||
if ((mo->flags5 & MF5_SUMMONEDMONSTER) && (mo->tracer == master)) continue;
|
if ((mo->flags5 & MF5_SUMMONEDMONSTER) && (mo->tracer == master)) continue;
|
||||||
|
|
|
@ -129,7 +129,7 @@ void DEarthquake::Tick ()
|
||||||
AActor *victim = players[i].mo;
|
AActor *victim = players[i].mo;
|
||||||
fixed_t dist;
|
fixed_t dist;
|
||||||
|
|
||||||
dist = P_AproxDistance (victim->x - m_Spot->x, victim->y - m_Spot->y);
|
dist = m_Spot->AproxDistance (victim, true);
|
||||||
// Check if in damage radius
|
// Check if in damage radius
|
||||||
if (dist < m_DamageRadius && victim->z <= victim->floorz)
|
if (dist < m_DamageRadius && victim->z <= victim->floorz)
|
||||||
{
|
{
|
||||||
|
@ -242,8 +242,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
|
||||||
{
|
{
|
||||||
if (quake->m_Spot != NULL)
|
if (quake->m_Spot != NULL)
|
||||||
{
|
{
|
||||||
fixed_t dist = P_AproxDistance (victim->x - quake->m_Spot->x,
|
fixed_t dist = quake->m_Spot->AproxDistance (victim, true);
|
||||||
victim->y - quake->m_Spot->y);
|
|
||||||
if (dist < quake->m_TremorRadius)
|
if (dist < quake->m_TremorRadius)
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "p_local.h"
|
#include "p_local.h"
|
||||||
#include "p_lnspec.h"
|
#include "p_lnspec.h"
|
||||||
#include "farchive.h"
|
#include "farchive.h"
|
||||||
|
#include "r_sky.h"
|
||||||
|
|
||||||
// arg0 = Visibility*4 for this skybox
|
// arg0 = Visibility*4 for this skybox
|
||||||
|
|
||||||
|
@ -87,6 +88,24 @@ void ASkyViewpoint::Destroy ()
|
||||||
class ASkyCamCompat : public ASkyViewpoint
|
class ASkyCamCompat : public ASkyViewpoint
|
||||||
{
|
{
|
||||||
DECLARE_CLASS (ASkyCamCompat, ASkyViewpoint)
|
DECLARE_CLASS (ASkyCamCompat, ASkyViewpoint)
|
||||||
|
|
||||||
|
// skyboxify all tagged sectors
|
||||||
|
// This involves changing their texture to the sky flat, because while
|
||||||
|
// EE works with any texture for its skybox portals, ZDoom doesn't.
|
||||||
|
void SkyboxifySector(sector_t *sector, int plane)
|
||||||
|
{
|
||||||
|
// plane: 0=floor, 1=ceiling, 2=both
|
||||||
|
if (plane == 1 || plane == 2)
|
||||||
|
{
|
||||||
|
sector->CeilingSkyBox = this;
|
||||||
|
sector->SetTexture(sector_t::ceiling, skyflatnum, false);
|
||||||
|
}
|
||||||
|
if (plane == 0 || plane == 2)
|
||||||
|
{
|
||||||
|
sector->FloorSkyBox = this;
|
||||||
|
sector->SetTexture(sector_t::floor, skyflatnum, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
void BeginPlay ();
|
void BeginPlay ();
|
||||||
};
|
};
|
||||||
|
@ -116,23 +135,35 @@ void ASkyCamCompat::BeginPlay ()
|
||||||
// Then, change the alpha
|
// Then, change the alpha
|
||||||
alpha = refline->args[4];
|
alpha = refline->args[4];
|
||||||
|
|
||||||
// Finally, skyboxify all tagged sectors
|
|
||||||
// This involves changing their texture to the sky flat, because while
|
|
||||||
// EE works with any texture for its skybox portals, ZDoom doesn't.
|
|
||||||
FSectorTagIterator it(skybox_id);
|
FSectorTagIterator it(skybox_id);
|
||||||
int secnum;
|
int secnum;
|
||||||
while ((secnum = it.Next()) >= 0)
|
while ((secnum = it.Next()) >= 0)
|
||||||
{
|
{
|
||||||
// plane: 0=floor, 1=ceiling, 2=both
|
SkyboxifySector(§ors[secnum], refline->args[2]);
|
||||||
if (refline->args[2] == 1 || refline->args[2] == 2)
|
}
|
||||||
|
// and finally, check for portal copy linedefs
|
||||||
|
for (int j=0;j<numlines;j++)
|
||||||
|
{
|
||||||
|
// Check if this portal needs to be copied to other sectors
|
||||||
|
// This must be done here to ensure that it gets done only after the portal is set up
|
||||||
|
if (lines[j].special == Sector_SetPortal &&
|
||||||
|
lines[j].args[1] == 1 &&
|
||||||
|
(lines[j].args[2] == refline->args[2] || lines[j].args[2] == 3) &&
|
||||||
|
lines[j].args[3] == skybox_id)
|
||||||
{
|
{
|
||||||
sectors[secnum].CeilingSkyBox = this;
|
if (lines[j].args[0] == 0)
|
||||||
sectors[secnum].SetTexture(sector_t::ceiling, skyflatnum, false);
|
{
|
||||||
}
|
SkyboxifySector(lines[j].frontsector, refline->args[2]);
|
||||||
if (refline->args[2] == 0 || refline->args[2] == 2)
|
}
|
||||||
{
|
else
|
||||||
sectors[secnum].FloorSkyBox = this;
|
{
|
||||||
sectors[secnum].SetTexture(sector_t::floor, skyflatnum, false);
|
FSectorTagIterator itr(lines[j].args[0]);
|
||||||
|
int s;
|
||||||
|
while ((s = itr.Next()) >= 0)
|
||||||
|
{
|
||||||
|
SkyboxifySector(§ors[s], refline->args[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ struct FSpotList
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
distance = P_AproxDistance(Spots[i]->x - x, Spots[i]->y - y);
|
distance = Spots[i]->AproxDistance(x, y);
|
||||||
|
|
||||||
if ((distance >= mindist) && ((maxdist == 0) || (distance <= maxdist))) break;
|
if ((distance >= mindist) && ((maxdist == 0) || (distance <= maxdist))) break;
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags)
|
||||||
if (player->mo != NULL)
|
if (player->mo != NULL)
|
||||||
{
|
{
|
||||||
// The next 12 lines are from the Doom statusbar code.
|
// The next 12 lines are from the Doom statusbar code.
|
||||||
badguyangle = R_PointToAngle2(player->mo->x, player->mo->y, player->attacker->x, player->attacker->y);
|
badguyangle = player->mo->AngleTo(player->attacker);
|
||||||
if (badguyangle > player->mo->angle)
|
if (badguyangle > player->mo->angle)
|
||||||
{
|
{
|
||||||
// whether right or left
|
// whether right or left
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
static bool CrusaderCheckRange (AActor *self)
|
static bool CrusaderCheckRange (AActor *self)
|
||||||
{
|
{
|
||||||
if (P_CheckSight (self, self->target) && self->reactiontime == 0)
|
if (self->reactiontime == 0 && P_CheckSight (self, self->target))
|
||||||
{
|
{
|
||||||
return P_AproxDistance (self->x - self->target->x, self->y - self->target->y) < 264*FRACUNIT;
|
return self->AproxDistance (self->target) < 264*FRACUNIT;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ bool InquisitorCheckDistance (AActor *self)
|
||||||
{
|
{
|
||||||
if (self->reactiontime == 0 && P_CheckSight (self, self->target))
|
if (self->reactiontime == 0 && P_CheckSight (self, self->target))
|
||||||
{
|
{
|
||||||
return P_AproxDistance (self->x - self->target->x, self->y - self->target->y) < 264*FRACUNIT;
|
return self->AproxDistance (self->target) < 264*FRACUNIT;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump)
|
||||||
speed = self->Speed * 2/3;
|
speed = self->Speed * 2/3;
|
||||||
self->velx += FixedMul (speed, finecosine[an]);
|
self->velx += FixedMul (speed, finecosine[an]);
|
||||||
self->vely += FixedMul (speed, finesine[an]);
|
self->vely += FixedMul (speed, finesine[an]);
|
||||||
dist = P_AproxDistance (self->target->x - self->x, self->target->y - self->y);
|
dist = self->AproxDistance (self->target);
|
||||||
dist /= speed;
|
dist /= speed;
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,10 +118,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger)
|
||||||
S_Sound (self, CHAN_WEAPON,
|
S_Sound (self, CHAN_WEAPON,
|
||||||
linetarget->flags & MF_NOBLOOD ? "misc/metalhit" : "misc/meathit",
|
linetarget->flags & MF_NOBLOOD ? "misc/metalhit" : "misc/meathit",
|
||||||
1, ATTN_NORM);
|
1, ATTN_NORM);
|
||||||
self->angle = R_PointToAngle2 (self->x,
|
self->angle = self->AngleTo(linetarget);
|
||||||
self->y,
|
|
||||||
linetarget->x,
|
|
||||||
linetarget->y);
|
|
||||||
self->flags |= MF_JUSTATTACKED;
|
self->flags |= MF_JUSTATTACKED;
|
||||||
P_DaggerAlert (self, linetarget);
|
P_DaggerAlert (self, linetarget);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1117,7 +1117,7 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang
|
||||||
if (facetalker)
|
if (facetalker)
|
||||||
{
|
{
|
||||||
A_FaceTarget (npc);
|
A_FaceTarget (npc);
|
||||||
pc->angle = R_PointToAngle2 (pc->x, pc->y, npc->x, npc->y);
|
pc->angle = pc->AngleTo(npc);
|
||||||
}
|
}
|
||||||
if ((npc->flags & MF_FRIENDLY) || (npc->flags4 & MF4_NOHATEPLAYERS))
|
if ((npc->flags & MF_FRIENDLY) || (npc->flags4 & MF4_NOHATEPLAYERS))
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,7 +138,7 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun
|
||||||
for (actor = sec->thinglist; actor != NULL; actor = actor->snext)
|
for (actor = sec->thinglist; actor != NULL; actor = actor->snext)
|
||||||
{
|
{
|
||||||
if (actor != soundtarget && (!splash || !(actor->flags4 & MF4_NOSPLASHALERT)) &&
|
if (actor != soundtarget && (!splash || !(actor->flags4 & MF4_NOSPLASHALERT)) &&
|
||||||
(!maxdist || (P_AproxDistance(actor->x - emitter->x, actor->y - emitter->y) <= maxdist)))
|
(!maxdist || (actor->AproxDistance(emitter) <= maxdist)))
|
||||||
{
|
{
|
||||||
actor->LastHeard = soundtarget;
|
actor->LastHeard = soundtarget;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ bool AActor::CheckMeleeRange ()
|
||||||
if (!pl)
|
if (!pl)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dist = P_AproxDistance (pl->x - x, pl->y - y);
|
dist = AproxDistance (pl);
|
||||||
|
|
||||||
if (dist >= meleerange + pl->radius)
|
if (dist >= meleerange + pl->radius)
|
||||||
return false;
|
return false;
|
||||||
|
@ -275,7 +275,7 @@ bool P_CheckMeleeRange2 (AActor *actor)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mo = actor->target;
|
mo = actor->target;
|
||||||
dist = P_AproxDistance (mo->x-actor->x, mo->y-actor->y);
|
dist = mo->AproxDistance (actor);
|
||||||
if (dist >= MELEERANGE*2 || dist < MELEERANGE-20*FRACUNIT + mo->radius)
|
if (dist >= MELEERANGE*2 || dist < MELEERANGE-20*FRACUNIT + mo->radius)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -348,8 +348,7 @@ bool P_CheckMissileRange (AActor *actor)
|
||||||
|
|
||||||
// OPTIMIZE: get this from a global checksight
|
// OPTIMIZE: get this from a global checksight
|
||||||
// [RH] What?
|
// [RH] What?
|
||||||
dist = P_AproxDistance (actor->x-actor->target->x,
|
dist = actor->AproxDistance (actor->target) - 64*FRACUNIT;
|
||||||
actor->y-actor->target->y) - 64*FRACUNIT;
|
|
||||||
|
|
||||||
if (actor->MeleeState == NULL)
|
if (actor->MeleeState == NULL)
|
||||||
dist -= 128*FRACUNIT; // no melee attack, so fire more
|
dist -= 128*FRACUNIT; // no melee attack, so fire more
|
||||||
|
@ -393,8 +392,8 @@ bool P_HitFriend(AActor * self)
|
||||||
|
|
||||||
if (self->flags&MF_FRIENDLY && self->target != NULL)
|
if (self->flags&MF_FRIENDLY && self->target != NULL)
|
||||||
{
|
{
|
||||||
angle_t angle = R_PointToAngle2 (self->x, self->y, self->target->x, self->target->y);
|
angle_t angle = self->AngleTo(self->target);
|
||||||
fixed_t dist = P_AproxDistance (self->x - self->target->x, self->y - self->target->y);
|
fixed_t dist = self->AproxDistance (self->target);
|
||||||
P_AimLineAttack (self, angle, dist, &linetarget, 0, true);
|
P_AimLineAttack (self, angle, dist, &linetarget, 0, true);
|
||||||
if (linetarget != NULL && linetarget != self->target)
|
if (linetarget != NULL && linetarget != self->target)
|
||||||
{
|
{
|
||||||
|
@ -450,7 +449,7 @@ bool P_Move (AActor *actor)
|
||||||
|
|
||||||
if ((actor->flags6 & MF6_JUMPDOWN) && target &&
|
if ((actor->flags6 & MF6_JUMPDOWN) && target &&
|
||||||
!(target->IsFriend(actor)) &&
|
!(target->IsFriend(actor)) &&
|
||||||
P_AproxDistance(actor->x - target->x, actor->y - target->y) < FRACUNIT*144 &&
|
actor->AproxDistance(target) < FRACUNIT*144 &&
|
||||||
pr_dropoff() < 235)
|
pr_dropoff() < 235)
|
||||||
{
|
{
|
||||||
dropoff = 2;
|
dropoff = 2;
|
||||||
|
@ -933,7 +932,7 @@ void P_NewChaseDir(AActor * actor)
|
||||||
if (actor->flags3 & MF3_AVOIDMELEE)
|
if (actor->flags3 & MF3_AVOIDMELEE)
|
||||||
{
|
{
|
||||||
bool ismeleeattacker = false;
|
bool ismeleeattacker = false;
|
||||||
fixed_t dist = P_AproxDistance(actor->x-target->x, actor->y-target->y);
|
fixed_t dist = actor->AproxDistance(target);
|
||||||
if (target->player == NULL)
|
if (target->player == NULL)
|
||||||
{
|
{
|
||||||
ismeleeattacker = (target->MissileState == NULL && dist < (target->meleerange + target->radius)*2);
|
ismeleeattacker = (target->MissileState == NULL && dist < (target->meleerange + target->radius)*2);
|
||||||
|
@ -1151,7 +1150,7 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams
|
||||||
fov = allaround ? 0 : ANGLE_180;
|
fov = allaround ? 0 : ANGLE_180;
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_t dist = P_AproxDistance (other->x - lookee->x, other->y - lookee->y);
|
fixed_t dist = lookee->AproxDistance (other);
|
||||||
|
|
||||||
if (maxdist && dist > maxdist)
|
if (maxdist && dist > maxdist)
|
||||||
return false; // [KS] too far
|
return false; // [KS] too far
|
||||||
|
@ -1161,7 +1160,7 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams
|
||||||
|
|
||||||
if (fov && fov < ANGLE_MAX)
|
if (fov && fov < ANGLE_MAX)
|
||||||
{
|
{
|
||||||
angle_t an = R_PointToAngle2 (lookee->x, lookee->y, other->x, other->y) - lookee->angle;
|
angle_t an = lookee->AngleTo(other) - lookee->angle;
|
||||||
|
|
||||||
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
||||||
{
|
{
|
||||||
|
@ -1202,8 +1201,7 @@ bool P_LookForMonsters (AActor *actor)
|
||||||
{ // Not a valid monster
|
{ // Not a valid monster
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (P_AproxDistance (actor->x-mo->x, actor->y-mo->y)
|
if (mo->AproxDistance (actor) > MONS_LOOK_RANGE)
|
||||||
> MONS_LOOK_RANGE)
|
|
||||||
{ // Out of range
|
{ // Out of range
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1703,10 +1701,8 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
|
||||||
if ((player->mo->flags & MF_SHADOW && !(i_compatflags & COMPATF_INVISIBILITY)) ||
|
if ((player->mo->flags & MF_SHADOW && !(i_compatflags & COMPATF_INVISIBILITY)) ||
|
||||||
player->mo->flags3 & MF3_GHOST)
|
player->mo->flags3 & MF3_GHOST)
|
||||||
{
|
{
|
||||||
if ((P_AproxDistance (player->mo->x - actor->x,
|
if ((player->mo->AproxDistance (actor) > 2*MELEERANGE)
|
||||||
player->mo->y - actor->y) > 2*MELEERANGE)
|
&& P_AproxDistance (player->mo->velx, player->mo->vely) < 5*FRACUNIT)
|
||||||
&& P_AproxDistance (player->mo->velx, player->mo->vely)
|
|
||||||
< 5*FRACUNIT)
|
|
||||||
{ // Player is sneaking - can't detect
|
{ // Player is sneaking - can't detect
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1903,8 +1899,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dist = P_AproxDistance (targ->x - self->x,
|
dist = self->AproxDistance (targ);
|
||||||
targ->y - self->y);
|
|
||||||
|
|
||||||
// [KS] If the target is too far away, don't respond to the sound.
|
// [KS] If the target is too far away, don't respond to the sound.
|
||||||
if (maxheardist && dist > maxheardist)
|
if (maxheardist && dist > maxheardist)
|
||||||
|
@ -1975,8 +1970,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
|
||||||
{
|
{
|
||||||
if (self->flags & MF_AMBUSH)
|
if (self->flags & MF_AMBUSH)
|
||||||
{
|
{
|
||||||
dist = P_AproxDistance (self->target->x - self->x,
|
dist = self->AproxDistance (self->target);
|
||||||
self->target->y - self->y);
|
|
||||||
if (P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING) &&
|
if (P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING) &&
|
||||||
(!minseedist || dist > minseedist) &&
|
(!minseedist || dist > minseedist) &&
|
||||||
(!maxseedist || dist < maxseedist))
|
(!maxseedist || dist < maxseedist))
|
||||||
|
@ -2390,12 +2384,12 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
|
||||||
actor->FastChaseStrafeCount = 0;
|
actor->FastChaseStrafeCount = 0;
|
||||||
actor->velx = 0;
|
actor->velx = 0;
|
||||||
actor->vely = 0;
|
actor->vely = 0;
|
||||||
fixed_t dist = P_AproxDistance (actor->x - actor->target->x, actor->y - actor->target->y);
|
fixed_t dist = actor->AproxDistance (actor->target);
|
||||||
if (dist < CLASS_BOSS_STRAFE_RANGE)
|
if (dist < CLASS_BOSS_STRAFE_RANGE)
|
||||||
{
|
{
|
||||||
if (pr_chase() < 100)
|
if (pr_chase() < 100)
|
||||||
{
|
{
|
||||||
angle_t ang = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y);
|
angle_t ang = actor->AngleTo(actor->target);
|
||||||
if (pr_chase() < 128) ang += ANGLE_90;
|
if (pr_chase() < 128) ang += ANGLE_90;
|
||||||
else ang -= ANGLE_90;
|
else ang -= ANGLE_90;
|
||||||
actor->velx = 13 * finecosine[ang>>ANGLETOFINESHIFT];
|
actor->velx = 13 * finecosine[ang>>ANGLETOFINESHIFT];
|
||||||
|
@ -2749,7 +2743,7 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a
|
||||||
|
|
||||||
self->flags &= ~MF_AMBUSH;
|
self->flags &= ~MF_AMBUSH;
|
||||||
|
|
||||||
angle_t other_angle = R_PointToAngle2 (self->x, self->y, other->x, other->y);
|
angle_t other_angle = self->AngleTo(other);
|
||||||
|
|
||||||
// 0 means no limit. Also, if we turn in a single step anyways, no need to go through the algorithms.
|
// 0 means no limit. Also, if we turn in a single step anyways, no need to go through the algorithms.
|
||||||
// It also means that there is no need to check for going past the other.
|
// It also means that there is no need to check for going past the other.
|
||||||
|
@ -2922,10 +2916,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail)
|
||||||
|
|
||||||
self->flags &= ~MF_AMBUSH;
|
self->flags &= ~MF_AMBUSH;
|
||||||
|
|
||||||
self->angle = R_PointToAngle2 (self->x,
|
self->angle = self->AngleTo(self->target);
|
||||||
self->y,
|
|
||||||
self->target->x,
|
|
||||||
self->target->y);
|
|
||||||
|
|
||||||
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, 0, self->target);
|
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, 0, self->target);
|
||||||
if (linetarget == NULL)
|
if (linetarget == NULL)
|
||||||
|
@ -2938,10 +2929,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let the aim trail behind the player
|
// Let the aim trail behind the player
|
||||||
self->angle = R_PointToAngle2 (self->x,
|
self->angle = self->AngleTo(self->target, -self->target->velx * 3, -self->target->vely * 3);
|
||||||
self->y,
|
|
||||||
self->target->x - self->target->velx * 3,
|
|
||||||
self->target->y - self->target->vely * 3);
|
|
||||||
|
|
||||||
if (self->target->flags & MF_SHADOW && !(self->flags6 & MF6_SEEINVISIBLE))
|
if (self->target->flags & MF_SHADOW && !(self->flags6 & MF6_SEEINVISIBLE))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1164,7 +1164,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ang = R_PointToAngle2 (origin->x, origin->y, target->x, target->y);
|
ang = origin->AngleTo(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate this as float to avoid overflows so that the
|
// Calculate this as float to avoid overflows so that the
|
||||||
|
|
|
@ -1075,8 +1075,8 @@ bool PIT_CheckThing(AActor *thing, FCheckPosition &tm)
|
||||||
abs(thing->y - tm.thing->y) < (thing->radius+tm.thing->radius))
|
abs(thing->y - tm.thing->y) < (thing->radius+tm.thing->radius))
|
||||||
|
|
||||||
{
|
{
|
||||||
fixed_t newdist = P_AproxDistance(thing->x - tm.x, thing->y - tm.y);
|
fixed_t newdist = thing->AproxDistance(tm.x, tm.y, tm.thing);
|
||||||
fixed_t olddist = P_AproxDistance(thing->x - tm.thing->x, thing->y - tm.thing->y);
|
fixed_t olddist = thing->AproxDistance(tm.thing);
|
||||||
|
|
||||||
if (newdist > olddist)
|
if (newdist > olddist)
|
||||||
{
|
{
|
||||||
|
@ -1754,7 +1754,7 @@ void P_FakeZMovement(AActor *mo)
|
||||||
{ // float down towards target if too close
|
{ // float down towards target if too close
|
||||||
if (!(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT))
|
if (!(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT))
|
||||||
{
|
{
|
||||||
fixed_t dist = P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y);
|
fixed_t dist = mo->AproxDistance(mo->target);
|
||||||
fixed_t delta = (mo->target->z + (mo->height >> 1)) - mo->z;
|
fixed_t delta = (mo->target->z + (mo->height >> 1)) - mo->z;
|
||||||
if (delta < 0 && dist < -(delta * 3))
|
if (delta < 0 && dist < -(delta * 3))
|
||||||
mo->z -= mo->FloatSpeed;
|
mo->z -= mo->FloatSpeed;
|
||||||
|
@ -3066,7 +3066,7 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
|
||||||
if (!ontop)
|
if (!ontop)
|
||||||
{
|
{
|
||||||
fixed_t speed;
|
fixed_t speed;
|
||||||
angle_t angle = R_PointToAngle2(BlockingMobj->x,BlockingMobj->y, mo->x, mo->y) + ANGLE_1*((pr_bounce() % 16) - 8);
|
angle_t angle = BlockingMobj->AngleTo(mo) + ANGLE_1*((pr_bounce() % 16) - 8);
|
||||||
speed = P_AproxDistance(mo->velx, mo->vely);
|
speed = P_AproxDistance(mo->velx, mo->vely);
|
||||||
speed = FixedMul(speed, mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent
|
speed = FixedMul(speed, mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent
|
||||||
mo->angle = angle;
|
mo->angle = angle;
|
||||||
|
@ -4084,7 +4084,7 @@ void P_TraceBleed(int damage, AActor *target, AActor *missile)
|
||||||
pitch = 0;
|
pitch = 0;
|
||||||
}
|
}
|
||||||
P_TraceBleed(damage, target->x, target->y, target->z + target->height / 2,
|
P_TraceBleed(damage, target->x, target->y, target->z + target->height / 2,
|
||||||
target, R_PointToAngle2(missile->x, missile->y, target->x, target->y),
|
target, missile->AngleTo(target),
|
||||||
pitch);
|
pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4853,7 +4853,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo
|
||||||
{
|
{
|
||||||
velz *= 0.8f;
|
velz *= 0.8f;
|
||||||
}
|
}
|
||||||
angle_t ang = R_PointToAngle2(bombspot->x, bombspot->y, thing->x, thing->y) >> ANGLETOFINESHIFT;
|
angle_t ang = bombspot->AngleTo(thing) >> ANGLETOFINESHIFT;
|
||||||
thing->velx += fixed_t(finecosine[ang] * thrust);
|
thing->velx += fixed_t(finecosine[ang] * thrust);
|
||||||
thing->vely += fixed_t(finesine[ang] * thrust);
|
thing->vely += fixed_t(finesine[ang] * thrust);
|
||||||
if (!(flags & RADF_NODAMAGE))
|
if (!(flags & RADF_NODAMAGE))
|
||||||
|
|
|
@ -1556,7 +1556,7 @@ int P_FaceMobj (AActor *source, AActor *target, angle_t *delta)
|
||||||
angle_t angle2;
|
angle_t angle2;
|
||||||
|
|
||||||
angle1 = source->angle;
|
angle1 = source->angle;
|
||||||
angle2 = R_PointToAngle2 (source->x, source->y, target->x, target->y);
|
angle2 = source->AngleTo(target);
|
||||||
if (angle2 > angle1)
|
if (angle2 > angle1)
|
||||||
{
|
{
|
||||||
diff = angle2 - angle1;
|
diff = angle2 - angle1;
|
||||||
|
@ -1669,8 +1669,7 @@ bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool preci
|
||||||
if (actor->z + actor->height < target->z ||
|
if (actor->z + actor->height < target->z ||
|
||||||
target->z + target->height < actor->z)
|
target->z + target->height < actor->z)
|
||||||
{ // Need to seek vertically
|
{ // Need to seek vertically
|
||||||
dist = P_AproxDistance (target->x - actor->x, target->y - actor->y);
|
dist = actor->AproxDistance (target) / speed;
|
||||||
dist = dist / speed;
|
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
{
|
{
|
||||||
dist = 1;
|
dist = 1;
|
||||||
|
@ -2020,7 +2019,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly)
|
||||||
// Don't change the angle if there's THRUREFLECT on the monster.
|
// Don't change the angle if there's THRUREFLECT on the monster.
|
||||||
if (!(BlockingMobj->flags7 & MF7_THRUREFLECT))
|
if (!(BlockingMobj->flags7 & MF7_THRUREFLECT))
|
||||||
{
|
{
|
||||||
angle = R_PointToAngle2(BlockingMobj->x, BlockingMobj->y, mo->x, mo->y);
|
angle = BlockingMobj->AngleTo(mo);
|
||||||
bool dontReflect = (mo->AdjustReflectionAngle(BlockingMobj, angle));
|
bool dontReflect = (mo->AdjustReflectionAngle(BlockingMobj, angle));
|
||||||
// Change angle for deflection/reflection
|
// Change angle for deflection/reflection
|
||||||
|
|
||||||
|
@ -2380,7 +2379,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz)
|
||||||
{ // float down towards target if too close
|
{ // float down towards target if too close
|
||||||
if (!(mo->flags & (MF_SKULLFLY | MF_INFLOAT)))
|
if (!(mo->flags & (MF_SKULLFLY | MF_INFLOAT)))
|
||||||
{
|
{
|
||||||
dist = P_AproxDistance (mo->x - mo->target->x, mo->y - mo->target->y);
|
dist = mo->AproxDistance (mo->target);
|
||||||
delta = (mo->target->z + (mo->height>>1)) - mo->z;
|
delta = (mo->target->z + (mo->height>>1)) - mo->z;
|
||||||
if (delta < 0 && dist < -(delta*3))
|
if (delta < 0 && dist < -(delta*3))
|
||||||
mo->z -= mo->FloatSpeed;
|
mo->z -= mo->FloatSpeed;
|
||||||
|
@ -3089,8 +3088,7 @@ bool AActor::IsOkayToAttack (AActor *link)
|
||||||
// to only allow the check to succeed if the enemy was in a ~84<38> FOV of the player
|
// to only allow the check to succeed if the enemy was in a ~84<38> FOV of the player
|
||||||
if (flags3 & MF3_SCREENSEEKER)
|
if (flags3 & MF3_SCREENSEEKER)
|
||||||
{
|
{
|
||||||
angle_t angle = R_PointToAngle2(Friend->x,
|
angle_t angle = Friend->AngleTo(link) - Friend->angle;
|
||||||
Friend->y, link->x, link->y) - Friend->angle;
|
|
||||||
angle >>= 24;
|
angle >>= 24;
|
||||||
if (angle>226 || angle<30)
|
if (angle>226 || angle<30)
|
||||||
{
|
{
|
||||||
|
@ -3392,7 +3390,7 @@ void AActor::Tick ()
|
||||||
if (health > 0
|
if (health > 0
|
||||||
&& !players[i].Bot->enemy
|
&& !players[i].Bot->enemy
|
||||||
&& player ? !IsTeammate (players[i].mo) : true
|
&& player ? !IsTeammate (players[i].mo) : true
|
||||||
&& P_AproxDistance (players[i].mo->x-x, players[i].mo->y-y) < MAX_MONSTER_TARGET_DIST
|
&& AproxDistance (players[i].mo) < MAX_MONSTER_TARGET_DIST
|
||||||
&& P_CheckSight (players[i].mo, this, SF_SEEPASTBLOCKEVERYTHING))
|
&& P_CheckSight (players[i].mo, this, SF_SEEPASTBLOCKEVERYTHING))
|
||||||
{ //Probably a monster, so go kill it.
|
{ //Probably a monster, so go kill it.
|
||||||
players[i].Bot->enemy = this;
|
players[i].Bot->enemy = this;
|
||||||
|
@ -5036,7 +5034,7 @@ AActor *P_SpawnPuff (AActor *source, const PClass *pufftype, fixed_t x, fixed_t
|
||||||
puff->target = source;
|
puff->target = source;
|
||||||
|
|
||||||
|
|
||||||
if (source != NULL) puff->angle = R_PointToAngle2(x, y, source->x, source->y);
|
if (source != NULL) puff->angle = puff->AngleTo(source);
|
||||||
|
|
||||||
// If a puff has a crash state and an actor was not hit,
|
// If a puff has a crash state and an actor was not hit,
|
||||||
// it will enter the crash state. This is used by the StrifeSpark
|
// it will enter the crash state. This is used by the StrifeSpark
|
||||||
|
@ -5783,12 +5781,12 @@ AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const
|
||||||
P_PlaySpawnSound(th, source);
|
P_PlaySpawnSound(th, source);
|
||||||
th->target = owner; // record missile's originator
|
th->target = owner; // record missile's originator
|
||||||
|
|
||||||
th->angle = an = R_PointToAngle2 (source->x, source->y, dest->x, dest->y);
|
th->angle = an = source->AngleTo(dest);
|
||||||
an >>= ANGLETOFINESHIFT;
|
an >>= ANGLETOFINESHIFT;
|
||||||
th->velx = FixedMul (th->Speed, finecosine[an]);
|
th->velx = FixedMul (th->Speed, finecosine[an]);
|
||||||
th->vely = FixedMul (th->Speed, finesine[an]);
|
th->vely = FixedMul (th->Speed, finesine[an]);
|
||||||
|
|
||||||
dist = P_AproxDistance (dest->x - source->x, dest->y - source->y);
|
dist = source->AproxDistance (dest);
|
||||||
if (th->Speed) dist = dist / th->Speed;
|
if (th->Speed) dist = dist / th->Speed;
|
||||||
|
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
|
@ -5849,7 +5847,7 @@ AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, const PCl
|
||||||
{
|
{
|
||||||
an += pr_spawnmissile.Random2() << 20;
|
an += pr_spawnmissile.Random2() << 20;
|
||||||
}
|
}
|
||||||
dist = P_AproxDistance (dest->x - source->x, dest->y - source->y);
|
dist = source->AproxDistance (dest);
|
||||||
speed = GetDefaultSpeed (type);
|
speed = GetDefaultSpeed (type);
|
||||||
dist /= speed;
|
dist /= speed;
|
||||||
velz = dist != 0 ? (dest->z - source->z)/dist : speed;
|
velz = dist != 0 ? (dest->z - source->z)/dist : speed;
|
||||||
|
|
|
@ -2234,7 +2234,7 @@ void DPusher::Tick ()
|
||||||
{
|
{
|
||||||
int sx = m_X;
|
int sx = m_X;
|
||||||
int sy = m_Y;
|
int sy = m_Y;
|
||||||
int dist = P_AproxDistance (thing->x - sx,thing->y - sy);
|
int dist = thing->AproxDistance (sx, sy);
|
||||||
int speed = (m_Magnitude - ((dist>>FRACBITS)>>1))<<(FRACBITS-PUSH_FACTOR-1);
|
int speed = (m_Magnitude - ((dist>>FRACBITS)>>1))<<(FRACBITS-PUSH_FACTOR-1);
|
||||||
|
|
||||||
// If speed <= 0, you're outside the effective radius. You also have
|
// If speed <= 0, you're outside the effective radius. You also have
|
||||||
|
@ -2242,7 +2242,7 @@ void DPusher::Tick ()
|
||||||
|
|
||||||
if ((speed > 0) && (P_CheckSight (thing, m_Source, SF_IGNOREVISIBILITY)))
|
if ((speed > 0) && (P_CheckSight (thing, m_Source, SF_IGNOREVISIBILITY)))
|
||||||
{
|
{
|
||||||
angle_t pushangle = R_PointToAngle2 (thing->x, thing->y, sx, sy);
|
angle_t pushangle = thing->AngleTo(sx, sy);
|
||||||
if (m_Source->GetClass()->TypeName == NAME_PointPusher)
|
if (m_Source->GetClass()->TypeName == NAME_PointPusher)
|
||||||
pushangle += ANG180; // away
|
pushangle += ANG180; // away
|
||||||
pushangle >>= ANGLETOFINESHIFT;
|
pushangle >>= ANGLETOFINESHIFT;
|
||||||
|
|
|
@ -304,7 +304,8 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nolead: mobj->angle = R_PointToAngle2 (mobj->x, mobj->y, targ->x, targ->y);
|
nolead:
|
||||||
|
mobj->angle = mobj->AngleTo(targ);
|
||||||
aim.Resize (fspeed);
|
aim.Resize (fspeed);
|
||||||
mobj->velx = fixed_t(aim[0]);
|
mobj->velx = fixed_t(aim[0]);
|
||||||
mobj->vely = fixed_t(aim[1]);
|
mobj->vely = fixed_t(aim[1]);
|
||||||
|
|
|
@ -670,7 +670,7 @@ void DoJumpIfCloser(AActor *target, DECLARE_PARAMINFO)
|
||||||
// No target - no jump
|
// No target - no jump
|
||||||
if (!target)
|
if (!target)
|
||||||
return;
|
return;
|
||||||
if (P_AproxDistance(self->x-target->x, self->y-target->y) < dist &&
|
if (self->AproxDistance(target) < dist &&
|
||||||
(noz ||
|
(noz ||
|
||||||
((self->z > target->z && self->z - (target->z + target->height) < dist) ||
|
((self->z > target->z && self->z - (target->z + target->height) < dist) ||
|
||||||
(self->z <= target->z && target->z - (self->z + self->height) < dist))))
|
(self->z <= target->z && target->z - (self->z + self->height) < dist))))
|
||||||
|
@ -1487,10 +1487,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
|
||||||
if (!(flags & CPF_NOTURN))
|
if (!(flags & CPF_NOTURN))
|
||||||
{
|
{
|
||||||
// turn to face target
|
// turn to face target
|
||||||
self->angle = R_PointToAngle2 (self->x,
|
self->angle = self->AngleTo(linetarget);
|
||||||
self->y,
|
|
||||||
linetarget->x,
|
|
||||||
linetarget->y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & CPF_PULLIN) self->flags |= MF_JUSTATTACKED;
|
if (flags & CPF_PULLIN) self->flags |= MF_JUSTATTACKED;
|
||||||
|
@ -1614,10 +1611,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
|
||||||
|
|
||||||
if (aim)
|
if (aim)
|
||||||
{
|
{
|
||||||
self->angle = R_PointToAngle2 (self->x,
|
self->angle = self->AngleTo(self->target);
|
||||||
self->y,
|
|
||||||
self->target->x,
|
|
||||||
self->target->y);
|
|
||||||
}
|
}
|
||||||
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, 0, aim ? self->target : NULL);
|
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, 0, aim ? self->target : NULL);
|
||||||
if (linetarget == NULL && aim)
|
if (linetarget == NULL && aim)
|
||||||
|
@ -1631,9 +1625,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
|
||||||
// Let the aim trail behind the player
|
// Let the aim trail behind the player
|
||||||
if (aim)
|
if (aim)
|
||||||
{
|
{
|
||||||
saved_angle = self->angle = R_PointToAngle2 (self->x, self->y,
|
saved_angle = self->angle = self->AngleTo(self->target, -self->target->velx * 3, -self->target->vely * 3);
|
||||||
self->target->x - self->target->velx * 3,
|
|
||||||
self->target->y - self->target->vely * 3);
|
|
||||||
|
|
||||||
if (aim == CRF_AIMDIRECT)
|
if (aim == CRF_AIMDIRECT)
|
||||||
{
|
{
|
||||||
|
@ -1642,9 +1634,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
|
||||||
self->x += Spawnofs_XY * finecosine[self->angle];
|
self->x += Spawnofs_XY * finecosine[self->angle];
|
||||||
self->y += Spawnofs_XY * finesine[self->angle];
|
self->y += Spawnofs_XY * finesine[self->angle];
|
||||||
Spawnofs_XY = 0;
|
Spawnofs_XY = 0;
|
||||||
self->angle = R_PointToAngle2 (self->x, self->y,
|
self->angle = self->AngleTo(self->target,- self->target->velx * 3, -self->target->vely * 3);
|
||||||
self->target->x - self->target->velx * 3,
|
|
||||||
self->target->y - self->target->vely * 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->target->flags & MF_SHADOW)
|
if (self->target->flags & MF_SHADOW)
|
||||||
|
@ -3342,8 +3332,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
FVector2 xyvec(target->x - x1, target->y - y1);
|
fixed_t xydist = self->Distance2D(target);
|
||||||
fixed_t distance = P_AproxDistance((fixed_t)xyvec.Length(), target->z - z1);
|
fixed_t distance = P_AproxDistance(xydist, target->z - z1);
|
||||||
|
|
||||||
if (range && !(flags & CLOFF_CHECKPARTIAL))
|
if (range && !(flags & CLOFF_CHECKPARTIAL))
|
||||||
{
|
{
|
||||||
|
@ -3357,7 +3347,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
|
||||||
{
|
{
|
||||||
ang = self->angle;
|
ang = self->angle;
|
||||||
}
|
}
|
||||||
else ang = R_PointToAngle2 (x1, y1, target->x, target->y);
|
else ang = self->AngleTo (target);
|
||||||
|
|
||||||
angle += ang;
|
angle += ang;
|
||||||
|
|
||||||
|
@ -3372,11 +3362,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
|
||||||
}
|
}
|
||||||
else if (flags & CLOFF_AIM_VERT_NOOFFSET)
|
else if (flags & CLOFF_AIM_VERT_NOOFFSET)
|
||||||
{
|
{
|
||||||
pitch += R_PointToAngle2 (0,0, (fixed_t)xyvec.Length(), target->z - z1 + offsetheight + target->height / 2);
|
pitch += R_PointToAngle2 (0,0, xydist, target->z - z1 + offsetheight + target->height / 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pitch += R_PointToAngle2 (0,0, (fixed_t)xyvec.Length(), target->z - z1 + target->height / 2);
|
pitch += R_PointToAngle2 (0,0, xydist, target->z - z1 + target->height / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (flags & CLOFF_ALLOWNULL)
|
else if (flags & CLOFF_ALLOWNULL)
|
||||||
|
@ -3546,8 +3536,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
|
||||||
// [FDARI] If actors share team, don't jump
|
// [FDARI] If actors share team, don't jump
|
||||||
if ((flags & JLOSF_ALLYNOJUMP) && self->IsFriend(target)) return;
|
if ((flags & JLOSF_ALLYNOJUMP) && self->IsFriend(target)) return;
|
||||||
|
|
||||||
fixed_t distance = P_AproxDistance(target->x - self->x, target->y - self->y);
|
fixed_t distance = self->AproxDistance3D(target);
|
||||||
distance = P_AproxDistance(distance, target->z - self->z);
|
|
||||||
|
|
||||||
if (dist_max && (distance > dist_max)) return;
|
if (dist_max && (distance > dist_max)) return;
|
||||||
|
|
||||||
|
@ -3577,11 +3566,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
|
||||||
|
|
||||||
if (fov && (fov < ANGLE_MAX))
|
if (fov && (fov < ANGLE_MAX))
|
||||||
{
|
{
|
||||||
an = R_PointToAngle2 (viewport->x,
|
an = viewport->AngleTo(target) - viewport->angle;
|
||||||
viewport->y,
|
|
||||||
target->x,
|
|
||||||
target->y)
|
|
||||||
- viewport->angle;
|
|
||||||
|
|
||||||
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
||||||
{
|
{
|
||||||
|
@ -3635,8 +3620,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS)
|
||||||
|
|
||||||
if ((flags & JLOSF_DEADNOJUMP) && (target->health <= 0)) return;
|
if ((flags & JLOSF_DEADNOJUMP) && (target->health <= 0)) return;
|
||||||
|
|
||||||
fixed_t distance = P_AproxDistance(target->x - self->x, target->y - self->y);
|
fixed_t distance = self->AproxDistance3D(target);
|
||||||
distance = P_AproxDistance(distance, target->z - self->z);
|
|
||||||
|
|
||||||
if (dist_max && (distance > dist_max)) return;
|
if (dist_max && (distance > dist_max)) return;
|
||||||
|
|
||||||
|
@ -3656,11 +3640,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS)
|
||||||
|
|
||||||
if (fov && (fov < ANGLE_MAX))
|
if (fov && (fov < ANGLE_MAX))
|
||||||
{
|
{
|
||||||
an = R_PointToAngle2 (target->x,
|
an = target->AngleTo(self) - target->angle;
|
||||||
target->y,
|
|
||||||
self->x,
|
|
||||||
self->y)
|
|
||||||
- target->angle;
|
|
||||||
|
|
||||||
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
||||||
{
|
{
|
||||||
|
@ -4590,7 +4570,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack)
|
||||||
|
|
||||||
|
|
||||||
// Target can dodge if it can see enemy
|
// Target can dodge if it can see enemy
|
||||||
angle_t angle = R_PointToAngle2(self->target->x, self->target->y, self->x, self->y) - self->target->angle;
|
angle_t angle = self->target->AngleTo(self) - self->target->angle;
|
||||||
angle >>= 24;
|
angle >>= 24;
|
||||||
bool dodge = (P_CheckSight(self->target, self) && (angle>226 || angle<30));
|
bool dodge = (P_CheckSight(self->target, self) && (angle>226 || angle<30));
|
||||||
|
|
||||||
|
@ -4629,7 +4609,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack)
|
||||||
dx = self->target->x;
|
dx = self->target->x;
|
||||||
dy = self->target->y;
|
dy = self->target->y;
|
||||||
dz = self->target->z + (self->target->height>>1);
|
dz = self->target->z + (self->target->height>>1);
|
||||||
angle = R_PointToAngle2(dx, dy, self->x, self->y);
|
angle = self->target->AngleTo(self);
|
||||||
|
|
||||||
dx += FixedMul(self->target->radius, finecosine[angle>>ANGLETOFINESHIFT]);
|
dx += FixedMul(self->target->radius, finecosine[angle>>ANGLETOFINESHIFT]);
|
||||||
dy += FixedMul(self->target->radius, finesine[angle>>ANGLETOFINESHIFT]);
|
dy += FixedMul(self->target->radius, finesine[angle>>ANGLETOFINESHIFT]);
|
||||||
|
@ -4664,7 +4644,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack)
|
||||||
if (spawnblood)
|
if (spawnblood)
|
||||||
{
|
{
|
||||||
P_SpawnBlood(dx, dy, dz, angle, newdam > 0 ? newdam : damage, self->target);
|
P_SpawnBlood(dx, dy, dz, angle, newdam > 0 ? newdam : damage, self->target);
|
||||||
P_TraceBleed(newdam > 0 ? newdam : damage, self->target, R_PointToAngle2(self->x, self->y, dx, dy), 0);
|
P_TraceBleed(newdam > 0 ? newdam : damage, self->target, self->AngleTo(dx, dy, self->target), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5950,7 +5930,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckProximity)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Make sure it's in range and respect the desire for Z or not.
|
//Make sure it's in range and respect the desire for Z or not.
|
||||||
if (P_AproxDistance(ref->x - mo->x, ref->y - mo->y) < distance &&
|
if (ref->AproxDistance(mo) < distance &&
|
||||||
((flags & CPXF_NOZ) ||
|
((flags & CPXF_NOZ) ||
|
||||||
((ref->z > mo->z && ref->z - (mo->z + mo->height) < distance) ||
|
((ref->z > mo->z && ref->z - (mo->z + mo->height) < distance) ||
|
||||||
(ref->z <= mo->z && mo->z - (ref->z + ref->height) < distance))))
|
(ref->z <= mo->z && mo->z - (ref->z + ref->height) < distance))))
|
||||||
|
|
|
@ -85,6 +85,10 @@
|
||||||
// The number of quads we can batch together.
|
// The number of quads we can batch together.
|
||||||
#define MAX_QUAD_BATCH (NUM_INDEXES / 6)
|
#define MAX_QUAD_BATCH (NUM_INDEXES / 6)
|
||||||
|
|
||||||
|
// The default size for a texture atlas.
|
||||||
|
#define DEF_ATLAS_WIDTH 512
|
||||||
|
#define DEF_ATLAS_HEIGHT 512
|
||||||
|
|
||||||
// TYPES -------------------------------------------------------------------
|
// TYPES -------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_CLASS(D3DFB)
|
IMPLEMENT_CLASS(D3DFB)
|
||||||
|
@ -1833,8 +1837,8 @@ void D3DFB::DrawPackedTextures(int packnum)
|
||||||
{
|
{
|
||||||
D3DCOLOR empty_colors[8] =
|
D3DCOLOR empty_colors[8] =
|
||||||
{
|
{
|
||||||
0xFFFF9999, 0xFF99FF99, 0xFF9999FF, 0xFFFFFF99,
|
0x50FF0000, 0x5000FF00, 0x500000FF, 0x50FFFF00,
|
||||||
0xFFFF99FF, 0xFF99FFFF, 0xFFFFCC99, 0xFF99CCFF
|
0x50FF00FF, 0x5000FFFF, 0x50FF8000, 0x500080FF
|
||||||
};
|
};
|
||||||
Atlas *pack;
|
Atlas *pack;
|
||||||
int x = 8, y = 8;
|
int x = 8, y = 8;
|
||||||
|
@ -1869,7 +1873,17 @@ void D3DFB::DrawPackedTextures(int packnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
AddColorOnlyRect(x-1, y-1-LBOffsetI, 258, 258, D3DCOLOR_XRGB(255,255,0));
|
AddColorOnlyRect(x-1, y-1-LBOffsetI, 258, 258, D3DCOLOR_XRGB(255,255,0));
|
||||||
AddColorOnlyQuad(x, y-LBOffsetI, 256, 256, D3DCOLOR_ARGB(180,0,0,0));
|
int back = 0;
|
||||||
|
for (PackedTexture *box = pack->UsedList; box != NULL; box = box->Next)
|
||||||
|
{
|
||||||
|
AddColorOnlyQuad(
|
||||||
|
x + box->Area.left * 256 / pack->Width,
|
||||||
|
y + box->Area.top * 256 / pack->Height,
|
||||||
|
(box->Area.right - box->Area.left) * 256 / pack->Width,
|
||||||
|
(box->Area.bottom - box->Area.top) * 256 / pack->Height, empty_colors[back]);
|
||||||
|
back = (back + 1) & 7;
|
||||||
|
}
|
||||||
|
// AddColorOnlyQuad(x, y-LBOffsetI, 256, 256, D3DCOLOR_ARGB(180,0,0,0));
|
||||||
|
|
||||||
CheckQuadBatch();
|
CheckQuadBatch();
|
||||||
|
|
||||||
|
@ -1973,8 +1987,8 @@ D3DFB::PackedTexture *D3DFB::AllocPackedTexture(int w, int h, bool wrapping, D3D
|
||||||
Rect box;
|
Rect box;
|
||||||
bool padded;
|
bool padded;
|
||||||
|
|
||||||
// check for 254 to account for padding
|
// The - 2 to account for padding
|
||||||
if (w > 254 || h > 254 || wrapping)
|
if (w > 256 - 2 || h > 256 - 2 || wrapping)
|
||||||
{ // Create a new texture atlas.
|
{ // Create a new texture atlas.
|
||||||
pack = new Atlas(this, w, h, format);
|
pack = new Atlas(this, w, h, format);
|
||||||
pack->OneUse = true;
|
pack->OneUse = true;
|
||||||
|
@ -1999,7 +2013,7 @@ D3DFB::PackedTexture *D3DFB::AllocPackedTexture(int w, int h, bool wrapping, D3D
|
||||||
}
|
}
|
||||||
if (pack == NULL)
|
if (pack == NULL)
|
||||||
{ // Create a new texture atlas.
|
{ // Create a new texture atlas.
|
||||||
pack = new Atlas(this, 256, 256, format);
|
pack = new Atlas(this, DEF_ATLAS_WIDTH, DEF_ATLAS_HEIGHT, format);
|
||||||
box = pack->Packer.Insert(w, h);
|
box = pack->Packer.Insert(w, h);
|
||||||
}
|
}
|
||||||
padded = true;
|
padded = true;
|
||||||
|
|
Loading…
Reference in a new issue