mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
Serious deep-cleaning to most of the kartstuff
More optional fields, more careful eye placed on return values and other checks
This commit is contained in:
parent
2b9b1e3bff
commit
bc7e865e6b
4 changed files with 94 additions and 64 deletions
|
@ -8788,6 +8788,35 @@ struct {
|
|||
|
||||
{"V_CHARCOLORSHIFT",V_CHARCOLORSHIFT},
|
||||
{"V_ALPHASHIFT",V_ALPHASHIFT},
|
||||
|
||||
// SRB2Kart
|
||||
// kartitems_t
|
||||
{"KITEM_SAD",KITEM_SAD}, // Actual items (can be set for k_itemtype)
|
||||
{"KITEM_NONE",KITEM_NONE},
|
||||
{"KITEM_SNEAKER",KITEM_SNEAKER},
|
||||
{"KITEM_ROCKETSNEAKER",KITEM_ROCKETSNEAKER},
|
||||
{"KITEM_INVINCIBILITY",KITEM_INVINCIBILITY},
|
||||
{"KITEM_BANANA",KITEM_BANANA},
|
||||
{"KITEM_EGGMAN",KITEM_EGGMAN},
|
||||
{"KITEM_ORBINAUT",KITEM_ORBINAUT},
|
||||
{"KITEM_JAWZ",KITEM_JAWZ},
|
||||
{"KITEM_MINE",KITEM_MINE},
|
||||
{"KITEM_BALLHOG",KITEM_BALLHOG},
|
||||
{"KITEM_SPB",KITEM_SPB},
|
||||
{"KITEM_GROW",KITEM_GROW},
|
||||
{"KITEM_SHRINK",KITEM_SHRINK},
|
||||
{"KITEM_THUNDERSHIELD",KITEM_THUNDERSHIELD},
|
||||
{"KITEM_HYUDORO",KITEM_HYUDORO},
|
||||
{"KITEM_POGOSPRING",KITEM_POGOSPRING},
|
||||
{"KITEM_KITCHENSINK",KITEM_KITCHENSINK},
|
||||
{"NUMKARTITEMS",NUMKARTITEMS},
|
||||
{"KRITEM_TRIPLESNEAKER",KRITEM_TRIPLESNEAKER}, // Additional roulette IDs (not usable for much in Lua besides K_GetItemPatch)
|
||||
{"KRITEM_TRIPLEBANANA",KRITEM_TRIPLEBANANA},
|
||||
{"KRITEM_TENFOLDBANANA",KRITEM_TENFOLDBANANA},
|
||||
{"KRITEM_TRIPLEORBINAUT",KRITEM_TRIPLEORBINAUT},
|
||||
{"KRITEM_QUADORBINAUT",KRITEM_QUADORBINAUT},
|
||||
{"KRITEM_DUALJAWZ",KRITEM_DUALJAWZ},
|
||||
{"NUMKARTRESULTS",NUMKARTRESULTS},
|
||||
#endif
|
||||
|
||||
{NULL,0}
|
||||
|
|
17
src/k_kart.c
17
src/k_kart.c
|
@ -2256,7 +2256,8 @@ void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32
|
|||
mobj->momy = FixedMul(FixedDiv(mobjy - y, dist), FixedDiv(dist, 6*FRACUNIT));
|
||||
mobj->momz = FixedMul(FixedDiv(mobjz - z, dist), FixedDiv(dist, 6*FRACUNIT));
|
||||
|
||||
P_SetTarget(&mobj->target, source);
|
||||
if (source && !P_MobjWasRemoved(source))
|
||||
P_SetTarget(&mobj->target, source);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4373,7 +4374,7 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue)
|
|||
return turnvalue;
|
||||
}
|
||||
|
||||
fixed_t K_GetKartDriftSparkValue(player_t *player)
|
||||
INT32 K_GetKartDriftSparkValue(player_t *player)
|
||||
{
|
||||
UINT8 kartspeed = (G_BattleGametype() && player->kartstuff[k_bumper] <= 0)
|
||||
? 1
|
||||
|
@ -4383,9 +4384,9 @@ fixed_t K_GetKartDriftSparkValue(player_t *player)
|
|||
|
||||
static void K_KartDrift(player_t *player, boolean onground)
|
||||
{
|
||||
fixed_t dsone = K_GetKartDriftSparkValue(player);
|
||||
fixed_t dstwo = dsone*2;
|
||||
fixed_t dsthree = dstwo*2;
|
||||
INT32 dsone = K_GetKartDriftSparkValue(player);
|
||||
INT32 dstwo = dsone*2;
|
||||
INT32 dsthree = dstwo*2;
|
||||
|
||||
// Drifting is actually straffing + automatic turning.
|
||||
// Holding the Jump button will enable drifting.
|
||||
|
@ -7368,9 +7369,9 @@ static void K_drawKartFirstPerson(void)
|
|||
|
||||
if (stplyr->mo)
|
||||
{
|
||||
fixed_t dsone = K_GetKartDriftSparkValue(stplyr);
|
||||
fixed_t dstwo = dsone*2;
|
||||
fixed_t dsthree = dstwo*2;
|
||||
INT32 dsone = K_GetKartDriftSparkValue(stplyr);
|
||||
INT32 dstwo = dsone*2;
|
||||
INT32 dsthree = dstwo*2;
|
||||
|
||||
#ifndef DONTLIKETOASTERSFPTWEAKS
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ void K_RepairOrbitChain(mobj_t *orbit);
|
|||
player_t *K_FindJawzTarget(mobj_t *actor, player_t *source);
|
||||
boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y);
|
||||
INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue);
|
||||
fixed_t K_GetKartDriftSparkValue(player_t *player);
|
||||
INT32 K_GetKartDriftSparkValue(player_t *player);
|
||||
void K_DropItems(player_t *player);
|
||||
void K_StripItems(player_t *player);
|
||||
void K_StripOther(player_t *player);
|
||||
|
|
|
@ -2068,8 +2068,8 @@ static int lib_kIsPlayerLosing(lua_State *L)
|
|||
//HUDSAFE
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
K_IsPlayerLosing(player);
|
||||
return 0;
|
||||
lua_pushboolean(L, K_IsPlayerLosing(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_kIsPlayerWanted(lua_State *L)
|
||||
|
@ -2078,16 +2078,16 @@ static int lib_kIsPlayerWanted(lua_State *L)
|
|||
//HUDSAFE
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
K_IsPlayerWanted(player);
|
||||
return 0;
|
||||
lua_pushboolean(L, K_IsPlayerWanted(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_kKartBouncing(lua_State *L)
|
||||
{
|
||||
mobj_t *mobj1 = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
mobj_t *mobj2 = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||
boolean bounce = luaL_checkboolean(L, 3);
|
||||
boolean solid = luaL_checkboolean(L, 4);
|
||||
boolean bounce = lua_optboolean(L, 3);
|
||||
boolean solid = lua_optboolean(L, 4);
|
||||
NOHUD
|
||||
if (!mobj1)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
|
@ -2123,13 +2123,13 @@ static int lib_kDoInstashield(lua_State *L)
|
|||
static int lib_kSpawnBattlePoints(lua_State *L)
|
||||
{
|
||||
player_t *source = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
player_t *victim = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
|
||||
player_t *victim = NULL;
|
||||
UINT8 amount = (UINT8)luaL_checkinteger(L, 3);
|
||||
NOHUD
|
||||
if (!source)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
if (!victim)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
victim = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
|
||||
K_SpawnBattlePoints(source, victim, amount);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2137,14 +2137,14 @@ static int lib_kSpawnBattlePoints(lua_State *L)
|
|||
static int lib_kSpinPlayer(lua_State *L)
|
||||
{
|
||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||
INT32 type = (INT32)luaL_checkinteger(L, 3);
|
||||
boolean trapitem = luaL_checkboolean(L, 4);
|
||||
mobj_t *source = NULL;
|
||||
INT32 type = (INT32)luaL_optinteger(L, 3, 0);
|
||||
boolean trapitem = lua_optboolean(L, 4);
|
||||
NOHUD
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
if (!source)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||
K_SpinPlayer(player, source, type, trapitem);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2152,12 +2152,12 @@ static int lib_kSpinPlayer(lua_State *L)
|
|||
static int lib_kSquishPlayer(lua_State *L)
|
||||
{
|
||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||
mobj_t *source = NULL;
|
||||
NOHUD
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
if (!source)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||
K_SquishPlayer(player, source);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2165,15 +2165,15 @@ static int lib_kSquishPlayer(lua_State *L)
|
|||
static int lib_kExplodePlayer(lua_State *L)
|
||||
{
|
||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||
mobj_t *inflictor = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
|
||||
mobj_t *source = NULL;
|
||||
mobj_t *inflictor = NULL;
|
||||
NOHUD
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
if (!source)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!inflictor)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||
if (!lua_isnone(L, 3) && lua_isuserdata(L, 3))
|
||||
inflictor = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
|
||||
K_ExplodePlayer(player, source, inflictor);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2182,7 +2182,7 @@ static int lib_kStealBumper(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);
|
||||
boolean force = lua_optboolean(L, 3);
|
||||
NOHUD
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
|
@ -2197,16 +2197,16 @@ static int lib_kSpawnKartExplosion(lua_State *L)
|
|||
fixed_t x = luaL_checkfixed(L, 1);
|
||||
fixed_t y = luaL_checkfixed(L, 2);
|
||||
fixed_t z = luaL_checkfixed(L, 3);
|
||||
fixed_t radius = luaL_checkfixed(L, 4);
|
||||
INT32 number = (INT32)luaL_checkinteger(L, 5);
|
||||
mobjtype_t type = luaL_checkinteger(L, 6);
|
||||
angle_t rotangle = luaL_checkangle(L, 7);
|
||||
boolean spawncenter = luaL_checkboolean(L, 8);
|
||||
boolean ghostit = luaL_checkboolean(L, 9);
|
||||
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 10, META_MOBJ));
|
||||
fixed_t radius = (fixed_t)luaL_optinteger(L, 4, 32*FRACUNIT);
|
||||
INT32 number = (INT32)luaL_optinteger(L, 5, 32);
|
||||
mobjtype_t type = luaL_optinteger(L, 6, MT_MINEEXPLOSION);
|
||||
angle_t rotangle = luaL_optinteger(L, 7, 0);
|
||||
boolean spawncenter = lua_opttrueboolean(L, 8);
|
||||
boolean ghostit = lua_optboolean(L, 9);
|
||||
mobj_t *source = NULL;
|
||||
NOHUD
|
||||
if (!source)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!lua_isnone(L, 10) && lua_isuserdata(L, 10))
|
||||
source = *((mobj_t **)luaL_checkudata(L, 10, META_MOBJ));
|
||||
K_SpawnKartExplosion(x, y, z, radius, number, type, rotangle, spawncenter, ghostit, source);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2214,7 +2214,7 @@ static int lib_kSpawnKartExplosion(lua_State *L)
|
|||
static int lib_kSpawnMineExplosion(lua_State *L)
|
||||
{
|
||||
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
UINT8 color = (UINT8)luaL_checkinteger(L, 2);
|
||||
UINT8 color = (UINT8)luaL_optinteger(L, 2, SKINCOLOR_KETCHUP);
|
||||
NOHUD
|
||||
if (!source)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
|
@ -2245,7 +2245,7 @@ static int lib_kSpawnSparkleTrail(lua_State *L)
|
|||
static int lib_kSpawnWipeoutTrail(lua_State *L)
|
||||
{
|
||||
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
boolean translucent = luaL_checkboolean(L, 2);
|
||||
boolean translucent = lua_optboolean(L, 2);
|
||||
NOHUD
|
||||
if (!mo)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
|
@ -2266,7 +2266,7 @@ static int lib_kDriftDustHandling(lua_State *L)
|
|||
static int lib_kDoSneaker(lua_State *L)
|
||||
{
|
||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
INT32 type = luaL_checkinteger(L, 2);
|
||||
INT32 type = luaL_optinteger(L, 2, 0);
|
||||
NOHUD
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
|
@ -2277,8 +2277,8 @@ static int lib_kDoSneaker(lua_State *L)
|
|||
static int lib_kDoPogoSpring(lua_State *L)
|
||||
{
|
||||
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
fixed_t vertispeed = luaL_checkfixed(L, 2);
|
||||
UINT8 sound = luaL_checkinteger(L, 3);
|
||||
fixed_t vertispeed = (fixed_t)luaL_optinteger(L, 2, 0);
|
||||
UINT8 sound = (UINT8)luaL_optinteger(L, 3, 1);
|
||||
NOHUD
|
||||
if (!mo)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
|
@ -2289,15 +2289,15 @@ static int lib_kDoPogoSpring(lua_State *L)
|
|||
static int lib_kKillBananaChain(lua_State *L)
|
||||
{
|
||||
mobj_t *banana = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
mobj_t *inflictor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
mobj_t *inflictor = NULL;
|
||||
mobj_t *source = NULL;
|
||||
NOHUD
|
||||
if (!banana)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!inflictor)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!source)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
inflictor = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||
if (!lua_isnone(L, 3) && lua_isuserdata(L, 3))
|
||||
source = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
|
||||
K_KillBananaChain(banana, inflictor, source);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2322,7 +2322,7 @@ static int lib_kFindJawzTarget(lua_State *L)
|
|||
if (!source)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
LUA_PushUserdata(L, K_FindJawzTarget(actor, source), META_PLAYER);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_kGetKartDriftSparkValue(lua_State *L)
|
||||
|
@ -2331,8 +2331,8 @@ static int lib_kGetKartDriftSparkValue(lua_State *L)
|
|||
NOHUD
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
lua_pushfixed(L, K_GetKartDriftSparkValue(player));
|
||||
return 0;
|
||||
lua_pushinteger(L, K_GetKartDriftSparkValue(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_kDropItems(lua_State *L)
|
||||
|
@ -2378,12 +2378,12 @@ static int lib_kMomentumToFacing(lua_State *L)
|
|||
static int lib_kGetKartSpeed(lua_State *L)
|
||||
{
|
||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
boolean doboostpower = luaL_checkboolean(L, 2);
|
||||
boolean doboostpower = lua_optboolean(L, 2);
|
||||
//HUDSAFE
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
lua_pushinteger(L, K_GetKartSpeed(player, doboostpower));
|
||||
return 0;
|
||||
lua_pushfixed(L, K_GetKartSpeed(player, doboostpower));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_kGetKartAccel(lua_State *L)
|
||||
|
@ -2392,8 +2392,8 @@ static int lib_kGetKartAccel(lua_State *L)
|
|||
//HUDSAFE
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
lua_pushinteger(L, K_GetKartAccel(player));
|
||||
return 0;
|
||||
lua_pushfixed(L, K_GetKartAccel(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_kGetKartFlashing(lua_State *L)
|
||||
|
@ -2403,13 +2403,13 @@ static int lib_kGetKartFlashing(lua_State *L)
|
|||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
lua_pushinteger(L, K_GetKartFlashing(player));
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_kGetItemPatch(lua_State *L)
|
||||
{
|
||||
UINT8 item = luaL_checkinteger(L, 1);
|
||||
boolean tiny = luaL_checkboolean(L, 2);
|
||||
UINT8 item = (UINT8)luaL_optinteger(L, 1, KITEM_NONE);
|
||||
boolean tiny = lua_optboolean(L, 2);
|
||||
//HUDSAFE
|
||||
lua_pushstring(L, K_GetItemPatch(item, tiny));
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue