This commit is contained in:
toaster 2024-08-17 20:16:27 +01:00
commit 1e502da748
13 changed files with 279 additions and 208 deletions

View file

@ -4975,6 +4975,11 @@ struct int_const_s const INT_CONST[] = {
{"BT_DRIFT",BT_DRIFT},
{"BT_BRAKE",BT_BRAKE},
{"BT_ATTACK",BT_ATTACK},
{"BT_LOOKBACK",BT_LOOKBACK},
{"BT_RESPAWN",BT_RESPAWN},
{"BT_VOTE",BT_VOTE},
{"BT_EBRAKEMASK",BT_EBRAKEMASK}, // Macro button
{"BT_SPINDASHMASK",BT_SPINDASHMASK}, // Macro button
{"BT_LUAA",BT_LUAA}, // Lua customizable
{"BT_LUAB",BT_LUAB}, // Lua customizable
{"BT_LUAC",BT_LUAC}, // Lua customizable

View file

@ -3874,24 +3874,24 @@ static boolean K_ShowPlayerNametag(player_t *p)
return true;
}
static void K_DrawLocalTagForPlayer(fixed_t x, fixed_t y, player_t *p, UINT8 id)
static void K_DrawLocalTagForPlayer(fixed_t x, fixed_t y, player_t *p, UINT8 id, UINT32 flags)
{
UINT8 blink = ((leveltime / 7) & 1);
UINT8 *colormap = R_GetTranslationColormap(TC_RAINBOW, static_cast<skincolornum_t>(p->skincolor), GTC_CACHE);
V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN, kp_localtag[id][blink], colormap);
V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_localtag[id][blink], colormap);
}
static void K_DrawRivalTagForPlayer(fixed_t x, fixed_t y)
static void K_DrawRivalTagForPlayer(fixed_t x, fixed_t y, UINT32 flags)
{
UINT8 blink = ((leveltime / 7) & 1);
V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN, kp_rival[blink], NULL);
V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_rival[blink], NULL);
}
static void K_DrawTypingDot(fixed_t x, fixed_t y, UINT8 duration, player_t *p, INT32 flags)
{
if (p->typing_duration > duration)
{
V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN|flags, kp_typdot, NULL);
V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_typdot, NULL);
}
}
@ -3913,8 +3913,19 @@ static void K_DrawNameTagItemSpy(INT32 x, INT32 y, player_t *p, INT32 flags)
{
using srb2::Draw;
bool tiny = r_splitscreen > 1;
SINT8 flip = 1, flipboxoffset = 0;
if ((flags & V_VFLIP) == V_VFLIP)
{
// Remove the v_vflip flag - it makes things messy, but we also understand
// that we want to make this look okay for flipped players, so simply use this
// opportunity to flip vertical offsets accordingly instead.
flags &= ~V_VFLIP;
flip = P_MobjFlip(p->mo);
flipboxoffset = 8;
}
Draw bar = Draw(x, y).flags(V_NOSCALESTART|flags);
Draw box = tiny ? bar.xy(-22 * vid.dupx, -17 * vid.dupy) : bar.xy(-40 * vid.dupx, -26 * vid.dupy);
Draw box = tiny ? bar.xy(-22 * vid.dupx, (-17+flipboxoffset) * vid.dupy) : bar.xy(-40 * vid.dupx, (-26+flipboxoffset) * vid.dupy);
box.colorize(p->skincolor).patch(kp_itembg[tiny ? 4 : 2]);
@ -3941,8 +3952,8 @@ static void K_DrawNameTagItemSpy(INT32 x, INT32 y, player_t *p, INT32 flags)
if (p->itemamount > 1)
{
(tiny ?
bar.xy(-3 * vid.dupx, -4 * vid.dupy).font(Draw::Font::kPing) :
bar.xy(-4 * vid.dupx, -2 * vid.dupy).font(Draw::Font::kThinTimer)
bar.xy(-3 * vid.dupx, (-4*flip) * vid.dupy).font(Draw::Font::kPing) :
bar.xy(-4 * vid.dupx, (-2*flip) * vid.dupy).font(Draw::Font::kThinTimer)
)
.align(Draw::Align::kRight)
.text("{}", p->itemamount);
@ -3988,6 +3999,13 @@ static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, INT32 flag
UINT8 *colormap = V_GetStringColormap(clr);
INT32 barx = 0, bary = 0, barw = 0;
INT32 flipped = P_MobjFlip(p->mo), flipfilloffset = 0, flipfontoffset = 0, flipspheresoffset = 0;
if (flipped == -1)
{
flipfilloffset = -3; // You cannot really flip drawfill.
flipfontoffset = -9; // Accounts for font height.
flipspheresoffset = 2;
}
UINT8 cnum = R_GetViewNumber();
@ -4010,7 +4028,7 @@ static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, INT32 flag
bary = (y * vid.dupy) / FRACUNIT;
barx += (6 * vid.dupx);
bary -= (16 * vid.dupx);
bary -= ((16 + flipfilloffset) * vid.dupx) * flipped;
// Center it if necessary
if (vid.width != BASEVIDWIDTH * vid.dupx)
@ -4031,7 +4049,7 @@ static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, INT32 flag
if (gametyperules & GTR_SPHERES)
{
K_DrawNameTagSphereMeter(barx, bary + (4 * vid.dupy), barw, p->spheres, flags);
K_DrawNameTagSphereMeter(barx, bary + (((4 + flipspheresoffset) * vid.dupy) * P_MobjFlip(p->mo)), barw, p->spheres, flags);
}
// Lat: 10/06/2020: colormap can be NULL on the frame you join a game, just arbitrarily use palette indexes 31 and 0 instead of whatever the colormap would give us instead to avoid crashes.
@ -4043,7 +4061,7 @@ static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, INT32 flag
V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_nametagstem, colormap);
// Draw the name itself
V_DrawThinStringAtFixed(x + (5*FRACUNIT), y - (26*FRACUNIT), clr|flags, player_names[p - players]);
V_DrawThinStringAtFixed(x + (5*FRACUNIT), y - (((26 + flipfontoffset) * FRACUNIT) * P_MobjFlip(p->mo)), clr|flags, player_names[p - players]);
}
playertagtype_t K_WhichPlayerTag(player_t *p)
@ -4073,19 +4091,25 @@ playertagtype_t K_WhichPlayerTag(player_t *p)
return PLAYERTAG_NONE;
}
void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, INT32 flags)
void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, boolean foreground)
{
INT32 flags = P_IsObjectFlipped(p->mo) ? V_VFLIP : 0;
switch (type)
{
case PLAYERTAG_LOCAL:
K_DrawLocalTagForPlayer(x, y, p, G_PartyPosition(p - players));
flags |= V_HUDTRANS|V_SPLITSCREEN;
K_DrawLocalTagForPlayer(x, y, p, G_PartyPosition(p - players), flags);
break;
case PLAYERTAG_RIVAL:
K_DrawRivalTagForPlayer(x, y);
flags |= V_HUDTRANS|V_SPLITSCREEN;
K_DrawRivalTagForPlayer(x, y, flags);
break;
case PLAYERTAG_NAME:
// We only care about the trans flag here (based?) as well as V_VFLIP.
flags |= foreground ? 0 : V_60TRANS;
K_DrawNameTagForPlayer(x, y, p, flags);
K_DrawTypingNotifier(x, y, p, flags);
break;
@ -4298,6 +4322,19 @@ static void K_drawKartProgressionMinimapIcon(UINT32 distancetofinish, INT32 hudx
V_DrawFixedPatch(hudx, hudy, FRACUNIT, flags, icon, colormap);
}
position_t K_GetKartObjectPosToMinimapPos(fixed_t objx, fixed_t objy)
{
fixed_t amnumxpos, amnumypos;
amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x);
amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y);
if (encoremode)
amnumxpos = -amnumxpos;
return (position_t){amnumxpos, amnumypos};
}
static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, patch_t *icon, UINT8 *colormap)
{
// amnum xpos & ypos are the icon's speed around the HUD.
@ -4306,35 +4343,27 @@ static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32
// am xpos & ypos are the icon's starting position. Withouht
// it, they wouldn't 'spawn' on the top-right side of the HUD.
fixed_t amnumxpos, amnumypos;
position_t amnumpos;
INT32 amxpos, amypos;
amnumpos = K_GetKartObjectPosToMinimapPos(objx, objy);
amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x);
amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y);
if (encoremode)
amnumxpos = -amnumxpos;
amxpos = amnumxpos + ((hudx - (SHORT(icon->width))/2)<<FRACBITS);
amypos = amnumypos + ((hudy - (SHORT(icon->height))/2)<<FRACBITS);
amxpos = amnumpos.x + ((hudx - (SHORT(icon->width))/2)<<FRACBITS);
amypos = amnumpos.y + ((hudy - (SHORT(icon->height))/2)<<FRACBITS);
V_DrawFixedPatch(amxpos, amypos, FRACUNIT, flags, icon, colormap);
}
static void K_drawKartMinimapDot(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, UINT8 color, UINT8 size)
{
fixed_t amnumxpos, amnumypos;
position_t amnumpos;
INT32 amxpos, amypos;
amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x);
amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y);
amnumpos = K_GetKartObjectPosToMinimapPos(objx, objy);
if (encoremode)
amnumxpos = -amnumxpos;
amxpos = (amnumxpos / FRACUNIT);
amypos = (amnumypos / FRACUNIT);
amxpos = (amnumpos.x / FRACUNIT);
amypos = (amnumpos.y / FRACUNIT);
if (flags & V_NOSCALESTART)
{
@ -4397,6 +4426,50 @@ static void K_drawKartMinimapWaypoint(waypoint_t *wp, UINT8 rank, INT32 hudx, IN
K_drawKartMinimapDot(wp->mobj->x, wp->mobj->y, hudx, hudy, flags | V_NOSCALESTART, pal, size);
}
INT32 K_GetMinimapTransFlags(const boolean usingProgressBar)
{
INT32 minimaptrans = 4;
boolean dofade = (usingProgressBar && r_splitscreen > 0) || (!usingProgressBar && r_splitscreen >= 1);
if (dofade)
{
minimaptrans = FixedMul(minimaptrans, (st_translucency * FRACUNIT) / 10);
// If the minimap is fully transparent, just get your 0 back. Bail out with this.
if (!minimaptrans)
return minimaptrans;
}
minimaptrans = ((10-minimaptrans)<<V_ALPHASHIFT);
return minimaptrans;
}
INT32 K_GetMinimapSplitFlags(const boolean usingProgressBar)
{
INT32 splitflags = 0;
if (usingProgressBar)
splitflags = (V_SLIDEIN|V_SNAPTOBOTTOM);
else
{
if (r_splitscreen < 1) // 1P right aligned
{
splitflags = (V_SLIDEIN|V_SNAPTORIGHT);
}
else // 2/4P splits
{
if (r_splitscreen == 1)
splitflags = V_SNAPTORIGHT; // 2P right aligned
// 3P lives in the middle of the bottom right
// viewport and shouldn't fade in OR slide
}
}
return splitflags;
}
#define ICON_DOT_RADIUS (10)
static void K_drawKartMinimap(void)
@ -4406,8 +4479,8 @@ static void K_drawKartMinimap(void)
INT32 i = 0;
INT32 x, y;
INT32 minimaptrans = 4;
INT32 splitflags = 0;
INT32 minimaptrans;
INT32 splitflags;
UINT8 skin = 0;
UINT8 *colormap = NULL;
@ -4420,7 +4493,7 @@ static void K_drawKartMinimap(void)
fixed_t interpx, interpy;
boolean doprogressionbar = false;
boolean dofade = false, doencore = false;
boolean doencore = false;
UINT8 minipal;
@ -4441,6 +4514,11 @@ static void K_drawKartMinimap(void)
// distancetofinish for an arbitrary object. ~toast 070423
doprogressionbar = true;
}
minimaptrans = K_GetMinimapTransFlags(doprogressionbar);
if (!minimaptrans) return; // Exit early if it wouldn't draw anyway.
splitflags = K_GetMinimapSplitFlags(doprogressionbar);
if (doprogressionbar == false)
{
@ -4449,20 +4527,6 @@ static void K_drawKartMinimap(void)
return; // no pic, just get outta here
}
else if (r_splitscreen < 1) // 1P right aligned
{
splitflags = (V_SLIDEIN|V_SNAPTORIGHT);
}
else // 2/4P splits
{
if (r_splitscreen == 1)
splitflags = V_SNAPTORIGHT; // 2P right aligned
dofade = true;
}
// 3P lives in the middle of the bottom right
// viewport and shouldn't fade in OR slide
x = MINI_X;
y = MINI_Y;
@ -4477,27 +4541,15 @@ static void K_drawKartMinimap(void)
if (r_splitscreen > 0)
{
y = BASEVIDHEIGHT/2;
dofade = true;
}
else
{
y = 180;
splitflags = (V_SLIDEIN|V_SNAPTOBOTTOM);
}
workingPic = kp_wouldyoustillcatchmeifiwereaworm;
}
if (dofade)
{
minimaptrans = FixedMul(minimaptrans, (st_translucency * FRACUNIT) / 10);
if (!minimaptrans)
return;
}
minimaptrans = ((10-minimaptrans)<<V_ALPHASHIFT);
// Really looking forward to never writing this loop again
UINT8 bestplayer = MAXPLAYERS;
for (i = 0; i < MAXPLAYERS; i++)

View file

@ -25,6 +25,8 @@ extern "C" {
#define POS_DELAY_TIME 10
extern INT32 MINI_X, MINI_Y;
struct trackingResult_t
{
fixed_t x, y;
@ -34,6 +36,11 @@ struct trackingResult_t
fixed_t fov;
};
typedef struct position_t
{
fixed_t x, y;
} position_t;
void K_ObjectTracking(trackingResult_t *result, const vector3_t *point, boolean reverse);
tic_t K_TranslateTimer(tic_t drawtime, UINT8 mode, INT32 *return_jitter);
@ -116,7 +123,11 @@ typedef enum
playertagtype_t;
playertagtype_t K_WhichPlayerTag(player_t *p);
void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, INT32 flags);
void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, boolean foreground);
INT32 K_GetMinimapTransFlags(const boolean usingProgressBar);
INT32 K_GetMinimapSplitFlags(const boolean usingProgressBar);
position_t K_GetKartObjectPosToMinimapPos(fixed_t objx, fixed_t objy);
#ifdef __cplusplus
} // extern "C"

View file

@ -466,7 +466,7 @@ void K_DrawTargetTracking(const TargetTracking& target)
{
if (target.nametag != PLAYERTAG_NONE)
{
K_DrawPlayerTag(target.result.x, target.result.y, target.mobj->player, target.nametag, target.foreground ? 0 : V_60TRANS);
K_DrawPlayerTag(target.result.x, target.result.y, target.mobj->player, target.nametag, target.foreground);
return;
}

View file

@ -8787,12 +8787,20 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
// GROSS. In order to have a transparent version of this for a splitscreen local player, we actually need to spawn two!
for (doubler = 0; doubler < 2; doubler++)
{
fixed_t heightOffset = player->mo->height + (24*player->mo->scale);
if (P_IsObjectFlipped(player->mo))
{
// This counteracts the offset added by K_FlipFromObject so it looks seamless from non-flipped.
heightOffset += player->mo->height - FixedMul(player->mo->scale, player->mo->height);
heightOffset *= P_MobjFlip(player->mo); // Fleep.
}
mobj_t *debtflag = P_SpawnMobj(player->mo->x + player->mo->momx, player->mo->y + player->mo->momy,
player->mo->z + P_GetMobjZMovement(player->mo) + player->mo->height + (24*player->mo->scale), MT_THOK);
player->mo->z + P_GetMobjZMovement(player->mo) + heightOffset, MT_THOK);
debtflag->old_x = player->mo->old_x;
debtflag->old_y = player->mo->old_y;
debtflag->old_z = player->mo->old_z + P_GetMobjZMovement(player->mo) + player->mo->height + (24*player->mo->scale);
debtflag->old_z = player->mo->old_z + P_GetMobjZMovement(player->mo) + heightOffset;
P_SetMobjState(debtflag, S_RINGDEBT);
P_SetScale(debtflag, (debtflag->destscale = player->mo->scale));
@ -9440,6 +9448,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
for(i = 0;i < 5;i++)
{
mobj_t *aura = P_SpawnMobjFromMobj(player->mo, 0, 0, player->mo->height/2, MT_CHARGEAURA);
aura->eflags &= ~MFE_VERTICALFLIP;
aura->angle = player->mo->angle + i*ANG15;
P_SetTarget(&aura->target, player->mo);
if (i == 0)
@ -11821,7 +11830,7 @@ void K_KartEbrakeVisuals(player_t *p)
{
if (p->ebrakefor % 20 == 0)
{
wave = P_SpawnMobj(p->mo->x, p->mo->y, p->mo->floorz, MT_SOFTLANDING);
wave = P_SpawnMobj(p->mo->x, p->mo->y, P_GetMobjGround(p->mo), MT_SOFTLANDING);
P_InstaScale(wave, p->mo->scale);
P_SetTarget(&wave->target, p->mo);
P_SetTarget(&wave->owner, p->mo);
@ -13481,6 +13490,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
if (player->curshield != KSHIELD_BUBBLE)
{
mobj_t *shield = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_BUBBLESHIELD);
// MT_BUBBLESHIELD doesn't have MF_NOBLOCKMAP so we need to remove this manually.
// Otherwise if you roll a bubble shield while flipped, the visuals look too mismatched.
shield->eflags &= ~MFE_VERTICALFLIP;
P_SetScale(shield, (shield->destscale = (5*shield->destscale)>>2));
P_SetTarget(&shield->target, player->mo);
S_StartSound(player->mo, sfx_s3k3f);
@ -13829,7 +13841,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
// debug shit
//CONS_Printf("%d\n", player->mo->momz / mapobjectscale);
if (momz < -10*FRACUNIT) // :youfuckedup:
if (momz * P_MobjFlip(player->mo) < -10*FRACUNIT) // :youfuckedup:
{
// tumble if you let your chance pass!!
player->tumbleBounces = 1;

View file

@ -2981,6 +2981,54 @@ static int lib_gTicsToMilliseconds(lua_State *L)
return 1;
}
// K_HUD
////////////
static int lib_kAddMessage(lua_State *L)
{
const char *msg = luaL_checkstring(L, 1);
boolean interrupt = lua_optboolean(L, 2);
boolean persist = lua_optboolean(L, 3);
INLEVEL
if (msg == NULL)
return luaL_error(L, "argument #1 not given (expected string)");
K_AddMessage(msg, interrupt, persist);
return 0;
}
static int lib_kAddMessageForPlayer(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
const char *msg = luaL_checkstring(L, 2);
boolean interrupt = lua_optboolean(L, 3);
boolean persist = lua_optboolean(L, 4);
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
if (msg == NULL)
return luaL_error(L, "argument #2 not given (expected string)");
K_AddMessageForPlayer(player, msg, interrupt, persist);
return 0;
}
static int lib_kClearPersistentMessages(lua_State *L)
{
INLEVEL
K_ClearPersistentMessages();
lua_pushnil(L);
return 0;
}
static int lib_kClearPersistentMessageForPlayer(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
K_ClearPersistentMessageForPlayer(player);
return 0;
}
// K_KART
////////////
@ -3815,6 +3863,12 @@ static luaL_Reg lib[] = {
{"G_TicsToMilliseconds",lib_gTicsToMilliseconds},
{"getTimeMicros",lib_getTimeMicros},
// k_hud
{"K_AddMessage", lib_kAddMessage},
{"K_AddMessageForPlayer", lib_kAddMessageForPlayer},
{"K_ClearPersistentMessages", lib_kClearPersistentMessages},
{"K_ClearPersistentMessageForPlayer", lib_kClearPersistentMessageForPlayer},
// k_kart
{"K_PlayAttackTaunt", lib_kAttackSound},
{"K_PlayBoostTaunt", lib_kBoostSound},

View file

@ -26,6 +26,7 @@
#include "w_wad.h"
#include "z_zone.h"
#include "hu_stuff.h"
#include "k_hud.h"
#include "lua_script.h"
#include "lua_libs.h"
@ -575,6 +576,7 @@ static int libd_drawStretched(lua_State *L)
// KART: draw patch on minimap from x, y coordinates on the map
// Sal: Let's please just merge the relevant info into the actual function, and have Lua call that...
// JugadorXEI: hey, sure.
static int libd_drawOnMinimap(lua_State *L)
{
fixed_t x, y, scale; // coordinates of the object
@ -585,22 +587,12 @@ static int libd_drawOnMinimap(lua_State *L)
// variables used to replicate k_kart's mmap drawer:
patch_t *AutomapPic;
INT32 mx, my;
INT32 splitflags, minimaptrans;
// base position of the minimap which also takes splits into account:
INT32 MM_X, MM_Y;
// variables used for actually drawing the icon:
fixed_t amnumxpos, amnumypos;
INT32 amxpos, amypos;
node_t *bsp = &nodes[numnodes-1];
fixed_t maxx, minx, maxy, miny;
fixed_t mapwidth, mapheight;
fixed_t xoffset, yoffset;
fixed_t xscale, yscale, zoom;
position_t amnumpos;
INT32 minimapflags;
fixed_t amxpos, amypos;
INT32 mm_x, mm_y;
fixed_t patchw, patchh;
HUDONLY // only run this function in hud hooks
@ -611,56 +603,7 @@ static int libd_drawOnMinimap(lua_State *L)
if (!lua_isnoneornil(L, 5))
colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP));
centered = lua_optboolean(L, 6);
// replicate exactly what source does for its minimap drawer; AKA hardcoded garbo.
// first, check what position the mmap is supposed to be in (pasted from k_kart.c):
MM_X = BASEVIDWIDTH - 50; // 270
MM_Y = (BASEVIDHEIGHT/2)-16; // 84
if (r_splitscreen)
{
MM_Y = (BASEVIDHEIGHT/2);
if (r_splitscreen > 1) // 3P : bottom right
{
MM_X = (3*BASEVIDWIDTH/4);
MM_Y = (3*BASEVIDHEIGHT/4);
if (r_splitscreen > 2) // 4P: centered
{
MM_X = (BASEVIDWIDTH/2);
MM_Y = (BASEVIDHEIGHT/2);
}
}
}
// splitscreen flags
splitflags = (r_splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split)
{
const tic_t length = TICRATE/2;
if (!lt_exitticker)
return 0;
minimaptrans = 4;
if (lt_exitticker < length)
minimaptrans = (((INT32)lt_exitticker)*minimaptrans)/((INT32)length);
if (!minimaptrans)
return 0;
}
minimaptrans = ((10-minimaptrans)<<FF_TRANSSHIFT);
splitflags |= minimaptrans;
if (!(r_splitscreen == 2))
{
splitflags &= ~minimaptrans;
splitflags |= V_HUDTRANSHALF;
}
splitflags &= ~V_HUDTRANSHALF;
splitflags |= V_HUDTRANS;
// Draw the HUD only when playing in a level.
// hu_stuff needs this, unlike st_stuff.
if (gamestate != GS_LEVEL)
@ -668,79 +611,40 @@ static int libd_drawOnMinimap(lua_State *L)
if (R_GetViewNumber() != 0)
return 0;
AutomapPic = mapheaderinfo[gamemap-1]->minimapPic;
AutomapPic = minimapinfo.minimap_pic;
if (!AutomapPic)
{
return 0; // no pic, just get outta here
}
mx = MM_X - (AutomapPic->width/2);
my = MM_Y - (AutomapPic->height/2);
// let offsets transfer to the heads, too!
// Handle offsets and stuff.
mm_x = MINI_X;
mm_y = MINI_Y - SHORT(AutomapPic->topoffset);
if (encoremode)
mx += SHORT(AutomapPic->leftoffset);
{
mm_x += SHORT(AutomapPic->leftoffset);
}
else
mx -= SHORT(AutomapPic->leftoffset);
my -= SHORT(AutomapPic->topoffset);
{
mm_x -= SHORT(AutomapPic->leftoffset);
}
// now that we have replicated this behavior, we can draw an icon from our supplied x, y coordinates by replicating k_kart.c's totally understandable uncommented code!!!
// get map boundaries using nodes
maxx = maxy = INT32_MAX;
minx = miny = INT32_MIN;
minx = bsp->bbox[0][BOXLEFT];
maxx = bsp->bbox[0][BOXRIGHT];
miny = bsp->bbox[0][BOXBOTTOM];
maxy = bsp->bbox[0][BOXTOP];
if (bsp->bbox[1][BOXLEFT] < minx)
minx = bsp->bbox[1][BOXLEFT];
if (bsp->bbox[1][BOXRIGHT] > maxx)
maxx = bsp->bbox[1][BOXRIGHT];
if (bsp->bbox[1][BOXBOTTOM] < miny)
miny = bsp->bbox[1][BOXBOTTOM];
if (bsp->bbox[1][BOXTOP] > maxy)
maxy = bsp->bbox[1][BOXTOP];
// You might be wondering why these are being bitshift here
// it's because mapwidth and height would otherwise overflow for maps larger than half the size possible...
// map boundaries and sizes will ALWAYS be whole numbers thankfully
// later calculations take into consideration that these are actually not in terms of FRACUNIT though
minx >>= FRACBITS;
maxx >>= FRACBITS;
miny >>= FRACBITS;
maxy >>= FRACBITS;
// these are our final map boundaries:
mapwidth = maxx - minx;
mapheight = maxy - miny;
// These should always be small enough to be bitshift back right now
xoffset = (minx + mapwidth/2)<<FRACBITS;
yoffset = (miny + mapheight/2)<<FRACBITS;
xscale = FixedDiv(AutomapPic->width, mapwidth);
yscale = FixedDiv(AutomapPic->height, mapheight);
zoom = FixedMul(min(xscale, yscale), FRACUNIT-FRACUNIT/20);
amnumxpos = (FixedMul(x, zoom) - FixedMul(xoffset, zoom));
amnumypos = -(FixedMul(y, zoom) - FixedMul(yoffset, zoom));
if (encoremode)
amnumxpos = -amnumxpos;
// Minimap flags:
minimapflags = K_GetMinimapSplitFlags(false)|K_GetMinimapTransFlags(false);
// scale patch coords
patchw = patch->width*scale /2;
patchh = patch->height*scale /2;
patchw = (SHORT(patch->width) / 2) * scale;
patchh = (SHORT(patch->height) / 2) * scale;
if (centered)
patchw = patchh = 0; // patch is supposedly already centered, don't butt in.
amxpos = amnumxpos + ((mx + AutomapPic->width/2)<<FRACBITS) - patchw;
amypos = amnumypos + ((my + AutomapPic->height/2)<<FRACBITS) - patchh;
amnumpos = K_GetKartObjectPosToMinimapPos(x, y);
amxpos = amnumpos.x + (mm_x<<FRACBITS) - patchw;
amypos = amnumpos.y + (mm_y<<FRACBITS) - patchh;
// and NOW we can FINALLY DRAW OUR GOD DAMN PATCH :V
lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
@ -748,9 +652,9 @@ static int libd_drawOnMinimap(lua_State *L)
lua_pop(L, 1);
if (LUA_HUD_IsDrawListValid(list))
LUA_HUD_AddDrawScaled(list, amxpos, amypos, scale, patch, splitflags, colormap);
LUA_HUD_AddDrawScaled(list, amxpos, amypos, scale, patch, minimapflags, colormap);
else
V_DrawFixedPatch(amxpos, amypos, scale, splitflags, patch, colormap);
V_DrawFixedPatch(amxpos, amypos, scale, minimapflags, patch, colormap);
return 0;
}

View file

@ -300,6 +300,8 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->gateBoost);
else if (fastcmp(field,"gatesound"))
lua_pushinteger(L, plr->gateSound);
else if (fastcmp(field,"startboost"))
lua_pushinteger(L, plr->startboost);
else if (fastcmp(field,"aizdriftstraft"))
lua_pushinteger(L, plr->aizdriftstrat);
else if (fastcmp(field,"aizdriftextend"))
@ -876,6 +878,8 @@ static int player_set(lua_State *L)
plr->gateBoost = luaL_checkinteger(L, 3);
else if (fastcmp(field,"gatesound"))
plr->gateSound = luaL_checkinteger(L, 3);
else if (fastcmp(field,"startboost"))
plr->startboost = luaL_checkinteger(L, 3);
else if (fastcmp(field,"aizdriftstraft"))
plr->aizdriftstrat = luaL_checkinteger(L, 3);
else if (fastcmp(field,"aizdrifttilt"))

View file

@ -111,7 +111,10 @@ sine_bob
fixed_t sineofs)
{
hyu->sprzoff = FixedMul(HYU_VISUAL_HEIGHT * hyu->scale,
sineofs + FINESINE(a >> ANGLETOFINESHIFT));
sineofs + FINESINE(a >> ANGLETOFINESHIFT)) * P_MobjFlip(hyu);
if (P_IsObjectFlipped(hyu))
hyu->sprzoff -= hyu->height;
}
static void
@ -155,11 +158,6 @@ project_hyudoro (mobj_t *hyu)
hyu->z = P_GetZAt(center->standingslope, hyu->x, hyu->y,
P_GetMobjGround(center));
if (P_IsObjectFlipped(hyu))
{
hyu->z -= hyu->height;
}
}
static void

View file

@ -17,6 +17,7 @@
#include "../p_local.h"
#include "../p_mobj.h"
#include "../tables.h"
#include "../k_kart.h"
// copied from objects/monitor.c
#define FINE90 (FINEANGLES/4)
@ -91,8 +92,11 @@ struct Aura : mobj_t
{
return;
}
K_FlipFromObject(this, origin());
fixed_t flipoffset = P_IsObjectFlipped(origin()) ? origin()->height : 0;
P_MoveOrigin(this, origin()->x, origin()->y, origin()->z);
P_MoveOrigin(this, origin()->x, origin()->y, origin()->z - flipoffset);
P_InstaScale(this, 11 * origin()->scale / 10);
translate();

View file

@ -28,11 +28,19 @@ void Obj_ServantHandSpawning(player_t *player)
{
player->handtimer++;
if (player->hand == NULL && player->handtimer == TICRATE)
{
{
fixed_t heightOffset = player->mo->height + 30*mapobjectscale;
if (P_IsObjectFlipped(player->mo))
{
// This counteracts the offset added by K_FlipFromObject so it looks seamless from non-flipped.
heightOffset += player->mo->height - FixedMul(player->mo->scale, player->mo->height);
heightOffset *= P_MobjFlip(player->mo); // Fleep.
}
mobj_t *hand = P_SpawnMobj(
player->mo->x,
player->mo->y,
player->mo->z + player->mo->height + 30*mapobjectscale,
player->mo->z + heightOffset,
MT_SERVANTHAND
);
@ -115,13 +123,17 @@ void Obj_ServantHandThink(mobj_t *hand)
{
hand->color = player->skincolor;
hand->angle = player->besthanddirection;
fixed_t heightOffset = player->mo->height + 30*mapobjectscale;
if (P_IsObjectFlipped(player->mo))
heightOffset *= P_MobjFlip(player->mo); // Fleep.
K_FlipFromObject(hand, player->mo);
P_MoveOrigin(hand,
player->mo->x + xoffs,
player->mo->y + yoffs,
player->mo->z + player->mo->height + 30*mapobjectscale
player->mo->z + heightOffset
);
K_FlipFromObject(hand, player->mo);
hand->sprzoff = player->mo->sprzoff;

View file

@ -93,7 +93,10 @@ sine_bob
// slightly modified from objects/hyudoro.c
hyu->sprzoff = FixedMul(kBobHeight,
sineofs + FINESINE(a >> ANGLETOFINESHIFT));
sineofs + FINESINE(a >> ANGLETOFINESHIFT)) * P_MobjFlip(hyu);
if (P_IsObjectFlipped(hyu))
hyu->sprzoff -= hyu->height;
}
void
@ -303,6 +306,7 @@ struct Flicky : mobj_t
color = super_color();
}
K_FlipFromObject(this, source());
bob_in_place(this, phase() * 8, 32);
}

View file

@ -8355,6 +8355,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
P_SetScale(mobj, (mobj->destscale = (5*mobj->target->scale)>>2));
P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z + mobj->target->height/2);
// Taken from K_FlipFromObject. We just want to flip the visual according to its target, but that's it.
mobj->eflags = (mobj->eflags & ~MFE_VERTICALFLIP)|(mobj->target->eflags & MFE_VERTICALFLIP);
break;
}
case MT_BUBBLESHIELD:
@ -8460,9 +8463,15 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
mobj->extravalue2 = mobj->target->player->bubbleblowup;
P_SetScale(mobj, (mobj->destscale = scale));
// For some weird reason, the Bubble Shield is the exception flip-wise, it has the offset baked into the sprite.
// So instead of simply flipping the object, we have to do a position offset.
fixed_t positionOffset = 0;
if (P_IsObjectFlipped(mobj->target))
positionOffset -= 8 * mobj->scale;
mobj->flags &= ~(MF_NOCLIPTHING);
P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z);
P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z + positionOffset);
mobj->flags |= MF_NOCLIPTHING;
break;
}
@ -8550,6 +8559,8 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
}
}
// Taken from K_FlipFromObject. We just want to flip the visual according to its target, but that's it.
mobj->eflags = (mobj->eflags & ~MFE_VERTICALFLIP)|(mobj->target->eflags & MFE_VERTICALFLIP);
P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z + mobj->target->height/2);
mobj->angle = K_MomentumAngle(mobj->target);
@ -10578,8 +10589,8 @@ void P_SceneryThinker(mobj_t *mobj)
if (!P_MobjWasRemoved(mobj->target))
{
// Cast like a shadow on the ground
P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->floorz);
mobj->standingslope = mobj->target->standingslope;
P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, P_GetMobjGround(mobj->target));
mobj->standingslope = P_IsObjectOnGround(mobj->target) ? mobj->target->standingslope : NULL;
if (!P_IsObjectOnGround(mobj->target) && mobj->target->momz < -24 * mapobjectscale)
{