From e4849af91fea514bee717b5e7aad123512f95866 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 13 Jul 2013 21:04:38 +0000 Subject: [PATCH] LunaCON: implement 'tossweapon'. git-svn-id: https://svn.eduke32.com/eduke32@3943 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/control.lua | 29 ++++++++++++++----- polymer/eduke32/source/lunatic/defs.ilua | 1 + polymer/eduke32/source/lunatic/dynsymlist | 1 + polymer/eduke32/source/lunatic/lunacon.lua | 2 +- .../source/lunatic/test/weaponvars.con | 4 +++ 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index fe12dc71e..43616dca1 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -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] diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 0d0937fdc..577f20314 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -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]; diff --git a/polymer/eduke32/source/lunatic/dynsymlist b/polymer/eduke32/source/lunatic/dynsymlist index a3118fdec..43f3ec399 100644 --- a/polymer/eduke32/source/lunatic/dynsymlist +++ b/polymer/eduke32/source/lunatic/dynsymlist @@ -139,6 +139,7 @@ g_player; g_player_ps; g_playerWeapon; g_weaponOverridden; +WeaponPickupSprites; g_tile; ProjectileData; SpriteProjectile; diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 93b977a68..adebf6c62 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -2307,7 +2307,7 @@ local Cinner = { tip = cmd() / PLS".tipincs=26", tossweapon = cmd() - / "", -- TODO_MP + / "_con._tossweapon(_pli)", wackplayer = cmd() / PLS":whack()", diff --git a/polymer/eduke32/source/lunatic/test/weaponvars.con b/polymer/eduke32/source/lunatic/test/weaponvars.con index 1a81a2664..db6595115 100644 --- a/polymer/eduke32/source/lunatic/test/weaponvars.con +++ b/polymer/eduke32/source/lunatic/test/weaponvars.con @@ -50,3 +50,7 @@ useractor notenemy 909 // tree trunk quote 400 } enda + +onevent EVENT_JUMP + tossweapon +endevent