diff --git a/dlls/engine/engine.def b/dlls/engine/engine.def new file mode 100755 index 00000000..f3ecefac --- /dev/null +++ b/dlls/engine/engine.def @@ -0,0 +1,10 @@ +LIBRARY engine +EXPORTS + GiveFnptrsToDll @1 + Meta_Attach @2 + Meta_Detach @3 + Meta_Query @4 + AMX_Attach @5 + AMX_Detach @7 +SECTIONS + .data READ WRITE diff --git a/dlls/engine/engine.dsp b/dlls/engine/engine.dsp new file mode 100755 index 00000000..e5036942 --- /dev/null +++ b/dlls/engine/engine.dsp @@ -0,0 +1,121 @@ +# Microsoft Developer Studio Project File - Name="engine" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=engine - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "engine.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "engine.mak" CFG="engine - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "engine - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "engine - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "engine - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VEXDUM_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VEXDUM_EXPORTS" /FR /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 + +!ELSEIF "$(CFG)" == "engine - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VEXDUM_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VEXDUM_EXPORTS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "engine - Win32 Release" +# Name "engine - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\amx.h +# End Source File +# Begin Source File + +SOURCE=.\meta_api.cpp +# End Source File +# Begin Source File + +SOURCE=.\modules.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\engine.inc +# End Source File +# Begin Source File + +SOURCE=.\engine.def +# End Source File +# End Group +# End Target +# End Project diff --git a/dlls/engine/engine.dsw b/dlls/engine/engine.dsw new file mode 100755 index 00000000..48aee702 --- /dev/null +++ b/dlls/engine/engine.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "engine"=".\engine.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/dlls/engine/meta_api.cpp b/dlls/engine/meta_api.cpp index 17e6d9fd..eb7dc2c3 100755 --- a/dlls/engine/meta_api.cpp +++ b/dlls/engine/meta_api.cpp @@ -1,15 +1,12 @@ -/* <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> - * Project:Vexd Utility Module - * By: Vexd +/**************************************************************************** + * Project: AMX Mod X + * By: BAILOPAN, JohnnyGotHisGun, Manip, PM, SniperBeamer * - * Purpose:This module provides more options for working with entities and other - * things that are half-life related using amxmod scripts. + * Purpose:Engine and entity related natives for AMXX scripting. * - * Notes: This module is in 1 large file because it used to be multiple smaller - * modules. I never intended this module to have so many functions, but I kept - * adding things, never splitting into more files, so it ended up like this. - * You must have the Half-life software development kit, and the include directories - * properly set up to compile this module. You also may need the metamod source. + * Notes: Many core functions of this module were originally made by VexD. + * VexD gets the credit for setting up the framework for this, as it was + * Originally VexD Utilities * * Licence: * This program is free software; you can redistribute it and/or modify @@ -28,7 +25,7 @@ * * Full licence can be found at: * http://www.gnu.org/licenses/gpl.txt - * <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> */ + ***************************************************************************/ #include #include @@ -59,10 +56,11 @@ std::vector vTouchCallList; std::vector vServerFrameCallList; //This was originally by VexD +//Thank you for an excellent piece of work, VexD! #define NAME "Engine Module" #define AUTHOR "BAILOPAN" -#define VERSION "0.1" +#define VERSION "0.2" #define URL "No Website" #define LOGTAG "AMXXE" #define DATE __DATE__ @@ -257,7 +255,7 @@ struct GlobalInfo { GlobalInfo GlInfo; -cvar_t vx_version = {"vx_version", VERSION, FCVAR_SERVER, 0}; +cvar_t amxxe_version = {"amxxe_version", VERSION, FCVAR_SERVER, 0}; plugin_info_t Plugin_info = { META_INTERFACE_VERSION, @@ -281,6 +279,101 @@ module_info_s AMXInfo = { /********************* Begin Utility Functions ******************************/ +//(BAILOPAN) +//Sets a pvPrivateData offset for a player (player, offset, val, float=0) +static cell AMX_NATIVE_CALL set_offset(AMX *amx, cell *params) +{ + int index = params[1]; + int off = params[2]; + + if (index < 1 || index > gpGlobals->maxClients) { + AMX_RAISEERROR(amx, AMX_ERR_NATIVE); + return 0; + } + + edict_t *Player = INDEXENT(index); + +#ifndef __linux__ + off -= 5; +#endif + + *((int *)Player->pvPrivateData + off) = params[3]; + + return 1; +} + +//(BAILOPAN) +//Sets a pvPrivateData offset for a player (player, offset, Float:val) +static cell AMX_NATIVE_CALL set_offset_float(AMX *amx, cell *params) +{ + int index = params[1]; + int off = params[2]; + + if (index < 1 || index > gpGlobals->maxClients) { + AMX_RAISEERROR(amx, AMX_ERR_NATIVE); + return 0; + } + + edict_t *Player = INDEXENT(index); + +#ifndef __linux__ + off -= 5; +#endif + + *((float *)Player->pvPrivateData + off) = params[3]; + + return 1; +} + +//(BAILOPAN) +//Gets a pvPrivateData offset for a player (player, offset, float=0) +static cell AMX_NATIVE_CALL get_offset(AMX *amx, cell *params) +{ + int index = params[1]; + int off = params[2]; + + if (index < 1 || index > gpGlobals->maxClients) { + AMX_RAISEERROR(amx, AMX_ERR_NATIVE); + return 0; + } + + edict_t *Player = INDEXENT(index); + +#ifndef __linux__ + off -= 5; +#endif + + return (int)*((int *)Player->pvPrivateData + off); + + return 1; +} + +//(BAILOPAN) +//Gets a pvPrivateData offset for a player (player, offset, float=0) +static cell AMX_NATIVE_CALL get_offset_float(AMX *amx, cell *params) +{ + int index = params[1]; + int off = params[2]; + float retVal; + + if (index < 1 || index > gpGlobals->maxClients) { + AMX_RAISEERROR(amx, AMX_ERR_NATIVE); + return 0; + } + + edict_t *Player = INDEXENT(index); + +#ifndef __linux__ + off -= 5; +#endif + + retVal = ((float)*((float *)Player->pvPrivateData + off)); + + return *(cell*)((void *)&retVal); + + return 1; +} + // Finds edict points that are in a sphere, used in RadiusDamage. edict_t *UTIL_FindEntityInSphere(edict_t *pStart, const Vector &vecCenter, float flRadius) { if (!pStart) pStart = NULL; @@ -2370,7 +2463,7 @@ static cell AMX_NATIVE_CALL FakeTouch(AMX *amx, cell *params) { // This is where we register any Console-variables we have. void GameInit(void) { - CVAR_REGISTER(&vx_version); + CVAR_REGISTER(&amxxe_version); } // Check if they are using a model, if so, don't let CS know. @@ -2725,11 +2818,16 @@ AMX_NATIVE_INFO Engine_Exports[] = { {"RemoveEntity", RemoveEntity}, {"EntityCount", EntityCount}, - { "get_user_velocity", get_user_velocity }, - { "set_user_velocity", set_user_velocity }, - { "get_grenade_id", get_grenade_id }, - { "set_user_footsteps", set_user_footsteps }, - { "get_user_footsteps", set_user_footsteps }, + {"get_user_velocity", get_user_velocity }, + {"set_user_velocity", set_user_velocity }, + {"get_grenade_id", get_grenade_id }, + {"set_user_footsteps", set_user_footsteps }, + {"get_user_footsteps", set_user_footsteps }, + + {"get_offset", get_offset}, + {"get_offset_float", get_offset_float}, + {"set_offset", set_offset}, + {"set_offset_float", set_offset_float}, {"TraceLn", TraceLn}, {"TraceNormal", TraceNormal},