DZR_Mikhail 14 Posted August 11, 2010 If I later will find the way to capture AI's combat modes, and if there's an EventHandler for this - this will be sure added in future. If I could I would add every single eventhandler to replay and reproduce it in playback. In some cases it's a matter of time, and in some cases not everything can be reproduced. Ok, don't panic... Let's get to the stable release and then address our maybe\future plans))) Btw I had a huge progress in Delphi application coding (brought my laptop at work, hope they won't fire me)... WIP report will be in the evening or tomorrow. Share this post Link to post Share on other sites
kremator 1065 Posted August 11, 2010 Sounds like good progress is being made. I also do agree to get a stable version out then it can be tinkered with. Share this post Link to post Share on other sites
DZR_Mikhail 14 Posted August 11, 2010 (edited) All right! Today I made the last step for complete test of AAR. I coded at work and had no Arma2 at hand, but I created two modes for AAR: One is original to playback and record and second is a simulation of a client side like arma2 will do. These client and server just 15 minutes ago managed to successfully exchange all the data, commands and server could read a replay file from hdd and send it to the last bit to the client. The client hungrily accepted all the data. Now the rest of work is to get to the big PC at home, launch arma and see if arma grabs data that successfully as simulation client did. Wish us all luck. Here's a teaser scrreenie. You can see original AAR on the left, and a simulation client on the right (see the checkbox ArmaSimulation and an armasim panel?). This is the end state of transmitting of replay file from server to arma2. The last line of data is [9.386,q_11,[4224.73,3247.1,0.00175858],313.83,'0'] both last on client console and on server console, which means it's in sync and nothing lost. The line consists of [time, unit, position, direction, animation] Thus the line above is about the 9-th second of unit called q_11, which was at some place on Utes, heading north-east 313 and having no changed animation))) Edited August 11, 2010 by zvukoper Share this post Link to post Share on other sites
kremator 1065 Posted August 11, 2010 Nice .... it's getting closer :) Have you an idea about how much information (in KB) that needs to be passed during a large battle (of perhaps 100 entities) and the processor overhead this will add ? GOOD teaser! Can't wait. Share this post Link to post Share on other sites
DZR_Mikhail 14 Posted August 12, 2010 Kremator, at current stage the replay of 10 units will cost >1mb per minute (but it can be still optimized). System resources are taken only to store and read an amount of data not bigger than 1mb too, so this will not consume much RAM. CPU is used at minimum because not very much calculations are made in whole AAR process. The biggest impact will be when the recorded list of data for unit for current time is read and need to be applied immediately. In any case, for recording data there will be an option at which FPS you want to record the replay. The CPU performance will depend on that FPS and on unit count. With 20 units I believe that it's possible to have a smooth playback at high FPS, but if you have 50+ units the FPS must be reduced, because your playback will be too inaccurate and jumpy. But its only theory now, because no actual testing was made. Yesterday I've stumbled across two major difficulties, which I could not predict while using AAR + AAR arma simulation client. AAR WIP REPORT More detailed wall of text about the problems under the spoiler 1) JayArmaLib has very small documentation, I'm not telling about sources and specifications. And when I learned how to create data transfer channels I always used unmodified data length while reading. I mean, if I send it with a length of 50 then I read it serverside 50 as well and all works. I know that in this case there are some unknown to me system units sent with length which are not stripped. But in my simulation it had no effect and if I compare "PLAYBACK MODE" received from pipe with my "PLAYBACK MODE" string on server - they're EQUAL. But JayArmaLib used some other sending options concerning the length. So arma2 sent "PLAYBACK MODE", which I read successfully at server (it showed exactly the same text) but compared to my string of "PLAYBACK MODE" it WASN'T EQUAL! It took me two hours to understand that I need to subtract 1 length unit when reading Arma2 pipe (sent string length - 1) and only after this sent string and my variable ARE EQUAL. Can you believe this?))) Looks like arma2 sent string and an unreadable character or byte at the end, and my plain text wasn't equal of course. Well, a more educated coder would explain this or tell the real reason, but I', over with it. This particular issue is resolved. The sent strings and received can be compared. 2) The second major collapse happened when I tired reading the data from server. In my coding rush I did not realize that server can only send STRINGS of text, and arma can receive only STRING as well. But to setPos to a unit we need ARRAY! Here I so painfully facepalmed myself that I still have an aching nose)) It was midnight when I've found this trap and had no time to solve it. So, at this moment Arma and AAR communicate, exchange data. Arma reads all the data sent from AAR server, BUT... It only receives plain strings, which can be only shown to user in a hint. When I try to use it as an array - it fails and returns "ANY". Now the only obstacle to AAR is the way to convert STRING to ARRAY. I found two methods to do this. First is obvious but amazingly complicated. Using BI script command ToArray seemed to be it, but then I saw description: "The numbers in the created array are the decimal Unicode representations of characters. " So its a complete mess and will consume all recourses on encoding decoding from and to Unicode, also we will need a huge function with all Unicode table preset to be able to turn it to arma-readable string. The other way is to use call compile method. It turns any plain text into arma script code, compiles string as a code. I think this is the salvation, but my few attempts last night showed no result. It just refused to compile array from AAR string. But it doesn't mean it cannot. I just never used this compile commend and I'm sure I just made some mistake. So I need help with turning string to array in arma2. Now the problem itself in practice: So we have a string _ddata = "[9.386,q_11,[4224.73,3247.1,0.00175858],313.83,'0']"; and we need to make it an array something like this call compile "_ddata_array = _ddata;"; That last piece of script is the point I fail with. Without the conversion the AAR won't be able to playback. HALP! :butbut: Share this post Link to post Share on other sites
HeliJunkie 11 Posted August 12, 2010 Now the problem itself in practice: So we have a string _ddata = "[9.386,q_11,[4224.73,3247.1,0.00175858],313.83,'0']"; and we need to make it an array something like this call compile "_ddata_array = _ddata;"; That last piece of script is the point I fail with. Without the conversion the AAR won't be able to playback. HALP! :butbut: Think the q_11 may be the failing point. It's starting with a letter, but isn't in quotes. Try to set it in quotes like this: _ddata = "[9.386,[color=Red]'q_11'[/color],[4224.73,3247.1,0.00175858],313.83,'0']"; What is the error message, if there is one? Is there a message in the RPT-File related to this command ? Share this post Link to post Share on other sites
DZR_Mikhail 14 Posted August 12, 2010 No, q_11 is a variable. It's a unit's name. It must be without quotes. If I create such array explicitly like _ddata = [color="Red"][[/color]9.386,q_11,[4224.73,3247.1,0.00175858],313.83,'0'[color="Red"]][/color]; WITHOUT the quotes then everything works perfect! But I receive string, not array. Need to compile this string to be an array somehow. Share this post Link to post Share on other sites
HeliJunkie 11 Posted August 12, 2010 If it is a Variable... what's the content ? A String? A Unit(-Object) ? If you "compile" this string, the variable value is taken instead of the variable name itself! So, i think there is your problem! What do you want to store or restore ? If the content is a Unit's name, maybe something like this will work: _ddata = "[9.386,[color=Red]'[/color]" [color=Red]+ str (q_11) +[/color] "[color=Red]'[/color],[4224.73,3247.1,0.00175858],313.83,'0']"; Be careful with single and double quotes ! Share this post Link to post Share on other sites
DZR_Mikhail 14 Posted August 12, 2010 (edited) Sorry, I think I didn't clarify correctly how the things work... Well, I'll explain in short so you don't need to read entire thread. I created an application on Delphi which uses Win API to communicate with Arma through JayArmaLib. 1) I tell arma to send unit's [uNIT VARIABLE, getPos UNIT, getDir UNIT] etc every millisecond in AN ARRAY to my Delphi application using a named pipe method. 2) My Delphi app reads all the data and saves every ARRAY to a local text file, every array as a line of text. 3) Then I need to playback this recording, and my Delphi app reads this local text file line by line and sends every line to Arma through the same way as recorded. 4) Every new line is SENT AS STRING, irrespective that arma sent ARRAY, because they are TWO different virtual universes with own set of variables and data formats))) And JayArmLib gives the only possible way of communication and data transfer - PLAIN TEXT When I load the recorded local file contents MANUALLY inside my script like _huge_array = [color="Blue"]<copy pasted contents of a file in ARMA array format>[/color] Then it all works. Because arma reads my q_11 as its variable and finds a unit called q_11 and applies all the rest of the data respectively, q_11 setPos [array of pos], setDir [array of dir] etc. But Delphi app sends string that I can only able to show as a hint. It is shown like [q_11, [3424.23423],4324,0] Without problems, But its a string. And I need to address its contents as if it's an array. So I need to compile the string to ARMA array. Hope you get my point))) ---------- Post added at 09:42 AM ---------- Previous post was at 09:28 AM ---------- I think it's time to give complete code... [b]player sidechat [/b][color="DarkRed"]"Let's try PLAYBACKING!"[/color]; [color="Blue"]_delphiPipe[/color] = ["\\.\pipe\delphiPipe"] [b]call[/b] jayarma2lib_fnc_openPipe; [color="Blue"]_armaPipe[/color] = ["\\.\pipe\armaPipe"] [b]call[/b] jayarma2lib_fnc_openPipe; [b]player sidechat[/b] [color="DarkRed"]"Trying to open pipes"[/color]; [b]if[/b](isNil("_delphiPipe")) [b]then[/b] { player sidechat "NO AAR PIPE!!"; }; [b]if[/b](isNil([color="DarkRed"]"_armaPipe"[/color])) [b]then[/b] { [b]player sidechat[/b] "NO CLIENT PIPE!!"; }; [[color="Blue"]_armaPipe[/color], [color="DarkRed"]"READY PLAYBACK"[/color]] [b]call[/b] jayarma2lib_fnc_writePipe; [color="Blue"]_timer[/color] = [b][] execVM[/b] "timer.sqf"; [b]player sidechat[/b] [color="DarkRed"]"while start"[/color]; [color="Blue"]Playback[/color] = true; [color="Blue"]_i [/color]= 0; [color="Blue"]_p[/color] = [color="DarkRed"]"."[/color]; [color="Blue"]_xdata[/color] = []; [b]while[/b] {true} [b]do[/b] { [color="Blue"]_ddata[/color] = [_delphiPipe] call jayarma2lib_fnc_readPipe; [b]player sidechat[/b] format[[color="DarkRed"]"READING: %1"[/color], [color="Blue"]_ddata[/color]]; [i][color="DarkGreen"]// here it shows a hint correctly![/color][/i] if(!isNil([color="DarkRed"]"_ddata"[/color])) then { [color="Blue"]_p[/color] = [color="DarkRed"]"R"[/color]; [color="Blue"]_cdata[/color] = [color="DarkRed"]"_xdata = ""_ddata"";"[/color]; // now I try compiling the string [b]call compile[/b] [color="Blue"]_cdata[/color]; [i][color="DarkGreen"]// here is final compile AND HERE no errors... just nothing happens, and array is inaccessible[/color][/i] [b]waitUntil[/b] {[color="Blue"]vrema[/color] >= [color="Blue"]_xdata[/color] select 0}; [color="Blue"]_anim[/color] = format[[color="DarkRed"]"%1"[/color], [color="Blue"]_xdata[/color] select 4]; [b]if[/b] ([color="Blue"]_anim[/color] != "0") [b]then[/b] {([color="Blue"]_xdata[/color] select 1) [b]playMoveNow[/b] [color="Blue"]_anim[/color];}; hint format["%1",[color="Blue"]vrema[/color]]; ([color="Blue"]_xdata[/color] select 1) [b]setPos[/b] [([color="Blue"]_xdata[/color] select 2) select 0,(_xdata select 2) select 1,([color="Blue"]_xdata[/color] select 2) select 2]; ([color="Blue"]_xdata[/color] select 1) [b]setDir[/b] ([color="Blue"]_xdata[/color] select 3); }; [b]if[/b] ([color="Blue"]Cstop[/color]) [b]exitWith[/b] {[[color="Blue"]_armaPipe[/color], [color="DarkRed"]"STOP"[/color]] call jayarma2lib_fnc_writePipe; [color="Blue"]Playback[/color] = false;}; [b]sleep[/b] 3; [color="Blue"]_i[/color] = [color="Blue"]_i[/color] + 1; [b]hint[/b] format[[color="DarkRed"]"%2: %1"[/color],[color="Blue"]_i[/color],[color="Blue"]_p[/color]]; }; [b]player sidechat[/b] [color="DarkRed"]"done"[/color]; [b]hint[/b] [color="DarkRed"]"END"[/color]; [[color="Blue"]_armaPipe[/color]] [b]call[/b] jayarma2lib_fnc_closePipe; [[color="Blue"]_delphiPipe[/color]] [b]call[/b] jayarma2lib_fnc_closePipe; Edited August 12, 2010 by zvukoper Share this post Link to post Share on other sites
HeliJunkie 11 Posted August 12, 2010 (edited) Arma can only store: - numeric values - strings in an array. So you can only parse the variable as a string. Safe the line with the variable name as string: Write the line to the text file as: "[9.386,'" + getVehicleVarName(q_11) + "',[4224.73,3247.1,0.00175858],313.83,'0']"; so the text line in your file should look like this: [9.386,'q_11',[4224.73,3247.1,0.00175858],313.83,'0'] After you load the text line parse it like: call compile format["_ddata_array = %1;",_ddata]; And not(!) [color=Magenta]call compile "_ddata_array = ""_ddata"";";[/color] Now you have (something like): _ddata_array select 1 = "q_11" But you can't do anything with it, because it is a string, and not a variable... so you have to build the command as string and compile it, so it will be used as variable: call compile format["%1 setPos %2;"_ddata_array_select 1, _ddata_array select 2]; will extend to: call compile "q_11 setPos [4224.73,3247.1,0.00175858];"; Hope that helps you to advance your project. Uploaded modified code to pastebin. You should use it too, if you have problems with larger script examples: http://pastebin.com/uyHWVw9K Edited August 12, 2010 by HeliJunkie Added link to Pastebin for modified code Share this post Link to post Share on other sites
DZR_Mikhail 14 Posted August 12, 2010 Thank you very much! I think you suggested the right example of compiling. I will try it in the evening. Share this post Link to post Share on other sites
kremator 1065 Posted August 12, 2010 Sweet bit of helping there. Pity it's beyond my capabilities to understand. Good to see things progressing. Share this post Link to post Share on other sites
HeliJunkie 11 Posted August 12, 2010 Did you try it zvukoper? Share this post Link to post Share on other sites
DZR_Mikhail 14 Posted August 13, 2010 This worked _ddata_array = call compile format["%1;",_ddata]; THank you all. Made some tests today. There's a lag in playbcak, but it's not progressing like without channels. Tested 10 and 30 units. ALmost the same. 50 getting harder. Also made nice system of animation playback. Looks very nice. Units are not sliding like card borad targets in shooting range, they actually RUN and go prone, sit, die etc. All the animation preserved. So, now I'll compile whole system to some usable condition and also want to add the firin EH and the demo is ready to release. Need more time. Share this post Link to post Share on other sites
kremator 1065 Posted August 13, 2010 WOOT ! If you need a beta tester you know where I am :) Share this post Link to post Share on other sites
wallyschmo 10 Posted August 14, 2010 This will be a great utility if you can get it all worked out. Much like the Battle Recorder in Battlefield 2 Share this post Link to post Share on other sites
DZR_Mikhail 14 Posted August 16, 2010 Just to sum up and extend my brief posts above. Good news All the conversions worked. Some minor lag in playback is still present, but it's not that dreadful and it's not progressing in time. Actually I believe it's a matter of tuning the script and refreshing intervals\fps. I tested recording and playback on 10, 30 and 50 units. At that state of development 50 units is the limit. It gets too laggy for smooth performance, but still can be helpful. Animations aliiive! I also got a bright idea for replaying animations (mentioned in previous reports briefly)! So I decided to record animation every iteration with AnimationState command, and later PlayMoveNow it while playbacking. But this would give massive jumpiness on animation changes and looked messy. So I decided to optimize this part by adding a condition which compares the current and the recorded animations. If they equal - animation is not applied and skipped, letting the previous to finish without jumps and jitter. If current animation differs from the recorded - then the recorded animation is applied. That's the best idea I've had in scripting))) But when I did this I wasn't sure at all that it can be so good))))) Now with the new optimization animations are played almost perfect! Units now run, walk, go crouching and prone, even salute and DIE and all that jazz. Even without firing\killing EH it now looks natural when units shoot each other. Because AI shoots right the same moment each time when he is faced against the enemy by replay, and the AI falls dead (plays death animation) and never moves (as recorded). So animation part is solved I think. Still unsolved THe only thing that bothers me is the lag. It makes some of the units "flicker" between two different locations for some 1-2 seconds. Looks like for some reason a random unit's position is different for some 5-15 meters every odd (?) frame. It doesn't look as it's not his data applied, but looks like a miscalculation of getPos occurred, or some other issue I can't guess. May be it has to do with unoptimized recording, playback fps. So this is the main issue now - find the best recording and playbacking interval (a framerate). Now the bad news. On the weekend I tried to compile the app and rewrite script so it become more usable for demo, but I failed. Just had not enough time to plan all the rewritings (wife and kid got sick) and ruined all the code, all stopped working and I got lost in my own code))). Of course I have backup and I will sure try again. That's all about my low skills in Delphi and arma scripting. While developing it all went linear though now very good looking and user friendly. And when I tried to recompose the modules and reassign the buttons I misplaced some functions, and some cycles stopped working. And when there's no time to even analyze what's wrong... So I think it's better to start over again later with fresh and clear mind... And the worst The other trouble is my video card malfunctioning (after my son pushed reset or power for some 20 times in a row while I was in the kitchen). The PC (ASUS P5B motherboard) beeps 1 long and 3 short on cold start and then every game is lagging badly and sound is stuttering. So until I solve this problem I will not be able to test scripts for performance in Arma2, but still can work on the app... And because of all the above "adventures" I can't make a satisfactory demo and demo video... Hope I can at least fix my video card or get the new one (also hope it JUST a video card!)... Share this post Link to post Share on other sites
HeliJunkie 11 Posted August 16, 2010 Some really good news, but also some bad. Especially the beeps... This is not a hardware support forum, but for you.... :D I looked in the Manual.. and it says: One continuous beep followed by three beeps: No VGA detected Downloadlink for ASUS P5B Manuals. Share this post Link to post Share on other sites
DZR_Mikhail 14 Posted August 16, 2010 (edited) Thank you HeliJunkie. A little hardware offtopic I think will not spoil everything)) I forgot to say that it beeps, the screen is black, but then it beeps one beep after some 3-4 seconds and all is working, except all the graphics in games a re laggy and sounds stutter. Nothing beeps (one beep only signalling ALL'S OK) when I restart PC or press reset. It only beeps after I switch ON the pc after full power off. So to say beeps happen on cold power ON. Still sad to admit, my Zotac GeForce 8600 GTS dies. Farewell good friend... With my salary it will take two month to buy the new card... Edited August 16, 2010 by zvukoper Share this post Link to post Share on other sites
kremator 1065 Posted August 16, 2010 OMG that is terrible news on the HW front mate ! Don't worry about delaying a demo/proof of princple. What you have so far sounds wonderful .... a REAL step forward - BRAVO ! We all know how RL interferes with stuff. Have you tried removing the video card and reseating it ? Share this post Link to post Share on other sites
DZR_Mikhail 14 Posted August 16, 2010 Kremator, the moment I heard the beeps and decoded them, I opened my PC, pulled off every single slot I could, vacuum cleaned everything, assembled back without all my additional cards like TVtuner, spare LAN adapter etc. No change, still beeps on cold start. Now planning to bring the video card to some friend and test it. Some people say that such problems and beeps happened when motherboard burnt... Ah, unlucky me) Share this post Link to post Share on other sites
kremator 1065 Posted August 16, 2010 Oh dear ! No pocketmoney for your son for AGES then .... until he pays it off ! Share this post Link to post Share on other sites
Jack 0 Posted August 16, 2010 Would be cool if this was an Open Source project, people with delphi skills could help you create this much faster and more efficiently. Best of luck zvukoper. Share this post Link to post Share on other sites
DZR_Mikhail 14 Posted August 16, 2010 Thanks Jack This project will not be proprietary))) I'll just handle, so to say, the original AAR brand... I will share all the sources etc. at dev-heaven for public, but first I must finish the very basic functionality, test it and confirm that it is possible at all, working and etc. Right after I publish the demo I will throw everything at dev-hev and hope things will spin faster) Share this post Link to post Share on other sites