Upload 2197 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- scripts/$PBOPREFIX$.txt +6 -0
- scripts/1_Core/DayZ/constants.c +106 -0
- scripts/1_Core/DayZ/defines.c +139 -0
- scripts/1_Core/DayZ/param.c +357 -0
- scripts/1_Core/DayZ/proto/DbgUI.c +94 -0
- scripts/1_Core/DayZ/proto/EnAudio.c +9 -0
- scripts/1_Core/DayZ/proto/EnConvert.c +653 -0
- scripts/1_Core/DayZ/proto/EnDebug.c +341 -0
- scripts/1_Core/DayZ/proto/EnEntity.c +870 -0
- scripts/1_Core/DayZ/proto/EnMath.c +704 -0
- scripts/1_Core/DayZ/proto/EnMath3D.c +474 -0
- scripts/1_Core/DayZ/proto/EnPhysics.c +327 -0
- scripts/1_Core/DayZ/proto/EnProfiler.c +762 -0
- scripts/1_Core/DayZ/proto/EnScript.c +1003 -0
- scripts/1_Core/DayZ/proto/EnString.c +529 -0
- scripts/1_Core/DayZ/proto/EnSystem.c +534 -0
- scripts/1_Core/DayZ/proto/EnVRDevice.c +281 -0
- scripts/1_Core/DayZ/proto/EnVisual.c +244 -0
- scripts/1_Core/DayZ/proto/EnWidgets.c +712 -0
- scripts/1_Core/DayZ/proto/EnWorld.c +436 -0
- scripts/1_Core/DayZ/proto/Serializer.c +112 -0
- scripts/1_Core/DayZ/proto/proto.c +390 -0
- scripts/1_Core/DayZ/script.c +12 -0
- scripts/1_Core/DayZ/workbenchApi.c +151 -0
- scripts/2_GameLib/DayZ/components/gameLibComponents.c +276 -0
- scripts/2_GameLib/DayZ/entities/RenderTarget.c +79 -0
- scripts/2_GameLib/DayZ/entities/ScriptCamera.c +172 -0
- scripts/2_GameLib/DayZ/entities/ScriptLight.c +40 -0
- scripts/2_GameLib/DayZ/entities/ScriptModel.c +62 -0
- scripts/2_GameLib/DayZ/entities/WorldsMenu.c +97 -0
- scripts/2_GameLib/DayZ/entities/gameLibEntities.c +141 -0
- scripts/2_GameLib/DayZ/gameLib.c +158 -0
- scripts/2_GameLib/DayZ/inputManager.c +46 -0
- scripts/2_GameLib/DayZ/menuManager.c +95 -0
- scripts/2_GameLib/DayZ/settings.c +38 -0
- scripts/2_GameLib/DayZ/tools.c +216 -0
- scripts/3_Game/DayZ/AI/AIAgent.c +8 -0
- scripts/3_Game/DayZ/AI/AIGroup.c +15 -0
- scripts/3_Game/DayZ/AI/AIGroupBehaviour.c +32 -0
- scripts/3_Game/DayZ/AI/AIWorld.c +123 -0
- scripts/3_Game/DayZ/AIBehaviour.c +147 -0
- scripts/3_Game/DayZ/AmmoCamParams.c +17 -0
- scripts/3_Game/DayZ/AmmoEffects.c +137 -0
- scripts/3_Game/DayZ/Analytics/AnalyticsManagerClient.c +180 -0
- scripts/3_Game/DayZ/Analytics/AnalyticsManagerServer.c +73 -0
- scripts/3_Game/DayZ/Analytics/ScriptAnalytics.c +176 -0
- scripts/3_Game/DayZ/Anim/AnimCommand.c +35 -0
- scripts/3_Game/DayZ/BillboardSet.c +120 -0
- scripts/3_Game/DayZ/BleedChanceData.c +131 -0
- scripts/3_Game/DayZ/CE/CentralEconomy.c +768 -0
scripts/$PBOPREFIX$.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//<'scripts.pbo' properties via Mikero's dos tools, dll version 9.36>
|
| 2 |
+
product=dayz;
|
| 3 |
+
prefix=scripts;
|
| 4 |
+
version=105080;
|
| 5 |
+
//PboType=Arma Addon;
|
| 6 |
+
//</properties>
|
scripts/1_Core/DayZ/constants.c
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* \defgroup Constants Constants
|
| 3 |
+
* \desc static script constants
|
| 4 |
+
* @{
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* \defgroup InputDevice InputDevice
|
| 10 |
+
* \desc constants for input device - inputInterfaceDef.h
|
| 11 |
+
* @{
|
| 12 |
+
*/
|
| 13 |
+
const int INPUT_MODULE_TYPE_MASK = 0x00700000;
|
| 14 |
+
const int INPUT_KEY_MASK = 0x000000ff;
|
| 15 |
+
const int INPUT_ACTION_TYPE_MASK = 0x00000f00;
|
| 16 |
+
const int INPUT_AXIS = 0x00010000;
|
| 17 |
+
const int INPUT_POV = 0x00020000;
|
| 18 |
+
const int INPUT_COMBO_MASK = 0xff000000;
|
| 19 |
+
const int INPUT_COMBO_AXIS = 0x00800000;
|
| 20 |
+
const int INPUT_COMBO_AXIS_OFFSET = 0x00000080;
|
| 21 |
+
const int INPUT_COMBO_KEY_OFFSET = 0x01000000;
|
| 22 |
+
|
| 23 |
+
const int INPUT_DEVICE_KEYBOARD = 0x00000000;
|
| 24 |
+
const int INPUT_DEVICE_MOUSE = 0x00100000; // mouse button
|
| 25 |
+
const int INPUT_DEVICE_STICK = 0x00200000;
|
| 26 |
+
const int INPUT_DEVICE_XINPUT = 0x00300000; // XInput device
|
| 27 |
+
const int INPUT_DEVICE_TRACKIR = 0x00400000;
|
| 28 |
+
const int INPUT_DEVICE_GAMEPAD = 0x00500000;
|
| 29 |
+
const int INPUT_DEVICE_CHEAT = 0x00600000;
|
| 30 |
+
|
| 31 |
+
const int INPUT_ACTION_TYPE_NONE = 0x00000000;
|
| 32 |
+
const int INPUT_ACTION_TYPE_STATE = 0x00000100;
|
| 33 |
+
const int INPUT_ACTION_TYPE_DOWN_EVENT = 0x00000200;
|
| 34 |
+
const int INPUT_ACTION_TYPE_UP_EVENT = 0x00000300;
|
| 35 |
+
const int INPUT_ACTION_TYPE_SHORTCLICK_EVENT= 0x00000400;
|
| 36 |
+
const int INPUT_ACTION_TYPE_HOLD_EVENT = 0x00000500;
|
| 37 |
+
|
| 38 |
+
const int INPUT_ACTION_TYPE_COMBO = 0x00002000;
|
| 39 |
+
const int INPUT_ACTION_TYPE_SPECIALCOMBO = 0x00004000;
|
| 40 |
+
const int INPUT_ACTION_TYPE_DOUBLETAP = 0x00008000;
|
| 41 |
+
|
| 42 |
+
const int INPUT_DEVICE_MOUSE_AXIS = (INPUT_DEVICE_MOUSE | INPUT_AXIS);
|
| 43 |
+
const int INPUT_DEVICE_STICK_AXIS = (INPUT_DEVICE_STICK | INPUT_AXIS);
|
| 44 |
+
const int INPUT_DEVICE_STICK_POV = (INPUT_DEVICE_STICK | INPUT_POV);
|
| 45 |
+
const int INPUT_DEVICE_GAMEPAD_AXIS = (INPUT_DEVICE_GAMEPAD | INPUT_AXIS);
|
| 46 |
+
|
| 47 |
+
/** @}*/
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* \defgroup StringConstants String constants
|
| 51 |
+
* \desc String constants
|
| 52 |
+
* @{
|
| 53 |
+
*/
|
| 54 |
+
const string STRING_EMPTY = "";
|
| 55 |
+
/** @}*/
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
|
| 60 |
+
* \defgroup Colors Colors
|
| 61 |
+
* @{
|
| 62 |
+
*/
|
| 63 |
+
const int COLOR_WHITE = 0xFFFFFFFF;
|
| 64 |
+
const int COLOR_RED = 0xFFF22613;
|
| 65 |
+
const int COLOR_GREEN = 0xFF2ECC71;
|
| 66 |
+
const int COLOR_BLUE = 0xFF4B77BE;
|
| 67 |
+
const int COLOR_YELLOW = 0xFFF7CA18;
|
| 68 |
+
|
| 69 |
+
const int COLOR_RED_A = 0x1fF22613;
|
| 70 |
+
const int COLOR_GREEN_A = 0x1f2ECC71;
|
| 71 |
+
const int COLOR_BLUE_A = 0x1f4B77BE;
|
| 72 |
+
const int COLOR_YELLOW_A = 0x1fF7CA18;
|
| 73 |
+
|
| 74 |
+
/** @}*/
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
|
| 78 |
+
* \defgroup Materials Materials
|
| 79 |
+
* @{
|
| 80 |
+
*/
|
| 81 |
+
|
| 82 |
+
/****************************************************************************
|
| 83 |
+
* MATERIALS LIST
|
| 84 |
+
*
|
| 85 |
+
* Note: If you add new materials here, don't forget to add physics
|
| 86 |
+
* parameters to them in physics/materials.xml
|
| 87 |
+
***************************************************************************/
|
| 88 |
+
const int MATERIAL_DEFAULT = 0;
|
| 89 |
+
const int MATERIAL_METAL = 1; //full steel
|
| 90 |
+
const int MATERIAL_IRON = 2; //iron
|
| 91 |
+
const int MATERIAL_GLASS = 3; //glass pane
|
| 92 |
+
const int MATERIAL_PLASTIC = 4; //plastic object
|
| 93 |
+
const int MATERIAL_LIQUID = 5; //liquids, water
|
| 94 |
+
const int MATERIAL_SLIME = 6; //slime, oil etc
|
| 95 |
+
const int MATERIAL_BETON = 7; //concrete
|
| 96 |
+
const int MATERIAL_RUBBER = 8; //rubber, linoeum
|
| 97 |
+
const int MATERIAL_FLESH = 9; //flesh, humanoids
|
| 98 |
+
const int MATERIAL_GRASS = 10; //grass
|
| 99 |
+
const int MATERIAL_WOOD = 11; //wood
|
| 100 |
+
const int MATERIAL_SNOW = 12; //snow
|
| 101 |
+
const int MATERIAL_SAND = 13; //soft sand
|
| 102 |
+
const int MATERIAL_DIRT = 14; //super-soft dirt
|
| 103 |
+
const int MATERIAL_GRAVEL = 15; //gravel
|
| 104 |
+
const int MATERIAL_STONE = 16; //rocks, cliffs
|
| 105 |
+
|
| 106 |
+
/** @}*/
|
scripts/1_Core/DayZ/defines.c
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// All defines in this file are added from C++ side
|
| 2 |
+
// It simply exists for documentation purposes
|
| 3 |
+
#ifdef DOXYGEN
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* \defgroup Defines Defines
|
| 7 |
+
* \desc static defines
|
| 8 |
+
* @{
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
/*!
|
| 12 |
+
\brief Define filled in with the current Major and Minor version (e.g. DAYZ_1_16)
|
| 13 |
+
*/
|
| 14 |
+
#define DAYZ_X_XX
|
| 15 |
+
|
| 16 |
+
/*!
|
| 17 |
+
\brief Enabled when game is in Buldozer mode
|
| 18 |
+
*/
|
| 19 |
+
#define BULDOZER
|
| 20 |
+
|
| 21 |
+
/*!
|
| 22 |
+
\brief Enabled when script is compiled for Workbench
|
| 23 |
+
*/
|
| 24 |
+
#define WORKBENCH
|
| 25 |
+
|
| 26 |
+
/*!
|
| 27 |
+
\note Present for server builds
|
| 28 |
+
*/
|
| 29 |
+
#define NO_GUI
|
| 30 |
+
|
| 31 |
+
/*!
|
| 32 |
+
\note Present for server builds
|
| 33 |
+
*/
|
| 34 |
+
#define NO_GUI_INGAME
|
| 35 |
+
|
| 36 |
+
/*!
|
| 37 |
+
\note Work in progress feature flag to prevent cursor from being hijacked by the game. Original intention was only DEVELOPER_DIAG but the fix later introduced problems in retail.
|
| 38 |
+
*/
|
| 39 |
+
#define FEATURE_CURSOR
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* \defgroup BuildDefines Build defines
|
| 45 |
+
* \desc Defines for different builds
|
| 46 |
+
* @{
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
/*!
|
| 50 |
+
\brief Define present in Diag builds
|
| 51 |
+
*/
|
| 52 |
+
#define DIAG
|
| 53 |
+
|
| 54 |
+
/*!
|
| 55 |
+
\note A build is always either DEVELOPER or RELEASE, one is always active
|
| 56 |
+
*/
|
| 57 |
+
#define DEVELOPER
|
| 58 |
+
|
| 59 |
+
/*!
|
| 60 |
+
\note includes Diag
|
| 61 |
+
*/
|
| 62 |
+
#define RELEASE
|
| 63 |
+
|
| 64 |
+
/*!
|
| 65 |
+
\brief DIAG || DEVELOPER
|
| 66 |
+
*/
|
| 67 |
+
#define DIAG_DEVELOPER
|
| 68 |
+
|
| 69 |
+
/*!
|
| 70 |
+
\brief Define present in Experimental builds
|
| 71 |
+
*/
|
| 72 |
+
#define BUILD_EXPERIMENTAL
|
| 73 |
+
|
| 74 |
+
/** @}*/
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* \defgroup ServerDefines Server defines
|
| 80 |
+
* \desc Defines for dedicated server code
|
| 81 |
+
* \note Only defined when CGame.IsDedicatedServer equals true
|
| 82 |
+
* \note The platforms mentioned are the client platform, for game platform use PLATFORM defines
|
| 83 |
+
* @{
|
| 84 |
+
*/
|
| 85 |
+
|
| 86 |
+
/*!
|
| 87 |
+
\brief Define always present on dedicated servers
|
| 88 |
+
\note Should be preferred over using CGame.IsDedicatedServer when possible
|
| 89 |
+
*/
|
| 90 |
+
#define SERVER
|
| 91 |
+
|
| 92 |
+
/*!
|
| 93 |
+
\warning This is defined for Linux servers as well, as it targets Windows clients
|
| 94 |
+
\note A server is always either FOR_WINDOWS, FOR_X1 or FOR_PS4
|
| 95 |
+
*/
|
| 96 |
+
#define SERVER_FOR_WINDOWS
|
| 97 |
+
|
| 98 |
+
/*!
|
| 99 |
+
\note A server is always either FOR_WINDOWS, FOR_X1 or FOR_PS4
|
| 100 |
+
*/
|
| 101 |
+
#define SERVER_FOR_X1
|
| 102 |
+
|
| 103 |
+
/*!
|
| 104 |
+
\note A server is always either FOR_WINDOWS, FOR_X1 or FOR_PS4
|
| 105 |
+
*/
|
| 106 |
+
#define SERVER_FOR_PS4
|
| 107 |
+
|
| 108 |
+
/*!
|
| 109 |
+
\brief SERVER_FOR_X1 || SERVER_FOR_PS4
|
| 110 |
+
*/
|
| 111 |
+
#define SERVER_FOR_CONSOLE
|
| 112 |
+
|
| 113 |
+
/** @}*/
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* \defgroup PlatformDefines Platform defines
|
| 119 |
+
* \desc Defines for platform the build is built for
|
| 120 |
+
* @{
|
| 121 |
+
*/
|
| 122 |
+
|
| 123 |
+
#define PLATFORM_LINUX
|
| 124 |
+
|
| 125 |
+
#define PLATFORM_WINDOWS
|
| 126 |
+
|
| 127 |
+
#define PLATFORM_XBOX
|
| 128 |
+
|
| 129 |
+
#define PLATFORM_PS4
|
| 130 |
+
|
| 131 |
+
/*!
|
| 132 |
+
\brief PLATFORM_XBOX || PLATFORM_PS4
|
| 133 |
+
*/
|
| 134 |
+
#define PLATFORM_CONSOLE
|
| 135 |
+
|
| 136 |
+
/** @}*/
|
| 137 |
+
|
| 138 |
+
/** @}*/
|
| 139 |
+
#endif
|
scripts/1_Core/DayZ/param.c
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* \defgroup Tools Tools
|
| 3 |
+
* \desc Helpful functions & classes
|
| 4 |
+
* @{
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
//-----------------------------------------------------------------------------
|
| 8 |
+
/**
|
| 9 |
+
\brief Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Param4 templates
|
| 10 |
+
*/
|
| 11 |
+
class Param: Managed
|
| 12 |
+
{
|
| 13 |
+
bool Serialize(Serializer ctx)
|
| 14 |
+
{
|
| 15 |
+
return false;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
bool Deserializer(Serializer ctx)
|
| 19 |
+
{
|
| 20 |
+
return false;
|
| 21 |
+
}
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
\brief Param Class Template with one parameter.
|
| 26 |
+
\n usage:
|
| 27 |
+
@code
|
| 28 |
+
Param paramA = new Param1<int>(55);
|
| 29 |
+
Param paramB = new Param1<string>("Hello");
|
| 30 |
+
@endcode
|
| 31 |
+
*/
|
| 32 |
+
class Param1<Class T1> extends Param
|
| 33 |
+
{
|
| 34 |
+
T1 param1;
|
| 35 |
+
|
| 36 |
+
void Param1(T1 p1)
|
| 37 |
+
{
|
| 38 |
+
param1 = p1;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
override bool Serialize(Serializer ctx)
|
| 42 |
+
{
|
| 43 |
+
return ctx.Write(param1);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
override bool Deserializer(Serializer ctx)
|
| 47 |
+
{
|
| 48 |
+
return ctx.Read(param1);
|
| 49 |
+
}
|
| 50 |
+
};
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
\brief Param Class Template with two parameters.
|
| 54 |
+
\n usage:
|
| 55 |
+
@code
|
| 56 |
+
Param param = new Param2<float, string>(3.14, "Pi");
|
| 57 |
+
@endcode
|
| 58 |
+
*/
|
| 59 |
+
class Param2<Class T1, Class T2> extends Param
|
| 60 |
+
{
|
| 61 |
+
T1 param1;
|
| 62 |
+
T2 param2;
|
| 63 |
+
|
| 64 |
+
void Param2(T1 p1, T2 p2)
|
| 65 |
+
{
|
| 66 |
+
param1 = p1;
|
| 67 |
+
param2 = p2;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
override bool Serialize(Serializer ctx)
|
| 71 |
+
{
|
| 72 |
+
return ctx.Write(param1) && ctx.Write(param2);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
override bool Deserializer(Serializer ctx)
|
| 76 |
+
{
|
| 77 |
+
return ctx.Read(param1) && ctx.Read(param2);
|
| 78 |
+
}
|
| 79 |
+
};
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
\brief Param Class Template with three parameters.
|
| 83 |
+
\n usage:
|
| 84 |
+
@code
|
| 85 |
+
Param param = new Param3<float, string, bool>(2.89, "Lala", true);
|
| 86 |
+
@endcode
|
| 87 |
+
*/
|
| 88 |
+
class Param3<Class T1, Class T2, Class T3> extends Param
|
| 89 |
+
{
|
| 90 |
+
T1 param1;
|
| 91 |
+
T2 param2;
|
| 92 |
+
T3 param3;
|
| 93 |
+
|
| 94 |
+
void Param3(T1 p1, T2 p2, T3 p3)
|
| 95 |
+
{
|
| 96 |
+
param1 = p1;
|
| 97 |
+
param2 = p2;
|
| 98 |
+
param3 = p3;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
override bool Serialize(Serializer ctx)
|
| 102 |
+
{
|
| 103 |
+
return ctx.Write(param1) && ctx.Write(param2) && ctx.Write(param3);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
override bool Deserializer(Serializer ctx)
|
| 107 |
+
{
|
| 108 |
+
return ctx.Read(param1) && ctx.Read(param2) && ctx.Read(param3);
|
| 109 |
+
}
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
/**
|
| 113 |
+
\brief Param Class Template with four parameters.
|
| 114 |
+
\n usage:
|
| 115 |
+
@code
|
| 116 |
+
Param param = new Param4<int, bool, float, string>(100, false, 79.9, "Test");
|
| 117 |
+
@endcode
|
| 118 |
+
*/
|
| 119 |
+
class Param4<Class T1, Class T2, Class T3, Class T4> extends Param
|
| 120 |
+
{
|
| 121 |
+
T1 param1;
|
| 122 |
+
T2 param2;
|
| 123 |
+
T3 param3;
|
| 124 |
+
T4 param4;
|
| 125 |
+
|
| 126 |
+
void Param4(T1 p1, T2 p2, T3 p3, T4 p4)
|
| 127 |
+
{
|
| 128 |
+
param1 = p1;
|
| 129 |
+
param2 = p2;
|
| 130 |
+
param3 = p3;
|
| 131 |
+
param4 = p4;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
override bool Serialize(Serializer ctx)
|
| 135 |
+
{
|
| 136 |
+
return ctx.Write(param1) && ctx.Write(param2) && ctx.Write(param3) && ctx.Write(param4);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
override bool Deserializer(Serializer ctx)
|
| 140 |
+
{
|
| 141 |
+
return ctx.Read(param1) && ctx.Read(param2) && ctx.Read(param3) && ctx.Read(param4);
|
| 142 |
+
}
|
| 143 |
+
};
|
| 144 |
+
|
| 145 |
+
/**
|
| 146 |
+
\brief Param Class Template with five parameters.
|
| 147 |
+
*/
|
| 148 |
+
class Param5<Class T1, Class T2, Class T3, Class T4, Class T5> extends Param
|
| 149 |
+
{
|
| 150 |
+
T1 param1;
|
| 151 |
+
T2 param2;
|
| 152 |
+
T3 param3;
|
| 153 |
+
T4 param4;
|
| 154 |
+
T5 param5;
|
| 155 |
+
|
| 156 |
+
void Param5(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
|
| 157 |
+
{
|
| 158 |
+
param1 = p1;
|
| 159 |
+
param2 = p2;
|
| 160 |
+
param3 = p3;
|
| 161 |
+
param4 = p4;
|
| 162 |
+
param5 = p5;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
override bool Serialize(Serializer ctx)
|
| 166 |
+
{
|
| 167 |
+
return ctx.Write(param1) && ctx.Write(param2) && ctx.Write(param3) && ctx.Write(param4) && ctx.Write(param5);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
override bool Deserializer(Serializer ctx)
|
| 171 |
+
{
|
| 172 |
+
return ctx.Read(param1) && ctx.Read(param2) && ctx.Read(param3) && ctx.Read(param4) && ctx.Read(param5);
|
| 173 |
+
}
|
| 174 |
+
};
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
\brief Param Class Template with six parameters.
|
| 178 |
+
*/
|
| 179 |
+
class Param6<Class T1, Class T2, Class T3, Class T4, Class T5, Class T6> extends Param
|
| 180 |
+
{
|
| 181 |
+
T1 param1;
|
| 182 |
+
T2 param2;
|
| 183 |
+
T3 param3;
|
| 184 |
+
T4 param4;
|
| 185 |
+
T5 param5;
|
| 186 |
+
T6 param6;
|
| 187 |
+
|
| 188 |
+
void Param6(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6)
|
| 189 |
+
{
|
| 190 |
+
param1 = p1;
|
| 191 |
+
param2 = p2;
|
| 192 |
+
param3 = p3;
|
| 193 |
+
param4 = p4;
|
| 194 |
+
param5 = p5;
|
| 195 |
+
param6 = p6;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
override bool Serialize(Serializer ctx)
|
| 199 |
+
{
|
| 200 |
+
return ctx.Write(param1) && ctx.Write(param2) && ctx.Write(param3) && ctx.Write(param4) && ctx.Write(param5) && ctx.Write(param6);
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
override bool Deserializer(Serializer ctx)
|
| 204 |
+
{
|
| 205 |
+
return ctx.Read(param1) && ctx.Read(param2) && ctx.Read(param3) && ctx.Read(param4) && ctx.Read(param5) && ctx.Read(param6);
|
| 206 |
+
}
|
| 207 |
+
};
|
| 208 |
+
|
| 209 |
+
/**
|
| 210 |
+
\brief Param Class Template with seven parameters.
|
| 211 |
+
*/
|
| 212 |
+
class Param7<Class T1, Class T2, Class T3, Class T4, Class T5, Class T6, Class T7>: Param
|
| 213 |
+
{
|
| 214 |
+
T1 param1;
|
| 215 |
+
T2 param2;
|
| 216 |
+
T3 param3;
|
| 217 |
+
T4 param4;
|
| 218 |
+
T5 param5;
|
| 219 |
+
T6 param6;
|
| 220 |
+
T7 param7;
|
| 221 |
+
|
| 222 |
+
void Param7(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7)
|
| 223 |
+
{
|
| 224 |
+
param1 = p1;
|
| 225 |
+
param2 = p2;
|
| 226 |
+
param3 = p3;
|
| 227 |
+
param4 = p4;
|
| 228 |
+
param5 = p5;
|
| 229 |
+
param6 = p6;
|
| 230 |
+
param7 = p7;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
override bool Serialize(Serializer ctx)
|
| 234 |
+
{
|
| 235 |
+
return ctx.Write(param1) && ctx.Write(param2) && ctx.Write(param3) && ctx.Write(param4) && ctx.Write(param5) && ctx.Write(param6) && ctx.Write(param7);
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
override bool Deserializer(Serializer ctx)
|
| 239 |
+
{
|
| 240 |
+
return ctx.Read(param1) && ctx.Read(param2) && ctx.Read(param3) && ctx.Read(param4) && ctx.Read(param5) && ctx.Read(param6) && ctx.Read(param7);
|
| 241 |
+
}
|
| 242 |
+
};
|
| 243 |
+
/**
|
| 244 |
+
\brief Param Class Template with eight parameters.
|
| 245 |
+
*/
|
| 246 |
+
class Param8<Class T1, Class T2, Class T3, Class T4, Class T5, Class T6, Class T7, Class T8>: Param
|
| 247 |
+
{
|
| 248 |
+
T1 param1;
|
| 249 |
+
T2 param2;
|
| 250 |
+
T3 param3;
|
| 251 |
+
T4 param4;
|
| 252 |
+
T5 param5;
|
| 253 |
+
T6 param6;
|
| 254 |
+
T7 param7;
|
| 255 |
+
T8 param8;
|
| 256 |
+
|
| 257 |
+
void Param8(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8)
|
| 258 |
+
{
|
| 259 |
+
param1 = p1;
|
| 260 |
+
param2 = p2;
|
| 261 |
+
param3 = p3;
|
| 262 |
+
param4 = p4;
|
| 263 |
+
param5 = p5;
|
| 264 |
+
param6 = p6;
|
| 265 |
+
param7 = p7;
|
| 266 |
+
param8 = p8;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
override bool Serialize(Serializer ctx)
|
| 270 |
+
{
|
| 271 |
+
return ctx.Write(param1) && ctx.Write(param2) && ctx.Write(param3) && ctx.Write(param4) && ctx.Write(param5) && ctx.Write(param6) && ctx.Write(param7) && ctx.Write(param8);
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
override bool Deserializer(Serializer ctx)
|
| 275 |
+
{
|
| 276 |
+
return ctx.Read(param1) && ctx.Read(param2) && ctx.Read(param3) && ctx.Read(param4) && ctx.Read(param5) && ctx.Read(param6) && ctx.Read(param7) && ctx.Read(param8);
|
| 277 |
+
}
|
| 278 |
+
};
|
| 279 |
+
/**
|
| 280 |
+
\brief Param Class Template with nine parameters.
|
| 281 |
+
*/
|
| 282 |
+
class Param9<Class T1, Class T2, Class T3, Class T4, Class T5, Class T6, Class T7, Class T8, Class T9>: Param
|
| 283 |
+
{
|
| 284 |
+
T1 param1;
|
| 285 |
+
T2 param2;
|
| 286 |
+
T3 param3;
|
| 287 |
+
T4 param4;
|
| 288 |
+
T5 param5;
|
| 289 |
+
T6 param6;
|
| 290 |
+
T7 param7;
|
| 291 |
+
T8 param8;
|
| 292 |
+
T9 param9;
|
| 293 |
+
|
| 294 |
+
void Param9(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8, T9 p9)
|
| 295 |
+
{
|
| 296 |
+
param1 = p1;
|
| 297 |
+
param2 = p2;
|
| 298 |
+
param3 = p3;
|
| 299 |
+
param4 = p4;
|
| 300 |
+
param5 = p5;
|
| 301 |
+
param6 = p6;
|
| 302 |
+
param7 = p7;
|
| 303 |
+
param8 = p8;
|
| 304 |
+
param9 = p9;
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
override bool Serialize(Serializer ctx)
|
| 308 |
+
{
|
| 309 |
+
return ctx.Write(param1) && ctx.Write(param2) && ctx.Write(param3) && ctx.Write(param4) && ctx.Write(param5) && ctx.Write(param6) && ctx.Write(param7) && ctx.Write(param8) && ctx.Write(param9);
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
override bool Deserializer(Serializer ctx)
|
| 313 |
+
{
|
| 314 |
+
return ctx.Read(param1) && ctx.Read(param2) && ctx.Read(param3) && ctx.Read(param4) && ctx.Read(param5) && ctx.Read(param6) && ctx.Read(param7) && ctx.Read(param8) && ctx.Read(param9);
|
| 315 |
+
}
|
| 316 |
+
};
|
| 317 |
+
/**
|
| 318 |
+
\brief Param Class Template with ten parameters.
|
| 319 |
+
*/
|
| 320 |
+
class Param10<Class T1, Class T2, Class T3, Class T4, Class T5, Class T6, Class T7, Class T8, Class T9, Class T10>: Param
|
| 321 |
+
{
|
| 322 |
+
T1 param1;
|
| 323 |
+
T2 param2;
|
| 324 |
+
T3 param3;
|
| 325 |
+
T4 param4;
|
| 326 |
+
T5 param5;
|
| 327 |
+
T6 param6;
|
| 328 |
+
T7 param7;
|
| 329 |
+
T8 param8;
|
| 330 |
+
T9 param9;
|
| 331 |
+
T10 param10;
|
| 332 |
+
|
| 333 |
+
void Param10(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8, T9 p9, T10 p10)
|
| 334 |
+
{
|
| 335 |
+
param1 = p1;
|
| 336 |
+
param2 = p2;
|
| 337 |
+
param3 = p3;
|
| 338 |
+
param4 = p4;
|
| 339 |
+
param5 = p5;
|
| 340 |
+
param6 = p6;
|
| 341 |
+
param7 = p7;
|
| 342 |
+
param8 = p8;
|
| 343 |
+
param9 = p9;
|
| 344 |
+
param10 = p10;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
override bool Serialize(Serializer ctx)
|
| 348 |
+
{
|
| 349 |
+
return ctx.Write(param1) && ctx.Write(param2) && ctx.Write(param3) && ctx.Write(param4) && ctx.Write(param5) && ctx.Write(param6) && ctx.Write(param7) && ctx.Write(param8) && ctx.Write(param9) && ctx.Write(param10);
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
override bool Deserializer(Serializer ctx)
|
| 353 |
+
{
|
| 354 |
+
return ctx.Read(param1) && ctx.Read(param2) && ctx.Read(param3) && ctx.Read(param4) && ctx.Read(param5) && ctx.Read(param6) && ctx.Read(param7) && ctx.Read(param8) && ctx.Read(param9) && ctx.Read(param10);
|
| 355 |
+
}
|
| 356 |
+
};
|
| 357 |
+
/** @}*/
|
scripts/1_Core/DayZ/proto/DbgUI.c
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @addtogroup Debug
|
| 2 |
+
@{*/
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* \defgroup DebugUI Debug UI API
|
| 6 |
+
\brief Immediate mode debug UI API
|
| 7 |
+
* @{
|
| 8 |
+
Per frame usage example:
|
| 9 |
+
@code
|
| 10 |
+
bool m_ShowDbgUI = false;
|
| 11 |
+
int m_DbgListSelection = 0;
|
| 12 |
+
float m_DbgSliderValue = 0.0;
|
| 13 |
+
autoptr array<string> m_DbgOptions = {"jedna", "dva", "tri"};
|
| 14 |
+
|
| 15 |
+
void OnUpdate(float timeslice)
|
| 16 |
+
{
|
| 17 |
+
DbgUI.Begin("Test");
|
| 18 |
+
DbgUI.Check("Show DbgUI", m_ShowDbgUI);
|
| 19 |
+
if (m_ShowDbgUI)
|
| 20 |
+
{
|
| 21 |
+
DbgUI.Text("DbgUI Test");
|
| 22 |
+
|
| 23 |
+
string name = "";
|
| 24 |
+
DbgUI.InputText("name", name);
|
| 25 |
+
|
| 26 |
+
if (DbgUI.Button("Print name"))
|
| 27 |
+
{
|
| 28 |
+
Print(name);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
DbgUI.List("test list", m_DbgListSelection, m_DbgOptions);
|
| 32 |
+
|
| 33 |
+
DbgUI.Text("Choice = " + m_DbgListSelection.ToString());
|
| 34 |
+
|
| 35 |
+
DbgUI.Spacer(10);
|
| 36 |
+
DbgUI.SliderFloat("slider", m_DbgSliderValue, 0, 100);
|
| 37 |
+
DbgUI.Text("Slider value = " + ftoa(m_DbgSliderValue));
|
| 38 |
+
}
|
| 39 |
+
DbgUI.End();
|
| 40 |
+
}
|
| 41 |
+
@endcode
|
| 42 |
+
|
| 43 |
+
For non-per frame usage example:
|
| 44 |
+
@code
|
| 45 |
+
int m_DbgEventCount = 0;
|
| 46 |
+
void OnEvent(EventType eventTypeId, Param params)
|
| 47 |
+
{
|
| 48 |
+
m_DbgEventCount++;
|
| 49 |
+
|
| 50 |
+
DbgUI.BeginCleanupScope();
|
| 51 |
+
DbgUI.Begin("events", 300, 0);
|
| 52 |
+
DbgUI.Text("Events count = " + m_DbgEventCount.ToString());
|
| 53 |
+
DbgUI.End();
|
| 54 |
+
DbgUI.EndCleanupScope();
|
| 55 |
+
}
|
| 56 |
+
@endcode
|
| 57 |
+
*/
|
| 58 |
+
|
| 59 |
+
class DbgUI
|
| 60 |
+
{
|
| 61 |
+
private void DbgUI() {}
|
| 62 |
+
private void ~DbgUI() {}
|
| 63 |
+
|
| 64 |
+
static proto native void DoUnitTest(); ///< Creates all possible DbgUI widgets. Just for the testing purposes.
|
| 65 |
+
static proto native void Text(string label);
|
| 66 |
+
static proto native void ColoredText(int color, string label);
|
| 67 |
+
static proto void Check(string label, out bool checked);
|
| 68 |
+
static proto void Combo(string label, out int selection, TStringArray elems);
|
| 69 |
+
static proto void List(string label, out int selection, TStringArray elems);
|
| 70 |
+
static proto void SliderFloat(string label, out float value, float min, float max, int pxWidth = 150);
|
| 71 |
+
static proto native void Spacer(int height);
|
| 72 |
+
static proto native void Panel(string label, int width, int height, int color = 0xaa555555);
|
| 73 |
+
static proto native bool Button(string txt, int minWidth = 0);
|
| 74 |
+
static proto void InputText(string txt, out string value, int pxWidth = 150);
|
| 75 |
+
static proto void InputInt(string txt, out int value, int pxWidth = 150);
|
| 76 |
+
static proto void InputFloat(string txt, out float value, int pxWidth = 150);
|
| 77 |
+
|
| 78 |
+
static proto native void PlotLive(string label, int sizeX, int sizeY, float val, int timeStep = 100, int historySize = 30, int color = 0xFFFFFFFF);
|
| 79 |
+
|
| 80 |
+
static proto native void SameLine();
|
| 81 |
+
static proto native void SameSpot();
|
| 82 |
+
|
| 83 |
+
static proto native void PushID_Int(int int_id);
|
| 84 |
+
static proto native void PushID_Str(string str_id);
|
| 85 |
+
static proto native void PopID();
|
| 86 |
+
|
| 87 |
+
static proto void BeginCleanupScope();
|
| 88 |
+
static proto native void EndCleanupScope();
|
| 89 |
+
|
| 90 |
+
static proto native void Begin(string windowTitle, float x = 0, float y = 0);
|
| 91 |
+
static proto native void End();
|
| 92 |
+
};
|
| 93 |
+
//@}
|
| 94 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnAudio.c
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
typedef int[] AudioHandle;
|
| 2 |
+
|
| 3 |
+
class AudioSystem
|
| 4 |
+
{
|
| 5 |
+
proto native static AudioHandle BankLoad(string path);
|
| 6 |
+
proto native static AudioHandle ShaderLoad(string path);
|
| 7 |
+
proto native static AudioHandle SoundPlay(AudioHandle bank, AudioHandle shader);
|
| 8 |
+
proto native static void SoundDestroy(AudioHandle handle);
|
| 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
| 9 |
+
|
| 10 |
+
class func
|
| 11 |
+
{
|
| 12 |
+
//! For internal usage of VM
|
| 13 |
+
private proto void SetInstance(Class inst);
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
enum EBool
|
| 17 |
+
{
|
| 18 |
+
NO = 0,
|
| 19 |
+
YES = 1
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
class int
|
| 23 |
+
{
|
| 24 |
+
protected const int ZERO_PAD_SIZE = 8;
|
| 25 |
+
protected static string m_ZeroPad[ZERO_PAD_SIZE] = {"", "0", "00", "000", "0000", "00000", "000000", "0000000"};
|
| 26 |
+
|
| 27 |
+
const int MAX = 2147483647;
|
| 28 |
+
const int MIN = -2147483648;
|
| 29 |
+
|
| 30 |
+
proto string ToString();
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
\brief Converts ASCII code to string
|
| 34 |
+
\param ascii ASCII code for convert to \p string.
|
| 35 |
+
\return \p string - Converted \p int.
|
| 36 |
+
@code
|
| 37 |
+
int ascii_code = 77;
|
| 38 |
+
string str = ascii_code.AsciiToString();
|
| 39 |
+
Print(str);
|
| 40 |
+
|
| 41 |
+
>> str = 'M'
|
| 42 |
+
@endcode
|
| 43 |
+
*/
|
| 44 |
+
proto string AsciiToString();
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
\brief Integer to string with fixed length, padded with zeroes
|
| 48 |
+
\param num \p int integer to convert
|
| 49 |
+
\param len \p int fixed length
|
| 50 |
+
\return \p vector Converted s as vector
|
| 51 |
+
@code
|
| 52 |
+
int num = 123;
|
| 53 |
+
string s = num.ToStringLen(5);
|
| 54 |
+
Print(s);
|
| 55 |
+
|
| 56 |
+
>> s = '00123'
|
| 57 |
+
@endcode
|
| 58 |
+
*/
|
| 59 |
+
string ToStringLen(int len)
|
| 60 |
+
{
|
| 61 |
+
string str = value.ToString();
|
| 62 |
+
|
| 63 |
+
int l = len - str.Length();
|
| 64 |
+
|
| 65 |
+
if (l > 0 && l < ZERO_PAD_SIZE )
|
| 66 |
+
return m_ZeroPad[l] + str;
|
| 67 |
+
|
| 68 |
+
return str;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
\brief Check whether integer falls into an inclusive range
|
| 73 |
+
\param min \p int low end of range
|
| 74 |
+
\param max \p int high end of range
|
| 75 |
+
\return \p bool True if this value is withing the set range
|
| 76 |
+
@code
|
| 77 |
+
int num = 123;
|
| 78 |
+
bool test = num.InRange( 100, 150 );
|
| 79 |
+
Print(test);
|
| 80 |
+
|
| 81 |
+
>> s = true
|
| 82 |
+
@endcode
|
| 83 |
+
*/
|
| 84 |
+
bool InRange( int min, int max, bool inclusive_min = true, bool inclusive_max = true )
|
| 85 |
+
{
|
| 86 |
+
if( ( !inclusive_min && value <= min ) || value < min )
|
| 87 |
+
return false;
|
| 88 |
+
|
| 89 |
+
if( ( !inclusive_max && value >= max ) || value > max )
|
| 90 |
+
return false;
|
| 91 |
+
|
| 92 |
+
return true;
|
| 93 |
+
}
|
| 94 |
+
};
|
| 95 |
+
|
| 96 |
+
class float
|
| 97 |
+
{
|
| 98 |
+
const float MIN = FLT_MIN;
|
| 99 |
+
const float MAX = FLT_MAX;
|
| 100 |
+
const float LOWEST = -FLT_MAX;
|
| 101 |
+
|
| 102 |
+
proto string ToString();
|
| 103 |
+
};
|
| 104 |
+
|
| 105 |
+
class vector
|
| 106 |
+
{
|
| 107 |
+
static const vector Up = "0 1 0";
|
| 108 |
+
static const vector Aside = "1 0 0";
|
| 109 |
+
static const vector Forward = "0 0 1";
|
| 110 |
+
static const vector Zero = "0 0 0";
|
| 111 |
+
|
| 112 |
+
/**
|
| 113 |
+
\brief Vector to string
|
| 114 |
+
\param beautify If true verbose vector in more human readable form "<1, 1, 1>" instead of simple form "1 1 1"
|
| 115 |
+
\return \p string Converted vector as parsed string
|
| 116 |
+
@code
|
| 117 |
+
vector v = "1 0 1";
|
| 118 |
+
Print( v.ToString() );
|
| 119 |
+
Print( v.ToString(false) );
|
| 120 |
+
|
| 121 |
+
>> '<1, 0, 1>'
|
| 122 |
+
>> '1 0 1'
|
| 123 |
+
@endcode
|
| 124 |
+
*/
|
| 125 |
+
proto string ToString(bool beautify = true);
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
\brief Normalizes vector. Returns length
|
| 129 |
+
\return \p float Length of origin vector
|
| 130 |
+
@code
|
| 131 |
+
vector vec = "1 0 1";
|
| 132 |
+
float length = vec.Normalize();
|
| 133 |
+
Print( vec );
|
| 134 |
+
Print( length );
|
| 135 |
+
|
| 136 |
+
>> vec = <0.707107,0,0.707107>
|
| 137 |
+
>> length = 1.41421
|
| 138 |
+
@endcode
|
| 139 |
+
*/
|
| 140 |
+
proto float Normalize();
|
| 141 |
+
|
| 142 |
+
//! return normalized vector (keeps orginal vector untouched)
|
| 143 |
+
proto vector Normalized();
|
| 144 |
+
|
| 145 |
+
/**
|
| 146 |
+
\brief Returns length of vector (magnitude)
|
| 147 |
+
\return \p float Length of vector
|
| 148 |
+
@code
|
| 149 |
+
vector vec = "1 0 1";
|
| 150 |
+
float length = vec.Length();
|
| 151 |
+
Print( length );
|
| 152 |
+
|
| 153 |
+
>> length = 1.41421
|
| 154 |
+
@endcode
|
| 155 |
+
*/
|
| 156 |
+
proto native float Length();
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
\brief Returns squared length (magnitudeSqr)
|
| 160 |
+
\return \p float Length of vector
|
| 161 |
+
@code
|
| 162 |
+
vector vec = "1 1 0";
|
| 163 |
+
float length = vec.LengthSq();
|
| 164 |
+
Print( length );
|
| 165 |
+
|
| 166 |
+
>> length = 2
|
| 167 |
+
@endcode
|
| 168 |
+
*/
|
| 169 |
+
proto native float LengthSq();
|
| 170 |
+
|
| 171 |
+
/**
|
| 172 |
+
\brief Returns the distance between tips of two 3D vectors.
|
| 173 |
+
\param v1 \p vector 3D Vector 1
|
| 174 |
+
\param v2 \p vector 3D Vector 2
|
| 175 |
+
\return \p float Distance
|
| 176 |
+
@code
|
| 177 |
+
float dist = vector.Distance( "1 2 3", "4 5 6" );
|
| 178 |
+
Print( dist );
|
| 179 |
+
|
| 180 |
+
>> dist = 5.19615
|
| 181 |
+
@endcode
|
| 182 |
+
*/
|
| 183 |
+
proto static native float Distance(vector v1, vector v2);
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
\brief Returns the square distance between tips of two 3D vectors.
|
| 187 |
+
\param v1 \p vector 3D Vector 1
|
| 188 |
+
\param v2 \p vector 3D Vector 2
|
| 189 |
+
\return \p float Squere distance
|
| 190 |
+
@code
|
| 191 |
+
float dist = vector.DistanceSq( "0 0 0", "0 5 0" );
|
| 192 |
+
Print( dist );
|
| 193 |
+
|
| 194 |
+
>> dist = 25
|
| 195 |
+
@endcode
|
| 196 |
+
*/
|
| 197 |
+
proto static native float DistanceSq(vector v1, vector v2);
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
\brief Returns perpendicular vector. Perpendicular vector is computed as cross product between input vector and up vector (0, 1, 0).
|
| 201 |
+
\return \p vector perpendicular vector
|
| 202 |
+
@code
|
| 203 |
+
vector vec = "1 0 0";
|
| 204 |
+
Print( vec.Perpend() );
|
| 205 |
+
|
| 206 |
+
>> <0,0,1>
|
| 207 |
+
@endcode
|
| 208 |
+
*/
|
| 209 |
+
vector Perpend()
|
| 210 |
+
{
|
| 211 |
+
return value * vector.Up;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/**
|
| 215 |
+
\brief Returns direction vector from point p1 to point p2
|
| 216 |
+
\param p1 \p vector point from
|
| 217 |
+
\param p2 \p vector point to
|
| 218 |
+
\return \p vector direction vector
|
| 219 |
+
*/
|
| 220 |
+
static vector Direction(vector p1, vector p2)
|
| 221 |
+
{
|
| 222 |
+
vector dir_vec;
|
| 223 |
+
|
| 224 |
+
dir_vec[0] = p2[0] - p1[0];
|
| 225 |
+
dir_vec[1] = p2[1] - p1[1];
|
| 226 |
+
dir_vec[2] = p2[2] - p1[2];
|
| 227 |
+
|
| 228 |
+
return dir_vec;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
\brief Returns randomly generated unit vector
|
| 233 |
+
\return \p randomly generated unit vector
|
| 234 |
+
@code
|
| 235 |
+
vector vec = vector.RandomDir();
|
| 236 |
+
Print(vec);
|
| 237 |
+
Print(vec.Length());
|
| 238 |
+
|
| 239 |
+
>> <-0.179424,0.966825,0.181816>
|
| 240 |
+
>> 1
|
| 241 |
+
@endcode
|
| 242 |
+
*/
|
| 243 |
+
static vector RandomDir()
|
| 244 |
+
{
|
| 245 |
+
return Vector(Math.RandomFloatInclusive(-1,1),Math.RandomFloatInclusive(-1,1),Math.RandomFloatInclusive(-1,1)).Normalized();
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
/**
|
| 249 |
+
\brief Returns randomly generated XZ unit vector with the Y(up) axis set to 0
|
| 250 |
+
\return \p randomly generated XZ unit vector
|
| 251 |
+
@code
|
| 252 |
+
vector vec = vector.RandomDir();
|
| 253 |
+
Print(vec);
|
| 254 |
+
Print(vec.Length());
|
| 255 |
+
|
| 256 |
+
>> <0.631697,0,0.775216>
|
| 257 |
+
>> 1
|
| 258 |
+
@endcode
|
| 259 |
+
*/
|
| 260 |
+
static vector RandomDir2D()
|
| 261 |
+
{
|
| 262 |
+
return Vector(Math.RandomFloatInclusive(-1,1),0,Math.RandomFloatInclusive(-1,1)).Normalized();
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
/**
|
| 266 |
+
\brief Returns Dot product of vector v1 and vector v2
|
| 267 |
+
\param v1 \p vector input vector
|
| 268 |
+
\param v2 \p vector input vector
|
| 269 |
+
\return \p vector direction vector
|
| 270 |
+
*/
|
| 271 |
+
static float Dot(vector v1, vector v2)
|
| 272 |
+
{
|
| 273 |
+
return ((v1[0] * v2[0]) + (v1[1] * v2[1]) + (v1[2] * v2[2]));
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
/**
|
| 277 |
+
\brief Returns relative angles between -180 and 180, not 0 to 360
|
| 278 |
+
\return \p float Relative angles
|
| 279 |
+
@code
|
| 280 |
+
vector angles = "-45 190 160";
|
| 281 |
+
Print( angles.GetRelAngles() );
|
| 282 |
+
|
| 283 |
+
>> <-45,-170,160>
|
| 284 |
+
@endcode
|
| 285 |
+
*/
|
| 286 |
+
vector GetRelAngles()
|
| 287 |
+
{
|
| 288 |
+
for(int i = 0; i < 3; i++) {
|
| 289 |
+
if(value[i] > 180)
|
| 290 |
+
value[i] = value[i] - 360;
|
| 291 |
+
if(value[i] < -180)
|
| 292 |
+
value[i] = value[i] + 360;
|
| 293 |
+
}
|
| 294 |
+
return value;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
/**
|
| 298 |
+
\brief Returns yaw of vector
|
| 299 |
+
\param vec \p vector Vector to convert yaw
|
| 300 |
+
\return \p float Yaw of vector
|
| 301 |
+
@code
|
| 302 |
+
vector v1 = "0 1 0";
|
| 303 |
+
vector v2 = "0.7 0.7 0";
|
| 304 |
+
Print( v1.ToYaw() );
|
| 305 |
+
Print( v2.ToYaw() );
|
| 306 |
+
|
| 307 |
+
>> 90
|
| 308 |
+
>> 45
|
| 309 |
+
@endcode
|
| 310 |
+
*/
|
| 311 |
+
proto float VectorToYaw();
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
\brief Returns vector of yaw
|
| 315 |
+
\param yaw \p float Value of yaw
|
| 316 |
+
\return \p vector Yaw converted in vector
|
| 317 |
+
@code
|
| 318 |
+
Print( vector.Yaw2Vector(90) );
|
| 319 |
+
Print( vector.Yaw2Vector(45) );
|
| 320 |
+
|
| 321 |
+
>> <0,1,0>
|
| 322 |
+
>> <0.707107,0.707107,0>
|
| 323 |
+
@endcode
|
| 324 |
+
*/
|
| 325 |
+
proto native static vector YawToVector(float yaw);
|
| 326 |
+
|
| 327 |
+
/**
|
| 328 |
+
\brief Converts vector to spherical coordinates with radius = 1
|
| 329 |
+
\return \p vector spherical coordinates (yaw, pitch, roll in degrees)
|
| 330 |
+
@code
|
| 331 |
+
vector v1 = "1 0 1";
|
| 332 |
+
vector v2 = "1 1 1";
|
| 333 |
+
Print( v1.VectorToAngles() );
|
| 334 |
+
Print( v2.VectorToAngles() );
|
| 335 |
+
|
| 336 |
+
>> <45,-0,0>
|
| 337 |
+
>> <45,35.2644,0>
|
| 338 |
+
@endcode
|
| 339 |
+
*/
|
| 340 |
+
proto vector VectorToAngles();
|
| 341 |
+
|
| 342 |
+
/**
|
| 343 |
+
\brief Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector
|
| 344 |
+
\return \p normalized direction vector
|
| 345 |
+
@code
|
| 346 |
+
vector v1 = "45 0 0";
|
| 347 |
+
vector v2 = "15 60 0";
|
| 348 |
+
Print( v1.AnglesToVector() );
|
| 349 |
+
Print( v2.AnglesToVector() );
|
| 350 |
+
|
| 351 |
+
>> <0.707107,0,0.707107>
|
| 352 |
+
>> <0.12941,0.866025,0.482963>
|
| 353 |
+
@endcode
|
| 354 |
+
*/
|
| 355 |
+
proto vector AnglesToVector();
|
| 356 |
+
|
| 357 |
+
/**
|
| 358 |
+
\brief Creates rotation matrix from angles
|
| 359 |
+
\param ang \p vector which contains angles
|
| 360 |
+
\param[out] mat \p vector created rotation matrix
|
| 361 |
+
@code
|
| 362 |
+
vector mat[3];
|
| 363 |
+
vector ang = "70 15 45";
|
| 364 |
+
ang.RotationMatrixFromAngles( mat );
|
| 365 |
+
Print( mat );
|
| 366 |
+
|
| 367 |
+
>> <0.330366,0.0885213,-0.939693>,<0.458809,0.854988,0.241845>,<0.824835,-0.511037,0.241845>
|
| 368 |
+
@endcode
|
| 369 |
+
*/
|
| 370 |
+
proto void RotationMatrixFromAngles(out vector mat[3]);
|
| 371 |
+
|
| 372 |
+
/**
|
| 373 |
+
\brief Transforms position
|
| 374 |
+
\param mat \p vector[4] transformation matrix
|
| 375 |
+
\param vec \p vector position to transform
|
| 376 |
+
\return \p vector transformed position
|
| 377 |
+
@code
|
| 378 |
+
vector mat[4] = { "1 0 0 0", "0 1 0 0", "0 0 1 1", "3 1 2 1" }; // translation matrix
|
| 379 |
+
vector pos = "1 1 1";
|
| 380 |
+
Print( pos.Multiply4(mat) );
|
| 381 |
+
|
| 382 |
+
>> <4,2,3>
|
| 383 |
+
@endcode
|
| 384 |
+
*/
|
| 385 |
+
proto vector Multiply4(vector mat[4]);
|
| 386 |
+
|
| 387 |
+
/**
|
| 388 |
+
\brief Transforms vector
|
| 389 |
+
\param mat \p vector[3] transformation matrix
|
| 390 |
+
\param vec \p vector vector to transform
|
| 391 |
+
\return \p vector transformed vector
|
| 392 |
+
@code
|
| 393 |
+
vector mat[3] = { "2 0 0", "0 3 0", "0 0 1" }; // scale matrix
|
| 394 |
+
vector vec = "1 1 1";
|
| 395 |
+
Print( vec.Multiply3(mat) );
|
| 396 |
+
|
| 397 |
+
>> <2,3,1>
|
| 398 |
+
@endcode
|
| 399 |
+
*/
|
| 400 |
+
proto vector Multiply3(vector mat[3]);
|
| 401 |
+
|
| 402 |
+
/**
|
| 403 |
+
\brief Invert-transforms position
|
| 404 |
+
\param mat \p vector[4] transformation matrix
|
| 405 |
+
\param vec \p vector position to transform
|
| 406 |
+
\return \p vector transformed position
|
| 407 |
+
@code
|
| 408 |
+
vector mat[4] = { "1 0 0 0", "0 1 0 0", "0 0 1 1", "3 1 2 1" }; // translation matrix
|
| 409 |
+
vector pos = "1 1 1";
|
| 410 |
+
Print( pos.InvMultiply4(mat) );
|
| 411 |
+
|
| 412 |
+
>> <-2,0,-1>
|
| 413 |
+
@endcode
|
| 414 |
+
*/
|
| 415 |
+
proto vector InvMultiply4(vector mat[4]);
|
| 416 |
+
|
| 417 |
+
/**
|
| 418 |
+
\brief Invert-transforms vector
|
| 419 |
+
\param mat \p vector[3] transformation matrix
|
| 420 |
+
\param vec \p vector vector to transform
|
| 421 |
+
\return \p vector transformed vector
|
| 422 |
+
@code
|
| 423 |
+
vector mat[3] = { "1.5 2.5 0", "0.1 1.3 0", "0 0 1" }; // rotation matrix
|
| 424 |
+
vector vec = "1 1 1";
|
| 425 |
+
Print( vec.InvMultiply3(mat) );
|
| 426 |
+
|
| 427 |
+
>> <4,1.4,1>
|
| 428 |
+
@endcode
|
| 429 |
+
*/
|
| 430 |
+
proto vector InvMultiply3(vector mat[3]);
|
| 431 |
+
|
| 432 |
+
/**
|
| 433 |
+
\brief Lerp between two vectors
|
| 434 |
+
@code
|
| 435 |
+
vector v1 = Vector(0,0,0);
|
| 436 |
+
vector v2 = Vector(5,6,1);
|
| 437 |
+
Print( vector.Lerp(v1, v2, 0.5) );
|
| 438 |
+
@endcode
|
| 439 |
+
*/
|
| 440 |
+
proto static native vector Lerp(vector v1, vector v2, float t);
|
| 441 |
+
|
| 442 |
+
/**
|
| 443 |
+
\brief Rotate a vector around 0,0,0 by an angle in degrees
|
| 444 |
+
\param vec \p vector to rotate
|
| 445 |
+
\param axis \p axis to rotate around
|
| 446 |
+
\param cosAngle \p angle in degrees
|
| 447 |
+
\return \p vector transformed vector
|
| 448 |
+
*/
|
| 449 |
+
|
| 450 |
+
static vector RotateAroundZeroDeg(vector vec, vector axis, float angle)
|
| 451 |
+
{
|
| 452 |
+
return (vec * Math.Cos(angle * Math.DEG2RAD)) + ((axis * vec) * Math.Sin(angle * Math.DEG2RAD)) + (axis * vector.Dot(axis, vec)) * (1 - Math.Cos(angle * Math.DEG2RAD));
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
/**
|
| 456 |
+
\brief Rotate a vector around 0,0,0 by an angle in radians
|
| 457 |
+
\param vec \p vector to rotate
|
| 458 |
+
\param axis \p axis to rotate around
|
| 459 |
+
\param cosAngle \p angle in radians
|
| 460 |
+
\return \p vector transformed vector
|
| 461 |
+
*/
|
| 462 |
+
|
| 463 |
+
static vector RotateAroundZeroRad(vector vec, vector axis, float angle)
|
| 464 |
+
{
|
| 465 |
+
return (vec * Math.Cos(angle)) + ((axis * vec) * Math.Sin(angle)) + (axis * vector.Dot(axis, vec)) * (1 - Math.Cos(angle));
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
/**
|
| 469 |
+
\brief Rotate a vector around 0,0,0
|
| 470 |
+
\param pos \p vector to rotate
|
| 471 |
+
\param axis \p axis to rotate around
|
| 472 |
+
\param cosAngle \p cos of angle
|
| 473 |
+
\param sinAngle \p sin of angle
|
| 474 |
+
\return \p vector transformed vector
|
| 475 |
+
*/
|
| 476 |
+
|
| 477 |
+
static vector RotateAroundZero(vector pos, vector axis, float cosAngle, float sinAngle)
|
| 478 |
+
{
|
| 479 |
+
return (pos * cosAngle) + ((axis * pos) * sinAngle) + (axis * vector.Dot(axis, pos)) * (1 - cosAngle);
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
/**
|
| 483 |
+
\brief Rotate a vector around point
|
| 484 |
+
\param point \p point to rotate around
|
| 485 |
+
\param pos \p vector to rotate
|
| 486 |
+
\param axis \p axis to rotate around
|
| 487 |
+
\param cosAngle \p cos of angle
|
| 488 |
+
\param sinAngle \p sin of angle
|
| 489 |
+
\return \p vector transformed vector
|
| 490 |
+
*/
|
| 491 |
+
static vector RotateAroundPoint(vector point, vector pos, vector axis, float cosAngle, float sinAngle)
|
| 492 |
+
{
|
| 493 |
+
vector offsetPos = pos - point;
|
| 494 |
+
return RotateAroundZero(offsetPos, axis, cosAngle, sinAngle) + point;
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
/**
|
| 498 |
+
\brief Convert static array of floats into a vector
|
| 499 |
+
\param arr \p vector in array format
|
| 500 |
+
\return \p vector resulting vector
|
| 501 |
+
*/
|
| 502 |
+
static vector ArrayToVec(float arr[])
|
| 503 |
+
{
|
| 504 |
+
return Vector(arr[0], arr[1], arr[2]);
|
| 505 |
+
}
|
| 506 |
+
};
|
| 507 |
+
|
| 508 |
+
class typename
|
| 509 |
+
{
|
| 510 |
+
/**
|
| 511 |
+
\brief Dynamic variant to 'new' keyword. It creates new instance of class
|
| 512 |
+
\returns \p volatile instance of class
|
| 513 |
+
@code
|
| 514 |
+
???
|
| 515 |
+
@endcode
|
| 516 |
+
*/
|
| 517 |
+
proto volatile Class Spawn();
|
| 518 |
+
|
| 519 |
+
/**
|
| 520 |
+
\brief Get the name of the module the typename belongs to
|
| 521 |
+
\returns \p string Name of parent module (1_Core)
|
| 522 |
+
*/
|
| 523 |
+
proto owned string GetModule();
|
| 524 |
+
|
| 525 |
+
//!Returns type name of variable as string
|
| 526 |
+
proto native owned string ToString();
|
| 527 |
+
|
| 528 |
+
/**
|
| 529 |
+
\brief Returns true when type is the same as 'baseType', or inherited one.
|
| 530 |
+
\param baseType typename
|
| 531 |
+
\returns \p bool true when type is the same as 'baseType', or inherited one.
|
| 532 |
+
@code
|
| 533 |
+
???
|
| 534 |
+
@endcode
|
| 535 |
+
*/
|
| 536 |
+
proto native bool IsInherited(typename baseType);
|
| 537 |
+
|
| 538 |
+
proto native int GetVariableCount();
|
| 539 |
+
proto native owned string GetVariableName(int vIdx);
|
| 540 |
+
proto native typename GetVariableType(int vIdx);
|
| 541 |
+
proto bool GetVariableValue(Class var, int vIdx, out void val);
|
| 542 |
+
|
| 543 |
+
/**
|
| 544 |
+
\brief Return string name of enum value
|
| 545 |
+
@code
|
| 546 |
+
DialogPriority prio = DialogPriority.WARNING;
|
| 547 |
+
Print( typename.EnumToString(DialogPriority, prio) );
|
| 548 |
+
@endcode
|
| 549 |
+
*/
|
| 550 |
+
static string EnumToString(typename e, int enumValue)
|
| 551 |
+
{
|
| 552 |
+
int cnt = e.GetVariableCount();
|
| 553 |
+
int val;
|
| 554 |
+
|
| 555 |
+
for (int i = 0; i < cnt; i++)
|
| 556 |
+
{
|
| 557 |
+
if (e.GetVariableType(i) == int && e.GetVariableValue(null, i, val) && val == enumValue)
|
| 558 |
+
{
|
| 559 |
+
return e.GetVariableName(i);
|
| 560 |
+
}
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
return "unknown";
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
/**
|
| 567 |
+
\brief Return enum value from string name
|
| 568 |
+
@code
|
| 569 |
+
Print( typename.StringToEnum(DialogPriority, "WARNING") );
|
| 570 |
+
@endcode
|
| 571 |
+
*/
|
| 572 |
+
static int StringToEnum(typename e, string enumName)
|
| 573 |
+
{
|
| 574 |
+
int count = e.GetVariableCount();
|
| 575 |
+
int value;
|
| 576 |
+
|
| 577 |
+
for (int i = 0; i < count; i++)
|
| 578 |
+
{
|
| 579 |
+
if (e.GetVariableType(i) == int && e.GetVariableValue(null, i, value) && e.GetVariableName(i) == enumName)
|
| 580 |
+
{
|
| 581 |
+
return value;
|
| 582 |
+
}
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
return -1;
|
| 586 |
+
}
|
| 587 |
+
};
|
| 588 |
+
|
| 589 |
+
class EnumTools
|
| 590 |
+
{
|
| 591 |
+
private void EnumTools();
|
| 592 |
+
private void ~EnumTools();
|
| 593 |
+
|
| 594 |
+
/**
|
| 595 |
+
\brief Return string name of enum value
|
| 596 |
+
@code
|
| 597 |
+
DialogPriority prio = DialogPriority.WARNING;
|
| 598 |
+
Print( EnumTools.EnumToString(DialogPriority, prio) );
|
| 599 |
+
@endcode
|
| 600 |
+
*/
|
| 601 |
+
static string EnumToString(typename e, int enumValue)
|
| 602 |
+
{
|
| 603 |
+
return typename.EnumToString(e, enumValue);
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
/**
|
| 607 |
+
\brief Return enum value from string name
|
| 608 |
+
@code
|
| 609 |
+
Print( EnumTools.StringToEnum(DialogPriority, "WARNING") );
|
| 610 |
+
@endcode
|
| 611 |
+
*/
|
| 612 |
+
static int StringToEnum(typename e, string enumName)
|
| 613 |
+
{
|
| 614 |
+
return typename.StringToEnum(e, enumName);
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
/**
|
| 618 |
+
\brief Return amount of values in enum
|
| 619 |
+
@code
|
| 620 |
+
Print( EnumTools.GetEnumSize(DialogPriority) );
|
| 621 |
+
@endcode
|
| 622 |
+
*/
|
| 623 |
+
static int GetEnumSize(typename e)
|
| 624 |
+
{
|
| 625 |
+
return e.GetVariableCount();
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
/**
|
| 629 |
+
\brief Return the nth value in the enum
|
| 630 |
+
@code
|
| 631 |
+
Print( EnumTools.GetEnumValue(DialogPriority, 1) );
|
| 632 |
+
@endcode
|
| 633 |
+
*/
|
| 634 |
+
static int GetEnumValue(typename e, int idx)
|
| 635 |
+
{
|
| 636 |
+
int value;
|
| 637 |
+
e.GetVariableValue(null, idx, value);
|
| 638 |
+
return value;
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
/**
|
| 642 |
+
\brief Return amount of values in enum
|
| 643 |
+
@code
|
| 644 |
+
Print( EnumTools.GetLastEnumValue(DialogPriority) );
|
| 645 |
+
@endcode
|
| 646 |
+
*/
|
| 647 |
+
static int GetLastEnumValue(typename e)
|
| 648 |
+
{
|
| 649 |
+
int lastValue;
|
| 650 |
+
e.GetVariableValue(null, e.GetVariableCount() - 1, lastValue);
|
| 651 |
+
return lastValue;
|
| 652 |
+
}
|
| 653 |
+
}
|
scripts/1_Core/DayZ/proto/EnDebug.c
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* \defgroup Debug Debug utilities
|
| 3 |
+
* @{
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
\brief Prints current call stack (stack trace)
|
| 8 |
+
\return \p void
|
| 9 |
+
@code
|
| 10 |
+
DumpStack();
|
| 11 |
+
|
| 12 |
+
@endcode
|
| 13 |
+
|
| 14 |
+
\verbatim
|
| 15 |
+
Output:
|
| 16 |
+
-- Stack trace --
|
| 17 |
+
SaveFile() Scripts\Entities\Modules\ModuleBase\ModuleFileHandler.c : 51
|
| 18 |
+
SaveConfigToFile() Scripts\Entities\Modules\ModuleBase\ModuleFileHandler\ModuleLocalProfile.c : 114
|
| 19 |
+
SaveParameterArray() Scripts\Entities\Modules\ModuleBase\ModuleFileHandler\ModuleLocalProfile.c : 133
|
| 20 |
+
SetParameterArray() Scripts\Entities\Modules\ModuleBase\ModuleFileHandler\ModuleLocalProfile.c : 231
|
| 21 |
+
PresetAdd() Scripts\Entities\Modules\ModuleBase\ModuleFileHandler\ModuleLocalProfile\ModuleLocalProfileUI.h : 46
|
| 22 |
+
OnKeyPress() Scripts/mission/missionGameplay.c : 215
|
| 23 |
+
OnKeyPress() Scripts/DayZGame.c : 334
|
| 24 |
+
-----------------
|
| 25 |
+
\endverbatim
|
| 26 |
+
*/
|
| 27 |
+
proto void DumpStack();
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
\brief Prints current call stack (stack trace) to given output
|
| 31 |
+
\return \p void
|
| 32 |
+
@code
|
| 33 |
+
string tmp;
|
| 34 |
+
DumpStackString(tmp);
|
| 35 |
+
Print(tmp);
|
| 36 |
+
|
| 37 |
+
@endcode
|
| 38 |
+
|
| 39 |
+
\verbatim
|
| 40 |
+
Output:
|
| 41 |
+
SaveFile() Scripts\Entities\Modules\ModuleBase\ModuleFileHandler.c : 51
|
| 42 |
+
SaveConfigToFile() Scripts\Entities\Modules\ModuleBase\ModuleFileHandler\ModuleLocalProfile.c : 114
|
| 43 |
+
SaveParameterArray() Scripts\Entities\Modules\ModuleBase\ModuleFileHandler\ModuleLocalProfile.c : 133
|
| 44 |
+
SetParameterArray() Scripts\Entities\Modules\ModuleBase\ModuleFileHandler\ModuleLocalProfile.c : 231
|
| 45 |
+
PresetAdd() Scripts\Entities\Modules\ModuleBase\ModuleFileHandler\ModuleLocalProfile\ModuleLocalProfileUI.h : 46
|
| 46 |
+
OnKeyPress() Scripts/mission/missionGameplay.c : 215
|
| 47 |
+
OnKeyPress() Scripts/DayZGame.c : 334
|
| 48 |
+
\endverbatim
|
| 49 |
+
*/
|
| 50 |
+
proto void DumpStackString(out string stack);
|
| 51 |
+
|
| 52 |
+
//! Triggers breakpoint in C++ in run time(when app is running in debug enviroment)
|
| 53 |
+
proto void DebugBreak(bool condition = true, void param1 = NULL, void param2 = NULL, void param3 = NULL, void param4 = NULL, void param5 = NULL, void param6 = NULL, void param7 = NULL, void param8 = NULL, void param9 = NULL);
|
| 54 |
+
|
| 55 |
+
//! Triggers breakpoint in C++ in compile time(when app is running in debug enviroment)
|
| 56 |
+
void CompileBreak();
|
| 57 |
+
|
| 58 |
+
//! Prints content of variable to console/log. Should be used for critical messages so it will appear in debug log
|
| 59 |
+
proto void DPrint(string var);
|
| 60 |
+
|
| 61 |
+
enum ErrorExSeverity
|
| 62 |
+
{
|
| 63 |
+
INFO,
|
| 64 |
+
WARNING,
|
| 65 |
+
ERROR,
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
\brief Error message, prefixed by method name, above 'INFO' will show a messagebox
|
| 70 |
+
\note Format: [%className%::%methodName%] :: [%severity%] :: %errString%
|
| 71 |
+
\param \p string Error message to use
|
| 72 |
+
@code
|
| 73 |
+
class ErrorExTest
|
| 74 |
+
{
|
| 75 |
+
void ThrowWarning()
|
| 76 |
+
{
|
| 77 |
+
// [ErrorExTest::ThrowWarning] :: [WARNING] :: This is a warning.
|
| 78 |
+
ErrorEx("This is a warning.", ErrorExSeverity.WARNING);
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
@endcode
|
| 82 |
+
*/
|
| 83 |
+
proto void ErrorEx(string err, ErrorExSeverity severity = ErrorExSeverity.ERROR);
|
| 84 |
+
proto void ErrorExString(string err, out string str, ErrorExSeverity severity = ErrorExSeverity.ERROR);
|
| 85 |
+
|
| 86 |
+
//! Messagebox with error message
|
| 87 |
+
proto native void Error2(string title, string err);
|
| 88 |
+
|
| 89 |
+
//! Messagebox with error message
|
| 90 |
+
void Error(string err)
|
| 91 |
+
{
|
| 92 |
+
Error2("", err);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
//!Prints content of variable to console/log
|
| 96 |
+
proto void Print(void var);
|
| 97 |
+
|
| 98 |
+
//!Prints content of variable to RPT file (performance warning - each write means fflush! use with care)
|
| 99 |
+
proto void PrintToRPT(void var);
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
\brief Prints formated text to console/log
|
| 103 |
+
@code
|
| 104 |
+
string c = "Peter";
|
| 105 |
+
PrintFormat("Hello %1, how are you?", c); // prints "Hello 'Peter', how are you?"
|
| 106 |
+
@endcode
|
| 107 |
+
*/
|
| 108 |
+
proto void PrintFormat(string fmt, void param1 = NULL, void param2 = NULL, void param3 = NULL, void param4 = NULL, void param5 = NULL, void param6 = NULL, void param7 = NULL, void param8 = NULL, void param9 = NULL);
|
| 109 |
+
|
| 110 |
+
//------------------------------------------
|
| 111 |
+
/**
|
| 112 |
+
* \defgroup DebugShape Debug Shape API definition
|
| 113 |
+
* @{
|
| 114 |
+
*/
|
| 115 |
+
enum ShapeType
|
| 116 |
+
{
|
| 117 |
+
BBOX, //< Just box
|
| 118 |
+
LINE, //< One or more lines
|
| 119 |
+
SPHERE, //< Sphere represented by triangle mesh
|
| 120 |
+
CYLINDER, //< Cylinder represented by triangle mesh
|
| 121 |
+
DIAMOND, //< Eight faced pyramid. Defined by bound-box, where middle part is equal to horizontal extents of box and top/bottom apogees lies on top/bottom side of box.
|
| 122 |
+
PYRAMID //< Four sided pyramid. Defined by bound-box, where base is equal to bottom side of box.
|
| 123 |
+
};
|
| 124 |
+
|
| 125 |
+
enum ShapeFlags
|
| 126 |
+
{
|
| 127 |
+
NOZBUFFER, //< Do not compare z-buffer when render
|
| 128 |
+
NOZWRITE, //< Do not update z-buffer when render
|
| 129 |
+
WIREFRAME, //< Render just wire-frame outline. No solid faces
|
| 130 |
+
TRANSP, //< Is translucent
|
| 131 |
+
DOUBLESIDE, //< Double-sided (do not cull back-faces)
|
| 132 |
+
ONCE, //< Rendered just once and then it's automatically destroyed. Do not keep pointer to these!!
|
| 133 |
+
NOOUTLINE, //< Render just solid faces. No wire-frame outline.
|
| 134 |
+
BACKFACE, //< Render just back faces
|
| 135 |
+
NOCULL, //< Do not cull shapes by view frustum
|
| 136 |
+
VISIBLE, //< Make it visible. Set by default
|
| 137 |
+
ADDITIVE //< Additive blending (works with ShapeFlags.TRANSP)
|
| 138 |
+
};
|
| 139 |
+
|
| 140 |
+
enum CollisionFlags
|
| 141 |
+
{
|
| 142 |
+
FIRSTCONTACT, //<In many cases only collided=true/false is enough
|
| 143 |
+
NEARESTCONTACT //<We want only one, the nearest contact
|
| 144 |
+
ONLYSTATIC //<Only static objects
|
| 145 |
+
ONLYDYNAMIC //<Only dynamic objects
|
| 146 |
+
ONLYWATER //<Only water components (legacy support for "walk on geometry")
|
| 147 |
+
ALLOBJECTS //<Valid when CF_FIRST_CONTACT, we get first contact for each object
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/*!
|
| 151 |
+
Instance of created debug visualizer
|
| 152 |
+
*/
|
| 153 |
+
class Shape
|
| 154 |
+
{
|
| 155 |
+
//!don't call destructor directly. Use Destroy() instead
|
| 156 |
+
proto private void ~Shape();
|
| 157 |
+
|
| 158 |
+
proto native void GetMatrix(out vector mat[4]);
|
| 159 |
+
proto native void SetMatrix(vector mat[4]);
|
| 160 |
+
proto native void SetDirection(vector direction);
|
| 161 |
+
proto native void SetPosition(vector position);
|
| 162 |
+
proto native void SetColor(int color);
|
| 163 |
+
proto native void SetFlags(ShapeFlags flags);
|
| 164 |
+
proto native void Destroy();
|
| 165 |
+
|
| 166 |
+
proto static native Shape Create(ShapeType type, int color, ShapeFlags flags, vector p1, vector p2);
|
| 167 |
+
proto static native Shape CreateLines(int color, ShapeFlags flags, vector p[], int num);
|
| 168 |
+
proto static native Shape CreateTris(int color, ShapeFlags flags, vector p[], int num);
|
| 169 |
+
proto static native Shape CreateSphere(int color, ShapeFlags flags, vector origin, float radius);
|
| 170 |
+
proto static native Shape CreateFrustum(float horizontalAngle, float verticalAngle, float length, int color, ShapeFlags flags);
|
| 171 |
+
proto static native Shape CreateCylinder(int color, ShapeFlags flags, vector origin, float radius, float length);
|
| 172 |
+
|
| 173 |
+
static Shape CreateArrow(vector from, vector to, float size, int color, ShapeFlags flags)
|
| 174 |
+
{
|
| 175 |
+
vector dir = to - from;
|
| 176 |
+
dir.Normalize();
|
| 177 |
+
vector dir1 = dir * size;
|
| 178 |
+
size = size * 0.5;
|
| 179 |
+
|
| 180 |
+
vector dir2 = dir.Perpend() * size;
|
| 181 |
+
|
| 182 |
+
vector pts[5];
|
| 183 |
+
pts[0] = from;
|
| 184 |
+
pts[1] = to;
|
| 185 |
+
pts[2] = to - dir1 - dir2;
|
| 186 |
+
pts[3] = to - dir1 + dir2;
|
| 187 |
+
pts[4] = to;
|
| 188 |
+
|
| 189 |
+
return CreateLines(color, flags, pts, 5);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
static Shape CreateBridgeArrow(vector from, vector to, float size, int color, ShapeFlags flags)
|
| 193 |
+
{
|
| 194 |
+
vector dir = to - from;
|
| 195 |
+
dir.Normalize();
|
| 196 |
+
|
| 197 |
+
vector dir1 = Vector(0, 0, -size);
|
| 198 |
+
size = size * 0.5;
|
| 199 |
+
|
| 200 |
+
vector dir2 = dir.Perpend() * size;
|
| 201 |
+
|
| 202 |
+
vector pts[7];
|
| 203 |
+
pts[0] = from;
|
| 204 |
+
pts[1] = from + "0 0 1";
|
| 205 |
+
pts[2] = to + "0 0 1";
|
| 206 |
+
pts[3] = to;
|
| 207 |
+
pts[4] = to - dir1 - dir2;
|
| 208 |
+
pts[5] = to - dir1 + dir2;
|
| 209 |
+
pts[6] = to;
|
| 210 |
+
|
| 211 |
+
return CreateLines(color, flags, pts, 7);
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
static void CreateMatrix(vector mat[4])
|
| 215 |
+
{
|
| 216 |
+
vector org = mat[3];
|
| 217 |
+
int flags = ShapeFlags.NOZWRITE|ShapeFlags.DOUBLESIDE|ShapeFlags.TRANSP|ShapeFlags.ONCE;
|
| 218 |
+
Create(ShapeType.LINE, 0xffff0000, flags, org, mat[0] * 0.5 + org);
|
| 219 |
+
Create(ShapeType.LINE, 0xff00ff00, flags, org, mat[1] * 0.5 + org);
|
| 220 |
+
Create(ShapeType.LINE, 0xff0000ff, flags, org, mat[2] * 0.5 + org);
|
| 221 |
+
}
|
| 222 |
+
};
|
| 223 |
+
|
| 224 |
+
//@}
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
//------------------------------------------
|
| 228 |
+
/**
|
| 229 |
+
* \defgroup DiagMenu Diag menu API definition
|
| 230 |
+
* @{
|
| 231 |
+
*/
|
| 232 |
+
class DiagMenu
|
| 233 |
+
{
|
| 234 |
+
//! Checks if DiagMenu is initialized
|
| 235 |
+
static proto bool IsInitialized();
|
| 236 |
+
|
| 237 |
+
//! To be used before registering scripted diags
|
| 238 |
+
static proto void InitScriptDiags();
|
| 239 |
+
//! To be used when scripted diags should not be present
|
| 240 |
+
static proto void ClearScriptDiags();
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
\brief Register a new menu
|
| 244 |
+
\param id \p int The unique ID of the menu in the range [0,512]
|
| 245 |
+
\param name \p string The name of the menu
|
| 246 |
+
\param parent \p int The index of the parent of the menu
|
| 247 |
+
*/
|
| 248 |
+
static proto void RegisterMenu(int id, string name, int parent);
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
\brief Register a new item
|
| 252 |
+
\param id \p int The unique ID of the item in the range [0,512]
|
| 253 |
+
\param shortcut \p string The keyboard shortcut of the item
|
| 254 |
+
\param name \p string The name of the item
|
| 255 |
+
\param parent \p int The index of the parent of the item
|
| 256 |
+
\param values \p string The values of the item separated by commas, internally this will be an int starting at 0 for the first item
|
| 257 |
+
\param callback \p func Callback to call when the value is changed (OPTIONAL) (Also read BindCallback)
|
| 258 |
+
*/
|
| 259 |
+
static proto void RegisterItem(int id, string shortcut, string name, int parent, string values, func callback = null);
|
| 260 |
+
|
| 261 |
+
/**
|
| 262 |
+
\brief Register a new bool item
|
| 263 |
+
\note This is just a RegisterItem with value="true,false" or when reversed value="false,true"
|
| 264 |
+
\param id \p int The unique ID of the item in the range [0,512]
|
| 265 |
+
\param shortcut \p string The keyboard shortcut of the item
|
| 266 |
+
\param name \p string The name of the item
|
| 267 |
+
\param parent \p string The index of the parent of the item
|
| 268 |
+
\param values \p string The values of the item, separated by commas
|
| 269 |
+
\param reverse \p bool Whether to reverse the bool (OPTIONAL)
|
| 270 |
+
\param callback \p func Callback to call when the value is changed (OPTIONAL) (Also read BindCallback)
|
| 271 |
+
*/
|
| 272 |
+
static proto void RegisterBool(int id, string shortcut, string name, int parent, bool reverse = false, func callback = null);
|
| 273 |
+
|
| 274 |
+
/**
|
| 275 |
+
\brief Register a new range item
|
| 276 |
+
\param id \p int The unique ID of the item in the range [0,512]
|
| 277 |
+
\param shortcut \p string The keyboard shortcut of the item
|
| 278 |
+
\param name \p string The name of the item
|
| 279 |
+
\param parent \p int The index of the parent of the item
|
| 280 |
+
\param values \p string Range specification in format "min,max,startValue,step"
|
| 281 |
+
\param callback \p func Callback to call when the value is changed (OPTIONAL) (Also read BindCallback)
|
| 282 |
+
*/
|
| 283 |
+
static proto void RegisterRange(int id, string shortcut, string name, int parent, string valuenames, func callback = null);
|
| 284 |
+
|
| 285 |
+
//! Unregister the item at given id
|
| 286 |
+
static proto void Unregister(int id);
|
| 287 |
+
|
| 288 |
+
//! Check if the item at given id has been registered
|
| 289 |
+
static proto bool IsRegistered(int id);
|
| 290 |
+
|
| 291 |
+
/**
|
| 292 |
+
*\brief Bind a callback to the given id
|
| 293 |
+
* \note Only one callback can be registered, so when attempting to registering multiple, only the last one will be present
|
| 294 |
+
* \note The callbacks are required to have one of following signatures
|
| 295 |
+
* - All Register... support:
|
| 296 |
+
* o static void Callback();
|
| 297 |
+
* - RegisterItem & RegisterBool:
|
| 298 |
+
* o static void Callback(int value);
|
| 299 |
+
* o static void Callback(int value, int id);
|
| 300 |
+
* o static void Callback(bool value);
|
| 301 |
+
* o static void Callback(bool value, int id);
|
| 302 |
+
* - RegisterRange:
|
| 303 |
+
* o static void Callback(float value);
|
| 304 |
+
* o static void Callback(float value, int id);
|
| 305 |
+
* o static void Callback(int value);
|
| 306 |
+
* o static void Callback(int value, int id);
|
| 307 |
+
* \note Keep in mind that bool and int are interchangeable, so 'bool value' is possible for RegisterRange too
|
| 308 |
+
*/
|
| 309 |
+
static proto bool BindCallback(int id, func callback);
|
| 310 |
+
//! Unbind the callback from the given id
|
| 311 |
+
static proto void UnbindCallback(int id);
|
| 312 |
+
|
| 313 |
+
//! Get value as bool from the given script id
|
| 314 |
+
static proto bool GetBool(int id, bool reverse = false);
|
| 315 |
+
//! Get value as int from the given script id
|
| 316 |
+
static proto int GetValue(int id);
|
| 317 |
+
//! Set value at the given script id
|
| 318 |
+
static proto void SetValue(int id, int value);
|
| 319 |
+
|
| 320 |
+
//! Get range value at the given script id
|
| 321 |
+
static proto float GetRangeValue(int id);
|
| 322 |
+
//! Set range value at the given script id
|
| 323 |
+
static proto void SetRangeValue(int id, float value);
|
| 324 |
+
|
| 325 |
+
//! Get value at the given engine id
|
| 326 |
+
static proto int GetEngineValue(int id);
|
| 327 |
+
//! Set value at the given engine id
|
| 328 |
+
static proto void SetEngineValue(int id, int value);
|
| 329 |
+
|
| 330 |
+
//! Get range value at the given engine id
|
| 331 |
+
static proto float GetEngineRangeValue(int id);
|
| 332 |
+
//! Set range value at the given engine id
|
| 333 |
+
static proto void SetEngineRangeValue(int id, float value);
|
| 334 |
+
|
| 335 |
+
//! Check if a menu with supplied name already exists
|
| 336 |
+
static proto bool MenuExists(string name);
|
| 337 |
+
};
|
| 338 |
+
|
| 339 |
+
//@}
|
| 340 |
+
|
| 341 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnEntity.c
ADDED
|
@@ -0,0 +1,870 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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edef int[] WidgetSource;
|
| 4 |
+
|
| 5 |
+
class BaseContainer
|
| 6 |
+
{
|
| 7 |
+
proto native owned string GetClassName();
|
| 8 |
+
proto native owned string GetName();
|
| 9 |
+
proto native int VarIndex(string varName);
|
| 10 |
+
proto native bool IsVariableSet(int varIndex);
|
| 11 |
+
proto bool IsType(int varIndex, typename type);
|
| 12 |
+
proto bool Get(int varIndex, out void val);
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
class IEntitySource: BaseContainer
|
| 16 |
+
{
|
| 17 |
+
proto native IEntitySource GetChildren();
|
| 18 |
+
proto native IEntitySource GetSibling();
|
| 19 |
+
proto native IEntitySource GetParent();
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
class WidgetSource: BaseContainer
|
| 23 |
+
{
|
| 24 |
+
proto native WidgetSource GetChildren();
|
| 25 |
+
proto native WidgetSource GetSibling();
|
| 26 |
+
proto native WidgetSource GetParent();
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* \defgroup EntityAPI Entity system
|
| 31 |
+
* @{
|
| 32 |
+
*/
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* \defgroup EntityAttributes Entity editor attribute system
|
| 36 |
+
* @{
|
| 37 |
+
*/
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
//@}
|
| 42 |
+
|
| 43 |
+
//!Entity events for event-mask, or throwing event from code
|
| 44 |
+
enum EntityEvent
|
| 45 |
+
{
|
| 46 |
+
//! entity was touched by other entity
|
| 47 |
+
TOUCH,
|
| 48 |
+
|
| 49 |
+
/*!
|
| 50 |
+
entity is visible, so part of the rendering
|
| 51 |
+
other WorldClass
|
| 52 |
+
extra frame index
|
| 53 |
+
result false should be rendered, true shoudn't be rendered
|
| 54 |
+
*/
|
| 55 |
+
VISIBLE,
|
| 56 |
+
|
| 57 |
+
/*!
|
| 58 |
+
entity is not visible, will not be part of rendering
|
| 59 |
+
other WorldClass
|
| 60 |
+
extra frame index
|
| 61 |
+
*/
|
| 62 |
+
NOTVISIBLE,
|
| 63 |
+
|
| 64 |
+
/*!
|
| 65 |
+
new frame event, called each frame
|
| 66 |
+
other WorldClass
|
| 67 |
+
extra frame index
|
| 68 |
+
*/
|
| 69 |
+
FRAME,
|
| 70 |
+
|
| 71 |
+
/*!
|
| 72 |
+
event at the end of each frame or when entity is moved during the frame
|
| 73 |
+
other WorldClass
|
| 74 |
+
*/
|
| 75 |
+
POSTFRAME,
|
| 76 |
+
|
| 77 |
+
/*!
|
| 78 |
+
event called after the world is created, including all entities
|
| 79 |
+
other WorldClass
|
| 80 |
+
*/
|
| 81 |
+
INIT,
|
| 82 |
+
|
| 83 |
+
//Only with MeshObject
|
| 84 |
+
//ANIMEND - End of AF_ONCE animation, extra = slot number 0...11
|
| 85 |
+
//ANIMBLEND - Animation blended from previous one, extra = slot number 0...11
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
//SOUNDEND - playing of SFL_ONCE sound has ended
|
| 89 |
+
// extra = pointer to a sound handle
|
| 90 |
+
|
| 91 |
+
//USER
|
| 92 |
+
|
| 93 |
+
JOINTBREAK,
|
| 94 |
+
SIMULATE,
|
| 95 |
+
POSTSIMULATE,
|
| 96 |
+
PHYSICSMOVE,
|
| 97 |
+
CONTACT,
|
| 98 |
+
EXTRA,
|
| 99 |
+
ANIMEVENT,
|
| 100 |
+
SOUNDEVENT,
|
| 101 |
+
PHYSICSSTEADY,
|
| 102 |
+
USER,
|
| 103 |
+
|
| 104 |
+
//! Object entered Trigger
|
| 105 |
+
ENTER,
|
| 106 |
+
//! Object left Trigger
|
| 107 |
+
LEAVE,
|
| 108 |
+
|
| 109 |
+
//!Mask of all events
|
| 110 |
+
ALL
|
| 111 |
+
};
|
| 112 |
+
|
| 113 |
+
//!Entity flags
|
| 114 |
+
enum EntityFlags
|
| 115 |
+
{
|
| 116 |
+
/*!
|
| 117 |
+
Entity is visible. Is rendered if there is some attached object
|
| 118 |
+
and event EntityEvent.VISIBLE is invoked, when event mask is set.
|
| 119 |
+
*/
|
| 120 |
+
VISIBLE,
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
SOLID, ///<Is collidable by various trace methods
|
| 124 |
+
TRIGGER, ///<Is not collidable, but invokes touch events.
|
| 125 |
+
TOUCHTRIGGERS, ///<Interacts with triggers
|
| 126 |
+
SYNCHRONIZATION_DIRTY, ///<Entity wants to synchronize (network)
|
| 127 |
+
|
| 128 |
+
FEATURE, ///<Scene rendering hint for dominant objects that are not culled by standard way
|
| 129 |
+
/*!
|
| 130 |
+
Used by tracing methods. When tracing with TraceFlags.PASSTRANSLUCENT,
|
| 131 |
+
then this entity is ignored. Used for glass for example.
|
| 132 |
+
*/
|
| 133 |
+
TRANSLUCENT,
|
| 134 |
+
|
| 135 |
+
//!Used by tracing methods. Traceable only with flag TraceFlags.WATER
|
| 136 |
+
WATER,
|
| 137 |
+
|
| 138 |
+
/*!
|
| 139 |
+
Tells that this entity has to be actively updated by engine, its
|
| 140 |
+
EntityEvent.FRAME has to be called etc.
|
| 141 |
+
*/
|
| 142 |
+
ACTIVE,
|
| 143 |
+
|
| 144 |
+
/*!
|
| 145 |
+
Tells that this entity will represent mostly static object, so
|
| 146 |
+
we can use more precise but slower methods for scene-tree linking.
|
| 147 |
+
Also it tells to scene tree that he can count with this entity as
|
| 148 |
+
tree-split hint.
|
| 149 |
+
*/
|
| 150 |
+
STATIC,
|
| 151 |
+
|
| 152 |
+
//!Flags for custom usage and filterings.
|
| 153 |
+
USER1,
|
| 154 |
+
USER2,
|
| 155 |
+
USER3,
|
| 156 |
+
USER4,
|
| 157 |
+
USER5,
|
| 158 |
+
USER6
|
| 159 |
+
};
|
| 160 |
+
|
| 161 |
+
/*!
|
| 162 |
+
Internal ancestor of all Entity implementations.
|
| 163 |
+
*/
|
| 164 |
+
class IEntity: Managed
|
| 165 |
+
{
|
| 166 |
+
//DO NOT INSERT ANYTHING BELOW - order of event methods matters!
|
| 167 |
+
/** \name Event methods
|
| 168 |
+
Event method stubs. Reimplement these in inherited entities to receive event calls
|
| 169 |
+
*/
|
| 170 |
+
//@{
|
| 171 |
+
event protected void EOnTouch(IEntity other, int extra) //!EntityEvent.TOUCH
|
| 172 |
+
{
|
| 173 |
+
}
|
| 174 |
+
event protected void EOnInit(IEntity other, int extra) //!EntityEvent.INIT
|
| 175 |
+
{
|
| 176 |
+
}
|
| 177 |
+
event protected void EOnExtra(IEntity other, int extra) //!EntityEvent.EXTRA
|
| 178 |
+
{
|
| 179 |
+
}
|
| 180 |
+
event protected void EOnNotVisible(IEntity other, int extra) //!EntityEvent.NOTVISIBLE
|
| 181 |
+
{
|
| 182 |
+
}
|
| 183 |
+
event protected void EOnFrame(IEntity other, float timeSlice) //!EntityEvent.FRAME
|
| 184 |
+
{
|
| 185 |
+
}
|
| 186 |
+
event protected int EOnVisible(IEntity other, int extra) //!EntityEvent.VISIBLE
|
| 187 |
+
{
|
| 188 |
+
}
|
| 189 |
+
event protected void EOnPostFrame(IEntity other, int extra) //!EntityEvent.POSTFRAME
|
| 190 |
+
{
|
| 191 |
+
}
|
| 192 |
+
event protected void EOnWorldProcess(IEntity other, int extra) //!EntityEvent.WORLDPROCESS
|
| 193 |
+
{
|
| 194 |
+
}
|
| 195 |
+
event protected void EOnAnimEvent(IEntity other, AnimEvent extra) //!EntityEvent.ANIMEVENT
|
| 196 |
+
{
|
| 197 |
+
}
|
| 198 |
+
event protected void EOnSoundEvent(IEntity other, SoundEvent extra) //!EntityEvent.SOUNDEVENT
|
| 199 |
+
{
|
| 200 |
+
}
|
| 201 |
+
event protected void EOnSimulate(IEntity other, float dt) //!EntityEvent.SIMULATE
|
| 202 |
+
{
|
| 203 |
+
}
|
| 204 |
+
event protected void EOnPostSimulate(IEntity other, float timeSlice) //!EntityEvent.POSTSIMULATE
|
| 205 |
+
{
|
| 206 |
+
}
|
| 207 |
+
event protected void EOnJointBreak(IEntity other, int extra) //!EntityEvent.JOINTBREAK
|
| 208 |
+
{
|
| 209 |
+
}
|
| 210 |
+
event protected void EOnPhysicsMove(IEntity other, int extra) //!EntityEvent.PHYSICSMOVE
|
| 211 |
+
{
|
| 212 |
+
}
|
| 213 |
+
event protected void EOnContact(IEntity other, Contact extra) //!EntityEvent.CONTACT
|
| 214 |
+
{
|
| 215 |
+
}
|
| 216 |
+
protected void EOnUser0(IEntity other, int extra) //!EntityEvent.EV_USER+0
|
| 217 |
+
{
|
| 218 |
+
}
|
| 219 |
+
protected void EOnUser1(IEntity other, int extra) //!EntityEvent.EV_USER+1
|
| 220 |
+
{
|
| 221 |
+
}
|
| 222 |
+
event protected void EOnEnter(IEntity other, int extra) //!EntityEvent.ENTER
|
| 223 |
+
{
|
| 224 |
+
}
|
| 225 |
+
event protected void EOnLeave(IEntity other, int extra) //!EntityEvent.LEAVE
|
| 226 |
+
{
|
| 227 |
+
}
|
| 228 |
+
protected void EOnUser4(IEntity other, int extra) //!EntityEvent.EV_USER+4
|
| 229 |
+
{
|
| 230 |
+
}
|
| 231 |
+
protected void EOnDummy020(IEntity other, int extra) //!Placeholder
|
| 232 |
+
{
|
| 233 |
+
}
|
| 234 |
+
protected void EOnDummy021(IEntity other, int extra) //!Placeholder
|
| 235 |
+
{
|
| 236 |
+
}
|
| 237 |
+
protected void EOnDummy022(IEntity other, int extra) //!Placeholder
|
| 238 |
+
{
|
| 239 |
+
}
|
| 240 |
+
protected void EOnDummy023(IEntity other, int extra) //!Placeholder
|
| 241 |
+
{
|
| 242 |
+
}
|
| 243 |
+
protected void EOnDummy024(IEntity other, int extra) //!Placeholder
|
| 244 |
+
{
|
| 245 |
+
}
|
| 246 |
+
protected void EOnDummy025(IEntity other, int extra) //!Placeholder
|
| 247 |
+
{
|
| 248 |
+
}
|
| 249 |
+
protected void EOnDummy026(IEntity other, int extra) //!Placeholder
|
| 250 |
+
{
|
| 251 |
+
}
|
| 252 |
+
protected void EOnDummy027(IEntity other, int extra) //!Placeholder
|
| 253 |
+
{
|
| 254 |
+
}
|
| 255 |
+
protected void EOnDummy028(IEntity other, int extra) //!Placeholder
|
| 256 |
+
{
|
| 257 |
+
}
|
| 258 |
+
protected void EOnDummy029(IEntity other, int extra) //!Placeholder
|
| 259 |
+
{
|
| 260 |
+
}
|
| 261 |
+
protected void EOnDummy030(IEntity other, int extra) //!Placeholder
|
| 262 |
+
{
|
| 263 |
+
}
|
| 264 |
+
protected void EOnDummy031(IEntity other, int extra) //!Placeholder
|
| 265 |
+
{
|
| 266 |
+
}
|
| 267 |
+
//@}
|
| 268 |
+
//DO NOT INSERT ANYTHING ABOVE - order of event methods matters!
|
| 269 |
+
|
| 270 |
+
/** \name Transformation methods
|
| 271 |
+
Setting and getting of entity transformation
|
| 272 |
+
*/
|
| 273 |
+
//@{
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
\brief Returns transformation of Entity. It returns only so much vectors as array is big
|
| 277 |
+
\param mat \p vector[1...4] matrix to be get
|
| 278 |
+
@code
|
| 279 |
+
Man player = g_Game.GetPlayer();
|
| 280 |
+
|
| 281 |
+
vector mat[4];
|
| 282 |
+
player.GetTransform(mat);
|
| 283 |
+
Print( mat );
|
| 284 |
+
|
| 285 |
+
>> <0.989879,-0,0.141916>,<0,1,0>,<-0.141916,0,0.989879>,<2545.08,15.6754,2867.49>
|
| 286 |
+
@endcode
|
| 287 |
+
*/
|
| 288 |
+
proto external void GetTransform(out vector mat[]);
|
| 289 |
+
|
| 290 |
+
/**
|
| 291 |
+
\brief Returns render transformation of Entity. Must pass in vector array size of 4
|
| 292 |
+
\param mat \p vector[4] matrix to be get
|
| 293 |
+
@code
|
| 294 |
+
Man player = g_Game.GetPlayer();
|
| 295 |
+
|
| 296 |
+
vector mat[4];
|
| 297 |
+
player.GetRenderTransform(mat);
|
| 298 |
+
Print( mat );
|
| 299 |
+
|
| 300 |
+
>> <0.989879,-0,0.141916>,<0,1,0>,<-0.141916,0,0.989879>,<2545.08,15.6754,2867.49>
|
| 301 |
+
@endcode
|
| 302 |
+
*/
|
| 303 |
+
proto external void GetRenderTransform(out vector mat[]);
|
| 304 |
+
|
| 305 |
+
/**
|
| 306 |
+
\brief Returns local transformation of Entity. It returns only so much vectors as array is big
|
| 307 |
+
\param mat \p vector[1...4] matrix to be get
|
| 308 |
+
@code
|
| 309 |
+
Man player = g_Game.GetPlayer();
|
| 310 |
+
|
| 311 |
+
vector mat[4];
|
| 312 |
+
player.GetTransform(mat);
|
| 313 |
+
Print( mat );
|
| 314 |
+
|
| 315 |
+
>> <0.989879,-0,0.141916>,<0,1,0>,<-0.141916,0,0.989879>,<2545.08,15.6754,2867.49>
|
| 316 |
+
@endcode
|
| 317 |
+
*/
|
| 318 |
+
proto external void GetLocalTransform(out vector mat[]);
|
| 319 |
+
|
| 320 |
+
/**
|
| 321 |
+
\brief Returns one row of Entity transformation matrix
|
| 322 |
+
\param axis \p int matrix axis. Can be 0..3
|
| 323 |
+
\return \p vector axis row of Entity matrix
|
| 324 |
+
@code
|
| 325 |
+
Man player = g_Game.GetPlayer();
|
| 326 |
+
Print( player.GetTransformAxis(0) );
|
| 327 |
+
Print( player.GetTransformAxis(1) );
|
| 328 |
+
Print( player.GetTransformAxis(2) );
|
| 329 |
+
Print( player.GetTransformAxis(3) );
|
| 330 |
+
|
| 331 |
+
>> <-0.386781,0,0.922171>
|
| 332 |
+
>> <0,1,0>
|
| 333 |
+
>> <-0.922171,0,-0.386782>
|
| 334 |
+
>> <2551.34,15.6439,2856.72>
|
| 335 |
+
@endcode
|
| 336 |
+
*/
|
| 337 |
+
proto native external vector GetTransformAxis(int axis);
|
| 338 |
+
|
| 339 |
+
/**
|
| 340 |
+
\brief Sets entity transformation
|
| 341 |
+
\param mat \p vector[4] matrix to be set
|
| 342 |
+
@code
|
| 343 |
+
vector mat[4];
|
| 344 |
+
Math3D.MatrixIdentity( mat )
|
| 345 |
+
|
| 346 |
+
Man player = g_Game.GetPlayer();
|
| 347 |
+
player.SetTransform( mat );
|
| 348 |
+
|
| 349 |
+
vector outmat[4];
|
| 350 |
+
player.GetTransform(outmat );
|
| 351 |
+
Print( outmat );
|
| 352 |
+
|
| 353 |
+
>> <1,0,0>,<0,1,0>,<0,0,1>,<0,0,0>
|
| 354 |
+
@endcode
|
| 355 |
+
*/
|
| 356 |
+
proto native external void SetTransform(vector mat[4]);
|
| 357 |
+
|
| 358 |
+
/**
|
| 359 |
+
\brief Returns origin of Entity
|
| 360 |
+
\return \p vector entity origin
|
| 361 |
+
@code
|
| 362 |
+
Man player = g_Game.GetPlayer();
|
| 363 |
+
Print( player.GetOrigin() );
|
| 364 |
+
|
| 365 |
+
>> <2577.02,15.6837,2924.27>
|
| 366 |
+
@endcode
|
| 367 |
+
*/
|
| 368 |
+
proto native external vector GetOrigin();
|
| 369 |
+
|
| 370 |
+
/**
|
| 371 |
+
\brief Returns local position of Entity
|
| 372 |
+
\return \p vector entity local position
|
| 373 |
+
@code
|
| 374 |
+
Man player = g_Game.GetPlayer();
|
| 375 |
+
Print( player.GetOrigin() );
|
| 376 |
+
|
| 377 |
+
>> <2577.02,15.6837,2924.27>
|
| 378 |
+
@endcode
|
| 379 |
+
*/
|
| 380 |
+
proto external vector GetLocalPosition();
|
| 381 |
+
|
| 382 |
+
/**
|
| 383 |
+
\brief Returns orientation of Entity in world space (Yaw, Pitch, Roll)
|
| 384 |
+
\return \p vector entity orientation
|
| 385 |
+
@code
|
| 386 |
+
Man player = g_Game.GetPlayer();
|
| 387 |
+
Print( player.GetYawPitchRoll() );
|
| 388 |
+
|
| 389 |
+
>> <180,-76.5987,180>
|
| 390 |
+
@endcode
|
| 391 |
+
*/
|
| 392 |
+
proto native external vector GetYawPitchRoll();
|
| 393 |
+
|
| 394 |
+
/**
|
| 395 |
+
\brief Same as GetYawPitchRoll, but returns rotation vector around X, Y and Z axis.
|
| 396 |
+
*/
|
| 397 |
+
proto native external vector GetAngles();
|
| 398 |
+
|
| 399 |
+
/**
|
| 400 |
+
\brief Returns local orientation when it's in hierarchy (Yaw, Pitch, Roll)
|
| 401 |
+
\return \p vector local orientation
|
| 402 |
+
@code
|
| 403 |
+
Man player = g_Game.GetPlayer();
|
| 404 |
+
Print( player.GetLocalYawPitchRoll() );
|
| 405 |
+
|
| 406 |
+
>> <180,-57.2585,180>
|
| 407 |
+
@endcode
|
| 408 |
+
*/
|
| 409 |
+
proto native external vector GetLocalYawPitchRoll();
|
| 410 |
+
|
| 411 |
+
/**
|
| 412 |
+
\brief Same as GetLocalYawPitchRoll, but returns rotation vector around X, Y and Z axis.
|
| 413 |
+
*/
|
| 414 |
+
proto native external vector GetLocalAngles();
|
| 415 |
+
|
| 416 |
+
/**
|
| 417 |
+
\brief Sets angles for entity (Yaw, Pitch, Roll)
|
| 418 |
+
\param angles \p vector angles to be set
|
| 419 |
+
@code
|
| 420 |
+
Man player = g_Game.GetPlayer();
|
| 421 |
+
player.SetYawPitchRoll("180 50 180" );
|
| 422 |
+
Print( player.GetYawPitchRoll() );
|
| 423 |
+
|
| 424 |
+
>> <-180,50,-180>
|
| 425 |
+
@endcode
|
| 426 |
+
*/
|
| 427 |
+
proto native external void SetYawPitchRoll(vector angles);
|
| 428 |
+
|
| 429 |
+
/**
|
| 430 |
+
\brief Same as SetYawPitchRoll, but sets rotation around X, Y and Z axis.
|
| 431 |
+
*/
|
| 432 |
+
proto native external void SetAngles(vector angles);
|
| 433 |
+
|
| 434 |
+
/**
|
| 435 |
+
\brief Sets origin for entity
|
| 436 |
+
\param orig \p vector origin to be set
|
| 437 |
+
@code
|
| 438 |
+
Man player = g_Game.GetPlayer();
|
| 439 |
+
player.SetOrigin("2550 10 2900" );
|
| 440 |
+
Print( player.GetOrigin() );
|
| 441 |
+
|
| 442 |
+
>> <2550,10,2900>
|
| 443 |
+
@endcode
|
| 444 |
+
*/
|
| 445 |
+
proto native external void SetOrigin(vector orig);
|
| 446 |
+
|
| 447 |
+
proto native external float GetScale();
|
| 448 |
+
proto native external void SetScale(float scale);
|
| 449 |
+
/**
|
| 450 |
+
\brief Transforms local vector to world space
|
| 451 |
+
\param vec \p vector local space vector to transform
|
| 452 |
+
\return \p vector world space vector
|
| 453 |
+
@code
|
| 454 |
+
Man player = g_Game.GetPlayer();
|
| 455 |
+
Print( player.VectorToParent("1 2 3") );
|
| 456 |
+
|
| 457 |
+
>> <2.89791,2,1.26575>
|
| 458 |
+
@endcode
|
| 459 |
+
*/
|
| 460 |
+
proto native external vector VectorToParent(vector vec);
|
| 461 |
+
|
| 462 |
+
/**
|
| 463 |
+
\brief Transforms local position to world space
|
| 464 |
+
\param coord \p vector local position to transform
|
| 465 |
+
\return \p vector position in world space
|
| 466 |
+
@code
|
| 467 |
+
Man player = g_Game.GetPlayer();
|
| 468 |
+
Print( player.CoordToParent("1 2 3") );
|
| 469 |
+
|
| 470 |
+
>> <2549,17.6478,2857>
|
| 471 |
+
@endcode
|
| 472 |
+
*/
|
| 473 |
+
proto native external vector CoordToParent(vector coord);
|
| 474 |
+
|
| 475 |
+
/**
|
| 476 |
+
\brief Transforms world space vector to local space
|
| 477 |
+
\param vec \p vector world space vector to transform
|
| 478 |
+
\return \p vector local space vector
|
| 479 |
+
@code
|
| 480 |
+
Man player = g_Game.GetPlayer();
|
| 481 |
+
Print( player.VectorToLocal("2 1 5") );
|
| 482 |
+
|
| 483 |
+
>> <-0.166849,1,5.38258>
|
| 484 |
+
@endcode
|
| 485 |
+
*/
|
| 486 |
+
proto native external vector VectorToLocal(vector vec);
|
| 487 |
+
|
| 488 |
+
/**
|
| 489 |
+
\brief Transforms world space position to local space
|
| 490 |
+
\param coord \p vector world space position to transform
|
| 491 |
+
\return \p vector position in local space
|
| 492 |
+
@code
|
| 493 |
+
Man player = g_Game.GetPlayer();
|
| 494 |
+
Print( player.CoordToLocal("500 10 155") );
|
| 495 |
+
|
| 496 |
+
>> <15254,-54.2004,8745.53>
|
| 497 |
+
@endcode
|
| 498 |
+
*/
|
| 499 |
+
proto native external vector CoordToLocal(vector coord);
|
| 500 |
+
|
| 501 |
+
//@}
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
/** \name Name/ID methods
|
| 505 |
+
*/
|
| 506 |
+
//@{
|
| 507 |
+
|
| 508 |
+
/**
|
| 509 |
+
\brief Return unique entity ID
|
| 510 |
+
\return \p int unique entity ID
|
| 511 |
+
@code
|
| 512 |
+
ItemBase apple = g_Game.CreateObject( "FruitApple", String2Vector("0 10 0"), false );
|
| 513 |
+
Print( apple.GetID() );
|
| 514 |
+
|
| 515 |
+
>> 0
|
| 516 |
+
@endcode
|
| 517 |
+
*/
|
| 518 |
+
proto native int GetID();
|
| 519 |
+
|
| 520 |
+
/**
|
| 521 |
+
\brief Set unique entity ID
|
| 522 |
+
\param id \p int unique entity ID to be set
|
| 523 |
+
@code
|
| 524 |
+
ItemBase apple = g_Game.CreateObject( "Fruit_Apple", String2Vector("0 10 0"), false );
|
| 525 |
+
apple.SetID(101);
|
| 526 |
+
Print( apple.GetID() );
|
| 527 |
+
|
| 528 |
+
>> 101
|
| 529 |
+
@endcode
|
| 530 |
+
*/
|
| 531 |
+
proto native void SetID(int id);
|
| 532 |
+
|
| 533 |
+
proto native void SetName(string name);
|
| 534 |
+
proto native external owned string GetName();
|
| 535 |
+
//@}
|
| 536 |
+
|
| 537 |
+
|
| 538 |
+
/** \name Hierarchy methods
|
| 539 |
+
Scene hierarchy management
|
| 540 |
+
*/
|
| 541 |
+
//@{
|
| 542 |
+
|
| 543 |
+
/**
|
| 544 |
+
\brief Adds child entity to this entity.
|
| 545 |
+
\note Make sure the parent is not ToDelete
|
| 546 |
+
\param child \p IEntity Pointer to entity which become our child
|
| 547 |
+
\param pivot \p int Pivot is pivot index, or -1 for center of parent.
|
| 548 |
+
\param positionOnly \p bool When set to true, the orientation will still be in WS.
|
| 549 |
+
\return \p bool True when entity has been attached. False otherwise.
|
| 550 |
+
*/
|
| 551 |
+
proto native external bool AddChild(notnull IEntity child, int pivot, bool positionOnly = false);
|
| 552 |
+
|
| 553 |
+
/**
|
| 554 |
+
\brief Removes child entity from hierarchy.
|
| 555 |
+
\note Make sure the child is not ToDelete
|
| 556 |
+
\param child \p IEntity Pointer to child entity we want to remove.
|
| 557 |
+
\param keepTransform \p bool When set to true, Entity is kept on her world position. Otherwise it's local transform is used as world-space one.
|
| 558 |
+
\return \p bool True if it was removed, false when this entity is not our child.
|
| 559 |
+
*/
|
| 560 |
+
proto native external bool RemoveChild(notnull IEntity child, bool keepTransform = false);
|
| 561 |
+
|
| 562 |
+
//! Returns if the hierarchy component was created with positionOnly
|
| 563 |
+
proto native bool IsHierarchyPositionOnly();
|
| 564 |
+
|
| 565 |
+
//! Returns the hierarchy component pivot
|
| 566 |
+
proto native int GetHierarchyPivot();
|
| 567 |
+
|
| 568 |
+
//! Returns pointer to parent Entity in hierarchy
|
| 569 |
+
proto native IEntity GetParent();
|
| 570 |
+
//! Returns pointer to first child Entity in hierarchy
|
| 571 |
+
proto native IEntity GetChildren();
|
| 572 |
+
//! Returns pointer to next child Entity on the same hierarchy
|
| 573 |
+
proto native IEntity GetSibling();
|
| 574 |
+
//@}
|
| 575 |
+
|
| 576 |
+
/**
|
| 577 |
+
\brief Returns local bounding box of model on Entity
|
| 578 |
+
\param[out] mins \p vector minimum point of bounding box
|
| 579 |
+
\param[out] maxs \p vector maximum point of bounding box
|
| 580 |
+
@code
|
| 581 |
+
Man player = g_Game.GetPlayer();
|
| 582 |
+
|
| 583 |
+
vector mins, maxs;
|
| 584 |
+
player.GetBounds(mins, maxs );
|
| 585 |
+
|
| 586 |
+
Print( mins );
|
| 587 |
+
Print( maxs );
|
| 588 |
+
|
| 589 |
+
>> <0,0,0>
|
| 590 |
+
>> <0,0,0>
|
| 591 |
+
@endcode
|
| 592 |
+
*/
|
| 593 |
+
proto external void GetBounds(out vector mins, out vector maxs);
|
| 594 |
+
|
| 595 |
+
/**
|
| 596 |
+
\brief Returns quantized world-bound-box of Entity
|
| 597 |
+
\param[out] mins \p vector minimum point of bounding box
|
| 598 |
+
\param[out] maxs \p vector maximum point of bounding box
|
| 599 |
+
@code
|
| 600 |
+
Man player = g_Game.GetPlayer();
|
| 601 |
+
|
| 602 |
+
vector mins, maxs;
|
| 603 |
+
player.GetWorldBounds( mins, maxs );
|
| 604 |
+
|
| 605 |
+
Print( mins );
|
| 606 |
+
Print( maxs );
|
| 607 |
+
|
| 608 |
+
>> <2547.2,15.5478,2852.85>
|
| 609 |
+
>> <2548.8,17.5478,2855.05>
|
| 610 |
+
@endcode
|
| 611 |
+
*/
|
| 612 |
+
proto external void GetWorldBounds(out vector mins, out vector maxs);
|
| 613 |
+
|
| 614 |
+
/** \name Simulation/handling properties
|
| 615 |
+
Flags that affects simulation and entity handling behavior
|
| 616 |
+
*/
|
| 617 |
+
//@{
|
| 618 |
+
/**
|
| 619 |
+
\brief Returns Entity flags
|
| 620 |
+
\return \p EntityFlags entity flags
|
| 621 |
+
@code
|
| 622 |
+
Man player = g_Game.GetPlayer();
|
| 623 |
+
Print( player.GetFlags() );
|
| 624 |
+
|
| 625 |
+
>> 1610612745
|
| 626 |
+
@endcode
|
| 627 |
+
*/
|
| 628 |
+
proto native external EntityFlags GetFlags();
|
| 629 |
+
|
| 630 |
+
/**
|
| 631 |
+
\brief Test if one or more of specified flags are set
|
| 632 |
+
\return \p bool True if is set, false otherwise.
|
| 633 |
+
@code
|
| 634 |
+
Man player = g_Game.GetPlayer();
|
| 635 |
+
player.SetFlags(EntityFlags.VISIBLE);
|
| 636 |
+
Print( player.IsFlagSet(EntityFlags.VISIBLE) );
|
| 637 |
+
|
| 638 |
+
>> true
|
| 639 |
+
@endcode
|
| 640 |
+
*/
|
| 641 |
+
proto native external bool IsFlagSet(EntityFlags flags);
|
| 642 |
+
|
| 643 |
+
/**
|
| 644 |
+
\brief Sets Entity flags. It's OR operation, not rewrite. Returns previous flags
|
| 645 |
+
\param flags \p int flags to be set
|
| 646 |
+
\param recursively flags will be recursively applied to children of hierarchy too
|
| 647 |
+
\return \p int previous flags
|
| 648 |
+
@code
|
| 649 |
+
Man player = g_Game.GetPlayer();
|
| 650 |
+
player.SetFlags(EntityFlags.VISIBLE|EntityFlags.SOLID );
|
| 651 |
+
Print( player.GetFlags() );
|
| 652 |
+
|
| 653 |
+
>> 1610612747
|
| 654 |
+
@endcode
|
| 655 |
+
*/
|
| 656 |
+
proto native external EntityFlags SetFlags(EntityFlags flags, bool recursively);
|
| 657 |
+
|
| 658 |
+
/**
|
| 659 |
+
\brief Clear Entity flags. Returns cleared flags
|
| 660 |
+
\param flags \p int flags to be set
|
| 661 |
+
\param recursively flags will be recursively applied to children of hierarchy too
|
| 662 |
+
\return \p int cleared flags
|
| 663 |
+
@code
|
| 664 |
+
Man player = g_Game.GetPlayer();
|
| 665 |
+
player.ClearFlags(EntityFlags.VISIBLE|EntityFlags.SOLID );
|
| 666 |
+
Print( player.GetFlags() );
|
| 667 |
+
|
| 668 |
+
>> 1610612744
|
| 669 |
+
@endcode
|
| 670 |
+
*/
|
| 671 |
+
proto native external EntityFlags ClearFlags(EntityFlags flags, bool recursively);
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
/**
|
| 675 |
+
\brief Returns current event mask
|
| 676 |
+
\return \p int current event mask
|
| 677 |
+
@code
|
| 678 |
+
Man player = g_Game.GetPlayer();
|
| 679 |
+
Print( player.GetEventMask() );
|
| 680 |
+
|
| 681 |
+
>> 0
|
| 682 |
+
@endcode
|
| 683 |
+
*/
|
| 684 |
+
proto native external EntityEvent GetEventMask();
|
| 685 |
+
|
| 686 |
+
/**
|
| 687 |
+
\brief Sets event mask
|
| 688 |
+
\param e combined mask of one or more members of EntityEvent enum
|
| 689 |
+
@code
|
| 690 |
+
Man player = g_Game.GetPlayer();
|
| 691 |
+
Print( player.GetEventMask() );
|
| 692 |
+
player.SetEventMask( EntityEvent.VISIBLE );
|
| 693 |
+
Print( player.GetEventMask() );
|
| 694 |
+
|
| 695 |
+
>> 0
|
| 696 |
+
>> 128
|
| 697 |
+
@endcode
|
| 698 |
+
*/
|
| 699 |
+
proto native external EntityEvent SetEventMask(EntityEvent e );
|
| 700 |
+
|
| 701 |
+
/**
|
| 702 |
+
\brief Clears event mask
|
| 703 |
+
\param e \p int event mask
|
| 704 |
+
\return \p int event mask
|
| 705 |
+
@code
|
| 706 |
+
Man player = g_Game.GetPlayer();
|
| 707 |
+
player.SetEventMask(EntityEvent.VISIBLE );
|
| 708 |
+
Print( player.GetEventMask() );
|
| 709 |
+
player.ClearEventMask(EntityEvent.ALL );
|
| 710 |
+
Print( player.GetEventMask() );
|
| 711 |
+
|
| 712 |
+
>> 128
|
| 713 |
+
>> 0
|
| 714 |
+
@endcode
|
| 715 |
+
*/
|
| 716 |
+
proto native external EntityEvent ClearEventMask(EntityEvent e);
|
| 717 |
+
|
| 718 |
+
//!Dynamic event invokation. Parameters are the same as in IEntity::EOnXXXX() methods
|
| 719 |
+
proto external volatile void SendEvent(notnull IEntity actor, EntityEvent e, void extra);
|
| 720 |
+
|
| 721 |
+
//@}
|
| 722 |
+
|
| 723 |
+
/** \name Visual component methods
|
| 724 |
+
Manipulation with visual component - model, particle effect etc
|
| 725 |
+
*/
|
| 726 |
+
//@{
|
| 727 |
+
|
| 728 |
+
/**
|
| 729 |
+
\brief Sets the visual object to this entity. Reference is added and released upon entity destruction
|
| 730 |
+
\param object handle to object got by GetObject()
|
| 731 |
+
\param options String, dependant on object type.
|
| 732 |
+
//Only supported one for XOB objects:
|
| 733 |
+
//$remap 'original material name' 'new material'; [$remap 'another original material name' 'anothernew material']
|
| 734 |
+
*/
|
| 735 |
+
proto native external void SetObject(vobject object, string options);
|
| 736 |
+
|
| 737 |
+
/**
|
| 738 |
+
\brief Returns visual object set to this Entity. No reference is added
|
| 739 |
+
*/
|
| 740 |
+
proto native vobject GetVObject();
|
| 741 |
+
|
| 742 |
+
//!Updates animation (either xob, or particle, whatever)
|
| 743 |
+
proto native external int Animate(float speed, int loop);
|
| 744 |
+
//!Updates animation (either xob, or particle, whatever)
|
| 745 |
+
proto native external int AnimateEx(float speed, int loop, out vector lin, out vector ang);
|
| 746 |
+
|
| 747 |
+
//!Sets visibility mask for cameras, where Entity will be rendered
|
| 748 |
+
proto native external int SetCameraMask(int mask);
|
| 749 |
+
//@}
|
| 750 |
+
|
| 751 |
+
/**
|
| 752 |
+
\brief When called, the Entity is excluded from consequent TraceMove/TraceLine
|
| 753 |
+
*/
|
| 754 |
+
proto native external void FilterNextTrace();
|
| 755 |
+
|
| 756 |
+
/*!
|
| 757 |
+
Updates entity state/position. Should be called when you want to manually commit position changes etc
|
| 758 |
+
before trace methods etc. Entity is updated automatically at the end and the beginning of simulation step,
|
| 759 |
+
when it has EntityFlags.TFL_ACTIVE flag set.
|
| 760 |
+
\returns mask with flags
|
| 761 |
+
// EntityFlags.UPDATE - hierarchy has been updated
|
| 762 |
+
// EntityFlags.UPDATE_MDL - model hierarchy has been updated
|
| 763 |
+
*/
|
| 764 |
+
proto native external int Update();
|
| 765 |
+
|
| 766 |
+
#ifdef COMPONENT_SYSTEM
|
| 767 |
+
//! Constructor
|
| 768 |
+
protected void IEntity(IEntitySource src, IEntity parent);
|
| 769 |
+
#endif
|
| 770 |
+
};
|
| 771 |
+
|
| 772 |
+
#ifdef ENF_DONE
|
| 773 |
+
// Set fixed LOD. -1 for non-fixed LOD
|
| 774 |
+
proto native void SetFixedLOD(IEntity ent, int lod);
|
| 775 |
+
//Sets the texture that can be referenced from material as $renderview
|
| 776 |
+
//and connects it with camera cam_index. Size iz recommended size of
|
| 777 |
+
//rendertarget (0 is default)
|
| 778 |
+
proto native void SetRenderView(IEntity ent, int cam_index, int width, int height);
|
| 779 |
+
proto void GetRenderView(IEntity ent, out int cam_index, out int width, out int height);
|
| 780 |
+
#endif
|
| 781 |
+
|
| 782 |
+
|
| 783 |
+
/**
|
| 784 |
+
* \defgroup EntityAttributes Entity editor attribute system
|
| 785 |
+
* @{
|
| 786 |
+
*/
|
| 787 |
+
|
| 788 |
+
class ParamEnum: Managed
|
| 789 |
+
{
|
| 790 |
+
string m_Key;
|
| 791 |
+
string m_Value;
|
| 792 |
+
string m_Desc;
|
| 793 |
+
|
| 794 |
+
void ParamEnum(string key, string value, string desc = "")
|
| 795 |
+
{
|
| 796 |
+
m_Key = key;
|
| 797 |
+
m_Value = value;
|
| 798 |
+
m_Desc = desc;
|
| 799 |
+
}
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
class ParamEnumArray: array<ref ParamEnum>
|
| 803 |
+
{
|
| 804 |
+
static ParamEnumArray FromEnum(typename e)
|
| 805 |
+
{
|
| 806 |
+
ParamEnumArray params = new ParamEnumArray();
|
| 807 |
+
int cnt = e.GetVariableCount();
|
| 808 |
+
int val;
|
| 809 |
+
|
| 810 |
+
for (int i = 0; i < cnt; i++)
|
| 811 |
+
{
|
| 812 |
+
if (e.GetVariableType(i) == int && e.GetVariableValue(NULL, i, val))
|
| 813 |
+
{
|
| 814 |
+
params.Insert(new ParamEnum(e.GetVariableName(i), val.ToString()));
|
| 815 |
+
}
|
| 816 |
+
}
|
| 817 |
+
|
| 818 |
+
return params;
|
| 819 |
+
}
|
| 820 |
+
}
|
| 821 |
+
|
| 822 |
+
// -------------------------------------------------------------------------
|
| 823 |
+
class Attribute
|
| 824 |
+
{
|
| 825 |
+
string m_DefValue;
|
| 826 |
+
string m_UiWidget; ///< can be "editbox", "combobox", "spinbox", "slider", "font", "fileeditbox", "colorPicker", "flags", "resourceNamePicker"
|
| 827 |
+
string m_RangeScale; ///< defined as "MIN_VALUE MAX_VALUE STEP" eg. "1 100 0.5"
|
| 828 |
+
string m_Desc;
|
| 829 |
+
ref ParamEnumArray m_Enums; ///< Only ints and floats are currently supported. Array can be defined this way: { ParamEnum("Choice 1", "1"), ParamEnum("Choicen 2", "2") }
|
| 830 |
+
|
| 831 |
+
void Attribute(string defvalue, string uiwidget, string desc = "", string rangescale = "", ParamEnumArray enums = NULL)
|
| 832 |
+
{
|
| 833 |
+
m_DefValue = defvalue;
|
| 834 |
+
m_UiWidget = uiwidget;
|
| 835 |
+
m_RangeScale = rangescale;
|
| 836 |
+
m_Desc = desc;
|
| 837 |
+
m_Enums = enums;
|
| 838 |
+
}
|
| 839 |
+
}
|
| 840 |
+
|
| 841 |
+
class EditorAttribute
|
| 842 |
+
{
|
| 843 |
+
string m_Style; ///< can be "box", "sphere", "cylinder", "pyramid", "diamond" or custom style name
|
| 844 |
+
string m_Category; ///< folder structure eg. StaticEntities/Walls
|
| 845 |
+
string m_Description; ///< class purpose description
|
| 846 |
+
vector m_SizeMin; ///< min vector of a bounding box
|
| 847 |
+
vector m_SizeMax; ///< max vector of a bounding box
|
| 848 |
+
string m_Color;
|
| 849 |
+
string m_Color2;
|
| 850 |
+
bool m_Visible;
|
| 851 |
+
bool m_Insertable;
|
| 852 |
+
bool m_DynamicBox;
|
| 853 |
+
|
| 854 |
+
void EditorAttribute(string style, string category, string description, vector sizeMin, vector sizeMax, string color, string color2 = "0 0 0 0", bool visible = true, bool insertable = true, bool dynamicBox = false)
|
| 855 |
+
{
|
| 856 |
+
m_Style = style;
|
| 857 |
+
m_Category = category;
|
| 858 |
+
m_Description = description;
|
| 859 |
+
m_SizeMin = sizeMin;
|
| 860 |
+
m_SizeMax = sizeMax;
|
| 861 |
+
m_Color = color;
|
| 862 |
+
m_Color2 = color2;
|
| 863 |
+
m_Visible = visible;
|
| 864 |
+
m_Insertable = insertable;
|
| 865 |
+
m_DynamicBox = dynamicBox;
|
| 866 |
+
}
|
| 867 |
+
}
|
| 868 |
+
//@}
|
| 869 |
+
|
| 870 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnMath.c
ADDED
|
@@ -0,0 +1,704 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() {}
|
| 10 |
+
|
| 11 |
+
static const float EULER = 2.7182818284590452353;
|
| 12 |
+
static const float PI = 3.14159265358979;
|
| 13 |
+
static const float PI2 = 6.28318530717958;
|
| 14 |
+
static const float PI_HALF = 1.570796326794;
|
| 15 |
+
|
| 16 |
+
static const float RAD2DEG = 57.2957795130823208768;
|
| 17 |
+
static const float DEG2RAD = 0.01745329251994329577;
|
| 18 |
+
|
| 19 |
+
//! returns the number of bits set in a bitmask i
|
| 20 |
+
proto static int GetNumberOfSetBits(int i);
|
| 21 |
+
|
| 22 |
+
//! returns the the index of n-th bit set in a bit mask counting from the right, for instance, in a mask ..0110 1000 , the 0th set bit(right-most bit set to 1) is at 3th position(starting at 0), 1st bit is at 5th position, 2nd bit is at 6th position etc..
|
| 23 |
+
proto static int GetNthBitSet(int value, int n);
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
\brief Returns a random \p int number between and min [inclusive] and max [exclusive].
|
| 27 |
+
\param min \p int Range starts [inclusive]
|
| 28 |
+
\param max \p int Range ends [exclusive]
|
| 29 |
+
\return \p int - Random number in range
|
| 30 |
+
@code
|
| 31 |
+
Print( Math.RandomInt(0, 1) ); // only 0
|
| 32 |
+
Print( Math.RandomInt(0, 2) ); // 0 or 1
|
| 33 |
+
|
| 34 |
+
>> 0
|
| 35 |
+
>> 1
|
| 36 |
+
@endcode
|
| 37 |
+
*/
|
| 38 |
+
proto static int RandomInt(int min, int max);
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
\brief Returns a random \p int number between and min [inclusive] and max [inclusive].
|
| 42 |
+
\param min \p int Range starts [inclusive]
|
| 43 |
+
\param max \p int Range ends [inclusive]
|
| 44 |
+
\return \p int - Random number in range
|
| 45 |
+
@code
|
| 46 |
+
Print( Math.RandomIntInclusive(0, 1) ); // 0 or 1
|
| 47 |
+
Print( Math.RandomIntInclusive(0, 2) ); // 0, 1, 2
|
| 48 |
+
|
| 49 |
+
>> 1
|
| 50 |
+
>> 2
|
| 51 |
+
@endcode
|
| 52 |
+
*/
|
| 53 |
+
|
| 54 |
+
static int RandomIntInclusive(int min, int max)
|
| 55 |
+
{
|
| 56 |
+
return Math.RandomInt(min, max+1);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
\brief Returns a random \p bool .
|
| 61 |
+
\return \p bool - Random bool either 0 or 1
|
| 62 |
+
@code
|
| 63 |
+
Print( Math.RandomBool() );
|
| 64 |
+
Print( Math.RandomBool() );
|
| 65 |
+
Print( Math.RandomBool() );
|
| 66 |
+
|
| 67 |
+
>> true
|
| 68 |
+
>> true
|
| 69 |
+
>> false
|
| 70 |
+
@endcode
|
| 71 |
+
*/
|
| 72 |
+
|
| 73 |
+
static bool RandomBool()
|
| 74 |
+
{
|
| 75 |
+
return RandomIntInclusive(0,1);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
\brief Returns a random \p float number between and min[inclusive] and max[exclusive].
|
| 80 |
+
\param min \p float Range starts [inclusive]
|
| 81 |
+
\param max \p float Range ends [exclusive]
|
| 82 |
+
\return \p float - Random number in range
|
| 83 |
+
@code
|
| 84 |
+
Print( Math.RandomFloat(0,1) );
|
| 85 |
+
Print( Math.RandomFloat(0,2) );
|
| 86 |
+
|
| 87 |
+
>> 0.597561
|
| 88 |
+
>> 1.936456
|
| 89 |
+
@endcode
|
| 90 |
+
*/
|
| 91 |
+
proto static float RandomFloat(float min, float max);
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
\brief Returns a random \p float number between and min [inclusive] and max [inclusive].
|
| 95 |
+
\param min \p float Range starts [inclusive]
|
| 96 |
+
\param max \p float Range ends [inclusive]
|
| 97 |
+
\return \p float - Random number in range
|
| 98 |
+
@code
|
| 99 |
+
Print( Math.RandomFloatInclusive(0, 1) ); // 0.0 .. 1.0
|
| 100 |
+
Print( Math.RandomFloatInclusive(1, 2) ); // 1.0 .. 2.0
|
| 101 |
+
|
| 102 |
+
>> 0.3
|
| 103 |
+
>> 2.0
|
| 104 |
+
@endcode
|
| 105 |
+
*/
|
| 106 |
+
static float RandomFloatInclusive(float min, float max)
|
| 107 |
+
{
|
| 108 |
+
int max_range = Math.Pow(2, 30); //max range
|
| 109 |
+
int random_int = Math.RandomInt(0, max_range);
|
| 110 |
+
float rand_float = (float)random_int / (float)max_range;
|
| 111 |
+
float range = max - min;
|
| 112 |
+
|
| 113 |
+
return min + (rand_float * range); //rand float
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
\brief Returns a random \p float number between and min [inclusive] and max [inclusive].
|
| 118 |
+
\return \p float - Random number in range 0.0 .. 1.0
|
| 119 |
+
@code
|
| 120 |
+
Print( Math.RandomFloat01() ); // 0.0 .. 1.0
|
| 121 |
+
|
| 122 |
+
>> 0.3
|
| 123 |
+
>> 1.0
|
| 124 |
+
@endcode
|
| 125 |
+
*/
|
| 126 |
+
static float RandomFloat01()
|
| 127 |
+
{
|
| 128 |
+
return RandomFloatInclusive(0, 1);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
\brief Sets the seed for the random number generator.
|
| 133 |
+
\param seed \p int New seed for the random number generator, -1 will use time
|
| 134 |
+
\return \p int - Returns new seed
|
| 135 |
+
@code
|
| 136 |
+
Print( Math.Randomize(5) );
|
| 137 |
+
|
| 138 |
+
>> 5
|
| 139 |
+
@endcode
|
| 140 |
+
*/
|
| 141 |
+
proto static int Randomize(int seed);
|
| 142 |
+
|
| 143 |
+
/**
|
| 144 |
+
\brief Normalizes the angle (0...360)
|
| 145 |
+
\param ang \p float Angle for normalizing
|
| 146 |
+
\return \p float - Normalized angle
|
| 147 |
+
@code
|
| 148 |
+
Print( Math.NormalizeAngle(390) );
|
| 149 |
+
Print( Math.NormalizeAngle(-90) );
|
| 150 |
+
|
| 151 |
+
>> 30
|
| 152 |
+
>> 270
|
| 153 |
+
@endcode
|
| 154 |
+
*/
|
| 155 |
+
proto static float NormalizeAngle(float ang);
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
\brief Return relative difference between angles
|
| 159 |
+
\param angle1 \p float
|
| 160 |
+
\param angle2 \p float
|
| 161 |
+
\return \p float Difference between angles (angle1 - angle2)
|
| 162 |
+
@code
|
| 163 |
+
Print( Math.DiffAngle(-45, 45) );
|
| 164 |
+
Print( Math.DiffAngle(90, 80) );
|
| 165 |
+
|
| 166 |
+
>> -90
|
| 167 |
+
>> 10
|
| 168 |
+
@endcode
|
| 169 |
+
*/
|
| 170 |
+
proto static float DiffAngle(float angle1, float angle2);
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
\brief Return power of v ^ power
|
| 174 |
+
\param v \p float Value
|
| 175 |
+
\param power \p float Power
|
| 176 |
+
\return \p float - The result of raising v to the given power
|
| 177 |
+
@code
|
| 178 |
+
Print( Math.Pow(2, 4) ); // (2*2*2*2)=16
|
| 179 |
+
|
| 180 |
+
>> 16
|
| 181 |
+
@endcode
|
| 182 |
+
*/
|
| 183 |
+
proto static float Pow(float v, float power);
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
\brief Returns the floating-point remainder of x/y rounded towards zero
|
| 187 |
+
\param x \p float Value of the quotient numerator
|
| 188 |
+
\param y \p float Value of the quotient denominator
|
| 189 |
+
\return \p float - The remainder of dividing the arguments
|
| 190 |
+
@code
|
| 191 |
+
Print( Math.ModFloat(5.3, 2) );
|
| 192 |
+
Print( Math.ModFloat(18.5, 4.2) );
|
| 193 |
+
|
| 194 |
+
>> 1.3
|
| 195 |
+
>> 1.7
|
| 196 |
+
@endcode
|
| 197 |
+
*/
|
| 198 |
+
proto static float ModFloat(float x, float y);
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
\brief Returns the floating-point remainder of x/y rounded to nearest
|
| 202 |
+
\param x \p float Value of the quotient numerator
|
| 203 |
+
\param y \p float Value of the quotient denominator
|
| 204 |
+
\return \p float - The remainder of dividing the arguments
|
| 205 |
+
@code
|
| 206 |
+
Print( Math.RemainderFloat(5.3, 2) );
|
| 207 |
+
Print( Math.RemainderFloat(18.5, 4.2) );
|
| 208 |
+
|
| 209 |
+
>> -0.7
|
| 210 |
+
>> 1.7
|
| 211 |
+
@endcode
|
| 212 |
+
*/
|
| 213 |
+
proto static float RemainderFloat(float x, float y);
|
| 214 |
+
|
| 215 |
+
/**
|
| 216 |
+
\brief Returns absolute value
|
| 217 |
+
\param f \p float Value
|
| 218 |
+
\return \p float - Absolute value
|
| 219 |
+
@code
|
| 220 |
+
Print( Math.AbsFloat(-12.5) );
|
| 221 |
+
|
| 222 |
+
>> 12.5
|
| 223 |
+
@endcode
|
| 224 |
+
*/
|
| 225 |
+
proto static float AbsFloat(float f);
|
| 226 |
+
|
| 227 |
+
/**
|
| 228 |
+
\brief Returns absolute value
|
| 229 |
+
\param i \p int Value
|
| 230 |
+
\return \p int - Absolute value
|
| 231 |
+
@code
|
| 232 |
+
Print( Math.AbsInt(-12) );
|
| 233 |
+
|
| 234 |
+
>> 12
|
| 235 |
+
@endcode
|
| 236 |
+
*/
|
| 237 |
+
proto static int AbsInt(int i);
|
| 238 |
+
|
| 239 |
+
/**
|
| 240 |
+
\brief Returns sign of given value
|
| 241 |
+
\param f \p float Value
|
| 242 |
+
\return \p float - Sign of given value
|
| 243 |
+
@code
|
| 244 |
+
Print( Math.SignFloat(-12.0) );
|
| 245 |
+
Print( Math.SignFloat(0.0) );
|
| 246 |
+
Print( Math.SignFloat(12.0) );
|
| 247 |
+
|
| 248 |
+
>> -1.0
|
| 249 |
+
>> 0
|
| 250 |
+
>> 1.0
|
| 251 |
+
@endcode
|
| 252 |
+
*/
|
| 253 |
+
proto static float SignFloat(float f);
|
| 254 |
+
|
| 255 |
+
/**
|
| 256 |
+
\brief Returns sign of given value
|
| 257 |
+
\param i \p int Value
|
| 258 |
+
\return \p int - Sign of given value
|
| 259 |
+
@code
|
| 260 |
+
Print( Math.SignFloat(-12) );
|
| 261 |
+
Print( Math.SignFloat(0) );
|
| 262 |
+
Print( Math.SignFloat(12) );
|
| 263 |
+
|
| 264 |
+
>> -1
|
| 265 |
+
>> 0
|
| 266 |
+
>> 1
|
| 267 |
+
@endcode
|
| 268 |
+
*/
|
| 269 |
+
proto static int SignInt(int i);
|
| 270 |
+
|
| 271 |
+
/**
|
| 272 |
+
\brief Returns squared value
|
| 273 |
+
\param f \p float Value
|
| 274 |
+
\return \p float - Squared value
|
| 275 |
+
@code
|
| 276 |
+
Print( Math.SqrFloat(12.5) );
|
| 277 |
+
|
| 278 |
+
>> 156.25
|
| 279 |
+
@endcode
|
| 280 |
+
*/
|
| 281 |
+
proto static float SqrFloat(float f);
|
| 282 |
+
|
| 283 |
+
/**
|
| 284 |
+
\brief Returns squared value
|
| 285 |
+
\param i \p int Value
|
| 286 |
+
\return \p int - Squared value
|
| 287 |
+
@code
|
| 288 |
+
Print( Math.SqrInt(12) );
|
| 289 |
+
|
| 290 |
+
>> 144
|
| 291 |
+
@endcode
|
| 292 |
+
*/
|
| 293 |
+
proto static int SqrInt(int i);
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
\brief Returns square root
|
| 297 |
+
\param val \p float Value
|
| 298 |
+
\return \p float - Square of value
|
| 299 |
+
@code
|
| 300 |
+
Print( Math.Sqrt(25));
|
| 301 |
+
|
| 302 |
+
>> 5
|
| 303 |
+
@endcode
|
| 304 |
+
*/
|
| 305 |
+
proto static float Sqrt(float val);
|
| 306 |
+
|
| 307 |
+
/**
|
| 308 |
+
\brief Returns the binary (base-2) logarithm of x.
|
| 309 |
+
\param x \p float Value whose logarithm is calculated.
|
| 310 |
+
\return \p float The binary logarithm of x: log2x.
|
| 311 |
+
\n If x is negative, it causes a domain error:
|
| 312 |
+
\n If x is zero, it may cause a pole error (depending on the library implementation).
|
| 313 |
+
@code
|
| 314 |
+
Print( Math.Log2(1.0) );
|
| 315 |
+
|
| 316 |
+
>> 0.0
|
| 317 |
+
@endcode
|
| 318 |
+
*/
|
| 319 |
+
proto static float Log2(float x);
|
| 320 |
+
|
| 321 |
+
/**
|
| 322 |
+
\brief Returns sinus of angle in radians
|
| 323 |
+
\param angle \p float Angle in radians
|
| 324 |
+
\return \p float - Sinus of angle
|
| 325 |
+
@code
|
| 326 |
+
Print( Math.Sin(0.785398) ); // (45)
|
| 327 |
+
|
| 328 |
+
>> 0.707107
|
| 329 |
+
@endcode
|
| 330 |
+
*/
|
| 331 |
+
proto static float Sin(float angle);
|
| 332 |
+
|
| 333 |
+
/**
|
| 334 |
+
\brief Returns cosinus of angle in radians
|
| 335 |
+
\param angle \p float Angle in radians
|
| 336 |
+
\return \p float - Cosinus of angle
|
| 337 |
+
@code
|
| 338 |
+
Print( Math.Cos(0.785398) ); // (45)
|
| 339 |
+
|
| 340 |
+
>> 0.707107
|
| 341 |
+
@endcode
|
| 342 |
+
*/
|
| 343 |
+
proto static float Cos(float angle);
|
| 344 |
+
|
| 345 |
+
/**
|
| 346 |
+
\brief Returns tangent of angle in radians
|
| 347 |
+
\param angle \p float Angle in radians
|
| 348 |
+
\return \p float - Tangens of angle
|
| 349 |
+
@code
|
| 350 |
+
Print( Math.Tan(0.785398) ); // (45)
|
| 351 |
+
|
| 352 |
+
>> 1
|
| 353 |
+
@endcode
|
| 354 |
+
*/
|
| 355 |
+
proto static float Tan(float angle);
|
| 356 |
+
|
| 357 |
+
/**
|
| 358 |
+
\brief Returns angle in radians from sinus
|
| 359 |
+
\param s \p float Sinus
|
| 360 |
+
\return \p float - Angle in radians
|
| 361 |
+
@code
|
| 362 |
+
Print( Math.Asin(0.707107) ); // (sinus 45)
|
| 363 |
+
|
| 364 |
+
>> 0.785398
|
| 365 |
+
@endcode
|
| 366 |
+
*/
|
| 367 |
+
proto static float Asin(float s);
|
| 368 |
+
|
| 369 |
+
/**
|
| 370 |
+
\brief Returns angle in radians from cosinus
|
| 371 |
+
\param c \p float Cosinus
|
| 372 |
+
\return \p float - Angle in radians
|
| 373 |
+
@code
|
| 374 |
+
Print( Math.Acos(0.707107) ); // (cosinus 45)
|
| 375 |
+
|
| 376 |
+
>> 0.785398
|
| 377 |
+
@endcode
|
| 378 |
+
*/
|
| 379 |
+
proto static float Acos(float c);
|
| 380 |
+
|
| 381 |
+
/**
|
| 382 |
+
\brief Returns angle in radians from tangent
|
| 383 |
+
\param x \p float Tangent
|
| 384 |
+
\return \p float - Angle in radians
|
| 385 |
+
*/
|
| 386 |
+
proto static float Atan(float x);
|
| 387 |
+
|
| 388 |
+
/**
|
| 389 |
+
\brief Returns angle in radians from tangent
|
| 390 |
+
\param y \p float Tangent
|
| 391 |
+
\param x \p float Tangent
|
| 392 |
+
\return \p float - Angle in radians
|
| 393 |
+
@code
|
| 394 |
+
Print ( Math.Atan2(1, 1) );
|
| 395 |
+
|
| 396 |
+
>> 0.785398
|
| 397 |
+
@endcode
|
| 398 |
+
*/
|
| 399 |
+
proto static float Atan2(float y, float x);
|
| 400 |
+
|
| 401 |
+
/**
|
| 402 |
+
\brief Returns mathematical round of value
|
| 403 |
+
\param f \p float Value
|
| 404 |
+
\return \p float - closest whole number to 'f'
|
| 405 |
+
@code
|
| 406 |
+
Print( Math.Round(5.3) );
|
| 407 |
+
Print( Math.Round(5.8) );
|
| 408 |
+
|
| 409 |
+
>> 5
|
| 410 |
+
>> 6
|
| 411 |
+
@endcode
|
| 412 |
+
*/
|
| 413 |
+
proto static float Round(float f);
|
| 414 |
+
|
| 415 |
+
/**
|
| 416 |
+
\brief Returns floor of value
|
| 417 |
+
\param f \p float Value
|
| 418 |
+
\return \p float - Floor of value
|
| 419 |
+
@code
|
| 420 |
+
Print( Math.Floor(5.3) );
|
| 421 |
+
Print( Math.Floor(5.8) );
|
| 422 |
+
|
| 423 |
+
>> 5
|
| 424 |
+
>> 5
|
| 425 |
+
@endcode
|
| 426 |
+
*/
|
| 427 |
+
proto static float Floor(float f);
|
| 428 |
+
|
| 429 |
+
/**
|
| 430 |
+
\brief Returns ceil of value
|
| 431 |
+
\param f \p float Value
|
| 432 |
+
\return \p float - Ceil of value
|
| 433 |
+
@code
|
| 434 |
+
Print( Math.Ceil(5.3) );
|
| 435 |
+
Print( Math.Ceil(5.8) );
|
| 436 |
+
|
| 437 |
+
>> 6
|
| 438 |
+
>> 6
|
| 439 |
+
@endcode
|
| 440 |
+
*/
|
| 441 |
+
proto static float Ceil(float f);
|
| 442 |
+
|
| 443 |
+
/**
|
| 444 |
+
\brief Returns wrap number to specified interval [min, max[
|
| 445 |
+
\param f \p float Value
|
| 446 |
+
\param min \p float Minimum
|
| 447 |
+
\param max \p float Maximum
|
| 448 |
+
\return \p float - number in specified interval [min, max[
|
| 449 |
+
@code
|
| 450 |
+
Print( Math.WrapFloat(9.0, 1.0, 9.0) );
|
| 451 |
+
|
| 452 |
+
>> 1.0
|
| 453 |
+
@endcode
|
| 454 |
+
*/
|
| 455 |
+
proto static float WrapFloat(float f, float min, float max);
|
| 456 |
+
|
| 457 |
+
/**
|
| 458 |
+
\brief Returns wrap number to specified interval [min, max]
|
| 459 |
+
\param f \p float Value
|
| 460 |
+
\param min \p float Minimum
|
| 461 |
+
\param max \p float Maximum
|
| 462 |
+
\return \p float - number in specified interval [min, max]
|
| 463 |
+
@code
|
| 464 |
+
Print( Math.WrapFloatInclusive(9.0, 1.0, 9.0) );
|
| 465 |
+
|
| 466 |
+
>> 9.0
|
| 467 |
+
@endcode
|
| 468 |
+
*/
|
| 469 |
+
proto static float WrapFloatInclusive(float f, float min, float max);
|
| 470 |
+
|
| 471 |
+
/**
|
| 472 |
+
\brief Returns wrap number to specified interval [0, max[
|
| 473 |
+
\param f \p float Value
|
| 474 |
+
\param max \p float Maximum
|
| 475 |
+
\return \p float - number in specified interval [0, max[
|
| 476 |
+
@code
|
| 477 |
+
Print( Math.WrapFloat0X(9.0, 9.0) );
|
| 478 |
+
|
| 479 |
+
>> 0.0
|
| 480 |
+
@endcode
|
| 481 |
+
*/
|
| 482 |
+
proto static float WrapFloat0X(float f, float max);
|
| 483 |
+
|
| 484 |
+
/**
|
| 485 |
+
\brief Returns wrap number to specified interval [0, max]
|
| 486 |
+
\param f \p float Value
|
| 487 |
+
\param max \p float Maximum
|
| 488 |
+
\return \p float - number in specified interval [0, max]
|
| 489 |
+
@code
|
| 490 |
+
Print( Math.WrapFloat0X(9.0, 9.0) );
|
| 491 |
+
|
| 492 |
+
>> 9.0
|
| 493 |
+
@endcode
|
| 494 |
+
*/
|
| 495 |
+
proto static float WrapFloat0XInclusive(float f, float max);
|
| 496 |
+
|
| 497 |
+
/**
|
| 498 |
+
\brief Returns wrap number to specified interval [min, max[
|
| 499 |
+
\param i \p int Value
|
| 500 |
+
\param min \p float Minimum
|
| 501 |
+
\param max \p int Maximum
|
| 502 |
+
\return \p int - number in specified interval [min, max[
|
| 503 |
+
@code
|
| 504 |
+
Print( Math.WrapInt(9, 1, 9) );
|
| 505 |
+
|
| 506 |
+
>> 1
|
| 507 |
+
@endcode
|
| 508 |
+
*/
|
| 509 |
+
proto static int WrapInt(int i, int min, int max);
|
| 510 |
+
|
| 511 |
+
/**
|
| 512 |
+
\brief Returns wrap number to specified interval [0, max[
|
| 513 |
+
\param i \p int Value
|
| 514 |
+
\param max \p int Maximum
|
| 515 |
+
\return \p int - number in specified interval [0, max[
|
| 516 |
+
@code
|
| 517 |
+
Print( Math.WrapInt0X(9, 9) );
|
| 518 |
+
|
| 519 |
+
>> 0
|
| 520 |
+
@endcode
|
| 521 |
+
*/
|
| 522 |
+
proto static int WrapInt0X(int i, int max);
|
| 523 |
+
|
| 524 |
+
/**
|
| 525 |
+
\brief Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'
|
| 526 |
+
\param value \p float Value
|
| 527 |
+
\param min \p float Minimum value
|
| 528 |
+
\param max \p float Maximum value
|
| 529 |
+
\return \p float - Clamped value
|
| 530 |
+
@code
|
| 531 |
+
Print( Math.Clamp(-0.1, 0, 1) );
|
| 532 |
+
Print( Math.Clamp(2, 0, 1) );
|
| 533 |
+
Print( Math.Clamp(0.5, 0, 1) );
|
| 534 |
+
|
| 535 |
+
>> 0
|
| 536 |
+
>> 1
|
| 537 |
+
>> 0.5
|
| 538 |
+
@endcode
|
| 539 |
+
*/
|
| 540 |
+
proto static float Clamp(float value, float min, float max);
|
| 541 |
+
|
| 542 |
+
/**
|
| 543 |
+
\brief Returns smaller of two given values
|
| 544 |
+
\param x \p float Value
|
| 545 |
+
\param y \p float Value
|
| 546 |
+
\return \p float - min value
|
| 547 |
+
@code
|
| 548 |
+
Print( Math.Min(5.3, 2.8) );
|
| 549 |
+
|
| 550 |
+
>> 2.8
|
| 551 |
+
@endcode
|
| 552 |
+
*/
|
| 553 |
+
proto static float Min(float x, float y);
|
| 554 |
+
|
| 555 |
+
/**
|
| 556 |
+
\brief Returns bigger of two given values
|
| 557 |
+
\param x \p float Value
|
| 558 |
+
\param y \p float Value
|
| 559 |
+
\return \p float - max value
|
| 560 |
+
@code
|
| 561 |
+
Print( Math.Max(5.3, 2.8) );
|
| 562 |
+
|
| 563 |
+
>> 5.3
|
| 564 |
+
@endcode
|
| 565 |
+
*/
|
| 566 |
+
proto static float Max(float x, float y);
|
| 567 |
+
|
| 568 |
+
/**
|
| 569 |
+
\brief Returns if value is between min and max (inclusive)
|
| 570 |
+
\param v \p float Value
|
| 571 |
+
\param min \p float Minimum value
|
| 572 |
+
\param max \p float Maximum value
|
| 573 |
+
\return \p bool - if value is within range [min,max]
|
| 574 |
+
@code
|
| 575 |
+
Print( Math.IsInRange(6.9, 3.6, 9.3) );
|
| 576 |
+
|
| 577 |
+
>> true
|
| 578 |
+
@endcode
|
| 579 |
+
*/
|
| 580 |
+
proto static bool IsInRange(float v, float min, float max);
|
| 581 |
+
|
| 582 |
+
/**
|
| 583 |
+
\brief Returns if value is between min and max (inclusive)
|
| 584 |
+
\param v \p int Value
|
| 585 |
+
\param min \p int Minimum value
|
| 586 |
+
\param max \p int Maximum value
|
| 587 |
+
\return \p bool - if value is within range [min,max]
|
| 588 |
+
@code
|
| 589 |
+
Print( Math.IsInRangeInt(6, 3, 9) );
|
| 590 |
+
|
| 591 |
+
>> true
|
| 592 |
+
@endcode
|
| 593 |
+
*/
|
| 594 |
+
proto static bool IsInRangeInt(int v, int min, int max);
|
| 595 |
+
|
| 596 |
+
/**
|
| 597 |
+
\brief Linearly interpolates between 'a' and 'b' given 'time'.
|
| 598 |
+
\param a \p float Start
|
| 599 |
+
\param b \p float End
|
| 600 |
+
\param time \p float Time [value needs to be between 0..1 for correct results, no auto clamp applied]
|
| 601 |
+
\return \p float - The interpolated result between the two float values.
|
| 602 |
+
@code
|
| 603 |
+
Print( Math.Lerp(3, 7, 0.5) );
|
| 604 |
+
|
| 605 |
+
>> 5
|
| 606 |
+
@endcode
|
| 607 |
+
*/
|
| 608 |
+
proto static float Lerp(float a, float b, float time);
|
| 609 |
+
|
| 610 |
+
/**
|
| 611 |
+
\brief Calculates the linear value that produces the interpolant value within the range [a, b], it's an inverse of Lerp.
|
| 612 |
+
\param a \p float Start
|
| 613 |
+
\param b \p float End
|
| 614 |
+
\param value \p float value
|
| 615 |
+
\return \p float - the time given the position between 'a' and 'b' given 'value', there is no clamp on 'value', to stay between [0..1] use 'value' between 'a' and 'b'
|
| 616 |
+
@code
|
| 617 |
+
Print( Math.InverseLerp(3, 7, 5) );
|
| 618 |
+
|
| 619 |
+
>> 0.5
|
| 620 |
+
@endcode
|
| 621 |
+
*/
|
| 622 |
+
proto static float InverseLerp(float a, float b, float value);
|
| 623 |
+
|
| 624 |
+
/**
|
| 625 |
+
\brief Returns area of a right triangle
|
| 626 |
+
\param s \p float Length of adjacent leg
|
| 627 |
+
\param a \p float Angle of corner bordering adjacent which is not the right corner (in radians)
|
| 628 |
+
\return \p float - Area
|
| 629 |
+
*/
|
| 630 |
+
proto static float AreaOfRightTriangle(float s, float a);
|
| 631 |
+
|
| 632 |
+
/**
|
| 633 |
+
\brief Returns hypotenus of a right triangle
|
| 634 |
+
\param s \p float Length of adjacent leg
|
| 635 |
+
\param a \p float Angle of corner bordering adjacent which is not the right corner (in radians)
|
| 636 |
+
\return \p float - hypotenus
|
| 637 |
+
*/
|
| 638 |
+
proto static float HypotenuseOfRightTriangle(float s, float a);
|
| 639 |
+
|
| 640 |
+
/**
|
| 641 |
+
\brief Returns if point is inside circle
|
| 642 |
+
\param c \p vector Center of circle ([0] and [2] will be used, as a circle is 2D)
|
| 643 |
+
\param r \p float Radius of circle
|
| 644 |
+
\param p \p vector Point ([0] and [2] will be used, as a circle is 2D)
|
| 645 |
+
\return \p bool - True when point is in circle
|
| 646 |
+
*/
|
| 647 |
+
proto static bool IsPointInCircle(vector c, float r, vector p);
|
| 648 |
+
|
| 649 |
+
/**
|
| 650 |
+
\brief Returns if point is inside rectangle
|
| 651 |
+
\param mi \p vector Minimums of rectangle ([0] and [2] will be used, as a rectangle is 2D)
|
| 652 |
+
\param ma \p vector Maximums of rectangle ([0] and [2] will be used, as a rectangle is 2D)
|
| 653 |
+
\param p \p vector Point ([0] and [2] will be used, as a rectangle is 2D)
|
| 654 |
+
\return \p bool - True when point is in rectangle
|
| 655 |
+
*/
|
| 656 |
+
proto static bool IsPointInRectangle(vector mi, vector ma, vector p);
|
| 657 |
+
|
| 658 |
+
//--------------------------------------------------------------------------
|
| 659 |
+
//-------------------------------- filters ---------------------------------
|
| 660 |
+
//--------------------------------------------------------------------------
|
| 661 |
+
|
| 662 |
+
/**
|
| 663 |
+
\brief Does the CD smoothing function - easy in | easy out / S shaped smoothing
|
| 664 |
+
\param val \p actual value
|
| 665 |
+
\param target \p value we are reaching for -> Target
|
| 666 |
+
\param velocity \p float[1] - array of ONE member - some kind of memory and actual accel/decel rate, need to be zeroed when filter is about to be reset
|
| 667 |
+
\param smoothTime \p smoothing parameter, 0.1 .. 0.4 are resonable values, 0.1 is sharp, 0.4 is very smooth
|
| 668 |
+
\param maxVelocity \p maximal value change when multiplied by dt
|
| 669 |
+
\param dt \p delta time
|
| 670 |
+
|
| 671 |
+
\return \p float smoothed/filtered value
|
| 672 |
+
|
| 673 |
+
@code
|
| 674 |
+
val = EnfMath.SmoothCD(val, varTarget, valVelocity, 0.3, 1000, dt);
|
| 675 |
+
@endcode
|
| 676 |
+
*/
|
| 677 |
+
|
| 678 |
+
proto static float SmoothCD(float val, float target, inout float velocity[], float smoothTime, float maxVelocity, float dt);
|
| 679 |
+
|
| 680 |
+
//! occurences values above '12' will cause Factorial to overflow int.
|
| 681 |
+
static float Poisson(float mean, int occurences)
|
| 682 |
+
{
|
| 683 |
+
return Pow(mean, occurences) * Pow(EULER,-mean) / Factorial(occurences);
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
//! values above '12' will cause int overflow
|
| 687 |
+
static int Factorial(int val)
|
| 688 |
+
{
|
| 689 |
+
if (val > 12)
|
| 690 |
+
{
|
| 691 |
+
ErrorEx("Values above '12' cause int overflow! Returning '1'");
|
| 692 |
+
return 1;
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
int res = 1;
|
| 696 |
+
while (val > 1)
|
| 697 |
+
{
|
| 698 |
+
res *= val--;
|
| 699 |
+
}
|
| 700 |
+
return res;
|
| 701 |
+
}
|
| 702 |
+
};
|
| 703 |
+
|
| 704 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnMath3D.c
ADDED
|
@@ -0,0 +1,474 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* \defgroup Math3DAPI Math3D library
|
| 3 |
+
* @{
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
\brief Vector constructor from components
|
| 8 |
+
\param x \p float x component
|
| 9 |
+
\param y \p float y component
|
| 10 |
+
\param z \p float z component
|
| 11 |
+
\return \p vector resulting vector
|
| 12 |
+
@code
|
| 13 |
+
Print( Vector(1, 2, 3) );
|
| 14 |
+
|
| 15 |
+
>> <1,2,3>
|
| 16 |
+
@endcode
|
| 17 |
+
*/
|
| 18 |
+
proto native vector Vector(float x, float y, float z);
|
| 19 |
+
|
| 20 |
+
enum ECurveType
|
| 21 |
+
{
|
| 22 |
+
CatmullRom,
|
| 23 |
+
NaturalCubic,
|
| 24 |
+
UniformCubic
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
class Math3D
|
| 28 |
+
{
|
| 29 |
+
private void Math3D() {}
|
| 30 |
+
private void ~Math3D() {}
|
| 31 |
+
|
| 32 |
+
//-----------------------------------------------------------------
|
| 33 |
+
proto static vector ClipLine(vector start, vector end, vector norm, float d);
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
\brief Tests whether ray is intersecting sphere.
|
| 37 |
+
\param raybase \p vector Start of ray
|
| 38 |
+
\param raycos \p vector End of ray
|
| 39 |
+
\param center \p vector Center of sphere
|
| 40 |
+
\param radius \p float Radius of sphere
|
| 41 |
+
\return \p float -1 when not intersecting, else the fraction of ray
|
| 42 |
+
*/
|
| 43 |
+
proto static float IntersectRaySphere(vector raybase, vector raycos, vector center, float radius);
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
\brief Tests whether ray is intersecting axis aligned box.
|
| 47 |
+
\param start \p vector Start of ray
|
| 48 |
+
\param end \p vector End of ray
|
| 49 |
+
\param mins \p vector Minimums of bound box
|
| 50 |
+
\param maxs \p vector Maximums of bound box
|
| 51 |
+
\return \p float -1 when not intersecting, else the fraction of ray
|
| 52 |
+
*/
|
| 53 |
+
proto static float IntersectRayBox(vector start, vector end, vector mins, vector maxs);
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
\brief Tests whether sphere is intersecting axis aligned box.
|
| 57 |
+
\param origin \p vector Origin of sphere
|
| 58 |
+
\param radius \p float Radius of sphere
|
| 59 |
+
\param mins \p vector Minimums of bound box
|
| 60 |
+
\param maxs \p vector Maximums of bound box
|
| 61 |
+
\return \p bool True when intersects
|
| 62 |
+
*/
|
| 63 |
+
proto static bool IntersectSphereBox(vector origin, float radius, vector mins, vector maxs);
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
\brief Tests whether sphere is intersecting cone.
|
| 67 |
+
\param origin \p vector Origin of sphere
|
| 68 |
+
\param radius \p float Radius of sphere
|
| 69 |
+
\param conepos \p vector Position of top of cone
|
| 70 |
+
\param axis \p vector Orientation of cone in direction from top to bottom
|
| 71 |
+
\param angle \p float Angle of cone in radians
|
| 72 |
+
\return \p bool True when sphere is intersecting cone
|
| 73 |
+
*/
|
| 74 |
+
proto static bool IntersectSphereCone(vector origin, float radius, vector conepos, vector axis, float angle);
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
\brief Tests whether sphere is fully inside cone.
|
| 78 |
+
\param origin \p vector Origin of sphere
|
| 79 |
+
\param radius \p float Radius of sphere
|
| 80 |
+
\param conepos \p vector Position of top of cone
|
| 81 |
+
\param axis \p vector Orientation of cone in direction from top to bottom
|
| 82 |
+
\param angle \p float Angle of cone in radians
|
| 83 |
+
\return \p bool True when sphere is fully inside cone
|
| 84 |
+
*/
|
| 85 |
+
proto static bool IntersectWholeSphereCone(vector origin, float radius, vector conepos, vector axis, float angle);
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
\brief Tests whether cylinder is intersecting oriented box.
|
| 89 |
+
\param mins \p vector Minimums of bound box
|
| 90 |
+
\param maxs \p vector Maximums of bound box
|
| 91 |
+
\param obbMat \p vector Transform of box
|
| 92 |
+
\param cylMat \p vector Transform of cylinder
|
| 93 |
+
\param cylinderRadius \p float Radius of cylinder
|
| 94 |
+
\param cylinderHeight \p float Height of cylinder
|
| 95 |
+
\return \p bool True when cylinder is intersecting oriented box
|
| 96 |
+
*/
|
| 97 |
+
proto static bool IntersectCylinderOBB(vector mins, vector maxs, vector obbMat[4], vector cylMat[4], float cylinderRadius, float cylinderHeight);
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
\brief Tests whether ray is intersecting cylinder.
|
| 101 |
+
\param rayStart \p vector Start of ray
|
| 102 |
+
\param rayEnd \p vector End of ray
|
| 103 |
+
\param center \p vector Center of cylinder
|
| 104 |
+
\param radius \p float Radius of cylinder
|
| 105 |
+
\param height \p float Height of cylinder
|
| 106 |
+
\return \p bool True when ray is intersecting cylinder
|
| 107 |
+
*/
|
| 108 |
+
proto static bool IntersectRayCylinder(vector rayStart, vector rayEnd, vector center, float radius, float height);
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
\brief Creates rotation matrix from angles
|
| 112 |
+
\param ang \p vector which contains angles
|
| 113 |
+
\param[out] mat \p vector created rotation matrix
|
| 114 |
+
@code
|
| 115 |
+
vector mat[3];
|
| 116 |
+
YawPitchRollMatrix( "70 15 45", mat );
|
| 117 |
+
Print( mat );
|
| 118 |
+
|
| 119 |
+
>> <0.330366,0.0885213,-0.939693>,<0.458809,0.854988,0.241845>,<0.824835,-0.511037,0.241845>
|
| 120 |
+
@endcode
|
| 121 |
+
*/
|
| 122 |
+
proto static void YawPitchRollMatrix(vector ang, out vector mat[3]);
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
\brief Creates rotation matrix from direction and up vector
|
| 126 |
+
\param dir \p vector direction vector
|
| 127 |
+
\param up \p vector up vector
|
| 128 |
+
\param[out] mat \p vector[4] created rotation matrix
|
| 129 |
+
@code
|
| 130 |
+
vector mat[4];
|
| 131 |
+
vector dir = "1 0 1";
|
| 132 |
+
vector up = "0 1 0";
|
| 133 |
+
DirectionAndUpMatrix( dir, up, mat );
|
| 134 |
+
Print( mat );
|
| 135 |
+
|
| 136 |
+
>> <0.707107,0,-0.707107>,<0,1,0>,<0.707107,0,0.707107>,<0,0,0>
|
| 137 |
+
@endcode
|
| 138 |
+
*/
|
| 139 |
+
proto static void DirectionAndUpMatrix(vector dir, vector up, out vector mat[4]);
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
\brief Transforms matrix
|
| 143 |
+
\param mat0 \p vector[4] first matrix
|
| 144 |
+
\param mat1 \p vector[4] second matrix
|
| 145 |
+
\param[out] res \p vector[4] result of first and second matrix multiplication
|
| 146 |
+
@code
|
| 147 |
+
vector mat0[4] = { "2 0 0 0", "0 3 0 0", "0 1 0 0", "0 0 0 1" }; // scale matrix
|
| 148 |
+
vector mat1[4] = { "1 0 0 0", "0 1 0 0", "0 1 0 0", "2 4 1 3" }; // translation matrix
|
| 149 |
+
vector res[4];
|
| 150 |
+
Math3D.MatrixMultiply4(mat0, mat1, res)
|
| 151 |
+
Print( res );
|
| 152 |
+
|
| 153 |
+
>> <2,0,0>,<0,3,0>,<0,3,0>,<4,13,0>
|
| 154 |
+
@endcode
|
| 155 |
+
*/
|
| 156 |
+
proto static void MatrixMultiply4(vector mat0[4], vector mat1[4], out vector res[4]);
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
\brief Transforms rotation matrix
|
| 160 |
+
\param mat0 \p vector[3] first matrix
|
| 161 |
+
\param mat1 \p vector[3] second matrix
|
| 162 |
+
\param[out] res \p vector[3] result of first and second matrix multiplication
|
| 163 |
+
@code
|
| 164 |
+
vector mat0[3] = { "1.5 2.5 0", "0.1 1.3 0", "0 0 1" }; // rotation matrix
|
| 165 |
+
vector mat1[3] = { "1 0.4 0", "0 1 0", "0 1.3 2.7" }; // rotation matrix
|
| 166 |
+
vector res[3];
|
| 167 |
+
Math3D.MatrixMultiply3(mat0, mat1, res)
|
| 168 |
+
Print( res );
|
| 169 |
+
|
| 170 |
+
>> <1.54,3.02,0>,<0.1,1.3,0>,<0.13,1.69,2.7>
|
| 171 |
+
@endcode
|
| 172 |
+
*/
|
| 173 |
+
proto static void MatrixMultiply3(vector mat0[3], vector mat1[3], out vector res[3]);
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
\brief Invert-transforms matrix
|
| 177 |
+
\param mat0 \p vector[4] first matrix
|
| 178 |
+
\param mat1 \p vector[4] second matrix
|
| 179 |
+
\param[out] res \p vector[4] inverse result of first and second matrix multiplication
|
| 180 |
+
@code
|
| 181 |
+
vector mat0[4] = { "2 0 0", "0 3 0", "0 0 1", "0 0 0" }; // scale matrix
|
| 182 |
+
vector mat1[4] = { "1 0 0", "0 1 0", "0 0 1", "2 4 1" }; // translation matrix
|
| 183 |
+
vector res[4];
|
| 184 |
+
Math3D.MatrixInvMultiply4(mat0, mat1, res)
|
| 185 |
+
Print( res );
|
| 186 |
+
|
| 187 |
+
>> <2,0,0>,<0,3,1>,<0,3,1>,<4,12,4>
|
| 188 |
+
@endcode
|
| 189 |
+
*/
|
| 190 |
+
proto static void MatrixInvMultiply4(vector mat0[4], vector mat1[4], out vector res[4]);
|
| 191 |
+
|
| 192 |
+
/**
|
| 193 |
+
\brief Invert-transforms rotation matrix
|
| 194 |
+
\param mat0 \p vector[3] first matrix
|
| 195 |
+
\param mat1 \p vector[3] second matrix
|
| 196 |
+
\param[out] res \p vector[3] result of first and second matrix multiplication
|
| 197 |
+
@code
|
| 198 |
+
vector mat0[3] = { "1.5 2.5 0", "0.1 1.3 0", "0 0 1" }; // rotation matrix
|
| 199 |
+
vector mat1[3] = { "1 0.4 0", "0 1 0", "0 1.3 2.7" }; // rotation matrix
|
| 200 |
+
vector res[3];
|
| 201 |
+
Math3D.MatrixInvMultiply3(mat0, mat1, res)
|
| 202 |
+
Print( res );
|
| 203 |
+
|
| 204 |
+
>> <2.5,0.62,0>,<2.5,1.3,0>,<3.25,1.69,2.7>
|
| 205 |
+
@endcode
|
| 206 |
+
*/
|
| 207 |
+
proto static void MatrixInvMultiply3(vector mat0[3], vector mat1[3], out vector res[3]);
|
| 208 |
+
|
| 209 |
+
/**
|
| 210 |
+
\brief Orthogonalizes matrix
|
| 211 |
+
\param[it] mat \p matrix which should be orthogonalized
|
| 212 |
+
*/
|
| 213 |
+
proto static void MatrixOrthogonalize4(vector mat[4]);
|
| 214 |
+
|
| 215 |
+
/**
|
| 216 |
+
\brief Orthogonalizes matrix
|
| 217 |
+
\param[it] mat \p matrix which should be orthogonalized
|
| 218 |
+
*/
|
| 219 |
+
proto static void MatrixOrthogonalize3(vector mat[3]);
|
| 220 |
+
|
| 221 |
+
/**
|
| 222 |
+
\brief Creates identity matrix
|
| 223 |
+
\param[out] mat \p created identity matrix
|
| 224 |
+
@code
|
| 225 |
+
vector mat[4];
|
| 226 |
+
Math3D.MatrixIdentity4( mat );
|
| 227 |
+
Print( mat );
|
| 228 |
+
|
| 229 |
+
>> <1,0,0>,<0,1,0>,<0,0,1>,<0,0,0>
|
| 230 |
+
@endcode
|
| 231 |
+
*/
|
| 232 |
+
|
| 233 |
+
static void MatrixIdentity4(out vector mat[4])
|
| 234 |
+
{
|
| 235 |
+
mat[0] = "1 0 0";
|
| 236 |
+
mat[1] = "0 1 0";
|
| 237 |
+
mat[2] = "0 0 1";
|
| 238 |
+
mat[3] = vector.Zero;
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
/**
|
| 242 |
+
\brief Creates identity matrix
|
| 243 |
+
\param[out] mat \p created identity matrix
|
| 244 |
+
@code
|
| 245 |
+
vector mat[3];
|
| 246 |
+
Math3D.MatrixIdentity3( mat );
|
| 247 |
+
Print( mat );
|
| 248 |
+
|
| 249 |
+
>> <1,0,0>,<0,1,0>,<0,0,1>
|
| 250 |
+
@endcode
|
| 251 |
+
*/
|
| 252 |
+
static void MatrixIdentity3(out vector mat[3])
|
| 253 |
+
{
|
| 254 |
+
mat[0] = "1 0 0";
|
| 255 |
+
mat[1] = "0 1 0";
|
| 256 |
+
mat[2] = "0 0 1";
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
/**
|
| 260 |
+
\brief Creates scale matrix
|
| 261 |
+
\param scale \p scale coeficient
|
| 262 |
+
\param[out] mat \p created scale matrix
|
| 263 |
+
@code
|
| 264 |
+
vector mat[3];
|
| 265 |
+
Math3D.ScaleMatrix( 2.5, mat );
|
| 266 |
+
Print( mat );
|
| 267 |
+
|
| 268 |
+
>> <2.5,0,0>,<0,2.5,0>,<0,0,2.5>
|
| 269 |
+
@endcode
|
| 270 |
+
*/
|
| 271 |
+
static void ScaleMatrix(float scale, out vector mat[3])
|
| 272 |
+
{
|
| 273 |
+
vector v0, v1, v2;
|
| 274 |
+
v0[0] = scale;
|
| 275 |
+
v1[1] = scale;
|
| 276 |
+
v2[2] = scale;
|
| 277 |
+
mat[0] = v0;
|
| 278 |
+
mat[1] = v1;
|
| 279 |
+
mat[2] = v2;
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
/**
|
| 283 |
+
\brief Creates identity quaternion
|
| 284 |
+
\param[out] q \p float[4] created identity quaternion
|
| 285 |
+
@code
|
| 286 |
+
float q[4];
|
| 287 |
+
Math3D.QuatIdentity( q );
|
| 288 |
+
Print( q );
|
| 289 |
+
|
| 290 |
+
>> {0,0,0,1}
|
| 291 |
+
@endcode
|
| 292 |
+
*/
|
| 293 |
+
static void QuatIdentity(out float q[4])
|
| 294 |
+
{
|
| 295 |
+
q[0] = 0;
|
| 296 |
+
q[1] = 0;
|
| 297 |
+
q[2] = 0;
|
| 298 |
+
q[3] = 1;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
/**
|
| 302 |
+
\brief Copies quaternion
|
| 303 |
+
\param s \p float[4] quaternion to copy
|
| 304 |
+
\param[out] d \p float[4] created quaternion copy
|
| 305 |
+
@code
|
| 306 |
+
float s[4] = { 2, 3, 4, 1 };
|
| 307 |
+
float d[4];
|
| 308 |
+
Math3D.QuatCopy( s, d );
|
| 309 |
+
Print( d );
|
| 310 |
+
|
| 311 |
+
>> {2,3,4,1}
|
| 312 |
+
@endcode
|
| 313 |
+
*/
|
| 314 |
+
static void QuatCopy(float s[4], out float d[4])
|
| 315 |
+
{
|
| 316 |
+
d[0] = s[0];
|
| 317 |
+
d[1] = s[1];
|
| 318 |
+
d[2] = s[2];
|
| 319 |
+
d[3] = s[3];
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
/**
|
| 323 |
+
\brief Converts rotation matrix to quaternion
|
| 324 |
+
\param mat \p vector[3] rotation matrix
|
| 325 |
+
\param[out] d \p float[4] created quaternion copy
|
| 326 |
+
@code
|
| 327 |
+
vector mat[3];
|
| 328 |
+
vector rot = "70 15 45";
|
| 329 |
+
rot.RotationMatrixFromAngles( mat );
|
| 330 |
+
float d[4];
|
| 331 |
+
Math3D.MatrixToQuat( mat, d );
|
| 332 |
+
Print( d );
|
| 333 |
+
|
| 334 |
+
>> {0.241626,0.566299,-0.118838,0.778973}
|
| 335 |
+
@endcode
|
| 336 |
+
*/
|
| 337 |
+
proto static void MatrixToQuat(vector mat[3], out float d[4]);
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
//! Converts quaternion to rotation matrix
|
| 341 |
+
proto static void QuatToMatrix(float q[4], out vector mat[3]);
|
| 342 |
+
|
| 343 |
+
/**
|
| 344 |
+
\brief Returns angles of rotation matrix
|
| 345 |
+
\param mat \p vector[3] rotation matrix
|
| 346 |
+
\return \p vector roll, pitch, yaw angles
|
| 347 |
+
@code
|
| 348 |
+
vector mat[3];
|
| 349 |
+
Math3D.RollPitchYawMatrix( "70 15 45", mat );
|
| 350 |
+
vector ang = Math3D.MatrixToAngles( mat );
|
| 351 |
+
Print( ang );
|
| 352 |
+
|
| 353 |
+
>> <70,15,-45>
|
| 354 |
+
@endcode
|
| 355 |
+
*/
|
| 356 |
+
proto static vector MatrixToAngles(vector mat[3]);
|
| 357 |
+
|
| 358 |
+
/**
|
| 359 |
+
\brief Linear interpolation between q1 and q2 with weight 'frac' (0...1)
|
| 360 |
+
\param[out] qout \p float[4] result quaternion
|
| 361 |
+
\param q1 \p float[4] first quaternion
|
| 362 |
+
\param q2 \p float[4] second quaternion
|
| 363 |
+
\param frac \p float interpolation weight
|
| 364 |
+
@code
|
| 365 |
+
float q1[4] = { 1, 1, 1, 1 };
|
| 366 |
+
float q2[4] = { 2, 2, 2, 1 };
|
| 367 |
+
float qout[4];
|
| 368 |
+
Math3D.QuatLerp( qout, q1, q2, 0.5 );
|
| 369 |
+
Print( qout );
|
| 370 |
+
|
| 371 |
+
>> {1.5,1.5,1.5,1}
|
| 372 |
+
@endcode
|
| 373 |
+
*/
|
| 374 |
+
proto static void QuatLerp(out float qout[4], float q1[4], float q2[4], float frac);
|
| 375 |
+
|
| 376 |
+
/**
|
| 377 |
+
\brief Multiplies quaternions
|
| 378 |
+
\param[out] qout \p float[4] result quaternion
|
| 379 |
+
\param q1 \p float[4] first quaternion
|
| 380 |
+
\param q2 \p float[4] second quaternion
|
| 381 |
+
@code
|
| 382 |
+
float q1[4] = { 1, 2, 3, 1 };
|
| 383 |
+
float q2[4] = { 2, 2, 2, 1 };
|
| 384 |
+
float qout[4];
|
| 385 |
+
Math3D.QuatMultiply( qout, q1, q2 );
|
| 386 |
+
Print( qout );
|
| 387 |
+
|
| 388 |
+
>> {2,4,6,1}
|
| 389 |
+
@endcode
|
| 390 |
+
*/
|
| 391 |
+
proto static void QuatMultiply(out float qout[4], float q1[4], float q2[4]);
|
| 392 |
+
|
| 393 |
+
//! Returns Angles vector from quaternion
|
| 394 |
+
proto static vector QuatToAngles(float q[4]);
|
| 395 |
+
|
| 396 |
+
/**
|
| 397 |
+
\brief Returns 1, when bounding boxes intersects
|
| 398 |
+
\param mins1 \p vector minimum point of first bounding box
|
| 399 |
+
\param maxs1 \p vector maximum point of first bounding box
|
| 400 |
+
\param mins2 \p vector minimum point of second bounding box
|
| 401 |
+
\param maxs2 \p vector maximum point of second bounding box
|
| 402 |
+
\return \p int 1 if boundig boxes intersects, otherwise 0
|
| 403 |
+
@code
|
| 404 |
+
vector mins1 = "1 1 1";
|
| 405 |
+
vector maxs1 = "3 3 3";
|
| 406 |
+
vector mins2 = "2 2 2";
|
| 407 |
+
vector maxs2 = "4 4 4";
|
| 408 |
+
Print( Math3D.CheckBoundBox(mins1, maxs1, mins2, maxs2) );
|
| 409 |
+
|
| 410 |
+
>> 1
|
| 411 |
+
@endcode
|
| 412 |
+
*/
|
| 413 |
+
proto static int CheckBoundBox(vector mins1, vector maxs1, vector mins2, vector maxs2);
|
| 414 |
+
|
| 415 |
+
/**
|
| 416 |
+
\brief Returns randon normalized direction
|
| 417 |
+
\return \p vector
|
| 418 |
+
@code
|
| 419 |
+
Print( Math3D.GetRandomDir() );
|
| 420 |
+
|
| 421 |
+
>>vector ret = 0x0000000007c1a1c0 {<0.422565,0,-0.906333>}
|
| 422 |
+
@endcode
|
| 423 |
+
*/
|
| 424 |
+
static vector GetRandomDir()
|
| 425 |
+
{
|
| 426 |
+
float x = Math.RandomFloatInclusive(-1, 1);
|
| 427 |
+
float y = Math.RandomFloatInclusive(-1, 1);
|
| 428 |
+
float z = Math.RandomFloatInclusive(-1, 1);
|
| 429 |
+
|
| 430 |
+
return Vector(x, y, z).Normalized();
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
|
| 434 |
+
/**
|
| 435 |
+
\brief Computes curve
|
| 436 |
+
\return \p vector
|
| 437 |
+
@code
|
| 438 |
+
auto points = new array<vector>();
|
| 439 |
+
points.Insert( Vector( 0, 0, 0) );
|
| 440 |
+
points.Insert( Vector( 5, 0, 0) );
|
| 441 |
+
points.Insert( Vector( 8, 3, 0) );
|
| 442 |
+
points.Insert( Vector( 6, 1, 0) );
|
| 443 |
+
|
| 444 |
+
float t = 0.5;
|
| 445 |
+
vector result = Math3D.Curve(ECurveType.CatmullRom, t, points);
|
| 446 |
+
@endcode
|
| 447 |
+
*/
|
| 448 |
+
proto static native vector Curve(ECurveType type, float param, notnull array<vector> points);
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
/**
|
| 452 |
+
\brief Point on line beg .. end nearest to pos
|
| 453 |
+
\return \p vector
|
| 454 |
+
*/
|
| 455 |
+
proto static vector NearestPoint(vector beg, vector end, vector pos);
|
| 456 |
+
|
| 457 |
+
/**
|
| 458 |
+
\brief Angle that a target is from the direction of an origin
|
| 459 |
+
\return \p float Angle in radians
|
| 460 |
+
*/
|
| 461 |
+
proto static float AngleFromPosition(vector origin, vector originDir, vector target);
|
| 462 |
+
|
| 463 |
+
/**
|
| 464 |
+
\brief Calculates the points of a right 2D cone in 3D space
|
| 465 |
+
\param origin \p vector Origin of cone
|
| 466 |
+
\param length \p float Length of the cone
|
| 467 |
+
\param halfAngle \p float Half of the angle of the cone in radians
|
| 468 |
+
\param angleOffset \p float Angle offset of the cone in radians (handy for rotating it along with something in the world)
|
| 469 |
+
\param[out] leftPoint \p vector Left point of the cone
|
| 470 |
+
\param[out] rightPoint \p vector Right point of the cone
|
| 471 |
+
*/
|
| 472 |
+
proto static void ConePoints(vector origin, float length, float halfAngle, float angleOffset, out vector leftPoint, out vector rightPoint);
|
| 473 |
+
};
|
| 474 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnPhysics.c
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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int[] dJoint;
|
| 8 |
+
typedef int[] dBlock;
|
| 9 |
+
|
| 10 |
+
proto native int dGetNumDynamicBodies(notnull IEntity worldEnt);
|
| 11 |
+
proto native IEntity dGetDynamicBody(notnull IEntity worldEnt, int index);
|
| 12 |
+
proto native void dSetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2, bool enable);
|
| 13 |
+
proto native bool dGetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2);
|
| 14 |
+
|
| 15 |
+
//!Gets global gravity
|
| 16 |
+
proto native vector dGetGravity(notnull IEntity worldEntity);
|
| 17 |
+
//!Changes global gravity
|
| 18 |
+
proto native void dSetGravity(notnull IEntity worldEntity, vector g);
|
| 19 |
+
//!Changes fixed time-slice. Default is 1/40, thus simulation runs on 40fps. With smaller values, there is more precise simulation
|
| 20 |
+
proto native void dSetTimeSlice(notnull IEntity worldEntity, float timeSlice);
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* \defgroup RigidBody RigidBody API
|
| 24 |
+
* @{
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
//proto native int dMaterialClone(string target, string source, int material_index)
|
| 28 |
+
//proto native int dMaterialGetType(string source)
|
| 29 |
+
//proto native int dMaterialSetType(string source, int material_index)
|
| 30 |
+
|
| 31 |
+
class PhysicsGeomDef: Managed
|
| 32 |
+
{
|
| 33 |
+
string Name;
|
| 34 |
+
dGeom Geometry;
|
| 35 |
+
vector Frame[4] = {Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1), Vector(0, 0, 0)};
|
| 36 |
+
int ParentNode = -1;
|
| 37 |
+
string MaterialName;
|
| 38 |
+
int LayerMask; //<Bit mask of layers we are in
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
void PhysicsGeomDef(string name, dGeom geom, string materialName, int layerMask)
|
| 42 |
+
{
|
| 43 |
+
Name = name;
|
| 44 |
+
Geometry = geom;
|
| 45 |
+
MaterialName = materialName;
|
| 46 |
+
LayerMask = layerMask;
|
| 47 |
+
}
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
/*!
|
| 51 |
+
Creates RigidBody from custom made geometries. The geometries are deleted when rigid body is destroyed
|
| 52 |
+
\param geoms array of custom made geometries
|
| 53 |
+
@code
|
| 54 |
+
autoptr PhysicsGeomDef geoms[] = {PhysicsGeomDef("", dGeomCreateBox(size), "material/default", 0xffffffff)};
|
| 55 |
+
dBodyCreateStaticEx(this, geoms);
|
| 56 |
+
@endcode
|
| 57 |
+
*/
|
| 58 |
+
proto bool dBodyCreateStaticEx(notnull IEntity ent, PhysicsGeomDef geoms[]);
|
| 59 |
+
proto bool dBodyCreateGhostEx(notnull IEntity ent, PhysicsGeomDef geoms[]);
|
| 60 |
+
|
| 61 |
+
/*!
|
| 62 |
+
Creates RigidBody from custom made geometries. The geometries are deleted when rigid body is destroyed
|
| 63 |
+
\param centerOfMass Offset from object-pivot to center of mass
|
| 64 |
+
\param mass Body mass
|
| 65 |
+
\param geoms array of custom made geometries
|
| 66 |
+
@code
|
| 67 |
+
autoptr PhysicsGeomDef geoms[] = {PhysicsGeomDef("", dGeomCreateBox(size), "material/default", 0xffffffff)};
|
| 68 |
+
dBodyCreateDynamicEx(this, center, 1.0, geoms);
|
| 69 |
+
@endcode
|
| 70 |
+
*/
|
| 71 |
+
proto bool dBodyCreateDynamicEx(notnull IEntity ent, vector centerOfMass, float mass, PhysicsGeomDef geoms[]);
|
| 72 |
+
|
| 73 |
+
//!Destroys attached physics body
|
| 74 |
+
proto native void dBodyDestroy(notnull IEntity ent);
|
| 75 |
+
|
| 76 |
+
//!Has the entity attached physics body?
|
| 77 |
+
proto native bool dBodyIsSet(notnull IEntity ent);
|
| 78 |
+
|
| 79 |
+
proto native void dBodySetInteractionLayer(notnull IEntity ent, int mask);
|
| 80 |
+
proto native int dBodyGetInteractionLayer(notnull IEntity ent);
|
| 81 |
+
proto native void dBodySetGeomInteractionLayer(notnull IEntity ent, int index, int mask);
|
| 82 |
+
proto native int dBodyGetGeomInteractionLayer(notnull IEntity ent, int index);
|
| 83 |
+
|
| 84 |
+
//! state of a rigidbody
|
| 85 |
+
enum ActiveState
|
| 86 |
+
{
|
| 87 |
+
ACTIVE,
|
| 88 |
+
INACTIVE,
|
| 89 |
+
ALWAYS_ACTIVE
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
proto native void dBodyActive(notnull IEntity ent, ActiveState activeState);
|
| 93 |
+
proto native void dBodyDynamic(notnull IEntity ent, bool dynamic);
|
| 94 |
+
proto native bool dBodyIsDynamic(notnull IEntity ent);
|
| 95 |
+
|
| 96 |
+
proto native bool dBodyIsActive(notnull IEntity ent);
|
| 97 |
+
proto native bool dBodyEnableGravity(notnull IEntity ent, bool enable);
|
| 98 |
+
proto native void dBodySetDamping(notnull IEntity ent, float linearDamping, float angularDamping);
|
| 99 |
+
proto native void dBodySetSleepingTreshold(notnull IEntity body, float linearTreshold, float angularTreshold);
|
| 100 |
+
|
| 101 |
+
proto native bool dBodyIsSolid(notnull IEntity ent);
|
| 102 |
+
proto native void dBodySetSolid(notnull IEntity ent, bool solid);
|
| 103 |
+
|
| 104 |
+
/*!
|
| 105 |
+
If both maxMotion and shapeCastRadius is >=0 then the continuous collision detection is enabled.
|
| 106 |
+
If you want to disable it, use -1
|
| 107 |
+
\param maxMotion max motion threshold when sphere-cast is performed, to find time of impact. It should be
|
| 108 |
+
little bit less than size of the geometry to catch the situation when tunelling can happen
|
| 109 |
+
\param sphereCastRadius The radius of the largest possible sphere, that is completelly inside the body geometry.
|
| 110 |
+
*/
|
| 111 |
+
proto native void dBodyEnableCCD(notnull IEntity body, float maxMotion, float sphereCastRadius);
|
| 112 |
+
/*!
|
| 113 |
+
Sets scale factor for all impulses/velocities/forces. Default is <1,1,1>. Zero any axis if you want to do 2D physics
|
| 114 |
+
*/
|
| 115 |
+
proto native void dBodySetLinearFactor(notnull IEntity body, vector linearFactor);
|
| 116 |
+
|
| 117 |
+
//!returns center of mass offset
|
| 118 |
+
proto native vector dBodyGetCenterOfMass(notnull IEntity body);
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
\brief Returns linear velocity
|
| 122 |
+
\param ent \p IEntity entity which origin will be set
|
| 123 |
+
\param mat \p vector[4] matrix to be set
|
| 124 |
+
\return \p vector linear velocity
|
| 125 |
+
@code
|
| 126 |
+
Man player = g_Game.GetPlayer();
|
| 127 |
+
Print( GetVelocity(player) );
|
| 128 |
+
|
| 129 |
+
>> <0,0,0>
|
| 130 |
+
@endcode
|
| 131 |
+
*/
|
| 132 |
+
proto native vector GetVelocity(notnull IEntity ent);
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
\brief Sets linear velocity (for Rigid bodies)
|
| 136 |
+
\param ent \p entity which velocity will be set
|
| 137 |
+
\param vel \p velocity vector to be set
|
| 138 |
+
*/
|
| 139 |
+
proto native void SetVelocity(notnull IEntity ent, vector vel);
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
\brief Disables collisions between two entities
|
| 143 |
+
*/
|
| 144 |
+
proto native dBlock dBodyCollisionBlock(notnull IEntity ent1, notnull IEntity ent2);
|
| 145 |
+
proto native void dBodyRemoveBlock(notnull IEntity worldEntity, dBlock block);
|
| 146 |
+
|
| 147 |
+
proto native void dBodySetInertiaTensorV(notnull IEntity body, vector v);
|
| 148 |
+
proto native void dBodySetInertiaTensorM(notnull IEntity body, vector m[3]);
|
| 149 |
+
|
| 150 |
+
proto native float dBodyGetMass(notnull IEntity ent);
|
| 151 |
+
proto native void dBodySetMass(notnull IEntity body, float mass);
|
| 152 |
+
|
| 153 |
+
proto native void dBodyApplyTorqueImpulse(notnull IEntity ent, vector torqueImpulse);
|
| 154 |
+
proto native vector dBodyGetInvInertiaDiagLocal(notnull IEntity ent);
|
| 155 |
+
proto native float dBodyComputeImpulseDenominator(notnull IEntity ent, vector position, vector normal);
|
| 156 |
+
proto native float dBodyComputeAngularImpulseDenominator(notnull IEntity ent, vector axis);
|
| 157 |
+
proto native vector dBodyGetLocalInertia(notnull IEntity ent);
|
| 158 |
+
|
| 159 |
+
proto void dBodyGetInvInertiaTensorWorld(notnull IEntity body, out vector inertiaTensorWS[3]);
|
| 160 |
+
|
| 161 |
+
/**
|
| 162 |
+
\brief Applies impuls on a pos position in world coordinates
|
| 163 |
+
*/
|
| 164 |
+
proto void dBodyApplyImpulseAt(notnull IEntity body, vector impulse, vector pos);
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
\brief Applies impuls on a rigidbody (origin)
|
| 168 |
+
*/
|
| 169 |
+
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse);
|
| 170 |
+
|
| 171 |
+
/**
|
| 172 |
+
\brief Applies constant force on a rigidbody (origin)
|
| 173 |
+
*/
|
| 174 |
+
proto void dBodyApplyForce(notnull IEntity body, vector force);
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
\brief Applies constant force on a position
|
| 178 |
+
*/
|
| 179 |
+
proto void dBodyApplyForceAt(notnull IEntity body, vector pos, vector force);
|
| 180 |
+
|
| 181 |
+
proto native void dBodyApplyTorque(notnull IEntity body, vector torque);
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
\brief Gets angular velocity for a rigidbody
|
| 185 |
+
*/
|
| 186 |
+
proto vector dBodyGetAngularVelocity(notnull IEntity body);
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
\brief Changed an angular velocity
|
| 190 |
+
\param body \p Rigid body
|
| 191 |
+
\param angvel \p Angular velocity, rotation around x, y and z axis (not yaw/pitch/roll)
|
| 192 |
+
*/
|
| 193 |
+
proto void dBodySetAngularVelocity(notnull IEntity body, vector angvel);
|
| 194 |
+
|
| 195 |
+
/**
|
| 196 |
+
\brief Sets target transformation. If timeslice == dt (simulation step delta time), it will happen in next step, otherwise in time = timeslice
|
| 197 |
+
*/
|
| 198 |
+
proto native void dBodySetTargetMatrix(notnull IEntity body, vector matrix[4], float timeslice);
|
| 199 |
+
proto native float dBodyGetKineticEnergy(notnull IEntity body);
|
| 200 |
+
|
| 201 |
+
proto native vector dBodyGetVelocityAt(notnull IEntity body, vector globalpos);
|
| 202 |
+
//@}
|
| 203 |
+
|
| 204 |
+
/**
|
| 205 |
+
* \defgroup Geometry Geometry API definition
|
| 206 |
+
* @{
|
| 207 |
+
*/
|
| 208 |
+
|
| 209 |
+
//! Creates box geometry
|
| 210 |
+
proto native dGeom dGeomCreateBox(vector size);
|
| 211 |
+
|
| 212 |
+
//! Creates sphere geometry
|
| 213 |
+
proto native dGeom dGeomCreateSphere(float radius);
|
| 214 |
+
|
| 215 |
+
//! Creates capsule geometry
|
| 216 |
+
proto native dGeom dGeomCreateCapsule(float radius, vector extent);
|
| 217 |
+
|
| 218 |
+
//! Creates cylinder geometry
|
| 219 |
+
proto native dGeom dGeomCreateCylinder(float radius, vector extent);
|
| 220 |
+
|
| 221 |
+
//! Destroys geometry
|
| 222 |
+
proto native void dGeomDestroy(dGeom geom);
|
| 223 |
+
|
| 224 |
+
//proto native int dBodyAddGeom(notnull IEntity body, dGeom geom, vector frame[4], string material, int interactionLayer);
|
| 225 |
+
// find a geometry by its name and returns its index or -1 if the geometry wasn't found
|
| 226 |
+
proto native int dBodyGetGeom(notnull IEntity ent, string name);
|
| 227 |
+
// returns number of geometries of the entity
|
| 228 |
+
proto native int dBodyGetNumGeoms(notnull IEntity ent);
|
| 229 |
+
//@}
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
* \defgroup Constraints Constraints API definition
|
| 233 |
+
* @{
|
| 234 |
+
*/
|
| 235 |
+
|
| 236 |
+
proto native dJoint dJointCreateHinge(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector axis1, vector point2, vector axis2, bool block, float breakThreshold);
|
| 237 |
+
proto native dJoint dJointCreateHinge2(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
|
| 238 |
+
proto native dJoint dJointCreateSlider(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
|
| 239 |
+
proto native dJoint dJointCreateBallSocket(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector point2, bool block, float breakThreshold);
|
| 240 |
+
proto native dJoint dJointCreateFixed(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector point2, bool block, float breakThreshold);
|
| 241 |
+
proto native dJoint dJointCreateConeTwist(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
|
| 242 |
+
proto native dJoint dJointCreate6DOF(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
|
| 243 |
+
proto native dJoint dJointCreate6DOFSpring(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
|
| 244 |
+
proto native void dJointDestroy(dJoint joint);
|
| 245 |
+
|
| 246 |
+
//only hinge joint
|
| 247 |
+
proto native void dJointHingeSetLimits(dJoint joint, float low, float high, float softness, float biasFactor, float relaxationFactor);
|
| 248 |
+
proto native void dJointHingeSetAxis(dJoint joint, vector axis);
|
| 249 |
+
proto native void dJointHingeSetMotorTargetAngle(dJoint joint, float angle, float dt, float maxImpulse);
|
| 250 |
+
|
| 251 |
+
//only cone-twist joint
|
| 252 |
+
proto native void dJointConeTwistSetAngularOnly(dJoint joint, bool angularOnly);
|
| 253 |
+
// setLimit(), a few notes:
|
| 254 |
+
// _softness:
|
| 255 |
+
// 0->1, recommend ~0.8->1.
|
| 256 |
+
// describes % of limits where movement is free.
|
| 257 |
+
// beyond this softness %, the limit is gradually enforced until the "hard" (1.0) limit is reached.
|
| 258 |
+
// _biasFactor:
|
| 259 |
+
// 0->1?, recommend 0.3 +/-0.3 or so.
|
| 260 |
+
// strength with which constraint resists zeroth order (angular, not angular velocity) limit violation.
|
| 261 |
+
// __relaxationFactor:
|
| 262 |
+
// 0->1, recommend to stay near 1.
|
| 263 |
+
// the lower the value, the less the constraint will fight velocities which violate the angular limits.
|
| 264 |
+
proto native void dJointConeTwistSetLimit(dJoint joint, int limitIndex, float limitValue);
|
| 265 |
+
proto native void dJointConeTwistSetLimits(dJoint joint, float _swingSpan1, float _swingSpan2, float _twistSpan, float _softness, float _biasFactor, float _relaxationFactor);
|
| 266 |
+
|
| 267 |
+
//only 6DOF & 6DOFSpring.
|
| 268 |
+
/*!
|
| 269 |
+
- free means upper < lower,
|
| 270 |
+
- locked means upper == lower
|
| 271 |
+
- limited means upper > lower
|
| 272 |
+
- axis: first 3 are linear, next 3 are angular
|
| 273 |
+
*/
|
| 274 |
+
proto native void dJoint6DOFSetLinearLimits(dJoint joint, vector linearLower, vector linearUpper);
|
| 275 |
+
proto native void dJoint6DOFSetAngularLimits(dJoint joint, vector angularLower, vector angularUpper);
|
| 276 |
+
proto native void dJoint6DOFSetLimit(dJoint joint, int axis, float lo, float hi);
|
| 277 |
+
|
| 278 |
+
//when stiffness == -1 && damping == -1, spring is disabled
|
| 279 |
+
proto native void dJoint6DOFSpringSetSpring(dJoint joint, int axis, float stiffness, float damping);
|
| 280 |
+
|
| 281 |
+
//only slider joint
|
| 282 |
+
proto native void dJointSliderSetLinearLimits(dJoint joint, float lowerLimit, float upperLimit);
|
| 283 |
+
proto native void dJointSliderSetAngularLimits(dJoint joint, float lowerLimit, float upperLimit);
|
| 284 |
+
proto native void dJointSliderSetDirLinear(dJoint joint, float softness, float restitution, float damping);
|
| 285 |
+
proto native void dJointSliderSetDirAngular(dJoint joint, float softness, float restitution, float damping);
|
| 286 |
+
proto native void dJointSliderSetLimLinear(dJoint joint, float softness, float restitution, float damping);
|
| 287 |
+
proto native void dJointSliderSetLimAngular(dJoint joint, float softness, float restitution, float damping);
|
| 288 |
+
proto native void dJointSliderSetOrthoLinear(dJoint joint, float softness, float restitution, float damping);
|
| 289 |
+
proto native void dJointSliderSetOrthoAngular(dJoint joint, float softness, float restitution, float damping);
|
| 290 |
+
//if force == 0, motor is off
|
| 291 |
+
proto native void dJointSliderSetLinearMotor(dJoint joint, float velocity, float force);
|
| 292 |
+
proto native void dJointSliderSetAngularMotor(dJoint joint, float velocity, float force);
|
| 293 |
+
proto native float dJointSliderGetLinearPos(dJoint joint);
|
| 294 |
+
proto native float dJointSliderGetAngularPos(dJoint joint);
|
| 295 |
+
//@}
|
| 296 |
+
|
| 297 |
+
//-----------------------------------------------------------------
|
| 298 |
+
typedef int[] dMaterial;
|
| 299 |
+
|
| 300 |
+
class Contact
|
| 301 |
+
{
|
| 302 |
+
private void Contact() {}
|
| 303 |
+
private void ~Contact() {}
|
| 304 |
+
|
| 305 |
+
dMaterial Material1;
|
| 306 |
+
dMaterial Material2;
|
| 307 |
+
int MaterialIndex1;
|
| 308 |
+
int MaterialIndex2;
|
| 309 |
+
int Index1;
|
| 310 |
+
int Index2;
|
| 311 |
+
|
| 312 |
+
float PenetrationDepth;
|
| 313 |
+
|
| 314 |
+
float Impulse;
|
| 315 |
+
float RelativeNormalVelocityBefore;
|
| 316 |
+
float RelativeNormalVelocityAfter;
|
| 317 |
+
|
| 318 |
+
vector Normal;
|
| 319 |
+
vector Position;
|
| 320 |
+
vector RelativeVelocityBefore;
|
| 321 |
+
vector RelativeVelocityAfter;
|
| 322 |
+
|
| 323 |
+
proto native vector GetNormalImpulse();
|
| 324 |
+
proto native float GetRelativeVelocityBefore(vector vel);
|
| 325 |
+
proto native float GetRelativeVelocityAfter(vector vel);
|
| 326 |
+
};
|
| 327 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnProfiler.c
ADDED
|
@@ -0,0 +1,762 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* \defgroup Profiler Enforce Script profiling API
|
| 3 |
+
* \warning Only available on developer and diag builds
|
| 4 |
+
* @{
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
//! Flags that influences the behaviour of the EnProfiler API, applied through ...Flags functions
|
| 8 |
+
enum EnProfilerFlags
|
| 9 |
+
{
|
| 10 |
+
//! No flags
|
| 11 |
+
NONE,
|
| 12 |
+
//! When present, will reset [PD] on sorting, otherwise will accumulate on top of it
|
| 13 |
+
RESET,
|
| 14 |
+
//! Whether to profile child modules
|
| 15 |
+
RECURSIVE,
|
| 16 |
+
//! All flags enabled
|
| 17 |
+
ALL
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
//! Current base scripted modules
|
| 21 |
+
enum EnProfilerModule
|
| 22 |
+
{
|
| 23 |
+
//! 1_Core
|
| 24 |
+
CORE,
|
| 25 |
+
//! 2_GameLib
|
| 26 |
+
GAMELIB,
|
| 27 |
+
//! 3_Game
|
| 28 |
+
GAME,
|
| 29 |
+
//! 4_World
|
| 30 |
+
WORLD,
|
| 31 |
+
//! 5_Mission
|
| 32 |
+
MISSION,
|
| 33 |
+
//! init.c
|
| 34 |
+
MISSION_CUSTOM,
|
| 35 |
+
//! Can be returned from some methods
|
| 36 |
+
ERROR,
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
*\brief There are 3 states which can be toggled that governs whether script profiling is enabled or not
|
| 41 |
+
* \note The reason for this is because when it is enabled in debug menu, or through this API without 'immediate', it will only be enabled the next frame
|
| 42 |
+
*/
|
| 43 |
+
enum EnProfilerEnabledFlags
|
| 44 |
+
{
|
| 45 |
+
//! No flags, has value 0, so will count as false in conditions
|
| 46 |
+
NONE,
|
| 47 |
+
//! Script profiling UI is enabled in WIN+ALT debug menu, when this is true, it will override SCRP
|
| 48 |
+
DIAG,
|
| 49 |
+
//! It has been set to being always enabled through EnProfiler (SCRipt Profiler)
|
| 50 |
+
SCRP,
|
| 51 |
+
//! Whether profiling is currently truly happening (SCRipt Context)
|
| 52 |
+
SCRC,
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
typedef Param2<float, typename> EnProfilerTimeClassPair;
|
| 56 |
+
typedef Param2<int, typename> EnProfilerCountClassPair;
|
| 57 |
+
|
| 58 |
+
typedef Param2<float, string> EnProfilerTimeFuncPair;
|
| 59 |
+
typedef Param2<int, string> EnProfilerCountFuncPair;
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
*\brief Set of methods for accessing script profiling data
|
| 63 |
+
* \note To enable profiling on game launch, use parameter "-profile"
|
| 64 |
+
* \note Any mention of "[DM]" in this context will mean the WIN+ALT debug menu
|
| 65 |
+
* \note Any mention of "[CI]" in this context will mean Class Instances count
|
| 66 |
+
* \note Any mention of "[SR]" in this context will mean a Session Reset (See ResetSession for more information)
|
| 67 |
+
* \note Any mention of "[SD]" in this context will mean a Sorted Data, which is the data which supplies Get...Per... functions (the ones that give an array)
|
| 68 |
+
* \note Any mention of "[PD]" in this context will mean a Profiling Data, which is the time, count and allocation information which is stored on the class/func itself
|
| 69 |
+
* \warning [PD] is only calculated AFTER a function call is finished, there is no continuous timer running
|
| 70 |
+
* \note 'proto' methods are not tracked, but will contribute to a script methods total time
|
| 71 |
+
*/
|
| 72 |
+
class EnProfiler
|
| 73 |
+
{
|
| 74 |
+
/**
|
| 75 |
+
\brief Enable the gathering of script profiling data
|
| 76 |
+
\note DEFAULT: disabled (unless launched with "-profile", then it is default enabled)
|
| 77 |
+
\note This is separate from the one in [DM], so toggling it in [DM] will not affect this, and toggling it here will not affect [DM]
|
| 78 |
+
\note It will ignore the call if trying to set the current state, except when "immediate" is used
|
| 79 |
+
\param enable \p bool Whether to enable or disable, if it was previously not enabled, it will cause [SR]
|
| 80 |
+
\note Disabling does not cause [SR], so all data will stay intact
|
| 81 |
+
\param immediate \p bool When true will instantly start/stop profiling, otherwise it will apply it at the end of the frame (to have one stable point in time)
|
| 82 |
+
\warning Keep in mind that when using immediate, it will not be the data of the entire frame, which can skew data if not kept in mind
|
| 83 |
+
\param sessionReset \p bool When set to false, no [SR] will trigger, regardless of situation
|
| 84 |
+
|
| 85 |
+
@code
|
| 86 |
+
// Simple enable, will start profiling the next frame
|
| 87 |
+
// Will cause [SR] if !IsEnabledP() before this call
|
| 88 |
+
EnProfiler.Enable(true);
|
| 89 |
+
|
| 90 |
+
// Immediate enable, will start profiling immediately
|
| 91 |
+
// Will cause [SR] if !IsEnabledP() before this call
|
| 92 |
+
EnProfiler.Enable(true, true);
|
| 93 |
+
|
| 94 |
+
// Immediate disable, will stop profiling immediately
|
| 95 |
+
// Disabling will never cause [SR], preserving data
|
| 96 |
+
EnProfiler.Enable(false, true);
|
| 97 |
+
|
| 98 |
+
// Simple disable, will not profile the next frame (but still finish profiling the current one)
|
| 99 |
+
// Disabling will never cause [SR], preserving data
|
| 100 |
+
EnProfiler.Enable(false);
|
| 101 |
+
@endcode
|
| 102 |
+
*/
|
| 103 |
+
static proto void Enable(bool enable, bool immediate = false, bool sessionReset = true);
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
\brief Return if script profiling is enabled
|
| 107 |
+
\note Helper methods below
|
| 108 |
+
\return \p int Flags regarding the current state
|
| 109 |
+
|
| 110 |
+
@code
|
| 111 |
+
int isScriptProfilingEnabled = EnProfiler.IsEnabled();
|
| 112 |
+
@endcode
|
| 113 |
+
*/
|
| 114 |
+
static proto int IsEnabled();
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
\brief Return if script profiling is enabled through [DM]
|
| 118 |
+
\return \p bool Whether script profiling is enabled through [DM]
|
| 119 |
+
|
| 120 |
+
@code
|
| 121 |
+
bool isScriptProfilingDiagEnabled = EnProfiler.IsEnabledD();
|
| 122 |
+
@endcode
|
| 123 |
+
*/
|
| 124 |
+
static bool IsEnabledD()
|
| 125 |
+
{
|
| 126 |
+
return (IsEnabled() & EnProfilerEnabledFlags.DIAG);
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/**
|
| 130 |
+
\brief Return if script profiling is enabled through EnProfiler
|
| 131 |
+
\note When using "-profile" launch parameter, it will enable it through EnProfiler, so this will return true
|
| 132 |
+
\return \p bool Whether script profiling is enabled through script profiler
|
| 133 |
+
|
| 134 |
+
@code
|
| 135 |
+
bool isScriptProfilingToggleEnabled = EnProfiler.IsEnabledP();
|
| 136 |
+
@endcode
|
| 137 |
+
*/
|
| 138 |
+
static bool IsEnabledP()
|
| 139 |
+
{
|
| 140 |
+
return (IsEnabled() & EnProfilerEnabledFlags.SCRP);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/**
|
| 144 |
+
\brief Return if script profiling is actually turned on inside of the script context
|
| 145 |
+
\note When using "-profile" launch parameter, it will enable it through EnProfiler, so this will return true
|
| 146 |
+
\return \p bool Whether script is being profiled as of this moment
|
| 147 |
+
|
| 148 |
+
@code
|
| 149 |
+
bool isScriptProfilingEnabled = EnProfiler.IsEnabledC();
|
| 150 |
+
@endcode
|
| 151 |
+
*/
|
| 152 |
+
static bool IsEnabledC()
|
| 153 |
+
{
|
| 154 |
+
return (IsEnabled() & EnProfilerEnabledFlags.SCRC);
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
\brief The internal sorting that happens at the end of the frame (so it is NOT necessary to call this manually) to supply Get...Per... functions
|
| 159 |
+
\note This will clear the previous [SD] and sort the [PD] currently available at this moment
|
| 160 |
+
\note Flags apply to this
|
| 161 |
+
\warning Keep in mind that EnProfilerFlags.RESET will clear all [PD] after this is called
|
| 162 |
+
|
| 163 |
+
@code
|
| 164 |
+
// Sorting all the currently available [PD], populating [SD]
|
| 165 |
+
EnProfiler.SortData();
|
| 166 |
+
|
| 167 |
+
// If flag EnProfilerFlags.RESET is enabled, then this will return 0 now even if it has been called, as [PD] has been cleared
|
| 168 |
+
// This goes for any Get...Of... function (Except for [CI], the counter persists)
|
| 169 |
+
EnProfiler.GetTimeOfFunc("Sleep", EnProfilerTests, true);
|
| 170 |
+
@endcode
|
| 171 |
+
*/
|
| 172 |
+
static proto void SortData();
|
| 173 |
+
|
| 174 |
+
/**
|
| 175 |
+
\brief Perform [SR], clearing SessionFrame, ProfiledSessionFrames, [SD] and [PD] (except for [CI])
|
| 176 |
+
\note Can also be triggered by a variety of other functions in this API
|
| 177 |
+
\note When triggered by the other functions, it will call with fullReset = false
|
| 178 |
+
\param fullReset \p bool Whether to clear [PD] of all modules, when false it will only clear the [PD] according to current settings
|
| 179 |
+
|
| 180 |
+
@code
|
| 181 |
+
// Considering the settings: SetFlags(EnProfilerFlags.NONE) and SetModule(EnProfilerModule.GAME)
|
| 182 |
+
// The following call will only clear [PD] of 3_Game
|
| 183 |
+
EnProfiler.ResetSession();
|
| 184 |
+
|
| 185 |
+
// Considering the settings: SetFlags(EnProfilerFlags.RECURSIVE) and SetModule(EnProfilerModule.WORLD)
|
| 186 |
+
// The following call will clear [PD] of 3_Game, 4_World, 5_Mission and their children
|
| 187 |
+
EnProfiler.ResetSession();
|
| 188 |
+
|
| 189 |
+
// The following call resets [PD] across all modules
|
| 190 |
+
EnProfiler.ResetSession(true);
|
| 191 |
+
@endcode
|
| 192 |
+
*/
|
| 193 |
+
static proto void ResetSession(bool fullReset = false);
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
/** \name EnProfilerFlags
|
| 198 |
+
Set of functions to configure the currently active EnProfilerFlags
|
| 199 |
+
*/
|
| 200 |
+
//@{
|
| 201 |
+
|
| 202 |
+
/**
|
| 203 |
+
\brief Override the currently used set of EnProfilerFlags across the API
|
| 204 |
+
\note DEFAULT: EnProfilerFlags.ALL
|
| 205 |
+
\param flags \p int The combination of desired EnProfilerFlags to override the currently used set
|
| 206 |
+
\param sessionReset \p bool When set to false, no [SR] will trigger, regardless of situation
|
| 207 |
+
\return \p int The currently used set of EnProfilerFlags after the function call
|
| 208 |
+
|
| 209 |
+
@code
|
| 210 |
+
// No RESET flag, [PD] will be accumulated across frames
|
| 211 |
+
// No RECURSIVE flag, only the curently profiled module will be sorted
|
| 212 |
+
EnProfiler.SetFlags(EnProfilerFlags.NONE);
|
| 213 |
+
|
| 214 |
+
// RESET flag, [PD] will be reset after sorting
|
| 215 |
+
// No RECURSIVE flag, only the curently profiled module will be sorted
|
| 216 |
+
EnProfiler.SetFlags(EnProfilerFlags.RESET);
|
| 217 |
+
|
| 218 |
+
// RESET flag, [PD] will be reset after sorting
|
| 219 |
+
// RECURSIVE flag, all modules will be sorted
|
| 220 |
+
EnProfiler.SetFlags(EnProfilerFlags.ALL);
|
| 221 |
+
@endcode
|
| 222 |
+
*/
|
| 223 |
+
static proto int SetFlags(int flags, bool sessionReset = true);
|
| 224 |
+
|
| 225 |
+
/**
|
| 226 |
+
\brief Get the currently used flags across the API
|
| 227 |
+
\return \p int The currently used set of EnProfilerFlags
|
| 228 |
+
|
| 229 |
+
@code
|
| 230 |
+
int flags = EnProfiler.GetFlags();
|
| 231 |
+
|
| 232 |
+
if (flags & EnProfilerFlags.RECURSIVE)
|
| 233 |
+
{
|
| 234 |
+
Print("Currently profiling all modules.");
|
| 235 |
+
}
|
| 236 |
+
@endcode
|
| 237 |
+
*/
|
| 238 |
+
static proto int GetFlags();
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
\brief Check if the flags are set
|
| 242 |
+
\note Is effectively the same as the code displayed in GetFlags example, but without the bitwise operation
|
| 243 |
+
\param flags \p int The combination of EnProfilerFlags to check if present
|
| 244 |
+
\return \p bool If the flags are set
|
| 245 |
+
|
| 246 |
+
@code
|
| 247 |
+
if (EnProfiler.IsFlagsSet(EnProfilerFlags.ALL))
|
| 248 |
+
{
|
| 249 |
+
Print("Currently all flags are enabled.");
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
if (EnProfiler.IsFlagsSet(EnProfilerFlags.RECURSIVE))
|
| 253 |
+
{
|
| 254 |
+
Print("Currently profiling all modules.");
|
| 255 |
+
}
|
| 256 |
+
@endcode
|
| 257 |
+
*/
|
| 258 |
+
static proto bool IsFlagsSet(int flags);
|
| 259 |
+
|
| 260 |
+
/**
|
| 261 |
+
\brief Add flags to the currently used set of EnProfilerFlags across the API
|
| 262 |
+
\note Simply a helper method to quickly add EnProfilerFlags
|
| 263 |
+
\param flags \p int The combination of desired EnProfilerFlags to be added to the currently used set
|
| 264 |
+
\param sessionReset \p bool When set to false, no [SR] will trigger, regardless of situation
|
| 265 |
+
\return \p int The currently used set of EnProfilerFlags after the function call
|
| 266 |
+
|
| 267 |
+
@code
|
| 268 |
+
// In the case where the current set of EnProfilerFlags is EnProfilerFlags.RESET
|
| 269 |
+
EnProfiler.AddFlags(EnProfilerFlags.RECURSIVE);
|
| 270 |
+
// The resulting set of flags now will be EnProfilerFlags.RESET | EnProfilerFlags.RECURSIVE
|
| 271 |
+
// As the above is pretty much the same as the following
|
| 272 |
+
// EnProfiler.SetFlags(EnProfiler.GetFlags() | EnProfilerFlags.RECURSIVE);
|
| 273 |
+
// But a much cleaner and faster alternative (bitwise operations in script is ~10x slower than C++)
|
| 274 |
+
@endcode
|
| 275 |
+
*/
|
| 276 |
+
static proto int AddFlags(int flags, bool sessionReset = true);
|
| 277 |
+
|
| 278 |
+
/**
|
| 279 |
+
\brief Remove flags from the currently used set of EnProfilerFlags across the API
|
| 280 |
+
\note Simply a helper method to quickly remove EnProfilerFlags
|
| 281 |
+
\param flags \p int The combination of desired EnProfilerFlags to be added to the currently used set
|
| 282 |
+
\param sessionReset \p bool When set to false, no [SR] will trigger, regardless of situation
|
| 283 |
+
\return \p int The currently used set of EnProfilerFlags after the function call
|
| 284 |
+
|
| 285 |
+
@code
|
| 286 |
+
// In the case where the current set of EnProfilerFlags is EnProfilerFlags.RESET
|
| 287 |
+
EnProfiler.RemoveFlags(EnProfilerFlags.RESET);
|
| 288 |
+
// The resulting set of flags now will be EnProfilerFlags.NONE
|
| 289 |
+
// As the above is pretty much the same as the following
|
| 290 |
+
// EnProfiler.SetFlags(EnProfiler.GetFlags() & ~EnProfilerFlags.RECURSIVE);
|
| 291 |
+
// But a much cleaner and faster alternative (bitwise operations in script is ~10x slower than C++)
|
| 292 |
+
@endcode
|
| 293 |
+
*/
|
| 294 |
+
static proto int RemoveFlags(int flags, bool sessionReset = true);
|
| 295 |
+
|
| 296 |
+
/**
|
| 297 |
+
\brief Remove all flags from the currently used set of EnProfilerFlags across the API
|
| 298 |
+
\note Simply a helper method to quickly remove all EnProfilerFlags
|
| 299 |
+
\param sessionReset \p bool When set to false, no [SR] will trigger, regardless of situation
|
| 300 |
+
\return \p int The currently used set of EnProfilerFlags after the function call
|
| 301 |
+
|
| 302 |
+
@code
|
| 303 |
+
// In the case where the current set of EnProfilerFlags is EnProfilerFlags.RESET
|
| 304 |
+
EnProfiler.ClearFlags();
|
| 305 |
+
// The resulting set of flags now will be EnProfilerFlags.NONE
|
| 306 |
+
// As the above is pretty much the same as the following
|
| 307 |
+
// EnProfiler.SetFlags(EnProfilerFlags.NONE);
|
| 308 |
+
// But a much cleaner and implicit alternative
|
| 309 |
+
@endcode
|
| 310 |
+
*/
|
| 311 |
+
static proto int ClearFlags(bool sessionReset = true);
|
| 312 |
+
|
| 313 |
+
//@}
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
/** \name EnProfilerModule
|
| 318 |
+
Set of functions to configure the currently profiled EnProfilerModule
|
| 319 |
+
*/
|
| 320 |
+
//@{
|
| 321 |
+
|
| 322 |
+
/**
|
| 323 |
+
\brief Set the module to be profiled
|
| 324 |
+
\note DEFAULT: EnProfilerModule.CORE
|
| 325 |
+
\note When session reset is enabled, it will only reset the module which it is currently being set to, previous module data will be untouched
|
| 326 |
+
\param module \p EnProfilerModule The module to profile
|
| 327 |
+
\param sessionReset \p bool When set to false, no [SR] will trigger, regardless of situation
|
| 328 |
+
|
| 329 |
+
@code
|
| 330 |
+
EnProfiler.SetModule(EnProfilerModule.WORLD);
|
| 331 |
+
@endcode
|
| 332 |
+
*/
|
| 333 |
+
static proto void SetModule(EnProfilerModule module, bool sessionReset = true);
|
| 334 |
+
|
| 335 |
+
/**
|
| 336 |
+
\brief Get the currently profiled module
|
| 337 |
+
\return \p EnProfilerModule The currently profiled module
|
| 338 |
+
|
| 339 |
+
@code
|
| 340 |
+
EnProfilerModule module = EnProfiler.GetModule();
|
| 341 |
+
@endcode
|
| 342 |
+
*/
|
| 343 |
+
static proto EnProfilerModule GetModule();
|
| 344 |
+
|
| 345 |
+
/**
|
| 346 |
+
\brief Helper to convert EnProfilerModule to string
|
| 347 |
+
\param module \p EnProfilerModule The module to get the name of
|
| 348 |
+
\return \p string The name of the module
|
| 349 |
+
|
| 350 |
+
@code
|
| 351 |
+
string moduleName = EnProfiler.ModuleToName(EnProfilerModule.GAME);
|
| 352 |
+
@endcode
|
| 353 |
+
*/
|
| 354 |
+
static proto owned string ModuleToName(EnProfilerModule module);
|
| 355 |
+
|
| 356 |
+
/**
|
| 357 |
+
\brief Convert string to EnProfilerModule
|
| 358 |
+
\param moduleName \p string The name of the module
|
| 359 |
+
\param module \p EnProfilerModule The enum value of the module or EnProfilerModule.ERROR if not found
|
| 360 |
+
\return \p bool Whether the module was found
|
| 361 |
+
|
| 362 |
+
@code
|
| 363 |
+
// Get the name of the module of the current class
|
| 364 |
+
string nameOfCurrentModule = Type().GetModule();
|
| 365 |
+
EnProfilerModule module;
|
| 366 |
+
|
| 367 |
+
// Convert it to the enum value
|
| 368 |
+
if (EnProfiler.NameToModule(nameOfCurrentModule, module))
|
| 369 |
+
{
|
| 370 |
+
EnProfiler.SetModule(module);
|
| 371 |
+
}
|
| 372 |
+
else
|
| 373 |
+
{
|
| 374 |
+
ErrorEx(string.Format("Could not find EnProfilerModule: %1", nameOfCurrentModule));
|
| 375 |
+
}
|
| 376 |
+
@endcode
|
| 377 |
+
*/
|
| 378 |
+
static proto bool NameToModule(string moduleName, out EnProfilerModule module);
|
| 379 |
+
|
| 380 |
+
//@}
|
| 381 |
+
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
/**
|
| 385 |
+
\brief Set the interval for the [SD] to update
|
| 386 |
+
\note DEFAULT: 0
|
| 387 |
+
\note [DM] has the following values: {0, 5, 10, 20, 30, 50, 60, 120, 144}; When an interval not part of this list is set, [DM] will be set to "CUSTOM_INTERVAL"
|
| 388 |
+
\note Does not affect the gathering of [PD], this will happen continuously as the profiling is enabled
|
| 389 |
+
\note This also delays the [SR] caused by EnProfilerFlags.RESET
|
| 390 |
+
\param interval \p int Amount of frames to wait before [SD] is updated
|
| 391 |
+
\param sessionReset \p bool When set to false, no [SR] will trigger, regardless of situation
|
| 392 |
+
|
| 393 |
+
@code
|
| 394 |
+
// This will make it so that [SD] is updated every 60 frames
|
| 395 |
+
EnProfiler.SetInterval(60);
|
| 396 |
+
@endcode
|
| 397 |
+
*/
|
| 398 |
+
static proto void SetInterval(int interval, bool sessionReset = true);
|
| 399 |
+
|
| 400 |
+
/**
|
| 401 |
+
\brief Get the currently set interval
|
| 402 |
+
\return \p int The currently set interval
|
| 403 |
+
|
| 404 |
+
@code
|
| 405 |
+
int currentInterval = EnProfiler.GetInterval();
|
| 406 |
+
@endcode
|
| 407 |
+
*/
|
| 408 |
+
static proto int GetInterval();
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
|
| 412 |
+
/**
|
| 413 |
+
\brief Set the resolution of the fetched Time data
|
| 414 |
+
\note DEFAULT: 100000
|
| 415 |
+
\note [DM] has the following values: {100000, 1000000, 1, 10, 100, 1000, 10000}; These are the only values available, otherwise it will round up to one in the list
|
| 416 |
+
\note Does not affect any data itself, only the fetching and displaying of it (therefore, no [SR] is ever triggered by this method)
|
| 417 |
+
\param resolution \p int The nth resolution of a second
|
| 418 |
+
|
| 419 |
+
@code
|
| 420 |
+
// Have all time being reported in 1 second
|
| 421 |
+
EnProfiler.SetTimeResolution(1);
|
| 422 |
+
|
| 423 |
+
// Have all time being reported in 1000th of a second (ms)
|
| 424 |
+
EnProfiler.SetTimeResolution(1000);
|
| 425 |
+
@endcode
|
| 426 |
+
*/
|
| 427 |
+
static proto void SetTimeResolution(int resolution);
|
| 428 |
+
|
| 429 |
+
/**
|
| 430 |
+
\brief Get the currently set time resolution
|
| 431 |
+
\return \p int The currently set resolution
|
| 432 |
+
|
| 433 |
+
@code
|
| 434 |
+
int currentTimeResolution = EnProfiler.GetTimeResolution();
|
| 435 |
+
@endcode
|
| 436 |
+
*/
|
| 437 |
+
static proto int GetTimeResolution();
|
| 438 |
+
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
/**
|
| 442 |
+
\brief Enable/disable returning calculated averages
|
| 443 |
+
\note DEFAULT: false
|
| 444 |
+
\note When EnProfilerFlags.RESET flag is not present, it will divide by the session frame
|
| 445 |
+
\note When an interval is set, it will divide by the interval
|
| 446 |
+
\note Does not affect any data itself, only the fetching and displaying of it (therefore, no [SR] is ever triggered by this method)
|
| 447 |
+
\note [CI] will never be an average, it will always be the current count of the instance (allocations will be the value of how many times an instance is created)
|
| 448 |
+
\param enable \p bool Whether to enable or disable
|
| 449 |
+
|
| 450 |
+
@code
|
| 451 |
+
// For example, take the situation where we only reset every 60 frames
|
| 452 |
+
EnProfiler.AddFlags(EnProfilerFlags.RESET);
|
| 453 |
+
EnProfiler.SetInterval(60);
|
| 454 |
+
EnProfiler.EnableAverage(true);
|
| 455 |
+
|
| 456 |
+
// And a method is called once per frame, gathering the count of that function will be 1
|
| 457 |
+
// Or if a method is called twice per frame, gathering the count of that function will be 2
|
| 458 |
+
// Or if a method is 3 times every 3 frames, gathering the count of that function will be 1
|
| 459 |
+
// ...
|
| 460 |
+
// So you get the average amount of times the method is called per frame, out of the sample of 60 frames
|
| 461 |
+
@endcode
|
| 462 |
+
*/
|
| 463 |
+
static proto void EnableAverage(bool enable);
|
| 464 |
+
|
| 465 |
+
/**
|
| 466 |
+
\brief Check if returning of average data is enabled
|
| 467 |
+
\return \p bool Whether returning of average data is enabled
|
| 468 |
+
|
| 469 |
+
@code
|
| 470 |
+
bool isDataAverage = EnProfiler.IsAverage();
|
| 471 |
+
@endcode
|
| 472 |
+
*/
|
| 473 |
+
static proto bool IsAverage();
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
/**
|
| 478 |
+
\brief Print out [SD] to script log
|
| 479 |
+
|
| 480 |
+
@code
|
| 481 |
+
EnProfiler.Dump();
|
| 482 |
+
@endcode
|
| 483 |
+
*/
|
| 484 |
+
static proto void Dump();
|
| 485 |
+
|
| 486 |
+
|
| 487 |
+
|
| 488 |
+
/** \name Frame data
|
| 489 |
+
Set of functions to obtain information about frame counts
|
| 490 |
+
*/
|
| 491 |
+
//@{
|
| 492 |
+
|
| 493 |
+
/**
|
| 494 |
+
\brief Get the total amount of frames passed
|
| 495 |
+
\return \p int The total amount of frames passed
|
| 496 |
+
|
| 497 |
+
@code
|
| 498 |
+
int gameFrame = EnProfiler.GetGameFrame();
|
| 499 |
+
@endcode
|
| 500 |
+
*/
|
| 501 |
+
static proto int GetGameFrame();
|
| 502 |
+
|
| 503 |
+
/**
|
| 504 |
+
\brief Get the total amount of frames in this profiling session
|
| 505 |
+
\note This will only differ from GetProfiledSessionFrames when there is an Interval set
|
| 506 |
+
\return \p int The total amount of frames in this profiling session
|
| 507 |
+
|
| 508 |
+
@code
|
| 509 |
+
int sessionFrame = EnProfiler.GetSessionFrame();
|
| 510 |
+
@endcode
|
| 511 |
+
*/
|
| 512 |
+
static proto int GetSessionFrame();
|
| 513 |
+
|
| 514 |
+
/**
|
| 515 |
+
\brief Get the total amount of frames across all profiling session
|
| 516 |
+
\note This will only differ from GetProfiledFrames when there was an Interval set at some point
|
| 517 |
+
\return \p int The total amount of frames across all profiling session
|
| 518 |
+
|
| 519 |
+
@code
|
| 520 |
+
int totalFrames = EnProfiler.GetTotalFrames();
|
| 521 |
+
@endcode
|
| 522 |
+
*/
|
| 523 |
+
static proto int GetTotalFrames();
|
| 524 |
+
|
| 525 |
+
/**
|
| 526 |
+
\brief Get the total amount of frames profiled in this profiling session
|
| 527 |
+
\note This will only differ from GetSessionFrame when there is an Interval set
|
| 528 |
+
\return \p int The total amount of frames profiled in this profiling session
|
| 529 |
+
|
| 530 |
+
@code
|
| 531 |
+
int profiledSessionFrames = EnProfiler.GetProfiledSessionFrames();
|
| 532 |
+
@endcode
|
| 533 |
+
*/
|
| 534 |
+
static proto int GetProfiledSessionFrames();
|
| 535 |
+
|
| 536 |
+
/**
|
| 537 |
+
\brief Get the total amount of frames profiled across all profiling session
|
| 538 |
+
\note This will only differ from GetTotalFrames when there was an Interval set at some point
|
| 539 |
+
\return \p int The total amount of frames profiled across all profiling session
|
| 540 |
+
|
| 541 |
+
@code
|
| 542 |
+
int totalProfiledFrames = EnProfiler.GetProfiledFrames();
|
| 543 |
+
@endcode
|
| 544 |
+
*/
|
| 545 |
+
static proto int GetProfiledFrames();
|
| 546 |
+
|
| 547 |
+
//@}
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
|
| 551 |
+
/** \name Sorted data
|
| 552 |
+
Set of functions to obtain [SD]
|
| 553 |
+
\warning Data is appended to the array, it will not clear any previous data already existing in the array
|
| 554 |
+
\note Read SortData as well for more information regarding [SD]
|
| 555 |
+
*/
|
| 556 |
+
//@{
|
| 557 |
+
|
| 558 |
+
/**
|
| 559 |
+
\brief Obtain [SD] for Time Per Class
|
| 560 |
+
\param outArr \p array<ref EnProfilerTimeClassPair> Array sorted by time consumed by a class
|
| 561 |
+
\param count \p int The maximum amount of entries wanted
|
| 562 |
+
|
| 563 |
+
@code
|
| 564 |
+
// In this example the array will be filled with the 20 most time intensive classes
|
| 565 |
+
// If there are less than 20 classes which consumed time, it will output that number of classes instead
|
| 566 |
+
array<ref EnProfilerTimeClassPair> timePerClass = {};
|
| 567 |
+
EnProfiler.GetTimePerClass(timePerClass, 20);
|
| 568 |
+
|
| 569 |
+
// In this example the array will be filled with all classes sorted by time
|
| 570 |
+
array<ref EnProfilerTimeClassPair> timePerClass2 = {};
|
| 571 |
+
EnProfiler.GetTimePerClass(timePerClass2);
|
| 572 |
+
@endcode
|
| 573 |
+
*/
|
| 574 |
+
static proto void GetTimePerClass(notnull out array<ref EnProfilerTimeClassPair> outArr, int count = int.MAX);
|
| 575 |
+
|
| 576 |
+
/**
|
| 577 |
+
\brief Obtain [SD] for Allocations Per Class
|
| 578 |
+
\param outArr \p array<ref EnProfilerCountClassPair> Array sorted by number of allocations of a class
|
| 579 |
+
\param count \p int The maximum amount of entries wanted
|
| 580 |
+
|
| 581 |
+
@code
|
| 582 |
+
array<ref EnProfilerCountClassPair> allocPerClass = {};
|
| 583 |
+
EnProfiler.GetAllocationsPerClass(allocPerClass, 20);
|
| 584 |
+
@endcode
|
| 585 |
+
*/
|
| 586 |
+
static proto void GetAllocationsPerClass(notnull out array<ref EnProfilerCountClassPair> outArr, int count = int.MAX);
|
| 587 |
+
|
| 588 |
+
/**
|
| 589 |
+
\brief Obtain [SD] for Instances Per Class
|
| 590 |
+
\param outArr \p array<ref EnProfilerCountClassPair> Array sorted by number of instances of a class
|
| 591 |
+
\param count \p int The maximum amount of entries wanted
|
| 592 |
+
|
| 593 |
+
@code
|
| 594 |
+
array<ref EnProfilerCountClassPair> instancesPerClass = {};
|
| 595 |
+
EnProfiler.GetInstancesPerClass(instancesPerClass, 20);
|
| 596 |
+
@endcode
|
| 597 |
+
*/
|
| 598 |
+
static proto void GetInstancesPerClass(notnull out array<ref EnProfilerCountClassPair> outArr, int count = int.MAX);
|
| 599 |
+
|
| 600 |
+
/**
|
| 601 |
+
\brief Obtain [SD] for Time Per Function
|
| 602 |
+
\param outArr \p array<ref EnProfilerTimeFuncPair> Array sorted by time consumed by a function
|
| 603 |
+
\param count \p int The maximum amount of entries wanted
|
| 604 |
+
|
| 605 |
+
@code
|
| 606 |
+
array<ref EnProfilerTimeFuncPair> timePerFunc = {};
|
| 607 |
+
EnProfiler.GetTimePerFunc(timePerFunc, 20);
|
| 608 |
+
@endcode
|
| 609 |
+
*/
|
| 610 |
+
static proto void GetTimePerFunc(notnull out array<ref EnProfilerTimeFuncPair> outArr, int count = int.MAX);
|
| 611 |
+
|
| 612 |
+
/**
|
| 613 |
+
\brief Obtain [SD] for Count Per Function
|
| 614 |
+
\param outArr \p array<ref EnProfilerCountFuncPair> Array sorted by amount of times a function was called
|
| 615 |
+
\param count \p int The maximum amount of entries wanted
|
| 616 |
+
|
| 617 |
+
@code
|
| 618 |
+
array<ref EnProfilerCountFuncPair> countPerFunc = {};
|
| 619 |
+
EnProfiler.GetCountPerFunc(countPerFunc, 20);
|
| 620 |
+
@endcode
|
| 621 |
+
*/
|
| 622 |
+
static proto void GetCountPerFunc(notnull out array<ref EnProfilerCountFuncPair> outArr, int count = int.MAX);
|
| 623 |
+
|
| 624 |
+
//@}
|
| 625 |
+
|
| 626 |
+
|
| 627 |
+
|
| 628 |
+
/** \name Specific data
|
| 629 |
+
Set of functions to obtain specific data
|
| 630 |
+
*/
|
| 631 |
+
//@{
|
| 632 |
+
|
| 633 |
+
/**
|
| 634 |
+
\brief Obtain [SD] or [PD] regarding the time a specific class consumed
|
| 635 |
+
\param clss \p typename Typename of desired class
|
| 636 |
+
\param immediate \p bool When true, it will pull from [SD], when false it will pull from [PD]
|
| 637 |
+
\return \p float Time consumed by the specified class
|
| 638 |
+
|
| 639 |
+
@code
|
| 640 |
+
// Consider the class
|
| 641 |
+
EPTHelperClass clss = new EPTHelperClass();
|
| 642 |
+
|
| 643 |
+
// Some functions being called here...
|
| 644 |
+
|
| 645 |
+
// Gathering of data can be done through
|
| 646 |
+
float timeOfClass = EnProfiler.GetTimeOfClass(clss.Type(), true);
|
| 647 |
+
|
| 648 |
+
// Or when you have no variable/reference
|
| 649 |
+
float timeOfClass2 = EnProfiler.GetTimeOfClass(StaticGetType(EPTHelperClass), true);
|
| 650 |
+
@endcode
|
| 651 |
+
*/
|
| 652 |
+
static proto float GetTimeOfClass(typename clss, bool immediate = false);
|
| 653 |
+
|
| 654 |
+
/**
|
| 655 |
+
\brief Obtain [SD] or [PD] regarding the allocations of a specific class
|
| 656 |
+
\param clss \p typename Typename of desired class
|
| 657 |
+
\param immediate \p bool When true, it will pull from [SD], when false it will pull from [PD]
|
| 658 |
+
\return \p int Allocations of the specified class
|
| 659 |
+
|
| 660 |
+
@code
|
| 661 |
+
int allocationsOfClass = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
|
| 662 |
+
@endcode
|
| 663 |
+
*/
|
| 664 |
+
static proto int GetAllocationsOfClass(typename clss, bool immediate = false);
|
| 665 |
+
|
| 666 |
+
/**
|
| 667 |
+
\brief Obtain [SD] or [PD] regarding the [CI] of a specific class
|
| 668 |
+
\param clss \p typename Typename of desired class
|
| 669 |
+
\param immediate \p bool When true, it will pull from [SD], when false it will pull from [PD]
|
| 670 |
+
\return \p int [CI] of the specified class
|
| 671 |
+
|
| 672 |
+
@code
|
| 673 |
+
int instancesOfClass = EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass), true);
|
| 674 |
+
@endcode
|
| 675 |
+
*/
|
| 676 |
+
static proto int GetInstancesOfClass(typename clss, bool immediate = false);
|
| 677 |
+
|
| 678 |
+
/**
|
| 679 |
+
\brief Obtain [SD] or [PD] regarding the time consumed by a specific function
|
| 680 |
+
\param funct \p string Function name
|
| 681 |
+
\param clss \p typename Typename of class the function belongs to
|
| 682 |
+
\param immediate \p bool When true, it will pull from [SD], when false it will pull from [PD]
|
| 683 |
+
\return \p float Time consumed by the specified function or -1 when function was not found
|
| 684 |
+
|
| 685 |
+
@code
|
| 686 |
+
float timeOfFunc = EnProfiler.GetTimeOfFunc("StringFormat", StaticGetType(EnProfilerTests), true);
|
| 687 |
+
@endcode
|
| 688 |
+
*/
|
| 689 |
+
static proto float GetTimeOfFunc(string funct, typename clss, bool immediate = false);
|
| 690 |
+
|
| 691 |
+
/**
|
| 692 |
+
\brief Obtain [SD] or [PD] regarding the time consumed by a specific global function
|
| 693 |
+
\param funct \p string Function name
|
| 694 |
+
\param immediate \p bool When true, it will pull from [SD], when false it will pull from [PD]
|
| 695 |
+
\return \p float Time consumed by the specified function or -1 when function was not found
|
| 696 |
+
|
| 697 |
+
@code
|
| 698 |
+
float timeOfFunc = EnProfiler.GetTimeOfFuncG("ErrorEx", true);
|
| 699 |
+
@endcode
|
| 700 |
+
*/
|
| 701 |
+
static proto float GetTimeOfFuncG(string funct, bool immediate, bool immediate = false);
|
| 702 |
+
|
| 703 |
+
/**
|
| 704 |
+
\brief Obtain [SD] or [PD] regarding the amount of times a specific function was called
|
| 705 |
+
\param funct \p string Function name
|
| 706 |
+
\param clss \p typename Typename of class the function belongs to
|
| 707 |
+
\param immediate \p bool When true, it will pull from [SD], when false it will pull from [PD]
|
| 708 |
+
\return \p int Amount of calls to the specified function or -1 when function was not found
|
| 709 |
+
|
| 710 |
+
@code
|
| 711 |
+
int callCountOfFunc = EnProfiler.GetCountOfFunc("StringFormat", StaticGetType(EnProfilerTests), true);
|
| 712 |
+
@endcode
|
| 713 |
+
*/
|
| 714 |
+
static proto int GetCountOfFunc(string funct, typename clss, bool immediate = false);
|
| 715 |
+
|
| 716 |
+
/**
|
| 717 |
+
\brief Obtain [SD] or [PD] regarding the amount of times a specific function was called
|
| 718 |
+
\param funct \p string Function name
|
| 719 |
+
\param immediate \p bool When true, it will pull from [SD], when false it will pull from [PD]
|
| 720 |
+
\return \p int Amount of calls to the specified function or -1 when function was not found
|
| 721 |
+
|
| 722 |
+
@code
|
| 723 |
+
int callCountOfFunc = EnProfiler.GetCountOfFuncG("ErrorEx", true);
|
| 724 |
+
@endcode
|
| 725 |
+
*/
|
| 726 |
+
static proto int GetCountOfFuncG(string funct, bool immediate = false);
|
| 727 |
+
|
| 728 |
+
//@}
|
| 729 |
+
|
| 730 |
+
|
| 731 |
+
|
| 732 |
+
/** \name Misc
|
| 733 |
+
Set of helper functions
|
| 734 |
+
*/
|
| 735 |
+
//@{
|
| 736 |
+
|
| 737 |
+
/**
|
| 738 |
+
\brief Helper method to ascertain the profiler will record [PD] right after this call
|
| 739 |
+
\return \p bool Whether it was enabled before or not
|
| 740 |
+
|
| 741 |
+
@code
|
| 742 |
+
bool wasEnabled = EnProfiler.RequestImmediateData();
|
| 743 |
+
@endcode
|
| 744 |
+
*/
|
| 745 |
+
static bool RequestImmediateData()
|
| 746 |
+
{
|
| 747 |
+
// I only care if it is actually profiling right now, so C
|
| 748 |
+
bool wasEnabled = IsEnabledC();
|
| 749 |
+
|
| 750 |
+
if (!wasEnabled)
|
| 751 |
+
{
|
| 752 |
+
// I want the data, and I want it now, so immediate
|
| 753 |
+
Enable(true, true);
|
| 754 |
+
}
|
| 755 |
+
|
| 756 |
+
return wasEnabled;
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
//@}
|
| 760 |
+
};
|
| 761 |
+
|
| 762 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnScript.c
ADDED
|
@@ -0,0 +1,1003 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* \defgroup Enforce Enforce script essentials
|
| 3 |
+
* \note \p float ftime; The deltaTime since last frame
|
| 4 |
+
* \note \p float FLT_MAX; The maximum value for float
|
| 5 |
+
* \note \p float FLT_MIN; The minimum value for float
|
| 6 |
+
* @{
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
//! Super root of all classes in Enforce script
|
| 10 |
+
class Class
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
\brief Returns true when instance is of the type, or inherited one.
|
| 14 |
+
\param type Class type
|
| 15 |
+
\returns \p bool true when 'clType' is the same as 'type', or inherited one.
|
| 16 |
+
@code
|
| 17 |
+
if (inst && inst.IsInherited(Widget))
|
| 18 |
+
{
|
| 19 |
+
Print("inst is inherited from Widget class!");
|
| 20 |
+
}
|
| 21 |
+
@endcode
|
| 22 |
+
*/
|
| 23 |
+
proto native external bool IsInherited(typename type);
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
\brief Returns name of class-type
|
| 27 |
+
\param inst Class
|
| 28 |
+
\returns \p string class-type
|
| 29 |
+
@code
|
| 30 |
+
Man player = g_Game.GetPlayer();
|
| 31 |
+
string className = player.ClassName();
|
| 32 |
+
Print(className);
|
| 33 |
+
|
| 34 |
+
>> className = 'Man'
|
| 35 |
+
@endcode
|
| 36 |
+
*/
|
| 37 |
+
proto native owned external string ClassName();
|
| 38 |
+
|
| 39 |
+
string GetDebugName() { return ClassName(); }
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
\brief Returns typename of object's class
|
| 43 |
+
\returns \p typename class-type
|
| 44 |
+
@code
|
| 45 |
+
Man player = g_Game.GetPlayer();
|
| 46 |
+
typename type = player.Type();
|
| 47 |
+
Print(type.ToString());
|
| 48 |
+
|
| 49 |
+
>> 'Man'
|
| 50 |
+
@endcode
|
| 51 |
+
*/
|
| 52 |
+
proto native external typename Type();
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
\brief Returns typename of object's reference
|
| 56 |
+
\returns \p typename class-type
|
| 57 |
+
@code
|
| 58 |
+
EntityAI e;
|
| 59 |
+
Print(e.StaticType());
|
| 60 |
+
|
| 61 |
+
>> 'EntityAI'
|
| 62 |
+
@endcode
|
| 63 |
+
*/
|
| 64 |
+
proto external static typename StaticType();
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
\brief Returns typename of class even without a variable or instance
|
| 68 |
+
\returns \p typename class-type
|
| 69 |
+
@code
|
| 70 |
+
typename eAITypename = StaticGetType(EntityAI);
|
| 71 |
+
@endcode
|
| 72 |
+
*/
|
| 73 |
+
static typename StaticGetType(typename t)
|
| 74 |
+
{
|
| 75 |
+
return t;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
proto external string ToString();
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
\brief Try to safely down-cast base class to child class.
|
| 82 |
+
\returns down-casted 'from' pointer when cast is successfull (classes are related), or null if casting is invalid
|
| 83 |
+
@code
|
| 84 |
+
// assume that Man inheites from Object
|
| 85 |
+
Object obj = g_Game.GetPlayer();
|
| 86 |
+
Man player = Man.Cast(obj);
|
| 87 |
+
|
| 88 |
+
if (player)
|
| 89 |
+
{
|
| 90 |
+
// horay!
|
| 91 |
+
}
|
| 92 |
+
@endcode
|
| 93 |
+
*/
|
| 94 |
+
proto static Class Cast(Class from);
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
\brief Try to safely down-cast base class to child class.
|
| 98 |
+
\returns \p bool true when 'from' is not null and cast successfull, false when casting is not valid or 'from' is null
|
| 99 |
+
@code
|
| 100 |
+
// assume that Man inheites from Object
|
| 101 |
+
Object obj = g_Game.GetPlayer();
|
| 102 |
+
Man player;
|
| 103 |
+
|
| 104 |
+
if (Class.CastTo(player, obj))
|
| 105 |
+
{
|
| 106 |
+
// horay!
|
| 107 |
+
}
|
| 108 |
+
@endcode
|
| 109 |
+
*/
|
| 110 |
+
proto static bool CastTo(out Class to, Class from);
|
| 111 |
+
|
| 112 |
+
//! This function is for internal script usage
|
| 113 |
+
private proto static bool SafeCastType(Class type, out Class to, Class from);
|
| 114 |
+
};
|
| 115 |
+
|
| 116 |
+
//! TODO doc
|
| 117 |
+
class Managed
|
| 118 |
+
{
|
| 119 |
+
};
|
| 120 |
+
|
| 121 |
+
//! TODO doc
|
| 122 |
+
class NonSerialized
|
| 123 |
+
{
|
| 124 |
+
};
|
| 125 |
+
|
| 126 |
+
//! script representation for C++ RTTI types
|
| 127 |
+
typedef int[] TypeID;
|
| 128 |
+
|
| 129 |
+
//! Module containing compiled scripts.
|
| 130 |
+
class ScriptModule
|
| 131 |
+
{
|
| 132 |
+
private void ~ScriptModule();
|
| 133 |
+
|
| 134 |
+
/*!dynamic call of function
|
| 135 |
+
when inst == NULL, it's global function call, otherwise it's method of class
|
| 136 |
+
returns true, when success
|
| 137 |
+
The call creates new thread, so it's legal to use sleep/wait
|
| 138 |
+
*/
|
| 139 |
+
proto volatile int Call(Class inst, string function, void parm);
|
| 140 |
+
|
| 141 |
+
/*!dynamic call of function
|
| 142 |
+
when inst == NULL, it's global function call, otherwise it's method of class
|
| 143 |
+
returns true, when success
|
| 144 |
+
The call do not create new thread!!!!
|
| 145 |
+
*/
|
| 146 |
+
proto volatile int CallFunction(Class inst, string function, out void returnVal, void parm);
|
| 147 |
+
proto volatile int CallFunctionParams(Class inst, string function, out void returnVal, Class parms);
|
| 148 |
+
proto native void Release();
|
| 149 |
+
|
| 150 |
+
/**
|
| 151 |
+
\brief Do load script and create ScriptModule for it
|
| 152 |
+
\param parentModule Module
|
| 153 |
+
\param scriptFile Script path
|
| 154 |
+
\param listing ??
|
| 155 |
+
\returns \p ScriptModule Loaded scripted module
|
| 156 |
+
@code
|
| 157 |
+
???
|
| 158 |
+
@endcode
|
| 159 |
+
*/
|
| 160 |
+
static proto native ScriptModule LoadScript(ScriptModule parentModule, string scriptFile, bool listing);
|
| 161 |
+
};
|
| 162 |
+
|
| 163 |
+
//main script module (contains script.c and this file)
|
| 164 |
+
//ScriptModule g_Script;
|
| 165 |
+
|
| 166 |
+
class EnScript
|
| 167 |
+
{
|
| 168 |
+
private void EnScript() {}
|
| 169 |
+
private void ~EnScript() {}
|
| 170 |
+
|
| 171 |
+
/**
|
| 172 |
+
\brief Dynamic read of variable value by its name
|
| 173 |
+
\param inst When inst == NULL, it's for global variable, otherwise it's class member
|
| 174 |
+
\param index Is index when variable is array
|
| 175 |
+
\param[out] result Variable must be of the same type!
|
| 176 |
+
\returns \p int true when success
|
| 177 |
+
@code
|
| 178 |
+
float count = 0;
|
| 179 |
+
|
| 180 |
+
bool success = EnScript.GetClassVar(myClass, "m_Counter", 0, count);
|
| 181 |
+
Print(count);
|
| 182 |
+
Print(success);
|
| 183 |
+
|
| 184 |
+
>> count = 5
|
| 185 |
+
>> success = 1
|
| 186 |
+
@endcode
|
| 187 |
+
*/
|
| 188 |
+
static proto int GetClassVar(Class inst, string varname,int index, out void result);
|
| 189 |
+
|
| 190 |
+
/**
|
| 191 |
+
\brief Dynamic write to variable by its name
|
| 192 |
+
\param inst when inst == NULL, it's for global variable, otherwise it's class member
|
| 193 |
+
\param varname
|
| 194 |
+
\param index Is index when variable is array
|
| 195 |
+
\param input Input variable must be of the same type!
|
| 196 |
+
\returns \p int Returns true(1) when success
|
| 197 |
+
@code
|
| 198 |
+
Print(myClass.m_Counter);
|
| 199 |
+
|
| 200 |
+
>> m_Counter = 0
|
| 201 |
+
|
| 202 |
+
bool success = EnScript.SetClassVar(myClass, "m_Counter", 0, 5.0);
|
| 203 |
+
|
| 204 |
+
Print(myClass.m_Counter);
|
| 205 |
+
Print(success);
|
| 206 |
+
|
| 207 |
+
>> m_Counter = 5
|
| 208 |
+
>> success = 1
|
| 209 |
+
@endcode
|
| 210 |
+
*/
|
| 211 |
+
static proto int SetClassVar(Class inst, string varname, int index, void input);
|
| 212 |
+
|
| 213 |
+
/**
|
| 214 |
+
\brief Sets variable value by value in string
|
| 215 |
+
\param[out] var
|
| 216 |
+
\param value
|
| 217 |
+
\returns int
|
| 218 |
+
@code
|
| 219 |
+
???
|
| 220 |
+
@endcode
|
| 221 |
+
*/
|
| 222 |
+
static proto int SetVar(out void var, string value);
|
| 223 |
+
|
| 224 |
+
/**
|
| 225 |
+
\brief Debug tool for watching certain variable. Invokes debugger whenever is variable used
|
| 226 |
+
\param var Certain variable for watching
|
| 227 |
+
\param flags = 1 means it will break even when not modified
|
| 228 |
+
\return \p void
|
| 229 |
+
*/
|
| 230 |
+
static proto void Watch(void var, int flags);
|
| 231 |
+
};
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
/**
|
| 236 |
+
\brief Sorts static array of integers(ascendically) / floats(ascendically) / strings(alphabetically)
|
| 237 |
+
\param param_array \p array Array to sort
|
| 238 |
+
\param num \p int How many items will be sorted in array
|
| 239 |
+
\return \p void
|
| 240 |
+
@code
|
| 241 |
+
string arrStr[3] = {"Dog", "Car", "Apple"};
|
| 242 |
+
Sort(arrStr, 2)
|
| 243 |
+
for ( int x = 0; x < 3; x++ )
|
| 244 |
+
{
|
| 245 |
+
Print( arrStr[x] );
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
>> 'Car'
|
| 249 |
+
>> 'Dog'
|
| 250 |
+
>> 'Apple'
|
| 251 |
+
@endcode
|
| 252 |
+
*/
|
| 253 |
+
proto void Sort(void param_array[], int num);
|
| 254 |
+
proto void reversearray(void param_array);
|
| 255 |
+
proto void copyarray(void destArray, void srcArray);
|
| 256 |
+
|
| 257 |
+
/**
|
| 258 |
+
\brief Parses one token from input string. Result is put into token string, and type of token is returned. Input string is left-truncated by the resulting token length.
|
| 259 |
+
\param[in,out] input \p string String for parse\ Output is without founded token
|
| 260 |
+
\param[out] token \p string Founded string token
|
| 261 |
+
\return \p int Type of token
|
| 262 |
+
\verbatim
|
| 263 |
+
Token types:
|
| 264 |
+
0 - error, no token
|
| 265 |
+
1 - defined token (special characters etc. . / * )
|
| 266 |
+
2 - quoted string. Quotes are removed -> TODO
|
| 267 |
+
3 - alphabetic string
|
| 268 |
+
4 - number
|
| 269 |
+
5 - end of line -> TODO
|
| 270 |
+
\endverbatim
|
| 271 |
+
@code
|
| 272 |
+
string input = "Hello*World";
|
| 273 |
+
string token1;
|
| 274 |
+
string token2;
|
| 275 |
+
|
| 276 |
+
int result1 = ParseStringEx(input, token1);
|
| 277 |
+
int result2 = ParseStringEx(input, token2);
|
| 278 |
+
|
| 279 |
+
Print( String( "Token1 = '" + token1 + "' Type = " + result1.ToString() ) );
|
| 280 |
+
Print( String( "Token2 = '" + token2 + "' Type = " + result2.ToString() ) );
|
| 281 |
+
Print( input );
|
| 282 |
+
|
| 283 |
+
>> 'Toke1 = 'Hello' Type = 3'
|
| 284 |
+
>> 'Toke1 = '*' Type = 1'
|
| 285 |
+
@endcode
|
| 286 |
+
*/
|
| 287 |
+
proto int ParseStringEx(inout string input, string token);
|
| 288 |
+
|
| 289 |
+
/**
|
| 290 |
+
\brief Parses string into array of tokens returns number of tokens
|
| 291 |
+
\param input \p string String for parse
|
| 292 |
+
\param[out] tokens \p array[] Parsed string in array
|
| 293 |
+
\return \p int Number of tokens
|
| 294 |
+
@code
|
| 295 |
+
string token[2];
|
| 296 |
+
int result = ParseString("Hello World", token);
|
| 297 |
+
|
| 298 |
+
for( int i = 0; i < 2; i++ )
|
| 299 |
+
{
|
| 300 |
+
Print(token[i]);
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
>> 'Hello'
|
| 304 |
+
>> 'World'
|
| 305 |
+
@endcode
|
| 306 |
+
*/
|
| 307 |
+
proto int ParseString(string input, out string tokens[]);
|
| 308 |
+
|
| 309 |
+
/**
|
| 310 |
+
\brief Kills thread.
|
| 311 |
+
\param owner Can be NULL for global threads.
|
| 312 |
+
\param name Name of the first function on stack
|
| 313 |
+
\return \p int ???
|
| 314 |
+
@code
|
| 315 |
+
???
|
| 316 |
+
@endcode
|
| 317 |
+
*/
|
| 318 |
+
proto native int KillThread(Class owner, string name);
|
| 319 |
+
|
| 320 |
+
/**
|
| 321 |
+
Yiels execution to other threads and then it continues. Obsolete...
|
| 322 |
+
*/
|
| 323 |
+
proto volatile void Idle();
|
| 324 |
+
|
| 325 |
+
/**
|
| 326 |
+
\brief Debug function. Returns current function on stack of the thread
|
| 327 |
+
\param owner Can be NULL for global threads
|
| 328 |
+
\param name Name of the first function on stack
|
| 329 |
+
\param backtrace ???
|
| 330 |
+
\param linenumber ???
|
| 331 |
+
\return \p string ???
|
| 332 |
+
@code
|
| 333 |
+
???
|
| 334 |
+
@endcode
|
| 335 |
+
*/
|
| 336 |
+
proto owned string ThreadFunction(Class owner, string name, int backtrace, out int linenumber);
|
| 337 |
+
|
| 338 |
+
//!Helper for passing string expression to functions with void parameter. Example: Print(String("Hello " + var));
|
| 339 |
+
string String(string s)
|
| 340 |
+
{
|
| 341 |
+
return s;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
//!Helper for printing out string expression. Example: PrintString("Hello " + var);
|
| 345 |
+
void PrintString(string s)
|
| 346 |
+
{
|
| 347 |
+
Print(s);
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
class array<Class T>
|
| 351 |
+
{
|
| 352 |
+
/*!
|
| 353 |
+
O(1) complexity.
|
| 354 |
+
\return Number of elements of the array
|
| 355 |
+
*/
|
| 356 |
+
proto native int Count();
|
| 357 |
+
/*!
|
| 358 |
+
Destroyes all elements of the array and sets the Count to 0.
|
| 359 |
+
The underlying memory of the array is not freed.
|
| 360 |
+
*/
|
| 361 |
+
proto native void Clear();
|
| 362 |
+
/*!
|
| 363 |
+
Sets n-th element to given value.
|
| 364 |
+
*/
|
| 365 |
+
proto void Set(int n, T value);
|
| 366 |
+
/*!
|
| 367 |
+
Tries to find the first occurance of given value in the array.
|
| 368 |
+
\return Index of the first occurance of `value` if found, -1 otherwise
|
| 369 |
+
*/
|
| 370 |
+
proto int Find(T value);
|
| 371 |
+
/*!
|
| 372 |
+
\return Element at the index `n`
|
| 373 |
+
*/
|
| 374 |
+
|
| 375 |
+
proto T Get(int n);
|
| 376 |
+
/*!
|
| 377 |
+
Inserts element at the end of array.
|
| 378 |
+
\param value
|
| 379 |
+
Element to be inserted
|
| 380 |
+
\return
|
| 381 |
+
Position at which element is inserted
|
| 382 |
+
*/
|
| 383 |
+
proto int Insert(T value);
|
| 384 |
+
/*!
|
| 385 |
+
Inserts element at certain position and moves all elements behind
|
| 386 |
+
this position by one.
|
| 387 |
+
\param value
|
| 388 |
+
Element to be inserted
|
| 389 |
+
\param index
|
| 390 |
+
Position at which element is inserted. Must be less than Array::GetCardinality()
|
| 391 |
+
\return
|
| 392 |
+
Number of elements after insertion
|
| 393 |
+
*/
|
| 394 |
+
proto int InsertAt(T value, int index);
|
| 395 |
+
/**
|
| 396 |
+
\brief Inserts all elements from array
|
| 397 |
+
\param from \p array<T> array from which all elements will be added
|
| 398 |
+
@code
|
| 399 |
+
TStringArray arr1 = new TStringArray;
|
| 400 |
+
arr1.Insert( "Dave" );
|
| 401 |
+
arr1.Insert( "Mark" );
|
| 402 |
+
arr1.Insert( "John" );
|
| 403 |
+
|
| 404 |
+
TStringArray arr2 = new TStringArray;
|
| 405 |
+
arr2.Insert( "Sarah" );
|
| 406 |
+
arr2.Insert( "Cate" );
|
| 407 |
+
|
| 408 |
+
arr1.InsertAll(arr2);
|
| 409 |
+
|
| 410 |
+
for ( int i = 0; i < arr1.Count(); i++ )
|
| 411 |
+
{
|
| 412 |
+
Print( arr1.Get(i) );
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
delete arr2;
|
| 416 |
+
delete arr1;
|
| 417 |
+
|
| 418 |
+
>> "Dave"
|
| 419 |
+
>> "Mark"
|
| 420 |
+
>> "John"
|
| 421 |
+
>> "Sarah"
|
| 422 |
+
>> "Cate"
|
| 423 |
+
@endcode
|
| 424 |
+
*/
|
| 425 |
+
void InsertAll(notnull array<T> from)
|
| 426 |
+
{
|
| 427 |
+
for ( int i = 0; i < from.Count(); i++ )
|
| 428 |
+
{
|
| 429 |
+
Insert( from.Get(i) );
|
| 430 |
+
}
|
| 431 |
+
}
|
| 432 |
+
/*!
|
| 433 |
+
Removes element from array. The empty position is replaced by
|
| 434 |
+
last element, so removal is quite fast but do not retain order.
|
| 435 |
+
\param index
|
| 436 |
+
Index of element to be removed
|
| 437 |
+
*/
|
| 438 |
+
proto native void Remove(int index);
|
| 439 |
+
/*!
|
| 440 |
+
Removes element from array, but retain all elements ordered. It's
|
| 441 |
+
slower than Remove
|
| 442 |
+
\param index
|
| 443 |
+
Index of element to be removed
|
| 444 |
+
*/
|
| 445 |
+
proto native void RemoveOrdered(int index);
|
| 446 |
+
/*!
|
| 447 |
+
Resizes the array to given size.
|
| 448 |
+
If the `newSize` is lower than current Count overflowing objects are destroyed.
|
| 449 |
+
If the `newSize` is higher than current Count missing elements are initialized to zero (null).
|
| 450 |
+
*/
|
| 451 |
+
proto native void Resize(int newSize);
|
| 452 |
+
|
| 453 |
+
/*!
|
| 454 |
+
Resizes the array to given size internally.
|
| 455 |
+
Is used for optimization purposes when the approx. size is known beforehand
|
| 456 |
+
*/
|
| 457 |
+
proto native void Reserve(int newSize);
|
| 458 |
+
|
| 459 |
+
/*!
|
| 460 |
+
Swaps the contents of this and `other` arrays.
|
| 461 |
+
Does not involve copying of the elements.
|
| 462 |
+
*/
|
| 463 |
+
proto native void Swap(notnull array<T> other);
|
| 464 |
+
|
| 465 |
+
/*!
|
| 466 |
+
Sorts elements of array, depends on underlaying type.
|
| 467 |
+
*/
|
| 468 |
+
proto native void Sort(bool reverse = false);
|
| 469 |
+
/*!
|
| 470 |
+
Copes contents of `from` array to this array.
|
| 471 |
+
\return How many elements were copied
|
| 472 |
+
*/
|
| 473 |
+
|
| 474 |
+
proto int Copy(notnull array<T> from);
|
| 475 |
+
proto int Init(T init[]);
|
| 476 |
+
|
| 477 |
+
void RemoveItem(T value)
|
| 478 |
+
{
|
| 479 |
+
int remove_index = Find(value);
|
| 480 |
+
|
| 481 |
+
if ( remove_index >= 0 )
|
| 482 |
+
{
|
| 483 |
+
RemoveOrdered(remove_index);
|
| 484 |
+
}
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
void RemoveItemUnOrdered(T value)
|
| 488 |
+
{
|
| 489 |
+
int remove_index = Find(value);
|
| 490 |
+
|
| 491 |
+
if ( remove_index >= 0 )
|
| 492 |
+
{
|
| 493 |
+
Remove(remove_index);
|
| 494 |
+
}
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
bool IsValidIndex( int index )
|
| 498 |
+
{
|
| 499 |
+
return ( index > -1 && index < Count() );
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
/*
|
| 503 |
+
T GetChecked( int index )
|
| 504 |
+
{
|
| 505 |
+
if( IsValidIndex( index ) )
|
| 506 |
+
return Get( index );
|
| 507 |
+
else
|
| 508 |
+
return null;
|
| 509 |
+
}
|
| 510 |
+
*/
|
| 511 |
+
|
| 512 |
+
/**
|
| 513 |
+
\brief Print all elements in array
|
| 514 |
+
\return \p void
|
| 515 |
+
@code
|
| 516 |
+
my_array.Debug();
|
| 517 |
+
|
| 518 |
+
>> "One"
|
| 519 |
+
>> "Two"
|
| 520 |
+
>> "Three"
|
| 521 |
+
@endcode
|
| 522 |
+
*/
|
| 523 |
+
void Debug()
|
| 524 |
+
{
|
| 525 |
+
Print(string.Format("Array count: %1", Count()));
|
| 526 |
+
for (int i = 0; i < Count(); i++)
|
| 527 |
+
{
|
| 528 |
+
T item = Get(i);
|
| 529 |
+
Print(string.Format("[%1] => %2", i, item));
|
| 530 |
+
}
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
/**
|
| 534 |
+
\brief Returns a random index of array. If Count is 0, return index is -1 .
|
| 535 |
+
\return \p int Random index of array
|
| 536 |
+
@code
|
| 537 |
+
Print( my_array.GetRandomIndex() );
|
| 538 |
+
|
| 539 |
+
>> 2
|
| 540 |
+
@endcode
|
| 541 |
+
*/
|
| 542 |
+
int GetRandomIndex()
|
| 543 |
+
{
|
| 544 |
+
if ( Count() > 0 )
|
| 545 |
+
{
|
| 546 |
+
return Math.RandomInt(0, Count());
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
return -1;
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
/**
|
| 553 |
+
\brief Returns a random element of array
|
| 554 |
+
\return \p int Random element of array
|
| 555 |
+
@code
|
| 556 |
+
Print( my_array.GetRandomElement() );
|
| 557 |
+
|
| 558 |
+
>> "Three"
|
| 559 |
+
@endcode
|
| 560 |
+
*/
|
| 561 |
+
T GetRandomElement()
|
| 562 |
+
{
|
| 563 |
+
return Get(GetRandomIndex());
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
void SwapItems(int item1_index, int item2_index)
|
| 567 |
+
{
|
| 568 |
+
T item1 = Get(item1_index);
|
| 569 |
+
Set(item1_index, Get(item2_index));
|
| 570 |
+
Set(item2_index, item1);
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
void InsertArray(array<T> other)
|
| 574 |
+
{
|
| 575 |
+
for (int i = 0; i < other.Count(); i++)
|
| 576 |
+
{
|
| 577 |
+
T item = other.Get(i);
|
| 578 |
+
Insert(item);
|
| 579 |
+
}
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
void Invert()
|
| 583 |
+
{
|
| 584 |
+
int left = 0;
|
| 585 |
+
int right = Count() - 1;
|
| 586 |
+
if (right > 0)
|
| 587 |
+
{
|
| 588 |
+
while (left < right)
|
| 589 |
+
{
|
| 590 |
+
T temp = Get(left);
|
| 591 |
+
Set(left++, Get(right));
|
| 592 |
+
Set(right--, temp);
|
| 593 |
+
}
|
| 594 |
+
}
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
/**
|
| 598 |
+
\brief Returns a index in array moved by specific number
|
| 599 |
+
\return \p int Moved index in this array
|
| 600 |
+
@code
|
| 601 |
+
Print( "Count: "+ my_array.Count() );
|
| 602 |
+
Print( "Moved 1:"+ my_array.MoveIndex(2, 1) );
|
| 603 |
+
Print( "Moved 3:"+ my_array.MoveIndex(2, 2) );
|
| 604 |
+
|
| 605 |
+
>> "Count: 4"
|
| 606 |
+
>> "Moved index 2 by 1: 3";
|
| 607 |
+
>> "Moved index 2 by 2: 0";
|
| 608 |
+
@endcode
|
| 609 |
+
*/
|
| 610 |
+
int MoveIndex(int curr_index, int move_number)
|
| 611 |
+
{
|
| 612 |
+
int count = Count();
|
| 613 |
+
int new_index = curr_index;
|
| 614 |
+
|
| 615 |
+
if ( move_number > 0 )
|
| 616 |
+
{
|
| 617 |
+
new_index = curr_index + move_number;
|
| 618 |
+
}
|
| 619 |
+
|
| 620 |
+
if ( move_number < 0 )
|
| 621 |
+
{
|
| 622 |
+
new_index = curr_index - move_number;
|
| 623 |
+
|
| 624 |
+
if ( new_index < 0 )
|
| 625 |
+
{
|
| 626 |
+
if ( new_index <= -count )
|
| 627 |
+
{
|
| 628 |
+
new_index = (new_index % count);
|
| 629 |
+
}
|
| 630 |
+
|
| 631 |
+
new_index = new_index + count;
|
| 632 |
+
}
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
if ( new_index >= count )
|
| 636 |
+
{
|
| 637 |
+
new_index = (new_index % count);
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
// move_number is 0
|
| 641 |
+
return new_index;
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
void ShuffleArray()
|
| 645 |
+
{
|
| 646 |
+
for (int i = 0; i < Count(); i++)
|
| 647 |
+
{
|
| 648 |
+
SwapItems(i,GetRandomIndex());
|
| 649 |
+
}
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
/**
|
| 653 |
+
\brief Returns an index where 2 arrays start to differ from each other
|
| 654 |
+
\return \p int Index from where arrays differ
|
| 655 |
+
@code
|
| 656 |
+
array<int> arr1 = {0,1,2,3};
|
| 657 |
+
array<int> arr2 = {0,1,3,2};
|
| 658 |
+
int differsAt = arr1.DifferentAtPosition(arr2);
|
| 659 |
+
Print(differsAt);
|
| 660 |
+
|
| 661 |
+
>> 2
|
| 662 |
+
@endcode
|
| 663 |
+
*/
|
| 664 |
+
int DifferentAtPosition(array<T> pOtherArray)
|
| 665 |
+
{
|
| 666 |
+
if (Count() != pOtherArray.Count())
|
| 667 |
+
{
|
| 668 |
+
ErrorEx("arrays are not the same size");
|
| 669 |
+
return -1;
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
+
for (int i = 0; i < pOtherArray.Count(); ++i)
|
| 673 |
+
{
|
| 674 |
+
if (Get(i) != pOtherArray.Get(i))
|
| 675 |
+
{
|
| 676 |
+
return i;
|
| 677 |
+
}
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
return -1;
|
| 681 |
+
}
|
| 682 |
+
};
|
| 683 |
+
|
| 684 |
+
//force these to compile so we can link C++ methods to them
|
| 685 |
+
typedef array<string> TStringArray;
|
| 686 |
+
typedef array<float> TFloatArray;
|
| 687 |
+
typedef array<int> TIntArray;
|
| 688 |
+
typedef array<bool> TBoolArray;
|
| 689 |
+
typedef array<Class> TClassArray;
|
| 690 |
+
typedef array<Managed> TManagedArray;
|
| 691 |
+
typedef array<ref Managed> TManagedRefArray;
|
| 692 |
+
typedef array<vector> TVectorArray;
|
| 693 |
+
typedef array<typename> TTypenameArray;
|
| 694 |
+
|
| 695 |
+
class set<Class T>
|
| 696 |
+
{
|
| 697 |
+
proto native int Count();
|
| 698 |
+
proto native void Clear();
|
| 699 |
+
/*!
|
| 700 |
+
Tries to find the first occurance of given value in the set.
|
| 701 |
+
\return Index of the first occurance of `value` if found, -1 otherwise
|
| 702 |
+
*/
|
| 703 |
+
proto int Find(T value);
|
| 704 |
+
proto T Get(int n);
|
| 705 |
+
/*!
|
| 706 |
+
Inserts element at the end of array.
|
| 707 |
+
\param value
|
| 708 |
+
Element to be inserted
|
| 709 |
+
\return
|
| 710 |
+
Position at which element is inserted
|
| 711 |
+
*/
|
| 712 |
+
proto int Insert(T value);
|
| 713 |
+
/*!
|
| 714 |
+
Inserts element at certain position and moves all elements behind
|
| 715 |
+
this position by one.
|
| 716 |
+
\param value
|
| 717 |
+
Element to be inserted
|
| 718 |
+
\param index
|
| 719 |
+
Position at which element is inserted. Must be less than Array::GetCardinality()
|
| 720 |
+
\return
|
| 721 |
+
Number of elements after insertion
|
| 722 |
+
*/
|
| 723 |
+
proto int InsertAt(T value, int index);
|
| 724 |
+
/*!
|
| 725 |
+
Removes element from array, but retain all elements ordered.
|
| 726 |
+
\param index
|
| 727 |
+
Index of element to be removed
|
| 728 |
+
*/
|
| 729 |
+
proto native void Remove(int index);
|
| 730 |
+
proto int Copy(set<T> from);
|
| 731 |
+
proto native void Swap(set<T> other);
|
| 732 |
+
proto int Init(T init[]);
|
| 733 |
+
|
| 734 |
+
void InsertSet(set<T> other)
|
| 735 |
+
{
|
| 736 |
+
int count = other.Count();
|
| 737 |
+
for (int i = 0; i < count; i++)
|
| 738 |
+
{
|
| 739 |
+
T item = other[i];
|
| 740 |
+
Insert(item);
|
| 741 |
+
}
|
| 742 |
+
}
|
| 743 |
+
|
| 744 |
+
void RemoveItem(T value)
|
| 745 |
+
{
|
| 746 |
+
int remove_index = Find(value);
|
| 747 |
+
if (remove_index >= 0)
|
| 748 |
+
{
|
| 749 |
+
Remove(remove_index);
|
| 750 |
+
}
|
| 751 |
+
}
|
| 752 |
+
|
| 753 |
+
void RemoveItems(set<T> other)
|
| 754 |
+
{
|
| 755 |
+
int count = other.Count();
|
| 756 |
+
for (int i = 0; i < count; i++)
|
| 757 |
+
{
|
| 758 |
+
T item = other[i];
|
| 759 |
+
RemoveItem(item);
|
| 760 |
+
}
|
| 761 |
+
}
|
| 762 |
+
|
| 763 |
+
void Debug()
|
| 764 |
+
{
|
| 765 |
+
Print(string.Format("Set count: %1", Count()));
|
| 766 |
+
for (int i = 0; i < Count(); i++)
|
| 767 |
+
{
|
| 768 |
+
T item = Get(i);
|
| 769 |
+
Print(string.Format("[%1] => %2", i, item));
|
| 770 |
+
}
|
| 771 |
+
}
|
| 772 |
+
};
|
| 773 |
+
|
| 774 |
+
//force these to compile so we can link C++ methods to them
|
| 775 |
+
typedef set<string> TStringSet;
|
| 776 |
+
typedef set<float> TFloatSet;
|
| 777 |
+
typedef set<int> TIntSet;
|
| 778 |
+
typedef set<Class> TClassSet;
|
| 779 |
+
typedef set<Managed> TManagedSet;
|
| 780 |
+
typedef set<ref Managed> TManagedRefSet;
|
| 781 |
+
typedef set<typename> TTypenameSet;
|
| 782 |
+
|
| 783 |
+
typedef int MapIterator;
|
| 784 |
+
/**
|
| 785 |
+
\brief Associative array template
|
| 786 |
+
\n usage:
|
| 787 |
+
@code
|
| 788 |
+
autoptr map<string, int> prg_count = new map<string, int>;
|
| 789 |
+
|
| 790 |
+
// fill
|
| 791 |
+
project_locations.Insert("dayz", 10);
|
| 792 |
+
project_locations.Insert("arma", 20);
|
| 793 |
+
project_locations.Insert("tkom", 1);
|
| 794 |
+
|
| 795 |
+
Print(project_locations.Get("arma")); // prints '20'
|
| 796 |
+
|
| 797 |
+
@endcode
|
| 798 |
+
|
| 799 |
+
*/
|
| 800 |
+
class map<Class TKey,Class TValue>
|
| 801 |
+
{
|
| 802 |
+
/*!
|
| 803 |
+
\return
|
| 804 |
+
The number of elements in the hashmap.
|
| 805 |
+
*/
|
| 806 |
+
proto native int Count();
|
| 807 |
+
|
| 808 |
+
/*!
|
| 809 |
+
Clears the hash map.
|
| 810 |
+
*/
|
| 811 |
+
proto native void Clear();
|
| 812 |
+
/*!
|
| 813 |
+
Search for an element with the given key.
|
| 814 |
+
|
| 815 |
+
\param key
|
| 816 |
+
The key of the element to find
|
| 817 |
+
\return
|
| 818 |
+
Pointer to element data if found, NULL otherwise.
|
| 819 |
+
*/
|
| 820 |
+
proto TValue Get(TKey key);
|
| 821 |
+
/*!
|
| 822 |
+
Search for an element with the given key.
|
| 823 |
+
|
| 824 |
+
\param key
|
| 825 |
+
The key of the element to find
|
| 826 |
+
\param val
|
| 827 |
+
result is stored to val
|
| 828 |
+
\return
|
| 829 |
+
returns True if given key exist.
|
| 830 |
+
*/
|
| 831 |
+
proto bool Find(TKey key, out TValue val);
|
| 832 |
+
/*!
|
| 833 |
+
Return the i:th element in the map.
|
| 834 |
+
Note: This operation is O(n) complexity. Use with care!
|
| 835 |
+
|
| 836 |
+
\param index
|
| 837 |
+
The position of the element in the map
|
| 838 |
+
\return
|
| 839 |
+
The element on the i:th position
|
| 840 |
+
*/
|
| 841 |
+
proto TValue GetElement(int index);
|
| 842 |
+
/*!
|
| 843 |
+
Return the i:th element key in the map.
|
| 844 |
+
Note: This operation is O(n) complexity. Use with care!
|
| 845 |
+
|
| 846 |
+
\param i
|
| 847 |
+
The position of the element key in the map
|
| 848 |
+
\return
|
| 849 |
+
Return key of i-th element
|
| 850 |
+
*/
|
| 851 |
+
proto TKey GetKey(int i);
|
| 852 |
+
/*!
|
| 853 |
+
Sets value of element with given key. If element with key not exists, it is created.
|
| 854 |
+
Note: creating new elements is faster using Insert function.
|
| 855 |
+
*/
|
| 856 |
+
proto void Set(TKey key, TValue value);
|
| 857 |
+
/*!
|
| 858 |
+
Removes element with given key.
|
| 859 |
+
*/
|
| 860 |
+
proto void Remove(TKey key);
|
| 861 |
+
/*!
|
| 862 |
+
Removes i:th element with given key.
|
| 863 |
+
Note: This operation is O(n) complexity. Use with care!
|
| 864 |
+
\param i
|
| 865 |
+
The position of the element key in the map
|
| 866 |
+
*/
|
| 867 |
+
proto void RemoveElement(int i);
|
| 868 |
+
/*!
|
| 869 |
+
Returns if map contains element with given key.
|
| 870 |
+
*/
|
| 871 |
+
proto bool Contains(TKey key);
|
| 872 |
+
/*!
|
| 873 |
+
Insert new element into hash map.
|
| 874 |
+
|
| 875 |
+
\param key
|
| 876 |
+
Key of element to be inserted.
|
| 877 |
+
\param value
|
| 878 |
+
Data of element to be inserted.
|
| 879 |
+
*/
|
| 880 |
+
proto bool Insert(TKey key, TValue value);
|
| 881 |
+
proto int Copy(map<TKey,TValue> from);
|
| 882 |
+
|
| 883 |
+
array<TKey> GetKeyArray()
|
| 884 |
+
{
|
| 885 |
+
array<TKey> keys = new array<TKey>;
|
| 886 |
+
for (int i = 0; i < Count(); i++)
|
| 887 |
+
{
|
| 888 |
+
keys.Insert( GetKey( i ) );
|
| 889 |
+
}
|
| 890 |
+
return keys;
|
| 891 |
+
}
|
| 892 |
+
|
| 893 |
+
array<TValue> GetValueArray()
|
| 894 |
+
{
|
| 895 |
+
array<TValue> elements = new array<TValue>;
|
| 896 |
+
for (int i = 0; i < Count(); i++)
|
| 897 |
+
{
|
| 898 |
+
elements.Insert( GetElement( i ) );
|
| 899 |
+
}
|
| 900 |
+
return elements;
|
| 901 |
+
}
|
| 902 |
+
|
| 903 |
+
bool ReplaceKey(TKey old_key, TKey new_key)
|
| 904 |
+
{
|
| 905 |
+
if (Contains(old_key))
|
| 906 |
+
{
|
| 907 |
+
Set(new_key, Get(old_key));
|
| 908 |
+
Remove(old_key);
|
| 909 |
+
return true;
|
| 910 |
+
}
|
| 911 |
+
return false;
|
| 912 |
+
}
|
| 913 |
+
|
| 914 |
+
TKey GetKeyByValue(TValue value)
|
| 915 |
+
{
|
| 916 |
+
TKey ret;
|
| 917 |
+
for (int i = 0; i < Count(); i++)
|
| 918 |
+
{
|
| 919 |
+
if (GetElement(i) == value)
|
| 920 |
+
{
|
| 921 |
+
ret = GetKey(i);
|
| 922 |
+
break;
|
| 923 |
+
}
|
| 924 |
+
}
|
| 925 |
+
|
| 926 |
+
return ret;
|
| 927 |
+
}
|
| 928 |
+
|
| 929 |
+
bool GetKeyByValueChecked(TValue value, out TKey key)
|
| 930 |
+
{
|
| 931 |
+
for (int i = 0; i < Count(); i++)
|
| 932 |
+
{
|
| 933 |
+
if (GetElement(i) == value)
|
| 934 |
+
{
|
| 935 |
+
key = GetKey(i);
|
| 936 |
+
return true;
|
| 937 |
+
}
|
| 938 |
+
}
|
| 939 |
+
return false;
|
| 940 |
+
}
|
| 941 |
+
|
| 942 |
+
proto native MapIterator Begin();
|
| 943 |
+
proto native MapIterator End();
|
| 944 |
+
proto native MapIterator Next(MapIterator it);
|
| 945 |
+
proto TKey GetIteratorKey(MapIterator it);
|
| 946 |
+
proto TValue GetIteratorElement(MapIterator it);
|
| 947 |
+
};
|
| 948 |
+
|
| 949 |
+
typedef map<int, float> TIntFloatMap;
|
| 950 |
+
typedef map<int, int> TIntIntMap;
|
| 951 |
+
typedef map<int, string> TIntStringMap;
|
| 952 |
+
typedef map<int, Class> TIntClassMap;
|
| 953 |
+
typedef map<int, Managed> TIntManagedMap;
|
| 954 |
+
typedef map<int, ref Managed> TIntManagedRefMap;
|
| 955 |
+
typedef map<int, typename> TIntTypenameMap;
|
| 956 |
+
typedef map<int, vector> TIntVectorMap;
|
| 957 |
+
|
| 958 |
+
typedef map<string, float> TStringFloatMap;
|
| 959 |
+
typedef map<string, int> TStringIntMap;
|
| 960 |
+
typedef map<string, string> TStringStringMap;
|
| 961 |
+
typedef map<string, Class> TStringClassMap;
|
| 962 |
+
typedef map<string, Managed> TStringManagedMap;
|
| 963 |
+
typedef map<string, ref Managed> TStringManagedRefMap;
|
| 964 |
+
typedef map<string, typename> TStringTypenameMap;
|
| 965 |
+
typedef map<string, vector> TStringVectorMap;
|
| 966 |
+
|
| 967 |
+
typedef map<Class, float> TClassFloatMap;
|
| 968 |
+
typedef map<Class, int> TClassIntMap;
|
| 969 |
+
typedef map<Class, string> TClassStringMap;
|
| 970 |
+
typedef map<Class, Class> TClassClassMap;
|
| 971 |
+
typedef map<Class, Managed> TClassManagedMap;
|
| 972 |
+
typedef map<Class, ref Managed> TClassManagedRefMap;
|
| 973 |
+
typedef map<Class, typename> TClassTypenameMap;
|
| 974 |
+
typedef map<Class, vector> TClassVectorMap;
|
| 975 |
+
|
| 976 |
+
typedef map<typename, float> TTypeNameFloatMap;
|
| 977 |
+
typedef map<typename, int> TTypeNameIntMap;
|
| 978 |
+
typedef map<typename, string> TTypeNameStringMap;
|
| 979 |
+
typedef map<typename, Class> TTypeNameClassMap;
|
| 980 |
+
typedef map<typename, Managed> TTypeNameManagedMap;
|
| 981 |
+
typedef map<typename, ref Managed> TTypeNameManagedRefMap;
|
| 982 |
+
typedef map<typename, typename> TTypeNameTypenameMap;
|
| 983 |
+
typedef map<typename, vector> TTypeNameVectorMap;
|
| 984 |
+
|
| 985 |
+
typedef map<Managed, float> TManagedFloatMap;
|
| 986 |
+
typedef map<Managed, int> TManagedIntMap;
|
| 987 |
+
typedef map<Managed, string> TManagedStringMap;
|
| 988 |
+
typedef map<Managed, Class> TManagedClassMap;
|
| 989 |
+
typedef map<Managed, Managed> TManagedManagedMap;
|
| 990 |
+
typedef map<Managed, ref Managed> TManagedManagedRefMap;
|
| 991 |
+
typedef map<Managed, typename> TManagedTypenameMap;
|
| 992 |
+
typedef map<Managed, vector> TManagedVectorMap;
|
| 993 |
+
|
| 994 |
+
typedef map<ref Managed, float> TManagedRefFloatMap;
|
| 995 |
+
typedef map<ref Managed, int> TManagedRefIntMap;
|
| 996 |
+
typedef map<ref Managed, string> TManagedRefStringMap;
|
| 997 |
+
typedef map<ref Managed, Class> TManagedRefClassMap;
|
| 998 |
+
typedef map<ref Managed, Managed> TManagedRefManagedMap;
|
| 999 |
+
typedef map<ref Managed, ref Managed> TManagedRefManagedRefMap;
|
| 1000 |
+
typedef map<ref Managed, typename> TManagedRefTypenameMap;
|
| 1001 |
+
typedef map<ref Managed, vector> TManagedRefVectorMap;
|
| 1002 |
+
|
| 1003 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnString.c
ADDED
|
@@ -0,0 +1,529 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* \defgroup Strings Strings
|
| 3 |
+
* @{
|
| 4 |
+
*/
|
| 5 |
+
class string
|
| 6 |
+
{
|
| 7 |
+
static const string Empty;
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
\brief Converts string to integer
|
| 11 |
+
\return \p int - Converted \p string.
|
| 12 |
+
@code
|
| 13 |
+
string str = "56";
|
| 14 |
+
int i = str.ToInt();
|
| 15 |
+
Print(i);
|
| 16 |
+
|
| 17 |
+
>> i = 56
|
| 18 |
+
@endcode
|
| 19 |
+
*/
|
| 20 |
+
proto native int ToInt();
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
\brief Converts string to integer
|
| 24 |
+
\return \p int - Converted \p string.
|
| 25 |
+
@code
|
| 26 |
+
string str = "0xFF";
|
| 27 |
+
int i = str.HexToInt();
|
| 28 |
+
Print(i);
|
| 29 |
+
|
| 30 |
+
>> i = 255
|
| 31 |
+
@endcode
|
| 32 |
+
*/
|
| 33 |
+
proto native int HexToInt();
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
\brief Converts string to float
|
| 37 |
+
\return \p float - Converted \p string \p in float.
|
| 38 |
+
@code
|
| 39 |
+
string str = "56.6";
|
| 40 |
+
float f = str.ToFloat();
|
| 41 |
+
Print(f);
|
| 42 |
+
|
| 43 |
+
>> f = 56.6
|
| 44 |
+
@endcode
|
| 45 |
+
*/
|
| 46 |
+
proto native float ToFloat();
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
\brief Returns a vector from a string
|
| 50 |
+
\return \p vector Converted s as vector
|
| 51 |
+
@code
|
| 52 |
+
string str = "1 0 1";
|
| 53 |
+
vector v = str.ToVector();
|
| 54 |
+
Print(v);
|
| 55 |
+
|
| 56 |
+
>> v = <1,0,1>
|
| 57 |
+
@endcode
|
| 58 |
+
*/
|
| 59 |
+
proto vector ToVector();
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
\brief Convert beautified string into a vector
|
| 64 |
+
\param vec \p beautified string
|
| 65 |
+
\return \p vector resulting vector
|
| 66 |
+
*/
|
| 67 |
+
vector BeautifiedToVector()
|
| 68 |
+
{
|
| 69 |
+
string copy = value;
|
| 70 |
+
copy.Replace("<", "");
|
| 71 |
+
copy.Replace(">", "");
|
| 72 |
+
copy.Replace(",", " ");
|
| 73 |
+
return copy.ToVector();
|
| 74 |
+
}
|
| 75 |
+
/**
|
| 76 |
+
\brief Converts string's first character to ASCII code
|
| 77 |
+
\param str String for convert to ASCII code
|
| 78 |
+
\return \p ascii code \p int.
|
| 79 |
+
@code
|
| 80 |
+
int ascii = "M".ToAscii();
|
| 81 |
+
Print(ascii);
|
| 82 |
+
|
| 83 |
+
>> ascii = 77
|
| 84 |
+
@endcode
|
| 85 |
+
*/
|
| 86 |
+
proto native int ToAscii();
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
\brief Returns internal type representation. Can be used in runtime, or cached in variables and used for faster inheritance checking
|
| 90 |
+
\returns \p typename Type of class
|
| 91 |
+
@code
|
| 92 |
+
???
|
| 93 |
+
@endcode
|
| 94 |
+
*/
|
| 95 |
+
proto native typename ToType();
|
| 96 |
+
|
| 97 |
+
//! Return string representation of variable
|
| 98 |
+
static proto string ToString(void var, bool type = false, bool name = false, bool quotes = true);
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
\brief Substring of 'str' from 'start' position 'len' number of characters
|
| 102 |
+
\param start Position in \p str
|
| 103 |
+
\param len Count of characters
|
| 104 |
+
\return \p string - Substring of \p str
|
| 105 |
+
@code
|
| 106 |
+
string str = "Hello World";
|
| 107 |
+
string strSub = str.Substring(2, 5);
|
| 108 |
+
Print(strSub);
|
| 109 |
+
|
| 110 |
+
>> strSub = llo W
|
| 111 |
+
@endcode
|
| 112 |
+
*/
|
| 113 |
+
proto string Substring(int start, int len);
|
| 114 |
+
|
| 115 |
+
//! Inverted SubString. This deletes everything in between position_start and position_end.
|
| 116 |
+
string SubstringInverted( string string_to_split, int position_start, int position_end )
|
| 117 |
+
{
|
| 118 |
+
string first_half = string_to_split.Substring(0, position_start);
|
| 119 |
+
string second_half = string_to_split.Substring( position_end, string_to_split.Length() - position_end );
|
| 120 |
+
string result = first_half + second_half;
|
| 121 |
+
return result;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
\brief Substring of 'str' from 'startChar' position 'len' number of characters for UTF8 strings with multibyte chars
|
| 126 |
+
\param startChar Position in \p str.
|
| 127 |
+
\param len Count of characters
|
| 128 |
+
\return \p string - Substring of \p str with \p startChar character and \p len characters
|
| 129 |
+
@code
|
| 130 |
+
string str = "こんにちは世界";
|
| 131 |
+
string strSub = str.SubstringUtf8(2, 4);
|
| 132 |
+
Print(strSub);
|
| 133 |
+
|
| 134 |
+
>> strSub = にちは世
|
| 135 |
+
@endcode
|
| 136 |
+
*/
|
| 137 |
+
proto string SubstringUtf8(int startChar, int len);
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
\brief Replace all occurrances of 'sample' in 'str' by 'replace'
|
| 141 |
+
\param sample string to search in \p str
|
| 142 |
+
\param replace string which replace \p sample in \p str
|
| 143 |
+
\return \p int - number of occurrances of 'sample' in 'str'
|
| 144 |
+
@code
|
| 145 |
+
string test = "If the length of the C string in source is less than num, only the content up to the terminating null-character is copied.";
|
| 146 |
+
Print(test);
|
| 147 |
+
int count = test.Replace("the", "*");
|
| 148 |
+
Print(count);
|
| 149 |
+
Print(test);
|
| 150 |
+
|
| 151 |
+
>> string test = 'If the length of the C string in source is less than num, only the content up to the terminating null-character is copied.';
|
| 152 |
+
>> int count = 4
|
| 153 |
+
>> string test = 'If * length of * C string in source is less than num, only * content up to * terminating null-character is copied.'
|
| 154 |
+
@endcode
|
| 155 |
+
*/
|
| 156 |
+
proto int Replace(string sample, string replace);
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
\brief Changes string to lowercase. Returns length
|
| 160 |
+
\return \p int - Length of changed string
|
| 161 |
+
@code
|
| 162 |
+
string str = "Hello World";
|
| 163 |
+
int i = str.ToLower();
|
| 164 |
+
Print(str);
|
| 165 |
+
Print(i);
|
| 166 |
+
|
| 167 |
+
>> str = hello world
|
| 168 |
+
>> i = 11
|
| 169 |
+
@endcode
|
| 170 |
+
*/
|
| 171 |
+
proto int ToLower();
|
| 172 |
+
|
| 173 |
+
/**
|
| 174 |
+
\brief Changes string to uppercase. Returns length
|
| 175 |
+
\return \p int - Length of changed string
|
| 176 |
+
@code
|
| 177 |
+
string str = "Hello World";
|
| 178 |
+
int i = str.ToUpper();
|
| 179 |
+
Print(str);
|
| 180 |
+
Print(i);
|
| 181 |
+
|
| 182 |
+
>> str = HELLO WORLD
|
| 183 |
+
>> i = 11
|
| 184 |
+
@endcode
|
| 185 |
+
*/
|
| 186 |
+
proto int ToUpper();
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
\brief Returns length of string
|
| 190 |
+
\return \p int - Length of string
|
| 191 |
+
@code
|
| 192 |
+
string str = "Hello World";
|
| 193 |
+
int i = str.Length();
|
| 194 |
+
Print(i);
|
| 195 |
+
|
| 196 |
+
>> i = 11
|
| 197 |
+
@endcode
|
| 198 |
+
*/
|
| 199 |
+
proto native int Length();
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
\brief Returns number of characters in UTF8 string
|
| 203 |
+
\return \p int - Number of characters in UTF8 string
|
| 204 |
+
@code
|
| 205 |
+
string str = "こんにちは世界";
|
| 206 |
+
int i = str.LengthUtf8();
|
| 207 |
+
Print(i);
|
| 208 |
+
|
| 209 |
+
>> i = 7
|
| 210 |
+
@endcode
|
| 211 |
+
*/
|
| 212 |
+
proto native int LengthUtf8();
|
| 213 |
+
|
| 214 |
+
/**
|
| 215 |
+
\brief Returns hash of string
|
| 216 |
+
\return \p int - Hash of string
|
| 217 |
+
@code
|
| 218 |
+
string str = "Hello World";
|
| 219 |
+
int hash = str.Hash();
|
| 220 |
+
Print(hash);
|
| 221 |
+
@endcode
|
| 222 |
+
*/
|
| 223 |
+
proto native int Hash();
|
| 224 |
+
|
| 225 |
+
/**
|
| 226 |
+
\brief Finds 'sample' in 'str'. Returns -1 when not found
|
| 227 |
+
\param sample \p string Finding string
|
| 228 |
+
\return \p int - Returns position where \p sample starts, or -1 when \p sample not found
|
| 229 |
+
@code
|
| 230 |
+
string str = "Hello World";
|
| 231 |
+
Print( str.IndexOf( "H" ) );
|
| 232 |
+
Print( str.IndexOf( "W" ) );
|
| 233 |
+
Print( str.IndexOf( "Q" ) );
|
| 234 |
+
|
| 235 |
+
>> 0
|
| 236 |
+
>> 6
|
| 237 |
+
>> -1
|
| 238 |
+
@endcode
|
| 239 |
+
*/
|
| 240 |
+
proto native int IndexOf(string sample);
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
\brief Finds last 'sample' in 'str'. Returns -1 when not found
|
| 244 |
+
\param sample \p string Finding string
|
| 245 |
+
\return \p int - Returns position where \p sample starts, or -1 when \p sample not found
|
| 246 |
+
@code
|
| 247 |
+
string str = "Hello World";
|
| 248 |
+
Print( str.IndexOf( "l" ) );
|
| 249 |
+
|
| 250 |
+
>> 9
|
| 251 |
+
@endcode
|
| 252 |
+
*/
|
| 253 |
+
proto native int LastIndexOf(string sample);
|
| 254 |
+
|
| 255 |
+
/**
|
| 256 |
+
\brief Finds 'sample' in 'str' from 'start' position. Returns -1 when not found
|
| 257 |
+
\param start \p int Start from position
|
| 258 |
+
\param sample \p string Finding string expression
|
| 259 |
+
\return \p int - Length of string \p s
|
| 260 |
+
@code
|
| 261 |
+
string str = "Hello World";
|
| 262 |
+
Print( str.IndexOfFrom( 3, "H" ) );
|
| 263 |
+
Print( str.IndexOfFrom( 3, "W" ) );
|
| 264 |
+
Print( str.IndexOfFrom( 3, "Q" ) );
|
| 265 |
+
|
| 266 |
+
>> -1
|
| 267 |
+
>> 6
|
| 268 |
+
>> -1
|
| 269 |
+
@endcode
|
| 270 |
+
*/
|
| 271 |
+
proto native int IndexOfFrom(int start, string sample);
|
| 272 |
+
|
| 273 |
+
/**
|
| 274 |
+
\brief Returns true if sample is substring of string
|
| 275 |
+
\param sample \p string Finding string expression
|
| 276 |
+
\return \p bool true if sample is substring of string
|
| 277 |
+
@code
|
| 278 |
+
string str = "Hello World";
|
| 279 |
+
Print( str.IndexOfFrom( 3, "Hello" ) );
|
| 280 |
+
Print( str.IndexOfFrom( 3, "Mexico" ) );
|
| 281 |
+
|
| 282 |
+
>> true
|
| 283 |
+
>> false
|
| 284 |
+
@endcode
|
| 285 |
+
*/
|
| 286 |
+
bool Contains(string sample)
|
| 287 |
+
{
|
| 288 |
+
return value.IndexOf(sample) != -1;
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
/**
|
| 292 |
+
\brief Returns trimmed string with removed leading and trailing whitespaces
|
| 293 |
+
\return \p string - Trimmed string
|
| 294 |
+
@code
|
| 295 |
+
string str = " Hello World "
|
| 296 |
+
Print( str );
|
| 297 |
+
Print( str.Trim() );
|
| 298 |
+
|
| 299 |
+
>> ' Hello World '
|
| 300 |
+
>> 'Hello World'
|
| 301 |
+
@endcode
|
| 302 |
+
|
| 303 |
+
*/
|
| 304 |
+
proto string Trim();
|
| 305 |
+
|
| 306 |
+
/**
|
| 307 |
+
\brief Removes leading and trailing whitespaces in string. Returns length
|
| 308 |
+
\return \p int - Count of chars
|
| 309 |
+
@code
|
| 310 |
+
string str = " Hello World ";
|
| 311 |
+
int i = str.TrimInPlace();
|
| 312 |
+
Print(str);
|
| 313 |
+
Print(i);
|
| 314 |
+
|
| 315 |
+
>> str = 'Hello World'
|
| 316 |
+
>> i = 11
|
| 317 |
+
@endcode
|
| 318 |
+
*/
|
| 319 |
+
proto int TrimInPlace();
|
| 320 |
+
|
| 321 |
+
/**
|
| 322 |
+
\brief Parses one token from input string. Result is put into token string, and type of token is returned. Input string is left-truncated by the resulting token length.
|
| 323 |
+
\param[out] token \p string Founded string token
|
| 324 |
+
\return \p int Type of token
|
| 325 |
+
\verbatim
|
| 326 |
+
Token types:
|
| 327 |
+
0 - error, no token
|
| 328 |
+
1 - defined token (special characters etc. . / * )
|
| 329 |
+
2 - quoted string. Quotes are removed -> TODO
|
| 330 |
+
3 - alphabetic string
|
| 331 |
+
4 - number
|
| 332 |
+
5 - end of line -> TODO
|
| 333 |
+
\endverbatim
|
| 334 |
+
@code
|
| 335 |
+
string input = "Hello*World";
|
| 336 |
+
string token1;
|
| 337 |
+
string token2;
|
| 338 |
+
|
| 339 |
+
int result1 = input.ParseStringEx(token1);
|
| 340 |
+
int result2 = input.ParseStringEx(token2);
|
| 341 |
+
|
| 342 |
+
Print( "Token1 = '" + token1 + "' Type = " + result1.ToString() ) );
|
| 343 |
+
Print( "Token2 = '" + token2 + "' Type = " + result2.ToString() ) );
|
| 344 |
+
|
| 345 |
+
>> 'Toke1 = 'Hello' Type = 3'
|
| 346 |
+
>> 'Toke1 = '*' Type = 1'
|
| 347 |
+
@endcode
|
| 348 |
+
*/
|
| 349 |
+
proto int ParseStringEx(out string token);
|
| 350 |
+
|
| 351 |
+
/**
|
| 352 |
+
\brief Parses string into array of tokens returns number of tokens
|
| 353 |
+
\param[out] tokens \p array[] Parsed string in array
|
| 354 |
+
\return \p int Number of tokens
|
| 355 |
+
@code
|
| 356 |
+
string token[2];
|
| 357 |
+
string str = "Hello World";
|
| 358 |
+
int result = str.ParseString(token);
|
| 359 |
+
|
| 360 |
+
for (int i = 0; i < 2; i++)
|
| 361 |
+
{
|
| 362 |
+
Print(token[i]);
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
>> 'Hello'
|
| 366 |
+
>> 'World'
|
| 367 |
+
@endcode
|
| 368 |
+
*/
|
| 369 |
+
proto int ParseString(out string tokens[]);
|
| 370 |
+
|
| 371 |
+
/**
|
| 372 |
+
\brief Splits string into array of strings separated by 'sample'
|
| 373 |
+
\param sample \p string Strings separator
|
| 374 |
+
\return \p TStringArray Array with strings
|
| 375 |
+
@code
|
| 376 |
+
string example = "The quick brown fox jumps over the lazy dog";
|
| 377 |
+
TStringArray strs = new TStringArray;
|
| 378 |
+
example.Split(" ", strs);
|
| 379 |
+
|
| 380 |
+
for (int i = 0; i < strs.Count(); i++)
|
| 381 |
+
{
|
| 382 |
+
Print(strs.Get(i));
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
>> 'The'
|
| 386 |
+
>> 'quick'
|
| 387 |
+
>> 'brown'
|
| 388 |
+
>> 'fox'
|
| 389 |
+
>> 'jumps'
|
| 390 |
+
>> 'over'
|
| 391 |
+
>> 'the'
|
| 392 |
+
>> 'lazy'
|
| 393 |
+
>> 'dog'
|
| 394 |
+
@endcode
|
| 395 |
+
*/
|
| 396 |
+
void Split(string sample, out array<string> output)
|
| 397 |
+
{
|
| 398 |
+
int txt_len = 0;
|
| 399 |
+
int sep_pos = -1;
|
| 400 |
+
int nxt_sep_pos = 0;
|
| 401 |
+
string text = "";
|
| 402 |
+
|
| 403 |
+
bool line_end = false;
|
| 404 |
+
while (line_end == false)
|
| 405 |
+
{
|
| 406 |
+
sep_pos = sep_pos + txt_len + 1;
|
| 407 |
+
nxt_sep_pos = value.IndexOfFrom(sep_pos, sample);
|
| 408 |
+
if ( nxt_sep_pos == -1 )
|
| 409 |
+
{
|
| 410 |
+
nxt_sep_pos = value.Length();
|
| 411 |
+
line_end = true;
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
txt_len = nxt_sep_pos - sep_pos;
|
| 415 |
+
if ( txt_len > 0 )
|
| 416 |
+
{
|
| 417 |
+
text = value.Substring(sep_pos, txt_len);
|
| 418 |
+
output.Insert(text);
|
| 419 |
+
}
|
| 420 |
+
}
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
// !Joins array of strings into a single string, separated by 'separator'. Inverse of Split
|
| 424 |
+
static string Join(string separator, notnull TStringArray tokens)
|
| 425 |
+
{
|
| 426 |
+
string output;
|
| 427 |
+
foreach (int i, string s: tokens)
|
| 428 |
+
{
|
| 429 |
+
if (i != 0)
|
| 430 |
+
output += separator;
|
| 431 |
+
output += s;
|
| 432 |
+
}
|
| 433 |
+
return output;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
/**
|
| 437 |
+
\brief Gets n-th character from string
|
| 438 |
+
\param index character index
|
| 439 |
+
\return \p string character on index-th position in string
|
| 440 |
+
\warning VME When index less than 0 or greater than string length
|
| 441 |
+
@code
|
| 442 |
+
string str = "Hello World";
|
| 443 |
+
Print( str[4] ); // Print( str.Get(4) );
|
| 444 |
+
|
| 445 |
+
>> 'o'
|
| 446 |
+
@endcode
|
| 447 |
+
*/
|
| 448 |
+
proto string Get(int index);
|
| 449 |
+
|
| 450 |
+
/**
|
| 451 |
+
\brief Sets the n-th character in string with the input, replacing previous value
|
| 452 |
+
\param index index to be replaced
|
| 453 |
+
\param input single non-terminated character value to replace with
|
| 454 |
+
\warning VME When index less than 0 or greater than string length
|
| 455 |
+
\warning (Diag) VME When string is empty or greater than length of 1
|
| 456 |
+
(Retail) Calls 'string.Insert' except it replaces only the initial character
|
| 457 |
+
@code
|
| 458 |
+
string str = "Hello World";
|
| 459 |
+
str[4] = "O";
|
| 460 |
+
Print( str );
|
| 461 |
+
|
| 462 |
+
>> 'HellO World'
|
| 463 |
+
@endcode
|
| 464 |
+
|
| 465 |
+
@code
|
| 466 |
+
string str = "Hello World";
|
| 467 |
+
str[6] = "Test ";
|
| 468 |
+
Print( str );
|
| 469 |
+
|
| 470 |
+
>> 'Hello Test orld'
|
| 471 |
+
@endcode
|
| 472 |
+
*/
|
| 473 |
+
proto void Set(int index, string input);
|
| 474 |
+
|
| 475 |
+
#ifdef DIAG_DEVELOPER
|
| 476 |
+
/**
|
| 477 |
+
\brief Do not use. Re-implemented for verification of new function due to design of previous function allowing for unexpected behavior that modders may depend on.
|
| 478 |
+
\see string.Set warnings for handling existing mods in Retail
|
| 479 |
+
@code
|
| 480 |
+
string str = "Hello World";
|
| 481 |
+
str.OldSet(6, "Test ");
|
| 482 |
+
Print( str );
|
| 483 |
+
|
| 484 |
+
>> 'Hello Test orld'
|
| 485 |
+
@endcode
|
| 486 |
+
*/
|
| 487 |
+
void OldSet(int n, string _value)
|
| 488 |
+
{
|
| 489 |
+
string pre = value.Substring(0, n);
|
| 490 |
+
n += 1;
|
| 491 |
+
int length = value.Length() - n;
|
| 492 |
+
string post = value.Substring(n, length);
|
| 493 |
+
value = pre + _value + post;
|
| 494 |
+
}
|
| 495 |
+
#endif
|
| 496 |
+
|
| 497 |
+
/**
|
| 498 |
+
\brief Inserts a string into the n-th index, increasing the string length by the size of the input
|
| 499 |
+
\param index index to insert at
|
| 500 |
+
\param input string value to insert with
|
| 501 |
+
\warning VME When index less than 0 or greater than string length
|
| 502 |
+
\warning VME When string is empty
|
| 503 |
+
@code
|
| 504 |
+
string str = "Hello World";
|
| 505 |
+
str.Insert(6, "Test ");
|
| 506 |
+
Print( str );
|
| 507 |
+
|
| 508 |
+
>> 'Hello Test World'
|
| 509 |
+
@endcode
|
| 510 |
+
*/
|
| 511 |
+
proto void Insert(int index, string input);
|
| 512 |
+
|
| 513 |
+
/**
|
| 514 |
+
\brief Gets n-th character from string
|
| 515 |
+
\param index character index
|
| 516 |
+
\return \p string character on index-th position in string
|
| 517 |
+
@code
|
| 518 |
+
int a = 5;
|
| 519 |
+
float b = 5.99;
|
| 520 |
+
string c = "beta";
|
| 521 |
+
string test = string.Format("Ahoj %1 = %3 , %2", a, b, c);
|
| 522 |
+
Print(test);
|
| 523 |
+
>> 'Ahoj 5 = 'beta' , 5.99'
|
| 524 |
+
@endcode
|
| 525 |
+
*/
|
| 526 |
+
static proto string Format(string fmt, void param1 = NULL, void param2 = NULL, void param3 = NULL, void param4 = NULL, void param5 = NULL, void param6 = NULL, void param7 = NULL, void param8 = NULL, void param9 = NULL);
|
| 527 |
+
};
|
| 528 |
+
|
| 529 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnSystem.c
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* \defgroup System System
|
| 3 |
+
* @{
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
\brief Returns world time
|
| 8 |
+
\param[out] hour \p int Hour
|
| 9 |
+
\param[out] minute \p int Minute
|
| 10 |
+
\param[out] second \p int Second
|
| 11 |
+
\return \p void
|
| 12 |
+
@code
|
| 13 |
+
int hour = 0;
|
| 14 |
+
int minute = 0;
|
| 15 |
+
int second = 0;
|
| 16 |
+
|
| 17 |
+
GetHourMinuteSecondUTC(hour, minute, second);
|
| 18 |
+
|
| 19 |
+
Print(hour);
|
| 20 |
+
Print(minute);
|
| 21 |
+
Print(second);
|
| 22 |
+
|
| 23 |
+
>> hour = 16
|
| 24 |
+
>> minute = 38
|
| 25 |
+
>> second = 7
|
| 26 |
+
@endcode
|
| 27 |
+
*/
|
| 28 |
+
proto void GetHourMinuteSecond(out int hour, out int minute, out int second);
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
\brief Returns world date
|
| 32 |
+
\param[out] year \p int Year
|
| 33 |
+
\param[out] month \p int Month
|
| 34 |
+
\param[out] day \p int Day
|
| 35 |
+
\return \p void
|
| 36 |
+
@code
|
| 37 |
+
int year = 0;
|
| 38 |
+
int month = 0;
|
| 39 |
+
int day = 0;
|
| 40 |
+
|
| 41 |
+
GetYearMonthDay(year, month, day);
|
| 42 |
+
|
| 43 |
+
Print(year);
|
| 44 |
+
Print(month);
|
| 45 |
+
Print(day);
|
| 46 |
+
|
| 47 |
+
>> year = 2015
|
| 48 |
+
>> month = 3
|
| 49 |
+
>> day = 24
|
| 50 |
+
@endcode
|
| 51 |
+
*/
|
| 52 |
+
proto void GetYearMonthDay(out int year, out int month, out int day);
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
\brief Returns UTC world time
|
| 56 |
+
\param[out] hour \p int Hour
|
| 57 |
+
\param[out] minute \p int Minute
|
| 58 |
+
\param[out] second \p int Second
|
| 59 |
+
\return \p void
|
| 60 |
+
@code
|
| 61 |
+
int hour = 0;
|
| 62 |
+
int minute = 0;
|
| 63 |
+
int second = 0;
|
| 64 |
+
|
| 65 |
+
GetHourMinuteSecondUTC(hour, minute, second);
|
| 66 |
+
|
| 67 |
+
Print(hour);
|
| 68 |
+
Print(minute);
|
| 69 |
+
Print(second);
|
| 70 |
+
|
| 71 |
+
>> hour = 15
|
| 72 |
+
>> minute = 38
|
| 73 |
+
>> second = 7
|
| 74 |
+
@endcode
|
| 75 |
+
*/
|
| 76 |
+
proto void GetHourMinuteSecondUTC(out int hour, out int minute, out int second);
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
\brief Returns UTC world date
|
| 80 |
+
\param[out] year \p int Year
|
| 81 |
+
\param[out] month \p int Month
|
| 82 |
+
\param[out] day \p int Day
|
| 83 |
+
\return \p void
|
| 84 |
+
@code
|
| 85 |
+
int year = 0;
|
| 86 |
+
int month = 0;
|
| 87 |
+
int day = 0;
|
| 88 |
+
|
| 89 |
+
GetYearMonthDayUTC(year, month, day);
|
| 90 |
+
|
| 91 |
+
Print(year);
|
| 92 |
+
Print(month);
|
| 93 |
+
Print(day);
|
| 94 |
+
|
| 95 |
+
>> year = 2015
|
| 96 |
+
>> month = 3
|
| 97 |
+
>> day = 24
|
| 98 |
+
@endcode
|
| 99 |
+
*/
|
| 100 |
+
proto void GetYearMonthDayUTC(out int year, out int month, out int day);
|
| 101 |
+
|
| 102 |
+
proto string GetProfileName();
|
| 103 |
+
proto string GetMachineName();
|
| 104 |
+
|
| 105 |
+
//! performance counter. Returns number of CPU ticks between 'prev' and 'now'
|
| 106 |
+
proto native int TickCount(int prev);
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
\brief Switches memory validation (huge slowdown! Use with care only for certain section of code!)
|
| 110 |
+
\param enable \p bool Enable
|
| 111 |
+
\return \p void
|
| 112 |
+
@code
|
| 113 |
+
???
|
| 114 |
+
@endcode
|
| 115 |
+
*/
|
| 116 |
+
proto native void MemoryValidation(bool enable);
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
\brief Returns command line argument
|
| 120 |
+
\param name of a command line argument
|
| 121 |
+
\param val \p string value of the param or empty string if the param hasn't been found
|
| 122 |
+
\return True if param is present, False if hasn't been found
|
| 123 |
+
@code
|
| 124 |
+
string param;
|
| 125 |
+
GetCLIParam("world", param); // return a value when program executed with param -world something
|
| 126 |
+
@endcode
|
| 127 |
+
*/
|
| 128 |
+
proto bool GetCLIParam(string param, out string val);
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
\brief Returns if command line argument is present
|
| 132 |
+
\param name of a command line argument
|
| 133 |
+
\return True if param is present, False if hasn't been found
|
| 134 |
+
@code
|
| 135 |
+
if (IsCLIParam("verbose")) // Prints "something" when program executed with param -verbose
|
| 136 |
+
{
|
| 137 |
+
Print("something");
|
| 138 |
+
}
|
| 139 |
+
@endcode
|
| 140 |
+
*/
|
| 141 |
+
proto native bool IsCLIParam(string param);
|
| 142 |
+
|
| 143 |
+
#ifdef ENF_DONE
|
| 144 |
+
|
| 145 |
+
//! developer tool - start video grabber
|
| 146 |
+
proto native void StartVideo(string name);
|
| 147 |
+
//! developer tool - stop video grabber
|
| 148 |
+
proto native void StopVideo();
|
| 149 |
+
#endif
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
/**
|
| 153 |
+
* \defgroup Keyboard Keyboard input API
|
| 154 |
+
* @{
|
| 155 |
+
*/
|
| 156 |
+
enum KeyCode
|
| 157 |
+
{
|
| 158 |
+
KC_ESCAPE,
|
| 159 |
+
KC_1,
|
| 160 |
+
KC_2,
|
| 161 |
+
KC_3,
|
| 162 |
+
KC_4,
|
| 163 |
+
KC_5,
|
| 164 |
+
KC_6,
|
| 165 |
+
KC_7,
|
| 166 |
+
KC_8,
|
| 167 |
+
KC_9,
|
| 168 |
+
KC_0,
|
| 169 |
+
KC_MINUS, ///< - on main keyboard
|
| 170 |
+
KC_EQUALS,
|
| 171 |
+
KC_BACK, ///< backspace
|
| 172 |
+
KC_TAB,
|
| 173 |
+
KC_Q,
|
| 174 |
+
KC_W,
|
| 175 |
+
KC_E,
|
| 176 |
+
KC_R,
|
| 177 |
+
KC_T,
|
| 178 |
+
KC_Y,
|
| 179 |
+
KC_U,
|
| 180 |
+
KC_I,
|
| 181 |
+
KC_O,
|
| 182 |
+
KC_P,
|
| 183 |
+
KC_LBRACKET,
|
| 184 |
+
KC_RBRACKET,
|
| 185 |
+
KC_RETURN, ///< Enter on main keyboard
|
| 186 |
+
KC_LCONTROL,
|
| 187 |
+
KC_A,
|
| 188 |
+
KC_S,
|
| 189 |
+
KC_D,
|
| 190 |
+
KC_F,
|
| 191 |
+
KC_G,
|
| 192 |
+
KC_H,
|
| 193 |
+
KC_J,
|
| 194 |
+
KC_K,
|
| 195 |
+
KC_L,
|
| 196 |
+
KC_SEMICOLON,
|
| 197 |
+
KC_APOSTROPHE,
|
| 198 |
+
KC_GRAVE, ///< accent grave
|
| 199 |
+
KC_LSHIFT,
|
| 200 |
+
KC_BACKSLASH,
|
| 201 |
+
KC_Z,
|
| 202 |
+
KC_X,
|
| 203 |
+
KC_C,
|
| 204 |
+
KC_V,
|
| 205 |
+
KC_B,
|
| 206 |
+
KC_N,
|
| 207 |
+
KC_M,
|
| 208 |
+
KC_COMMA,
|
| 209 |
+
KC_PERIOD, ///< . on main keyboard
|
| 210 |
+
KC_SLASH, ///< / on main keyboard
|
| 211 |
+
KC_RSHIFT,
|
| 212 |
+
KC_MULTIPLY, ///< * on numeric keypad
|
| 213 |
+
KC_LMENU, ///< left Alt
|
| 214 |
+
KC_SPACE,
|
| 215 |
+
KC_CAPITAL,
|
| 216 |
+
KC_F1,
|
| 217 |
+
KC_F2,
|
| 218 |
+
KC_F3,
|
| 219 |
+
KC_F4,
|
| 220 |
+
KC_F5,
|
| 221 |
+
KC_F6,
|
| 222 |
+
KC_F7,
|
| 223 |
+
KC_F8,
|
| 224 |
+
KC_F9,
|
| 225 |
+
KC_F10,
|
| 226 |
+
KC_NUMLOCK,
|
| 227 |
+
KC_SCROLL, ///< Scroll Lock
|
| 228 |
+
KC_NUMPAD7,
|
| 229 |
+
KC_NUMPAD8,
|
| 230 |
+
KC_NUMPAD9,
|
| 231 |
+
KC_SUBTRACT, ///< - on numeric keypad
|
| 232 |
+
KC_NUMPAD4,
|
| 233 |
+
KC_NUMPAD5,
|
| 234 |
+
KC_NUMPAD6,
|
| 235 |
+
KC_ADD, ///< + on numeric keypad
|
| 236 |
+
KC_NUMPAD1,
|
| 237 |
+
KC_NUMPAD2,
|
| 238 |
+
KC_NUMPAD3,
|
| 239 |
+
KC_NUMPAD0,
|
| 240 |
+
KC_DECIMAL, ///< . on numeric keypad
|
| 241 |
+
KC_OEM_102, ///< < > | on UK/Germany keyboards
|
| 242 |
+
KC_F11,
|
| 243 |
+
KC_F12,
|
| 244 |
+
KC_NUMPADEQUALS, ///< = on numeric keypad (NEC PC98)
|
| 245 |
+
KC_PREVTRACK, ///< Previous Track (DIKC_CIRCUMFLEX on Japanese keyboard)
|
| 246 |
+
KC_AT, ///< (NEC PC98)
|
| 247 |
+
KC_COLON, ///< (NEC PC98)
|
| 248 |
+
KC_UNDERLINE, ///< (NEC PC98)
|
| 249 |
+
KC_STOP, ///< (NEC PC98)
|
| 250 |
+
KC_AX, ///< (Japan AX)
|
| 251 |
+
KC_UNLABELED, ///< (J3100)
|
| 252 |
+
KC_NEXTTRACK, ///< Next Track
|
| 253 |
+
KC_NUMPADENTER, ///< Enter on numeric keypad
|
| 254 |
+
KC_RCONTROL,
|
| 255 |
+
KC_MUTE, ///< Mute
|
| 256 |
+
KC_CALCULATOR, ///< Calculator
|
| 257 |
+
KC_PLAYPAUSE, ///< Play / Pause
|
| 258 |
+
KC_MEDIASTOP, ///< Media Stop
|
| 259 |
+
KC_VOLUMEDOWN, ///< Volume -
|
| 260 |
+
KC_VOLUMEUP, ///< Volume +
|
| 261 |
+
KC_WEBHOME, ///< Web home
|
| 262 |
+
KC_NUMPADCOMMA, ///< , on numeric keypad (NEC PC98)
|
| 263 |
+
KC_DIVIDE, ///< / on numeric keypad
|
| 264 |
+
KC_SYSRQ,
|
| 265 |
+
KC_RMENU, ///< right Alt
|
| 266 |
+
KC_PAUSE, ///< Pause
|
| 267 |
+
KC_HOME, ///< Home on arrow keypad
|
| 268 |
+
KC_UP, ///< UpArrow on arrow keypad
|
| 269 |
+
KC_PRIOR, ///< PgUp on arrow keypad
|
| 270 |
+
KC_LEFT, ///< LeftArrow on arrow keypad
|
| 271 |
+
KC_RIGHT, ///< RightArrow on arrow keypad
|
| 272 |
+
KC_END, ///< End on arrow keypad
|
| 273 |
+
KC_DOWN, ///< DownArrow on arrow keypad
|
| 274 |
+
KC_NEXT, ///< PgDn on arrow keypad
|
| 275 |
+
KC_INSERT, ///< Insert on arrow keypad
|
| 276 |
+
KC_DELETE, ///< Delete on arrow keypad
|
| 277 |
+
KC_LWIN, ///< Left Windows key
|
| 278 |
+
KC_RWIN, ///< Right Windows key
|
| 279 |
+
KC_APPS, ///< AppMenu key
|
| 280 |
+
KC_POWER, ///< System Power
|
| 281 |
+
KC_SLEEP, ///< System Sleep
|
| 282 |
+
KC_WAKE, ///< System Wake
|
| 283 |
+
KC_MEDIASELECT ///< Media Select
|
| 284 |
+
};
|
| 285 |
+
|
| 286 |
+
/*!
|
| 287 |
+
Gets key state
|
| 288 |
+
\param key Key code
|
| 289 |
+
\returns 0 when not pressed, 15. bit set when pressed, 0.-14. bit pressed count
|
| 290 |
+
*/
|
| 291 |
+
proto native int KeyState(KeyCode key);
|
| 292 |
+
|
| 293 |
+
/*!
|
| 294 |
+
Clears the key state.
|
| 295 |
+
Call this function if you want to overcome autorepeating in reporting key state. If called, the KeyState returns pressed only after the key is released and pressed again.
|
| 296 |
+
*/
|
| 297 |
+
proto native void ClearKey(KeyCode key);
|
| 298 |
+
/** @}*/
|
| 299 |
+
|
| 300 |
+
//! returns index of defined key in InputDevice by its name
|
| 301 |
+
//proto native int GetDefKey(string name);
|
| 302 |
+
//proto native int DefKeyState(int defkey, bool clear);
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
/**
|
| 306 |
+
* \defgroup Mouse Mouse API
|
| 307 |
+
* @{
|
| 308 |
+
*/
|
| 309 |
+
|
| 310 |
+
enum MouseState
|
| 311 |
+
{
|
| 312 |
+
LEFT,
|
| 313 |
+
RIGHT,
|
| 314 |
+
MIDDLE,
|
| 315 |
+
X,
|
| 316 |
+
Y,
|
| 317 |
+
WHEEL
|
| 318 |
+
};
|
| 319 |
+
//const int MB_PRESSED_MASK
|
| 320 |
+
|
| 321 |
+
/*!
|
| 322 |
+
Returns state of mouse button. It's combination of number of release/pressed edges and mask MB_PRESSED_MASK
|
| 323 |
+
that is set when button is pressed.
|
| 324 |
+
If you want just to check if button is pressed, use this: if(GetMouseState(MouseState.LEFT) & MB_PRESSED_MASK)) Print("left button pressed");
|
| 325 |
+
*/
|
| 326 |
+
proto native int GetMouseState(MouseState index);
|
| 327 |
+
|
| 328 |
+
// Gets current mouse position
|
| 329 |
+
proto void GetMousePos(out int x, out int y);
|
| 330 |
+
// Gets current screen size (resolution)
|
| 331 |
+
proto void GetScreenSize(out int x, out int y);
|
| 332 |
+
|
| 333 |
+
/** @}*/
|
| 334 |
+
|
| 335 |
+
/**
|
| 336 |
+
* \defgroup Gamepad API
|
| 337 |
+
* @{
|
| 338 |
+
*/
|
| 339 |
+
|
| 340 |
+
enum GamepadButton
|
| 341 |
+
{
|
| 342 |
+
BUTTON_NONE,
|
| 343 |
+
MENU,
|
| 344 |
+
VIEW,
|
| 345 |
+
A,
|
| 346 |
+
B,
|
| 347 |
+
X,
|
| 348 |
+
Y,
|
| 349 |
+
PAD_UP,
|
| 350 |
+
PAD_DOWN,
|
| 351 |
+
PAD_LEFT,
|
| 352 |
+
PAD_RIGHT,
|
| 353 |
+
SHOULDER_LEFT,
|
| 354 |
+
SHOULDER_RIGHT,
|
| 355 |
+
THUMB_LEFT,
|
| 356 |
+
THUMB_RIGHT
|
| 357 |
+
};
|
| 358 |
+
|
| 359 |
+
enum GamepadAxis
|
| 360 |
+
{
|
| 361 |
+
LEFT_THUMB_HORIZONTAL,
|
| 362 |
+
LEFT_THUMB_VERTICAL,
|
| 363 |
+
RIGHT_THUMB_HORIZONTAL,
|
| 364 |
+
RIGHT_THUMB_VERTICAL,
|
| 365 |
+
LEFT_TRIGGER,
|
| 366 |
+
RIGHT_TRIGGER,
|
| 367 |
+
};
|
| 368 |
+
|
| 369 |
+
//! return if the button is pressed or not
|
| 370 |
+
proto native int GetGamepadButton(GamepadButton button);
|
| 371 |
+
//! return value in gamepad axis <-1000; 1000>
|
| 372 |
+
proto native float GetGamepadAxis(GamepadAxis axis);
|
| 373 |
+
|
| 374 |
+
/** @}*/
|
| 375 |
+
|
| 376 |
+
//----------------------------------------------
|
| 377 |
+
/**
|
| 378 |
+
* \defgroup File FileIO API
|
| 379 |
+
* @{
|
| 380 |
+
*/
|
| 381 |
+
|
| 382 |
+
enum FileMode
|
| 383 |
+
{
|
| 384 |
+
READ,
|
| 385 |
+
WRITE,
|
| 386 |
+
APPEND
|
| 387 |
+
};
|
| 388 |
+
|
| 389 |
+
typedef int[] ParseHandle;
|
| 390 |
+
typedef int[] FileHandle;
|
| 391 |
+
|
| 392 |
+
proto native ParseHandle BeginParse(string filename);
|
| 393 |
+
proto int ParseLine(ParseHandle tp, int num, string tokens[]);
|
| 394 |
+
proto native void EndParse(ParseHandle file);
|
| 395 |
+
|
| 396 |
+
//!Check existence of file
|
| 397 |
+
proto bool FileExist(string name);
|
| 398 |
+
|
| 399 |
+
/**
|
| 400 |
+
\brief Opens File
|
| 401 |
+
@param name of a file to open, (you can use filesystem prefixes ('$profile','$saves','$mission'). For accessing profile dir use '$profile', e.g. '$profile:myfilename.txt')
|
| 402 |
+
@param mode constants FileMode.WRITE, FileMode.READ or FileMode.APPEND flag can be used
|
| 403 |
+
\return file handle ID or 0 if fails
|
| 404 |
+
\n usage :
|
| 405 |
+
@code
|
| 406 |
+
FileHandle file = OpenFile("$profile:testiik.txt", FileMode.WRITE);
|
| 407 |
+
//FileHandle file = OpenFile("$profile:testiik.txt", FileMode.APPEND);
|
| 408 |
+
if (file != 0)
|
| 409 |
+
{
|
| 410 |
+
FPrintln(file, "line1");
|
| 411 |
+
FPrintln(file, "line2");
|
| 412 |
+
FPrintln(file, "line3");
|
| 413 |
+
CloseFile(file);
|
| 414 |
+
}
|
| 415 |
+
@endcode
|
| 416 |
+
*/
|
| 417 |
+
proto FileHandle OpenFile(string name, FileMode mode);
|
| 418 |
+
|
| 419 |
+
/**
|
| 420 |
+
Reads raw data from file.
|
| 421 |
+
\param param_array Receiving array for the data. Valid types are int[] or string
|
| 422 |
+
\param length Length of data
|
| 423 |
+
\returns number of read bytes
|
| 424 |
+
*/
|
| 425 |
+
proto int ReadFile(FileHandle file, void param_array, int length);
|
| 426 |
+
|
| 427 |
+
/**
|
| 428 |
+
\brief Close the File
|
| 429 |
+
@param file File handle ID of a opened file
|
| 430 |
+
\return void
|
| 431 |
+
\n usage :
|
| 432 |
+
@code
|
| 433 |
+
FileHandle file = OpenFile("$profile:testiik.txt", FileMode.WRITE);
|
| 434 |
+
if (file != 0)
|
| 435 |
+
{
|
| 436 |
+
FPrintln(file, "line1");
|
| 437 |
+
FPrintln(file, "line2");
|
| 438 |
+
FPrintln(file, "line3");
|
| 439 |
+
CloseFile(file);
|
| 440 |
+
}
|
| 441 |
+
@endcode
|
| 442 |
+
*/
|
| 443 |
+
proto void CloseFile(FileHandle file);
|
| 444 |
+
|
| 445 |
+
/**
|
| 446 |
+
\brief Write to file
|
| 447 |
+
@param file File handle ID of a opened file
|
| 448 |
+
@param var Value to write
|
| 449 |
+
\return void
|
| 450 |
+
\n usage :
|
| 451 |
+
@code
|
| 452 |
+
FileHandle file = OpenFile("$profile:testiik.txt", FileMode.WRITE);
|
| 453 |
+
if (file != 0)
|
| 454 |
+
{
|
| 455 |
+
FPrint(file, "A");
|
| 456 |
+
FPrint(file, "B");
|
| 457 |
+
FPrint(file, "C");
|
| 458 |
+
CloseFile(file);
|
| 459 |
+
}
|
| 460 |
+
@endcode
|
| 461 |
+
*/
|
| 462 |
+
proto void FPrint(FileHandle file, void var);
|
| 463 |
+
|
| 464 |
+
/**
|
| 465 |
+
\brief Write to file and add new line
|
| 466 |
+
@param file File handle ID of a opened file
|
| 467 |
+
@param var Value to write
|
| 468 |
+
\return void
|
| 469 |
+
\n usage :
|
| 470 |
+
@code
|
| 471 |
+
FileHandle file = OpenFile("$profile:testiik.txt", FileMode.WRITE);
|
| 472 |
+
if (file != 0)
|
| 473 |
+
{
|
| 474 |
+
FPrintln(file, "line1");
|
| 475 |
+
FPrintln(file, "line2");
|
| 476 |
+
FPrintln(file, "line3");
|
| 477 |
+
CloseFile(file);
|
| 478 |
+
}
|
| 479 |
+
@endcode
|
| 480 |
+
*/
|
| 481 |
+
proto void FPrintln(FileHandle file, void var);
|
| 482 |
+
|
| 483 |
+
/**
|
| 484 |
+
\brief Get line from file, every next call of this function returns next line
|
| 485 |
+
@param file File handle ID of a opened file
|
| 486 |
+
@param var Value to write
|
| 487 |
+
\return int Count of chars or -1 if is not any for read (end of file is EMPTY line)
|
| 488 |
+
\n usage :
|
| 489 |
+
@code
|
| 490 |
+
FileHandle file_handle = OpenFile("$profile:testiik.txt", FileMode.READ);
|
| 491 |
+
string line_content;
|
| 492 |
+
|
| 493 |
+
while ( FGets( file_handle, line_content ) > 0 )
|
| 494 |
+
{
|
| 495 |
+
Print(line_content);
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
CloseFile(file_handle);
|
| 499 |
+
@endcode
|
| 500 |
+
*/
|
| 501 |
+
proto int FGets(FileHandle file, string var);
|
| 502 |
+
|
| 503 |
+
typedef int[] FindFileHandle;
|
| 504 |
+
|
| 505 |
+
enum FileAttr
|
| 506 |
+
{
|
| 507 |
+
DIRECTORY, ///<File is directory
|
| 508 |
+
HIDDEN, ///<File is hidden
|
| 509 |
+
READONLY, ///<File is read-only
|
| 510 |
+
INVALID ///<Invalid file
|
| 511 |
+
};
|
| 512 |
+
|
| 513 |
+
enum FindFileFlags
|
| 514 |
+
{
|
| 515 |
+
DIRECTORIES, ///<Looks for files in fs directories only.
|
| 516 |
+
ARCHIVES, ///<Looks for files in archive only. (.pak)
|
| 517 |
+
ALL ///<Looks in archives and fs directories.
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
proto FindFileHandle FindFile(string pattern, out string fileName, out FileAttr fileAttributes, FindFileFlags flags);
|
| 521 |
+
proto bool FindNextFile(FindFileHandle handle, out string fileName, out FileAttr fileAttributes);
|
| 522 |
+
proto native void CloseFindFile(FindFileHandle handle);
|
| 523 |
+
|
| 524 |
+
//!Makes a directory
|
| 525 |
+
proto native bool MakeDirectory(string name);
|
| 526 |
+
|
| 527 |
+
//!delete file. Works only on "$profile:" and "$saves:" locations
|
| 528 |
+
proto native bool DeleteFile(string name);
|
| 529 |
+
|
| 530 |
+
//! copy file. destName must be "$profile:" or "$saves:" location
|
| 531 |
+
proto native bool CopyFile(string sourceName, string destName);
|
| 532 |
+
/** @}*/
|
| 533 |
+
|
| 534 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnVRD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< The HMD is being used for rendering.
|
| 18 |
+
VR_STATUS_PRESENT, //< The HMD port is open.
|
| 19 |
+
VR_STATUS_MOUNTED, //< The HMD is mounted on users head.
|
| 20 |
+
VR_STATUS_DISPLAY_LOST, //< The HMD was present and disappeared.
|
| 21 |
+
VR_STATUS_SHOULD_QUIT, //< Application requested exit.
|
| 22 |
+
VR_STATUS_SHOULD_RECENTER, //< The HMD Recenter request event was triggered.
|
| 23 |
+
VR_STATUS_TRACKED, //< The tracking data for the HMD are up to date.
|
| 24 |
+
VR_STATUS_CALIBRATING, //< The HMD is being calibrated.
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
enum VRHandEnum
|
| 28 |
+
{
|
| 29 |
+
VR_HAND_LEFT, //< HMD controller left hand.
|
| 30 |
+
VR_HAND_RIGHT //< HMD controller right hand.
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
enum VREye
|
| 34 |
+
{
|
| 35 |
+
VR_EYE_LEFT, // HMD left eye.
|
| 36 |
+
VR_EYE_RIGHT // HMD right eye.
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/*!
|
| 40 |
+
VRDevice interface common for all VR implementations.
|
| 41 |
+
|
| 42 |
+
DO NOT INHERIT FROM THIS CLASS!
|
| 43 |
+
*/
|
| 44 |
+
class VRDevice : Managed
|
| 45 |
+
{
|
| 46 |
+
/*!
|
| 47 |
+
\brief returns VRDevice instance.
|
| 48 |
+
\return device instance.
|
| 49 |
+
*/
|
| 50 |
+
proto native static VRDevice GetInstance();
|
| 51 |
+
|
| 52 |
+
/*!
|
| 53 |
+
\brief returns status flags.
|
| 54 |
+
|
| 55 |
+
\return current device state flags.
|
| 56 |
+
*/
|
| 57 |
+
proto native VRStatus GetStatusFlags();
|
| 58 |
+
/*!
|
| 59 |
+
\brief returns device name.
|
| 60 |
+
\return device brand name.
|
| 61 |
+
*/
|
| 62 |
+
proto native owned string GetName();
|
| 63 |
+
/*!
|
| 64 |
+
\brief returns device type.
|
| 65 |
+
\return device type enum.
|
| 66 |
+
*/
|
| 67 |
+
proto native VRDeviceType GetDeviceType();
|
| 68 |
+
/*!
|
| 69 |
+
\brief Forces immediate head recenter.
|
| 70 |
+
|
| 71 |
+
Uses the current scene position and orientation
|
| 72 |
+
as the new camera origin.
|
| 73 |
+
*/
|
| 74 |
+
proto native void RecenterHeadTracking();
|
| 75 |
+
/*!
|
| 76 |
+
\brief returns HMD head position .
|
| 77 |
+
\return position in world space.
|
| 78 |
+
*/
|
| 79 |
+
proto native vector GetHeadPosition();
|
| 80 |
+
/*!
|
| 81 |
+
\brief returns HMD head orientation.
|
| 82 |
+
\return Euler angles in device space. (Yaw, Pitch, Roll)
|
| 83 |
+
*/
|
| 84 |
+
proto native vector GetHeadOrientation();
|
| 85 |
+
/*!
|
| 86 |
+
\brief returns HMD controller's position.
|
| 87 |
+
|
| 88 |
+
\param hand left/right hand enum.
|
| 89 |
+
\return position in world space.
|
| 90 |
+
*/
|
| 91 |
+
proto native vector GetHandPosition(VRHand hand);
|
| 92 |
+
/*!
|
| 93 |
+
\brief returns HMD controller's orientation.
|
| 94 |
+
|
| 95 |
+
\param hand left/right hand enum.
|
| 96 |
+
\return Euler angles in device space. (Yaw, Pitch, Roll)
|
| 97 |
+
*/
|
| 98 |
+
proto native vector GetHandOrientation(VRHand hand);
|
| 99 |
+
/*!
|
| 100 |
+
\brief returns HMD Eye's position.
|
| 101 |
+
|
| 102 |
+
\param eye left/right eye enum.
|
| 103 |
+
\return position in world space.
|
| 104 |
+
*/
|
| 105 |
+
proto native vector GetEyePosition(VREye eye);
|
| 106 |
+
/*!
|
| 107 |
+
\brief returns HMD Eye's orientation.
|
| 108 |
+
|
| 109 |
+
\param eye left/right eye enum.
|
| 110 |
+
\return Euler angles in device space. (Yaw, Pitch, Roll)
|
| 111 |
+
*/
|
| 112 |
+
proto native vector GetEyeOrientation(VREye eye);
|
| 113 |
+
/*!
|
| 114 |
+
\brief Sets up current vr scale.
|
| 115 |
+
|
| 116 |
+
All translations will get scaled by this value.
|
| 117 |
+
With higher scale values will the world around look smaller.
|
| 118 |
+
|
| 119 |
+
"Warning: The tracking errors will render more visible with high scale."
|
| 120 |
+
\param scale the scale amount.
|
| 121 |
+
*/
|
| 122 |
+
proto native void SetScale(float scale);
|
| 123 |
+
/*!
|
| 124 |
+
\brief returns current vr scale.
|
| 125 |
+
\return the scale amount.
|
| 126 |
+
*/
|
| 127 |
+
proto native float GetScale();
|
| 128 |
+
|
| 129 |
+
/*!
|
| 130 |
+
\brief returns current FOV's tangent values.
|
| 131 |
+
|
| 132 |
+
In VR mode the FOV should be asymmetric.
|
| 133 |
+
\returns tangent values of asymetric FOV.
|
| 134 |
+
*/
|
| 135 |
+
proto external void GetEyeFOV(VREye eye, out float leftTan, out float rightTan, out float upTan, out float downTan);
|
| 136 |
+
};
|
| 137 |
+
|
| 138 |
+
enum PSVrHeadRecenterFlagsEnum
|
| 139 |
+
{
|
| 140 |
+
VR_RECENTER_POSITION,
|
| 141 |
+
VR_RECENTER_ORIENTATION
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
enum PSVrBrightnessRiskEnum
|
| 145 |
+
{
|
| 146 |
+
VR_BRIGHTNESS_RISK_LOW,
|
| 147 |
+
VR_BRIGHTNESS_RISK_HIGH,
|
| 148 |
+
VR_BRIGHTNESS_RISK_MAX
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
enum PSVrTrackingQualityEnum
|
| 152 |
+
{
|
| 153 |
+
VR_TRACKING_QUALITY_NONE,
|
| 154 |
+
VR_TRACKING_QUALITY_NOT_VISIBLE,
|
| 155 |
+
VR_TRACKING_QUALITY_PARTIAL,
|
| 156 |
+
VR_TRACKING_QUALITY_FULL
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
enum PSVrDialogStatusEnum
|
| 160 |
+
{
|
| 161 |
+
VR_DIALOG_UNKNOWN,
|
| 162 |
+
VR_DIALOG_OK,
|
| 163 |
+
VR_DIALOG_CANCELED,
|
| 164 |
+
VR_DIALOG_RUNNING
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
/*!
|
| 168 |
+
PS4 specific VR interface.
|
| 169 |
+
*/
|
| 170 |
+
class VRDevice_PS4 : VRDevice
|
| 171 |
+
{
|
| 172 |
+
/*!
|
| 173 |
+
\brief Switches VR device into 2D "theater" mode.
|
| 174 |
+
|
| 175 |
+
Don't forget to set appropriate FOV.
|
| 176 |
+
|
| 177 |
+
At the moment the device uses the render targets of the
|
| 178 |
+
left eye. These render targets are 8:9 and we are still rendering
|
| 179 |
+
both eyes. If the feature gets used in a actual gameplay we can
|
| 180 |
+
extend it to separate set of 16:9 render targets.
|
| 181 |
+
|
| 182 |
+
\param enabled enable/disable flag.
|
| 183 |
+
*/
|
| 184 |
+
proto native void Set2D(bool enabled);
|
| 185 |
+
/*!
|
| 186 |
+
\brief Pops up HMD service dialog.
|
| 187 |
+
\return true when dialog was opened and his state was resolved as OK.
|
| 188 |
+
*/
|
| 189 |
+
proto native bool ShowHmdServiceDialog();
|
| 190 |
+
/*!
|
| 191 |
+
\brief Pops up HMD setup dialog.
|
| 192 |
+
\return true when dialog was opened and closed successfully.
|
| 193 |
+
*/
|
| 194 |
+
proto native bool ShowHmdSetupDialog();
|
| 195 |
+
/*!
|
| 196 |
+
\brief Returns current setup dialog state.
|
| 197 |
+
\return dialog state enum.
|
| 198 |
+
*/
|
| 199 |
+
proto native PSVrDialogStatusEnum GetSetupDialogStatus();
|
| 200 |
+
/*!
|
| 201 |
+
\brief Returns current service dialog state.
|
| 202 |
+
\return dialog state enum.
|
| 203 |
+
*/
|
| 204 |
+
proto native PSVrDialogStatusEnum GetServiceDialogStatus();
|
| 205 |
+
|
| 206 |
+
/*!
|
| 207 |
+
\brief HMD recentering hint flags setup.
|
| 208 |
+
*/
|
| 209 |
+
proto native void SetRecenterHeadFlags(PSVrHeadRecenterFlagsEnum flags);
|
| 210 |
+
/*!
|
| 211 |
+
\brief Returns HMD recentering flags.
|
| 212 |
+
\return recentering enum.
|
| 213 |
+
*/
|
| 214 |
+
proto native PSVrHeadRecenterFlagsEnum GetRecenterHeadFlags();
|
| 215 |
+
/*!
|
| 216 |
+
\brief Returns the eye offset in device space.
|
| 217 |
+
\return 3D position centered around device space center.
|
| 218 |
+
*/
|
| 219 |
+
proto native vector GetEyeOffset(VREye eye);
|
| 220 |
+
/*!
|
| 221 |
+
\brief Sets up the minimal displayable color.
|
| 222 |
+
|
| 223 |
+
Setup this value when smears start appearing in
|
| 224 |
+
dark environments.
|
| 225 |
+
*/
|
| 226 |
+
proto native void SetMinOutputColor(int color);
|
| 227 |
+
/*!
|
| 228 |
+
\brief Per eye FOV setup.
|
| 229 |
+
|
| 230 |
+
Keep in mind that changing the values from device presets
|
| 231 |
+
may cause user discomfort.
|
| 232 |
+
*/
|
| 233 |
+
proto native void SetEyeFOV(VREye eye, float leftTan, float rightTan, float upTan, float downTan);
|
| 234 |
+
/*!
|
| 235 |
+
\brief Resets the FOV settings to device preset value.
|
| 236 |
+
*/
|
| 237 |
+
proto native void ResetToDeviceFOV(VREye eye);
|
| 238 |
+
/*!
|
| 239 |
+
\brief Sets up the render target size multiplier.
|
| 240 |
+
|
| 241 |
+
Set this value before the device gets initialized.
|
| 242 |
+
*/
|
| 243 |
+
proto native void SetOversamplingFactor(float factor);
|
| 244 |
+
/*!
|
| 245 |
+
\brief Returns HMD tracking status.
|
| 246 |
+
\param bRisk tracked scene brightness risk.
|
| 247 |
+
\param posQuality precision of the HMD position.
|
| 248 |
+
\param orQuality precision of tthe HMD orientation.
|
| 249 |
+
\return false when the HMD port is not open.
|
| 250 |
+
*/
|
| 251 |
+
proto bool GetHmdTrackingStatus( out PSVrBrightnessRiskEnum bRisk,
|
| 252 |
+
out PSVrTrackingQualityEnum posQuality,
|
| 253 |
+
out PSVrTrackingQualityEnum orQuality);
|
| 254 |
+
/*!
|
| 255 |
+
\brief Returns Move controller tracking status.
|
| 256 |
+
|
| 257 |
+
\param hand identifier of the contoller.
|
| 258 |
+
\param bRisk tracked scene brightness risk.
|
| 259 |
+
\param posQuality precision of the controllers position.
|
| 260 |
+
\param orQuality precision of the controllers orientation.
|
| 261 |
+
\return false when the Move port is not open.
|
| 262 |
+
*/
|
| 263 |
+
proto bool GetMoveTrackingStatus( VRHand hand,
|
| 264 |
+
out PSVrBrightnessRiskEnum bRisk,
|
| 265 |
+
out PSVrTrackingQualityEnum posQuality,
|
| 266 |
+
out PSVrTrackingQualityEnum orQuality);
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
/*!
|
| 270 |
+
Oculus specific VR interface.
|
| 271 |
+
*/
|
| 272 |
+
class Oculus : VRDevice
|
| 273 |
+
{
|
| 274 |
+
// TODO:
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
/*
|
| 278 |
+
* @}
|
| 279 |
+
*/
|
| 280 |
+
|
| 281 |
+
#endif
|
scripts/1_Core/DayZ/proto/EnVisual.c
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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data, or gets it from cache. Object must be released when not used
|
| 7 |
+
proto native vobject GetObject(string name);
|
| 8 |
+
|
| 9 |
+
/*!
|
| 10 |
+
Release object. When there are not any other references, object is stored into cache and ready to be victed if necessary.
|
| 11 |
+
\param object Object handle
|
| 12 |
+
\param flag If RF_RELEASE is used, the object is evicted immediatelly, if not used by anyone else
|
| 13 |
+
*/
|
| 14 |
+
proto native void ReleaseObject(vobject object, int flag = 0);
|
| 15 |
+
|
| 16 |
+
//! Returns number of frames, if the object is animation
|
| 17 |
+
proto native int GetNumAnimFrames(vobject anim);
|
| 18 |
+
|
| 19 |
+
//! Returns name of visual object
|
| 20 |
+
proto string vtoa(vobject vobj);
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* \defgroup MeshObject Mesh object (XOB)
|
| 24 |
+
* @{
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
proto int GetObjectMaterials(vobject object, string materials[]);
|
| 28 |
+
|
| 29 |
+
// dynamic model creation (for dynamic aabb triggers)
|
| 30 |
+
//proto void CreateModel(IEntity ent, vector mins, vector maxs);
|
| 31 |
+
//proto void RemoveModel(IEntity ent);
|
| 32 |
+
|
| 33 |
+
//! Dynamic MeshObject
|
| 34 |
+
proto vobject CreateXOB(int nsurfaces, int nverts[], int numindices[], string materials[]);
|
| 35 |
+
proto void UpdateVertsEx(notnull IEntity ent, int surf, vector verts[], float uv[]);
|
| 36 |
+
proto void UpdateIndices(vobject obj, int surf, int indices[]);
|
| 37 |
+
|
| 38 |
+
proto native void SetBone(notnull IEntity ent, int bone, vector angles, vector trans, float scale);
|
| 39 |
+
proto native bool SetBoneMatrix(notnull IEntity ent, int bone, vector mat[4]);
|
| 40 |
+
proto native void SetBoneGlobal(notnull IEntity ent, int bone, vector mat[4]);
|
| 41 |
+
proto native bool GetBoneMatrix(notnull IEntity ent, int bone, vector mat[4]);
|
| 42 |
+
proto native bool GetBoneLocalMatrix(notnull IEntity ent, int bone, vector mat[4]);
|
| 43 |
+
|
| 44 |
+
proto native void SetAnimFrame(notnull IEntity ent, int slot, float frame);
|
| 45 |
+
|
| 46 |
+
//! BoneMask == NULL means that all bits are set
|
| 47 |
+
//! WARNING: Non-managed, needs manual delete call, should not be ref'd
|
| 48 |
+
class BoneMask
|
| 49 |
+
{
|
| 50 |
+
int Mask[8]
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
enum AnimFlags
|
| 54 |
+
{
|
| 55 |
+
//! animation is played only once and then if freezes at the last frame. EntityEvent.ANIMEND is called
|
| 56 |
+
ONCE,
|
| 57 |
+
/*! defaultne zustava animace pri prehravani a AF_ONCE po skonceni na posledni frame "zamrzla", dokud neni nahrazena jinou,
|
| 58 |
+
nebo neni kanal vynulovan. Pokud se nastavi AF_BLENDOUT, postara se engine o vyhozeni animace sam a pro preblendovani pouzije hodnotu
|
| 59 |
+
blendout. Pokud je odchycen EOnAnimEnd a byla zmenena animace na jinou, nebo byl kanal rucne vynulovan, tak se tato
|
| 60 |
+
funkcnost neprovede. */
|
| 61 |
+
BLENDOUT,
|
| 62 |
+
|
| 63 |
+
//! animation waits on the first frame. Frame is set by calling SetFrame()
|
| 64 |
+
USER,
|
| 65 |
+
|
| 66 |
+
//! forces animation to start from begining (including blending)
|
| 67 |
+
RESET,
|
| 68 |
+
|
| 69 |
+
/*! defaul framerate is from anim.def. If it is missing, parametr fps applies
|
| 70 |
+
It is possible to use fps parameter even when the framerate is defined in the anim.def, is using this flag
|
| 71 |
+
*/
|
| 72 |
+
FORCEFPS,
|
| 73 |
+
|
| 74 |
+
//! EntityEvent.ANIMEND will not be called
|
| 75 |
+
NOANIMEND,
|
| 76 |
+
|
| 77 |
+
//! Animhooks will not be called
|
| 78 |
+
NOANIMHOOKS
|
| 79 |
+
};
|
| 80 |
+
|
| 81 |
+
proto native void SetAnimSlot(notnull IEntity ent, int slot, vobject anim, float blendin, float blendout, BoneMask mask, int fps, AnimFlags flags);
|
| 82 |
+
|
| 83 |
+
// changes a mask and does the blending if the blendin is set
|
| 84 |
+
proto native void ChangeAnimSlotMask(notnull IEntity ent, int slot, float blendin, BoneMask mask);
|
| 85 |
+
|
| 86 |
+
// changes animation framerate to fps param
|
| 87 |
+
proto native void ChangeAnimSlotFPS(notnull IEntity ent, int slot, int fps);
|
| 88 |
+
|
| 89 |
+
// set mask for a channel. There are 12 chanels and mask is using first for bits 0..3
|
| 90 |
+
proto native void SetAnimMask(notnull IEntity ent, int mask);
|
| 91 |
+
|
| 92 |
+
// clears chanal mask, return bits which were cleared
|
| 93 |
+
proto native int ClearAnimMask(notnull IEntity ent, int mask);
|
| 94 |
+
|
| 95 |
+
//vrati nastavene bity tech kanalu, ktere maji nastavenou animaci, nejsou na konci
|
| 96 |
+
// a pro ktere byla nastavena vstupni maska.
|
| 97 |
+
//Je tim mozno se dotazat na stav vice slotu najednou
|
| 98 |
+
proto native int IsAnimSlotPlaying(notnull IEntity ent, int mask);
|
| 99 |
+
//mask - 16bitu, pro 16 anim slotu. Maximalni hodnota je tedy 0xffff!
|
| 100 |
+
|
| 101 |
+
//sets how much this morph affect object
|
| 102 |
+
proto native bool SetMorphState(notnull IEntity ent, string morph, float value);
|
| 103 |
+
//morph name
|
| 104 |
+
//value 0...1
|
| 105 |
+
//@}
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* \defgroup ParticleEffect Particle effect API
|
| 110 |
+
* @{
|
| 111 |
+
*/
|
| 112 |
+
|
| 113 |
+
enum EmitorParam
|
| 114 |
+
{
|
| 115 |
+
//! Vector3 R/W
|
| 116 |
+
CONEANGLE,
|
| 117 |
+
|
| 118 |
+
//! Vector3 R/W
|
| 119 |
+
EMITOFFSET,
|
| 120 |
+
|
| 121 |
+
//! Float R/W
|
| 122 |
+
VELOCITY,
|
| 123 |
+
|
| 124 |
+
//! Float R/W
|
| 125 |
+
VELOCITY_RND,
|
| 126 |
+
|
| 127 |
+
//! Float R/W
|
| 128 |
+
AVELOCITY,
|
| 129 |
+
|
| 130 |
+
//! Float R/W
|
| 131 |
+
SIZE,
|
| 132 |
+
|
| 133 |
+
//! Float R/W
|
| 134 |
+
STRETCH,
|
| 135 |
+
|
| 136 |
+
//! begin with random rotation. Bool R/W
|
| 137 |
+
RANDOM_ANGLE,
|
| 138 |
+
|
| 139 |
+
//! rotate in random direction. Bool R/W
|
| 140 |
+
RANDOM_ROT,
|
| 141 |
+
|
| 142 |
+
//! Float R/W
|
| 143 |
+
AIR_RESISTANCE,
|
| 144 |
+
|
| 145 |
+
//! Float R/W
|
| 146 |
+
AIR_RESISTANCE_RND,
|
| 147 |
+
|
| 148 |
+
//! Float R/W
|
| 149 |
+
GRAVITY_SCALE,
|
| 150 |
+
|
| 151 |
+
//! Float R/W
|
| 152 |
+
GRAVITY_SCALE_RND,
|
| 153 |
+
|
| 154 |
+
//! Float R/W
|
| 155 |
+
BIRTH_RATE,
|
| 156 |
+
|
| 157 |
+
//! Float R/W
|
| 158 |
+
BIRTH_RATE_RND,
|
| 159 |
+
|
| 160 |
+
//! Float R/W
|
| 161 |
+
LIFETIME,
|
| 162 |
+
|
| 163 |
+
//! Float R/W
|
| 164 |
+
LIFETIME_RND,
|
| 165 |
+
|
| 166 |
+
//! Bool R/W
|
| 167 |
+
LIFETIME_BY_ANIM,
|
| 168 |
+
|
| 169 |
+
//! Bool R/W
|
| 170 |
+
ANIM_ONCE,
|
| 171 |
+
|
| 172 |
+
//! Bool R/W
|
| 173 |
+
RAND_FRAME,
|
| 174 |
+
|
| 175 |
+
//! efector's total time. Float R/W
|
| 176 |
+
EFFECT_TIME,
|
| 177 |
+
|
| 178 |
+
//! should efector repeate after time up? Bool R/W
|
| 179 |
+
REPEAT,
|
| 180 |
+
|
| 181 |
+
//! current efector's time. Float R/W
|
| 182 |
+
CURRENT_TIME,
|
| 183 |
+
|
| 184 |
+
//! number of active particles. Int R
|
| 185 |
+
ACTIVE_PARTICLES,
|
| 186 |
+
|
| 187 |
+
//! Bool R/W
|
| 188 |
+
SORT,
|
| 189 |
+
|
| 190 |
+
//! Bool R/W
|
| 191 |
+
WIND,
|
| 192 |
+
|
| 193 |
+
//! Float R/W
|
| 194 |
+
SPRING
|
| 195 |
+
};
|
| 196 |
+
|
| 197 |
+
// return total count of active particles in all emitors
|
| 198 |
+
// internally does a sum
|
| 199 |
+
// HasActiveParticles is better when just needing to check if there are any active
|
| 200 |
+
proto native int GetParticleCount(notnull IEntity ent);
|
| 201 |
+
|
| 202 |
+
// return if there are any active particles
|
| 203 |
+
proto bool HasActiveParticle(notnull IEntity ent);
|
| 204 |
+
|
| 205 |
+
int ParticleGetCount(IEntity ent)
|
| 206 |
+
{
|
| 207 |
+
return GetParticleCount(ent);
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
bool ParticleHasActive(IEntity ent)
|
| 211 |
+
{
|
| 212 |
+
return HasActiveParticle(ent);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
// gets name of defined emitors in a particle effect
|
| 216 |
+
// return number of emitors and their names in an array (max defines max. emitors to return)
|
| 217 |
+
proto int GetParticleEmitors(notnull IEntity ent, out string emitors[], int max);
|
| 218 |
+
|
| 219 |
+
// return number of emitors
|
| 220 |
+
proto int GetParticleEmitorCount(notnull IEntity ent);
|
| 221 |
+
|
| 222 |
+
// sets a parametr of the particle emitor
|
| 223 |
+
// if the emitor == - 1, it sets the parameter for all emitors
|
| 224 |
+
proto void SetParticleParm(notnull IEntity ent, int emitor, EmitorParam parameter, void value);
|
| 225 |
+
|
| 226 |
+
//gets parameter of particle emitor
|
| 227 |
+
proto void GetParticleParm(notnull IEntity ent, int emitor, EmitorParam parameter, out void value);
|
| 228 |
+
|
| 229 |
+
//gets original parameter of particle emitor
|
| 230 |
+
proto void GetParticleParmOriginal(notnull IEntity ent, int emitor, EmitorParam parameter, out void value);
|
| 231 |
+
|
| 232 |
+
//Force-changes particle emitor position to the current one.
|
| 233 |
+
//Used for sudden changes of particle position to avoid spreading emitted
|
| 234 |
+
//particles between previous and the new one position
|
| 235 |
+
proto native void ResetParticlePosition(notnull IEntity ent);
|
| 236 |
+
|
| 237 |
+
//Restart particle effect to its default state. This means no
|
| 238 |
+
//particles, timer reset and so on. Usefull for implementing
|
| 239 |
+
//particle cache.
|
| 240 |
+
proto native void RestartParticle(notnull IEntity ent);
|
| 241 |
+
//@}
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnWidgets.c
ADDED
|
@@ -0,0 +1,712 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* \defgroup WidgetAPI Widget UI system
|
| 3 |
+
* @{
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
#ifdef DOXYGEN
|
| 7 |
+
/** @name WidgetType
|
| 8 |
+
* Following WidgetType constants are available to script
|
| 9 |
+
*/
|
| 10 |
+
///@{
|
| 11 |
+
|
| 12 |
+
//!Single-line text. See enf::TextWidget
|
| 13 |
+
TextWidgetTypeID,
|
| 14 |
+
//!Multi-line text. See enf::MultilineTextWidget
|
| 15 |
+
MultilineTextWidgetTypeID,
|
| 16 |
+
//!Multi-line edit box. See enf::MultilineTextWidget
|
| 17 |
+
MultilineEditBoxWidgetTypeID,
|
| 18 |
+
//!Multi-line text with images in text. See enf::RichTextWidget
|
| 19 |
+
RichTextWidgetTypeID,
|
| 20 |
+
//! Render target for enf::BaseWorld. See enf::RenderTargetWidget
|
| 21 |
+
RenderTargetWidgetTypeID,
|
| 22 |
+
//! Picture, or multiple picture. See enf::ImageWidget
|
| 23 |
+
ImageWidgetTypeID,
|
| 24 |
+
//!Console. See enf::ConsoleWidget
|
| 25 |
+
ConsoleWidgetTypeID,
|
| 26 |
+
//!Video player. See enf::VideoWidget
|
| 27 |
+
VideoWidgetTypeID,
|
| 28 |
+
//! Texture used as render target for children widgets. See enf::RTTextureWidget
|
| 29 |
+
RTTextureWidgetTypeID,
|
| 30 |
+
//! Dummy frame, used as hierarchy node and clipper
|
| 31 |
+
FrameWidgetTypeID,
|
| 32 |
+
//! Dummy frame, used for embedding another layout and as hierarchy node and clipper
|
| 33 |
+
EmbededWidgetTypeID,
|
| 34 |
+
ButtonWidgetTypeID,
|
| 35 |
+
CheckBoxWidgetTypeID,
|
| 36 |
+
WindowWidgetTypeID,
|
| 37 |
+
ComboBoxWidgetTypeID,
|
| 38 |
+
SimpleProgressBarWidgetTypeID,
|
| 39 |
+
ProgressBarWidgetTypeID,
|
| 40 |
+
SliderWidgetTypeID,
|
| 41 |
+
BaseListboxWidgetTypeID,
|
| 42 |
+
TextListboxWidgetTypeID,
|
| 43 |
+
GenericListboxWidgetTypeID,
|
| 44 |
+
EditBoxWidgetTypeID,
|
| 45 |
+
PasswordEditBoxWidgetTypeID,
|
| 46 |
+
WorkspaceWidgetTypeID,
|
| 47 |
+
GridSpacerWidgetTypeID,
|
| 48 |
+
WrapSpacerWidgetTypeID,
|
| 49 |
+
ScrollWidgetTypeID,
|
| 50 |
+
///@}
|
| 51 |
+
#else
|
| 52 |
+
typedef TypeID WidgetType;
|
| 53 |
+
#endif
|
| 54 |
+
|
| 55 |
+
typedef TypeID EventType;
|
| 56 |
+
|
| 57 |
+
enum WidgetFlags
|
| 58 |
+
{
|
| 59 |
+
SOURCEALPHA, //< takes alpha from texture * alpha from color. If not set, considers texture as non-transparent and transparency is set only by color
|
| 60 |
+
BLEND, //< texture is blended with a surface base on alpha
|
| 61 |
+
ADDITIVE, //< texture is added to a surface based on alpha
|
| 62 |
+
VISIBLE, //<Widget is visible - ShowWidget(w, true)
|
| 63 |
+
NOWRAP, //< Do not do texture wrapping
|
| 64 |
+
CENTER, //< Centers TextWidgetTypeID
|
| 65 |
+
VCENTER, //< Centers TextWidgetTypeID verticaly
|
| 66 |
+
HEXACTPOS,
|
| 67 |
+
VEXACTPOS,
|
| 68 |
+
EXACTPOS, //< Uses physical resolution (g_iWidth, h_iHeight)
|
| 69 |
+
HEXACTSIZE, //< Uses physical resolution (g_iWidth)
|
| 70 |
+
VEXACTSIZE, //< Uses physical resolution (h_iHeight)
|
| 71 |
+
EXACTSIZE, //< Uses physical resolution
|
| 72 |
+
NOFILTER, //< no texture filtering (no blur)
|
| 73 |
+
RALIGN, //< Right alignment TextWidgetTypeID
|
| 74 |
+
STRETCH, //< Stretch texture to a full size
|
| 75 |
+
FLIPU, //< Flips texture in U axis
|
| 76 |
+
FLIPV, //< Flips texture in V axis
|
| 77 |
+
CUSTOMUV, //< ignores STRETCH/FLIPU/FLIPV and take custom UV set by SetWidgetUV()
|
| 78 |
+
IGNOREPOINTER,
|
| 79 |
+
DISABLED,
|
| 80 |
+
NOFOCUS,
|
| 81 |
+
CLIPCHILDREN,
|
| 82 |
+
RENDER_ALWAYS,
|
| 83 |
+
NOCLEAR,
|
| 84 |
+
DRAGGABLE
|
| 85 |
+
};
|
| 86 |
+
|
| 87 |
+
//------------------------------------------
|
| 88 |
+
enum WidgetAlignment
|
| 89 |
+
{
|
| 90 |
+
WA_LEFT = 0,
|
| 91 |
+
WA_RIGHT = 1,
|
| 92 |
+
WA_CENTER = 2,
|
| 93 |
+
WA_TOP = 0,
|
| 94 |
+
WA_BOTTOM = 1,
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
//------------------------------------------
|
| 98 |
+
//! Defined in code
|
| 99 |
+
/*enum LinebreakOverrideMode
|
| 100 |
+
{
|
| 101 |
+
LINEBREAK_DEFAULT,
|
| 102 |
+
LINEBREAK_WESTERN,
|
| 103 |
+
LINEBREAK_ASIAN
|
| 104 |
+
};*/
|
| 105 |
+
|
| 106 |
+
//------------------------------------------
|
| 107 |
+
class Widget: Managed
|
| 108 |
+
{
|
| 109 |
+
proto void ~Widget();
|
| 110 |
+
proto private void Widget();
|
| 111 |
+
|
| 112 |
+
proto static string TranslateString(string stringId);
|
| 113 |
+
|
| 114 |
+
//! Set global LV of widgets, value between [-15, 0], default: 0, lower value is less bright
|
| 115 |
+
proto static void SetLV(float lv);
|
| 116 |
+
//! Set global LV of the text in widgets, value between [-15, 0], default: 0, lower value is less bright
|
| 117 |
+
proto static void SetTextLV(float lv);
|
| 118 |
+
//! Set global lighting of objects in widgets, value between [0, 1], default: 1, lower value is less bright
|
| 119 |
+
proto static void SetObjectLighting(float lighting);
|
| 120 |
+
|
| 121 |
+
proto native owned string GetName();
|
| 122 |
+
proto native void SetName(string name);
|
| 123 |
+
proto native owned string GetTypeName();
|
| 124 |
+
proto native WidgetType GetTypeID();
|
| 125 |
+
proto native void Show(bool show, bool immedUpdate = true);
|
| 126 |
+
proto native void Enable(bool enable);
|
| 127 |
+
proto native int GetFlags();
|
| 128 |
+
proto native int SetFlags(int flags, bool immedUpdate = true);
|
| 129 |
+
proto native int GetSort();
|
| 130 |
+
proto native void SetSort(int sort, bool immedUpdate = true);
|
| 131 |
+
proto native int ClearFlags(int flags, bool immedUpdate = true);
|
| 132 |
+
proto native bool IsControlClass();
|
| 133 |
+
proto native owned string GetStyleName();
|
| 134 |
+
proto void GetUserData(out Class data);
|
| 135 |
+
proto native void SetUserData(Class data);
|
| 136 |
+
proto native int GetUserID();
|
| 137 |
+
proto native void SetUserID(int id);
|
| 138 |
+
proto native bool IsVisible();
|
| 139 |
+
proto native bool IsVisibleHierarchy();
|
| 140 |
+
proto native void SetPos(float x, float y, bool immedUpdate = true);
|
| 141 |
+
proto native void SetSize(float w, float h, bool immedUpdate = true);
|
| 142 |
+
proto native void SetScreenPos(float x, float y, bool immedUpdate = true);
|
| 143 |
+
proto native void SetScreenSize(float w, float h, bool immedUpdate = true);
|
| 144 |
+
proto native void SetColor(int color);
|
| 145 |
+
proto native int GetColor();
|
| 146 |
+
proto native void SetRotation(float roll, float pitch, float yaw, bool immedUpdate = true);
|
| 147 |
+
//! returns rotation of widget in order roll, pitch, yaw
|
| 148 |
+
proto native vector GetRotation();
|
| 149 |
+
proto native void SetAlpha(float alpha);
|
| 150 |
+
proto native float GetAlpha();
|
| 151 |
+
proto void GetPos(out float x, out float y);
|
| 152 |
+
proto void GetSize(out float width, out float height);
|
| 153 |
+
proto void GetScreenPos(out float x, out float y);
|
| 154 |
+
proto void GetScreenSize(out float width, out float height);
|
| 155 |
+
|
| 156 |
+
proto native void SetTransform(vector mat[4], bool immedUpdate = true);
|
| 157 |
+
|
| 158 |
+
proto native Widget GetParent();
|
| 159 |
+
proto native Widget GetChildren();
|
| 160 |
+
proto native Widget GetSibling();
|
| 161 |
+
proto native void AddChild(Widget child, bool immedUpdate = true);
|
| 162 |
+
proto native void RemoveChild(Widget child);
|
| 163 |
+
|
| 164 |
+
proto native volatile void Update();
|
| 165 |
+
|
| 166 |
+
proto void GetScript(out Class data);
|
| 167 |
+
|
| 168 |
+
proto native Widget FindWidget(string pathname); //find Widget by path. e.g FindWidget("widget1.widget2.widget3.mywidget")
|
| 169 |
+
proto native Widget FindAnyWidget(string pathname); //find Widget by name e.g. FindWidget("widget1")
|
| 170 |
+
proto native Widget FindAnyWidgetById(int user_id); //find Widget by userID
|
| 171 |
+
|
| 172 |
+
proto native void SetHandler(ScriptedWidgetEventHandler eventHandler);
|
| 173 |
+
proto native void Unlink(); //destroys widget and all its children
|
| 174 |
+
};
|
| 175 |
+
|
| 176 |
+
class WorkspaceWidget: Widget
|
| 177 |
+
{
|
| 178 |
+
//!Create widgets by \ref WidgetType
|
| 179 |
+
proto native external Widget CreateWidget(WidgetType type, int left, int top, int width, int height, WidgetFlags flags, int color, int sort, Widget parentWidget = NULL);
|
| 180 |
+
//!Create widgets from *.layout file
|
| 181 |
+
proto native external Widget CreateWidgets(string layout, Widget parentWidget = NULL, bool immedUpdate = true);
|
| 182 |
+
};
|
| 183 |
+
|
| 184 |
+
proto native Widget GetWidgetUnderCursor();
|
| 185 |
+
proto native Widget CancelWidgetDragging();
|
| 186 |
+
proto native Widget GetDragWidget();
|
| 187 |
+
proto native void ReportMouse(int mousex, int mousey, Widget rootWidget);
|
| 188 |
+
|
| 189 |
+
class TextWidget extends Widget
|
| 190 |
+
{
|
| 191 |
+
proto native void SetTextSpacing(int horiz, int vert);
|
| 192 |
+
//! set text exact size. Exact Text flag must be enabled. 0 equals original size.
|
| 193 |
+
proto native void SetTextExactSize(int size);
|
| 194 |
+
proto native void SetTextOffset(int left, int top);
|
| 195 |
+
proto native void SetText(string text, bool immedUpdate = true);
|
| 196 |
+
proto native void SetOutline(int outlineSize, int argb = 0xFF000000);
|
| 197 |
+
proto native int GetOutlineSize();
|
| 198 |
+
proto native int GetOutlineColor();
|
| 199 |
+
proto native void SetShadow(int shadowSize, int shadowARGB = 0xFF000000, float shadowOpacity = 1, float shadowOffsetX = 0, float shadowOffsetY = 0);
|
| 200 |
+
proto native int GetShadowSize();
|
| 201 |
+
proto native int GetShadowColor();
|
| 202 |
+
proto native float GetShadowOpacity();
|
| 203 |
+
proto void GetShadowOffset(out float sx, out float sy);
|
| 204 |
+
proto native void SetItalic(bool italic);
|
| 205 |
+
proto native bool GetItalic();
|
| 206 |
+
proto native void SetBold(bool bold);
|
| 207 |
+
proto native bool GetBold();
|
| 208 |
+
|
| 209 |
+
//! Returns text size in pixels
|
| 210 |
+
proto void GetTextSize(out int sx, out int sy);
|
| 211 |
+
proto void SetTextFormat(string text, void param1 = NULL, void param2 = NULL, void param3 = NULL, void param4 = NULL, void param5 = NULL, void param6 = NULL, void param7 = NULL, void param8 = NULL, void param9 = NULL);
|
| 212 |
+
|
| 213 |
+
//! Get text proportion - ratio between button height and button text height in interval <0,1>
|
| 214 |
+
proto native float GetTextProportion();
|
| 215 |
+
//! Set text proportion - ratio between button height and button text height in interval <0,1>
|
| 216 |
+
proto native void SetTextProportion(float val);
|
| 217 |
+
};
|
| 218 |
+
|
| 219 |
+
class MultilineTextWidget extends TextWidget
|
| 220 |
+
{
|
| 221 |
+
proto native float SetLineBreakingOverride(int mode);
|
| 222 |
+
};
|
| 223 |
+
|
| 224 |
+
class RichTextWidget extends TextWidget
|
| 225 |
+
{
|
| 226 |
+
proto native float GetContentHeight();
|
| 227 |
+
proto native float GetContentOffset();
|
| 228 |
+
proto native void SetContentOffset(float offset, bool snapToLine = false);
|
| 229 |
+
proto native void ElideText(int line, float maxWidth, string str);
|
| 230 |
+
proto native int GetNumLines();
|
| 231 |
+
proto native void SetLinesVisibility(int lineFrom, int lineTo, bool visible);
|
| 232 |
+
proto native float GetLineWidth(int line);
|
| 233 |
+
proto native float SetLineBreakingOverride(int mode);
|
| 234 |
+
};
|
| 235 |
+
|
| 236 |
+
class RenderTargetWidget extends Widget
|
| 237 |
+
{
|
| 238 |
+
//!when period > 1 then every n-th frame will be rendered. Offset is initial counter.
|
| 239 |
+
proto native void SetRefresh(int period, int offset);
|
| 240 |
+
proto native void SetResolutionScale(float xscale, float ycale);
|
| 241 |
+
};
|
| 242 |
+
|
| 243 |
+
class RTTextureWidget extends Widget
|
| 244 |
+
{
|
| 245 |
+
};
|
| 246 |
+
|
| 247 |
+
class ImageWidget extends Widget
|
| 248 |
+
{
|
| 249 |
+
/*!
|
| 250 |
+
Loads image. When image of this 'num' is already loaded, then is replaced
|
| 251 |
+
by new one.
|
| 252 |
+
\param num Number of image (0...7)
|
| 253 |
+
\param name Name of image file
|
| 254 |
+
\param noCache Do not cache the texture
|
| 255 |
+
\return True when image is loaded, false otherwise
|
| 256 |
+
*/
|
| 257 |
+
proto native bool LoadImageFile(int num, string name, bool noCache = false);
|
| 258 |
+
proto native void SetImageTexture(int image, RTTextureWidget texture);
|
| 259 |
+
//! returns size of image
|
| 260 |
+
proto void GetImageSize(int image, out int sx, out int sy);
|
| 261 |
+
|
| 262 |
+
/*!
|
| 263 |
+
Switches to another image, if it's loaded
|
| 264 |
+
\param num Number of image.
|
| 265 |
+
\return True when there is such image, false otherwise.
|
| 266 |
+
*/
|
| 267 |
+
proto native bool SetImage(int num);
|
| 268 |
+
//!Returns active image
|
| 269 |
+
proto native int GetImage();
|
| 270 |
+
/*!
|
| 271 |
+
When WF_CUSTOMUV is set, we can supply our own UV coords instead of computed ones.
|
| 272 |
+
\param uv
|
| 273 |
+
Pointer to array of at least 8 floats (4 corners * 2 floats for u/v)
|
| 274 |
+
*/
|
| 275 |
+
proto native void SetUV(float uv[4][2]);
|
| 276 |
+
|
| 277 |
+
/*!
|
| 278 |
+
Loads texture as mask used for alpha masking.
|
| 279 |
+
\param resource Resource name of the texture to load
|
| 280 |
+
\return True if texture was successfully loaded, false otherwise
|
| 281 |
+
*/
|
| 282 |
+
proto native bool LoadMaskTexture(string resource);
|
| 283 |
+
|
| 284 |
+
/*!
|
| 285 |
+
Progress determines which alpha values are opaque using the mask. For progress x,
|
| 286 |
+
pixels with alpha in mask < x will be opaque and alpha in mask > x will be transparent.
|
| 287 |
+
For smooth transition see GetMaskTransitionWidth.
|
| 288 |
+
\return Progress from 0 to 1 representing alpha range which is visible in the mask
|
| 289 |
+
*/
|
| 290 |
+
proto native float GetMaskProgress();
|
| 291 |
+
|
| 292 |
+
/*!
|
| 293 |
+
See GetMaskProgress for explanation.
|
| 294 |
+
\param value Expected in range [0; 1]
|
| 295 |
+
*/
|
| 296 |
+
proto native void SetMaskProgress(float value);
|
| 297 |
+
|
| 298 |
+
/*!
|
| 299 |
+
Transition width 0.1 and progress 0.2 mean that values in mask lower than progress will be opaque.
|
| 300 |
+
Values higher than (progress + width) will be transparent and values between progress and (progress + width)
|
| 301 |
+
will be smoothly transitioned.
|
| 302 |
+
\return Width of the alpha mask transition representing softness of the transition.
|
| 303 |
+
*/
|
| 304 |
+
proto native float GetMaskTransitionWidth();
|
| 305 |
+
|
| 306 |
+
/*!
|
| 307 |
+
See GetMaskTransitionWidth for transition width explanation.
|
| 308 |
+
\param value Expected in range [0; 1]
|
| 309 |
+
*/
|
| 310 |
+
proto native void SetMaskTransitionWidth(float value);
|
| 311 |
+
};
|
| 312 |
+
|
| 313 |
+
class MultilineEditBoxWidget extends TextWidget
|
| 314 |
+
{
|
| 315 |
+
proto native int GetLinesCount();
|
| 316 |
+
proto native int GetCarriageLine();
|
| 317 |
+
proto native int GetCarriagePos();
|
| 318 |
+
proto void GetText(out string text);
|
| 319 |
+
proto native void SetLine(int line, string text);
|
| 320 |
+
proto void GetLine(int line, out string text);
|
| 321 |
+
};
|
| 322 |
+
|
| 323 |
+
class UIWidget extends Widget
|
| 324 |
+
{
|
| 325 |
+
proto native void SetTextColor(int color);
|
| 326 |
+
proto native void SetTextOutline(int outlineSize, int argb = 0xFF000000);
|
| 327 |
+
proto native int GetTextOutlineSize();
|
| 328 |
+
proto native int GetTextOutlineColor();
|
| 329 |
+
proto native void SetTextShadow(int shadowSize, int shadowARGB = 0xFF000000, float shadowOpacity = 1.0, float shadowOffsetX = 0.0, float shadowOffsetY = 0.0);
|
| 330 |
+
proto native int GetTextShadowSize();
|
| 331 |
+
proto native int GetTextShadowColor();
|
| 332 |
+
proto native float GetTextShadowOpacity();
|
| 333 |
+
proto native float GetTextShadowOffsetX();
|
| 334 |
+
proto native float GetTextShadowOffsetY();
|
| 335 |
+
proto native void SetTextItalic(bool italic);
|
| 336 |
+
proto native bool GetTextItalic();
|
| 337 |
+
proto native void SetTextBold(bool bold);
|
| 338 |
+
proto native bool GetTextBold();
|
| 339 |
+
};
|
| 340 |
+
|
| 341 |
+
class CanvasWidget extends Widget
|
| 342 |
+
{
|
| 343 |
+
proto native void DrawLine(float x1, float y1, float x2, float y2, float width, int color);
|
| 344 |
+
proto native void Clear();
|
| 345 |
+
};
|
| 346 |
+
|
| 347 |
+
class EditBoxWidget extends UIWidget
|
| 348 |
+
{
|
| 349 |
+
proto string GetText();
|
| 350 |
+
proto native void SetText(string str);
|
| 351 |
+
};
|
| 352 |
+
|
| 353 |
+
class PasswordEditBoxWidget extends EditBoxWidget
|
| 354 |
+
{
|
| 355 |
+
proto native void SetHideText(bool hide);
|
| 356 |
+
};
|
| 357 |
+
|
| 358 |
+
class SliderWidget extends UIWidget
|
| 359 |
+
{
|
| 360 |
+
proto native void SetMinMax(float minimum, float maximum);
|
| 361 |
+
proto native float GetMin();
|
| 362 |
+
proto native float GetMax();
|
| 363 |
+
proto native float GetCurrent();
|
| 364 |
+
proto native void SetCurrent(float curr);
|
| 365 |
+
proto native float GetStep();
|
| 366 |
+
proto native void SetStep(float step);
|
| 367 |
+
};
|
| 368 |
+
|
| 369 |
+
class SimpleProgressBarWidget extends UIWidget
|
| 370 |
+
{
|
| 371 |
+
proto native float GetMin();
|
| 372 |
+
proto native float GetMax();
|
| 373 |
+
proto native float GetCurrent();
|
| 374 |
+
proto native void SetCurrent(float curr);
|
| 375 |
+
};
|
| 376 |
+
|
| 377 |
+
class ProgressBarWidget extends SimpleProgressBarWidget
|
| 378 |
+
{
|
| 379 |
+
};
|
| 380 |
+
|
| 381 |
+
class ButtonWidget extends UIWidget
|
| 382 |
+
{
|
| 383 |
+
proto native bool GetState();
|
| 384 |
+
|
| 385 |
+
proto native bool SetState(bool state);
|
| 386 |
+
|
| 387 |
+
proto native void SetText(string text);
|
| 388 |
+
|
| 389 |
+
proto void GetText(out string text);
|
| 390 |
+
|
| 391 |
+
proto native void SetTextOffset(float xoffset, float yoffset);
|
| 392 |
+
/**
|
| 393 |
+
\param align ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT
|
| 394 |
+
*/
|
| 395 |
+
proto native void SetTextHorizontalAlignment(int align);
|
| 396 |
+
/**
|
| 397 |
+
\param align ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM
|
| 398 |
+
*/
|
| 399 |
+
proto native void SetTextVerticalAlignment(int align);
|
| 400 |
+
|
| 401 |
+
//! Get text proportion - ratio between button height and button text height in interval <0,1>
|
| 402 |
+
proto native float GetTextProportion();
|
| 403 |
+
//! Set text proportion - ratio between button height and button text height in interval <0,1>
|
| 404 |
+
proto native void SetTextProportion(float val);
|
| 405 |
+
};
|
| 406 |
+
|
| 407 |
+
class XComboBoxWidget extends UIWidget
|
| 408 |
+
{
|
| 409 |
+
proto native int AddItem(string item);
|
| 410 |
+
proto native void ClearAll();
|
| 411 |
+
proto native void SetItem(int item, string value);
|
| 412 |
+
proto native void RemoveItem(int item);
|
| 413 |
+
proto native int GetNumItems();
|
| 414 |
+
proto native int SetCurrentItem(int n);
|
| 415 |
+
proto native int GetCurrentItem();
|
| 416 |
+
};
|
| 417 |
+
|
| 418 |
+
class CheckBoxWidget extends UIWidget
|
| 419 |
+
{
|
| 420 |
+
proto native void SetText(string str);
|
| 421 |
+
proto native bool IsChecked();
|
| 422 |
+
proto native void SetChecked(bool checked);
|
| 423 |
+
};
|
| 424 |
+
|
| 425 |
+
class BaseListboxWidget extends UIWidget
|
| 426 |
+
{
|
| 427 |
+
proto native void ClearItems();
|
| 428 |
+
proto native int GetNumItems();
|
| 429 |
+
proto native void SelectRow(int row);
|
| 430 |
+
proto native int GetSelectedRow();
|
| 431 |
+
proto native void RemoveRow(int row);
|
| 432 |
+
proto native void EnsureVisible(int row);
|
| 433 |
+
};
|
| 434 |
+
|
| 435 |
+
class SimpleListboxWidget extends BaseListboxWidget
|
| 436 |
+
{
|
| 437 |
+
};
|
| 438 |
+
|
| 439 |
+
class TextListboxWidget extends SimpleListboxWidget
|
| 440 |
+
{
|
| 441 |
+
//! Insert new Row, if row = -1, new Row is inserted at the end otherwise at row index.
|
| 442 |
+
proto native int AddItem(string text, Class userData, int column, int row = -1);
|
| 443 |
+
proto native void SetItem(int position, string text, Class userData, int column);
|
| 444 |
+
/**
|
| 445 |
+
\brief Get item
|
| 446 |
+
\param row \p int Index of row
|
| 447 |
+
\param column \p int Index of column
|
| 448 |
+
\return \p string Value in widget on row and column
|
| 449 |
+
@code
|
| 450 |
+
string value;
|
| 451 |
+
textListboxWidg.GetItemText(2, 0, value);
|
| 452 |
+
@endcode
|
| 453 |
+
*/
|
| 454 |
+
proto bool GetItemText(int row, int column, out string text);
|
| 455 |
+
proto void GetItemData(int row, int column, out Class data);
|
| 456 |
+
|
| 457 |
+
proto native void SetItemColor(int row, int column, int color );
|
| 458 |
+
};
|
| 459 |
+
|
| 460 |
+
class SpacerBaseWidget extends UIWidget
|
| 461 |
+
{
|
| 462 |
+
proto native void AddChildAfter(Widget child,Widget after, bool immedUpdate = true);
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
class SpacerWidget extends SpacerBaseWidget
|
| 466 |
+
{
|
| 467 |
+
proto native WidgetAlignment GetContentAlignmentH();
|
| 468 |
+
proto native void SetContentAlignmentH(WidgetAlignment alignment);
|
| 469 |
+
proto native WidgetAlignment GetContentAlignmentV();
|
| 470 |
+
proto native void SetContentAlignmentV(WidgetAlignment alignment);
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
class GridSpacerWidget extends SpacerWidget
|
| 474 |
+
{
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
class WrapSpacerWidget extends SpacerWidget
|
| 478 |
+
{
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
class ScrollWidget extends SpacerBaseWidget
|
| 482 |
+
{
|
| 483 |
+
proto native float GetScrollbarWidth();
|
| 484 |
+
proto native bool IsScrollbarVisible(); //reflects native C++ side scrollbar state
|
| 485 |
+
|
| 486 |
+
proto native float GetContentWidth();
|
| 487 |
+
proto native float GetContentHeight();
|
| 488 |
+
|
| 489 |
+
proto native float GetHScrollPos();
|
| 490 |
+
proto native float GetHScrollPos01();
|
| 491 |
+
proto native bool HScrollStep(int steps);
|
| 492 |
+
proto native void HScrollToPos(float pos);
|
| 493 |
+
proto native void HScrollToPos01(float pos01);
|
| 494 |
+
proto native void HScrollToWidget(Widget child);
|
| 495 |
+
|
| 496 |
+
proto native float GetVScrollPos();
|
| 497 |
+
proto native float GetVScrollPos01();
|
| 498 |
+
proto native bool VScrollStep(int steps);
|
| 499 |
+
proto native void VScrollToPos(float pos);
|
| 500 |
+
proto native void VScrollToPos01(float pos01);
|
| 501 |
+
proto native void VScrollToWidget(Widget child);
|
| 502 |
+
};
|
| 503 |
+
|
| 504 |
+
//! Legacy, do not use
|
| 505 |
+
enum VideoCommand
|
| 506 |
+
{
|
| 507 |
+
PLAY,
|
| 508 |
+
STOP,
|
| 509 |
+
REWIND,
|
| 510 |
+
POSITION,
|
| 511 |
+
REPEAT,
|
| 512 |
+
ISPLAYING,
|
| 513 |
+
KILL
|
| 514 |
+
};
|
| 515 |
+
|
| 516 |
+
enum VideoState
|
| 517 |
+
{
|
| 518 |
+
//! There is no video
|
| 519 |
+
NONE,
|
| 520 |
+
//! The video is playing
|
| 521 |
+
PLAYING,
|
| 522 |
+
//! The video is paused
|
| 523 |
+
PAUSED,
|
| 524 |
+
//! The video is paused at the beginning of the video
|
| 525 |
+
STOPPED,
|
| 526 |
+
//! The video is paused at the end of the video
|
| 527 |
+
FINISHED,
|
| 528 |
+
};
|
| 529 |
+
|
| 530 |
+
enum VideoCallback
|
| 531 |
+
{
|
| 532 |
+
ON_PLAY,
|
| 533 |
+
ON_PAUSE,
|
| 534 |
+
ON_STOP,
|
| 535 |
+
ON_END,
|
| 536 |
+
ON_LOAD,
|
| 537 |
+
ON_SEEK,
|
| 538 |
+
ON_BUFFERING_START,
|
| 539 |
+
ON_BUFFERING_END,
|
| 540 |
+
};
|
| 541 |
+
|
| 542 |
+
class VideoWidget extends Widget
|
| 543 |
+
{
|
| 544 |
+
//! Load a video file
|
| 545 |
+
proto native bool Load(string name, bool looping = false, int startTime = 0);
|
| 546 |
+
//! Unload the video, freeing up all resources
|
| 547 |
+
proto native void Unload();
|
| 548 |
+
|
| 549 |
+
//! Starts video playback
|
| 550 |
+
proto native bool Play();
|
| 551 |
+
//! Pauses video playback
|
| 552 |
+
proto native bool Pause();
|
| 553 |
+
//! Stop video playback (cancels everything and sets it back at time 0)
|
| 554 |
+
proto native bool Stop();
|
| 555 |
+
|
| 556 |
+
//! Set the desired time for the video (preload decides whether it will already load the next frames too)
|
| 557 |
+
proto native bool SetTime(int time, bool preload);
|
| 558 |
+
//! Get the current time of the video
|
| 559 |
+
proto native int GetTime();
|
| 560 |
+
//! Get the total time of the video
|
| 561 |
+
proto native int GetTotalTime();
|
| 562 |
+
|
| 563 |
+
//! Set whether the video should loop
|
| 564 |
+
proto native void SetLooping(bool looping);
|
| 565 |
+
//! Whether looping is enabled
|
| 566 |
+
proto native bool IsLooping();
|
| 567 |
+
|
| 568 |
+
//! QoL direct method to check for playing state (buffering while playing will still return true)
|
| 569 |
+
proto native bool IsPlaying();
|
| 570 |
+
//! Get the current state of the video
|
| 571 |
+
proto native VideoState GetState();
|
| 572 |
+
|
| 573 |
+
/**
|
| 574 |
+
\brief Enable/Disable subtitles
|
| 575 |
+
\warning Subtitles need font to be assigned to VideoWidget in layout to work
|
| 576 |
+
\note Subtitles are in the format "videoName_Language.srt"
|
| 577 |
+
\note It is best to have the English one without language specified "videoName.srt"
|
| 578 |
+
*/
|
| 579 |
+
proto native void DisableSubtitles(bool disable);
|
| 580 |
+
//! Check if subtitles are disabled (enabled by default if available, so it will return false even if there are none)
|
| 581 |
+
proto native bool IsSubtitlesDisabled();
|
| 582 |
+
|
| 583 |
+
//! Set a callback for a certain video event
|
| 584 |
+
proto void SetCallback(VideoCallback cb, func fn);
|
| 585 |
+
|
| 586 |
+
//! Legacy, preferably not used, left for backwards compat
|
| 587 |
+
int Play(VideoCommand cmd)
|
| 588 |
+
{
|
| 589 |
+
// Yes, some things here do not do what the name implies
|
| 590 |
+
// And it returns 0 whether successful or not
|
| 591 |
+
// But this is what the old functionality looked like
|
| 592 |
+
// So for true backwards compat, it will be left like this
|
| 593 |
+
switch (cmd)
|
| 594 |
+
{
|
| 595 |
+
case VideoCommand.PLAY:
|
| 596 |
+
Play();
|
| 597 |
+
break;
|
| 598 |
+
case VideoCommand.STOP:
|
| 599 |
+
Pause();
|
| 600 |
+
break;
|
| 601 |
+
case VideoCommand.REWIND:
|
| 602 |
+
SetTime(0, true);
|
| 603 |
+
break;
|
| 604 |
+
case VideoCommand.POSITION:
|
| 605 |
+
return GetTime();
|
| 606 |
+
case VideoCommand.REPEAT:
|
| 607 |
+
SetLooping(true);
|
| 608 |
+
break;
|
| 609 |
+
case VideoCommand.ISPLAYING:
|
| 610 |
+
return IsPlaying();
|
| 611 |
+
case VideoCommand.KILL:
|
| 612 |
+
Unload();
|
| 613 |
+
break;
|
| 614 |
+
default:
|
| 615 |
+
return 0;
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
return 0;
|
| 619 |
+
}
|
| 620 |
+
|
| 621 |
+
//! Legacy, preferably not used, left for backwards compat
|
| 622 |
+
bool LoadVideo(string name, int soundScene)
|
| 623 |
+
{
|
| 624 |
+
return Load(name);
|
| 625 |
+
}
|
| 626 |
+
};
|
| 627 |
+
|
| 628 |
+
/*! sets Widget typu RTTextureWidgetTypeID, to which it is possible to reference in shader as $rendertarget
|
| 629 |
+
it is posible to use only after object selection. When selecting another object, it is necessary to set GUI widget again
|
| 630 |
+
*/
|
| 631 |
+
proto native void SetGUIWidget(IEntity ent, int index, RTTextureWidget w);
|
| 632 |
+
|
| 633 |
+
enum ControlID
|
| 634 |
+
{
|
| 635 |
+
CID_NONE = 0,
|
| 636 |
+
CID_SELECT = 1,//select/use focused
|
| 637 |
+
CID_BACK,
|
| 638 |
+
CID_LEFT, //navigation
|
| 639 |
+
CID_RIGHT,
|
| 640 |
+
CID_UP,
|
| 641 |
+
CID_DOWN,
|
| 642 |
+
CID_MENU, //get to main menu
|
| 643 |
+
CID_DRAG, //probably needed only for consoles
|
| 644 |
+
CID_TABLEFT,
|
| 645 |
+
CID_TABRIGHT,
|
| 646 |
+
CID_RADIALMENU,
|
| 647 |
+
CID_COUNT
|
| 648 |
+
};
|
| 649 |
+
|
| 650 |
+
class ScriptedWidgetEventHandler: Managed
|
| 651 |
+
{
|
| 652 |
+
bool OnClick(Widget w, int x, int y, int button);
|
| 653 |
+
bool OnModalResult(Widget w, int x, int y, int code, int result);
|
| 654 |
+
bool OnDoubleClick(Widget w, int x, int y, int button);
|
| 655 |
+
bool OnSelect(Widget w, int x, int y);
|
| 656 |
+
bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn);
|
| 657 |
+
bool OnFocus(Widget w, int x, int y);
|
| 658 |
+
bool OnFocusLost(Widget w, int x, int y);
|
| 659 |
+
bool OnMouseEnter(Widget w, int x, int y);
|
| 660 |
+
bool OnMouseLeave(Widget w, Widget enterW, int x, int y);
|
| 661 |
+
bool OnMouseWheel(Widget w, int x, int y, int wheel);
|
| 662 |
+
bool OnMouseButtonDown(Widget w, int x, int y, int button);
|
| 663 |
+
bool OnMouseButtonUp(Widget w, int x, int y, int button);
|
| 664 |
+
//! control is one of ControlID
|
| 665 |
+
bool OnController(Widget w, int control, int value);
|
| 666 |
+
bool OnKeyDown(Widget w, int x, int y, int key);
|
| 667 |
+
bool OnKeyUp(Widget w, int x, int y, int key);
|
| 668 |
+
bool OnKeyPress(Widget w, int x, int y, int key);
|
| 669 |
+
bool OnChange(Widget w, int x, int y, bool finished);
|
| 670 |
+
bool OnDrag(Widget w, int x, int y);
|
| 671 |
+
bool OnDragging(Widget w, int x, int y, Widget reciever);
|
| 672 |
+
bool OnDraggingOver(Widget w, int x, int y, Widget reciever);
|
| 673 |
+
bool OnDrop(Widget w, int x, int y, Widget reciever);
|
| 674 |
+
bool OnDropReceived(Widget w, int x, int y, Widget reciever);
|
| 675 |
+
bool OnResize(Widget w, int x, int y);
|
| 676 |
+
bool OnChildAdd(Widget w, Widget child);
|
| 677 |
+
bool OnChildRemove(Widget w, Widget child);
|
| 678 |
+
bool OnUpdate(Widget w);
|
| 679 |
+
bool OnEvent(EventType eventType, Widget target, int parameter0, int parameter1);
|
| 680 |
+
};
|
| 681 |
+
|
| 682 |
+
//Common Widget API
|
| 683 |
+
proto native void SetCursorWidget(Widget cursor);
|
| 684 |
+
//! direct mouse cursor visibility control
|
| 685 |
+
proto native void ShowCursorWidget(bool show);
|
| 686 |
+
proto native bool LoadWidgetImageSet(string filename);
|
| 687 |
+
proto native void LoadWidgetStyles(string filename);
|
| 688 |
+
// sets active window (widget which owns some control inputs like buttons, listboxes etc.). Necessary for controlling the focus by keyboard/joypad. In case when setFocus is set to true, it sets focus on a first child Widget, which may receive the focus (is not disabled, set as NoFocus etc.)
|
| 689 |
+
proto native bool SetActiveWindow(Widget w, bool resetFocus);
|
| 690 |
+
|
| 691 |
+
// sets focus (necessary when using keyboard/joyped) to a particular widget. Widget must have some inputs like button, listbox, checkbox, combobox etc.
|
| 692 |
+
proto native void SetFocus(Widget w);
|
| 693 |
+
|
| 694 |
+
proto native void SetModal(Widget w);
|
| 695 |
+
|
| 696 |
+
proto native Widget GetFocus();
|
| 697 |
+
|
| 698 |
+
//RenderTargetWidgetTypeID
|
| 699 |
+
proto native void SetWidgetWorld(RenderTargetWidget w, IEntity wrldEntity, int camera);
|
| 700 |
+
|
| 701 |
+
|
| 702 |
+
#ifdef PS3
|
| 703 |
+
/*!
|
| 704 |
+
circle and cross can be swapped when license area is japan/asia
|
| 705 |
+
*/
|
| 706 |
+
proto native bool IsCircleToCrossSwapped();
|
| 707 |
+
#endif
|
| 708 |
+
|
| 709 |
+
proto native bool ReloadTexture(string path);
|
| 710 |
+
|
| 711 |
+
|
| 712 |
+
//@}
|
scripts/1_Core/DayZ/proto/EnWorld.c
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** /**
|
| 2 |
+
* \defgroup World World
|
| 3 |
+
* @{
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
//----------------------------------------------
|
| 7 |
+
/**
|
| 8 |
+
* \defgroup WorldCommon World
|
| 9 |
+
* @{
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
typedef int[] WorldHandle;
|
| 13 |
+
|
| 14 |
+
proto native float GetWorldTime();
|
| 15 |
+
|
| 16 |
+
/*! Sets current world. It allows to work with entities outside world processing
|
| 17 |
+
// return previous world
|
| 18 |
+
*/
|
| 19 |
+
proto native WorldHandle SetCurrentWorld(WorldHandle world);
|
| 20 |
+
|
| 21 |
+
//proto native void SchedulePreload(vector pos, float radius);
|
| 22 |
+
|
| 23 |
+
proto native IEntity FindEntityByName(IEntity worldEnt, string name);
|
| 24 |
+
proto native IEntity FindEntityByID(IEntity worldEnt, int ID);
|
| 25 |
+
|
| 26 |
+
//!returns number of active (simulated) Entities in the world
|
| 27 |
+
proto native int GetNumActiveEntities(IEntity worldEntity);
|
| 28 |
+
//!returns active entity
|
| 29 |
+
proto native IEntity GetActiveEntity(IEntity worldEntity, int index);
|
| 30 |
+
//@}
|
| 31 |
+
|
| 32 |
+
//----------------------------------------------
|
| 33 |
+
/**
|
| 34 |
+
* \defgroup Camera Camera
|
| 35 |
+
* @{
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
enum CameraType
|
| 39 |
+
{
|
| 40 |
+
PERSPECTIVE,
|
| 41 |
+
ORTHOGRAPHIC
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
//! sets which camera will be a listener (for sound engine)
|
| 45 |
+
proto native void SetListenerCamera(int camera);
|
| 46 |
+
|
| 47 |
+
/*!
|
| 48 |
+
Changes camera position
|
| 49 |
+
\param cam Index of camera
|
| 50 |
+
\param origin position
|
| 51 |
+
\param angle orientation
|
| 52 |
+
*/
|
| 53 |
+
proto native void SetCamera(int cam, vector origin, vector angle);
|
| 54 |
+
|
| 55 |
+
//! Changes camera matrix
|
| 56 |
+
proto native void SetCameraEx(int cam, const vector mat[4]);
|
| 57 |
+
|
| 58 |
+
//!Returns current camera transformation
|
| 59 |
+
proto native void GetCamera(int cam, out vector mat[4]);
|
| 60 |
+
|
| 61 |
+
proto native void SetCameraVerticalFOV(int cam, float fovy);
|
| 62 |
+
proto native void SetCameraFarPlane(int cam, float farplane); //default 160000 units
|
| 63 |
+
proto native void SetCameraNearPlane(int cam, float nearplane); //default 5 units
|
| 64 |
+
|
| 65 |
+
proto native void SetCameraType(int cam, CameraType type);
|
| 66 |
+
|
| 67 |
+
/*!
|
| 68 |
+
\brief Post-process effect type.
|
| 69 |
+
\attention Keep enum names in synch with post-process effect material class names. Postfix "Effect" is appended automatically.
|
| 70 |
+
*/
|
| 71 |
+
enum PostProcessEffectType
|
| 72 |
+
{
|
| 73 |
+
None,
|
| 74 |
+
UnderWater,
|
| 75 |
+
SSAO,
|
| 76 |
+
DepthOfField,
|
| 77 |
+
HBAO,
|
| 78 |
+
RotBlur,
|
| 79 |
+
GodRays,
|
| 80 |
+
Rain,
|
| 81 |
+
FilmGrain,
|
| 82 |
+
RadialBlur,
|
| 83 |
+
ChromAber,
|
| 84 |
+
WetDistort,
|
| 85 |
+
DynamicBlur,
|
| 86 |
+
ColorGrading,
|
| 87 |
+
Colors,
|
| 88 |
+
Glow,
|
| 89 |
+
SMAA,
|
| 90 |
+
FXAA,
|
| 91 |
+
Median,//unused?
|
| 92 |
+
SunMask,
|
| 93 |
+
GaussFilter,
|
| 94 |
+
SSR //not available
|
| 95 |
+
};
|
| 96 |
+
/*!
|
| 97 |
+
set postprocess effect to camera
|
| 98 |
+
To disable effect in some prioroty ppEffect, just set effectName or name to NULL
|
| 99 |
+
\param cam number of camera
|
| 100 |
+
\param priority priority of effect
|
| 101 |
+
\param type type of effect
|
| 102 |
+
\param materialPath material
|
| 103 |
+
*/
|
| 104 |
+
proto native void SetCameraPostProcessEffect(int cam, int priority, PostProcessEffectType type, string materialPath);
|
| 105 |
+
|
| 106 |
+
//ent can be NULL for world-space coords
|
| 107 |
+
proto vector ProjectVector(int cam, IEntity ent, vector vec);
|
| 108 |
+
proto vector UnprojectVector(int cam, float x, float y, vector dir);
|
| 109 |
+
|
| 110 |
+
//@}
|
| 111 |
+
|
| 112 |
+
//----------------------------------------------
|
| 113 |
+
/**
|
| 114 |
+
* \defgroup Light Light API
|
| 115 |
+
* @{
|
| 116 |
+
*/
|
| 117 |
+
|
| 118 |
+
//!Light handle
|
| 119 |
+
typedef int[] HLIGHT;
|
| 120 |
+
|
| 121 |
+
enum LightType
|
| 122 |
+
{
|
| 123 |
+
POINT, //< point light, all directional light
|
| 124 |
+
SPOT, //< spot light, direction is determined by owner (entity)
|
| 125 |
+
DIRECTIONAL,
|
| 126 |
+
AMBIENT
|
| 127 |
+
};
|
| 128 |
+
|
| 129 |
+
enum LightFlags
|
| 130 |
+
{
|
| 131 |
+
/*!
|
| 132 |
+
Dynamic light. There is limit 512 dynamic lights per world and
|
| 133 |
+
32 per camera view. They are faster when moving and changing shape.
|
| 134 |
+
Also they are always attached to owner entity
|
| 135 |
+
*/
|
| 136 |
+
DYNAMIC,
|
| 137 |
+
CASTSHADOW,
|
| 138 |
+
//! for cheaper dynamic lights, like muzzle flashes (might use cheaper rendering method)
|
| 139 |
+
CHEAP
|
| 140 |
+
};
|
| 141 |
+
|
| 142 |
+
/*!
|
| 143 |
+
creates light
|
| 144 |
+
*/
|
| 145 |
+
proto HLIGHT AddLight(IEntity owner, LightType type, LightFlags flags, float radius, vector color);
|
| 146 |
+
//!removes light
|
| 147 |
+
proto native bool RemoveLight(HLIGHT light);
|
| 148 |
+
proto native bool SetLightEx(HLIGHT light, float radius, vector color);
|
| 149 |
+
//!sets lookup texture for projection lights
|
| 150 |
+
proto native bool SetLightTexture(HLIGHT light, string cubemap);
|
| 151 |
+
proto native int SetLightFlags(HLIGHT light, LightFlags flags);
|
| 152 |
+
proto native int ClearLightFlags(HLIGHT light, LightFlags flags);
|
| 153 |
+
//!Sets light cone in degrees (for LightType.SPOT).
|
| 154 |
+
proto native bool SetLightCone(HLIGHT light, float cone);
|
| 155 |
+
|
| 156 |
+
/*!
|
| 157 |
+
scene multiplicator of light (based on measured scene light levels) - preexposure of light
|
| 158 |
+
*/
|
| 159 |
+
proto native float GetSceneHDRMul(int camera);
|
| 160 |
+
//@}
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
//----------------------------------------------
|
| 165 |
+
/**
|
| 166 |
+
* \defgroup WorldTrace Trace&Visibility API
|
| 167 |
+
* @{
|
| 168 |
+
*/
|
| 169 |
+
|
| 170 |
+
enum TraceFlags
|
| 171 |
+
{
|
| 172 |
+
BONES, //< tests collision geometries around bones of animated objects
|
| 173 |
+
ENTS, //< tests entities
|
| 174 |
+
WORLD, //< tests world bounding box
|
| 175 |
+
ONLY_PHYSICS,
|
| 176 |
+
WATER, //< tests collision with water surface
|
| 177 |
+
PASSTRANSLUCENT,//< Do not intersects with entities with EntityFlags.TRANSLUCENT set
|
| 178 |
+
RAGDOLLS, //< tests ragdolls
|
| 179 |
+
VISTEST, //< performs visibility test first. Not necessary for entities receiving EntityEvent.VISIBLE, because there is a certainty that a camera will see them
|
| 180 |
+
NOTRACE,
|
| 181 |
+
TRANSPARENT_OCCLUDERS
|
| 182 |
+
};
|
| 183 |
+
|
| 184 |
+
enum TraceShape
|
| 185 |
+
{
|
| 186 |
+
LINE,
|
| 187 |
+
BOX,
|
| 188 |
+
OBB,
|
| 189 |
+
SPHERE
|
| 190 |
+
};
|
| 191 |
+
|
| 192 |
+
//! collision and tracing
|
| 193 |
+
//! WARNING: Non-managed, needs manual delete call, should not be ref'd
|
| 194 |
+
class TraceContact
|
| 195 |
+
{
|
| 196 |
+
float Fraction;
|
| 197 |
+
int Content;
|
| 198 |
+
int Surfparm;
|
| 199 |
+
int MaterialFlags;
|
| 200 |
+
int Triangle;
|
| 201 |
+
int SurfaceID;
|
| 202 |
+
owned string MaterialName;
|
| 203 |
+
owned string OriginalMaterialName;
|
| 204 |
+
float Plane[4];
|
| 205 |
+
vector Point;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
proto native bool TraceLineToEntity(IEntity ent, vector start, vector end, out TraceContact contact);
|
| 209 |
+
|
| 210 |
+
//bool FilterCallback(Class target [, vector rayorigin, vector raydirection])
|
| 211 |
+
|
| 212 |
+
class TraceParam: Managed
|
| 213 |
+
{
|
| 214 |
+
vector Start;
|
| 215 |
+
vector End;
|
| 216 |
+
int LayerMask = 0xffffffff;
|
| 217 |
+
TraceFlags Flags;
|
| 218 |
+
IEntity Exclude;
|
| 219 |
+
|
| 220 |
+
};
|
| 221 |
+
|
| 222 |
+
class TraceSphere: TraceParam
|
| 223 |
+
{
|
| 224 |
+
float Radius;
|
| 225 |
+
};
|
| 226 |
+
|
| 227 |
+
class TraceBox: TraceParam
|
| 228 |
+
{
|
| 229 |
+
vector Mins;
|
| 230 |
+
vector Maxs;
|
| 231 |
+
};
|
| 232 |
+
|
| 233 |
+
class TraceOBB: TraceBox
|
| 234 |
+
{
|
| 235 |
+
vector Mat[3];
|
| 236 |
+
};
|
| 237 |
+
|
| 238 |
+
/*!
|
| 239 |
+
traces line start->end, return 0..1 if trace was sucessfull.
|
| 240 |
+
// It take bboux from ent
|
| 241 |
+
// flag like in P2PVisibilityEx will be added
|
| 242 |
+
//OUTPUT:
|
| 243 |
+
\param cent [out] traced entity
|
| 244 |
+
\param plane [out] traced polygon plane (X,Y,Z,D)
|
| 245 |
+
\param surfparm [out] traced surface parameters
|
| 246 |
+
\returns value 0...1, percentage of a path traveled
|
| 247 |
+
*/
|
| 248 |
+
proto volatile float TraceMove(TraceParam param, out IEntity cent, out float plane[4], out int surfparm, func filtercallback);
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
/*!
|
| 252 |
+
tests visibility
|
| 253 |
+
\param from
|
| 254 |
+
\param to
|
| 255 |
+
\param flags
|
| 256 |
+
//TraceFlags.VISTEST -
|
| 257 |
+
//TraceFlags.DETAIL - test agains detail brushes
|
| 258 |
+
//TraceFlags.ENT - test against brush entities
|
| 259 |
+
//TraceFlags.NOTRACE - doesn't test geometry (has meaning in conjuction with s TraceFlags.VISTEST)
|
| 260 |
+
\returns true is visible/false not visibel
|
| 261 |
+
*/
|
| 262 |
+
proto native int P2PVisibilityEx(vector from, vector to,int flags);
|
| 263 |
+
|
| 264 |
+
//! finds all entities in a radius
|
| 265 |
+
proto int SphereQuery(vector origin, float radius, out IEntity visents[], int ents, int fmask);
|
| 266 |
+
|
| 267 |
+
/*!tests if bbox is visible according to view-frustum and PVS
|
| 268 |
+
\param flags & 1 - test also PVS
|
| 269 |
+
\returns true/false is/isn't visible
|
| 270 |
+
*/
|
| 271 |
+
proto native bool IsBoxVisible(vector mins, vector maxs, int flags);
|
| 272 |
+
|
| 273 |
+
/*!finds all visible entities (rought, according to a visibility. It is convinient for entitie selection where we want to do more precise visibility test)
|
| 274 |
+
\param origin - position it is looked from
|
| 275 |
+
\param look - look direction
|
| 276 |
+
\param angle - view angle (usuably 90). -1 if we do not care about the view angle
|
| 277 |
+
\param ents - array to which entities will be stored
|
| 278 |
+
\param maxents - length of the array (prevents overflowing the array)
|
| 279 |
+
\param fmask - flag mask (SetFlags()). Entity must have all flags set.
|
| 280 |
+
it is possible to use reserved flags like EntityFlags.USER1, EntityFlags.USER2, EntityFlags.USER6 for fast finding of entities in custom categories
|
| 281 |
+
*/
|
| 282 |
+
proto int VisEntities(vector origin, vector look, float angle, float radius, out IEntity ents[2], int maxents, int fmask);
|
| 283 |
+
|
| 284 |
+
/*!
|
| 285 |
+
Object that handles visibility on GPU. Used for coronas etc.
|
| 286 |
+
*/
|
| 287 |
+
class OcclusionQuery
|
| 288 |
+
{
|
| 289 |
+
proto private void ~OcclusionQuery();
|
| 290 |
+
|
| 291 |
+
/*!
|
| 292 |
+
return Query result
|
| 293 |
+
\returns -1 result is not ready yet, try it later.
|
| 294 |
+
>0 point is visible
|
| 295 |
+
==0 point is not visible
|
| 296 |
+
*/
|
| 297 |
+
proto native int GetResult();
|
| 298 |
+
|
| 299 |
+
//!Sets world position
|
| 300 |
+
proto native void SetPosition(vector pos);
|
| 301 |
+
//!Destroys the object
|
| 302 |
+
proto native void Destroy();
|
| 303 |
+
};
|
| 304 |
+
|
| 305 |
+
//@}
|
| 306 |
+
|
| 307 |
+
//----------------------------------------------
|
| 308 |
+
/**
|
| 309 |
+
* \defgroup Decals Decals API
|
| 310 |
+
* @{
|
| 311 |
+
*/
|
| 312 |
+
typedef int[] hDecal;
|
| 313 |
+
|
| 314 |
+
/*!
|
| 315 |
+
Creates single visual mark, e.g. from shots
|
| 316 |
+
//when lifetime=0, pointer to decal is returned, that can be removed by RemoveDecal then
|
| 317 |
+
\param entity entity where the landmark should be created
|
| 318 |
+
\param origin first point of the decal, nothing is done now
|
| 319 |
+
\param project projection direction (length is far clipping distance)
|
| 320 |
+
\param nearclip near clipping distance
|
| 321 |
+
\param materialName Material used for decal
|
| 322 |
+
\param lifetime Lifetime in seconds
|
| 323 |
+
\param flags Not used ATM
|
| 324 |
+
\return Decal pointer or null
|
| 325 |
+
*/
|
| 326 |
+
proto native hDecal CreateDecal(IEntity entity, vector origin, vector project, float nearclip, float angle, float size, string materialName, float lifetime, int flags);
|
| 327 |
+
|
| 328 |
+
proto native void RemoveDecal(hDecal decal);
|
| 329 |
+
|
| 330 |
+
/*!
|
| 331 |
+
Creates continous visual mark, e.g. from wheel when a car is moving on the ground
|
| 332 |
+
\param entity entity where the landmark should be created (only terrain is supported ATM)
|
| 333 |
+
\param origin first point of the decal, nothing is done now
|
| 334 |
+
\param normal normal of surface
|
| 335 |
+
\param edgesize Edge size of decal
|
| 336 |
+
\param lifetime Lifetime in seconds
|
| 337 |
+
\param materialName Material used for decal
|
| 338 |
+
\param prev Previous decal, we are connecting to
|
| 339 |
+
\param alpha translucency of point
|
| 340 |
+
\return Decal pointer or null
|
| 341 |
+
*/
|
| 342 |
+
proto native hDecal CreateLandMarkDecal(IEntity entity, vector origin, vector normal, float edgeSize, float lifeTime, string materialName, hDecal prevDecal, float alpha);
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
/*!
|
| 346 |
+
is it possible to add new point to landmark decal?
|
| 347 |
+
\param lmDecal entity to add new landmark point
|
| 348 |
+
\param entity entity to add new landmark point
|
| 349 |
+
\param mat material of decal
|
| 350 |
+
\param newpoint new point to add
|
| 351 |
+
\return
|
| 352 |
+
LMD_ERROR = error when adding new point (invalid decal)
|
| 353 |
+
LMD_VALID = can add new point
|
| 354 |
+
LMD_DIFF_ENT = new point is on different entity
|
| 355 |
+
LMD_TOO_FAR = new point is too far from previous point
|
| 356 |
+
*/
|
| 357 |
+
proto native int CanAddToLandMarkDecal(hDecal lmDecal, IEntity entity, string mat, vector newPoint);
|
| 358 |
+
|
| 359 |
+
/*!
|
| 360 |
+
add new point to decal, internally, new point is added when previous point is in some
|
| 361 |
+
distance or the angle is more than some threshold
|
| 362 |
+
\param lmDecal entity to add new landmark point
|
| 363 |
+
\param point contact point
|
| 364 |
+
\param normal normal of contact
|
| 365 |
+
\param alpha translucency in point
|
| 366 |
+
\return true if everything was OK, false if not. In this case, the application MUST not used later the pointer to decal, it's finalized internally !
|
| 367 |
+
*/
|
| 368 |
+
proto native bool AddPointToLandMarkDecal(hDecal lmDecal, vector point, vector normal, float alpha);
|
| 369 |
+
|
| 370 |
+
/*!
|
| 371 |
+
finalize landmark adding, e.g. when entity lose contact with ground -> the pointer to decal
|
| 372 |
+
should have only world and entity if it has something to render, otherwise it's destroyed here
|
| 373 |
+
\param lmDecal entity to add new landmark point
|
| 374 |
+
\param addAlpha if to add last point with transition to zero alpha
|
| 375 |
+
\param alphaDist distance to add last point
|
| 376 |
+
*/
|
| 377 |
+
proto native void FinalizeLandMarkDecal(hDecal lmDecal, bool addAlpha, float alphaDist);
|
| 378 |
+
|
| 379 |
+
/*!
|
| 380 |
+
return if landmark was finalized
|
| 381 |
+
\param lmDecal decal to test
|
| 382 |
+
*/
|
| 383 |
+
proto native bool IsLandMarkFinalized(hDecal lmDecal);
|
| 384 |
+
|
| 385 |
+
/*!
|
| 386 |
+
return last landmark point or -65535.0 in all components
|
| 387 |
+
\param lmDecal decal to test
|
| 388 |
+
*/
|
| 389 |
+
proto native vector GetLastLandMarkPoint(hDecal lmDecal);
|
| 390 |
+
|
| 391 |
+
/*!
|
| 392 |
+
set global parameters for landmark generation
|
| 393 |
+
\param minSegmentLength minimum length segment, when new point is added (4 default), when is less, just the end position is on the fly updated
|
| 394 |
+
\param maxSegmentLength maximum segment length, when length is bigger, the path is finished
|
| 395 |
+
\param degAngle angle in degrees, when is more, the path is finished
|
| 396 |
+
*/
|
| 397 |
+
proto native void SetGlobalLandMarkParams(float minSegmentLength, float maxSegmentLength, float degAngle);
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
//@}
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
//----------------------------------------------
|
| 404 |
+
/**
|
| 405 |
+
* \defgroup Ocean Ocean API
|
| 406 |
+
* @{
|
| 407 |
+
*/
|
| 408 |
+
|
| 409 |
+
/*!
|
| 410 |
+
Is ocean availabled
|
| 411 |
+
*/
|
| 412 |
+
proto native bool IsOcean();
|
| 413 |
+
|
| 414 |
+
/*!
|
| 415 |
+
Get water ocean height at given point
|
| 416 |
+
\param worldX world x position
|
| 417 |
+
\param worldZ world z position
|
| 418 |
+
*/
|
| 419 |
+
proto native float GetOceanHeight(float worldX, float worldZ);
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
/*!
|
| 423 |
+
Get water ocean height and displacement at given point, returns vector(displaceX, height, displaceZ)
|
| 424 |
+
\param worldX world x position
|
| 425 |
+
\param worldZ world z position
|
| 426 |
+
*/
|
| 427 |
+
proto native vector GetOceanHeightAndDisplace(float worldX, float worldZ);
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
//@}
|
| 432 |
+
|
| 433 |
+
|
| 434 |
+
|
| 435 |
+
//@}
|
| 436 |
+
|
scripts/1_Core/DayZ/proto/Serializer.c
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//-----------------------------------------------------------------------------
|
| 2 |
+
/**
|
| 3 |
+
\brief Serialization general interface. Serializer API works with:
|
| 4 |
+
- primitive types: int, float, string, bool, vector
|
| 5 |
+
- dynamic containers: array, set, map
|
| 6 |
+
- static arrays
|
| 7 |
+
- complex types: classes
|
| 8 |
+
\note Serializer provides deep serialization (it serialize class memebers and their members etc). To avoid serialization of certain class variable, use NonSerialized attribute.
|
| 9 |
+
\par usage:
|
| 10 |
+
@code
|
| 11 |
+
class MyData
|
| 12 |
+
{
|
| 13 |
+
int m_id;
|
| 14 |
+
autoptr map<string, float> m_values;
|
| 15 |
+
|
| 16 |
+
[NonSerialized()]
|
| 17 |
+
string m_dbg; // I don't want to serialize this variable
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
void Serialize(Serializer s)
|
| 21 |
+
{
|
| 22 |
+
int statArray[4] = {6,9,2,3};
|
| 23 |
+
array<int> dynArray = {8,5,6,4};
|
| 24 |
+
autoptr MyData data = new MyData();
|
| 25 |
+
|
| 26 |
+
data.m_id = 965;
|
| 27 |
+
data.m_values = map<string, float>;
|
| 28 |
+
data.m_values.Insert("value1", 5.98);
|
| 29 |
+
data.m_values.Insert("value2", 4.36);
|
| 30 |
+
|
| 31 |
+
s.Write(10);
|
| 32 |
+
s.Write("Hello");
|
| 33 |
+
s.Write(statArray);
|
| 34 |
+
s.Write(dynArray);
|
| 35 |
+
s.Write(data);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
void Deserialize(Serializer s)
|
| 39 |
+
{
|
| 40 |
+
int statArray[4];
|
| 41 |
+
array<int> dynArray;
|
| 42 |
+
MyData data;
|
| 43 |
+
int someInt;
|
| 44 |
+
string someString;
|
| 45 |
+
|
| 46 |
+
s.Read(someInt);
|
| 47 |
+
s.Read(someString);
|
| 48 |
+
s.Read(statArray);
|
| 49 |
+
s.Read(dynArray);
|
| 50 |
+
s.Read(data);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
@endcode
|
| 54 |
+
*/
|
| 55 |
+
class Serializer: Managed
|
| 56 |
+
{
|
| 57 |
+
proto bool Write(void value_out);
|
| 58 |
+
proto bool Read(void value_in);
|
| 59 |
+
|
| 60 |
+
proto native bool CanWrite();
|
| 61 |
+
proto native bool CanRead();
|
| 62 |
+
|
| 63 |
+
protected void Serializer() {}
|
| 64 |
+
protected void ~Serializer() {}
|
| 65 |
+
};
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
\brief Serializer API implementation for File IO. See Serializer for more info.
|
| 69 |
+
\n usage:
|
| 70 |
+
@code
|
| 71 |
+
void TestSave()
|
| 72 |
+
{
|
| 73 |
+
FileSerializer file = new FileSerializer();
|
| 74 |
+
string names[3] = {"alpha", "beta", "gama"};
|
| 75 |
+
|
| 76 |
+
if (file.Open("test.save", FileMode.WRITE))
|
| 77 |
+
{
|
| 78 |
+
file.Write(10);
|
| 79 |
+
file.Write("lalala");
|
| 80 |
+
file.Write(name);
|
| 81 |
+
file.Close();
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
void TestLoad()
|
| 86 |
+
{
|
| 87 |
+
FileSerializer file = new FileSerializer();
|
| 88 |
+
int intVal;
|
| 89 |
+
string stringVal;
|
| 90 |
+
string names[3];
|
| 91 |
+
|
| 92 |
+
if (file.Open("test.save", FileMode.READ))
|
| 93 |
+
{
|
| 94 |
+
file.Read(intVal);
|
| 95 |
+
file.Read(stringVal);
|
| 96 |
+
file.Read(names);
|
| 97 |
+
file.Close();
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
@endcode
|
| 102 |
+
*/
|
| 103 |
+
class FileSerializer: Serializer
|
| 104 |
+
{
|
| 105 |
+
void FileSerializer() {}
|
| 106 |
+
void ~FileSerializer() {}
|
| 107 |
+
|
| 108 |
+
proto native bool Open(string path, FileMode mode = FileMode.READ);
|
| 109 |
+
proto native bool IsOpen();
|
| 110 |
+
proto native void Close();
|
| 111 |
+
}
|
| 112 |
+
|
scripts/1_Core/DayZ/proto/proto.c
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @file */
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
/*
|
| 5 |
+
Function/method modifiers:
|
| 6 |
+
proto - prototyping of internal function (C++ side)
|
| 7 |
+
native - native call convention of internal function (C++ side)
|
| 8 |
+
volatile - internal function that may call back to script (hint for
|
| 9 |
+
compiler that context need to be saved on stack)
|
| 10 |
+
private - function may not be called from script
|
| 11 |
+
event - hint for tools that the function should be exposed as
|
| 12 |
+
Entity script event.
|
| 13 |
+
|
| 14 |
+
Variable modifiers:
|
| 15 |
+
owned - modifier for returing internal functions. Tells to script-VM,
|
| 16 |
+
that returning variable (string or array) must not be released
|
| 17 |
+
out - modifier for function parameters. It tells that variable will
|
| 18 |
+
be changed by function call (used mainly by internal functions)
|
| 19 |
+
inout - modifier for function parameters. It tells that variable will
|
| 20 |
+
be used and then changed by function call (used mainly by internal functions)
|
| 21 |
+
|
| 22 |
+
const - constants. May not be modified.
|
| 23 |
+
reference - hint for tools (Material editor), that the variable may be used
|
| 24 |
+
as parameter in material
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/*===================================================================*/
|
| 29 |
+
/* Enforce engine API */
|
| 30 |
+
/*===================================================================*/
|
| 31 |
+
|
| 32 |
+
//placeholder
|
| 33 |
+
class AnimEvent
|
| 34 |
+
{
|
| 35 |
+
int type;
|
| 36 |
+
int slot;
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
class SoundEvent
|
| 40 |
+
{
|
| 41 |
+
int type;
|
| 42 |
+
int handle;
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
typedef int[] vobject;
|
| 47 |
+
|
| 48 |
+
class vobject
|
| 49 |
+
{
|
| 50 |
+
proto native IEntitySource ToEntitySource();
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
#ifdef ENF_DONE
|
| 54 |
+
|
| 55 |
+
//------------------------------------------
|
| 56 |
+
// SOUND API
|
| 57 |
+
//------------------------------------------
|
| 58 |
+
//TODO:
|
| 59 |
+
typedef int[] HSOUND;
|
| 60 |
+
|
| 61 |
+
//flags
|
| 62 |
+
//!Play once and invoke EntityEvent.SOUNDEND event
|
| 63 |
+
//SFX_ONCE
|
| 64 |
+
//!Music. Has separate volume control, can be replaced by custom music
|
| 65 |
+
//SFX_MUSIC
|
| 66 |
+
//!Ambient, not positional sound
|
| 67 |
+
//SFX_AMBIENT
|
| 68 |
+
//!Positional sound
|
| 69 |
+
//SFX_3D
|
| 70 |
+
//!Don't even start if not hearable. Valid only together with SFX_3D!
|
| 71 |
+
//SFX_DISCARDABLE
|
| 72 |
+
//!Sound is positional. XSoundSource::GetSoundOrientation is called. Valid only together with SFX_3D!
|
| 73 |
+
//SFX_DIRECTIONAL
|
| 74 |
+
////!Sound is moveable. XSoundSource::GetSoundVelocity is called. Valid only together with SFX_3D!
|
| 75 |
+
//SFX_DOPPLER
|
| 76 |
+
//!Position is not changing, XSoundSource::GetSoundPosition/GetSoundOrientation is called only once upon start! Valid only together with SFX_3D!
|
| 77 |
+
//SFX_STATIC
|
| 78 |
+
//!Don't test hearability. Valid only together with SFX_3D!
|
| 79 |
+
//SFX_NOTEST
|
| 80 |
+
|
| 81 |
+
//proto volatile HSOUND PlaySound(int soundScene, IEntity source, string sshader, int flags);
|
| 82 |
+
proto volatile native void EndSound(HSOUND snd);
|
| 83 |
+
|
| 84 |
+
//volume 0...1. Logaritmic scale
|
| 85 |
+
proto native int SetSoundVolume(HSOUND sound, float volume)
|
| 86 |
+
proto native int SetSoundFrequency(HSOUND sound, int freq)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
//returns 0, if soundid is not valid
|
| 90 |
+
proto native int GetSoundLength(HSOUND sound)
|
| 91 |
+
|
| 92 |
+
//returns -1, if soundid is not valid
|
| 93 |
+
proto native int GetSoundPosition(HSOUND sound)
|
| 94 |
+
|
| 95 |
+
//defaultne se pouziva EAX prostredi nadefinovane v mape, ale lze ho prebit touto fci.
|
| 96 |
+
// Mohou se michat dve ruzna prostredi v pomeru danem hodnotou fade (fade==0 -> 100% env1, fade==1 -> 100% env2).
|
| 97 |
+
//pokud chceme michat aktualni prostredi s nejakym jinym, lze pouzit zastupny nazev "$current".
|
| 98 |
+
//Tim lze dosahnout nafadovani vlastniho prostredi, kdyz fci postupne volame napr. takto:
|
| 99 |
+
//SetEAXEnvironment("$current", "Drugged", fade)
|
| 100 |
+
//pricemz hodnota fade postupne narusta od nuly do jedne
|
| 101 |
+
//proto native bool SetEAXEnvironment(string env1, string env2, float fade)
|
| 102 |
+
#endif
|
| 103 |
+
|
| 104 |
+
class PacketOutputAdapter
|
| 105 |
+
{
|
| 106 |
+
proto native void WriteBool(bool value); //size: 1 byte
|
| 107 |
+
proto native void WriteInt(int value); //size: 4 bytes
|
| 108 |
+
proto native void WriteFloat(float value); //size: 4 bytes
|
| 109 |
+
proto native void WriteString(string value); //size: n bytes (string length)
|
| 110 |
+
proto native void WriteVector(vector value); //size: 12 bytes
|
| 111 |
+
proto native void WriteMatrixAsQuaternionVector(vector mat[4]); //size: 28 bytes
|
| 112 |
+
proto native void WriteIntAsByte(int value); //write int in range <-128, 127> size: 1 byte
|
| 113 |
+
proto native void WriteIntAsUByte(int value); //write int in range <0, 255> size: 1 byte
|
| 114 |
+
proto native void WriteIntAsHalf(int value); //write int in range <-32768, 32768> size: 2 bytes
|
| 115 |
+
proto native void WriteIntAsUHalf(int value); //write int in range <0, 65535> size: 2 bytes
|
| 116 |
+
proto native void WriteFloatAsByte(float value, float min, float max); // size: 1 byte
|
| 117 |
+
proto native void WriteFloatAsHalf(float value, float min, float max); // size: 2 bytes
|
| 118 |
+
};
|
| 119 |
+
|
| 120 |
+
class PacketInputAdapter
|
| 121 |
+
{
|
| 122 |
+
proto native bool ReadBool();
|
| 123 |
+
proto native int ReadInt();
|
| 124 |
+
proto native float ReadFloat();
|
| 125 |
+
proto string ReadString();
|
| 126 |
+
proto native vector ReadVector();
|
| 127 |
+
proto void ReadMatrixAsQuaternionVector(vector mat[4]);
|
| 128 |
+
proto native int ReadIntAsByte();
|
| 129 |
+
proto native int ReadIntAsUByte();
|
| 130 |
+
proto native int ReadIntAsHalf();
|
| 131 |
+
proto native int ReadIntAsUHalf();
|
| 132 |
+
proto native float ReadFloatAsByte(float min, float max);
|
| 133 |
+
proto native float ReadFloatAsHalf(float min, float max);
|
| 134 |
+
};
|
| 135 |
+
|
| 136 |
+
/*!
|
| 137 |
+
makes screenshot and stores it in to a DDS format file
|
| 138 |
+
if the name begins with '$' the screenshot in stored in the fullpath according to the name parameter
|
| 139 |
+
otherwise the screenshot is stored in "$profile:ScreenShotes/DATE TIME-NAME.dds" where DATE, TIME AND NAME are replaced by actual values
|
| 140 |
+
\param name name of the screenshot
|
| 141 |
+
*/
|
| 142 |
+
proto native void MakeScreenshot(string name);
|
| 143 |
+
|
| 144 |
+
/*!
|
| 145 |
+
Returns actual fps (average in last 10 frames)
|
| 146 |
+
*/
|
| 147 |
+
proto native int GetFPS();
|
| 148 |
+
|
| 149 |
+
//----------------------------------------------
|
| 150 |
+
/** \name SkyDome API */
|
| 151 |
+
//@{
|
| 152 |
+
|
| 153 |
+
/*!
|
| 154 |
+
load all sky presets from xml file
|
| 155 |
+
\param presetFile name of XML file with presets
|
| 156 |
+
*/
|
| 157 |
+
proto native int LoadSkyPresets(string presetsFile);
|
| 158 |
+
|
| 159 |
+
/*!
|
| 160 |
+
initialize sky with preset, must be called to set the global planets setting
|
| 161 |
+
\param presetName name of preset to be set (one of presets from file loaded using LoadSkyPresets)
|
| 162 |
+
*/
|
| 163 |
+
proto native int InitSky(string presetName);
|
| 164 |
+
|
| 165 |
+
/*!
|
| 166 |
+
set sky preset to day time and stormy parameter
|
| 167 |
+
\param presetName name of preset to be set (one of presets from file loaded using LoadSkyPresets)
|
| 168 |
+
\param stormy stormy parameter <0, 1>
|
| 169 |
+
\param dayTime day of time <0, 1>
|
| 170 |
+
*/
|
| 171 |
+
proto native int SetSkyPreset(string presetName, float stormy, float dayTime);
|
| 172 |
+
|
| 173 |
+
/*!
|
| 174 |
+
lerp two sky presets and set the result using day time
|
| 175 |
+
\param presetName1 name of preset1 to be set (one of presets from file loaded using LoadSkyPresets)
|
| 176 |
+
\param presetName2 name of preset2 to be set (one of presets from file loaded using LoadSkyPresets)
|
| 177 |
+
\param dayTime day of time <0, 1>
|
| 178 |
+
\param stormy1 stormy parameter for preset1 <0, 1>
|
| 179 |
+
\param stormy2 stormy parameter for preset2 <0, 1>
|
| 180 |
+
\param lerpVal lerp value between two presets
|
| 181 |
+
*/
|
| 182 |
+
proto native int LerpSkyPreset(string presetName1, string presetName2, float dayTime, float stormy1, float stormy2, float lerpVal);
|
| 183 |
+
|
| 184 |
+
/*!
|
| 185 |
+
lerp three sky presets using barycentric coordinates and set the result using day time
|
| 186 |
+
\param presetName1 name of preset1 to be set (one of presets from file loaded using LoadSkyPresets)
|
| 187 |
+
\param presetName2 name of preset2 to be set (one of presets from file loaded using LoadSkyPresets)
|
| 188 |
+
\param presetName2 name of preset3 to be set (one of presets from file loaded using LoadSkyPresets)
|
| 189 |
+
\param dayTime day of time <0, 1>
|
| 190 |
+
\param stormy1 stormy parameter for preset1 <0, 1>
|
| 191 |
+
\param stormy2 stormy parameter for preset2 <0, 1>
|
| 192 |
+
\param stormy3 stormy parameter for preset3 <0, 1>
|
| 193 |
+
\param w1 weight for preset1
|
| 194 |
+
\param w2 weight for preset2
|
| 195 |
+
\param w3 weight for preset3
|
| 196 |
+
*/
|
| 197 |
+
proto native int LerpSkyPreset3(string presetName1, string presetName2, string presetName3, float dayTime, float stormy1, float stormy2, float stormy3, float w1, float w2, float w3);
|
| 198 |
+
|
| 199 |
+
/*!
|
| 200 |
+
user can set planets to its own positions on skydome using SetSkyPresetPlanet function,
|
| 201 |
+
if disabled, the planets are positioned automatically using sky preset setting
|
| 202 |
+
\param enabled enable/disable
|
| 203 |
+
*/
|
| 204 |
+
proto native void SetSkyUserPlanets(bool enabled);
|
| 205 |
+
|
| 206 |
+
/*!
|
| 207 |
+
set planet position
|
| 208 |
+
\param index index of planet, 0 = sun usually
|
| 209 |
+
\param azimuthDeg azimuth position in degrees
|
| 210 |
+
\param zenithDeg zenith position in degrees
|
| 211 |
+
*/
|
| 212 |
+
proto native bool SetSkyPlanet(int index, float azimuthDeg, float zenithDeg);
|
| 213 |
+
|
| 214 |
+
/*!
|
| 215 |
+
set planet size in degrees
|
| 216 |
+
\param index index of planet, 0 = sun usually
|
| 217 |
+
\param angleDeg angle size in degrees
|
| 218 |
+
*/
|
| 219 |
+
proto native bool SetSkyPlanetSize(int index, float angleDeg);
|
| 220 |
+
|
| 221 |
+
/*!
|
| 222 |
+
set UTC time for real time stars
|
| 223 |
+
\param year
|
| 224 |
+
\param month
|
| 225 |
+
\param day
|
| 226 |
+
\param hour
|
| 227 |
+
\param minute
|
| 228 |
+
\param sec
|
| 229 |
+
\param offsetSec to take into account time difference between Greenwich and local time (position dependency, summer/winter time)
|
| 230 |
+
*/
|
| 231 |
+
proto native void SetStarsObserverTime(int year, int month, int day, int hour, int minute, float sec, int offsetSec);
|
| 232 |
+
|
| 233 |
+
/*!
|
| 234 |
+
set observer position
|
| 235 |
+
\param latitudeDeg latitude in degrees
|
| 236 |
+
\param longitudeDeg longitude in degrees
|
| 237 |
+
*/
|
| 238 |
+
proto native void SetStarsObserverPosition(float latitudeDeg, float longitudeDeg);
|
| 239 |
+
|
| 240 |
+
/*!
|
| 241 |
+
update of stars
|
| 242 |
+
\param update true = automatic stars update, false = update is on user by SetStarsRotMatrix
|
| 243 |
+
*/
|
| 244 |
+
proto native void SetRealStarAutoUpdate(bool update);
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
/*!
|
| 248 |
+
night sky layer rotation matrix
|
| 249 |
+
\param mat rotation matrix
|
| 250 |
+
*/
|
| 251 |
+
proto native void SetNightLayerRotMatrix(vector mat[3]);
|
| 252 |
+
|
| 253 |
+
/*!
|
| 254 |
+
stars rotation matrix, is different from night rotation matrix
|
| 255 |
+
because we don't know the time when night layers was captured
|
| 256 |
+
\param mat rotation matrix
|
| 257 |
+
*/
|
| 258 |
+
proto native void SetStarsRotMatrix(vector mat[3]);
|
| 259 |
+
|
| 260 |
+
//@}
|
| 261 |
+
|
| 262 |
+
//----------------------------------------------
|
| 263 |
+
/** \name Materials API */
|
| 264 |
+
//@{
|
| 265 |
+
typedef int[] Material;
|
| 266 |
+
|
| 267 |
+
class Material
|
| 268 |
+
{
|
| 269 |
+
/*!
|
| 270 |
+
set parametr of material by string name
|
| 271 |
+
\param paramName name of parameter
|
| 272 |
+
\param value value
|
| 273 |
+
*/
|
| 274 |
+
proto bool SetParam(string propertyName, void value);
|
| 275 |
+
|
| 276 |
+
/*!
|
| 277 |
+
reset parametr of material to default value
|
| 278 |
+
\param paramName name of parameter
|
| 279 |
+
*/
|
| 280 |
+
proto native void ResetParam(string propertyName);
|
| 281 |
+
|
| 282 |
+
/*!
|
| 283 |
+
set parametr index for faster access to material properties
|
| 284 |
+
\param paramName name of parameter
|
| 285 |
+
\return parameter index
|
| 286 |
+
*/
|
| 287 |
+
proto native int GetParamIndex(string paramName);
|
| 288 |
+
|
| 289 |
+
/*!
|
| 290 |
+
set parametr of material by index
|
| 291 |
+
\param paramName name of parameter
|
| 292 |
+
\param value value
|
| 293 |
+
*/
|
| 294 |
+
proto void SetParamByIndex(int paramIndex, void value);
|
| 295 |
+
};
|
| 296 |
+
//@}
|
| 297 |
+
|
| 298 |
+
int VectortoRGBA( vector vec, float h)
|
| 299 |
+
{
|
| 300 |
+
float x,y,z;
|
| 301 |
+
int r,g,b,a,rgba;
|
| 302 |
+
|
| 303 |
+
x = vec[0];
|
| 304 |
+
y = vec[1];
|
| 305 |
+
z = vec[2];
|
| 306 |
+
|
| 307 |
+
x = x * 127.0 + 128.0;
|
| 308 |
+
y = y * 127.0 + 128.0;
|
| 309 |
+
z = z * 127.0 + 128.0;
|
| 310 |
+
h = h * 255.0;
|
| 311 |
+
|
| 312 |
+
a = (int)h << 24;
|
| 313 |
+
r = (int)x << 16;
|
| 314 |
+
g = (int)y << 8;
|
| 315 |
+
b = z;
|
| 316 |
+
|
| 317 |
+
return r | g | b | a;
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
//-----------------------------------------------------------------
|
| 322 |
+
int ARGB(int a, int r, int g, int b)
|
| 323 |
+
{
|
| 324 |
+
a = a << 24;
|
| 325 |
+
r = r << 16;
|
| 326 |
+
g = g << 8;
|
| 327 |
+
return a | r | g | b;
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
//-----------------------------------------------------------------
|
| 331 |
+
//! Converts <0.0, 1.0> ARGB into color
|
| 332 |
+
int ARGBF(float fa, float fr, float fg, float fb)
|
| 333 |
+
{
|
| 334 |
+
return ARGB((float)(fa * 255.0), (float)(fr * 255.0), (float)(fg * 255.0), (float)(fb * 255.0));
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
//-----------------------------------------------------------------
|
| 338 |
+
int AWHITE(int a)
|
| 339 |
+
{
|
| 340 |
+
return a << 24 | 0xffffff;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
//-----------------------------------------------------------------
|
| 344 |
+
int LerpARGB(int c1, int c2)
|
| 345 |
+
{
|
| 346 |
+
int cb1, cb2;
|
| 347 |
+
const int cmask = 0x00ff00ff;
|
| 348 |
+
|
| 349 |
+
cb1 = c1 >> 8 & cmask;
|
| 350 |
+
cb2 = c2 >> 8 & cmask;
|
| 351 |
+
cb1 = cb1 + cb2 >> 1;
|
| 352 |
+
|
| 353 |
+
c1 = c1 & cmask;
|
| 354 |
+
c2 = c2 & cmask;
|
| 355 |
+
c1 = c1 + c2 >> 1;
|
| 356 |
+
|
| 357 |
+
return cb1 << 8 | c1;
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
//-------------------------------------------------------------------------
|
| 361 |
+
class Link<Class T>
|
| 362 |
+
{
|
| 363 |
+
proto private native void Init(T init);
|
| 364 |
+
proto private native Object Get();
|
| 365 |
+
|
| 366 |
+
void Release()
|
| 367 |
+
{
|
| 368 |
+
T obj = Get();
|
| 369 |
+
if(obj)
|
| 370 |
+
obj.Release();
|
| 371 |
+
}
|
| 372 |
+
void Link(T init)
|
| 373 |
+
{
|
| 374 |
+
Init(init);
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
T Ptr()
|
| 378 |
+
{
|
| 379 |
+
return Get();
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
bool IsNull()
|
| 383 |
+
{
|
| 384 |
+
if(!Get())
|
| 385 |
+
return true;
|
| 386 |
+
|
| 387 |
+
return false;
|
| 388 |
+
}
|
| 389 |
+
};
|
| 390 |
+
|
scripts/1_Core/DayZ/script.c
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//some example "reference" variables for use in material editor
|
| 2 |
+
reference float g_testVariable1;
|
| 3 |
+
reference float g_testVariable2;
|
| 4 |
+
reference float g_testVariable3;
|
| 5 |
+
|
| 6 |
+
class TestClass
|
| 7 |
+
{
|
| 8 |
+
//some example "reference" variables for use in material editor
|
| 9 |
+
reference float testVar1;
|
| 10 |
+
reference float testVar2;
|
| 11 |
+
reference float testVar3;
|
| 12 |
+
}
|
scripts/1_Core/DayZ/workbenchApi.c
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
+
static proto native bool OpenModule(string type);
|
| 10 |
+
static proto native bool CloseModule(string type);
|
| 11 |
+
static proto native void Dialog(string caption, string text);
|
| 12 |
+
static proto int ScriptDialog(string caption, string text, Class data);
|
| 13 |
+
static proto bool SearchResources(string filter, func callback);
|
| 14 |
+
static proto native int RunCmd(string command, bool wait = false);
|
| 15 |
+
static proto void GetCwd(out string currentDir);
|
| 16 |
+
static proto bool GetAbsolutePath(string relativePath, out string absPath);
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
class WBModuleDef
|
| 20 |
+
{
|
| 21 |
+
proto native external bool SetOpenedResource(string filename);
|
| 22 |
+
proto native external int GetNumContainers();
|
| 23 |
+
proto native external BaseContainer GetContainer(int index = 0);
|
| 24 |
+
proto external bool GetCmdLine(string name, out string value);
|
| 25 |
+
proto native external bool Save();
|
| 26 |
+
proto native external bool Close();
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
class ScriptEditor: WBModuleDef
|
| 30 |
+
{
|
| 31 |
+
proto external bool GetCurrentFile(out string filename);
|
| 32 |
+
proto native external int GetCurrentLine();
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
class ResourceBrowser: WBModuleDef
|
| 36 |
+
{
|
| 37 |
+
proto external bool GetCurrentFile(out string filename);
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
class WorldEditor: WBModuleDef
|
| 41 |
+
{
|
| 42 |
+
proto native external WorldEditorAPI GetAPI();
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
class WorldEditorAPI
|
| 46 |
+
{
|
| 47 |
+
proto native bool BeginTerrainAction(string historyPointName = "", string historyPointIcon = "");
|
| 48 |
+
proto native void EndTerrainAction(string historyPointName = "");
|
| 49 |
+
proto native bool BeginEntityAction(string historyPointName = "", string historyPointIcon = ""); //begin of logical edit action
|
| 50 |
+
proto native bool EndEntityAction(string historyPointName = ""); //end of edit action
|
| 51 |
+
proto native bool IsDoingEditAction(); //true, if code stay betwen BeginEntityAction() and EndEntityAction()
|
| 52 |
+
proto native bool UndoOrRedoIsRestoring(); //true, if editor is restoring undo or redo state
|
| 53 |
+
proto native bool IsModifyingData();
|
| 54 |
+
proto native IEntity SourceToEntity(IEntitySource entSrc);
|
| 55 |
+
proto native IEntitySource EntityToSource(IEntity ent);
|
| 56 |
+
proto native IEntitySource FindEntityByName(string name);
|
| 57 |
+
|
| 58 |
+
proto native external void SetEntitySelection(IEntity ent);
|
| 59 |
+
proto native external void AddToEntitySelection(IEntity ent);
|
| 60 |
+
proto native void ClearEntitySelection();
|
| 61 |
+
proto native void RemoveFromEntitySelection(IEntity ent);
|
| 62 |
+
proto native void SetPropertySelection(string id);
|
| 63 |
+
|
| 64 |
+
proto native external bool ModifyEntityKey(IEntity ent, string key, string value);
|
| 65 |
+
proto native external bool ModifyEntityTemplateKey(IEntitySource tmpl, string key, string value);
|
| 66 |
+
|
| 67 |
+
proto native external IEntity CreateEntity(string className, string name, int layerId, vector coords, vector angles);
|
| 68 |
+
proto native external IEntity CreateClonedEntity(IEntity ent, string name);
|
| 69 |
+
proto native external bool DeleteEntity(IEntity ent);
|
| 70 |
+
proto native bool DeleteEntities(out array<IEntity> ents);
|
| 71 |
+
proto native IEntity GetEntityUnderCursor();
|
| 72 |
+
|
| 73 |
+
proto native external bool TraceWorldPos(int x, int y, int traceFlags, out vector traceStart, out vector traceEnd, out vector traceDir);
|
| 74 |
+
|
| 75 |
+
proto native int GetSelectedEntitiesCount();
|
| 76 |
+
proto native IEntity GetSelectedEntity(int n = 0);
|
| 77 |
+
|
| 78 |
+
private void WorldEditorAPI() {}
|
| 79 |
+
private void ~WorldEditorAPI() {}
|
| 80 |
+
};
|
| 81 |
+
|
| 82 |
+
class WorldEditorTool
|
| 83 |
+
{
|
| 84 |
+
//! Filled by workbench
|
| 85 |
+
WorldEditorAPI m_API;
|
| 86 |
+
|
| 87 |
+
void OnKeyPressEvent(int key) {}
|
| 88 |
+
void OnKeyReleaseEvent(int key) {}
|
| 89 |
+
void OnEnterEvent() {}
|
| 90 |
+
void OnLeaveEvent() {}
|
| 91 |
+
void OnMouseMoveEvent(float x, float y) {}
|
| 92 |
+
void OnMouseDoubleClickEvent(float x, float y) {}
|
| 93 |
+
void OnMousePressEvent(float x, float y) {}
|
| 94 |
+
void OnMouseReleaseEvent(float x, float y) {}
|
| 95 |
+
void OnWheelEvent(int delta) {}
|
| 96 |
+
|
| 97 |
+
private void WorldEditorTool() {}
|
| 98 |
+
private void ~WorldEditorTool() {}
|
| 99 |
+
};
|
| 100 |
+
|
| 101 |
+
class WorkbenchPlugin
|
| 102 |
+
{
|
| 103 |
+
void Run() {}
|
| 104 |
+
void RunCommandline() {}
|
| 105 |
+
void Configure() {}
|
| 106 |
+
};
|
| 107 |
+
|
| 108 |
+
class ButtonAttribute
|
| 109 |
+
{
|
| 110 |
+
string m_Label;
|
| 111 |
+
bool m_Focused;
|
| 112 |
+
|
| 113 |
+
void ButtonAttribute(string label = "ScriptButton", bool focused = false)
|
| 114 |
+
{
|
| 115 |
+
m_Label = label;
|
| 116 |
+
m_Focused = focused;
|
| 117 |
+
}
|
| 118 |
+
};
|
| 119 |
+
|
| 120 |
+
/*!
|
| 121 |
+
Attribute for Workbench plugin definition:
|
| 122 |
+
name - ui name in Script Tools menu
|
| 123 |
+
description - tooltip
|
| 124 |
+
shortcut - shortcut in simple text form e.g. "ctrl+g"
|
| 125 |
+
icon - relative path to icon file (32x32 png)
|
| 126 |
+
wbModules - list of strings representing Workbench modules where this tool should be avalaible (e.g. {"ResourceManager", "ScriptEditor"}). Leave null or empty array for any module.
|
| 127 |
+
*/
|
| 128 |
+
class WorkbenchPluginAttribute
|
| 129 |
+
{
|
| 130 |
+
string m_Name;
|
| 131 |
+
string m_Icon;
|
| 132 |
+
string m_Shortcut;
|
| 133 |
+
string m_Description;
|
| 134 |
+
ref array<string> m_WBModules;
|
| 135 |
+
|
| 136 |
+
void WorkbenchPluginAttribute(string name, string description = "", string shortcut = "", string icon = "", array<string> wbModules = null)
|
| 137 |
+
{
|
| 138 |
+
m_Name = name;
|
| 139 |
+
m_Icon = icon;
|
| 140 |
+
m_Shortcut = shortcut;
|
| 141 |
+
m_Description = description;
|
| 142 |
+
m_WBModules = wbModules;
|
| 143 |
+
}
|
| 144 |
+
};
|
| 145 |
+
|
| 146 |
+
/*!
|
| 147 |
+
Attribute for Workbench tool definition
|
| 148 |
+
*/
|
| 149 |
+
class WorkbenchToolAttribute: WorkbenchPluginAttribute
|
| 150 |
+
{
|
| 151 |
+
}
|
scripts/2_GameLib/DayZ/components/gameLibComponents.c
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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+
typedef int[] IEntityComponentSource;
|
| 5 |
+
class IEntityComponentSource: BaseContainer
|
| 6 |
+
{
|
| 7 |
+
};
|
| 8 |
+
|
| 9 |
+
//!Entity touch event types
|
| 10 |
+
enum TouchEvent
|
| 11 |
+
{
|
| 12 |
+
ON_ENTER,
|
| 13 |
+
ON_STAY,
|
| 14 |
+
ON_EXIT
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
//!Builtin component types
|
| 18 |
+
//TypeID MeshObjectTypeID;
|
| 19 |
+
//TypeID HierarchyTypeID;
|
| 20 |
+
//TypeID RigidBodyTypeID;
|
| 21 |
+
//TypeID SphereGeometryTypeID;
|
| 22 |
+
//TypeID BoxGeometryTypeID;
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class GenericComponent : Managed
|
| 26 |
+
{
|
| 27 |
+
/**
|
| 28 |
+
* Gets current eventmask of the component.
|
| 29 |
+
* \return Returns bitmask of events the component accepts
|
| 30 |
+
*/
|
| 31 |
+
proto native int GetEventMask();
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Sets eventmask. Component accepts only events which has set bits in eventmask.
|
| 35 |
+
* Bits are or'ed with existing bitmask. See enf::EntityEvents.
|
| 36 |
+
* When this method is called in the constructor of the component, it will not properly set the eventmask to the parent entity. You may consider OnComponentInsert event.
|
| 37 |
+
* \param mask Mask of those bits, which will be set.
|
| 38 |
+
* \return Returns bitmask of events the component accepts (result of mask|GetEventMask())
|
| 39 |
+
*/
|
| 40 |
+
proto native int SetEventMask(IEntity owner, int mask);
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Clears bitmask. Component accepts only events which has set bits in eventmask.
|
| 44 |
+
* Only bits set in the mask are cleared. See enf::EntityEvents
|
| 45 |
+
* \param mask Mask of those bits, which will be cleared.
|
| 46 |
+
* \return returns these bits that were set before and now are cleared.
|
| 47 |
+
*/
|
| 48 |
+
proto native int ClearEventMask(IEntity owner, int mask);
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Activate component and calls EOnActivate().
|
| 52 |
+
*/
|
| 53 |
+
proto native void Activate(IEntity owner);
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Deactivate component and calls EOnDectivate().
|
| 57 |
+
*/
|
| 58 |
+
proto native void Deactivate(IEntity owner);
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Returns activity state.
|
| 62 |
+
* \return Returns true, if component is active.
|
| 63 |
+
*/
|
| 64 |
+
proto native bool IsActive();
|
| 65 |
+
|
| 66 |
+
//! Constructor
|
| 67 |
+
protected void GenericComponent(IEntityComponentSource src, IEntity ent);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
class GenericComponentClass
|
| 71 |
+
{
|
| 72 |
+
bool DependsOn(typename otherClass, TypeID otherTypeID) {}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
/**
|
| 76 |
+
* Parent class for all components created in script.
|
| 77 |
+
* Every ScriptComponent is being created in Entity's constructor and may receive following events
|
| 78 |
+
* 1. OnComponentInsert is being called when component is created. This is last event Workbench sends in World Editor edit mode.
|
| 79 |
+
* 2. EOnInit is being called after all components have been inserted and if the component registered event mask EV_INIT
|
| 80 |
+
* 3. EOnActivate is being called if the entity was flagged as TFL_ACTIVE and if the component is active. The component is active by default.
|
| 81 |
+
* 4. EOnXXXs are being called base on event mask component registered
|
| 82 |
+
* 5. EOnDeactivate is being called when Deactivate is called or when the component is being to be removed. Component must be active to be deactivated.
|
| 83 |
+
* 6. OnComponentRemove is being called after a component is removed.
|
| 84 |
+
* 7. EOnDelete is being called after entity is going to be destroyed.
|
| 85 |
+
*/
|
| 86 |
+
class ScriptComponent : GenericComponent
|
| 87 |
+
{
|
| 88 |
+
/*
|
| 89 |
+
Event when owner entity is touched
|
| 90 |
+
\param owner
|
| 91 |
+
Touched entity
|
| 92 |
+
\param extra
|
| 93 |
+
Bitmask of touch types TODO
|
| 94 |
+
*/
|
| 95 |
+
protected void EOnTouch(IEntity owner, int extra);
|
| 96 |
+
|
| 97 |
+
/*!
|
| 98 |
+
Event after component is initialized. At this point all entity's components have recieved OnComponentInsert.
|
| 99 |
+
\param owner
|
| 100 |
+
\param extra
|
| 101 |
+
Number of entity
|
| 102 |
+
*/
|
| 103 |
+
protected void EOnInit(IEntity owner, int extra);
|
| 104 |
+
|
| 105 |
+
/*!
|
| 106 |
+
Extra event of various functional extensions. ATM it's used
|
| 107 |
+
by Trigger when some insider is leaving
|
| 108 |
+
\param owner
|
| 109 |
+
owner actor of event
|
| 110 |
+
\param extra
|
| 111 |
+
Extra value of event
|
| 112 |
+
*/
|
| 113 |
+
protected void EOnExtra(IEntity owner, int extra);
|
| 114 |
+
|
| 115 |
+
/*!
|
| 116 |
+
Event when we are out of visibility
|
| 117 |
+
\param owner
|
| 118 |
+
\param extra
|
| 119 |
+
Frame number
|
| 120 |
+
*/
|
| 121 |
+
protected void EOnNotVisible(IEntity owner, int extra);
|
| 122 |
+
|
| 123 |
+
/*!
|
| 124 |
+
Event when we are visible
|
| 125 |
+
\param owner
|
| 126 |
+
\param extra
|
| 127 |
+
Frame number
|
| 128 |
+
*/
|
| 129 |
+
protected void EOnVisible(IEntity owner, int extra);
|
| 130 |
+
|
| 131 |
+
/*!
|
| 132 |
+
Event every frame
|
| 133 |
+
\param owner
|
| 134 |
+
\param timeSlice
|
| 135 |
+
Time passed since last frame
|
| 136 |
+
*/
|
| 137 |
+
protected void EOnFrame(IEntity owner, float timeSlice);
|
| 138 |
+
|
| 139 |
+
/*!
|
| 140 |
+
Even after physics update
|
| 141 |
+
\param owner
|
| 142 |
+
\param extra
|
| 143 |
+
Frame number
|
| 144 |
+
*/
|
| 145 |
+
protected void EOnPostFrame(IEntity owner, int extra);
|
| 146 |
+
|
| 147 |
+
/*!
|
| 148 |
+
Event from animation system
|
| 149 |
+
\param owner
|
| 150 |
+
\param extra
|
| 151 |
+
extra data
|
| 152 |
+
*/
|
| 153 |
+
protected void EOnAnimEvent(IEntity owner, AnimEvent extra);
|
| 154 |
+
|
| 155 |
+
/*!
|
| 156 |
+
Event from sound system
|
| 157 |
+
\param owner
|
| 158 |
+
\param extra
|
| 159 |
+
extra data
|
| 160 |
+
*/
|
| 161 |
+
protected void EOnSoundEvent(IEntity owner, SoundEvent extra);
|
| 162 |
+
|
| 163 |
+
/*!
|
| 164 |
+
Event after simulated by physics engine (once per frame)
|
| 165 |
+
\param owner
|
| 166 |
+
\param timeslice
|
| 167 |
+
Time slice of simulation step
|
| 168 |
+
*/
|
| 169 |
+
protected void EOnPostSimulate(IEntity owner, float timeslice);
|
| 170 |
+
|
| 171 |
+
/*!
|
| 172 |
+
Event before simulated by physics engine (called from sub-iterations!
|
| 173 |
+
\param owner
|
| 174 |
+
\param timeslice
|
| 175 |
+
Time slice of simulation step
|
| 176 |
+
*/
|
| 177 |
+
protected void EOnSimulate(IEntity owner, float timeslice);
|
| 178 |
+
|
| 179 |
+
/*!
|
| 180 |
+
Event when joint attached to RigidBody of this entity is broken
|
| 181 |
+
\param owner
|
| 182 |
+
owner Entity attached to the joint
|
| 183 |
+
\param extra
|
| 184 |
+
Not used ATM
|
| 185 |
+
*/
|
| 186 |
+
protected void EOnJointBreak(IEntity owner, int extra);
|
| 187 |
+
/*!
|
| 188 |
+
Event when physics engine has moved with this Entity
|
| 189 |
+
\param owner
|
| 190 |
+
World Entity
|
| 191 |
+
\param extra
|
| 192 |
+
Not used ATM
|
| 193 |
+
*/
|
| 194 |
+
protected void EOnPhysicsMove(IEntity owner, int extra);
|
| 195 |
+
|
| 196 |
+
/*!
|
| 197 |
+
Event when physics engine registered contact with owner RigidBody
|
| 198 |
+
\param owner
|
| 199 |
+
\param contact
|
| 200 |
+
Structure describing the contact
|
| 201 |
+
*/
|
| 202 |
+
protected void EOnContact(IEntity owner, Contact extra);
|
| 203 |
+
|
| 204 |
+
/**
|
| 205 |
+
* Event when component is activated.
|
| 206 |
+
*/
|
| 207 |
+
protected void EOnActivate(IEntity owner);
|
| 208 |
+
|
| 209 |
+
/**
|
| 210 |
+
* Event when component is deactivated.
|
| 211 |
+
*/
|
| 212 |
+
protected void EOnDeactivate(IEntity owner);
|
| 213 |
+
|
| 214 |
+
/*!
|
| 215 |
+
Event when a component is created and added to Entity.
|
| 216 |
+
\param owner Entity into which component is added
|
| 217 |
+
\param other Component which is being added into Entity
|
| 218 |
+
*/
|
| 219 |
+
protected void OnComponentInsert(IEntity owner, ScriptComponent other);
|
| 220 |
+
|
| 221 |
+
/*!
|
| 222 |
+
Event when a component is being removed from Entity.
|
| 223 |
+
\param owner Entity from which component is being removed
|
| 224 |
+
\param other Component which is being removed from the Entity
|
| 225 |
+
*/
|
| 226 |
+
protected void OnComponentRemove(IEntity owner, ScriptComponent other);
|
| 227 |
+
|
| 228 |
+
/*!
|
| 229 |
+
Called when Entity is being to be destroyed (deleted) or component to be deleted (see Game::DeleteScriptComponent).
|
| 230 |
+
\param owner Entity which owns the component
|
| 231 |
+
*/
|
| 232 |
+
protected void OnDelete(IEntity owner);
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
typedef int[] SoundHandle;
|
| 236 |
+
|
| 237 |
+
class SignalInput
|
| 238 |
+
{
|
| 239 |
+
string m_name;
|
| 240 |
+
float m_value;
|
| 241 |
+
|
| 242 |
+
void SignalInput()
|
| 243 |
+
{
|
| 244 |
+
m_value = 0;
|
| 245 |
+
}
|
| 246 |
+
};
|
| 247 |
+
|
| 248 |
+
class BaseSoundComponent : GenericComponent
|
| 249 |
+
{
|
| 250 |
+
/* Get list of 'events'. */
|
| 251 |
+
proto native int GetEventNames(out array<string> events);
|
| 252 |
+
/* Get list of 'signals. '*/
|
| 253 |
+
proto native int GetSignalNames(out array<string> signals);
|
| 254 |
+
/* Convert signal name to index. */
|
| 255 |
+
proto native int GetSignalIndex(string name);
|
| 256 |
+
/* Set signal value by 'name'. */
|
| 257 |
+
proto native void SetSignalValueName(string signal, float value);
|
| 258 |
+
/* Set signal value by 'index'. */
|
| 259 |
+
proto native void SetSignalValue(int index, float value);
|
| 260 |
+
/* Play 'event'. */
|
| 261 |
+
proto native SoundHandle Play(string name);
|
| 262 |
+
/* Play sounds based on triggers. */
|
| 263 |
+
proto native SoundHandle Update();
|
| 264 |
+
/* Terminate 'sound'. */
|
| 265 |
+
proto native void Terminate(SoundHandle handle);
|
| 266 |
+
/* Check if 'sound' is played. */
|
| 267 |
+
proto native bool IsPlayed(SoundHandle handle);
|
| 268 |
+
/* Validate handle. */
|
| 269 |
+
proto native bool IsHandleValid(SoundHandle handle);
|
| 270 |
+
/* Set sound position. */
|
| 271 |
+
proto native void SetTransform(vector[] transf);
|
| 272 |
+
/* Enable debug mode. */
|
| 273 |
+
proto native void SetDebug(bool value);
|
| 274 |
+
};
|
| 275 |
+
|
| 276 |
+
#endif
|
scripts/2_GameLib/DayZ/entities/RenderTarget.c
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifdef GAME_TEMPLATE
|
| 2 |
+
|
| 3 |
+
[EditorAttribute("box", "GameLib/Scripted", "Render target", "-0.25 -0.25 -0.25", "0.25 0.25 0.25", "255 0 0 255")]
|
| 4 |
+
class RenderTargetClass
|
| 5 |
+
{
|
| 6 |
+
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
RenderTargetClass RenderTargetSource;
|
| 10 |
+
|
| 11 |
+
class RenderTarget: GenericEntity
|
| 12 |
+
{
|
| 13 |
+
[Attribute("0", "slider", "Camera index", "0 31 1")]
|
| 14 |
+
int CameraIndex;
|
| 15 |
+
[Attribute("0", "editbox", "Position X <0, 1>")]
|
| 16 |
+
float X;
|
| 17 |
+
[Attribute("0", "editbox", "Position Y <0, 1>")]
|
| 18 |
+
float Y;
|
| 19 |
+
[Attribute("1", "editbox", "Render target width <0, 1>")]
|
| 20 |
+
float Width;
|
| 21 |
+
[Attribute("1", "editbox", "Render target height <0, 1>")]
|
| 22 |
+
float Height;
|
| 23 |
+
[Attribute("-1", "editbox", "Sort index (the lesser the more important)")]
|
| 24 |
+
int Sort;
|
| 25 |
+
[Attribute("0", "combobox", "Autoinit", "", { ParamEnum("No", "0"), ParamEnum("Yes", "1") } )]
|
| 26 |
+
int AutoInit;
|
| 27 |
+
[Attribute("0", "combobox", "Forcing creation of render target for camera #0 in Workbench", "", { ParamEnum("No", "0"), ParamEnum("Yes", "1") } )]
|
| 28 |
+
bool ForceCreation;
|
| 29 |
+
bool m_Show = true; // when autoinit, wait with showing the render target after all entities are created (EOnInit)
|
| 30 |
+
ref RenderTargetWidget m_RenderWidget;
|
| 31 |
+
|
| 32 |
+
void RenderTarget(IEntitySource src, IEntity parent)
|
| 33 |
+
{
|
| 34 |
+
SetFlags(EntityFlags.ACTIVE, false);
|
| 35 |
+
|
| 36 |
+
if (AutoInit)
|
| 37 |
+
{
|
| 38 |
+
m_Show = false;
|
| 39 |
+
SetEventMask(EntityEvent.INIT);
|
| 40 |
+
Init();
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
void ~RenderTarget()
|
| 45 |
+
{
|
| 46 |
+
delete m_RenderWidget;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
void Init()
|
| 50 |
+
{
|
| 51 |
+
#ifdef WORKBENCH // Workbench is using its own renderer for main camera, it is not using render target widget.
|
| 52 |
+
if (!ForceCreation && CameraIndex == 0)
|
| 53 |
+
return;
|
| 54 |
+
#endif
|
| 55 |
+
|
| 56 |
+
int screenW, screenH;
|
| 57 |
+
GetScreenSize(screenW, screenH);
|
| 58 |
+
|
| 59 |
+
int posX = (float)(screenW * X);
|
| 60 |
+
int posY = (float)(screenH * Y);
|
| 61 |
+
int widthPix = (float)(screenW * Width);
|
| 62 |
+
int heightPix = (float)(screenH * Height);
|
| 63 |
+
if (Class.CastTo(m_RenderWidget, GetGame().GetWorkspace().CreateWidget(RenderTargetWidgetTypeID, posX, posY, widthPix, heightPix, WidgetFlags.VISIBLE | WidgetFlags.HEXACTSIZE | WidgetFlags.VEXACTSIZE | WidgetFlags.HEXACTPOS | WidgetFlags.VEXACTPOS, 0xffffffff, Sort)))
|
| 64 |
+
{
|
| 65 |
+
m_RenderWidget.Show(m_Show);
|
| 66 |
+
SetWidgetWorld(m_RenderWidget, GetGame().GetWorldEntity(), CameraIndex);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
override void EOnInit(IEntity other, int extra) //!EntityEvent.INIT
|
| 70 |
+
{
|
| 71 |
+
if (m_RenderWidget)
|
| 72 |
+
{
|
| 73 |
+
m_Show = true;
|
| 74 |
+
m_RenderWidget.Show(m_Show);
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
#endif
|
scripts/2_GameLib/DayZ/entities/ScriptCamera.c
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
ScriptCameraClass ScriptCameraSource;
|
| 10 |
+
|
| 11 |
+
class ScriptCamera: GenericEntity
|
| 12 |
+
{
|
| 13 |
+
[Attribute("60", "slider", "Field of view", "0 180 1")]
|
| 14 |
+
float FOV;
|
| 15 |
+
[Attribute("1", "editbox", "Near plane clip")]
|
| 16 |
+
float NearPlane;
|
| 17 |
+
[Attribute("4000", "editbox", "Far plane clip")]
|
| 18 |
+
float FarPlane;
|
| 19 |
+
|
| 20 |
+
[Attribute("1", "combobox", "Projection type", "", ParamEnumArray.FromEnum(CameraType) )]
|
| 21 |
+
int Type;
|
| 22 |
+
[Attribute("5", "slider", "Camera speed", "0 20 1")]
|
| 23 |
+
float Speed;
|
| 24 |
+
[Attribute("1", "combobox", "Free Fly", "", ParamEnumArray.FromEnum(EBool) )]
|
| 25 |
+
bool FreeFly;
|
| 26 |
+
[Attribute("0", "combobox", "Invert vertical", "", ParamEnumArray.FromEnum(EBool) )]
|
| 27 |
+
bool Inverted;
|
| 28 |
+
[Attribute("0", "slider", "Camera index", "0 31 1")]
|
| 29 |
+
int Index;
|
| 30 |
+
float m_MouseSensitivity = 0.001; // should be somewhere else.
|
| 31 |
+
float m_GamepadSensitivity = 0.2; // should be somewhere else.
|
| 32 |
+
int m_GamepadFreeFly;
|
| 33 |
+
|
| 34 |
+
// debug variables
|
| 35 |
+
int m_DbgListSelection = 0;
|
| 36 |
+
ref array<string> m_DbgOptions = {"Perspective", "Orthographic"};
|
| 37 |
+
|
| 38 |
+
void ScriptCamera(IEntitySource src, IEntity parent)
|
| 39 |
+
{
|
| 40 |
+
SetFlags(EntityFlags.ACTIVE, false);
|
| 41 |
+
SetEventMask(EntityEvent.FRAME);
|
| 42 |
+
|
| 43 |
+
SetCameraVerticalFOV(Index, FOV);
|
| 44 |
+
SetCameraFarPlane(Index, FarPlane);
|
| 45 |
+
SetCameraNearPlane(Index, NearPlane);
|
| 46 |
+
SetCameraType(Index, Type);
|
| 47 |
+
m_DbgListSelection = Type - 1;
|
| 48 |
+
SetCamera(Index, GetOrigin(), GetYawPitchRoll());
|
| 49 |
+
|
| 50 |
+
vector camMat[4];
|
| 51 |
+
GetTransform(camMat);
|
| 52 |
+
SetCameraEx(Index, camMat);
|
| 53 |
+
m_GamepadFreeFly = FreeFly;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
override protected void EOnFrame(IEntity other, float timeSlice) //EntityEvent.FRAME
|
| 57 |
+
{
|
| 58 |
+
GetGame().GetInputManager().ActivateContext("ScriptCameraContext");
|
| 59 |
+
|
| 60 |
+
if (GetGame().GetInputManager().GetActionTriggered("CamFreeFly"))
|
| 61 |
+
{
|
| 62 |
+
FreeFly = !FreeFly;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
if (FreeFly)
|
| 66 |
+
{
|
| 67 |
+
FreeFly(timeSlice);
|
| 68 |
+
}
|
| 69 |
+
else
|
| 70 |
+
{
|
| 71 |
+
vector camMat[4]; // matrix can be set outside the class
|
| 72 |
+
GetTransform(camMat);
|
| 73 |
+
SetCameraEx(Index, camMat);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
if (GameSettings.Debug)
|
| 77 |
+
{
|
| 78 |
+
DebugInfo();
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
protected void FreeFly(float timeSlice)
|
| 83 |
+
{
|
| 84 |
+
vector camPosition = GetOrigin();
|
| 85 |
+
vector angles = GetYawPitchRoll();
|
| 86 |
+
vector camMat[4];
|
| 87 |
+
GetTransform(camMat);
|
| 88 |
+
InputManager imanager = GetGame().GetInputManager();
|
| 89 |
+
imanager.ActivateContext("ScriptCameraFreeFlyContext");
|
| 90 |
+
|
| 91 |
+
// get input
|
| 92 |
+
float turnX = imanager.LocalValue("CamTurnRight") * 20.0 * timeSlice;
|
| 93 |
+
float turnY = imanager.LocalValue("CamTurnUp") * 20.0 * timeSlice;
|
| 94 |
+
float turnZ = imanager.LocalValue("CamRotate") * 20.0 * timeSlice;
|
| 95 |
+
float moveForward = imanager.LocalValue("CamForward");
|
| 96 |
+
float moveRight = imanager.LocalValue("CamRight");
|
| 97 |
+
float moveAscend = imanager.LocalValue("CamAscend");
|
| 98 |
+
float speedDelta = imanager.LocalValue("CamSpeedDelta") * timeSlice;
|
| 99 |
+
bool speedBoostHigh = imanager.GetActionTriggered("CamSpeedBoostHigh");
|
| 100 |
+
bool speedBoostLow = imanager.GetActionTriggered("CamSpeedBoostLow");
|
| 101 |
+
|
| 102 |
+
Speed = Math.Clamp(Speed + speedDelta * Speed * 0.25, 0.1, 1000.0);
|
| 103 |
+
|
| 104 |
+
float finalSpeed = Speed;
|
| 105 |
+
if (speedBoostLow)
|
| 106 |
+
finalSpeed *= 25;
|
| 107 |
+
else if (speedBoostHigh)
|
| 108 |
+
finalSpeed *= 5;
|
| 109 |
+
|
| 110 |
+
// rotation
|
| 111 |
+
angles[0] = turnX + angles[0];
|
| 112 |
+
if (Inverted)
|
| 113 |
+
angles[1] = turnY + angles[1];
|
| 114 |
+
else
|
| 115 |
+
angles[1] = -turnY + angles[1];
|
| 116 |
+
|
| 117 |
+
angles[2] = turnZ + angles[2];
|
| 118 |
+
|
| 119 |
+
// movement
|
| 120 |
+
vector move = vector.Zero;
|
| 121 |
+
vector forward = camMat[2];
|
| 122 |
+
vector up = camMat[1];
|
| 123 |
+
vector side = camMat[0];
|
| 124 |
+
|
| 125 |
+
move += forward * moveForward;
|
| 126 |
+
move += side * moveRight;
|
| 127 |
+
move += up * moveAscend;
|
| 128 |
+
|
| 129 |
+
// ------------
|
| 130 |
+
camPosition = (move * timeSlice * finalSpeed) + camPosition;
|
| 131 |
+
|
| 132 |
+
Math3D.YawPitchRollMatrix(angles, camMat);
|
| 133 |
+
camMat[3] = camPosition;
|
| 134 |
+
SetTransform(camMat);
|
| 135 |
+
SetCameraEx(Index, camMat);
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
protected void DebugInfo()
|
| 139 |
+
{
|
| 140 |
+
InputManager imanager = GetGame().GetInputManager();
|
| 141 |
+
DbgUI.Begin(String("Camera #" + Index.ToString()), 0, Index * 300);
|
| 142 |
+
|
| 143 |
+
DbgUI.Text(String("Position : " + GetOrigin().ToString()));
|
| 144 |
+
DbgUI.Text(String("Orientation (Y, P, R): " + GetYawPitchRoll().ToString()));
|
| 145 |
+
DbgUI.Text(String("Speed : " + Speed.ToString()));
|
| 146 |
+
DbgUI.Text(String("Mouse sensitivity : " + (2000 - (1 / m_MouseSensitivity)).ToString()));
|
| 147 |
+
DbgUI.Check("Select Free fly", FreeFly);
|
| 148 |
+
DbgUI.List("Camera type", m_DbgListSelection, m_DbgOptions);
|
| 149 |
+
if (m_DbgListSelection + 1 != Type)
|
| 150 |
+
{
|
| 151 |
+
Type = m_DbgListSelection + 1;
|
| 152 |
+
SetCameraType(Index, Type);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
float sensitivity = 2000 - (1 / m_MouseSensitivity);
|
| 156 |
+
DbgUI.SliderFloat("Mouse sensitivity", sensitivity, 1, 1999);
|
| 157 |
+
m_MouseSensitivity = 1 / (2000 - sensitivity);
|
| 158 |
+
|
| 159 |
+
DbgUI.Text("CamTurnRight: " + imanager.LocalValue("CamTurnRight"));
|
| 160 |
+
DbgUI.Text("CamTurnUp: " + imanager.LocalValue("CamTurnUp"));
|
| 161 |
+
DbgUI.Text("CamSpeedDelta: " + imanager.LocalValue("CamSpeedDelta"));
|
| 162 |
+
DbgUI.Text("CamForward: " + imanager.LocalValue("CamForward"));
|
| 163 |
+
DbgUI.Text("CamRight: " +imanager.LocalValue("CamRight"));
|
| 164 |
+
DbgUI.Text("CamAscend: " + imanager.LocalValue("CamAscend"));
|
| 165 |
+
DbgUI.Text("CamSpeedBoostHigh: " + imanager.GetActionTriggered("CamSpeedBoostHigh"));
|
| 166 |
+
DbgUI.Text("CamSpeedBoostLow:" + imanager.GetActionTriggered("CamSpeedBoostLow"));
|
| 167 |
+
|
| 168 |
+
DbgUI.End();
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
#endif
|
scripts/2_GameLib/DayZ/entities/ScriptLight.c
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifdef GAME_TEMPLATE
|
| 2 |
+
|
| 3 |
+
[EditorAttribute("box", "GameLib/Scripted", "Script light", "-0.25 -0.25 -0.25", "0.25 0.25 0.25", "255 0 0 255")]
|
| 4 |
+
class ScriptLightClass
|
| 5 |
+
{
|
| 6 |
+
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
ScriptLightClass ScriptLightSource;
|
| 10 |
+
|
| 11 |
+
class ScriptLight: GenericEntity
|
| 12 |
+
{
|
| 13 |
+
[Attribute("1", "flags", "Flags", "", { ParamEnum("Point", "1"), ParamEnum("Spot", "2"), ParamEnum("Directional", "4") } )]
|
| 14 |
+
int Flags;
|
| 15 |
+
[Attribute("1", "combobox", "Type", "", { ParamEnum("Point", "1"), ParamEnum("Spot", "2"), ParamEnum("Directional", "3") } )]
|
| 16 |
+
int Type;
|
| 17 |
+
[Attribute("1", "editbox", "Radius", "", NULL )]
|
| 18 |
+
float Radius;
|
| 19 |
+
[Attribute("1 1 1", "color", "Color", "", NULL )]
|
| 20 |
+
vector Color;
|
| 21 |
+
[Attribute("1", "editbox", "Intensity", "", NULL )]
|
| 22 |
+
float Intensity;
|
| 23 |
+
HLIGHT m_light;
|
| 24 |
+
|
| 25 |
+
void ScriptLight(IEntitySource src, IEntity parent)
|
| 26 |
+
{
|
| 27 |
+
//SetFlags(this, EntityFlags.ACTIVE | EntityFlags.SOLID | EntityFlags.VISIBLE);
|
| 28 |
+
m_light = AddLight(this, LightType.POINT, LightFlags.DYNAMIC|LightFlags.CASTSHADOW, Radius, Color * Intensity);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
void ~ScriptLight()
|
| 32 |
+
{
|
| 33 |
+
if(m_light)
|
| 34 |
+
{
|
| 35 |
+
RemoveLight(m_light);
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
#endif
|
scripts/2_GameLib/DayZ/entities/ScriptModel.c
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifdef GAME_TEMPLATE
|
| 2 |
+
|
| 3 |
+
[EditorAttribute("box", "GameLib/Scripted", "Script model", "-0.25 -0.25 -0.25", "0.25 0.25 0.25", "255 0 0 255", "0 0 0 0", true, true, true)]
|
| 4 |
+
class ScriptModelClass
|
| 5 |
+
{
|
| 6 |
+
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
ScriptModelClass ScriptModelSource;
|
| 10 |
+
|
| 11 |
+
class ScriptModel: GenericEntity
|
| 12 |
+
{
|
| 13 |
+
[Attribute("", "resourceNamePicker", "Model", "xob")]
|
| 14 |
+
string Model;
|
| 15 |
+
[Attribute("1", "combobox", "Physics", "", { ParamEnum("None", "2"), ParamEnum("Static", "1"), ParamEnum("Dynamic", "0") } )]
|
| 16 |
+
int Type;
|
| 17 |
+
|
| 18 |
+
void ScriptModel(IEntitySource src, IEntity parent)
|
| 19 |
+
{
|
| 20 |
+
if (Model== "")
|
| 21 |
+
return;
|
| 22 |
+
|
| 23 |
+
SetFlags(EntityFlags.ACTIVE | EntityFlags.SOLID | EntityFlags.VISIBLE, false);
|
| 24 |
+
|
| 25 |
+
vobject vobj = GetObject(Model);
|
| 26 |
+
SetObject(vobj, "");
|
| 27 |
+
ReleaseObject(vobj, false);
|
| 28 |
+
|
| 29 |
+
if (Type == 1)
|
| 30 |
+
{
|
| 31 |
+
dBodyCreateStatic(this, 0xffffffff); // todo - defines for layer mask
|
| 32 |
+
}
|
| 33 |
+
else if (Type == 0)
|
| 34 |
+
{
|
| 35 |
+
if(!dBodyCreateDynamic(this, 1.0, 0xffffffff))
|
| 36 |
+
{
|
| 37 |
+
//create implicit box
|
| 38 |
+
vector mins, maxs;
|
| 39 |
+
GetBounds(mins, maxs);
|
| 40 |
+
vector center = (mins + maxs) * 0.5;
|
| 41 |
+
vector size = maxs - mins;
|
| 42 |
+
|
| 43 |
+
PhysicsGeomDef geoms[] = {PhysicsGeomDef("", dGeomCreateBox(size), "material/default", 0xffffffff)};
|
| 44 |
+
dBodyCreateDynamicEx(this, center, 1, geoms);
|
| 45 |
+
}
|
| 46 |
+
if(dBodyIsSet(this))
|
| 47 |
+
{
|
| 48 |
+
dBodySetMass(this, 1.0);
|
| 49 |
+
dBodyActive(this, ActiveState.ACTIVE);
|
| 50 |
+
dBodyDynamic(this, true);
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
void ~ScriptModel()
|
| 56 |
+
{
|
| 57 |
+
if(dBodyIsSet(this))
|
| 58 |
+
dBodyDestroy(this);
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
#endif
|
scripts/2_GameLib/DayZ/entities/WorldsMenu.c
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifdef GAME_TEMPLATE
|
| 2 |
+
|
| 3 |
+
[EditorAttribute("box", "GameLib/Scripted", "Worlds menu", "-0.25 -0.25 -0.25", "0.25 0.25 0.25", "255 0 0 255")]
|
| 4 |
+
class WorldsMenuClass
|
| 5 |
+
{
|
| 6 |
+
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
WorldsMenuClass WorldsMenuSource;
|
| 10 |
+
|
| 11 |
+
class WorldsMenu: GenericEntity
|
| 12 |
+
{
|
| 13 |
+
int m_DbgListSelection = 0;
|
| 14 |
+
int m_WorldsCount = 0;
|
| 15 |
+
string DEFAULT_WORLD = "worlds/default.ent";
|
| 16 |
+
ref array<string> m_DbgOptions = {};
|
| 17 |
+
ref ImageWidget m_MouseWidget;
|
| 18 |
+
|
| 19 |
+
void WorldsMenu(IEntitySource src, IEntity parent)
|
| 20 |
+
{
|
| 21 |
+
SetFlags(EntityFlags.ACTIVE, false);
|
| 22 |
+
SetEventMask(EntityEvent.POSTFRAME);
|
| 23 |
+
|
| 24 |
+
Class.CastTo(m_MouseWidget, GetGame().GetWorkspace().CreateWidgets("gui/layouts/mouse.layout"));
|
| 25 |
+
m_MouseWidget.SetSort(1024);
|
| 26 |
+
SetCursorWidget(m_MouseWidget);
|
| 27 |
+
|
| 28 |
+
LoadWorlds();
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
void ~WorldsMenu()
|
| 32 |
+
{
|
| 33 |
+
delete m_MouseWidget;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
array<string> GetWorldList()
|
| 37 |
+
{
|
| 38 |
+
return m_DbgOptions;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
override void EOnPostFrame(IEntity other, int extra) //EntityEvent.POSTFRAME
|
| 42 |
+
{
|
| 43 |
+
InputManager im = GetGame().GetInputManager();
|
| 44 |
+
im.ActivateContext("MenuContext");
|
| 45 |
+
bool menuSelect = im.GetActionTriggered("MenuSelect");
|
| 46 |
+
bool menuBack = im.GetActionTriggered("MenuBack");
|
| 47 |
+
|
| 48 |
+
DbgUI.Begin("Load world", 400, 100);
|
| 49 |
+
|
| 50 |
+
DbgUI.Text("Select world to load from worlds directory");
|
| 51 |
+
|
| 52 |
+
if (m_DbgOptions.Count() > 0)
|
| 53 |
+
{
|
| 54 |
+
DbgUI.List("Worlds", m_DbgListSelection, m_DbgOptions);
|
| 55 |
+
if (DbgUI.Button("Start") || menuSelect)
|
| 56 |
+
{
|
| 57 |
+
string worldToLoad = m_DbgOptions.Get(m_DbgListSelection);
|
| 58 |
+
GetGame().SetWorldFile(worldToLoad, true);
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
if (DbgUI.Button("Exit") || menuBack)
|
| 62 |
+
{
|
| 63 |
+
GetGame().RequestClose();
|
| 64 |
+
}
|
| 65 |
+
DbgUI.End();
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
void LoadWorlds()
|
| 69 |
+
{
|
| 70 |
+
string fileName;
|
| 71 |
+
FileAttr fileAttr;
|
| 72 |
+
FindFileHandle worlds = FindFile("worlds/*.ent", fileName, fileAttr, 0);
|
| 73 |
+
|
| 74 |
+
if (!worlds)
|
| 75 |
+
return;
|
| 76 |
+
|
| 77 |
+
InsertWorldToList(fileName);
|
| 78 |
+
|
| 79 |
+
while(FindNextFile(worlds, fileName, fileAttr))
|
| 80 |
+
{
|
| 81 |
+
InsertWorldToList(fileName);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
CloseFindFile(worlds);
|
| 85 |
+
|
| 86 |
+
m_WorldsCount = m_DbgOptions.Count();
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
void InsertWorldToList(string fileName)
|
| 90 |
+
{
|
| 91 |
+
string path = String("worlds/" + fileName);
|
| 92 |
+
if (path != DEFAULT_WORLD)
|
| 93 |
+
m_DbgOptions.Insert(String(path));
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
#endif
|
scripts/2_GameLib/DayZ/entities/gameLibEntities.c
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//Generic entities from GameLib (script side of c++ classes)
|
| 2 |
+
|
| 3 |
+
#ifdef COMPONENT_SYSTEM
|
| 4 |
+
class GenericEntity extends IEntity
|
| 5 |
+
{
|
| 6 |
+
//native method implemented on c++ side
|
| 7 |
+
proto native void Show(bool show);
|
| 8 |
+
|
| 9 |
+
/*!
|
| 10 |
+
Finds first occurance of the coresponding component.
|
| 11 |
+
\param typeName type of the component
|
| 12 |
+
*/
|
| 13 |
+
proto native GenericComponent FindComponent(typename typeName);
|
| 14 |
+
|
| 15 |
+
/*!
|
| 16 |
+
inserts instance of the script component to the entity.
|
| 17 |
+
Calls OnComponentInsert on all entity's components to inform that this new component was inserted. The new instance have to FindScriptComponents in order to work with them.
|
| 18 |
+
Calls EOnInit on the component if component sets EV_INIT mask.
|
| 19 |
+
Calls EOnActivate on the component if the component is active (default)
|
| 20 |
+
\param component instance
|
| 21 |
+
*/
|
| 22 |
+
proto native void InsertComponent(GenericComponent component);
|
| 23 |
+
|
| 24 |
+
/*!
|
| 25 |
+
Removes component from entity. Doesn't delete the entity.
|
| 26 |
+
Calls EOnDeactivate on the component.
|
| 27 |
+
Calls OnComponentRemove on all entity's components to inform that this new component was removed.
|
| 28 |
+
\param component instance
|
| 29 |
+
*/
|
| 30 |
+
proto native void RemoveComponent(GenericComponent component);
|
| 31 |
+
|
| 32 |
+
/*!
|
| 33 |
+
Removes and deletes component from entity.
|
| 34 |
+
Calls EOnDeactivate on the component.
|
| 35 |
+
Calls OnComponentRemove on all entity's components to inform that this new component was removed.
|
| 36 |
+
Calls OnDelete on the component.
|
| 37 |
+
\param component instance
|
| 38 |
+
*/
|
| 39 |
+
proto native void DeleteComponent(GenericComponent component);
|
| 40 |
+
|
| 41 |
+
#ifdef WORKBENCH
|
| 42 |
+
/*!
|
| 43 |
+
Called after updating world in Workbench. The entity must be selected.
|
| 44 |
+
*/
|
| 45 |
+
void _WB_AfterWorldUpdate(float timeSlice) {};
|
| 46 |
+
#endif
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
class GenericWorldEntity extends GenericEntity
|
| 50 |
+
{
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
class GenericTerrainEntity extends GenericEntity
|
| 54 |
+
{
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
class LightEntity extends GenericEntity
|
| 58 |
+
{
|
| 59 |
+
/*!
|
| 60 |
+
Sets diffuse part of light.
|
| 61 |
+
\param color Color of light
|
| 62 |
+
*/
|
| 63 |
+
proto native external void SetDiffuseColor(int color);
|
| 64 |
+
proto native external int GetDiffuseColor();
|
| 65 |
+
|
| 66 |
+
proto native external void SetRadius(float radius);
|
| 67 |
+
proto native external float GetRadius();
|
| 68 |
+
|
| 69 |
+
/*!
|
| 70 |
+
Sets cone of light. It's meaningful for LT_SPOT only!
|
| 71 |
+
\param angle
|
| 72 |
+
*/
|
| 73 |
+
proto native external void SetConeAngle(float angle);
|
| 74 |
+
/*!
|
| 75 |
+
Gets cone of light. It's meaningful for LT_SPOT only!
|
| 76 |
+
\return Cone of light
|
| 77 |
+
*/
|
| 78 |
+
proto native external float GetConeAngle();
|
| 79 |
+
|
| 80 |
+
proto native external void SetCastShadow(bool enable);
|
| 81 |
+
proto native external bool IsCastShadow(bool enable);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
class GenericWorldLightEntity extends GenericEntity
|
| 85 |
+
{
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
class GenericWorldFogEntity extends GenericEntity
|
| 89 |
+
{
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
class BasicEntity extends GenericEntity
|
| 93 |
+
{
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
class WorldEntityClass
|
| 97 |
+
{
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
class WorldEntity extends GenericWorldEntity
|
| 101 |
+
{
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
class ModelEntity extends BasicEntity
|
| 105 |
+
{
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
enum CharacterMovement
|
| 109 |
+
{
|
| 110 |
+
MOVEMENTTYPE_IDLE,
|
| 111 |
+
MOVEMENTTYPE_WALK,
|
| 112 |
+
MOVEMENTTYPE_RUN,
|
| 113 |
+
MOVEMENTTYPE_SPRINT
|
| 114 |
+
};
|
| 115 |
+
|
| 116 |
+
enum CharacterStance
|
| 117 |
+
{
|
| 118 |
+
STANCE_ERECT,
|
| 119 |
+
STANCE_CROUCH,
|
| 120 |
+
STANCE_PRONE,
|
| 121 |
+
STANCE_ERECT_RAISED,
|
| 122 |
+
STANCE_CROUCH_RAISED,
|
| 123 |
+
STANCE_PRONE_RAISED
|
| 124 |
+
};
|
| 125 |
+
|
| 126 |
+
class CharacterEntity extends BasicEntity
|
| 127 |
+
{
|
| 128 |
+
proto native void Teleport(vector transform[4]);
|
| 129 |
+
proto native CharacterMovement GetCurrentMovement();
|
| 130 |
+
proto native CharacterStance GetCurrentStance();
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
class BasicCamera extends BasicEntity
|
| 134 |
+
{
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
class VRHandEntity extends GenericEntity
|
| 138 |
+
{
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
#endif
|
scripts/2_GameLib/DayZ/gameLib.c
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifdef GAME_TEMPLATE
|
| 2 |
+
Game g_Game;
|
| 3 |
+
|
| 4 |
+
Game GetGame()
|
| 5 |
+
{
|
| 6 |
+
return g_Game;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
class Game
|
| 10 |
+
{
|
| 11 |
+
ScriptModule GameScript;
|
| 12 |
+
|
| 13 |
+
ScriptModule GetScriptModule()
|
| 14 |
+
{
|
| 15 |
+
return GameScript;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
void SetDebug(bool isDebug) {}
|
| 19 |
+
//!
|
| 20 |
+
/**
|
| 21 |
+
\brief Called when some system event occur.
|
| 22 |
+
@param eventTypeId event type.
|
| 23 |
+
@param params Param object, cast to specific param class to get parameters for particular event.
|
| 24 |
+
*/
|
| 25 |
+
void OnEvent(EventType eventTypeId, Param params)
|
| 26 |
+
{
|
| 27 |
+
Print("OnEvent");
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
\brief Called after full initialization of Game instance
|
| 32 |
+
*/
|
| 33 |
+
void OnAfterInit()
|
| 34 |
+
{
|
| 35 |
+
Print("OnAfterInit");
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
\brief Called on World update
|
| 40 |
+
@param timeslice time elapsed from last call
|
| 41 |
+
*/
|
| 42 |
+
void OnUpdate(float timeslice)
|
| 43 |
+
{
|
| 44 |
+
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
\brief Sets world file to be loaded. Returns false if file doesn't exist.
|
| 49 |
+
@param path Path to the ent file
|
| 50 |
+
@param reload Force reload the world
|
| 51 |
+
*/
|
| 52 |
+
proto native bool SetWorldFile(string path, bool reload);
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
\brief Returns path of world file loaded
|
| 56 |
+
*/
|
| 57 |
+
proto native owned string GetWorldFile();
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
\brief Event which is called right before game starts (all entities are created and initialized). Returns true if the game can start.
|
| 61 |
+
*/
|
| 62 |
+
bool OnGameStart()
|
| 63 |
+
{
|
| 64 |
+
return true;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
\brief Event which is called right before game end.
|
| 69 |
+
*/
|
| 70 |
+
void OnGameEnd()
|
| 71 |
+
{
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
\brief Creates loading screen
|
| 76 |
+
*/
|
| 77 |
+
void ShowLoadingAnim()
|
| 78 |
+
{
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
\brief Hides loading screen
|
| 83 |
+
*/
|
| 84 |
+
void HideLoadingAnim()
|
| 85 |
+
{
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
\brief Used for updating the loading screen
|
| 90 |
+
@param timeslice
|
| 91 |
+
@param progress loading progress between 0 and 1
|
| 92 |
+
*/
|
| 93 |
+
void UpdateLoadingAnim(float timeslice, float progress)
|
| 94 |
+
{
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
\brief Safely instantiate the entity and calls EOnInit if the entity sets event mask EntityEvent.INIT.
|
| 99 |
+
@param typename Name of entity's type to instantiate.
|
| 100 |
+
@return instantiated entity
|
| 101 |
+
*/
|
| 102 |
+
proto native IEntity SpawnEntity(typename typeName);
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
\brief Safely instantiate the entity from template (with all components) and calls EOnInit if the entity sets event mask EntityEvent.INIT.
|
| 106 |
+
@param templateResource Template resource of the entity to instantiate.
|
| 107 |
+
@return instantiated entity
|
| 108 |
+
*/
|
| 109 |
+
proto native IEntity SpawnEntityTemplate(vobject templateResource);
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
\brief Safely instantiate the component from template, insert it to entity and calls EOnInit if the component sets event mask EntityEvent.INIT.
|
| 113 |
+
@param owner Entity which will own the component
|
| 114 |
+
@param templateResource Template resource of the component to instantiate.
|
| 115 |
+
@return instantiated component
|
| 116 |
+
*/
|
| 117 |
+
proto native GenericComponent SpawnComponentTemplate(IEntity owner, vobject templateResource);
|
| 118 |
+
|
| 119 |
+
proto native IEntity FindEntity(string name);
|
| 120 |
+
|
| 121 |
+
proto native WorkspaceWidget GetWorkspace();
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
\brief Setting request flag for engine to exit the game
|
| 125 |
+
*/
|
| 126 |
+
proto native void RequestClose();
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
\brief Setting request flag for the engine to reinitialize the game
|
| 130 |
+
* Doesn't do anything in Workbench
|
| 131 |
+
*/
|
| 132 |
+
proto native void RequestReload();
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
\brief Returns version of the game
|
| 136 |
+
*/
|
| 137 |
+
proto native owned string GetBuildVersion();
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
\brief Returns date and time when the game was built
|
| 141 |
+
*/
|
| 142 |
+
proto native owned string GetBuildTime();
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
\brief Returns World entity when in game or in play mode in WE. NULL otherwise.
|
| 146 |
+
*/
|
| 147 |
+
proto native GenericWorldEntity GetWorldEntity();
|
| 148 |
+
|
| 149 |
+
proto native InputManager GetInputManager();
|
| 150 |
+
proto native MenuManager GetMenuManager();
|
| 151 |
+
proto native int GetTickCount();
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
void GameLibInit()
|
| 155 |
+
{
|
| 156 |
+
|
| 157 |
+
}
|
| 158 |
+
#endif
|
scripts/2_GameLib/DayZ/inputManager.c
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifdef GAME_TEMPLATE
|
| 2 |
+
|
| 3 |
+
enum InputTrigger
|
| 4 |
+
{
|
| 5 |
+
UP, ///< call listener when button/key is released
|
| 6 |
+
DOWN, ///< call listener when button/key is pressed
|
| 7 |
+
PRESSED, ///< call listener in each tick when button/key is pressed
|
| 8 |
+
VALUE ///< call listener in each tick with current value
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
class ActionManager
|
| 12 |
+
{
|
| 13 |
+
void ActionManager(ActionManager parent);
|
| 14 |
+
proto native external bool RegisterAction(string actionName);
|
| 15 |
+
proto native external bool RegisterContext(string contextName);
|
| 16 |
+
|
| 17 |
+
proto native external float LocalValue(string actionName);
|
| 18 |
+
proto native external bool GetActionTriggered(string actionName);
|
| 19 |
+
|
| 20 |
+
proto native external bool ActivateAction(string actionName, int duration = 0);
|
| 21 |
+
proto native external bool IsActionActive(string actionName);
|
| 22 |
+
|
| 23 |
+
proto native external bool ActivateContext(string contextName, int duration = 0);
|
| 24 |
+
proto native external bool IsContextActive(string contextName);
|
| 25 |
+
|
| 26 |
+
proto external void AddActionListener(string actionName, InputTrigger trigger, func callback);
|
| 27 |
+
|
| 28 |
+
proto native external void SetContextDebug(string contextName, bool bDebug);
|
| 29 |
+
|
| 30 |
+
proto native void SetParent(ActionManager parent);
|
| 31 |
+
proto native void SetDebug(bool bDebug);
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
class InputManager: ActionManager
|
| 35 |
+
{
|
| 36 |
+
private void InputManager(ActionManager parent) {};
|
| 37 |
+
private void ~InputManager() {};
|
| 38 |
+
|
| 39 |
+
proto native external void ResetAction(string actionName);
|
| 40 |
+
proto native void SetCursorPosition(int x, int y);
|
| 41 |
+
proto native external bool RegisterActionManager(ActionManager pManager);
|
| 42 |
+
proto native external bool UnregisterActionManager(ActionManager pManager);
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
#endif
|
| 46 |
+
|
scripts/2_GameLib/DayZ/menuManager.c
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifdef GAME_TEMPLATE
|
| 2 |
+
|
| 3 |
+
enum DialogPriority
|
| 4 |
+
{
|
| 5 |
+
INFORMATIVE,
|
| 6 |
+
WARNING,
|
| 7 |
+
CRITICAL
|
| 8 |
+
};
|
| 9 |
+
|
| 10 |
+
enum DialogResult
|
| 11 |
+
{
|
| 12 |
+
PENDING,
|
| 13 |
+
OK,
|
| 14 |
+
YES,
|
| 15 |
+
NO,
|
| 16 |
+
CANCEL,
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
enum ScriptMenuPresetEnum
|
| 20 |
+
{
|
| 21 |
+
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
class MenuManager
|
| 25 |
+
{
|
| 26 |
+
proto native MenuBase OpenMenu(ScriptMenuPresetEnum preset, int userId = 0, bool unique = false);
|
| 27 |
+
proto native MenuBase OpenDialog(ScriptMenuPresetEnum preset, int priority = DialogPriority.INFORMATIVE, int iUserId = 0, bool unique = false);
|
| 28 |
+
proto native MenuBase FindMenuByPreset(ScriptMenuPresetEnum preset);
|
| 29 |
+
proto native MenuBase FindMenuByUserId(int userId);
|
| 30 |
+
proto native MenuBase GetTopMenu();
|
| 31 |
+
|
| 32 |
+
proto native bool IsAnyMenuOpen();
|
| 33 |
+
proto native bool IsAnyDialogOpen();
|
| 34 |
+
|
| 35 |
+
proto native bool CloseMenuByPreset(ScriptMenuPresetEnum preset);
|
| 36 |
+
proto native bool CloseMenuByUserId(int userId);
|
| 37 |
+
proto native bool CloseMenu(MenuBase menu);
|
| 38 |
+
|
| 39 |
+
protected void MenuManager();
|
| 40 |
+
protected void ~MenuManager();
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
class MenuBindAttribute
|
| 44 |
+
{
|
| 45 |
+
string m_MenuItemName;
|
| 46 |
+
|
| 47 |
+
void MenuBindAttribute(string menuItemName = "")
|
| 48 |
+
{
|
| 49 |
+
m_MenuItemName = menuItemName;
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
class MenuBase: ScriptedWidgetEventHandler
|
| 54 |
+
{
|
| 55 |
+
proto native int GetUserId();
|
| 56 |
+
proto native Widget GetRootWidget();
|
| 57 |
+
proto external MenuBase BindItem(string menuItemName, func callback);
|
| 58 |
+
proto native MenuBase SetLabel(string menuItemName, string text);
|
| 59 |
+
proto native Widget GetItemWidget(string menuItemName);
|
| 60 |
+
proto native MenuManager GetManager();
|
| 61 |
+
proto native void Close();
|
| 62 |
+
|
| 63 |
+
void OnMenuFocusGained() {}
|
| 64 |
+
void OnMenuFocusLost() {}
|
| 65 |
+
void OnMenuShow() {}
|
| 66 |
+
void OnMenuHide() {}
|
| 67 |
+
void OnMenuOpen() {}
|
| 68 |
+
void OnMenuClose() {}
|
| 69 |
+
void OnMenuInit() {}
|
| 70 |
+
void OnMenuUpdate(float tDelta) {}
|
| 71 |
+
void OnMenuItem(string menuItemName, bool changed, bool finished) {}
|
| 72 |
+
|
| 73 |
+
protected void MenuBase();
|
| 74 |
+
protected void ~MenuBase();
|
| 75 |
+
};
|
| 76 |
+
|
| 77 |
+
class MessageBox: MenuBase
|
| 78 |
+
{
|
| 79 |
+
[MenuBindAttribute()]
|
| 80 |
+
void Ok()
|
| 81 |
+
{
|
| 82 |
+
Close();
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
#ifdef PLATFORM_WINDOWS
|
| 87 |
+
class WorldEditorIngame: MenuBase
|
| 88 |
+
{
|
| 89 |
+
proto native bool LoadWorld(string worldFilePath);
|
| 90 |
+
proto native bool SaveWorld();
|
| 91 |
+
};
|
| 92 |
+
#endif
|
| 93 |
+
|
| 94 |
+
#endif
|
| 95 |
+
|
scripts/2_GameLib/DayZ/settings.c
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifdef GAME_TEMPLATE
|
| 2 |
+
|
| 3 |
+
class Settings
|
| 4 |
+
{
|
| 5 |
+
static void OnChange(string variableName) {}
|
| 6 |
+
static void OnAnyChange() {}
|
| 7 |
+
static void OnLoad() {}
|
| 8 |
+
static void OnSave() {}
|
| 9 |
+
static void OnReset() {}
|
| 10 |
+
static void OnRevert() {}
|
| 11 |
+
static void OnApply() {}
|
| 12 |
+
|
| 13 |
+
private void Settings() {}
|
| 14 |
+
private void ~Settings() {}
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
class GameSettings: Settings
|
| 18 |
+
{
|
| 19 |
+
[Attribute("false", "checkbox", "Is debug mode enabled")]
|
| 20 |
+
static bool Debug;
|
| 21 |
+
|
| 22 |
+
override static void OnAnyChange()
|
| 23 |
+
{
|
| 24 |
+
GetGame().SetDebug(Debug);
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
class SettingsMenu: MenuBase
|
| 29 |
+
{
|
| 30 |
+
proto native external bool AddSettings(typename settingsClass);
|
| 31 |
+
proto native void Save();
|
| 32 |
+
proto native void Reset();
|
| 33 |
+
proto native void Revert();
|
| 34 |
+
proto native void Apply();
|
| 35 |
+
proto native void Back();
|
| 36 |
+
};
|
| 37 |
+
#endif
|
| 38 |
+
|
scripts/2_GameLib/DayZ/tools.c
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ief ScriptCallQueue Class provide "lazy" calls - when we don't want to execute function immediately but later during frame update (used mainly in UI)
|
| 3 |
+
\n usage:
|
| 4 |
+
@code
|
| 5 |
+
class Arkanoid extends Game
|
| 6 |
+
{
|
| 7 |
+
ref ScriptCallQueue m_CallQueue = new ScriptCallQueue();
|
| 8 |
+
|
| 9 |
+
ScriptCallQueue GetCallQueue() {
|
| 10 |
+
return m_CallQueue;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
override void OnUpdate(float timeslice)
|
| 14 |
+
{
|
| 15 |
+
m_CallQueue.Tick(timeslice);
|
| 16 |
+
...
|
| 17 |
+
}
|
| 18 |
+
...
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
class MyObject
|
| 22 |
+
{
|
| 23 |
+
int m_cnt = 0;
|
| 24 |
+
|
| 25 |
+
void Hello(int p1, string p2)
|
| 26 |
+
{
|
| 27 |
+
Print("Hello( " + p1 + " , " + p2 + ")");
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
void Test()
|
| 31 |
+
{
|
| 32 |
+
Print(m_cnt);
|
| 33 |
+
m_cnt++;
|
| 34 |
+
|
| 35 |
+
if (m_cnt > 10)
|
| 36 |
+
{
|
| 37 |
+
ScriptCallQueue queue = GetGame().GetCallQueue();
|
| 38 |
+
queue.Remove(Test);
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
void Test(MyObject obj)
|
| 44 |
+
{
|
| 45 |
+
ScriptCallQueue queue = GetGame().GetCallQueue();
|
| 46 |
+
queue.CallLater(obj.Hello, 5000, false, 65, "world"); // adds call 'obj.Hello(65, "world")' into queue, and it will be executed once after 5s
|
| 47 |
+
queue.CallLater(obj.Test, 3000, true); // adds call 'obj.Test()' into queue, and it will be executed each 3s
|
| 48 |
+
queue.Call(obj.Hello, 72, "world 2"); // adds call 'obj.Hello(72, "world 2")' into queue, and it will be executed next frame (on next call of ScriptCallQueue.Tick)
|
| 49 |
+
}
|
| 50 |
+
@endcode
|
| 51 |
+
*/
|
| 52 |
+
class ScriptCallQueue
|
| 53 |
+
{
|
| 54 |
+
//! executes calls on queue if their time is already elapsed, if 'repeat = false' call is removed from queue
|
| 55 |
+
proto native void Tick(float timeslice);
|
| 56 |
+
//! adds call into the queue with given parameters and arguments (arguments are held in memory until the call is executed/removed or ScriptCallQueue is destroyed)
|
| 57 |
+
proto void Call(func fn, void param1 = NULL, void param2 = NULL, void param3 = NULL, void param4 = NULL, void param5 = NULL, void param6 = NULL, void param7 = NULL, void param8 = NULL, void param9 = NULL);
|
| 58 |
+
//! adds call into the queue with given parameters and arguments (arguments are held in memory until the call is executed/removed or ScriptCallQueue is destroyed)
|
| 59 |
+
proto void CallByName(Class obj, string fnName , Param params = NULL);
|
| 60 |
+
//! adds call into the queue with given parameters and arguments (arguments are held in memory until the call is executed/removed or ScriptCallQueue is destroyed)
|
| 61 |
+
proto void CallLater(func fn, int delay = 0, bool repeat = false, void param1 = NULL, void param2 = NULL, void param3 = NULL, void param4 = NULL, void param5 = NULL, void param6 = NULL, void param7 = NULL, void param8 = NULL, void param9 = NULL);
|
| 62 |
+
//! adds call into the queue with given parameters and arguments (arguments are held in memory until the call is executed/removed or ScriptCallQueue is destroyed)
|
| 63 |
+
proto void CallLaterByName(Class obj, string fnName, int delay = 0, bool repeat = false, Param params = NULL);
|
| 64 |
+
//! remove specific call from queue
|
| 65 |
+
proto void Remove(func fn);
|
| 66 |
+
//! return Remaining time to the call execution (in miliseconds)
|
| 67 |
+
proto int GetRemainingTime(func fn);
|
| 68 |
+
//! remove specific call from queue
|
| 69 |
+
proto void RemoveByName(Class obj, string fnName);
|
| 70 |
+
//! return Remaining time to the call execution (in miliseconds)
|
| 71 |
+
proto int GetRemainingTimeByName(Class obj, string fnName);
|
| 72 |
+
//! remove all calls from queue
|
| 73 |
+
proto native void Clear();
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
\brief ScriptInvoker Class provide list of callbacks
|
| 78 |
+
\n usage:
|
| 79 |
+
@code
|
| 80 |
+
class Player
|
| 81 |
+
{
|
| 82 |
+
ref ScriptInvoker m_DeathInvoker = new ScriptInvoker();
|
| 83 |
+
|
| 84 |
+
void OnKilled()
|
| 85 |
+
{
|
| 86 |
+
m_DeathInvoker.Invoke(this);
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
void LogPlayerDeath(p)
|
| 91 |
+
{
|
| 92 |
+
Print("RIP " + p);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
class Game
|
| 96 |
+
{
|
| 97 |
+
void RemovePlayer(Player p)
|
| 98 |
+
{
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
void GameOver()
|
| 102 |
+
{
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
void OnPlayerSpaned(Player p)
|
| 107 |
+
{
|
| 108 |
+
Game game = GetGame();
|
| 109 |
+
p.m_DeathInvoker.Insert(LogPlayerDeath);
|
| 110 |
+
p.m_DeathInvoker.Insert(game.RemovePlayer);
|
| 111 |
+
p.m_DeathInvoker.Insert(game.GameOver);
|
| 112 |
+
}
|
| 113 |
+
@endcode
|
| 114 |
+
*/
|
| 115 |
+
class ScriptInvoker
|
| 116 |
+
{
|
| 117 |
+
//! invoke call on all inserted methods with given arguments
|
| 118 |
+
proto void Invoke(void param1 = NULL, void param2 = NULL, void param3 = NULL, void param4 = NULL, void param5 = NULL, void param6 = NULL, void param7 = NULL, void param8 = NULL, void param9 = NULL);
|
| 119 |
+
//! insert method to list
|
| 120 |
+
proto bool Insert(func fn, int flags = EScriptInvokerInsertFlags.IMMEDIATE);
|
| 121 |
+
//! remove specific call from list
|
| 122 |
+
proto bool Remove(func fn, int flags = EScriptInvokerRemoveFlags.ALL);
|
| 123 |
+
//! count how many times this fn is actively present in the Invoker
|
| 124 |
+
proto int Count(func fn);
|
| 125 |
+
//! remove all calls from list
|
| 126 |
+
proto native void Clear();
|
| 127 |
+
};
|
| 128 |
+
|
| 129 |
+
enum EScriptInvokerInsertFlags
|
| 130 |
+
{
|
| 131 |
+
NONE,
|
| 132 |
+
/**
|
| 133 |
+
\brief It gets added in immediately, which means that when called while an invoker is running, it will call this newly added call in the same run
|
| 134 |
+
\note Default flag, as that is the original behaviour, although it might cause endless Insert chain now... (still better than undefined behaviour)
|
| 135 |
+
\note In case of "Possible endless Insert detected" VME, either create an exit, remove the IMMEDIATE flag or make the insert UNIQUE
|
| 136 |
+
\note The Endless Insert is detected by seeing if "amount of calls > initial size + 128"
|
| 137 |
+
*/
|
| 138 |
+
IMMEDIATE,
|
| 139 |
+
/**
|
| 140 |
+
\brief Only one call to this instance+method is ever expected
|
| 141 |
+
\note Will throw a VME when a second one is attempted to be added
|
| 142 |
+
\note If it was already added without the flag, it will also throw a VME and keep the first of all previously inserted
|
| 143 |
+
*/
|
| 144 |
+
UNIQUE,
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
enum EScriptInvokerRemoveFlags
|
| 148 |
+
{
|
| 149 |
+
NONE,
|
| 150 |
+
/**
|
| 151 |
+
\brief Default flag
|
| 152 |
+
\note Don't use this if you want it to remove only the last insert instead of all of them
|
| 153 |
+
*/
|
| 154 |
+
ALL,
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
\brief Designed to hold 1 valid call
|
| 159 |
+
*/
|
| 160 |
+
class ScriptCaller
|
| 161 |
+
{
|
| 162 |
+
//! ScriptCaller is meant to be created through Create
|
| 163 |
+
private void ScriptCaller();
|
| 164 |
+
//! Creates a ScriptCaller
|
| 165 |
+
static proto ScriptCaller Create(func fn);
|
| 166 |
+
//! Replaces the current registered func with the new one, throws errors if unsuccessful
|
| 167 |
+
proto void Init(func fn);
|
| 168 |
+
//! Invoke call on the registered func, throws errors if unsuccessful
|
| 169 |
+
proto void Invoke(void param1 = null, void param2 = null, void param3 = null, void param4 = null, void param5 = null, void param6 = null, void param7 = null, void param8 = null, void param9 = null);
|
| 170 |
+
|
| 171 |
+
//! Checks if the ScriptCaller is valid
|
| 172 |
+
proto bool IsValid();
|
| 173 |
+
|
| 174 |
+
/**
|
| 175 |
+
\brief Compares this script caller against another script caller
|
| 176 |
+
\note May return true even if either one is invalid
|
| 177 |
+
|
| 178 |
+
@code
|
| 179 |
+
class SomeClass
|
| 180 |
+
{
|
| 181 |
+
void SomeMethod()
|
| 182 |
+
{
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
void Test()
|
| 187 |
+
{
|
| 188 |
+
SomeClass instanceA = new SomeClass();
|
| 189 |
+
SomeClass instanceB = new SomeClass();
|
| 190 |
+
|
| 191 |
+
ScriptCaller callerA;
|
| 192 |
+
ScriptCaller callerB;
|
| 193 |
+
|
| 194 |
+
//! Two methods that are to the same instance
|
| 195 |
+
callerA = ScriptCaller.Create(instanceA.SomeMethod);
|
| 196 |
+
callerB = ScriptCaller.Create(instanceA.SomeMethod);
|
| 197 |
+
|
| 198 |
+
Print(callerA.Equals(callerB)); //! "1"
|
| 199 |
+
Print(callerA == callerB); //! "0"
|
| 200 |
+
Print(callerA); //! "ScriptCaller callerA = ScriptCaller<87bc2d40>"
|
| 201 |
+
Print(callerB); //! "ScriptCaller callerB = ScriptCaller<87bc3600>"
|
| 202 |
+
|
| 203 |
+
//! Two methods belonging to different instances
|
| 204 |
+
callerA = ScriptCaller.Create(instanceA.SomeMethod);
|
| 205 |
+
callerB = ScriptCaller.Create(instanceB.SomeMethod);
|
| 206 |
+
|
| 207 |
+
Print(callerA.Equals(callerB)); //! "0"
|
| 208 |
+
Print(callerA == callerB); //! "0"
|
| 209 |
+
Print(callerA); //! "ScriptCaller callerA = ScriptCaller<87bc3c40>"
|
| 210 |
+
Print(callerB); //! "ScriptCaller callerB = ScriptCaller<87bc2d40>"
|
| 211 |
+
}
|
| 212 |
+
@endcode
|
| 213 |
+
*/
|
| 214 |
+
proto bool Equals(notnull ScriptCaller other);
|
| 215 |
+
|
| 216 |
+
};
|
scripts/3_Game/DayZ/AI/AIAgent.c
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class AIAgent : Managed
|
| 2 |
+
{
|
| 3 |
+
private void AIAgent();
|
| 4 |
+
private void ~AIAgent();
|
| 5 |
+
|
| 6 |
+
proto native void SetKeepInIdle(bool enable);
|
| 7 |
+
proto native AIGroup GetGroup();
|
| 8 |
+
}
|
scripts/3_Game/DayZ/AI/AIGroup.c
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class AIGroup : Managed
|
| 2 |
+
{
|
| 3 |
+
private void AIGroup();
|
| 4 |
+
private void ~AIGroup();
|
| 5 |
+
|
| 6 |
+
/*!
|
| 7 |
+
Manual group management - add / remove agents from group.
|
| 8 |
+
Don't forget to remove agent from old group.
|
| 9 |
+
Caution! Empty groups are deleted on the next frame.
|
| 10 |
+
*/
|
| 11 |
+
proto native void AddAgent(notnull AIAgent agent);
|
| 12 |
+
proto native void RemoveAgent(notnull AIAgent agent);
|
| 13 |
+
|
| 14 |
+
proto native AIGroupBehaviour GetBehaviour();
|
| 15 |
+
};
|
scripts/3_Game/DayZ/AI/AIGroupBehaviour.c
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class AIGroupBehaviour : Managed
|
| 2 |
+
{
|
| 3 |
+
private void AIGroupBehaviour();
|
| 4 |
+
private void ~AIGroupBehaviour();
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
class BehaviourGroupInfectedPackWaypointParams
|
| 8 |
+
{
|
| 9 |
+
vector m_CenterPosition;
|
| 10 |
+
float m_Radius;
|
| 11 |
+
|
| 12 |
+
void BehaviourGroupInfectedPackWaypointParams(vector pos, float radius)
|
| 13 |
+
{
|
| 14 |
+
m_CenterPosition = pos;
|
| 15 |
+
m_Radius = radius;
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
class BehaviourGroupInfectedPack : AIGroupBehaviour
|
| 20 |
+
{
|
| 21 |
+
/*!
|
| 22 |
+
Group waypoints initialization
|
| 23 |
+
/param [in] waypointDefaultIndex Starting waypoint. Index to array of waypoints specified by waypointParams. Acceptable range is [0, waypointParams.Count() - 1]
|
| 24 |
+
/param [in] forwardDirection Waypoints traverse order.
|
| 25 |
+
/param [in] loop Specifies what happens after last waypoint is reached. true - cycle waypoints, false - patrol waypoints
|
| 26 |
+
*/
|
| 27 |
+
proto native void SetWaypoints(array<ref BehaviourGroupInfectedPackWaypointParams> waypointParams, int waypointDefaultIndex, bool forwardDirection, bool loop);
|
| 28 |
+
|
| 29 |
+
proto native void SetWaypointsTraverseDirection(bool forwardDirection);
|
| 30 |
+
proto native void SetWaypointsLoop(bool loop);
|
| 31 |
+
proto native void SetCurrentWaypoint(int waypointIndex);
|
| 32 |
+
}
|
scripts/3_Game/DayZ/AI/AIWorld.c
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
enum PGPolyFlags
|
| 2 |
+
{
|
| 3 |
+
NONE,
|
| 4 |
+
|
| 5 |
+
WALK, // Ability to walk (ground, grass, road)
|
| 6 |
+
DISABLED, // Disabled polygon
|
| 7 |
+
DOOR, // Ability to move through doors
|
| 8 |
+
INSIDE, // Ability to move inside buildings
|
| 9 |
+
|
| 10 |
+
SWIM, // Ability to swim (water)
|
| 11 |
+
SWIM_SEA, // Ability to swim (sea water)
|
| 12 |
+
|
| 13 |
+
LADDER, // Ability to climb on ladders
|
| 14 |
+
JUMP_OVER, // Ability to do jumps overs
|
| 15 |
+
JUMP_DOWN, // Ability to jump down
|
| 16 |
+
CLIMB, // Ability to climb up
|
| 17 |
+
CRAWL, // Ability to crawl
|
| 18 |
+
CROUCH, // Ability to crouch
|
| 19 |
+
|
| 20 |
+
UNREACHABLE,
|
| 21 |
+
|
| 22 |
+
ALL,
|
| 23 |
+
|
| 24 |
+
JUMP, // JUMP_OVER | JUMP_DOWN
|
| 25 |
+
SPECIAL // JUMP | CLIMB | CRAWL | CROUCH
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
enum PGAreaType
|
| 29 |
+
{
|
| 30 |
+
NONE,
|
| 31 |
+
|
| 32 |
+
TERRAIN,
|
| 33 |
+
|
| 34 |
+
WATER,
|
| 35 |
+
WATER_DEEP,
|
| 36 |
+
WATER_SEA,
|
| 37 |
+
WATER_SEA_DEEP,
|
| 38 |
+
OBJECTS_NOFFCON,
|
| 39 |
+
|
| 40 |
+
OBJECTS,
|
| 41 |
+
BUILDING,
|
| 42 |
+
ROADWAY,
|
| 43 |
+
TREE,
|
| 44 |
+
ROADWAY_BUILDING,
|
| 45 |
+
|
| 46 |
+
DOOR_OPENED,
|
| 47 |
+
DOOR_CLOSED,
|
| 48 |
+
|
| 49 |
+
LADDER,
|
| 50 |
+
CRAWL,
|
| 51 |
+
CROUCH,
|
| 52 |
+
FENCE_WALL,
|
| 53 |
+
JUMP
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/*!
|
| 57 |
+
Filter for FindPath, RaycastNavMesh, SampleNavmeshPosition
|
| 58 |
+
*/
|
| 59 |
+
class PGFilter : Managed
|
| 60 |
+
{
|
| 61 |
+
// Uses PGPolyFlags bitmasks
|
| 62 |
+
proto native int GetIncludeFlags();
|
| 63 |
+
proto native int GetExcludeFlags();
|
| 64 |
+
proto native int GetExlusiveFlags();
|
| 65 |
+
proto native void SetFlags(int includeFlags, int excludeFlags, int exclusiveFlags);
|
| 66 |
+
|
| 67 |
+
proto native void SetCost(PGAreaType areaType, float cost);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
class AIWorld : Managed
|
| 71 |
+
{
|
| 72 |
+
private void AIWorld();
|
| 73 |
+
private void ~AIWorld();
|
| 74 |
+
|
| 75 |
+
/*!
|
| 76 |
+
Creates group with group behaviour specified by templateName param.
|
| 77 |
+
AIGroups lifetime is managed by AIWorld, e.g. empty groups are deleted automatically.
|
| 78 |
+
*/
|
| 79 |
+
proto native AIGroup CreateGroup(string templateName);
|
| 80 |
+
/*!
|
| 81 |
+
Creates group with no group behaviour
|
| 82 |
+
*/
|
| 83 |
+
proto native AIGroup CreateDefaultGroup();
|
| 84 |
+
/*!
|
| 85 |
+
Destroys group and all AIAgents attached
|
| 86 |
+
*/
|
| 87 |
+
proto native void DeleteGroup(notnull AIGroup group);
|
| 88 |
+
|
| 89 |
+
/*!
|
| 90 |
+
Finds path on navmesh using path graph filter.
|
| 91 |
+
|
| 92 |
+
/param [in] from starting position
|
| 93 |
+
/param [in] to ending position
|
| 94 |
+
/param [in] pgFilter filter used for searching
|
| 95 |
+
/param [out] waypoints waypoints array including starting and ending position
|
| 96 |
+
/returns true - if path has been found
|
| 97 |
+
*/
|
| 98 |
+
proto native bool FindPath(vector from, vector to, PGFilter pgFilter, out TVectorArray waypoints);
|
| 99 |
+
|
| 100 |
+
/*!
|
| 101 |
+
Raytest in navmesh
|
| 102 |
+
|
| 103 |
+
/param [in] from starting position
|
| 104 |
+
/param [in] to ending position
|
| 105 |
+
/param [in] pgFilter filter used for searching
|
| 106 |
+
/param [out] hitPos hit position
|
| 107 |
+
/param [out] hitNormal hit normal
|
| 108 |
+
/returns true - if ray hits navmesh edge
|
| 109 |
+
*/
|
| 110 |
+
proto native bool RaycastNavMesh(vector from, vector to, PGFilter pgFilter, out vector hitPos, out vector hitNormal);
|
| 111 |
+
|
| 112 |
+
/*!
|
| 113 |
+
Finds closest point on navmesh within maxDistance radius using path graph filter.
|
| 114 |
+
|
| 115 |
+
/param [in] position position wanted
|
| 116 |
+
/param [in] maxDistance search radius
|
| 117 |
+
/param [in] pgFilter filter used for searching
|
| 118 |
+
/param [out] sampledPosition closest position on navmesh to position
|
| 119 |
+
/returns true - function succeedes and found position is written to output paramter "sampledPosition"
|
| 120 |
+
/returns false - function failed to find position on navmesh within given radius, output paramter is left intact
|
| 121 |
+
*/
|
| 122 |
+
proto native bool SampleNavmeshPosition(vector position, float maxDistance, PGFilter pgFilter, out vector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+
*/
|
| 6 |
+
|
| 7 |
+
/*
|
| 8 |
+
class AIMessage: Managed
|
| 9 |
+
|
| 10 |
+
{
|
| 11 |
+
Param m_Parameters;
|
| 12 |
+
int m_CrcMessage;
|
| 13 |
+
Param GetParameters();
|
| 14 |
+
int GetTypeNameCRC();
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
class AIMessageTest : AIMessage
|
| 18 |
+
{
|
| 19 |
+
int GetTypeNameCRC() {return testCRC;}
|
| 20 |
+
//static int testCRC = 5;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
*/
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class AIBehaviourHLData
|
| 27 |
+
{
|
| 28 |
+
private void AIBehaviourHLData() {}
|
| 29 |
+
private void ~AIBehaviourHLData() {}
|
| 30 |
+
|
| 31 |
+
//void ParseConfig(ParamEntryPar param, AIWorld* world, AIAgentTemplate* agentTemplate) {};
|
| 32 |
+
void OnParseConfig();
|
| 33 |
+
|
| 34 |
+
//Can be use only inside OnParseConfig function
|
| 35 |
+
proto native void ParseBehaviourSlot(string name);
|
| 36 |
+
proto native void ParseAlertLevel(string name);
|
| 37 |
+
proto native float ReadParamValue(string paramName, float defValue);
|
| 38 |
+
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class AIBehaviourHL
|
| 43 |
+
{
|
| 44 |
+
private void AIBehaviourHL() {}
|
| 45 |
+
private void ~AIBehaviourHL() {}
|
| 46 |
+
|
| 47 |
+
proto native AIBehaviourHLData GetTemplateData();
|
| 48 |
+
|
| 49 |
+
void OnInit(){};
|
| 50 |
+
//private void AIBehaviourHL_script() {};
|
| 51 |
+
//private void ~AIBehaviourHL_script() {};
|
| 52 |
+
|
| 53 |
+
void Simulate (float timeDelta)
|
| 54 |
+
{
|
| 55 |
+
//time = time + timeDelta;
|
| 56 |
+
//Print("A2");
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
//void OnNoise(AINoiseInfo noise, EntityAI source){}
|
| 61 |
+
void OnDamage(float damage, EntityAI source){}
|
| 62 |
+
|
| 63 |
+
void OnDamageInflicted(){}
|
| 64 |
+
void OnAnimationEvent(int nameCrc){}
|
| 65 |
+
//void OnMessage(AIMessage message){}
|
| 66 |
+
//void OnBehaviourSwitched(AIBehaviour* behaviour){}
|
| 67 |
+
proto native void SetNextBehaviour(int BehaviourCrc);
|
| 68 |
+
proto native void SwitchToNextBehaviour();
|
| 69 |
+
|
| 70 |
+
static proto void RegAIBehaviour(string behname,typename behClass, typename behClassData);
|
| 71 |
+
};
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class AIBehaviourHLZombie2 : AIBehaviourHL
|
| 75 |
+
{
|
| 76 |
+
//AIBehaviourHLDataZombie2 data;
|
| 77 |
+
//int state;
|
| 78 |
+
//float time;
|
| 79 |
+
AIBehaviourHLDataZombie2 GetData()
|
| 80 |
+
{
|
| 81 |
+
return AIBehaviourHLDataZombie2.Cast( GetTemplateData() );
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
private void AIBehaviourHLZombie2() {}
|
| 85 |
+
private void ~AIBehaviourHLZombie2() {}
|
| 86 |
+
|
| 87 |
+
override void OnInit()
|
| 88 |
+
{
|
| 89 |
+
SetNextBehaviour(0x7b9a4ee9);
|
| 90 |
+
SwitchToNextBehaviour();
|
| 91 |
+
//Print("OnInit");
|
| 92 |
+
//data = GetData();
|
| 93 |
+
//float a = data.m_fDamageToCrawl;
|
| 94 |
+
//Print(a);
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
override void Simulate (float timeDelta)
|
| 98 |
+
{
|
| 99 |
+
//time = time + timeDelta;
|
| 100 |
+
//Print("B2");
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
void ShowDebugInfo()
|
| 104 |
+
{
|
| 105 |
+
//Print(time);
|
| 106 |
+
};
|
| 107 |
+
|
| 108 |
+
//void OnMessage(AIMessage message)
|
| 109 |
+
//{
|
| 110 |
+
//int ID = message.GetTypeNameCRC();
|
| 111 |
+
//Print(ID);
|
| 112 |
+
|
| 113 |
+
//}
|
| 114 |
+
};
|
| 115 |
+
|
| 116 |
+
class AIBehaviourHLDataZombie2 : AIBehaviourHLData
|
| 117 |
+
{
|
| 118 |
+
float m_fDamageToCrawl;
|
| 119 |
+
float m_fCrawlProbability;
|
| 120 |
+
|
| 121 |
+
private void AIBehaviourHLDataZombie2() {}
|
| 122 |
+
private void ~AIBehaviourHLDataZombie2() {}
|
| 123 |
+
|
| 124 |
+
override void OnParseConfig()
|
| 125 |
+
{
|
| 126 |
+
Print("zombie data parse config start");
|
| 127 |
+
|
| 128 |
+
ParseBehaviourSlot("Calm");
|
| 129 |
+
ParseBehaviourSlot("Attracted");
|
| 130 |
+
ParseBehaviourSlot("Disturbed");
|
| 131 |
+
ParseBehaviourSlot("Alerted");
|
| 132 |
+
|
| 133 |
+
ParseAlertLevel("Calm");
|
| 134 |
+
ParseAlertLevel("Disturbed");
|
| 135 |
+
ParseAlertLevel("Attracted");
|
| 136 |
+
ParseAlertLevel("Alerted");
|
| 137 |
+
|
| 138 |
+
m_fDamageToCrawl = ReadParamValue("damageToCrawl",0.01);
|
| 139 |
+
m_fCrawlProbability = ReadParamValue("crawlProbability",0.01);
|
| 140 |
+
|
| 141 |
+
Print("zombie data parse config end");
|
| 142 |
+
}
|
| 143 |
+
};
|
| 144 |
+
|
| 145 |
+
//NewNPC(model,behname,....)
|
| 146 |
+
|
| 147 |
+
|
scripts/3_Game/DayZ/AmmoCamParams.c
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class AmmoCamParams
|
| 2 |
+
{
|
| 3 |
+
void Load(string ammoType)
|
| 4 |
+
{
|
| 5 |
+
string cfgPath = "CfgAmmo " + ammoType + " Effects" + " CameraShake ";
|
| 6 |
+
|
| 7 |
+
m_Radius = GetGame().ConfigGetFloat(cfgPath + "radius");
|
| 8 |
+
m_Strength = GetGame().ConfigGetFloat(cfgPath + "strength");
|
| 9 |
+
m_ModifierClose = GetGame().ConfigGetFloat(cfgPath + "modifierClose");
|
| 10 |
+
m_ModifierFar = GetGame().ConfigGetFloat(cfgPath + "modifierFar");
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
float m_Radius = 40;//the max distance at which the cam shake is triggered
|
| 14 |
+
float m_Strength = 4;//strength of the cam shake
|
| 15 |
+
float m_ModifierClose = 1;//shake 'strength' modifier when the player is at distance 0 from the source of explosion
|
| 16 |
+
float m_ModifierFar = 0;//shake 'strength' modifier when the player is at distance 'radius' from the source of explosion
|
| 17 |
+
}
|
scripts/3_Game/DayZ/AmmoEffects.c
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
\brief Static data holder for certain ammo config values
|
| 3 |
+
\note Kept the names similar to what is in config, but it might be a little deceiving as this is mainly used for explosives
|
| 4 |
+
*/
|
| 5 |
+
class AmmoEffects
|
| 6 |
+
{
|
| 7 |
+
//! Key: Ammo class name; Data: ParticleList ID
|
| 8 |
+
static ref map<string, int> m_AmmoParticles;
|
| 9 |
+
|
| 10 |
+
//! Key: Ammo class name; Data: ParticleList ID
|
| 11 |
+
static ref map<string, typename> m_AmmoEffects;
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
/** \name Ammo particles
|
| 16 |
+
Methods regarding getting/playing ammo particle
|
| 17 |
+
*/
|
| 18 |
+
//@{
|
| 19 |
+
|
| 20 |
+
//! Get the ParticleList ID for the particle for this ammoType
|
| 21 |
+
static int GetAmmoParticleID(string ammoType)
|
| 22 |
+
{
|
| 23 |
+
int particleID;
|
| 24 |
+
|
| 25 |
+
// Search for it in the static map
|
| 26 |
+
if ( !m_AmmoParticles.Find(ammoType, particleID) )
|
| 27 |
+
{
|
| 28 |
+
// Load it in when we can't find it
|
| 29 |
+
string particleFileName;
|
| 30 |
+
GetGame().ConfigGetText(string.Format("cfgAmmo %1 particle", ammoType), particleFileName);
|
| 31 |
+
|
| 32 |
+
// If we found a valid entry, try looking for it in ParticleList
|
| 33 |
+
if ( particleFileName != "" )
|
| 34 |
+
{
|
| 35 |
+
particleID = ParticleList.GetParticleIDByName(particleFileName);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
// Store it for next search
|
| 39 |
+
m_AmmoParticles.Insert(ammoType, particleID);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
return particleID;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
//! Attempt to play the ammo particle at pos if found, returns true on success
|
| 46 |
+
static bool PlayAmmoParticle(string ammoType, vector pos)
|
| 47 |
+
{
|
| 48 |
+
int particleID = GetAmmoParticleID(ammoType);
|
| 49 |
+
|
| 50 |
+
if (ParticleList.IsValidId(particleID))
|
| 51 |
+
{
|
| 52 |
+
return ParticleManager.GetInstance().PlayInWorld(particleID, pos) != null;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
return false;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
//@}
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
/** \name Ammo effects
|
| 63 |
+
Methods regarding getting/playing ammo effect
|
| 64 |
+
*/
|
| 65 |
+
//@{
|
| 66 |
+
|
| 67 |
+
//! Get the typename for the effect for this ammoType
|
| 68 |
+
static typename GetAmmoEffectTypename(string ammoType)
|
| 69 |
+
{
|
| 70 |
+
typename typeName;
|
| 71 |
+
|
| 72 |
+
// Search for it in the static map
|
| 73 |
+
if ( !m_AmmoEffects.Find(ammoType, typeName) )
|
| 74 |
+
{
|
| 75 |
+
// Load it in when we can't find it
|
| 76 |
+
string effectName;
|
| 77 |
+
GetGame().ConfigGetText(string.Format("cfgAmmo %1 effect", ammoType), effectName);
|
| 78 |
+
|
| 79 |
+
// If we found a valid entry, try looking for it in ParticleList
|
| 80 |
+
if ( effectName != "" )
|
| 81 |
+
{
|
| 82 |
+
typeName = effectName.ToType();
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
// Store it for next search
|
| 86 |
+
m_AmmoEffects.Insert(ammoType, typeName);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
return typeName;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
//! Attempt to play the ammo effect at pos if found, returns true on success
|
| 93 |
+
static bool PlayAmmoEffect(string ammoType, vector pos)
|
| 94 |
+
{
|
| 95 |
+
typename typeName = GetAmmoEffectTypename(ammoType);
|
| 96 |
+
|
| 97 |
+
if ( typeName )
|
| 98 |
+
{
|
| 99 |
+
Effect eff = Effect.Cast(typeName.Spawn());
|
| 100 |
+
|
| 101 |
+
if ( eff )
|
| 102 |
+
{
|
| 103 |
+
eff.SetAutodestroy(true);
|
| 104 |
+
return SEffectManager.PlayInWorld( eff, pos );
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
return false;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
//@}
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
/** \name Lifetime
|
| 116 |
+
Creation and cleanup
|
| 117 |
+
*/
|
| 118 |
+
//@{
|
| 119 |
+
|
| 120 |
+
//! Initialize the containers: this is done this way, to have these not exist on server
|
| 121 |
+
static void Init()
|
| 122 |
+
{
|
| 123 |
+
m_AmmoParticles = new map<string, int>();
|
| 124 |
+
m_AmmoEffects = new map<string, typename>();
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
//! Clean up the data
|
| 128 |
+
static void Cleanup()
|
| 129 |
+
{
|
| 130 |
+
/* These ain't containing no refs, so whatever
|
| 131 |
+
m_AmmoParticles.Clear();
|
| 132 |
+
m_AmmoEffects.Clear();
|
| 133 |
+
*/
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
//@}
|
| 137 |
+
}
|
scripts/3_Game/DayZ/Analytics/AnalyticsManagerClient.c
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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};
|
| 5 |
+
|
| 6 |
+
void RegisterEvents()
|
| 7 |
+
{
|
| 8 |
+
ClientData.SyncEvent_OnEntityKilled.Insert(Event_OnEntityKilled);
|
| 9 |
+
ClientData.SyncEvent_OnPlayerIgnitedFireplace.Insert(Event_OnPlayerIgnitedFireplace);
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
void UnregisterEvents()
|
| 13 |
+
{
|
| 14 |
+
ClientData.SyncEvent_OnEntityKilled.Remove(Event_OnEntityKilled);
|
| 15 |
+
ClientData.SyncEvent_OnPlayerIgnitedFireplace.Remove(Event_OnPlayerIgnitedFireplace);
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
//===================================
|
| 19 |
+
// OnActionEat
|
| 20 |
+
//===================================
|
| 21 |
+
void OnActionEat()
|
| 22 |
+
{
|
| 23 |
+
Achievements.OnActionEat();
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
//===================================
|
| 27 |
+
// OnActionDrink
|
| 28 |
+
//===================================
|
| 29 |
+
void OnActionDrink()
|
| 30 |
+
{
|
| 31 |
+
Achievements.OnActionDrink();
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
//===================================
|
| 35 |
+
// OnActionCookedSteak - not implemented
|
| 36 |
+
//===================================
|
| 37 |
+
void OnActionCookedSteak()
|
| 38 |
+
{
|
| 39 |
+
Achievements.OnCookedSteak();
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
//===================================
|
| 43 |
+
// OnActionFinishedShaveSelf
|
| 44 |
+
//===================================
|
| 45 |
+
void OnActionFinishedShaveSelf()
|
| 46 |
+
{
|
| 47 |
+
Achievements.OnActionShave();
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
//===================================
|
| 51 |
+
// OnActionFinishedGutDeer
|
| 52 |
+
//===================================
|
| 53 |
+
void OnActionFinishedGutDeer()
|
| 54 |
+
{
|
| 55 |
+
Achievements.OnActionGutDeer();
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
//===================================
|
| 59 |
+
// OnActionRestrain
|
| 60 |
+
//===================================
|
| 61 |
+
void OnActionRestrain()
|
| 62 |
+
{
|
| 63 |
+
Achievements.OnActionHandcuff();
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
//===================================
|
| 67 |
+
// OnActionBandageTarget
|
| 68 |
+
//===================================
|
| 69 |
+
void OnActionBandageTarget()
|
| 70 |
+
{
|
| 71 |
+
Achievements.OnActionMedsSurvivor();
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
//===================================
|
| 75 |
+
// OnItemAttachedAtPlayer
|
| 76 |
+
//===================================
|
| 77 |
+
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
|
| 78 |
+
{
|
| 79 |
+
bool weapon_present;
|
| 80 |
+
bool melee_present;
|
| 81 |
+
bool backpack_present;
|
| 82 |
+
HumanInventory inventory;
|
| 83 |
+
|
| 84 |
+
if ( GetDayZGame().GetGameState() != DayZGameState.IN_GAME )
|
| 85 |
+
{
|
| 86 |
+
return;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
Man player = GetGame().GetPlayer();
|
| 90 |
+
if (!player)
|
| 91 |
+
{
|
| 92 |
+
return;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
inventory = player.GetHumanInventory();
|
| 96 |
+
|
| 97 |
+
if ( player && inventory )
|
| 98 |
+
{
|
| 99 |
+
for ( int i = 0; i < GEAR_COUNT; ++i )
|
| 100 |
+
{
|
| 101 |
+
int slot_id = InventorySlots.GetSlotIdFromString(m_FullGear[i]);
|
| 102 |
+
EntityAI att_item = inventory.FindAttachment( slot_id ); // Boris V [27.2.2019]: Consider using player.GetItemOnSlot(m_FullGear[i]) instead.
|
| 103 |
+
|
| 104 |
+
if ( !att_item )
|
| 105 |
+
{
|
| 106 |
+
//Print("index: "+ i +" slot_id: "+ slot_id +" = "+ att_item + " EMPTY");
|
| 107 |
+
continue;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
//checks for firearm
|
| 111 |
+
if (att_item.IsWeapon())
|
| 112 |
+
weapon_present = true;
|
| 113 |
+
//checks for melee weapon
|
| 114 |
+
else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Melee")))
|
| 115 |
+
melee_present = true;
|
| 116 |
+
//checks for backpack
|
| 117 |
+
else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Back")))
|
| 118 |
+
backpack_present = true;
|
| 119 |
+
//Print("index: "+ i +" slot_id: "+ slot_id +" = "+ att_item + " ATTACHED");
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
//separate check for hand slot; TODO remove duplicates
|
| 123 |
+
att_item = inventory.GetEntityInHands();
|
| 124 |
+
if ( att_item )
|
| 125 |
+
{
|
| 126 |
+
//checks for firearm
|
| 127 |
+
if (att_item.IsWeapon())
|
| 128 |
+
weapon_present = true;
|
| 129 |
+
//checks for melee weapon
|
| 130 |
+
else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Melee")) )
|
| 131 |
+
melee_present = true;
|
| 132 |
+
//checks for backpack
|
| 133 |
+
else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Back")))
|
| 134 |
+
backpack_present = true;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
if (weapon_present && melee_present && backpack_present)
|
| 138 |
+
{
|
| 139 |
+
//Print("---EAchievementActionId.ACTION_EQUIP_GEAR");
|
| 140 |
+
Achievements.OnEquippedFullGear();
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
//===================================
|
| 146 |
+
// Event_OnPlayerIgnitedFireplace
|
| 147 |
+
//===================================
|
| 148 |
+
void Event_OnPlayerIgnitedFireplace( EFireIgniteType ignite_type )
|
| 149 |
+
{
|
| 150 |
+
switch ( ignite_type )
|
| 151 |
+
{
|
| 152 |
+
case EFireIgniteType.Matchbox:
|
| 153 |
+
{
|
| 154 |
+
Achievements.OnActionIgniteMatchbox();
|
| 155 |
+
break;
|
| 156 |
+
}
|
| 157 |
+
case EFireIgniteType.Roadflare:
|
| 158 |
+
{
|
| 159 |
+
Achievements.OnActionIgniteRoadflare();
|
| 160 |
+
break;
|
| 161 |
+
}
|
| 162 |
+
case EFireIgniteType.HandDrill:
|
| 163 |
+
{
|
| 164 |
+
Achievements.OnActionIgniteDrill();
|
| 165 |
+
break;
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
//===================================
|
| 171 |
+
// Event_OnEntityKilled
|
| 172 |
+
//===================================
|
| 173 |
+
void Event_OnEntityKilled(EntityAI victim, EntityAI killer, EntityAI source, bool is_headshot)
|
| 174 |
+
{
|
| 175 |
+
if ( killer != null && killer.IsPlayer() && killer.GetID() == GetGame().GetPlayer().GetID() )
|
| 176 |
+
{
|
| 177 |
+
Achievements.OnPlayerKilled(victim, killer, source, is_headshot);
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
}
|
scripts/3_Game/DayZ/Analytics/AnalyticsManagerServer.c
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class AnalyticsManagerServer
|
| 2 |
+
{
|
| 3 |
+
const string STAT_DISTANCE = "dist";
|
| 4 |
+
const string STAT_PLAYTIME = "playtime";
|
| 5 |
+
const string STAT_PLAYERS_KILLED = "players_killed";
|
| 6 |
+
const string STAT_INFECTED_KILLED = "infected_killed";
|
| 7 |
+
const string STAT_LONGEST_SURVIVOR_HIT = "longest_survivor_hit";
|
| 8 |
+
|
| 9 |
+
void OnPlayerConnect(Man player)
|
| 10 |
+
{
|
| 11 |
+
player.StatRegister(STAT_DISTANCE);
|
| 12 |
+
player.StatRegister(STAT_PLAYTIME);
|
| 13 |
+
player.StatRegister(STAT_PLAYERS_KILLED);
|
| 14 |
+
player.StatRegister(STAT_INFECTED_KILLED);
|
| 15 |
+
player.StatRegister(STAT_LONGEST_SURVIVOR_HIT);
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
void OnPlayerDisconnect(Man player)
|
| 19 |
+
{
|
| 20 |
+
player.StatUpdateByPosition(STAT_DISTANCE);
|
| 21 |
+
player.StatUpdateByTime(STAT_PLAYTIME);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
//Entity-Entity hit
|
| 25 |
+
void OnEntityHit(EntityAI source, Man target)
|
| 26 |
+
{
|
| 27 |
+
if (source)
|
| 28 |
+
{
|
| 29 |
+
Man survivor = source.GetHierarchyRootPlayer();
|
| 30 |
+
if (survivor && source.IsWeapon())
|
| 31 |
+
OnPlayerToPlayerHit(survivor, target);
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
protected void OnPlayerToPlayerHit(Man shooter, Man target)
|
| 36 |
+
{
|
| 37 |
+
float longestHitDistance = shooter.StatGet(STAT_LONGEST_SURVIVOR_HIT);
|
| 38 |
+
float currentDistance = vector.Distance(shooter.GetPosition(), target.GetPosition());
|
| 39 |
+
float distanceUpdate;
|
| 40 |
+
|
| 41 |
+
if (longestHitDistance < currentDistance)
|
| 42 |
+
distanceUpdate = currentDistance - longestHitDistance;
|
| 43 |
+
|
| 44 |
+
shooter.StatUpdate(STAT_LONGEST_SURVIVOR_HIT, distanceUpdate);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
//Entity-Entity kill
|
| 48 |
+
void OnEntityKilled(Object killer, EntityAI target)
|
| 49 |
+
{
|
| 50 |
+
EntityAI killerEntity = EntityAI.Cast(killer);
|
| 51 |
+
if (killerEntity)
|
| 52 |
+
{
|
| 53 |
+
Man killerSurvivor = killerEntity.GetHierarchyRootPlayer();
|
| 54 |
+
if (killerSurvivor)
|
| 55 |
+
{
|
| 56 |
+
if (target.IsPlayer())
|
| 57 |
+
OnPlayerKilled(killerSurvivor, target);
|
| 58 |
+
else if (target.IsZombie())
|
| 59 |
+
OnInfectedKilled(killerSurvivor, target);
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
protected void OnPlayerKilled(Man killer, EntityAI target)
|
| 65 |
+
{
|
| 66 |
+
killer.StatUpdate(STAT_PLAYERS_KILLED, 1);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
protected void OnInfectedKilled(Man killer, EntityAI target)
|
| 70 |
+
{
|
| 71 |
+
killer.StatUpdate(STAT_INFECTED_KILLED, 1);
|
| 72 |
+
}
|
| 73 |
+
}
|
scripts/3_Game/DayZ/Analytics/ScriptAnalytics.c
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// class binded to engine
|
| 2 |
+
class StatsEventMeasuresData
|
| 3 |
+
{
|
| 4 |
+
string m_CharacterId; //!< character ID
|
| 5 |
+
int m_TimeInterval; //!< amount of real time in seconds covered by this event
|
| 6 |
+
int m_DaytimeHour; //!< current daytime in gameplay (hour in 24h format)
|
| 7 |
+
vector m_PositionStart; //!< player world position at the start of interval
|
| 8 |
+
vector m_PositionEnd; //!< player world position at the end of interval
|
| 9 |
+
float m_DistanceOnFoot; //!< traveled distance on foot (meters) during interval
|
| 10 |
+
|
| 11 |
+
float m_DistanceVehicle; //!< traveled distance (meters) in vehicle during interval
|
| 12 |
+
float m_TimeVONIn; //!< amount of time in seconds with inbound VON during interval
|
| 13 |
+
float m_TimeVONOut; //!< amount of time in seconds with outbound VON during interval
|
| 14 |
+
int m_CntLootAny; //!< count of any loot collected during interval
|
| 15 |
+
int m_CntLootFood; //!< count of any food or consumables collected during interval
|
| 16 |
+
int m_CntLootCloth; //!< count of cloth collected during interval
|
| 17 |
+
int m_CntLootFirearm; //!< count of firearms collected during interval
|
| 18 |
+
int m_CntLootAmmo; //!< count of ammo collected during interval
|
| 19 |
+
int m_CntKillInfected; //!< count of infected kills during interval
|
| 20 |
+
int m_CntConsumedFood; //!< count of consumed food during interval
|
| 21 |
+
int m_CntConsumedWater; //!< count of consumed water during interval
|
| 22 |
+
int m_HealthRestored; //!< number of health point restored during interval
|
| 23 |
+
int m_CntFiredAmmo; //!< firearm rounds fired during interval
|
| 24 |
+
int m_CntCraftedItem; //!< number of items crafted during interval
|
| 25 |
+
|
| 26 |
+
// listStatus // state metric of health, hunger, thirst, etc... when event is created/send
|
| 27 |
+
int m_HealthStatus; //!< state of health (current state)
|
| 28 |
+
int m_BloodStatus; //!< state of blood (current state)
|
| 29 |
+
int m_SicknessStatus; //!< state of sickness (current state)
|
| 30 |
+
int m_TemperatureStatus; //!< state of temperature (current state)
|
| 31 |
+
int m_FoodStatus; //!< state of food (hunger) (current state)
|
| 32 |
+
int m_HydrationStatus; //!< state of hydration (thirst) (current state)
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
// class binded to engine
|
| 36 |
+
class StatsEventDeathData
|
| 37 |
+
{
|
| 38 |
+
string m_CharacterId; //!< character ID
|
| 39 |
+
int m_CharacterLifetime; //!< lifetime of character in seconds
|
| 40 |
+
string m_Cause; //!< cause of death (hunger, sickness, player-killed, zombie-killed...)
|
| 41 |
+
string m_WeaponName; //!< name of weapon which caused death
|
| 42 |
+
float m_Distance; //!< distance in meters (rounded) from spawn position to death position
|
| 43 |
+
vector m_Position; //!< position of player when died
|
| 44 |
+
|
| 45 |
+
int m_ListDamages[5]; //!< list of damages (5 values) during last n sec. For example: {20, 80, 0, 0, 0}
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
// class binded to engine
|
| 49 |
+
class StatsEventScoredKillData
|
| 50 |
+
{
|
| 51 |
+
string m_CharacterId; //!< character ID
|
| 52 |
+
string m_WeaponName; //!< name of weapon which killed player (victim)
|
| 53 |
+
int m_KillDistance; //!< distance in meters (rounded) between killer and victim
|
| 54 |
+
vector m_PositionKiller; //!< position of killer
|
| 55 |
+
vector m_PositionVictim; //!< position of victim
|
| 56 |
+
};
|
| 57 |
+
|
| 58 |
+
// class binded to engine
|
| 59 |
+
class StatsEventDisconnectedData
|
| 60 |
+
{
|
| 61 |
+
string m_CharacterId; //!< character ID
|
| 62 |
+
string m_Reason; //!< reason of disconnect (quit, kick, ban, sign-out...)
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
// class binded to engine
|
| 66 |
+
class StatsEventSpawnedData
|
| 67 |
+
{
|
| 68 |
+
string m_CharacterId; //!< character ID
|
| 69 |
+
int m_Lifetime; //!< lifetime of character in seconds
|
| 70 |
+
vector m_Position; //!< position of spawn
|
| 71 |
+
int m_Population; //!< population of current gameplay (server)
|
| 72 |
+
int m_DaytimeHour; //!< current time in hour (hour in 24h)
|
| 73 |
+
};
|
| 74 |
+
|
| 75 |
+
// class binded to engine
|
| 76 |
+
class StatsEventData
|
| 77 |
+
{
|
| 78 |
+
void StatsEventData(string eventName)
|
| 79 |
+
{
|
| 80 |
+
m_eventName = eventName;
|
| 81 |
+
m_valuesBool = new map<string, int>();
|
| 82 |
+
m_valuesInt = new map<string, int>();
|
| 83 |
+
m_valuesFloat = new map<string, float>();
|
| 84 |
+
m_valuesString = new map<string, string>();
|
| 85 |
+
m_valuesVector = new map<string, vector>();
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
void AddBool(string key, bool value)
|
| 89 |
+
{
|
| 90 |
+
m_valuesBool.Insert(key, (int)value);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
void AddInt(string key, int value)
|
| 94 |
+
{
|
| 95 |
+
m_valuesInt.Insert(key, value);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
void AddFloat(string key, float value)
|
| 99 |
+
{
|
| 100 |
+
m_valuesFloat.Insert(key, value);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
void AddString(string key, string value)
|
| 104 |
+
{
|
| 105 |
+
m_valuesString.Insert(key, value);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
void AddVector(string key, vector value)
|
| 109 |
+
{
|
| 110 |
+
m_valuesVector.Insert(key, value);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
private string m_eventName;
|
| 114 |
+
private autoptr map<string, int> m_valuesBool;//TODO: use bool instead of int (problem with engine type binding)
|
| 115 |
+
private autoptr map<string, int> m_valuesInt;
|
| 116 |
+
private autoptr map<string, float> m_valuesFloat;
|
| 117 |
+
private autoptr map<string, string> m_valuesString;
|
| 118 |
+
private autoptr map<string, vector> m_valuesVector;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class ScriptAnalytics
|
| 123 |
+
{
|
| 124 |
+
//! send event about death to statistic DB
|
| 125 |
+
static proto native void SendPlayerDeath(StatsEventDeathData data);
|
| 126 |
+
|
| 127 |
+
//! send event about kill to statistic DB
|
| 128 |
+
static proto native void SendPlayerScoredKill(StatsEventScoredKillData data);
|
| 129 |
+
|
| 130 |
+
//! send event to statistic DB
|
| 131 |
+
static proto native void SendPlayerDisconnected(StatsEventDisconnectedData data);
|
| 132 |
+
|
| 133 |
+
//! send event about player status to statistic DB
|
| 134 |
+
static proto native void SendPlayerMeasures(StatsEventMeasuresData data);
|
| 135 |
+
|
| 136 |
+
//! send event about spawning to statistic DB
|
| 137 |
+
static proto native void SendPlayerSpawned(StatsEventSpawnedData data);
|
| 138 |
+
|
| 139 |
+
//! universal analytics event
|
| 140 |
+
static proto native void SendEvent(StatsEventData data);
|
| 141 |
+
};
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
class Analytics
|
| 146 |
+
{
|
| 147 |
+
// send stats data with log
|
| 148 |
+
static void PlayerDeath(StatsEventDeathData data)
|
| 149 |
+
{
|
| 150 |
+
ScriptAnalytics.SendPlayerDeath(data);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
// send stats data with log
|
| 154 |
+
static void PlayerScoredKill(StatsEventScoredKillData data)
|
| 155 |
+
{
|
| 156 |
+
ScriptAnalytics.SendPlayerScoredKill(data);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
// send stats data with log
|
| 160 |
+
static void PlayerDisconnected(StatsEventDisconnectedData data)
|
| 161 |
+
{
|
| 162 |
+
ScriptAnalytics.SendPlayerDisconnected(data);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
// send stats data with log
|
| 166 |
+
static void PlayerMeasures(StatsEventMeasuresData data)
|
| 167 |
+
{
|
| 168 |
+
ScriptAnalytics.SendPlayerMeasures(data);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
// send stats data with log
|
| 172 |
+
static void PlayerSpawned(StatsEventSpawnedData data)
|
| 173 |
+
{
|
| 174 |
+
ScriptAnalytics.SendPlayerSpawned(data);
|
| 175 |
+
}
|
| 176 |
+
}
|
scripts/3_Game/DayZ/Anim/AnimCommand.c
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! base class of all commands exposed to script to provide common functionality over animations
|
| 2 |
+
class AnimCommandBase
|
| 3 |
+
{
|
| 4 |
+
// These would be private if not for the scripted commands
|
| 5 |
+
// As other commands lifetime are handled internally
|
| 6 |
+
protected void AnimCommandBase() {}
|
| 7 |
+
protected void ~AnimCommandBase() {}
|
| 8 |
+
|
| 9 |
+
//! returns entity that this command is bount to
|
| 10 |
+
proto native IEntity GetEntity();
|
| 11 |
+
|
| 12 |
+
//! called when command starts
|
| 13 |
+
void OnActivate() {}
|
| 14 |
+
|
| 15 |
+
//! called when command ends
|
| 16 |
+
void OnDeactivate() {}
|
| 17 |
+
|
| 18 |
+
//! called before any animation is processed
|
| 19 |
+
//! here change animation values, add animation commands
|
| 20 |
+
void PreAnimUpdate(float pDt) {}
|
| 21 |
+
|
| 22 |
+
//! after animation is processed, before physics is processed
|
| 23 |
+
//! here you can listen to various events
|
| 24 |
+
void PrePhysUpdate(float pDt) {}
|
| 25 |
+
|
| 26 |
+
//! functions usable only from OnActivate or PreAnimUpdate
|
| 27 |
+
proto native void PreAnim_CallCommand(int pCommand, int pParamInt, float pParamFloat);
|
| 28 |
+
proto native void PreAnim_SetFloat(int pVar, float pFlt);
|
| 29 |
+
proto native void PreAnim_SetInt(int pVar, int pInt);
|
| 30 |
+
proto native void PreAnim_SetBool(int pVar, bool pBool);
|
| 31 |
+
|
| 32 |
+
//! functions usable in PrePhysUpdate
|
| 33 |
+
proto native bool PrePhys_IsEvent(int pEvent);
|
| 34 |
+
proto native bool PrePhys_IsTag(int pTag);
|
| 35 |
+
}
|
scripts/3_Game/DayZ/BillboardSet.c
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class BillboardSetHandler
|
| 2 |
+
{
|
| 3 |
+
protected bool m_BillboardSetIndex = -1;
|
| 4 |
+
protected ref array<ref BillboardSet> m_BillboardSets;
|
| 5 |
+
protected static const string ROOT_CLASS = "BillboardPresets";
|
| 6 |
+
protected static int m_SetIndexCached = -1;//once we resolve the name into an index, we cache it(this disallows dynamic index swapping during mission's runtime)
|
| 7 |
+
|
| 8 |
+
string GetTextureByType(string type)
|
| 9 |
+
{
|
| 10 |
+
if (m_BillboardSetIndex == -1)
|
| 11 |
+
return "";
|
| 12 |
+
BillboardSet bbset = m_BillboardSets.Get(m_BillboardSetIndex);
|
| 13 |
+
return bbset.GetTextureByType(type);
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
void OnRPCIndex(int index)
|
| 17 |
+
{
|
| 18 |
+
if (!m_BillboardSets)
|
| 19 |
+
LoadBillboardConfigs();
|
| 20 |
+
|
| 21 |
+
if (m_BillboardSets && m_BillboardSets.IsValidIndex(index))
|
| 22 |
+
{
|
| 23 |
+
m_BillboardSetIndex = index;
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
protected bool LoadBillboardConfigs()
|
| 28 |
+
{
|
| 29 |
+
m_BillboardSets = new array<ref BillboardSet>();
|
| 30 |
+
|
| 31 |
+
int setCount = g_Game.ConfigGetChildrenCount(ROOT_CLASS);
|
| 32 |
+
|
| 33 |
+
for (int setIndex = 0; setIndex < setCount; setIndex++)
|
| 34 |
+
{
|
| 35 |
+
string setName;
|
| 36 |
+
GetGame().ConfigGetChildName(ROOT_CLASS, setIndex, setName);
|
| 37 |
+
string path = ROOT_CLASS + " " + setName;
|
| 38 |
+
m_BillboardSets.Insert(new BillboardSet(path));
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
return true;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
static bool ActivateBillboardSet(string setClassName, PlayerIdentity identity)
|
| 45 |
+
{
|
| 46 |
+
if (!g_Game)
|
| 47 |
+
return false;
|
| 48 |
+
|
| 49 |
+
if (m_SetIndexCached == -1)
|
| 50 |
+
{
|
| 51 |
+
int setCount = g_Game.ConfigGetChildrenCount(ROOT_CLASS);
|
| 52 |
+
for (int setIndex = 0; setIndex < setCount; setIndex++)
|
| 53 |
+
{
|
| 54 |
+
string setName;
|
| 55 |
+
GetGame().ConfigGetChildName(ROOT_CLASS, setIndex, setName);
|
| 56 |
+
|
| 57 |
+
if (setName == setClassName)
|
| 58 |
+
{
|
| 59 |
+
m_SetIndexCached = setIndex;
|
| 60 |
+
break
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
if (m_SetIndexCached != -1)
|
| 66 |
+
{
|
| 67 |
+
auto param = new Param1<int>(m_SetIndexCached);
|
| 68 |
+
GetGame().RPCSingleParam( identity.GetPlayer(), ERPCs.RPC_SET_BILLBOARDS, param, true, identity );
|
| 69 |
+
return true;
|
| 70 |
+
}
|
| 71 |
+
return false;
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
class BillboardSet
|
| 77 |
+
{
|
| 78 |
+
protected ref map<string, string> m_TypeTextureMapping = new map<string, string>();
|
| 79 |
+
|
| 80 |
+
void BillboardSet(string path)
|
| 81 |
+
{
|
| 82 |
+
LoadConfig(path);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
string GetTextureByType(string type)
|
| 86 |
+
{
|
| 87 |
+
return m_TypeTextureMapping.Get(type);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
protected void LoadConfig(string path)
|
| 91 |
+
{
|
| 92 |
+
int count = g_Game.ConfigGetChildrenCount(path);
|
| 93 |
+
for ( int i = 0; i < count; i++ )
|
| 94 |
+
{
|
| 95 |
+
string itemName;
|
| 96 |
+
GetGame().ConfigGetChildName(path, i, itemName);
|
| 97 |
+
|
| 98 |
+
string typesPath = path + " " + itemName + " types";
|
| 99 |
+
string texturePath = path + " " + itemName + " texture";
|
| 100 |
+
|
| 101 |
+
if (GetGame().ConfigIsExisting(typesPath) && GetGame().ConfigIsExisting(texturePath))
|
| 102 |
+
{
|
| 103 |
+
TStringArray types = new TStringArray();
|
| 104 |
+
string texture;
|
| 105 |
+
GetGame().ConfigGetText(texturePath, texture);
|
| 106 |
+
GetGame().ConfigGetTextArray(typesPath, types);
|
| 107 |
+
|
| 108 |
+
foreach (string s: types)
|
| 109 |
+
{
|
| 110 |
+
m_TypeTextureMapping.Insert(s,texture);
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
else
|
| 114 |
+
{
|
| 115 |
+
ErrorEx("Billboard set incorrect configuration, type or texture param missing: " + path);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
}
|
scripts/3_Game/DayZ/BleedChanceData.c
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
typedef map<int,float> BleedChanceMaxMap; //<bloodDamageReceived,chanceMax>
|
| 2 |
+
|
| 3 |
+
//! Static data of bleeding chance probabilities; currently used for melee only
|
| 4 |
+
class BleedChanceData : Managed
|
| 5 |
+
{
|
| 6 |
+
private static const float BLOOD_HITPOINTS_UNIVERSAL = 100.0;
|
| 7 |
+
|
| 8 |
+
private static ref map<string, ref BleedChanceMaxMap> m_DamageTypeMap;
|
| 9 |
+
|
| 10 |
+
static void InitBleedChanceData()
|
| 11 |
+
{
|
| 12 |
+
m_DamageTypeMap = new map<string,ref BleedChanceMaxMap>();
|
| 13 |
+
|
| 14 |
+
InitMeleeChanceMap();
|
| 15 |
+
InitInfectedChanceMap();
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
static void InitMeleeChanceMap()
|
| 19 |
+
{
|
| 20 |
+
if (m_DamageTypeMap.Contains("Melee"))
|
| 21 |
+
ErrorEx("'Melee' damage type bleed chances already initialized!");
|
| 22 |
+
|
| 23 |
+
BleedChanceMaxMap bleedChanceMaxMap = new BleedChanceMaxMap();
|
| 24 |
+
|
| 25 |
+
//keys have to be integers, recalculated later
|
| 26 |
+
bleedChanceMaxMap.Set(0,0.0);
|
| 27 |
+
bleedChanceMaxMap.Set(10,5.0);
|
| 28 |
+
bleedChanceMaxMap.Set(20,15.0);
|
| 29 |
+
bleedChanceMaxMap.Set(30,23.4);
|
| 30 |
+
bleedChanceMaxMap.Set(40,31.2);
|
| 31 |
+
bleedChanceMaxMap.Set(50,39.0);
|
| 32 |
+
bleedChanceMaxMap.Set(60,46.8);
|
| 33 |
+
bleedChanceMaxMap.Set(70,54.6);
|
| 34 |
+
bleedChanceMaxMap.Set(80,62.4);
|
| 35 |
+
bleedChanceMaxMap.Set(90,70.2);
|
| 36 |
+
bleedChanceMaxMap.Set(BLOOD_HITPOINTS_UNIVERSAL,100.0);
|
| 37 |
+
|
| 38 |
+
m_DamageTypeMap.Set("Melee",bleedChanceMaxMap);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
static void InitInfectedChanceMap()
|
| 42 |
+
{
|
| 43 |
+
if (m_DamageTypeMap.Contains("Infected"))
|
| 44 |
+
ErrorEx("'Infected' damage type bleed chances already initialized!");
|
| 45 |
+
|
| 46 |
+
BleedChanceMaxMap bleedChanceMaxMap = new BleedChanceMaxMap();
|
| 47 |
+
|
| 48 |
+
//keys have to be integers, recalculated later
|
| 49 |
+
bleedChanceMaxMap.Set(0,0.0);
|
| 50 |
+
bleedChanceMaxMap.Set(10,5.0);
|
| 51 |
+
bleedChanceMaxMap.Set(20,15.0);
|
| 52 |
+
bleedChanceMaxMap.Set(30,27.5);
|
| 53 |
+
bleedChanceMaxMap.Set(40,40.0);
|
| 54 |
+
bleedChanceMaxMap.Set(50,55.0);
|
| 55 |
+
bleedChanceMaxMap.Set(60,60.0);
|
| 56 |
+
bleedChanceMaxMap.Set(70,70.0);
|
| 57 |
+
bleedChanceMaxMap.Set(80,75.0);
|
| 58 |
+
bleedChanceMaxMap.Set(90,85.0);
|
| 59 |
+
bleedChanceMaxMap.Set(BLOOD_HITPOINTS_UNIVERSAL,100.0);
|
| 60 |
+
|
| 61 |
+
m_DamageTypeMap.Set("Infected",bleedChanceMaxMap);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
static void Cleanup()
|
| 65 |
+
{
|
| 66 |
+
delete m_DamageTypeMap;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
//! returns 'false' when damageType is unhandled
|
| 70 |
+
static bool CalculateBleedChance(string damageType, float bloodDamage, float bleedThreshold, out float bleedChance)
|
| 71 |
+
{
|
| 72 |
+
map<int,float> bleedChanceMap = m_DamageTypeMap.Get(damageType);
|
| 73 |
+
if (!bleedChanceMap)
|
| 74 |
+
return false;
|
| 75 |
+
|
| 76 |
+
float armor = bloodDamage / BLOOD_HITPOINTS_UNIVERSAL;
|
| 77 |
+
float valueHigher = Math.Max(bleedThreshold,armor) * BLOOD_HITPOINTS_UNIVERSAL;
|
| 78 |
+
float valueLower = Math.Min(bleedThreshold,armor) * BLOOD_HITPOINTS_UNIVERSAL;
|
| 79 |
+
|
| 80 |
+
#ifdef DEVELOPER
|
| 81 |
+
if (LogManager.IsBleedingChancesLogEnable())
|
| 82 |
+
{
|
| 83 |
+
Debug.BleedingChancesLog(armor.ToString(), "BleedChanceData" , "n/a", "armor:");
|
| 84 |
+
Debug.BleedingChancesLog(bleedThreshold.ToString(), "BleedChanceData" , "n/a", "bleedThreshold:");
|
| 85 |
+
}
|
| 86 |
+
#endif
|
| 87 |
+
|
| 88 |
+
//unexpected values, unhandled
|
| 89 |
+
if (valueLower > BLOOD_HITPOINTS_UNIVERSAL)
|
| 90 |
+
{
|
| 91 |
+
bleedChance = 1.0;
|
| 92 |
+
|
| 93 |
+
#ifdef DEVELOPER
|
| 94 |
+
if (LogManager.IsBleedingChancesLogEnable())
|
| 95 |
+
{
|
| 96 |
+
Debug.BleedingChancesLog(bleedChance.ToString(), "BleedChanceData" , "n/a", "Unhandleed values, default bleeding chance used:");
|
| 97 |
+
}
|
| 98 |
+
#endif
|
| 99 |
+
|
| 100 |
+
return true;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
if (bleedChanceMap.Contains(valueLower))
|
| 104 |
+
{
|
| 105 |
+
bleedChance = bleedChanceMap.Get(valueLower) * valueHigher / 10000;
|
| 106 |
+
}
|
| 107 |
+
else
|
| 108 |
+
{
|
| 109 |
+
float chanceMaxActual;
|
| 110 |
+
|
| 111 |
+
float floor = Math.Floor(valueLower / 10) * 10;
|
| 112 |
+
float ceil = Math.Ceil(valueLower / 10) * 10;
|
| 113 |
+
float pos = Math.InverseLerp(floor,ceil,valueLower);
|
| 114 |
+
|
| 115 |
+
float chanceMin = bleedChanceMap.Get(floor);
|
| 116 |
+
float chanceMax = bleedChanceMap.Get(ceil);
|
| 117 |
+
|
| 118 |
+
chanceMaxActual = Math.Lerp(chanceMin,chanceMax,pos);
|
| 119 |
+
bleedChance = valueHigher * chanceMaxActual / 10000;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
#ifdef DEVELOPER
|
| 123 |
+
if (LogManager.IsBleedingChancesLogEnable())
|
| 124 |
+
{
|
| 125 |
+
Debug.BleedingChancesLog(bleedChance.ToString(), "BleedChanceData" , "n/a", "bleeding chance:");
|
| 126 |
+
}
|
| 127 |
+
#endif
|
| 128 |
+
|
| 129 |
+
return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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
/** @file */
|
| 3 |
+
|
| 4 |
+
// -------------------------------------------------------------------------
|
| 5 |
+
// object (SF) Spawn Flags (use to setup behavior and/ or trigger functionality)
|
| 6 |
+
//
|
| 7 |
+
const int ECE_NONE = 0;
|
| 8 |
+
|
| 9 |
+
const int ECE_SETUP = 2; // process full entity setup (when creating NEW entity)
|
| 10 |
+
const int ECE_TRACE = 4; // trace under entity when being placed (from the point of creation)
|
| 11 |
+
const int ECE_CENTER = 8; // use center from shape (model) for placement
|
| 12 |
+
|
| 13 |
+
const int ECE_UPDATEPATHGRAPH = 32; // update navmesh when object placed upon it
|
| 14 |
+
|
| 15 |
+
const int ECE_ROTATIONFLAGS = 512; // enable rotation flags for object placement
|
| 16 |
+
const int ECE_CREATEPHYSICS = 1024; // create collision envelope and related physics data (if object has them)
|
| 17 |
+
const int ECE_INITAI = 2048; // init ai
|
| 18 |
+
const int ECE_AIRBORNE = 4096; // create flying unit in the air
|
| 19 |
+
|
| 20 |
+
const int ECE_EQUIP_ATTACHMENTS = 8192; // equip with configured ATTACHMENTS
|
| 21 |
+
const int ECE_EQUIP_CARGO = 16384; // equip with configured CARGO
|
| 22 |
+
const int ECE_EQUIP = 24576; // equip with configured (ATTACHMENTS + CARGO)
|
| 23 |
+
const int ECE_EQUIP_CONTAINER = 2097152; // populate DE/ group CONTAINER during spawn
|
| 24 |
+
const int ECE_LOCAL = 1073741824; // create object locally
|
| 25 |
+
|
| 26 |
+
const int ECE_NOSURFACEALIGN = 262144; // do not align object on surface/ terrain
|
| 27 |
+
const int ECE_KEEPHEIGHT = 524288; // keep height when creating object (do not use trace or placement on surface)
|
| 28 |
+
|
| 29 |
+
const int ECE_NOLIFETIME = 4194304; // do not set lifetime when creating the object
|
| 30 |
+
const int ECE_NOPERSISTENCY_WORLD = 8388608; // do not save this object in world
|
| 31 |
+
const int ECE_NOPERSISTENCY_CHAR = 16777216; // do not save this object in character
|
| 32 |
+
const int ECE_DYNAMIC_PERSISTENCY = 33554432; // spawns in without persistency, once player takes it, persistency will be enabled if available
|
| 33 |
+
|
| 34 |
+
// note: use predefined combination when not solving something specific
|
| 35 |
+
//
|
| 36 |
+
const int ECE_IN_INVENTORY = 787456; // ECE_CREATEPHYSICS|ECE_KEEPHEIGHT|ECE_NOSURFACEALIGN
|
| 37 |
+
const int ECE_PLACE_ON_SURFACE = 1060; // ECE_CREATEPHYSICS|ECE_UPDATEPATHGRAPH|ECE_TRACE
|
| 38 |
+
const int ECE_OBJECT_SWAP = 787488; // ECE_CREATEPHYSICS|ECE_UPDATEPATHGRAPH|ECE_KEEPHEIGHT|ECE_NOSURFACEALIGN
|
| 39 |
+
|
| 40 |
+
const int ECE_FULL = 25126; // ECE_SETUP|ECE_TRACE|ECE_ROTATIONFLAGS|ECE_UPDATEPATHGRAPH|ECE_EQUIP
|
| 41 |
+
|
| 42 |
+
// -------------------------------------------------------------------------
|
| 43 |
+
// object (RF) Rotation Flags (use to force and/ or invoke placement rotation)
|
| 44 |
+
//
|
| 45 |
+
const int RF_NONE = 0;
|
| 46 |
+
|
| 47 |
+
const int RF_FRONT = 1; // front side placement
|
| 48 |
+
const int RF_TOP = 2; // top side placement
|
| 49 |
+
const int RF_LEFT = 4; // left side placement
|
| 50 |
+
const int RF_RIGHT = 8; // right side placement
|
| 51 |
+
const int RF_BACK = 16; // back side placement
|
| 52 |
+
const int RF_BOTTOM = 32; // bottom side placement
|
| 53 |
+
|
| 54 |
+
const int RF_ALL = 63; // RF_FRONT|RF_TOP|RF_LEFT|RF_RIGHT|RF_BACK|RF_BOTTOM
|
| 55 |
+
|
| 56 |
+
const int RF_IGNORE = 64; // ignore placement RF flags - object will spawn as model was created
|
| 57 |
+
|
| 58 |
+
const int RF_TOPBOTTOM = 34; // RF_TOP|RF_BOTTOM
|
| 59 |
+
const int RF_LEFTRIGHT = 12; // RF_LEFT|RF_RIGHT
|
| 60 |
+
const int RF_FRONTBACK = 17; // RF_FRONT|RF_BACK
|
| 61 |
+
|
| 62 |
+
const int RF_RANDOMROT = 64; // allow random rotation around axis when placing
|
| 63 |
+
const int RF_ORIGINAL = 128; // use default placement setuped on object in config
|
| 64 |
+
const int RF_DECORRECTION = 256; // angle correction when spawning InventoryItem at Building angle
|
| 65 |
+
const int RF_DEFAULT = 512; // use default placement setuped on object in config
|
| 66 |
+
|
| 67 |
+
// -------------------------------------------------------------------------
|
| 68 |
+
//! Categories for CEApi.EconomyLog
|
| 69 |
+
class EconomyLogCategories
|
| 70 |
+
{
|
| 71 |
+
private void EconomyLogCategories();
|
| 72 |
+
private void ~EconomyLogCategories();
|
| 73 |
+
|
| 74 |
+
const string Economy = "economy";
|
| 75 |
+
const string EconomyRespawn = "economy_respawn";
|
| 76 |
+
const string RespawnQueue = "respawn_queue";
|
| 77 |
+
const string Container = "container";
|
| 78 |
+
const string Matrix = "matrix";
|
| 79 |
+
const string UniqueLoot = "uniqueloot";
|
| 80 |
+
const string Bind = "bind";
|
| 81 |
+
const string SetupFail = "setupfail";
|
| 82 |
+
const string Storage = "storage";
|
| 83 |
+
const string Classes = "class";
|
| 84 |
+
const string Category = "category";
|
| 85 |
+
const string Tag = "tag";
|
| 86 |
+
const string SCategory = "s_category";
|
| 87 |
+
const string STag = "s_tag";
|
| 88 |
+
const string SAreaflags = "s_areaflags";
|
| 89 |
+
const string SCrafted = "s_crafted";
|
| 90 |
+
const string MapGroup = "map_group";
|
| 91 |
+
const string MapComplete = "map_complete";
|
| 92 |
+
const string InfectedZone = "infected_zone";
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
// -------------------------------------------------------------------------
|
| 96 |
+
//! Special strings for CEApi.EconomyMap
|
| 97 |
+
class EconomyMapStrings
|
| 98 |
+
{
|
| 99 |
+
private void EconomyMapStrings();
|
| 100 |
+
private void ~EconomyMapStrings();
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
\brief Generates string that will make CEApi.EconomyMap use all items with this category
|
| 104 |
+
\note This is refering to the CE categories of loot defined in cfglimitsdefinition.xml
|
| 105 |
+
\warning This is persistent per session, when you set it, it will persist until it is set to something else
|
| 106 |
+
\param category \p string The desired loot category
|
| 107 |
+
\return \p string The string to pass into CEApi.EconomyMap
|
| 108 |
+
@code
|
| 109 |
+
GetCEApi().EconomyMap(EconomyMapStrings.Category("food"));
|
| 110 |
+
@endcode
|
| 111 |
+
*/
|
| 112 |
+
static string Category(string category)
|
| 113 |
+
{
|
| 114 |
+
return string.Format("category:%1", category);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
\brief Generates string that will make CEApi.EconomyMap use all items with this tag
|
| 119 |
+
\note This is refering to the CE tags of loot defined in cfglimitsdefinition.xml
|
| 120 |
+
\warning This is persistent per session, when you set it, it will persist until it is set to something else
|
| 121 |
+
\param category \p string The desired loot tag
|
| 122 |
+
\return \p string The string to pass into CEApi.EconomyMap
|
| 123 |
+
@code
|
| 124 |
+
GetCEApi().EconomyMap(EconomyMapStrings.Tag("floor"));
|
| 125 |
+
@endcode
|
| 126 |
+
*/
|
| 127 |
+
static string Tag(string tag)
|
| 128 |
+
{
|
| 129 |
+
return string.Format("tag:%1", tag);
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
//! Everything
|
| 135 |
+
const string ALL_ALL = "all:all";
|
| 136 |
+
//! All loot
|
| 137 |
+
const string ALL_LOOT = "all:loot";
|
| 138 |
+
//! All vehicles
|
| 139 |
+
const string ALL_VEHICLE = "all:vehicle";
|
| 140 |
+
//! All infected
|
| 141 |
+
const string ALL_INFECTED = "all:infected";
|
| 142 |
+
//! All animals
|
| 143 |
+
const string ALL_ANIMAL = "all:animal";
|
| 144 |
+
//! All players
|
| 145 |
+
const string ALL_PLAYER = "all:player";
|
| 146 |
+
//! All proxies
|
| 147 |
+
const string ALL_PROXY = "all:proxy";
|
| 148 |
+
//! All static loot spawns
|
| 149 |
+
const string ALL_PROXY_STATIC = "all:proxystatic";
|
| 150 |
+
//! All dynamic loot spawns
|
| 151 |
+
const string ALL_PROXY_DYNAMIC = "all:proxydynamic";
|
| 152 |
+
//! All abandoned loot spawns
|
| 153 |
+
const string ALL_PROXY_ABANDONED = "all:proxyabandoned";
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
// -------------------------------------------------------------------------
|
| 157 |
+
//! Special strings for CEApi.EconomyOutput
|
| 158 |
+
class EconomyOutputStrings
|
| 159 |
+
{
|
| 160 |
+
private void EconomyOutputStrings();
|
| 161 |
+
private void ~EconomyOutputStrings();
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
\brief Lists stats regarding which loot spawn) that are linked together and how many there are
|
| 165 |
+
\note In logs: "[linked_groups]"
|
| 166 |
+
*/
|
| 167 |
+
const string LINKS = "links";
|
| 168 |
+
/**
|
| 169 |
+
\brief Lists loot spawns that have more loot than their maximum + 4
|
| 170 |
+
\note In logs: "[autotest:ListSuspiciousGroups]"
|
| 171 |
+
*/
|
| 172 |
+
const string SUSPICIOUS = "suspicious";
|
| 173 |
+
/**
|
| 174 |
+
\brief Lists DE spawns that have positions that are within supplied range (< fRange, not equal)
|
| 175 |
+
\note In logs: "[ClosePosition]"
|
| 176 |
+
*/
|
| 177 |
+
const string DE_CLOSE_POINT = "declosepoint";
|
| 178 |
+
/**
|
| 179 |
+
\brief Lists loot spawns that have been marked as abandoned
|
| 180 |
+
\note In logs: "[autotest:ListAbandonedGroups]"
|
| 181 |
+
*/
|
| 182 |
+
const string ABANDONED = "abandoned";
|
| 183 |
+
/**
|
| 184 |
+
\brief Lists loot spawns that are not abandoned but have no loot
|
| 185 |
+
\note In logs: "[autotest:ListEmptyGroups]"
|
| 186 |
+
*/
|
| 187 |
+
const string EMPTY = "empty";
|
| 188 |
+
/**
|
| 189 |
+
\brief Lists loot spawns that are not abandoned and within the supplied range (< fRange, not equal)
|
| 190 |
+
\note In logs: "[autotest:ListCloseGroups]"
|
| 191 |
+
\note Is the same as CEApi.ListCloseProxy
|
| 192 |
+
*/
|
| 193 |
+
const string CLOSE = "close";
|
| 194 |
+
/**
|
| 195 |
+
\brief Lists the number of objects inside of categories
|
| 196 |
+
\note In logs: "[autotest:ProcessDebugLog]"
|
| 197 |
+
*/
|
| 198 |
+
const string WORLD = "world";
|
| 199 |
+
/**
|
| 200 |
+
\brief Lists overall CE stats
|
| 201 |
+
\note In logs: "[autotest:OverallStatus]"
|
| 202 |
+
*/
|
| 203 |
+
const string STATUS = "status";
|
| 204 |
+
/**
|
| 205 |
+
\brief Lists the maxlootsize of all CE items
|
| 206 |
+
\note In logs: "[autotest:ListLootSize]"
|
| 207 |
+
*/
|
| 208 |
+
const string LOOT_SIZE = "lootsize";
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
// -------------------------------------------------------------------------
|
| 212 |
+
enum ESpawnVolumeVis
|
| 213 |
+
{
|
| 214 |
+
OFF = 0,
|
| 215 |
+
ADAPTIVE,
|
| 216 |
+
VOLUME,
|
| 217 |
+
OCCUPIED,
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
// -------------------------------------------------------------------------
|
| 221 |
+
/**
|
| 222 |
+
\brief API to interact with Central Economy
|
| 223 |
+
\note Accessible through GetCEApi, make sure to read the documentation for that as well
|
| 224 |
+
\note Any mention of 'storage/' means the '$mission:storage_#' folder
|
| 225 |
+
*/
|
| 226 |
+
class CEApi
|
| 227 |
+
{
|
| 228 |
+
private void CEApi() {}
|
| 229 |
+
private void ~CEApi() {}
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
\brief Regenerates "storage/spawnpoints.bin" if necessary
|
| 233 |
+
\note Already happens automatically when server starts before it is loaded in
|
| 234 |
+
@code
|
| 235 |
+
GetCEApi().ExportSpawnData();
|
| 236 |
+
@endcode
|
| 237 |
+
*/
|
| 238 |
+
proto native void ExportSpawnData();
|
| 239 |
+
/**
|
| 240 |
+
\brief Generates "storage/export/mapgrouppos.xml"
|
| 241 |
+
\param vCenter \p vector Center of area to generate from
|
| 242 |
+
\note When using a zero vector, this will automatically get the world center
|
| 243 |
+
\param fRadius \p float Radius in meters of area to generate from
|
| 244 |
+
\note When 0, this will automatically get a radius covering the map
|
| 245 |
+
@code
|
| 246 |
+
// Export for whole map
|
| 247 |
+
GetCEApi().ExportProxyData();
|
| 248 |
+
@endcode
|
| 249 |
+
*/
|
| 250 |
+
proto native void ExportProxyData( vector vCenter = vector.Zero, float fRadius = 0 );
|
| 251 |
+
/**
|
| 252 |
+
\brief Generates "storage/export/mapgroupcluster.xml"
|
| 253 |
+
@code
|
| 254 |
+
GetCEApi().ExportClusterData();
|
| 255 |
+
@endcode
|
| 256 |
+
*/
|
| 257 |
+
proto native void ExportClusterData();
|
| 258 |
+
/**
|
| 259 |
+
\brief Generates "storage/export/mapgroupproto.xml"
|
| 260 |
+
@code
|
| 261 |
+
GetCEApi().ExportProxyProto();
|
| 262 |
+
@endcode
|
| 263 |
+
*/
|
| 264 |
+
proto native void ExportProxyProto();
|
| 265 |
+
/**
|
| 266 |
+
\brief Invalidates loot spawn points which are closer than the radius supplied
|
| 267 |
+
\note Will output a message indicating how many points were invalidated
|
| 268 |
+
\param fRadius \p float The minimum desired distance in meters between loot spawn points
|
| 269 |
+
\note When 0 it will use a radius of 0.5
|
| 270 |
+
\param bAllSelections \p bool When false, will only check the points within a container against each other, when true will against all points
|
| 271 |
+
@code
|
| 272 |
+
// Example: I want there to be a minimum distance of 0.3m between any loot spawn point
|
| 273 |
+
GetCEApi().MarkCloseProxy(0.3, true);
|
| 274 |
+
@endcode
|
| 275 |
+
*/
|
| 276 |
+
proto native void MarkCloseProxy( float fRadius, bool bAllSelections );
|
| 277 |
+
/**
|
| 278 |
+
\brief Removes all invalid points
|
| 279 |
+
\note Is best paired with a MarkCloseProxy call first to invalidate unwanted points
|
| 280 |
+
\note Will output a message indicating the amount of deleted points
|
| 281 |
+
@code
|
| 282 |
+
GetCEApi().RemoveCloseProxy();
|
| 283 |
+
@endcode
|
| 284 |
+
*/
|
| 285 |
+
proto native void RemoveCloseProxy();
|
| 286 |
+
/**
|
| 287 |
+
\brief Outputs a list of all loot points closer than specified radius
|
| 288 |
+
\note This will automatically be checking all points against all points
|
| 289 |
+
\note This is a better way of handling it than the above two methods, as it can be then be removed manually from the xmls
|
| 290 |
+
\note Is the same as CEApi.EconomyOutput(EconomyOutputStrings.CLOSE, fRadius)
|
| 291 |
+
\param fRadius \p float The minimum desired distance in meters between loot spawn points
|
| 292 |
+
@code
|
| 293 |
+
GetCEApi().ListCloseProxy(0.3);
|
| 294 |
+
@endcode
|
| 295 |
+
*/
|
| 296 |
+
proto native void ListCloseProxy( float fRadius );
|
| 297 |
+
|
| 298 |
+
/**
|
| 299 |
+
\brief Will emulate the spawning of the item which is being looked at and generate images (.tga) in storage/lmap and output logs
|
| 300 |
+
\note DEVELOPER/DIAG ONLY
|
| 301 |
+
\note This will only work if the loot spawner is active
|
| 302 |
+
\param sClassName \p string The class name of the desired item to analyze
|
| 303 |
+
\note When using "*" as class name, instead of generating images, it will generate a .csv in storage/log containing the output of all spawnable items
|
| 304 |
+
\return \p bool Whether the operation was successful, it might fail in certain scenarios if the CE doesn't update in time
|
| 305 |
+
@code
|
| 306 |
+
GetCEApi().SpawnAnalyze("FlatCap_Grey");
|
| 307 |
+
@endcode
|
| 308 |
+
*/
|
| 309 |
+
proto native bool SpawnAnalyze( string sClassName );
|
| 310 |
+
|
| 311 |
+
/**
|
| 312 |
+
\brief Subtracts the supplied value from the current lifetime of all items in the world
|
| 313 |
+
\note Uses RadiusLifetimeDecrease under the hood and then calculates the parameters to fit the world
|
| 314 |
+
\note Will automatically clamp result between min and max lifetime [3, 316224000] (3 seconds to 10 years)
|
| 315 |
+
\param fShift \p float The value in seconds which will be subtracted from the current lifetimes
|
| 316 |
+
@code
|
| 317 |
+
// Shortens the lifetimes of all items in the world by 3 seconds
|
| 318 |
+
GetCEApi().TimeShift(3);
|
| 319 |
+
@endcode
|
| 320 |
+
*/
|
| 321 |
+
proto native void TimeShift( float fShift );
|
| 322 |
+
/**
|
| 323 |
+
\brief Fills in the Debug Lifetime, which will be used for any new DE spawned
|
| 324 |
+
\param fLifeTime \p float The lifetime for any DE spawned after this call
|
| 325 |
+
\note When this is set back to 0, it will stop using the Debug Lifetime
|
| 326 |
+
@code
|
| 327 |
+
// Any DE spawned after this call will have a lifetime of 300 seconds
|
| 328 |
+
GetCEApi().OverrideLifeTime(300);
|
| 329 |
+
@endcode
|
| 330 |
+
*/
|
| 331 |
+
proto native void OverrideLifeTime( float fLifeTime );
|
| 332 |
+
|
| 333 |
+
/**
|
| 334 |
+
\brief Force spawn specific prototype group + loot at position
|
| 335 |
+
\note DEVELOPER/DIAG ONLY
|
| 336 |
+
\note This can also spawn in other CE & DE related objects, but is best used exclusively for testing prototype groups
|
| 337 |
+
\param sGroupName \p string The group name to spawn
|
| 338 |
+
\param vPos \p vector The position to spawn the Entity at
|
| 339 |
+
\param fAngle \p float Angle to spawn the Entity with in degrees [0, 360]
|
| 340 |
+
\note When a negative value, will pick a random one
|
| 341 |
+
\return \p Entity The spawned Entity or null if unsuccessful
|
| 342 |
+
@code
|
| 343 |
+
GetCEApi().SpawnGroup("Land_Shed_M1", Vector(5, 10, 5));
|
| 344 |
+
@endcode
|
| 345 |
+
*/
|
| 346 |
+
proto native Entity SpawnGroup( string sGroupName, vector vPos, float fAngle = -1 );
|
| 347 |
+
/**
|
| 348 |
+
\brief Force spawn specific dynamic event
|
| 349 |
+
\note DEVELOPER/DIAG ONLY
|
| 350 |
+
\note Versatile, can be used for Animal, Infected, Static, Item and Vehicle
|
| 351 |
+
\note Is the only one capable of spawning DE's that have DE Groups
|
| 352 |
+
\note Is the same as the next one, but has ECE_FULL flags and a hidden flag which overrides herd limit
|
| 353 |
+
\note This is also FORCE spawn, so it will bypass any limit and avoidance checks
|
| 354 |
+
\param sEvName \p string The DE to spawn
|
| 355 |
+
\param vPos \p vector The position to spawn the Entity at
|
| 356 |
+
\param fAngle \p float Angle to spawn the Entity with in degrees [0, 360]
|
| 357 |
+
\note When a negative value, will pick a random one
|
| 358 |
+
\return \p bool Whether the spawn was successful
|
| 359 |
+
@code
|
| 360 |
+
GetCEApi().SpawnDE("StaticHeliCrash", Vector(5, 10, 5));
|
| 361 |
+
@endcode
|
| 362 |
+
*/
|
| 363 |
+
proto native void SpawnDE( string sEvName, vector vPos, float fAngle = -1 );
|
| 364 |
+
/**
|
| 365 |
+
\brief Force spawn specific dynamic event
|
| 366 |
+
\note DEVELOPER/DIAG ONLY
|
| 367 |
+
\note Is the same one as above but with the possibility of custom flags
|
| 368 |
+
\param sEvName \p string The DE to spawn
|
| 369 |
+
\param vPos \p vector The position to spawn the Entity at
|
| 370 |
+
\param fAngle \p float Angle to spawn the Entity with in degrees [0, 360]
|
| 371 |
+
\note When a negative value, will pick a random one
|
| 372 |
+
\param uFlags \p int ECE flags to apply while spawning the DE
|
| 373 |
+
\return \p bool Whether the spawn was successful
|
| 374 |
+
@code
|
| 375 |
+
GetCEApi().SpawnDEEx("StaticHeliCrash", Vector(5, 10, 5), ECE_FULL);
|
| 376 |
+
@endcode
|
| 377 |
+
*/
|
| 378 |
+
proto native void SpawnDEEx( string sEvName, vector vPos, float fAngle, int uFlags );
|
| 379 |
+
/**
|
| 380 |
+
\brief Spawn an item through CE
|
| 381 |
+
\note DEVELOPER/DIAG ONLY
|
| 382 |
+
\param sEvName \p string The DE to spawn
|
| 383 |
+
\param vPos \p vector The position to spawn the Entity at
|
| 384 |
+
\param fAngle \p float Angle to spawn the Entity with in degrees [0, 360]
|
| 385 |
+
\note When a negative value, will pick a random one
|
| 386 |
+
\param iCount \p int The amount of items
|
| 387 |
+
\param fRange \p float Circle radius
|
| 388 |
+
\note When iCount is larger than 1, changing this will make it so that they are spawned in a circle around vPos
|
| 389 |
+
@code
|
| 390 |
+
GetCEApi().SpawnLoot("Deagle", Vector(5, 10, 5), 0, 9, 1);
|
| 391 |
+
@endcode
|
| 392 |
+
*/
|
| 393 |
+
proto native void SpawnLoot( string sEvName, vector vPos, float fAngle, int iCount = 1, float fRange = 1 );
|
| 394 |
+
|
| 395 |
+
/**
|
| 396 |
+
\brief Spawn all entities with dynamic category through CE
|
| 397 |
+
\note DEVELOPER/DIAG ONLY
|
| 398 |
+
\note Will print additional logs to RPT
|
| 399 |
+
\param vPos \p vector The position to spawn the Entities at
|
| 400 |
+
\note This will be the starting position, the items will be split into segments by CE BBox size (smallest to largest)
|
| 401 |
+
\param bShowCylinders \p bool Whether to draw the CE BBox with debug shapes
|
| 402 |
+
\note Red: Invalid BBox; Yellow: Not in DB; Green: All ok
|
| 403 |
+
\param fDefaultDistance \p float The default distance to use when the entity does not have a CE BBox
|
| 404 |
+
\note This means that all the ones with invalid CE BBoxes will be piled up at the starting position when this is 0
|
| 405 |
+
@code
|
| 406 |
+
GetCEApi().SpawnDynamic(Vector(5, 10, 5), true);
|
| 407 |
+
@endcode
|
| 408 |
+
*/
|
| 409 |
+
proto native void SpawnDynamic( vector vPos, bool bShowCylinders = true, float fDefaultDistance = 0 );
|
| 410 |
+
/**
|
| 411 |
+
\brief Spawn all entities with vehicles category through CE
|
| 412 |
+
\note DEVELOPER/DIAG ONLY
|
| 413 |
+
\note Will print additional logs to RPT
|
| 414 |
+
\param vPos \p vector The position to spawn the Entities at
|
| 415 |
+
\note This will be the starting position, vehicles spawn with 20m spacing
|
| 416 |
+
\note Make sure you do it on a surface as flat and open as possible, they need a lot of space
|
| 417 |
+
\param bShowCylinders \p bool Does nothing for Vehicles, left for backwards compat
|
| 418 |
+
\param fDefaultDistance \p float The default distance to use when the entity does not have a CE BBox
|
| 419 |
+
\note This means that all the ones with invalid CE BBoxes will be piled up at the starting position when this is 0
|
| 420 |
+
@code
|
| 421 |
+
GetCEApi().SpawnVehicles(Vector(5, 10, 5));
|
| 422 |
+
@endcode
|
| 423 |
+
*/
|
| 424 |
+
proto native void SpawnVehicles( vector vPos, bool bShowCylinders = false, float fDefaultDistance = 20 );
|
| 425 |
+
/**
|
| 426 |
+
\brief Spawn all entities with building category through CE
|
| 427 |
+
\note DEVELOPER/DIAG ONLY
|
| 428 |
+
\note Will print additional logs to RPT
|
| 429 |
+
\param vPos \p vector The position to spawn the Entities at
|
| 430 |
+
\note This will be the starting position, the items will be split into segments by CE BBox size (smallest to largest)
|
| 431 |
+
\param bShowCylinders \p bool Whether to draw the CE BBox with debug shapes
|
| 432 |
+
\note Red: Invalid BBox; Yellow: Not in DB; Green: All ok
|
| 433 |
+
\note These will most likely just always be red
|
| 434 |
+
\param fDefaultDistance \p float The default distance to use when the entity does not have a CE BBox
|
| 435 |
+
\note This means that all the ones with invalid CE BBoxes will be piled up at the starting position when this is 0
|
| 436 |
+
@code
|
| 437 |
+
GetCEApi().SpawnBuilding(Vector(5, 10, 5), true);
|
| 438 |
+
@endcode
|
| 439 |
+
*/
|
| 440 |
+
proto native void SpawnBuilding( vector vPos, bool bShowCylinders = false, float fDefaultDistance = 20 );
|
| 441 |
+
|
| 442 |
+
/**
|
| 443 |
+
\brief Spawn an entity through CE
|
| 444 |
+
\note DEVELOPER/DIAG ONLY
|
| 445 |
+
\note Is similar to SpawnLoot, but works better on Animal/Infected/Vehicle
|
| 446 |
+
\param sClassName \p string The entity to spawn
|
| 447 |
+
\param vPos \p vector The position to spawn the Entity at
|
| 448 |
+
\param fRange \p float Circle radius
|
| 449 |
+
\note When iCount is larger than 1, changing this will make it so that they are spawned in a circle around vPos
|
| 450 |
+
\param iCount \p int The amount of items
|
| 451 |
+
@code
|
| 452 |
+
GetCEApi().SpawnEntity("Deagle", Vector(5, 10, 5), 1, 9);
|
| 453 |
+
@endcode
|
| 454 |
+
*/
|
| 455 |
+
proto native void SpawnEntity( string sClassName, vector vPos, float fRange, int iCount );
|
| 456 |
+
/**
|
| 457 |
+
\brief Spawn an entity through CE
|
| 458 |
+
\note DEVELOPER/DIAG ONLY
|
| 459 |
+
\note Is the same as SpawnEntity, but spawns only one and returns the spawned Object
|
| 460 |
+
\param sClassName \p string The entity to spawn
|
| 461 |
+
\param vPos \p vector The position to spawn the Entity at
|
| 462 |
+
\return \p Object The spawned Object
|
| 463 |
+
@code
|
| 464 |
+
GetCEApi().SpawnSingleEntity("Deagle", Vector(5, 10, 5));
|
| 465 |
+
@endcode
|
| 466 |
+
*/
|
| 467 |
+
proto native Object SpawnSingleEntity( string sClassName, vector vPos );
|
| 468 |
+
/**
|
| 469 |
+
\brief Spawn an entity through CE
|
| 470 |
+
\note DEVELOPER/DIAG ONLY
|
| 471 |
+
\note Is the same as SpawnEntity, under the hood it just defaults to RF_ORIGINAL
|
| 472 |
+
\param sClassName \p string The entity to spawn
|
| 473 |
+
\param vPos \p vector The position to spawn the Entity at
|
| 474 |
+
\param fRange \p float Circle radius
|
| 475 |
+
\note When iCount is larger than 1, changing this will make it so that they are spawned in a circle around vPos
|
| 476 |
+
\param iCount \p int The amount of items
|
| 477 |
+
\param iFlags \p int The rotation flags to apply
|
| 478 |
+
@code
|
| 479 |
+
GetCEApi().SpawnRotation("Deagle", Vector(5, 10, 5), 1, 9, RF_ALL);
|
| 480 |
+
@endcode
|
| 481 |
+
*/
|
| 482 |
+
proto native void SpawnRotation( string sClassName, vector vPos, float fRange, int iCount, int iFlags );
|
| 483 |
+
/**
|
| 484 |
+
\brief Spawn an entity through CE, x amount of times in a grid
|
| 485 |
+
\note DEVELOPER/DIAG ONLY
|
| 486 |
+
\note The name may imply it does something else, but a profiler is needed to actually benchmark it
|
| 487 |
+
\note The position starts at 0 0 0
|
| 488 |
+
\param sClassName \p string The entity to spawn
|
| 489 |
+
\param iCount \p int The amount of items
|
| 490 |
+
@code
|
| 491 |
+
GetCEApi().SpawnPerfTest("Deagle", 30);
|
| 492 |
+
@endcode
|
| 493 |
+
*/
|
| 494 |
+
proto native void SpawnPerfTest( string sClassName, int iCount );
|
| 495 |
+
|
| 496 |
+
/**
|
| 497 |
+
\brief Queue up the depleting of lifetime of everything in the world
|
| 498 |
+
\note DEVELOPER/DIAG ONLY
|
| 499 |
+
@code
|
| 500 |
+
GetCEApi().CleanMap();
|
| 501 |
+
@endcode
|
| 502 |
+
*/
|
| 503 |
+
proto native void CleanMap();
|
| 504 |
+
|
| 505 |
+
/**
|
| 506 |
+
\brief Outputs debug file to storage/log/*.csv
|
| 507 |
+
\note DEVELOPER/DIAG ONLY
|
| 508 |
+
\param sLogType \p string The type of log (EconomyLogCategories)
|
| 509 |
+
@code
|
| 510 |
+
GetCEApi().EconomyLog(EconomyLogCategories.Economy);
|
| 511 |
+
@endcode
|
| 512 |
+
*/
|
| 513 |
+
proto native void EconomyLog( string sLogType );
|
| 514 |
+
|
| 515 |
+
/**
|
| 516 |
+
\brief Outputs debug file to storage/lmap/*.tga showing the current places this is spawned
|
| 517 |
+
\note DEVELOPER/DIAG ONLY
|
| 518 |
+
\note This works best when you have an image of the map to overlay the tga with afterwards
|
| 519 |
+
\param sMapType \p string The type of lmap, can be just a class name or a special string
|
| 520 |
+
\note There are several prefixes and sets of strings that can be passed in here, see EconomyMapStrings
|
| 521 |
+
@code
|
| 522 |
+
// To check only a specific item
|
| 523 |
+
GetCEApi().EconomyMap("Deagle");
|
| 524 |
+
@endcode
|
| 525 |
+
*/
|
| 526 |
+
proto native void EconomyMap( string sMapType );
|
| 527 |
+
/**
|
| 528 |
+
\brief Outputs debug logs into server log or rpt
|
| 529 |
+
\note DEVELOPER/DIAG ONLY
|
| 530 |
+
\param sOutputType \p string One of the strings specified in EconomyOutputStrings
|
| 531 |
+
\param fRange \p float Range parameter used for some of the options
|
| 532 |
+
@code
|
| 533 |
+
GetCEApi().EconomyOutput(EconomyOutputStrings.CLOSE, 3);
|
| 534 |
+
@endcode
|
| 535 |
+
*/
|
| 536 |
+
proto native void EconomyOutput( string sOutputType, float fRange );
|
| 537 |
+
|
| 538 |
+
/**
|
| 539 |
+
\brief Process lifetime increase within radius by value (sec)
|
| 540 |
+
\note Will automatically clamp result between min and max lifetime [3, 316224000] (3 seconds to 10 years)
|
| 541 |
+
\param vCenter \p vector The center point
|
| 542 |
+
\param fRadius \p float The radius around the center point
|
| 543 |
+
\param fValue \p float The value to increase the lifetime by
|
| 544 |
+
\note When 0, this will reset it to default instead (but it's better to use RadiusLifetimeReset still)
|
| 545 |
+
@code
|
| 546 |
+
GetCEApi().RadiusLifetimeIncrease(Vector(500, 0, 500), 3, 500);
|
| 547 |
+
@endcode
|
| 548 |
+
*/
|
| 549 |
+
proto native void RadiusLifetimeIncrease( vector vCenter, float fRadius, float fValue );
|
| 550 |
+
/**
|
| 551 |
+
\brief Process lifetime decrease within radius by value (sec)
|
| 552 |
+
\note Will automatically clamp result between min and max lifetime [3, 316224000] (3 seconds to 10 years)
|
| 553 |
+
\param vCenter \p vector The center point
|
| 554 |
+
\param fRadius \p float The radius around the center point
|
| 555 |
+
\param fValue \p float The value to decrease the lifetime by
|
| 556 |
+
@code
|
| 557 |
+
GetCEApi().RadiusLifetimeDecrease(Vector(500, 0, 500), 3, 500);
|
| 558 |
+
@endcode
|
| 559 |
+
*/
|
| 560 |
+
proto native void RadiusLifetimeDecrease( vector vCenter, float fRadius, float fValue );
|
| 561 |
+
/**
|
| 562 |
+
\brief Process lifetime reset to default value from DB within radius
|
| 563 |
+
\param vCenter \p vector The center point
|
| 564 |
+
\param fRadius \p float The radius around the center point
|
| 565 |
+
@code
|
| 566 |
+
GetCEApi().RadiusLifetimeReset(Vector(500, 0, 500), 3);
|
| 567 |
+
@endcode
|
| 568 |
+
*/
|
| 569 |
+
proto native void RadiusLifetimeReset( vector vCenter, float fRadius );
|
| 570 |
+
|
| 571 |
+
|
| 572 |
+
|
| 573 |
+
/** \name Globals API
|
| 574 |
+
Get values from globals.xml
|
| 575 |
+
*/
|
| 576 |
+
//@{
|
| 577 |
+
|
| 578 |
+
/**
|
| 579 |
+
\brief Get int from globals.xml
|
| 580 |
+
\note type="0"
|
| 581 |
+
\param varName \p string The name of the entry
|
| 582 |
+
\return \p int The value or int.MIN if not found/not an int
|
| 583 |
+
*/
|
| 584 |
+
proto native int GetCEGlobalInt(string varName);
|
| 585 |
+
/**
|
| 586 |
+
\brief Get float from globals.xml
|
| 587 |
+
\note type="1"
|
| 588 |
+
\param varName \p string The name of the entry
|
| 589 |
+
\return \p float The value or float.MIN if not found/not a float
|
| 590 |
+
*/
|
| 591 |
+
proto native float GetCEGlobalFloat(string varName);
|
| 592 |
+
/**
|
| 593 |
+
\brief Get string from globals.xml
|
| 594 |
+
\note type="2"
|
| 595 |
+
\param varName \p string The name of the entry
|
| 596 |
+
\return \p string The value or empty string if not found/not a string
|
| 597 |
+
*/
|
| 598 |
+
proto native string GetCEGlobalString(string varName);
|
| 599 |
+
|
| 600 |
+
//@}
|
| 601 |
+
|
| 602 |
+
|
| 603 |
+
|
| 604 |
+
/** \name Avoidance API
|
| 605 |
+
Optimized internal methods that the CE uses to avoid spawning DE within certain distances
|
| 606 |
+
*/
|
| 607 |
+
//@{
|
| 608 |
+
|
| 609 |
+
/**
|
| 610 |
+
\brief Check if there is a player within a radius
|
| 611 |
+
\param vPos \p vector The center point
|
| 612 |
+
\param fDistance \p float The radius around the center point
|
| 613 |
+
\return \p bool Returns false when there is a player inside supplied area, true when it successfully avoided players
|
| 614 |
+
@code
|
| 615 |
+
GetCEApi().AvoidPlayer(Vector(500, 0, 500), 20);
|
| 616 |
+
@endcode
|
| 617 |
+
*/
|
| 618 |
+
proto native bool AvoidPlayer(vector vPos, float fDistance); // return false when there is a player
|
| 619 |
+
/**
|
| 620 |
+
\brief Check if there is a vehicle within a radius
|
| 621 |
+
\param vPos \p vector The center point
|
| 622 |
+
\param fDistance \p float The radius around the center point
|
| 623 |
+
\param sDEName \p string A specific DE to avoid, if left empty, will avoid all vehicles
|
| 624 |
+
\return \p bool Returns false when there is a vehicle inside supplied area, true when it successfully avoided vehicles
|
| 625 |
+
@code
|
| 626 |
+
GetCEApi().AvoidVehicle(Vector(500, 0, 500), 500, "VehicleCivilianSedan");
|
| 627 |
+
@endcode
|
| 628 |
+
*/
|
| 629 |
+
proto native bool AvoidVehicle(vector vPos, float fDistance, string sDEName = "");
|
| 630 |
+
/**
|
| 631 |
+
\brief Check if there is a vehicle within a radius
|
| 632 |
+
\param vPos \p vector The center point
|
| 633 |
+
\param fRange \p float The radius around the center point
|
| 634 |
+
\return \p int The amoutn of players inside supplied area
|
| 635 |
+
@code
|
| 636 |
+
GetCEApi().CountPlayersWithinRange(Vector(500, 0, 500), 500);
|
| 637 |
+
@endcode
|
| 638 |
+
*/
|
| 639 |
+
proto native int CountPlayersWithinRange(vector vPos, float fRange);
|
| 640 |
+
|
| 641 |
+
//@}
|
| 642 |
+
|
| 643 |
+
|
| 644 |
+
|
| 645 |
+
/** \name CE Debug menu Script API
|
| 646 |
+
DIAG ONLY: These options are available from the in-game debug menu on Diag exe (Game > Central Economy), documentation can be found on wiki
|
| 647 |
+
*/
|
| 648 |
+
//@{
|
| 649 |
+
|
| 650 |
+
// "Loot Spawn Edit"
|
| 651 |
+
//{
|
| 652 |
+
//! "Spawn Volume Vis"
|
| 653 |
+
proto native void LootSetSpawnVolumeVisualisation(ESpawnVolumeVis mode);
|
| 654 |
+
//! "Setup Vis"
|
| 655 |
+
proto native void LootToggleSpawnSetup(bool mode);
|
| 656 |
+
//! "Edit Volume"
|
| 657 |
+
proto native void LootToggleVolumeEditing(bool mode);
|
| 658 |
+
//! "Re-Trace Group Points"
|
| 659 |
+
proto native void LootRetraceGroupPoints();
|
| 660 |
+
//! "Export Group >>"
|
| 661 |
+
proto native void LootExportGroup();
|
| 662 |
+
//! "Export All Groups >>>>" / GetCEApi.ExportProxyProto();
|
| 663 |
+
proto native void LootExportAllGroups();
|
| 664 |
+
//! "<<< Export Map" / GetCEApi.ExportProxyData(vector.Zero, 0);
|
| 665 |
+
proto native void LootExportMap();
|
| 666 |
+
//! "<<< Export Clusters" / GetCEApi().ExportClusterData()
|
| 667 |
+
proto native void LootExportClusters();
|
| 668 |
+
//}
|
| 669 |
+
|
| 670 |
+
// "Loot Tool"
|
| 671 |
+
//{
|
| 672 |
+
//! "Deplete Lifetime"
|
| 673 |
+
proto native void LootDepleteLifetime();
|
| 674 |
+
//! "Set Damage = 1.0"
|
| 675 |
+
proto native void LootSetDamageToOne();
|
| 676 |
+
//! "Damage + Deplete"
|
| 677 |
+
proto native void LootDepleteAndDamage();
|
| 678 |
+
//}
|
| 679 |
+
|
| 680 |
+
// "Infected"
|
| 681 |
+
//{
|
| 682 |
+
//! "Infected Vis"
|
| 683 |
+
proto native void InfectedToggleVisualisation(bool mode);
|
| 684 |
+
//! "Infected Zone Info"
|
| 685 |
+
proto native void InfectedToggleZoneInfo(bool mode);
|
| 686 |
+
//! "Infected Spawn"
|
| 687 |
+
proto native void InfectedSpawn();
|
| 688 |
+
//! "Reset Cleanup"
|
| 689 |
+
proto native void InfectedResetCleanup();
|
| 690 |
+
//}
|
| 691 |
+
|
| 692 |
+
// "Animal"
|
| 693 |
+
//{
|
| 694 |
+
//! "Animal Vis"
|
| 695 |
+
proto native void AnimalToggleVisualisation(bool mode);
|
| 696 |
+
//! "Animal Spawn"
|
| 697 |
+
proto native void AnimalSpawn();
|
| 698 |
+
//! "Ambient Spawn"
|
| 699 |
+
proto native void AnimalAmbientSpawn();
|
| 700 |
+
//}
|
| 701 |
+
|
| 702 |
+
//! "Vehicle&Wreck Vis"
|
| 703 |
+
proto native void ToggleVehicleAndWreckVisualisation(bool mode);
|
| 704 |
+
//! "Loot Vis"
|
| 705 |
+
proto native void ToggleLootVisualisation(bool mode);
|
| 706 |
+
//! "Cluster Vis"
|
| 707 |
+
proto native void ToggleClusterVisualisation(bool mode);
|
| 708 |
+
|
| 709 |
+
//! "Dynamic Events Status"
|
| 710 |
+
proto native void ToggleDynamicEventStatus(bool mode);
|
| 711 |
+
//! "Dynamic Events Vis"
|
| 712 |
+
proto native void ToggleDynamicEventVisualisation(bool mode);
|
| 713 |
+
//! "Dynamic Events Spawn"
|
| 714 |
+
proto native void DynamicEventSpawn();
|
| 715 |
+
//! "Export Dyn Event >>"
|
| 716 |
+
proto native void DynamicEventExport();
|
| 717 |
+
|
| 718 |
+
//! "Overall Stats"
|
| 719 |
+
proto native void ToggleOverallStats(bool mode);
|
| 720 |
+
|
| 721 |
+
//@}
|
| 722 |
+
|
| 723 |
+
|
| 724 |
+
|
| 725 |
+
/** \name DEPRECATED/LEGACY
|
| 726 |
+
These don't do anything anymore but are left for backwards compatibility
|
| 727 |
+
*/
|
| 728 |
+
//@{
|
| 729 |
+
|
| 730 |
+
proto native void PlatformStatTest();
|
| 731 |
+
|
| 732 |
+
proto native void LootToggleProxyEditing(bool mode);
|
| 733 |
+
|
| 734 |
+
proto native void OnUpdate();
|
| 735 |
+
|
| 736 |
+
//@}
|
| 737 |
+
};
|
| 738 |
+
|
| 739 |
+
/**
|
| 740 |
+
\brief Get the CE API
|
| 741 |
+
\warning Only exists when the game has CE enabled
|
| 742 |
+
\note This means that this will work on anything which is running a mission with an initialized Hive
|
| 743 |
+
\note Client does not have Hive when connected to a server, only the server does if it was set up in the init.c
|
| 744 |
+
*/
|
| 745 |
+
proto native CEApi GetCEApi();
|
| 746 |
+
|
| 747 |
+
// -------------------------------------------------------------------------
|
| 748 |
+
class CEItemProfile
|
| 749 |
+
{
|
| 750 |
+
private void CEItemProfile() {}
|
| 751 |
+
private void ~CEItemProfile() {}
|
| 752 |
+
|
| 753 |
+
proto native int GetNominal(); // nominal - how many items should be aproximately in map
|
| 754 |
+
proto native int GetMin(); // min - minimal count should be available in map
|
| 755 |
+
|
| 756 |
+
proto native float GetQuantityMin(); // min quantity (0.0 - 1.0) (like ammobox - this determine how many bullets are there, or water bottle)
|
| 757 |
+
proto native float GetQuantityMax(); // max quantity (0.0 - 1.0) (like ammobox - this determine how many bullets are there, or water bottle)
|
| 758 |
+
|
| 759 |
+
proto native float GetQuantity(); // random quantity (0.0 - 1.0)
|
| 760 |
+
|
| 761 |
+
proto native float GetLifetime(); // maximum lifetime in (seconds) - what is the idle before item abandoned at ground gets deleted
|
| 762 |
+
proto native float GetRestock(); // restock is oposite of lifetime - idle before item is allowed to respawn when required
|
| 763 |
+
|
| 764 |
+
proto native int GetCost(); // cost of item determines its 'value' for players (this serve as priority during respawn and cleanup operation)
|
| 765 |
+
|
| 766 |
+
proto native int GetUsageFlags(); // area usage flags (each bit has assigned group - which as part of map overlay effectively affects spawning)
|
| 767 |
+
proto native int GetValueFlags(); // area value flags (each bit has assigned group - which as part of map overlay effectively affects spawning)
|
| 768 |
+
};
|