mirror of
https://github.com/UberGames/rpgxEF.git
synced 2025-04-22 08:50:48 +00:00
- Commented out unsued function from the lua vector library.
- Added lua hook for weapon firing.
This commit is contained in:
parent
95fc64d15e
commit
0242b959ae
4 changed files with 45 additions and 0 deletions
|
@ -456,6 +456,33 @@ lvm_t *G_Lua_GetVM(lua_State * L)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void LuaHook_G_FireWeapon(int ent, vec3_t muzzle, vec3_t forward, int alt_fire, int weapon) {
|
||||
int i;
|
||||
lvm_t* vm = NULL;
|
||||
|
||||
for (i = 0; i < NUM_VMS; i++) {
|
||||
vm = lVM[i];
|
||||
if (vm != NULL) {
|
||||
if (vm->id < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!G_Lua_GetFunction(vm, "FireWeapon")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lua_pushinteger(vm->L, ent);
|
||||
Lua_PushVector(vm->L, muzzle);
|
||||
Lua_PushVector(vm->L, forward);
|
||||
lua_pushboolean(vm->L, alt_fire);
|
||||
lua_pushinteger(vm->L, weapon);
|
||||
if (!G_Lua_Call(vm, "FireWeapon", 5, 0)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LuaHook_G_InitGame(int levelTime, unsigned int randomSeed, int restart)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -261,6 +261,17 @@ int Luaopen_Sound(lua_State *L);
|
|||
*/
|
||||
void LuaHook_G_InitGame(int leveltime, unsigned int randomseed, int restart);
|
||||
|
||||
/**
|
||||
* Lua hook for weapon firing.
|
||||
*
|
||||
* \param ent The player.
|
||||
* \param muzzle The muzzle point.
|
||||
* \param forwar The forward vector.
|
||||
* \param alt_fire Indicator whether the shot is alternative fire mode.
|
||||
* \param weapon Weapon number.
|
||||
*/
|
||||
void LuaHook_G_FireWeapon(int ent, vec3_t muzzle, vec3_t forward, int alt_fire, int weapon);
|
||||
|
||||
/**
|
||||
* Lua hook for Shutdown event.
|
||||
*
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "g_client.h"
|
||||
#include "g_missile.h"
|
||||
#include "g_logger.h"
|
||||
#include "g_lua.h"
|
||||
|
||||
#define MAX_BEAM_HITS 4
|
||||
|
||||
|
@ -1855,6 +1856,10 @@ void FireWeapon( gentity_t* ent, qboolean alt_fire )
|
|||
}
|
||||
G_Weapon_CalcMuzzlePoint ( ent, forward, right, up, muzzle, projsize);
|
||||
|
||||
#ifdef G_LUA
|
||||
LuaHook_G_FireWeapon(ent - g_entities, muzzle, forward, (int)alt_fire, ent->s.weapon);
|
||||
#endif
|
||||
|
||||
/* fire the specific weapon */
|
||||
switch( ent->s.weapon )
|
||||
{
|
||||
|
|
|
@ -403,6 +403,7 @@ static int Vector_AngleVectors(lua_State *L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int Vector_Index(lua_State *L) {
|
||||
vec_t *v;
|
||||
const char *i;
|
||||
|
@ -437,6 +438,7 @@ static int Vector_NewIndex(lua_State *L) {
|
|||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int Vector_AddOperator(lua_State *L) {
|
||||
vec_t *a, *b;
|
||||
|
|
Loading…
Reference in a new issue