LunaCON: implement 'tossweapon'.

git-svn-id: https://svn.eduke32.com/eduke32@3943 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-07-13 21:04:38 +00:00
parent d53b976acf
commit e4849af91f
5 changed files with 28 additions and 9 deletions

View file

@ -525,6 +525,26 @@ local function have_ammo_at_max(ps, weap)
return (ps.ammo_amount[weap] >= ps.max_ammo_amount[weap])
end
function _tossweapon(pli) -- P_DropWeapon replacement
check_player_idx(pli)
local ps = ffiC.g_player[pli].ps
bcheck.weapon_idx(ps.curr_weapon)
local cw = ffiC.g_playerWeapon[pli][ps.curr_weapon].workslike
if (cw >= ffiC.MAX_WEAPONS+0ULL) then
return
end
if (krandand(1) ~= 0) then
spawn(ffiC.WeaponPickupSprites[cw], ps.i)
elseif (cw==ffiC.RPG_WEAPON or cw==ffiC.HANDBOMB_WEAPON) then
if (D.EXPLOSION2 ~= nil) then
spawn(D.EXPLOSION2, ps.i)
end
end
end
local function P_AddAmmo(ps, weap, amount)
if (not have_ammo_at_max(ps, weap)) then
local curamount = ps.ammo_amount[weap]
@ -547,6 +567,7 @@ end
--- but which are off limits to users. (That is, we need to think about how to
--- expose the functionality in a better fashion than merely giving access to
--- the C functions.)
--- TODO: Move these to a separate module like "con_private".
-- quotes
local REALMAXQUOTES = con_lang.REALMAXQUOTES
@ -1010,14 +1031,6 @@ function _sizeto(i, xr, yr)
spr.yrepeat = spr.yrepeat + ((dr == 0) and 0 or (dr < 0 and -1 or 1))
end
-- NOTE: function args of the C function have overloaded meaning
function _A_Spawn(j, pn)
check_sprite_idx(j)
check_sector_idx(ffiC.sprite[j].sectnum)
check_tile_idx(pn)
return CF.A_Spawn(j, pn)
end
function _pstomp(ps, i)
if (ps.knee_incs == 0 and sprite[ps.i].xrepeat >= 40) then
local spr = sprite[i]

View file

@ -614,6 +614,7 @@ playerdata_t g_player[MAXPLAYERS];
DukePlayer_t *g_player_ps[MAXPLAYERS];
weapondata_x_MAX_WEAPONS g_playerWeapon[MAXPLAYERS];
weapondata_t g_weaponOverridden[MAX_WEAPONS];
int16_t WeaponPickupSprites[MAX_WEAPONS];
tiledata_t g_tile[MAXTILES];
projectile_t ProjectileData[MAXTILES];
projectile_t SpriteProjectile[MAXSPRITES];

View file

@ -139,6 +139,7 @@ g_player;
g_player_ps;
g_playerWeapon;
g_weaponOverridden;
WeaponPickupSprites;
g_tile;
ProjectileData;
SpriteProjectile;

View file

@ -2307,7 +2307,7 @@ local Cinner = {
tip = cmd()
/ PLS".tipincs=26",
tossweapon = cmd()
/ "", -- TODO_MP
/ "_con._tossweapon(_pli)",
wackplayer = cmd()
/ PLS":whack()",

View file

@ -50,3 +50,7 @@ useractor notenemy 909 // tree trunk
quote 400
}
enda
onevent EVENT_JUMP
tossweapon
endevent