From bb3653a36ff6ab5eb3f8a437845256446e076504 Mon Sep 17 00:00:00 2001 From: Walter Julius Hennecke Date: Mon, 19 Mar 2012 22:45:25 +0100 Subject: [PATCH] Expanded lua weapon library --- game/g_weapon.c | 5 +---- game/g_weapon.h | 10 +++++++++ game/lua_cvar.c | 7 +++++++ game/lua_weapons.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ stefgame.suo | Bin 235008 -> 235008 bytes 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 game/g_weapon.h diff --git a/game/g_weapon.c b/game/g_weapon.c index daf5fef..a8a30fe 100644 --- a/game/g_weapon.c +++ b/game/g_weapon.c @@ -4,10 +4,7 @@ // perform the server side effects of a weapon firing #include "g_local.h" - -static float s_quadFactor; -static vec3_t forward, right, up; -static vec3_t muzzle; +#include "g_weapon.h" extern void G_MissileImpact( gentity_t *ent, trace_t *trace); diff --git a/game/g_weapon.h b/game/g_weapon.h new file mode 100644 index 0000000..7e0303c --- /dev/null +++ b/game/g_weapon.h @@ -0,0 +1,10 @@ +#ifndef _G_WEAPON_H +#define _G_WEAPON_H + +#include "g_local.h" + +static float s_quadFactor; +vec3_t forward, right, up; +vec3_t muzzle; + +#endif // _G_WEAPON_H \ No newline at end of file diff --git a/game/lua_cvar.c b/game/lua_cvar.c index df9b089..acdcf83 100644 --- a/game/lua_cvar.c +++ b/game/lua_cvar.c @@ -69,10 +69,17 @@ static int Cvar_String(lua_State *L) { return 1; } +static int Cvar_rpg_phaserdmg(lua_State *L) { + lua_pushnumber(L, rpg_phaserdmg.integer); + + return 1; +} + static const luaL_Reg lib_cvar[] = { {"Integer", Cvar_Integer}, {"Value", Cvar_Value}, {"String", Cvar_String}, + {"rpg_phaserdmg", Cvar_rpg_phaserdmg}, {NULL, NULL} }; diff --git a/game/lua_weapons.c b/game/lua_weapons.c index 77670c6..febf96c 100644 --- a/game/lua_weapons.c +++ b/game/lua_weapons.c @@ -4,7 +4,57 @@ #ifdef G_LUA +#include "g_weapon.h" + +static int weapon_GetForward(lua_State *L) { + Lua_PushVector(L, forward); + + return 1; +} + +static int weapon_GetRight(lua_State *L) { + Lua_PushVector(L, right); + + return 1; +} + +static int weapon_GetUp(lua_State *L) { + Lua_PushVector(L, up); + + return 1; +} + +static int weapon_GetMuzzle(lua_State *L) { + Lua_PushVector(L, muzzle); + + return 1; +} + +static int weapon_Damage(lua_State *L) { + gentity_t *target, *inflictor, *attacker; + vec_t *dir, *point; + int damage, dflags, mod; + + target = Lua_GetEntity(L, 1)->e; + inflictor = Lua_GetEntity(L, 2)->e; + attacker = Lua_GetEntity(L, 3)->e; + dir = Lua_GetVector(L, 4); + point = Lua_GetVector(L, 5); + damage = (int)luaL_checknumber(L, 6); + dflags = (int)luaL_checknumber(L, 7); + mod = (int)luaL_checknumber(L, 8); + + G_Damage(target, inflictor, attacker, dir, point, damage, dflags, mod); + + return 0; +} + static const luaL_Reg lib_weapons[] = { + {"GetForward", weapon_GetForward}, + {"GetRight", weapon_GetRight}, + {"GetUp", weapon_GetUp}, + {"GetMuzzle", weapon_GetMuzzle}, + {"Damage", weapon_Damage}, {NULL, NULL} }; diff --git a/stefgame.suo b/stefgame.suo index 537a93aca2b629278ab5d52c345b34ac6b79675a..c95bbaaed13124da20eb595610bca3b2e1ac2e64 100644 GIT binary patch delta 415 zcmY+~vG)Vz&I|?L4N`NR%3htKEocf6S+*&Ff<1-7wC9v7(<} z86(@{!@eCEtO!dA3krMi(&wbg;25urG1cc%96{E!R)kMIw0ZH-$54RsxS@jBy&@AsVJw&QL)etT%yTPyOjBks!9s}L<@DO2L zUqi22yF_R@(!vf`Nm?K@olGn{- Jl&oVT_6r+ojywPW