Search the Community
Showing results for tags 'c++'.
Found 6 results
-
Best Ways to learn modding in Enfusion?
Gylden_Drage posted a topic in Arma Reforger - Mods: Discussion
https://community.bistudio.com/wiki/Category:Arma_Reforger/Modding/Tutorials https://community.bistudio.com/wiki/Category:Arma_Reforger/Modding https://community.bistudio.com/wiki/Arma_Reforger:From_SQF_to_Enforce_Script Ive read through most of these wiki's so far, there is a good deal I'm not understanding and curious what portions of my learning C++ will be useful in understanding how to adjust variables and game modes when modding Arma Reforger. While I've used limited parts of SQF from the A 3 days in editing small things in files for my own use. I'm wanting to understand the Enforce Script deeper than I ever did SQF things from A3. As I've read that it's inspired by C++, I am curious what things as a new coder I should be paying attention to, and what things I wont need to worry about so much when modding with Enfusion. What concepts will be most important that I can take from C++ and incorporate that knowledge with Enfusion? I hope that question isn't too open ended. My goals are primarily to modify game modes like Conflict to make "bases" smaller, use different place-able objects in place of the Antenna, Vehicle Depot, Materials Depot, Base, and etc. Ideally I want to require a player to find an item that randomly spawns in a city, and that item is a sort of "key" to allow them to take control of a territory. I understand I have a lot of work ahead of me, but I'm retired with time on my side to figure things out. I want to make best use of my time and efficiently start somewhere that will lead to using my time productively. I just am sort of lost at the moment on where to start learning. How much C++ should I know before I begin to try and mod game modes in Reforger? I'm not looking for perfect answers just a direction on where to look harder to learn myself. Thanks. -
Intercept: A library for writing Arma Addons in native C++
noubernou posted a topic in ARMA 3 - ADDONS & MODS: DISCUSSION
Intercept is a C/C++ binding interface to the Arma 3 engine (internally referred to as the Real Virtuality or RV engine). It's goal is to provide easy to use library for addon makers to develop addons in a native language, or to develop language extensions for the Arma 3 engine. In a nutshell, Intercept provides a full C/C++ binding system for calling the base C++ functions which are declared in RVEngine for SQF functions. All SQF functions within the RVEngine are actually native code, which is called by SQF via the function names. Intercept bypasses SQF entirely, allowing native C++ plugins to seamlessly interact with the game engine. In essence, Intercept allows for expansions of the game engine, calling internal functionality of the engine which has been exposed via SQF functions. This was the idea behind the intended Java implementation by Bohemia Interactive in Take On Helicopters and was planned for, but never implemented in Arma 3. Intercept not only completes the intended functionality of what Java was meant to provide but has gone much further, including returning data to SQF and multithreaded addons. Intercept works on a host/client based system, in which the host, Intercept itself, hosts client DLLs that implement the Intercept library. The Intercept host handles access to the RV engine by clients through a layer that provides thread concurrency, memory handling, and event dispatching. Client DLLs are then able to be written in a way that can safely ignore most internal nuances of handling data in the RV engine and work with standard C++ STD/STL data types, and only a few specialized objects specific to the game engine. The Intercept library also provides raw C bindings to the C++ versions of SQF functions, so it is entirely possible to use Intercept as the basis for writing in additional scripting languages to the RV engine, such as Python or Lua. You can find more information on our GitHub project page. Technical Details Intercept works by making direct calls to the SQF functions in the RV engine. These functions are themselves C++ functions which are then exposed to SQF for allowing interaction with the underlying game engine; Intercept completely bypasses SQF and allows C++ plugins to interact with the engine directly. User created threads can even be created and by properly using the provided thread concurrency functionality it is possible to execute game functionality safely and concurrently. Intercept clients are able to invoke through the host these commands by provided wrapper functions that replicate and emulate the SQF command namespace (minus some unneeded functionality, like arrays or control structures). These wrapper functions take standard inputs, such as simple primitives like float or bool, and standard std::string arguments and convert them into the proper SQF command variables, providing a seamless layer to the clients. An example of a very simple client that invokes nular, unary, and binary SQF functions (aka functions that take no arguments, a right side argument only, and both a left and right side argument respectively) is demonstrated below and a more examples can be found here. #include <Windows.h> #include <stdio.h> #include <cstdint> #include <sstream> // the Intercept library, only one include required. #include "intercept.hpp" // required exported function to return API version int __cdecl intercept::api_version() { return 1; } // This function is exported and is called by the host each frame. void __cdecl intercept::on_frame() { // get the player object and store it intercept::types::object player = intercept::sqf::player(); // get the post of the player intercept::types::vector3 pos = intercept::sqf::get_pos(player); // build a string... std::stringstream side_chat_msg; side_chat_msg << "Hello Arma World, here is the player pos: " << pos.x << "," << pos.y << "," << pos.z; // send it to the binary SQF sideChat command intercept::sqf::side_chat(player, side_chat_msg.str()); } // Normal Windows DLL junk... BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } Completion Status As of now (3/13/16) Intercept is over 82% language feature complete. You can view the progress of wrapper completion here. Almost all normally used SQF functions are available to the end user, and with the added ability of writing inline SQF code, you can call any function that has not had a wrapper written for it yet (though with a small performance penalty). We will post a release thread when we start releasing builds of the host. Contributions Feel free to contribute as much as you want to this project in terms of time and code. The goal of this project is to be a tool for the community to provide better performing and more complex addons for the Arma 3 platform. If you would like to contribute or want more information please join our Slack channels and get involved! License Intercept is licensed under the MIT license. You can find the full license in the LICENSE file. Prior to commit f9fe4d5 the project was licensed under the GNU/GPL v2 license and continues to be for any commit prior to that.- 52 replies
-
- 31
-
─────── Structure ─────── Motivation Introduction Features Benchmarks Installation Usage Final words Changelog Requirements Download Screenshots ─────── Motivation ─────── Hello there, first I want to talk about why I made this - well there is a pretty simple reason. As a developer and as server owner you always need logs. You need logs to write debug messages, you need logs to make statistics for your squad, you need logs to be able to have a look on who did what when. Logs are awesome, and without them it would take much longer to find an error or to find out who shot who first, or how many players were on your server today. Let us have a look on the game log itself, the rpt log. It provides errors, if you have got some, and gives some debug information about startup and shutdown of the game. However since there are some errors in the game that write a nice little message every 1-2 seconds into the log-file, the rpt gets larger and larger ... and now find the one line you need. Imagine, you are a server owner, and you want to keep track on who connected when on your squad server for you and some friends. Why ? Well you like it to stalk other people, or wanted to play NSA simulator 2016. You could log who connected, with which player-ID and so on ... but where do these logs go? Well I always had to log into the rpt file. Often I search for one line which is between 1000 of other lines. That does not only take time, but it might also happen, that you do not find the line, even if you go through everything 10 times. That is where I had the idea, well ... why not create an extension where you decide where logs are placed, in which format, how they are named, if they should have got a time stamp, if this time stamp should be in 12 or 24 hour format etc. I wanted a simple extension where you setup a config, and then just call a function with content, and maybe optional a name which is used for separation. Simple but fast, with options, so that you can get logs from ArmA just the way you want it. I already made a extension called Arma3Log a while ago but I was new into extension writing, and you could have seen that ... it was slow and not very useful... but I wanted to do better and here we are. ─────── Introduction ─────── A3log is a lightweight logging extension for ArmA III, which allows it's users to write customized log-files with a very high performance. It is very easy to use, and does not require and advanced skills for the setup, or the usage. The log-files are adjustable in nearly every way, you could come up with in case of writing log-files. Even when dealing with a high amount of data, the server will not be slowed down and there is no data loss. As it is still in development, there will be improvements to the speed and the amount of features / settings. ─────── Features ─────── Timestamp inside the logfile Timestamp (Date) within the filename Extend the filename with the minute of creation Changeable timestamp format 12/24H clock Custom directory to place the logs (Full-/Relative path) Choose the name of the file Choose the file-extension Define a unlimited amount of custom log categories Separate each log category as one folder Define path and name of the configuration ini ─────── Benchmarks ─────── 1000 lines with 100 characters each: 0.052 seconds - diag_log 0.0159998 seconds - A3log (with all features enabled at v1.1) Extreme example: 100.000 lines with 100 charaters each: 55,895 seconds - diag_log 15,2 seconds - A3log (with all features enabled at v1.1) Note: The test conditions for the benchmarks were reset for every run. The value in seconds is the middle value of 10 test runs. The time indicates how long it took for ArmA to process the input and output of the extension, so how long the server was under heavy load to send the content to the extension. ─────── Installation ─────── Download the latest version (See download section for that) Extract the @A3Log folder and place it in your server directory Go into the @A3Log folder and make sure the the A3Log.dll is not blocked Edit the A3Log.ini file to fit your personal need -> Save the file Edit your startup file and add @A3Log to your -serverMod / -mod parameter Optional: To specify from where the config should be loaded you can define startup a paramter for the arma3server executable with "-A3Log=Configurations/Mylogs.ini" (Only paths in your arma3server directory are allowed so in this case you would have a folder called Configurations inside of your serversetup and in that you have the config file called Mylogs.ini) - This feature is WIP Remove the A3Log_examples.pbo inside @A3Log/addons, once it worked for you and you got example log files Done ─────── Usage ─────── The A3Log.pbo provides you with the A3Log function, which you can call from anywhere. In addiotion to that there is a serverside PublicVariableEventHandler (sendlogfile) to catch incoming log entries, which may be send via publicVariableServer So an example for serverside use would be: ["I am Superman!"] call A3Log; This one has no category defined, so it goes into the catch all log (See A3Log.ini for this) --- ["I am Batman!","ExampleLog"] call A3Log; This one goes into the ExampleLog.log, or what ever you called it. An example for sending a log from a client / headless client would be: sendlogfile = ["I am Batman!","ExampleLog"]; publicVariableServer "sendlogfile"; You might need to whitelist this in the publicvariable.txt from Battleye with !="sendlogfile" --- Or if you prefer remoteExec ["I am Batman!","ExampleLog"] remoteExecCall ["A3Log", 2]; //2 = send to server only and call is much faster Note: You would need to whitelist A3Log as a function that can only be executed on the server. --- So to describe the usage in general: The function A3Log (Serverside) handles the input and sends it to the A3Log extension. <Paramter> call A3Log; --- <Paramter> is an array [], which you can send up to 2 paramters in. [<text>,<category (This second one is optional)>] call A3Log; Attention! - If you want to rewrite the function that sends the log message to the extension, you need to include the information separator byte, which can be used in ArmA like this: <bla bla text> + toString[31] + <your-cool-category> //This all is from variable type string --- You can use this extension as client mod too, just make sure to disable Battleye, as the dll would get blocked by BE otherwise. ─────── Final words ─────── I will provide some additional usage examples and code snippets inside the A3Log_examples.pbo in the future. This is not a drag and drop everything will be logged for every mission you use addon. You still need to invest some time into the configuration and your setup, what you want to log. Since there are many versions of missions, which all differ in their code like an eventhandler for being killed or something, I can not provide code that fits with just a simple copy and paste. How ever I offer everybody to send me a request on these forums or via arkensor@gmail.com so that I can help him with either the setup or write some lines of code from him. I will expand this extension with my own ideas, and requests you guys might have, and it would be great to have some feedback on this. At this point I would like to thank Killzone_Kid, for making a great documentation and tutorials about extensions, which made me start with extension making for arma3. And thanks to my teammate Maurice for helping me with some magic c++ code! If you want to support me and my work, you can send me a donation via paypal. Thank you very much! ─────── Changelog ─────── v1.7: - [Added] x64 support for Windows and Linux . v1.6: - [Added] Optional console output for Windows. - Formating and preparations for a colored debug output Older versions: ─────── Requirements ─────── Windows: C++ Redistributable 2013 32-Bit - Download -> vcredist_x86 (This should be pre installed on all hosting providers) ─────── Download ─────── Download the release from Github: https://github.com/Arkensor/A3LOG/releases/tag/1.8 ─────── Screenshots ─────── This is my folder where I place my logs at serverdir/@A3Log/Logs: Note: Inside the folders are files which were written as the config had folder seperation enabled. License: If you have got any questions feel free to ask. Help me with your feedback to improve this project! Now have fun with it, and enjoy your clean log files 🙂 Regards Arkensor
-
Need help adding a map marker to an already existing addon!
rosb posted a topic in ARMA 3 - ADDONS - CONFIGS & SCRIPTING
Hi. I'm relatively new to modding Arma 3 and using C++, and I would like to know how to add a script to an existing code block. To illustrate this I will provide an example of what I have already done and what I would like to add. What I have already done: class CfgPatches { class insignia_addon { units[] = {}; weapons[] = {}; requiredAddons[] = {}; version = "1.0.0"; author[] = {author}; authorUrl = "url"; }; }; class CfgUnitInsignia { class patch1 { displayName = "name"; author = "author"; texture = "texture"; textureVehicle = ""; }; class patch2 { displayName = "name"; author = "author"; texture = "texture"; textureVehicle = ""; }; class patch3 { displayName = "name"; author = "author"; texture = "texture"; textureVehicle = ""; }; class patch4 { displayName = "name"; author = "author"; texture = "texture"; textureVehicle = ""; }; class patch5 { displayName = "name"; author = "author"; texture = "texture"; textureVehicle = ""; }; class patch6 { displayName = "name"; author = "author"; texture = "texture"; textureVehicle = ""; }; }; What I would like to add is the following code I found on Arma Dev reddit, which is seven years old. I don't know if it works so if someone could tell me if it still does that would be very appreciated. Here it is: class CfgPatches { class Markers { units[] = {}; weapons[] = {}; requiredVersion=1.00; }; }; class CfgMarkers { class flag1 { name="name"; icon="texture"; color[]={1,1,1,1}; size=32; shadow = 0; scope = 2; markerClass = "Flags"; }; class flag2 { name="name"; icon="texture"; color[]={1,1,1,1}; size=32; shadow = 0; scope = 2; markerClass = "Flags"; }; }; I do not know where to go from where I currently am or where to insert the code. I do not know how to make a separate code block in C++ for the flags. If anyone could help me, I would really appreciate it! -
ASCT Server script executing toolset (x32/x64)
mind posted a topic in ARMA 3 - COMMUNITY MADE UTILITIES
General description Arma Server Control Tool can be used to execute SQF scripts on server directly, by using standalone server side application. Idea behind this project is to solve the problem that, in many cases it is hard or straight impossible for server administrator to execute certain scripts on server, also it most likely involves joining server with game client. A lot of times server admins are not able to quickly react to some event on server due to absence of a PC with installed arma nearby. With ASCT all you need to do is to login to your server with remote Desktop or TeamViewer, right click on script.sqf and select ASCT Execute. NOTICE! This application REQUIRE root access to server, you MUST be able to connect to server with remote desktop or TeamViewer. If you have only web access this application is NOT usable. Target audience This tool supposed to be used only on server side. it is made for server admins and developers. Currently this program can be used only on windows platform. Installing 1) Copy paste @asct folder to root of your server alongside with other addons 2) Change your server startup parameters by adding -serverMod="@asct;" 3) Copy paste “asct_console†anywhere you like. At this point you are basically done, you can now use asct.exe as console app. However there are few optional steps to make your life simpler. 4) Optional. If you are running several arma servers on single machine, you should set "instanceID" in order to distinguish arma servers. To do that execute following expression on server init asct_instanceID = “your_idâ€; Select something descriptive as “your_id†but use only a-z,0-9 and _ characters. 5) Optional. When directory for asct.exe selected, run Add_ASCT_to_context_menu.bat, that should be found in same directory. Remember to run it as administrator. This will add “ASCT Execute†option to windows explorer context menu. In case you have several servers on same machine, open Add_ASCT_to_context_menu_instance_yourID.bat file and edit 3rd line. instead of "yourID" type in same instanceID you used in step 4. Save .bat file and execute it as administrator. 6) Optional. For notepad++ users. Copy paste asct.dll from “Notepad++ plugin†folder to “C:\...\Notepad++\plugins\†Use as console application There are several ways to use app. They all have some pros and cons, choose one you like more. For sake of clear examples let`s assume you put asct.exe in C:\asct_console\ folder. As most console apps, this require user to provide parameters. Only one parameter can be used at once. 1) Execute script from file -f <filename> Example: C:\>asct_console\asct.exe -f "C:\my scripts folder\script.sqf" This is simplest method, nothing much to say here, app will read whole file and execute it`s contents. It is also possible to pass only filename, in such case file must be in same folder as asct.exe. This method allow file to have both single line comments // and multiline comments /* */. However, preprocessor directives are NOT allowed (#include, #define, __MACRO__, etc…). SQF files should be encoded as UTF-8. 2) Execute expression -e <expression> Example: C:\>asct_console\asct.exe -e "diag_log \"hello from RPT\";" This method is very straightforward, thus can be useful for only very simple commands. As you can see it require to escape inner quotes and some other technical characters like %, it does not support any comments and must have whole expression in single line. However, it might be useful if you like to use asct in conjuration with some batch, PowerShell, VBS or whatever else scripting methods you like. 3) Execute base64 encoded expression -b <base64code> Example: C:\>asct_console\asct.exe -b ZGlhZ19sb2cgImhlbGxvIGZyb20gUlBUIjs= This one accepts script expression in form of UTF-8 string encoded as base64. What you see in example is basically “literal†representation of bytes of UTF-8 string diag_log "hello from RPT"; This method combine ability to have whole expression in one line, allowing single and multiline comments and accept expression of any complexity. Encode/Decode algorithm borrowed from here http://www.adp-gmbh.ch/cpp/common/base64.html. You can use online services to encode script as base64, google for it. Optionaly, if you have several instances of arma servers, there is also one additional parameter to tell on which server script must be executed. It can be used in conjuration with other parameters. -id <instanceID> Example: C:\>asct_console\asct.exe -f "C:\my scripts folder\script.sqf" -id your_ID You can use this parameter before or after expression parameter. In this way script will be executed on server with given instanceID. NOTE! In windows, applications have limits on length of parameters. At max it is 32768 characters, but command prompt has own limitation of 8191 character. However, there is no limitation for size of script inside SQF file, so first method can be used on very long scripts. Use as notepad++ plugin If you are using Notepad++, you can install asct plugin for it. It will allow you to execute scripts directly from notepad++. After plugin is installed (see Install. step 4) you must specify full path to asct.exe. To do that, on toolbar press Plugins->ASCT->Settings. There you will see input box, write full path to ASCT and press OK. When you have your script ready, press Plugins->ASCT->Execute to run it. Notepad++ allow to have several documents opened at same time, but only content from currently active document, will be read and executed. if you have several instances of arma servers, you should add their instanceIDs to a list in settings menu, once it is done, you will be able to select target server with "Execute at..." pressed. It is also possible to select certain server as default target by selecting instanceID from list and pressing "make default" button, after that, selected instanceID will be used in Execute funciton. By pressing "make default" button with no selected server, instanceID will be "unset". Use as windows explorer context menu You can also execute scripts directly from windows explorer by using right-click context menu. Follow step 5 from installation to get “ASCT Execute†option in context menu. Now navigate to folder with your script.sqf file, right click it and select “ASCT Executeâ€. As with other methods, here you can have direct execution on each of your server instances. Security & Battleye This application does not use any “cheating†methods to do it`s job, no memory reading/writing, no dll injections or anything else like this. All it does is using callExtension command to communicate with asct_ext.dll from which receive and call compile expressions. This application is not meant to be used on client, thus it will be immediately blocked by battleye which is totally intended behavior. On server side, on the other hand, battleye have much less limitations (if any) and allow use any extensions. If you like to use application on client for development/testing feel free to do so with disabled battleye.Similarly, asct.pbo is not signed as it should NEVER be required mod, nor used on clients in actual game. In current implementation, there should be no way for cheaters to exploit application in any way, unless they have root access to server. Web interface Allowing to have asct available in browser on remote PC is something that I am very interested in doing. I realize many server owners have no root access, only some sort of web control panel with limited functionality. It would be amazing to allow use of asct for them as well. However, such a thing would require A LOT of safety considerations, it is direct control of server execution from internet after all. Does not seems to be very SAFE idea. Nonetheless I will consider implementing this as experiment. If you feel like helping me out with ssl and web development, send me a PM. Current version and goals Current version of application is 0.9.0.1. Next version will have bug fixing that hopefully will be found in the course on few next weeks. Once all bugs sorted out there will be final version 1.0. There probably will be no new functionality available in final version. License This application is released under GNU GENERAL PUBLIC LICENSE version 3. If you redistribute this application, please mention author and give link to this forum page. Changelog Download Latest version 0.9.0.1 Google drive (both x32 and x64) Older versions: 0.9.0.0 - Google drive Feel like this tool was usefull for you? You can show your appreciation with small donation, thank you! -
[Intercept] Arma-ofstream - text output to multiple log files
Sparker posted a topic in ARMA 3 - ADDONS - CONFIGS & SCRIPTING
Hi there! This tiny Intercept-based addon adds two SQF commands to output data to files in text mode. You can open a file and write data to it. That's it for now! Usage examples: g_myRpt = ofstream_new "myRpt.rpt"; // Opens a file and returns a handle to it g_myRpt ofstream_write "Some text"; // Write some text to a previously opened file g_myRpt << "Look, I can output text like in C++"; // '<<' is the same as 'ofstream_write' (ofstream_new "myRpt.rpt") ofstream_write "Some text"; // We can also 'open' the file every time we want to write, the addon will handle that fine // You should probably make yourself a macro like this: // Uncomment to switch between output to external file and standard diag_log // #define OFSTREAM_ENABLED #ifdef OFSTREAM_ENABLED #define MY_LOG (ofstream_new "myModule.rpt") ofstream_write #else #define MY_LOG diag_log #endif Download / Installation: Files will be created in <ARMA ROOT>/Logs folder Install to Arma root directory as a typical mod: https://github.com/Sparker95/ARMA-ofstream/releases Also you will need the Intercept host addon, this will do: https://steamcommunity.com/sharedfiles/filedetails/?id=1645973522 And disable Battleye before launching Arma! Source (to prove that It won't mine bitcoins): https://github.com/Sparker95/ARMA-ofstream/blob/master/src/FileInterface.cpp https://github.com/Sparker95/ARMA-ofstream/blob/master/src/FileInterface.h Intercept is an amazing project which lets you interface C++ (and, I think, Python and Lua?) code with the RV engine: It's pretty easy to make a working addon (I did it from this template: https://github.com/intercept/intercept-plugin-template ) and I hope developers will use it more often!