diff --git a/src/d_main.cpp b/src/d_main.cpp index 94e7a33d0..03f02ac2e 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -94,7 +94,7 @@ #define ASSET_HASH_TEXTURES_KART 0xb4211b2f32b6a291 #define ASSET_HASH_CHARS_KART 0x1e68a3e01aa5c68b #define ASSET_HASH_MAPS_KART 0x38558ed00da41ce9 -#define ASSET_HASH_MAIN_PK3 0x92477cf651c45063 +#define ASSET_HASH_MAIN_PK3 0x22734e65763c2939 #define ASSET_HASH_MAPPATCH_PK3 0x0afd8afc6fc50175 #define ASSET_HASH_BONUSCHARS_KART 0x60e6f13d822a7461 #ifdef USE_PATCH_FILE @@ -1661,6 +1661,8 @@ void D_SRB2Main(void) M_InitPlayerSetupColors(); + K_ReloadHUDColorCvar(); + // Do it before P_InitMapData because PNG patch // conversion sometimes needs the palette V_ReloadPalette(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 24e09a529..9791e1ed8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -168,6 +168,7 @@ static void KartSlipdash_OnChange(void); static void KartSlopeBoost_OnChange(void); static void KartDrafting_OnChange(void); static void KartAirDrop_OnChange(void); +static void KartAirThrust_OnChange(void); static void KartItemLitter_OnChange(void); static void KartItemPush_OnChange(void); static void KartAntiBump_OnChange(void); @@ -567,6 +568,13 @@ consvar_t cv_kartdrafting_basedistance = CVAR_INIT ("kartdrafting_basedistance", consvar_t cv_kartairdrop = CVAR_INIT ("kartairdrop", "No", CV_NETVAR|CV_CALL|CV_NOINIT|CV_GUARD, CV_YesNo, KartAirDrop_OnChange); +consvar_t cv_kartairthrust = CVAR_INIT ("kartairthrust", "Off", CV_NETVAR|CV_CALL|CV_NOINIT|CV_GUARD, CV_OnOff, KartAirThrust_OnChange); +consvar_t cv_kartairthrust_reductionrate = CVAR_INIT ("kartairthrust_reductionrate", "0.5", CV_NETVAR|CV_FLOAT|CV_CHEAT|CV_GUARD, CV_Unsigned, NULL); +consvar_t cv_kartairthrust_power1 = CVAR_INIT ("kartairthrust_power1", "0.2", CV_NETVAR|CV_FLOAT|CV_CHEAT|CV_GUARD, CV_Unsigned, NULL); +consvar_t cv_kartairthrust_power2 = CVAR_INIT ("kartairthrust_power2", "0.35", CV_NETVAR|CV_FLOAT|CV_CHEAT|CV_GUARD, CV_Unsigned, NULL); +consvar_t cv_kartairthrust_power3 = CVAR_INIT ("kartairthrust_power3", "0.5", CV_NETVAR|CV_FLOAT|CV_CHEAT|CV_GUARD, CV_Unsigned, NULL); +consvar_t cv_kartairthrust_power4 = CVAR_INIT ("kartairthrust_power4", "0.75", CV_NETVAR|CV_FLOAT|CV_CHEAT|CV_GUARD, CV_Unsigned, NULL); + consvar_t cv_kartitemlitter = CVAR_INIT ("kartitemlitter", "On", CV_NETVAR|CV_CALL|CV_NOINIT, CV_OnOff, KartItemLitter_OnChange); consvar_t cv_kartitempush = CVAR_INIT ("kartitempush", "Off", CV_NETVAR|CV_CALL|CV_NOINIT, CV_OnOff, KartItemPush_OnChange); @@ -8099,11 +8107,44 @@ static void KartAirDrop_OnChange(void) if (leveltime < starttime) { airdropactive = false; - CONS_Printf(M_GetText("Drafting has been turned \"Off\".\n")); + CONS_Printf(M_GetText("Air Drop has been turned \"Off\".\n")); } else { - CONS_Printf(M_GetText("Drafting will be turned \"Off\" next round.\n")); + CONS_Printf(M_GetText("Air Drop will be turned \"Off\" next round.\n")); + } + } +} + +static void KartAirThrust_OnChange(void) +{ + if (K_CanChangeRules(false) == false) + { + return; + } + + if (!K_AirThrustActive() && cv_kartairthrust.value) + { + if (leveltime < starttime) + { + airthrustactive = true; + CONS_Printf(M_GetText("Air Thrust has been turned \"On\".\n")); + } + else + { + CONS_Printf(M_GetText("Air Thrust will be turned \"On\" Next Round.\n")); + } + } + else if (K_AirThrustActive() && !cv_kartairthrust.value) + { + if (leveltime < starttime) + { + airthrustactive = false; + CONS_Printf(M_GetText("Air Thrust has been turned \"Off\".\n")); + } + else + { + CONS_Printf(M_GetText("Air Thrust will be turned \"Off\" next round.\n")); } } } diff --git a/src/d_netcmd.h b/src/d_netcmd.h index eee52d485..531d7b89a 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -195,6 +195,13 @@ extern consvar_t cv_kartairsquish; extern consvar_t cv_kartairdrop; +extern consvar_t cv_kartairthrust; +extern consvar_t cv_kartairthrust_reductionrate; +extern consvar_t cv_kartairthrust_power1; +extern consvar_t cv_kartairthrust_power2; +extern consvar_t cv_kartairthrust_power3; +extern consvar_t cv_kartairthrust_power4; + extern consvar_t cv_kartitemlitter, cv_kartitempush; extern consvar_t cv_kartantibump; diff --git a/src/d_player.h b/src/d_player.h index 8722eb700..464846045 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -563,9 +563,10 @@ struct player_t SINT8 driftlock; // Prevents you from using drift angle for x tics. Used for zipper fix. fixed_t driftcharge; // Charge your drift so you can release a burst of speed UINT8 driftboost; // (0 to 125) - Boost you get from drifting - tic_t driftsparkGrowTimer; - tic_t driftelapsed; // Elapsed time spent during a drift. - SINT8 driftlevel; // just for controller rumble for now + fixed_t airdriftspeed; // target velocity to reduce player velocity to while air trusting + tic_t driftsparkGrowTimer; // CLIENT ONLY - + tic_t driftelapsed; // CLIENT ONLY - Elapsed time spent during a drift. + SINT8 driftlevel; // CLIENT ONLY - handles controller rumble and air thrust power, cleared at the start of every tick. fixed_t spinoutrot; // When a player spins out, this value increments modulus 360. diff --git a/src/deh_tables.c b/src/deh_tables.c index 19696625d..9d9705bf7 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -1565,6 +1565,12 @@ struct int_const_s const INT_CONST[] = { {"KSHIELD_FLAME",KSHIELD_FLAME}, {"NUMKARTSHIELDS",NUMKARTSHIELDS}, + // kartitemequip_e + {"KITEMEQUIP_NONE",KITEMEQUIP_NONE}, + {"KITEMEQUIP_ORBIT",KITEMEQUIP_ORBIT}, + {"KITEMEQUIP_TRAIL",KITEMEQUIP_TRAIL}, + {"KITEMEQUIP_ROCKETS",KITEMEQUIP_ROCKETS}, + // kartroulettetype_e {"KROULETTETYPE_NORMAL",KROULETTETYPE_NORMAL}, {"KROULETTETYPE_KARMA",KROULETTETYPE_KARMA}, diff --git a/src/k_hud.c b/src/k_hud.c index 7fa5d321c..93129fada 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1402,7 +1402,7 @@ static void K_drawKartItem(void) V_DrawString(fx+24, fy+31, V_ALLOWLOWERCASE|V_HUDTRANS|fflags, va("x%d", stplyr->itemamount)); else { - V_DrawScaledPatch(fy+28, fy+41, V_HUDTRANS|fflags, kp_itemx); + V_DrawScaledPatch(fx+28, fy+41, V_HUDTRANS|fflags, kp_itemx); V_DrawKartString(fx+38, fy+36, V_HUDTRANS|fflags, va("%d", stplyr->itemamount)); } } @@ -2346,10 +2346,12 @@ static void K_DrawServerMods(INT32 x, INT32 y) {"Slope Boost", 0, NULL, K_PurpleDriftActive() > 0, true}, {"Drafting", 0, NULL, K_DraftingActive() > 0, true}, {"Air Drop", 0, NULL, K_AirDropActive() > 0, true}, + {"Air Thrust", 0, NULL, K_AirThrustActive() > 0, true}, {"Bump Spark", 0, &cv_kartbumpspark, -1, true}, {"Bump Drift", 0, NULL, K_GetBumpSpark() > 0, true}, {"Bump Spark", 0, NULL, K_GetBumpSpark() > BUMPSPARK_NOCHARGE, true}, {"Bump Spring", 0, &cv_kartbumpspring, -1, true}, + //TODO: separate drawer that enumerates item changes? {"Alt. Invin.", 0, NULL, K_IsKartItemAlternate(KITEM_INVINCIBILITY), true} }; @@ -2643,7 +2645,8 @@ static void K_drawKartStatsnLives(void) // Lives if (LUA_HudEnabled(hud_lives) && uselives) { - UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, K_GetHudColor(), GTC_CACHE); + // We specify stplyr->skincolor since we want it to match the player and not the hud color. + UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->skincolor, GTC_CACHE); patch_t *mmappatch = faceprefix[stplyr->skin][FACE_MINIMAP]; V_DrawMappedPatch(fx+21+mmappatch->leftoffset, fy-13+mmappatch->topoffset, V_HUDTRANS|splitflags, mmappatch, colormap); @@ -2672,7 +2675,8 @@ static void K_drawKartStatsnLives(void) } } - UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, K_GetHudColor(), GTC_CACHE); + // We specify stplyr->skincolor since we want it to match the player and not the hud color. + UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->skincolor, GTC_CACHE); patch_t *facerank = faceprefix[stplyr->skin][FACE_RANK]; V_DrawMappedPatch(fx+59+offsetx+facerank->leftoffset, fy-16+offsety+facerank->topoffset, V_HUDTRANS|splitflags, facerank, colormap); if (stplyr->lives >= 0 && uselives) diff --git a/src/k_items.c b/src/k_items.c index c55e973e2..a8f8685ae 100644 --- a/src/k_items.c +++ b/src/k_items.c @@ -2431,3 +2431,27 @@ void K_AltShrinkPityIncrease(player_t *player) player->growshrinktimer = ((INT16)shrinktime) * -1; } + +// this shit is so ass 🥲 +kartitemequip_e K_GetItemEquipStyle(mobjtype_t mobjtype) +{ + //TODO: lua hook to use any of these for a given mobj + // if we could use tables or dicts I'd use those insteasd + switch (mobjtype) + { + case MT_ORBINAUT_SHIELD: + case MT_JAWZ_SHIELD: + return KITEMEQUIP_ORBIT; + case MT_BANANA_SHIELD: + case MT_SSMINE_SHIELD: + case MT_EGGMANITEM_SHIELD: + case MT_SINK_SHIELD: + return KITEMEQUIP_TRAIL; + case MT_ROCKETSNEAKER: + return KITEMEQUIP_ROCKETS; + default: + { + return LUA_HookGetItemEquipStyle(mobjtype); + } + } +} \ No newline at end of file diff --git a/src/k_items.h b/src/k_items.h index ed82bb042..811b748a5 100644 --- a/src/k_items.h +++ b/src/k_items.h @@ -43,6 +43,14 @@ typedef enum #define MAXKARTRESULTS 255 +typedef enum +{ + KITEMEQUIP_NONE, + KITEMEQUIP_ORBIT, // orbiters (orbi, jawz) + KITEMEQUIP_TRAIL, // dragged items (bananas, mines, sinks) + KITEMEQUIP_ROCKETS, // direct player position with offset (rockets) +} kartitemequip_e; + typedef enum { KITEMBLINK_NORMAL, @@ -211,6 +219,8 @@ void K_AltShrinkPityIncrease(player_t *player); void K_PlayerItemThink(player_t *player, boolean onground); +kartitemequip_e K_GetItemEquipStyle(mobjtype_t mobjtype); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/k_kart.c b/src/k_kart.c index ab92002ad..4e2a7e23c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -383,6 +383,13 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartslipdash); + CV_RegisterVar(&cv_kartairthrust); + CV_RegisterVar(&cv_kartairthrust_reductionrate); + CV_RegisterVar(&cv_kartairthrust_power1); + CV_RegisterVar(&cv_kartairthrust_power2); + CV_RegisterVar(&cv_kartairthrust_power3); + CV_RegisterVar(&cv_kartairthrust_power4); + CV_RegisterVar(&cv_kartslopeboost); CV_RegisterVar(&cv_kartaltshrinktime); @@ -2859,7 +2866,7 @@ fixed_t K_GetKartSpeed(const player_t *player, boolean doboostpower, boolean dor boolean karmabomb = ((gametyperules & GTR_BUMPERS) && player->bumper <= 0); fixed_t finalspeed; - if (doboostpower && !player->pogospring && !P_IsObjectOnGround(player->mo)) + if (doboostpower && !player->pogospring && !P_IsObjectOnGround(player->mo) && (player->airdriftspeed == 0)) return (75*mapobjectscale); // air speed cap finalspeed = K_GetKartSpeedFromStat(player->kartspeed, karmabomb); @@ -5571,9 +5578,11 @@ void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z, fixed } // Move the hnext chain! +//TODO: generalize further? static void K_MoveHeldObjects(player_t *player) { TryMoveResult_t result = {0}; + kartitemequip_e equipstyle = KITEMEQUIP_NONE; if (!player->mo) return; @@ -5607,10 +5616,11 @@ static void K_MoveHeldObjects(player_t *player) return; } - switch (player->mo->hnext->type) + equipstyle = K_GetItemEquipStyle(player->mo->hnext->type); + + switch (equipstyle) { - case MT_ORBINAUT_SHIELD: // Kart orbit items - case MT_JAWZ_SHIELD: + case KITEMEQUIP_ORBIT: // Kart orbit items { mobj_t *cur = player->mo->hnext; fixed_t speed = ((8 - min(4, player->itemamount)) * cur->info->speed) / 7; @@ -5686,10 +5696,7 @@ static void K_MoveHeldObjects(player_t *player) } } break; - case MT_BANANA_SHIELD: // Kart trailing items - case MT_SSMINE_SHIELD: - case MT_EGGMANITEM_SHIELD: - case MT_SINK_SHIELD: + case KITEMEQUIP_TRAIL: // Kart trailing items { mobj_t *cur = player->mo->hnext; mobj_t *curnext; @@ -5798,7 +5805,7 @@ static void K_MoveHeldObjects(player_t *player) } } break; - case MT_ROCKETSNEAKER: // Special rocket sneaker stuff + case KITEMEQUIP_ROCKETS: //TODO: generalize with customizable offsets (Special rocket sneaker stuff) { mobj_t *cur = player->mo->hnext; INT32 num = 0; @@ -8884,6 +8891,42 @@ static boolean K_AltInvinSliptideCondition(player_t *player) return (K_InvincibilityGradient(player->invincibilitytimer) > (FRACUNIT/2)); } +// Sliptide conditions for Alt. Shrink +static boolean K_AltShrinkSliptideCondition(player_t *player) +{ + if (!(K_IsAltShrunk(player))) + { + // Not Alt. Shrunk! + return false; + } + + const fixed_t speedPercent = FixedDiv(player->speed, K_GetKartSpeed(player, false, false)); + + // Allow sliptides if you're moving above 125% speed. + return (speedPercent > (5 * FRACUNIT / 4)); +} + +static void K_HandleAirDriftDrag(player_t *player, boolean onground) +{ + if (onground && player->airdriftspeed > 0) + { + player->airdriftspeed = 0; + } + fixed_t difference; + if (player->mo && player->airdriftspeed > 0) + { + if (player->speed > player->airdriftspeed) + { + difference = player->speed - player->airdriftspeed; + P_Thrust(player->mo, K_MomentumAngle(player->mo), -min(difference, cv_kartairthrust_reductionrate.value)); + } + else // we're done doing drag (TODO: also stop applying drag after being bumped or hit or sprung etc.) + { + player->airdriftspeed = 0; + } + } +} + static void K_KartDrift(player_t *player, boolean onground) { fixed_t minspeed = (10 * player->mo->scale); @@ -8898,19 +8941,24 @@ static void K_KartDrift(player_t *player, boolean onground) if (player->pogospring == 2 && player->mo->scale > mapobjectscale) minspeed = FixedMul(10<drift != -5 && player->drift != 5) { - if (driftstage && onground) + if (driftstage && (onground || K_AirThrustActive())) { UINT8 boost = 0; - if (!cv_kartdriftsounds.value || driftstage < 3) S_StartSound(player->mo, sfx_s23c); - + switch (driftstage) { case 1: @@ -8919,7 +8967,7 @@ static void K_KartDrift(player_t *player, boolean onground) case 2: boost = 50; if (cv_kartdriftsounds.value) - S_StartSound(player->mo, sfx_kc5b); + S_StartSound(player->mo, sfx_kc5b); break; case 3: boost = 80; @@ -8939,6 +8987,39 @@ static void K_KartDrift(player_t *player, boolean onground) } break; } + if (K_AirThrustActive() && !onground) // Air Thrust is enabled + { + fixed_t airthrust = 0; + + switch (driftstage) + { + case 1: + airthrust = cv_kartairthrust_power1.value; + break; + case 2: + airthrust = cv_kartairthrust_power2.value; + break; + case 3: + airthrust = cv_kartairthrust_power3.value; + break; + case 4: + airthrust = cv_kartairthrust_power4.value; + break; + } + + if (driftstage > 0) + { + // before thrust, set player's target speed to their speed before the air thrust + // after the air thrust player's momentum will be reduced back to this value + player->airdriftspeed = max(K_GetKartSpeed(player, false, false), player->speed); + + // Give the player a forward boost + P_Thrust(player->mo, K_MomentumAngle(player->mo), FixedMul(player->speed, airthrust)); + + // Slash the player's vertical momentum. Gets stronger with higher drift charge, but is significantly weaker in water + player->mo->momz = FixedMul(player->mo->momz, FRACUNIT - FixedMul(airthrust/2, abs(P_GetMobjGravity(player->mo)))); + } + } if (player->driftboost < boost) player->driftboost = boost; @@ -8956,7 +9037,7 @@ static void K_KartDrift(player_t *player, boolean onground) player->karthud[khud_afterimagetime] = 10; } - if (onground) + if (onground || K_AirThrustActive()) player->driftcharge = 0; } @@ -9062,7 +9143,7 @@ static void K_KartDrift(player_t *player, boolean onground) player->pflags &= ~(PF_BRAKEDRIFT|PF_GETSPARKS); } - if ( (!(player->sneakertimer || player->flamestore || player->bubbleboost || K_AltInvinSliptideCondition(player))) + if ( (!(player->sneakertimer || player->flamestore || player->bubbleboost || K_AltInvinSliptideCondition(player) || K_AltShrinkSliptideCondition(player))) || (!player->cmd.turning) || (!player->aizdriftstrat) || (player->cmd.turning > 0) != (player->aizdriftstrat > 0)) @@ -10738,6 +10819,17 @@ boolean K_AirDropActive(void) return false; } +boolean K_AirThrustActive(void) +{ + if (airthrustactive) + { + // Air Thrust is enabled! + return true; + } + + return false; +} + boolean K_ItemLitterActive(void) { if (itemlittering) diff --git a/src/k_kart.h b/src/k_kart.h index 1657ebaa1..7cc5931d2 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -352,6 +352,7 @@ boolean K_SlipdashActive(void); boolean K_SlopeBoostActive(void); boolean K_DraftingActive(void); boolean K_AirDropActive(void); +boolean K_AirThrustActive(void); boolean K_ItemLitterActive(void); boolean K_ItemPushingActive(void); INT32 K_GetBumpSpark(void); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 261609105..c1a90b5c4 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3925,6 +3925,25 @@ static int lib_kDriftDustHandling(lua_State *L) return 0; } +static int lib_kThrowKartItem(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + boolean missile = luaL_checkboolean(L, 2); + mobjtype_t thingtype = luaL_checkinteger(L, 3); + INT32 defaultdir = luaL_optinteger(L, 4, 0); + INT32 altthrow = luaL_optinteger(L, 5, 0); + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + mobj_t *mo = K_ThrowKartItem(player, missile, thingtype, defaultdir, altthrow); + if (mo) + LUA_PushUserdata(L, mo, META_MOBJ); + else + lua_pushnil(L); + + return 1; +} + static int lib_kDoSneaker(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -4007,6 +4026,17 @@ static int lib_kKartUpdatePosition(lua_State *L) return 0; } +static int lib_kUpdateHnextList(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + boolean clean = lua_optboolean(L, 2); + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_UpdateHnextList(player, clean); + return 0; +} + static int lib_kDropItems(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5481,6 +5511,7 @@ static luaL_Reg lib[] = { {"K_SpawnSparkleTrail",lib_kSpawnSparkleTrail}, {"K_SpawnWipeoutTrail",lib_kSpawnWipeoutTrail}, {"K_DriftDustHandling",lib_kDriftDustHandling}, + {"K_ThrowKartItem",lib_kThrowKartItem}, {"K_DoSneaker",lib_kDoSneaker}, {"K_DoPogoSpring",lib_kDoPogoSpring}, {"K_KillBananaChain",lib_kKillBananaChain}, @@ -5488,6 +5519,7 @@ static luaL_Reg lib[] = { {"K_FindJawzTarget",lib_kFindJawzTarget}, {"K_GetKartDriftSparkValue",lib_kGetKartDriftSparkValue}, {"K_KartUpdatePosition",lib_kKartUpdatePosition}, + {"K_UpdateHnextList",lib_kUpdateHnextList}, {"K_DropItems",lib_kDropItems}, {"K_StripItems",lib_kStripItems}, {"K_StripOther",lib_kStripOther}, diff --git a/src/lua_hook.h b/src/lua_hook.h index dbf32b803..b4a10c616 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -92,6 +92,7 @@ automatically. X (KartStripItems),/*SRB2KART*/\ X (KartStripOther),/*SRB2KART*/\ X (CanPickupItem),/*SRB2KART*/\ + X (GetItemEquipStyle),/*SRB2KART*/\ #define STRING_HOOK_LIST(X) \ X (SpecialExecute),\ @@ -185,6 +186,7 @@ boolean LUA_HookKartSneaker(player_t *player, int type); // SRB2Kart: Hook for K boolean LUA_HookKartStripItems(player_t *player, UINT8 item); // SRB2Kart: Hook for K_StripItems. boolean LUA_HookKartStripOther(player_t *player); // SRB2Kart: Hook for K_StripOther. boolean LUA_HookCanPickupItem(player_t *player, UINT8 weapon, boolean *force); // SRB2Kart: Hook for P_CanPickupItem. +int LUA_HookGetItemEquipStyle(mobjtype_t mobjtype); // SRB2Kart: Hook for K_GetItemEquipStyle. #ifdef __cplusplus } // extern "C" diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index f3c3f8b18..12ce4629d 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1418,3 +1418,31 @@ boolean LUA_HookCanPickupItem(player_t *player, UINT8 weapon, boolean *force) *force = state.force; return state.override; } + +static void res_itemequipstyle(Hook_State *hook) +{ + if (!lua_isnil(gL, -1)) + { + UINT32 ret = lua_tonumber(gL, -1); + hook->status = ret; + } + else + { + hook->status = 0; + } +} + + +int LUA_HookGetItemEquipStyle(mobjtype_t type) +{ + Hook_State hook; + + if (prepare_hook(&hook, 0, HOOK(GetItemEquipStyle))) + { + lua_pushinteger(gL, type); + + call_hooks(&hook, 1, res_itemequipstyle); + } + + return hook.status; +} diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 2696a7d67..62aa11ee3 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -281,6 +281,7 @@ enum player_e player_drift, player_driftcharge, player_driftboost, + player_airdriftspeed, player_boostcharge, player_slopeboost, player_prevslopeboost, @@ -498,6 +499,7 @@ static const char *const player_opt[] = { "drift", "driftcharge", "driftboost", + "airdriftspeed", "boostcharge", "slopeboost", "prevslopeboost", @@ -841,6 +843,9 @@ static int player_get(lua_State *L) case player_driftboost: lua_pushinteger(L, plr->driftboost); break; + case player_airdriftspeed: + lua_pushinteger(L, plr->airdriftspeed); + break; case player_boostcharge: lua_pushinteger(L, plr->boostcharge); break; @@ -1594,6 +1599,9 @@ static int player_set(lua_State *L) case player_driftboost: plr->driftboost = luaL_checkinteger(L, 3); break; + case player_airdriftspeed: + plr->airdriftspeed = luaL_checkinteger(L, 3); + break; case player_boostcharge: plr->boostcharge = luaL_checkinteger(L, 3); break; diff --git a/src/m_menu.c b/src/m_menu.c index 11c4283a2..8d92d884f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5719,7 +5719,7 @@ INT32 MR_StartGrandPrix(INT32 choice) G_DeferedInitNew( false, levelNum + 1, - (UINT8)(cv_chooseskin.value), + cv_chooseskin.value, (UINT8)(cv_splitplayers.value - 1), false ); diff --git a/src/p_inter.c b/src/p_inter.c index c0ee3c23c..6badd614a 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2313,6 +2313,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da } player->driftboost = 0; + player->airdriftspeed = 0; player->ringboost = 0; player->glanceDir = 0; player->pflags &= ~PF_GAINAX; diff --git a/src/p_map.c b/src/p_map.c index 9611424b5..5876e9005 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -286,6 +286,12 @@ P_DoSpringEx finalSpeed = pSpeed; P_InstaThrust(object, finalAngle, FixedMul(finalSpeed,FixedSqrt(FixedMul(hscale, scaleVal)))); + + if (object->player->airdriftspeed > 0) + { + // clear air thrust target speed too + object->player->airdriftspeed = 0; + } } } } @@ -399,6 +405,12 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) } } } + + if (object->player->airdriftspeed > 0) + { + // clear air thrust target speed too + object->player->airdriftspeed = 0; + } } return true; } @@ -467,6 +479,12 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) default: break; } + + if (object->player && object->player->airdriftspeed > 0) + { + // clear air thrust target speed too + object->player->airdriftspeed = 0; + } } // diff --git a/src/p_mobj.h b/src/p_mobj.h index 68b94c098..6f83f8912 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -618,6 +618,7 @@ extern boolean purpledriftactive; extern boolean slopeboostactive; extern boolean draftingactive; extern boolean airdropactive; +extern boolean airthrustactive; extern boolean itemlittering; extern boolean itempushing; extern UINT8 bumpsparkactive; diff --git a/src/p_saveg.c b/src/p_saveg.c index aeacc00e5..e60bedc95 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -591,6 +591,7 @@ static void P_NetSyncPlayers(savebuffer_t *save) SYNC(players[i].driftlock); SYNC(players[i].driftcharge); SYNC(players[i].driftboost); + SYNC(players[i].airdriftspeed); SYNC(players[i].aizdriftstrat); SYNC(players[i].aizdrifttilt); diff --git a/src/p_setup.c b/src/p_setup.c index 938f622e8..dd8684ebd 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -161,6 +161,7 @@ boolean purpledriftactive; boolean slopeboostactive; boolean draftingactive; boolean airdropactive; +boolean airthrustactive; boolean itemlittering; boolean itempushing; UINT8 bumpsparkactive; @@ -7350,10 +7351,14 @@ static void P_ConvertBinaryThingTypes(void) case 556: //Diagonal red spring case 557: //Diagonal blue spring case 558: //Diagonal grey spring - if (mapthings[i].options & MTF_OBJECTSPECIAL) - mapthings[i].args[0] |= TMSPR_NOGRAVITY; - if (mapthings[i].options & MTF_AMBUSH) - mapthings[i].args[0] |= TMSPR_ROTATEEXTRA; + //if (mapthings[i].options & MTF_OBJECTSPECIAL) + //mapthings[i].args[0] |= TMSPR_NOGRAVITY; + // Not all springs had rotate extra in v1 + if (!(mapthings[i].type == 557 || mapthings[i].type == 558)) + { + if (mapthings[i].options & MTF_AMBUSH) + mapthings[i].args[0] |= TMSPR_ROTATEEXTRA; + } break; case 559: //Horizontal yellow spring case 560: //Horizontal red spring @@ -8169,6 +8174,7 @@ static void P_InitLevelSettings(boolean reloadinggamestate) slopeboostactive = false; draftingactive = false; airdropactive = false; + airthrustactive = false; itemlittering = false; itempushing = false; bumpsparkactive = 0; @@ -8198,6 +8204,9 @@ static void P_InitLevelSettings(boolean reloadinggamestate) if (cv_kartairdrop.value) airdropactive = true; + if (cv_kartairthrust.value) + airthrustactive = true; + if (cv_kartitemlitter.value) itemlittering = true; diff --git a/src/p_user.c b/src/p_user.c index f4cb5cb51..e70bbaf0f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2045,7 +2045,7 @@ static void P_3dMovement(player_t *player) } // else do nothing } - else + else if (player->airdriftspeed == 0) { tempmomx = FixedMul(FixedDiv(player->mo->momx - player->cmomx, newMagnitude), K_GetKartSpeed(player, true, true)); //topspeed) tempmomy = FixedMul(FixedDiv(player->mo->momy - player->cmomy, newMagnitude), K_GetKartSpeed(player, true, true)); //topspeed)