mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- refactored two mire files.
- fixed: FraggleScript's SetObjPosition function did not properly set the moved actor's properties. Better use SetOrigin for changing the position.
This commit is contained in:
parent
e8ee8c5c97
commit
b63eb391f7
4 changed files with 50 additions and 42 deletions
20
src/actor.h
20
src/actor.h
|
@ -957,17 +957,37 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fixedvec2 Vec2Angle(fixed_t length, angle_t angle, bool absolute = false) const
|
||||||
|
{
|
||||||
|
fixedvec2 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
|
||||||
|
y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) };
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const
|
fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const
|
||||||
{
|
{
|
||||||
fixedvec3 ret = { x + dx, y + dy, z + dz };
|
fixedvec3 ret = { x + dx, y + dy, z + dz };
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fixedvec3 Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) const
|
||||||
|
{
|
||||||
|
fixedvec3 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
|
||||||
|
y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), z + dz };
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void Move(fixed_t dx, fixed_t dy, fixed_t dz)
|
void Move(fixed_t dx, fixed_t dy, fixed_t dz)
|
||||||
{
|
{
|
||||||
SetOrigin(x + dx, y + dy, z + dz, true);
|
SetOrigin(x + dx, y + dy, z + dz, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetOrigin(const fixedvec3 & npos, bool moving)
|
||||||
|
{
|
||||||
|
SetOrigin(npos.x, npos.y, npos.z, moving);
|
||||||
|
}
|
||||||
|
|
||||||
inline void SetFriendPlayer(player_t *player);
|
inline void SetFriendPlayer(player_t *player);
|
||||||
|
|
||||||
bool IsVisibleToPlayer() const;
|
bool IsVisibleToPlayer() const;
|
||||||
|
|
|
@ -982,7 +982,7 @@ void FParser::SF_ObjX(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
t_return.type = svt_fixed; // haleyjd: SoM's fixed-point fix
|
t_return.type = svt_fixed; // haleyjd: SoM's fixed-point fix
|
||||||
t_return.value.f = mo ? mo->x : 0; // null ptr check
|
t_return.value.f = mo ? mo->X() : 0; // null ptr check
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1005,7 +1005,7 @@ void FParser::SF_ObjY(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
t_return.type = svt_fixed; // haleyjd
|
t_return.type = svt_fixed; // haleyjd
|
||||||
t_return.value.f = mo ? mo->y : 0; // null ptr check
|
t_return.value.f = mo ? mo->Y() : 0; // null ptr check
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1028,7 +1028,7 @@ void FParser::SF_ObjZ(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
t_return.type = svt_fixed; // haleyjd
|
t_return.type = svt_fixed; // haleyjd
|
||||||
t_return.value.f = mo ? mo->z : 0; // null ptr check
|
t_return.value.f = mo ? mo->Z() : 0; // null ptr check
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1466,8 +1466,8 @@ void FParser::SF_SetCamera(void)
|
||||||
angle = t_argc < 2 ? newcamera->angle : (fixed_t)FixedToAngle(fixedvalue(t_argv[1]));
|
angle = t_argc < 2 ? newcamera->angle : (fixed_t)FixedToAngle(fixedvalue(t_argv[1]));
|
||||||
|
|
||||||
newcamera->special1=newcamera->angle;
|
newcamera->special1=newcamera->angle;
|
||||||
newcamera->special2=newcamera->z;
|
newcamera->special2=newcamera->Z();
|
||||||
newcamera->z = t_argc < 3 ? (newcamera->z + (41 << FRACBITS)) : (intvalue(t_argv[2]) << FRACBITS);
|
newcamera->SetZ(t_argc < 3 ? (newcamera->Z() + (41 << FRACBITS)) : (intvalue(t_argv[2]) << FRACBITS));
|
||||||
newcamera->angle = angle;
|
newcamera->angle = angle;
|
||||||
if(t_argc < 4) newcamera->pitch = 0;
|
if(t_argc < 4) newcamera->pitch = 0;
|
||||||
else
|
else
|
||||||
|
@ -1498,7 +1498,7 @@ void FParser::SF_ClearCamera(void)
|
||||||
{
|
{
|
||||||
player->camera=player->mo;
|
player->camera=player->mo;
|
||||||
cam->angle=cam->special1;
|
cam->angle=cam->special1;
|
||||||
cam->z=cam->special2;
|
cam->SetZ(cam->special2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3065,7 +3065,7 @@ void FParser::SF_SetWeapon()
|
||||||
void FParser::SF_MoveCamera(void)
|
void FParser::SF_MoveCamera(void)
|
||||||
{
|
{
|
||||||
fixed_t x, y, z;
|
fixed_t x, y, z;
|
||||||
fixed_t xdist, ydist, zdist, xydist, movespeed;
|
fixed_t zdist, xydist, movespeed;
|
||||||
fixed_t xstep, ystep, zstep, targetheight;
|
fixed_t xstep, ystep, zstep, targetheight;
|
||||||
angle_t anglespeed, anglestep, angledist, targetangle,
|
angle_t anglespeed, anglestep, angledist, targetangle,
|
||||||
mobjangle, bigangle, smallangle;
|
mobjangle, bigangle, smallangle;
|
||||||
|
@ -3097,9 +3097,8 @@ void FParser::SF_MoveCamera(void)
|
||||||
anglespeed = (angle_t)FixedToAngle(fixedvalue(t_argv[5]));
|
anglespeed = (angle_t)FixedToAngle(fixedvalue(t_argv[5]));
|
||||||
|
|
||||||
// figure out how big one step will be
|
// figure out how big one step will be
|
||||||
xdist = target->x - cam->x;
|
fixedvec2 dist = cam->Vec2To(target);
|
||||||
ydist = target->y - cam->y;
|
zdist = targetheight - cam->Z();
|
||||||
zdist = targetheight - cam->z;
|
|
||||||
|
|
||||||
// Angle checking...
|
// Angle checking...
|
||||||
// 90
|
// 90
|
||||||
|
@ -3170,19 +3169,19 @@ void FParser::SF_MoveCamera(void)
|
||||||
else
|
else
|
||||||
anglestep = anglespeed;
|
anglestep = anglespeed;
|
||||||
|
|
||||||
if(abs(xstep) >= (abs(xdist) - 1))
|
if(abs(xstep) >= (abs(dist.x) - 1))
|
||||||
x = target->x;
|
x = cam->X() + dist.x;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x = cam->x + xstep;
|
x = cam->X() + xstep;
|
||||||
moved = 1;
|
moved = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(abs(ystep) >= (abs(ydist) - 1))
|
if(abs(ystep) >= (abs(dist.y) - 1))
|
||||||
y = target->y;
|
y = cam->Y() + dist.y;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
y = cam->y + ystep;
|
y = cam->Y() + ystep;
|
||||||
moved = 1;
|
moved = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3190,7 +3189,7 @@ void FParser::SF_MoveCamera(void)
|
||||||
z = targetheight;
|
z = targetheight;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
z = cam->z + zstep;
|
z = cam->Z() + zstep;
|
||||||
moved = 1;
|
moved = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3212,12 +3211,12 @@ void FParser::SF_MoveCamera(void)
|
||||||
|
|
||||||
cam->radius=8;
|
cam->radius=8;
|
||||||
cam->height=8;
|
cam->height=8;
|
||||||
if ((x != cam->x || y != cam->y) && !P_TryMove(cam, x, y, true))
|
if ((x != cam->X() || y != cam->Y()) && !P_TryMove(cam, x, y, true))
|
||||||
{
|
{
|
||||||
Printf("Illegal camera move to (%f, %f)\n", x/65536.f, y/65536.f);
|
Printf("Illegal camera move to (%f, %f)\n", x/65536.f, y/65536.f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cam->z = z;
|
cam->SetZ(z);
|
||||||
|
|
||||||
t_return.type = svt_int;
|
t_return.type = svt_int;
|
||||||
t_return.value.i = moved;
|
t_return.value.i = moved;
|
||||||
|
@ -3410,13 +3409,10 @@ void FParser::SF_SetObjPosition()
|
||||||
|
|
||||||
if (!mobj) return;
|
if (!mobj) return;
|
||||||
|
|
||||||
mobj->UnlinkFromWorld();
|
mobj->SetOrigin(
|
||||||
|
fixedvalue(t_argv[1]),
|
||||||
mobj->x = intvalue(t_argv[1]) << FRACBITS;
|
(t_argc >= 3)? fixedvalue(t_argv[2]) : mobj->Y(),
|
||||||
if(t_argc >= 3) mobj->y = intvalue(t_argv[2]) << FRACBITS;
|
(t_argc >= 4)? fixedvalue(t_argv[3]) : mobj->Z(), false);
|
||||||
if(t_argc == 4) mobj->z = intvalue(t_argv[3]) << FRACBITS;
|
|
||||||
|
|
||||||
mobj->LinkToWorld();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4285,7 +4281,7 @@ void FParser::SF_SpawnShot2(void)
|
||||||
|
|
||||||
t_return.type = svt_mobj;
|
t_return.type = svt_mobj;
|
||||||
|
|
||||||
AActor *mo = Spawn (PClass, source->x, source->y, source->z+z, ALLOW_REPLACE);
|
AActor *mo = Spawn (PClass, source->X(), source->Y(), source->Z()+z, ALLOW_REPLACE);
|
||||||
if (mo)
|
if (mo)
|
||||||
{
|
{
|
||||||
S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM);
|
S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM);
|
||||||
|
|
|
@ -52,7 +52,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Fire)
|
||||||
void A_Fire(AActor *self, int height)
|
void A_Fire(AActor *self, int height)
|
||||||
{
|
{
|
||||||
AActor *dest;
|
AActor *dest;
|
||||||
angle_t an;
|
|
||||||
|
|
||||||
dest = self->tracer;
|
dest = self->tracer;
|
||||||
if (dest == NULL || self->target == NULL)
|
if (dest == NULL || self->target == NULL)
|
||||||
|
@ -62,11 +61,8 @@ void A_Fire(AActor *self, int height)
|
||||||
if (!P_CheckSight (self->target, dest, 0) )
|
if (!P_CheckSight (self->target, dest, 0) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
an = dest->angle >> ANGLETOFINESHIFT;
|
fixedvec3 newpos = dest->Vec3Angle(24 * FRACUNIT, dest->angle, height);
|
||||||
|
self->SetOrigin(newpos, true);
|
||||||
self->SetOrigin (dest->x + FixedMul (24*FRACUNIT, finecosine[an]),
|
|
||||||
dest->y + FixedMul (24*FRACUNIT, finesine[an]),
|
|
||||||
dest->z + height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,8 +82,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileTarget)
|
||||||
|
|
||||||
A_FaceTarget (self);
|
A_FaceTarget (self);
|
||||||
|
|
||||||
fog = Spawn (fire, self->target->x, self->target->y,
|
fog = Spawn (fire, self->target->X(), self->target->Y(),
|
||||||
self->target->z, ALLOW_REPLACE);
|
self->target->Z(), ALLOW_REPLACE);
|
||||||
|
|
||||||
self->tracer = fog;
|
self->tracer = fog;
|
||||||
fog->target = self;
|
fog->target = self;
|
||||||
|
@ -117,7 +113,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack)
|
||||||
ACTION_PARAM_INT(flags,6);
|
ACTION_PARAM_INT(flags,6);
|
||||||
|
|
||||||
AActor *fire, *target;
|
AActor *fire, *target;
|
||||||
angle_t an;
|
|
||||||
|
|
||||||
if (NULL == (target = self->target))
|
if (NULL == (target = self->target))
|
||||||
return;
|
return;
|
||||||
|
@ -139,15 +134,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack)
|
||||||
|
|
||||||
P_TraceBleed (newdam > 0 ? newdam : dmg, target);
|
P_TraceBleed (newdam > 0 ? newdam : dmg, target);
|
||||||
|
|
||||||
an = self->angle >> ANGLETOFINESHIFT;
|
|
||||||
fire = self->tracer;
|
fire = self->tracer;
|
||||||
|
|
||||||
if (fire != NULL)
|
if (fire != NULL)
|
||||||
{
|
{
|
||||||
// move the fire between the vile and the player
|
// move the fire between the vile and the player
|
||||||
fire->SetOrigin (target->x - FixedMul (24*FRACUNIT, finecosine[an]),
|
fixedvec3 pos = target->Vec3Angle(-24 * FRACUNIT, self->angle, target->Z());
|
||||||
target->y - FixedMul (24*FRACUNIT, finesine[an]),
|
fire->SetOrigin (pos, true);
|
||||||
target->z);
|
|
||||||
|
|
||||||
P_RadiusAttack (fire, self, blastdmg, blastrad, dmgtype, 0);
|
P_RadiusAttack (fire, self, blastdmg, blastrad, dmgtype, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2918,8 +2918,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail)
|
||||||
{
|
{
|
||||||
// We probably won't hit the target, but aim at it anyway so we don't look stupid.
|
// We probably won't hit the target, but aim at it anyway so we don't look stupid.
|
||||||
TVector2<double> xydiff = self->Vec2To(self->target);
|
TVector2<double> xydiff = self->Vec2To(self->target);
|
||||||
double zdiff = (self->target->Z() + (self->target->height>>1)) -
|
double zdiff = FIXED2DBL((self->target->Z() + (self->target->height>>1)) - (self->Z() + (self->height>>1) - self->floorclip));
|
||||||
(self->Z() + (self->height>>1) - self->floorclip);
|
|
||||||
self->pitch = int(atan2(zdiff, xydiff.Length()) * ANGLE_180 / -M_PI);
|
self->pitch = int(atan2(zdiff, xydiff.Length()) * ANGLE_180 / -M_PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue