Some more minor comeback tweaks

- Comeback players are now 1 speed with -20 friction
- Bombing gives 2 karma now
- Item players should no longer be able to be hit
- Attempted to fix instances of trying to bomb someone while they can't
be touched causing you to lose all your karma and start a console
message saying you're back in the game, despite not rewarding a balloon
- Fixed a few places where kartspeed & kartweight were being read as
fixed point numbers, despite being UINT8's
- Fixed up kartstuff Lua support more, functions properly now
This commit is contained in:
TehRealSalt 2017-11-19 19:39:40 -05:00
parent 81c723b9b5
commit a2767fe341
10 changed files with 162 additions and 64 deletions

View file

@ -8021,6 +8021,20 @@ static powertype_t get_power(const char *word)
return pw_invulnerability;
}
static kartstufftype_t get_kartstuff(const char *word)
{ // Returns the vlaue of k_ enumerations
kartstufftype_t i;
if (*word >= '0' && *word <= '9')
return atoi(word);
if (fastncmp("K_",word,2))
word += 2; // take off the k_
for (i = 0; i < NUMKARTSTUFF; i++)
if (fastcmp(word, KARTSTUFF_LIST[i]))
return i;
deh_warning("Couldn't find power named 'k_%s'",word);
return k_position;
}
/// \todo Make ANY of this completely over-the-top math craziness obey the order of operations.
static fixed_t op_mul(fixed_t a, fixed_t b) { return a*b; }
static fixed_t op_div(fixed_t a, fixed_t b) { return a/b; }
@ -8611,8 +8625,8 @@ static inline int lib_getenum(lua_State *L)
}
return luaL_error(L, "power '%s' could not be found.\n", word);
}
else if (!mathlib && fastncmp("k_",word,3)) {
p = word+3;
else if (!mathlib && fastncmp("k_",word,2)) {
p = word+2;
for (i = 0; i < NUMKARTSTUFF; i++)
if (fasticmp(p, KARTSTUFF_LIST[i])) {
lua_pushinteger(L, i);
@ -8620,8 +8634,8 @@ static inline int lib_getenum(lua_State *L)
}
return 0;
}
else if (mathlib && fastncmp("K_",word,3)) { // SOCs are ALL CAPS!
p = word+3;
else if (mathlib && fastncmp("K_",word,2)) { // SOCs are ALL CAPS!
p = word+2;
for (i = 0; i < NUMKARTSTUFF; i++)
if (fastcmp(p, KARTSTUFF_LIST[i])) {
lua_pushinteger(L, i);

View file

@ -1629,7 +1629,9 @@ fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower)
fixed_t k_speed = 150;
fixed_t g_cc = FRACUNIT;
fixed_t xspd = 3072; // 4.6875 aka 3/64
UINT8 kartspeed = player->kartspeed;
fixed_t finalspeed;
switch (K_GetKartCC())
{
case 50:
@ -1643,7 +1645,10 @@ fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower)
break;
}
k_speed += player->kartspeed*3; // 153 - 177
if (gametype != GT_RACE && player->kartstuff[k_balloon] <= 0)
kartspeed = 1;
k_speed += kartspeed*3; // 153 - 177
finalspeed = FixedMul(FixedMul(k_speed<<14, g_cc), player->mo->scale);
@ -1655,9 +1660,13 @@ fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower)
fixed_t K_GetKartAccel(player_t *player)
{
fixed_t k_accel = 32; // 36;
UINT8 kartspeed = player->kartspeed;
//k_accel += 3 * (9 - player->kartspeed); // 36 - 60
k_accel += 4 * (9 - player->kartspeed); // 32 - 64
if (gametype != GT_RACE && player->kartstuff[k_balloon] <= 0)
kartspeed = 1;
//k_accel += 3 * (9 - kartspeed); // 36 - 60
k_accel += 4 * (9 - kartspeed); // 32 - 64
return FixedMul(k_accel, K_GetKartBoostPower(player, false));
}
@ -1714,7 +1723,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source)
if (player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0 || (player->kartstuff[k_spinouttimer] > 0 && player->kartstuff[k_spinout] > 0)
|| player->kartstuff[k_startimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_bootimer] > 0
|| (gametype != GT_RACE && (player->kartstuff[k_balloon] <= 0 && player->kartstuff[k_comebacktimer])))
|| (gametype != GT_RACE && ((player->kartstuff[k_balloon] <= 0 && player->kartstuff[k_comebacktimer]) || player->kartstuff[k_comebackmode] == 1)))
return;
if (source && source != player->mo && source->player && !source->player->kartstuff[k_sounds])
@ -1777,8 +1786,8 @@ void K_SquishPlayer(player_t *player, mobj_t *source)
return;
if (player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0 || player->kartstuff[k_startimer] > 0
|| player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_bootimer] > 0
|| (gametype != GT_RACE && (player->kartstuff[k_balloon] <= 0 && player->kartstuff[k_comebacktimer])))
|| player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_bootimer] > 0
|| (gametype != GT_RACE && ((player->kartstuff[k_balloon] <= 0 && player->kartstuff[k_comebacktimer]) || player->kartstuff[k_comebackmode] == 1)))
return;
player->kartstuff[k_mushroomtimer] = 0;
@ -1822,7 +1831,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source) // A bit of a hack, we ju
if (player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0 || (player->kartstuff[k_spinouttimer] > 0 && player->kartstuff[k_spinout] > 0)
|| player->kartstuff[k_startimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_bootimer] > 0
|| (gametype != GT_RACE && (player->kartstuff[k_balloon] <= 0 && player->kartstuff[k_comebacktimer])))
|| (gametype != GT_RACE && ((player->kartstuff[k_balloon] <= 0 && player->kartstuff[k_comebacktimer]) || player->kartstuff[k_comebackmode] == 1)))
return;
player->mo->momz = 18*FRACUNIT;
@ -1870,7 +1879,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source) // A bit of a hack, we ju
return;
}
void K_StealBalloon(player_t *player, player_t *victim)
void K_StealBalloon(player_t *player, player_t *victim, boolean force)
{
INT32 newballoon;
angle_t newangle, diff;
@ -1883,17 +1892,25 @@ void K_StealBalloon(player_t *player, player_t *victim)
if (player->health <= 0 || victim->health <= 0)
return;
if (victim->kartstuff[k_balloon] <= 0) // || player->kartstuff[k_balloon] >= cv_kartballoons.value+2
return;
if (force)
;
else
{
if (victim->kartstuff[k_balloon] <= 0) // || player->kartstuff[k_balloon] >= cv_kartballoons.value+2
return;
if ((player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0 || (player->kartstuff[k_spinouttimer] > 0 && player->kartstuff[k_spinout] > 0)
|| player->kartstuff[k_startimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_bootimer] > 0
|| (player->kartstuff[k_balloon] <= 0 && player->kartstuff[k_comebacktimer]))
|| (victim->powers[pw_flashing] > 0 || victim->kartstuff[k_squishedtimer] > 0 || (victim->kartstuff[k_spinouttimer] > 0 && victim->kartstuff[k_spinout] > 0)
|| victim->kartstuff[k_startimer] > 0 || victim->kartstuff[k_growshrinktimer] > 0 || victim->kartstuff[k_bootimer] > 0))
return;
if ((player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0 || (player->kartstuff[k_spinouttimer] > 0 && player->kartstuff[k_spinout] > 0)
|| player->kartstuff[k_startimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_bootimer] > 0
|| (player->kartstuff[k_balloon] <= 0 && player->kartstuff[k_comebacktimer]))
|| (victim->powers[pw_flashing] > 0 || victim->kartstuff[k_squishedtimer] > 0 || (victim->kartstuff[k_spinouttimer] > 0 && victim->kartstuff[k_spinout] > 0)
|| victim->kartstuff[k_startimer] > 0 || victim->kartstuff[k_growshrinktimer] > 0 || victim->kartstuff[k_bootimer] > 0))
return;
}
//CONS_Printf(M_GetText("%s stole a balloon from %s!\n"), player_names[player-players], player_names[victim-players]);
if (player->kartstuff[k_balloon] <= 0)
CONS_Printf(M_GetText("%s is back in the game!\n"), player_names[player-players]);
else
CONS_Printf(M_GetText("%s stole a balloon from %s!\n"), player_names[player-players], player_names[victim-players]);
newballoon = player->kartstuff[k_balloon];
if (newballoon <= 1)
@ -1920,8 +1937,8 @@ void K_StealBalloon(player_t *player, player_t *victim)
P_SetMobjState(newmo, S_BATTLEBALLOON1);
player->kartstuff[k_balloon]++;
player->kartstuff[k_comebackpoints] = 0;
player->powers[pw_flashing] = K_GetKartFlashing(player);
return;
}
@ -2627,9 +2644,15 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue)
static void K_KartDrift(player_t *player, boolean onground)
{
UINT8 kartspeed = player->kartspeed;
fixed_t dsone, dstwo;
if (gametype != GT_RACE && player->kartstuff[k_balloon] <= 0)
kartspeed = 1;
// IF YOU CHANGE THESE: MAKE SURE YOU UPDATE THE SAME VALUES IN p_mobjc, "case MT_DRIFT:"
fixed_t dsone = 26*4 + player->kartspeed*2 + (9 - player->kartweight);
fixed_t dstwo = dsone*2;
dsone = 26*4 + kartspeed*2 + (9 - player->kartweight);
dstwo = dsone*2;
// Drifting is actually straffing + automatic turning.
// Holding the Jump button will enable drifting.
@ -3461,9 +3484,28 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
// Friction
if (player->speed > 0 && cmd->forwardmove == 0 && player->mo->friction == 59392)
player->mo->friction += 4608;
player->mo->friction += 4608;
if (player->speed > 0 && cmd->forwardmove < 0 && player->mo->friction == 59392)
player->mo->friction += 1608;
player->mo->friction += 1608;
if (gametype != GT_RACE && player->kartstuff[k_balloon] <= 0)
{
player->mo->friction += 1228;
if (player->mo->friction > FRACUNIT)
player->mo->friction = FRACUNIT;
if (player->mo->friction < 0)
player->mo->friction = 0;
player->mo->movefactor = FixedDiv(ORIG_FRICTION, player->mo->friction);
if (player->mo->movefactor < FRACUNIT)
player->mo->movefactor = 19*player->mo->movefactor - 18*FRACUNIT;
else
player->mo->movefactor = FRACUNIT; //player->mo->movefactor = ((player->mo->friction - 0xDB34)*(0xA))/0x80;
if (player->mo->movefactor < 32)
player->mo->movefactor = 32;
}
K_KartDrift(player, onground);

View file

@ -22,7 +22,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd);
void K_SpinPlayer(player_t *player, mobj_t *source);
void K_SquishPlayer(player_t *player, mobj_t *source);
void K_ExplodePlayer(player_t *player, mobj_t *source);
void K_StealBalloon(player_t *player, player_t *victim);
void K_StealBalloon(player_t *player, player_t *victim, boolean force);
void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle, boolean spawncenter, boolean ghostit, mobj_t *source);
void K_SpawnDriftTrail(player_t *player);
void K_DoMushroom(player_t *player, boolean doPFlag, boolean startboost);

View file

@ -2057,12 +2057,13 @@ static int lib_kStealBalloon(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
player_t *victim = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
boolean force = luaL_checkboolean(L, 3);
NOHUD
if (!player)
return LUA_ErrInvalid(L, "player_t");
if (!victim)
return LUA_ErrInvalid(L, "player_t");
K_StealBalloon(player, victim);
K_StealBalloon(player, victim, force);
return 0;
}

View file

@ -412,10 +412,14 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"dashtime"))
plr->dashtime = (INT32)luaL_checkinteger(L, 3);
// SRB2kart
else if (fastcmp(field,"kartstuff"))
return NOSET;
else if (fastcmp(field,"frameangle"))
plr->frameangle = luaL_checkangle(L, 3);
else if (fastcmp(field,"kartspeed"))
plr->kartspeed = (UINT8)luaL_checkfixed(L, 3);
plr->kartspeed = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"kartweight"))
plr->kartweight = (UINT8)luaL_checkfixed(L, 3);
plr->kartweight = (UINT8)luaL_checkinteger(L, 3);
//
else if (fastcmp(field,"normalspeed"))
plr->normalspeed = luaL_checkfixed(L, 3);
@ -670,6 +674,38 @@ static int power_len(lua_State *L)
return 1;
}
// kartstuff, ks -> kartstuff[ks]
static int kartstuff_get(lua_State *L)
{
INT32 *kartstuff = *((INT32 **)luaL_checkudata(L, 1, META_KARTSTUFF));
kartstufftype_t ks = luaL_checkinteger(L, 2);
if (ks >= NUMKARTSTUFF)
return luaL_error(L, LUA_QL("kartstufftype_t") " cannot be %u", ks);
lua_pushinteger(L, kartstuff[ks]);
return 1;
}
// kartstuff, ks, value -> kartstuff[ks] = value
static int kartstuff_set(lua_State *L)
{
INT32 *kartstuff = *((INT32 **)luaL_checkudata(L, 1, META_KARTSTUFF));
kartstufftype_t ks = luaL_checkinteger(L, 2);
INT32 i = (INT32)luaL_checkinteger(L, 3);
if (ks >= NUMKARTSTUFF)
return luaL_error(L, LUA_QL("kartstufftype_t") " cannot be %u", ks);
if (hud_running)
return luaL_error(L, "Do not alter player_t in HUD rendering code!");
kartstuff[ks] = i;
return 0;
}
// #kartstuff -> NUMKARTSTUFF
static int kartstuff_len(lua_State *L)
{
lua_pushinteger(L, NUMKARTSTUFF);
return 1;
}
#define NOFIELD luaL_error(L, LUA_QL("ticcmd_t") " has no field named " LUA_QS, field)
static int ticcmd_get(lua_State *L)
@ -747,6 +783,17 @@ int LUA_PlayerLib(lua_State *L)
lua_setfield(L, -2, "__len");
lua_pop(L,1);
luaL_newmetatable(L, META_KARTSTUFF);
lua_pushcfunction(L, kartstuff_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, kartstuff_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, kartstuff_len);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
luaL_newmetatable(L, META_TICCMD);
lua_pushcfunction(L, ticcmd_get);
lua_setfield(L, -2, "__index");

View file

@ -165,10 +165,10 @@ static int skin_get(lua_State *L)
break;
// SRB2kart
case skin_kartspeed:
lua_pushfixed(L, skin->kartspeed);
lua_pushinteger(L, skin->kartspeed);
break;
case skin_kartweight:
lua_pushfixed(L, skin->kartweight);
lua_pushinteger(L, skin->kartweight);
break;
//
case skin_normalspeed:

View file

@ -433,11 +433,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
CONS_Printf(M_GetText("%s gave an item to %s.\n"), player_names[special->tracer->player-players], player_names[player-players]);
if (special->tracer->player->kartstuff[k_comebackpoints] >= 3)
{
K_StealBalloon(special->tracer->player, player);
special->tracer->player->kartstuff[k_comebackpoints] = 0;
CONS_Printf(M_GetText("%s is back in the game!\n"), player_names[special->tracer->player-players]);
}
K_StealBalloon(special->tracer->player, player, true);
special->tracer->player->kartstuff[k_comebacktimer] = comebacktime;
}

View file

@ -1647,15 +1647,11 @@ static boolean PIT_CheckThing(mobj_t *thing)
{
if (tmthing->player->kartstuff[k_balloon] > 0)
{
thing->player->kartstuff[k_comebackpoints]++;
thing->player->kartstuff[k_comebackpoints] += 2;
CONS_Printf(M_GetText("%s bombed %s!\n"), player_names[thing->player-players], player_names[tmthing->player-players]);
if (thing->player->kartstuff[k_comebackpoints] >= 3)
{
K_StealBalloon(thing->player, tmthing->player);
thing->player->kartstuff[k_comebackpoints] = 0;
CONS_Printf(M_GetText("%s is back in the game!\n"), player_names[thing->player-players]);
}
K_StealBalloon(thing->player, tmthing->player, true);
K_ExplodePlayer(tmthing->player, thing);
@ -1664,15 +1660,11 @@ static boolean PIT_CheckThing(mobj_t *thing)
}
else if (thing->player->kartstuff[k_balloon] > 0)
{
tmthing->player->kartstuff[k_comebackpoints]++;
tmthing->player->kartstuff[k_comebackpoints] += 2;
CONS_Printf(M_GetText("%s bombed %s!\n"), player_names[tmthing->player-players], player_names[thing->player-players]);
if (tmthing->player->kartstuff[k_comebackpoints] >= 3)
{
K_StealBalloon(tmthing->player, thing->player);
thing->player->kartstuff[k_comebackpoints] = 0;
CONS_Printf(M_GetText("%s is back in the game!\n"), player_names[tmthing->player-players]);
}
K_StealBalloon(tmthing->player, thing->player, true);
K_ExplodePlayer(thing->player, tmthing);
@ -1687,9 +1679,8 @@ static boolean PIT_CheckThing(mobj_t *thing)
K_KartBouncing(tmthing, thing, true);
if (gametype != GT_RACE && tmthing->player->kartstuff[k_feather] & 2)
{
K_StealBalloon(tmthing->player, thing->player);
K_StealBalloon(tmthing->player, thing->player, false);
K_SpinPlayer(thing->player, tmthing);
CONS_Printf(M_GetText("%s stole a balloon from %s!\n"), player_names[tmthing->player-players], player_names[thing->player-players]);
}
}
else if (P_IsObjectOnGround(tmthing) && thing->momz < 0)
@ -1697,9 +1688,8 @@ static boolean PIT_CheckThing(mobj_t *thing)
K_KartBouncing(thing, tmthing, true);
if (gametype != GT_RACE && thing->player->kartstuff[k_feather] & 2)
{
K_StealBalloon(thing->player, tmthing->player);
K_StealBalloon(thing->player, tmthing->player, false);
K_SpinPlayer(tmthing->player, thing);
CONS_Printf(M_GetText("%s stole a balloon from %s!\n"), player_names[thing->player-players], player_names[tmthing->player-players]);
}
}
else
@ -1709,15 +1699,13 @@ static boolean PIT_CheckThing(mobj_t *thing)
{
if (thing->player->kartstuff[k_mushroomtimer] && !(tmthing->player->kartstuff[k_mushroomtimer]))
{
K_StealBalloon(thing->player, tmthing->player);
K_StealBalloon(thing->player, tmthing->player, false);
K_SpinPlayer(tmthing->player, thing);
CONS_Printf(M_GetText("%s stole a balloon from %s!\n"), player_names[thing->player-players], player_names[tmthing->player-players]);
}
else if (tmthing->player->kartstuff[k_mushroomtimer] && !(thing->player->kartstuff[k_mushroomtimer]))
{
K_StealBalloon(tmthing->player, thing->player);
K_StealBalloon(tmthing->player, thing->player, false);
K_SpinPlayer(thing->player, tmthing);
CONS_Printf(M_GetText("%s stole a balloon from %s!\n"), player_names[tmthing->player-players], player_names[thing->player-players]);
}
}

View file

@ -6459,15 +6459,25 @@ void P_MobjThinker(mobj_t *mobj)
//{ SRB2kart mobs
case MT_DRIFT:
{
fixed_t dsone = 26*4 + mobj->target->player->kartspeed*2 + (9 - mobj->target->player->kartweight);
fixed_t dstwo = dsone*2;
if ((mobj->target && mobj->target->player && mobj->target->player->mo && mobj->target->player->health > 0 && !mobj->target->player->spectator)
&& (mobj->type == MT_DRIFT && mobj->target->player->kartstuff[k_driftcharge] >= dsone))
if (mobj->target && mobj->target->player && mobj->target->player->mo && mobj->target->player->health > 0 && !mobj->target->player->spectator)
{
UINT8 kartspeed = mobj->target->player->kartspeed;
fixed_t dsone, dstwo;
INT32 HEIGHT;
fixed_t radius;
if (gametype != GT_RACE && mobj->target->player->kartstuff[k_balloon] <= 0)
kartspeed = 1;
dsone = 26*4 + kartspeed*2 + (9 - mobj->target->player->kartweight);
dstwo = dsone*2;
if (mobj->target->player->kartstuff[k_driftcharge] < dsone)
{
P_RemoveMobj(mobj);
return;
}
if (mobj->target->player->kartstuff[k_bootimer] > 0)
{
if ((mobj->target->player == &players[displayplayer] || (splitscreen && mobj->target->player == &players[secondarydisplayplayer]))

View file

@ -91,8 +91,8 @@ typedef struct
fixed_t maxdash;
// SRB2kart
UINT8 kartspeed; // Normal ground
UINT8 kartweight; // Normal ground
UINT8 kartspeed;
UINT8 kartweight;
//
fixed_t normalspeed; // Normal ground