Merge branch 'unca_scrooge' into 'master'

The hardcoded part of ACZ3 so far

See merge request STJr/SRB2Internal!124
This commit is contained in:
toaster 2017-11-02 16:43:11 -04:00
commit c84d4261d1
5 changed files with 115 additions and 4 deletions

View File

@ -1805,6 +1805,7 @@ static actionpointer_t actionpointers[] =
{{A_FlickyFlutter}, "A_FLICKYFLUTTER"},
{{A_FlameParticle}, "A_FLAMEPARTICLE"},
{{A_FadeOverlay}, "A_FADEOVERLAY"},
{{A_Boss5Jump}, "A_BOSS5JUMP"},
{{NULL}, "NONE"},

View File

@ -217,6 +217,7 @@ void A_FlickyHeightCheck();
void A_FlickyFlutter();
void A_FlameParticle();
void A_FadeOverlay();
void A_Boss5Jump();
// ratio of states to sprites to mobj types is roughly 6 : 1 : 1
#define NUMMOBJFREESLOTS 256

View File

@ -424,6 +424,23 @@ static int lib_pSpawnMobj(lua_State *L)
return 1;
}
static int lib_pSpawnMobjFromMobj(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
fixed_t z = luaL_checkfixed(L, 4);
mobjtype_t type = luaL_checkinteger(L, 5);
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnMobjFromMobj(actor, x, y, z, type), META_MOBJ);
return 1;
}
static int lib_pRemoveMobj(lua_State *L)
{
mobj_t *th = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -2413,6 +2430,7 @@ static luaL_Reg lib[] = {
// p_mobj
// don't add P_SetMobjState or P_SetPlayerMobjState, use "mobj.state = S_NEWSTATE" instead.
{"P_SpawnMobj",lib_pSpawnMobj},
{"P_SpawnMobjFromMobj",lib_pSpawnMobjFromMobj},
{"P_RemoveMobj",lib_pRemoveMobj},
{"P_IsValidSprite2", lib_pIsValidSprite2},
{"P_SpawnLockOn", lib_pSpawnLockOn},

View File

@ -245,6 +245,7 @@ void A_FlickyHeightCheck(mobj_t *actor);
void A_FlickyFlutter(mobj_t *actor);
void A_FlameParticle(mobj_t *actor);
void A_FadeOverlay(mobj_t *actor);
void A_Boss5Jump(mobj_t *actor);
//
// ENEMY THINKING
@ -9179,7 +9180,7 @@ void A_Repeat(mobj_t *actor)
return;
#endif
if ((!(actor->extravalue2)) || actor->extravalue2 > locvar1)
if (locvar1 && (!actor->extravalue2 || actor->extravalue2 > locvar1))
actor->extravalue2 = locvar1;
if (--actor->extravalue2 > 0)
@ -10533,3 +10534,93 @@ void A_FadeOverlay(mobj_t *actor)
if (!(locvar1 & 4))
P_SetTarget(&actor->tracer, fade);
}
// Function: A_Boss5Jump
//
// Description: Makes an object jump in an arc to land on their tracer precicely.
// Adapted from A_BrakLobShot, see there for explanation.
//
// var1 = unused
// var2 = unused
//
void A_Boss5Jump(mobj_t *actor)
{
fixed_t v; // Velocity to jump at
fixed_t a1, a2, aToUse; // Velocity squared
fixed_t g; // Gravity
fixed_t x; // Horizontal difference
INT32 x_int; // x! But in integer form!
fixed_t y; // Vertical difference (yes that's normally z in SRB2 shut up)
INT32 y_int; // y! But in integer form!
INT32 intHypotenuse; // x^2 + y^2. Frequently overflows fixed point, hence why we need integers proper.
fixed_t fixedHypotenuse; // However, we can work around that and still get a fixed-point number.
angle_t theta; // Angle of attack
// INT32 locvar1 = var1;
// INT32 locvar2 = var2;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_Boss5Jump", actor))
return;
#endif
if (!actor->tracer)
return; // Don't even bother if we've got nothing to aim at.
// Look up actor's current gravity situation
if (actor->subsector->sector->gravity)
g = FixedMul(gravity,(FixedDiv(*actor->subsector->sector->gravity>>FRACBITS, 1000)));
else
g = gravity;
// Look up distance between actor and its tracer
x = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y);
// Look up height difference between actor and its tracer
y = actor->tracer->z - actor->z;
// Get x^2 + y^2. Have to do it in a roundabout manner, because this overflows fixed_t way too easily otherwise.
x_int = x>>FRACBITS;
y_int = y>>FRACBITS;
intHypotenuse = (x_int*x_int) + (y_int*y_int);
fixedHypotenuse = FixedSqrt(intHypotenuse) *256;
// a = g(y+/-sqrt(x^2+y^2)). a1 can be +, a2 can be -.
a1 = FixedMul(g,y+fixedHypotenuse);
a2 = FixedMul(g,y-fixedHypotenuse);
// Determine which one isn't actually an imaginary number (or the smaller of the two, if both are real), and use that for v.
if (a1 < 0 || a2 < 0)
{
if (a1 < 0 && a2 < 0)
{
//Somehow, v^2 is negative in both cases. v is therefore imaginary and something is horribly wrong. Abort!
return;
}
// Just find which one's NOT negative, and use that
aToUse = max(a1,a2);
}
else
{
// Both are positive; use whichever's smaller so it can decay faster
aToUse = min(a1,a2);
}
v = FixedSqrt(aToUse);
// Okay, so we know the velocity. Let's actually find theta.
// We can cut the "+/- sqrt" part out entirely, since v was calculated specifically for it to equal zero. So:
//theta = tantoangle[FixedDiv(aToUse,FixedMul(g,x)) >> DBITS];
theta = tantoangle[SlopeDiv(aToUse,FixedMul(g,x))];
// Okay, complicated math done. Let's make this object jump already.
A_FaceTracer(actor);
if (actor->eflags & MFE_VERTICALFLIP)
actor->z--;
else
actor->z++;
// Horizontal axes first. First parameter is initial horizontal impulse, second is to correct its angle.
actor->momx = FixedMul(FixedMul(v, FINECOSINE(theta >> ANGLETOFINESHIFT)), FINECOSINE(actor->angle >> ANGLETOFINESHIFT));
actor->momy = FixedMul(FixedMul(v, FINECOSINE(theta >> ANGLETOFINESHIFT)), FINESINE(actor->angle >> ANGLETOFINESHIFT));
// Then the vertical axis. No angle-correction needed here.
actor->momz = FixedMul(v, FINESINE(theta >> ANGLETOFINESHIFT));
// I hope that's all that's needed, ugh
}

View File

@ -299,7 +299,7 @@ sfxinfo_t S_sfx[NUMSFX] =
{"s3k49", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Falling rock"},
{"s3k4a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Grab"},
{"s3k4b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Water splash"},
{"s3k4c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Heavy landing"},
{"s3k4c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Heavy hit"},
{"s3k4d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Firing bullet"},
{"s3k4e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bomb explosion"},
{"s3k4f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flamethrower"},
@ -316,7 +316,7 @@ sfxinfo_t S_sfx[NUMSFX] =
{"s3k5a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Aiming"},
{"s3k5b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Menu beep"},
{"s3k5c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Electric spark"},
{"s3k5d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bouncing missile"},
{"s3k5d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Heavy hit"},
{"s3k5e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Firing laser"},
{"s3k5f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Crusher stomp"},
{"s3k60", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flying away"},
@ -367,7 +367,7 @@ sfxinfo_t S_sfx[NUMSFX] =
{"s3k8d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""},
{"s3k8e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""},
{"s3k8f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Opening"},
{"s3k90", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Closing"},
{"s3k90", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Impact"},
{"s3k91", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Closed"},
{"s3k92", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ghost"},
{"s3k93", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Rebuilding"},