Jump to content


  • Content Count

  • Joined

  • Last visited

  • Medals

Posts posted by riouken

  1. This should work:

    _gamelogic = CENTER;
    _towns = nearestLocations [getPosATL _gamelogic, ["NameVillage","NameCity","NameCityCapital"], 25000];
    _RandomTownPosition = position (_towns select (floor (random (count _towns))));
       _pos = position _x;
       _m = createMarker [format ["mrk%1",random 100000],_pos];
       _m setMarkerShape "ELLIPSE";
       _m setMarkerSize [500,500];
       _m setMarkerBrush "Solid";
       _m setMarkerAlpha 0.5;
       _m setMarkerColor "ColorRed";
    } forEach _towns;

  2. You have to provide at-least 2 positions in an array.

    I would try creating a function that tracks the players pos every second for say 5 -10 seconds and stores it in an array, then execute that function. rinse and repeat, in theory it should follow you around like a puppy dog. Let me see if I can write something up real quick.

    ---------- Post added at 07:20 PM ---------- Previous post was at 07:01 PM ----------

    This is not tested but I hope this helps.

    _target = _this select 0;
    _path = [];
    while {alive _target} do 
    _seedtime = time + 10;
    While {time < _seedtime} do
    		_newpos = getposATL _target;
    		_path set [count _path,_newpos];	
    		sleep 1;
    _nul = [_atv1,_path] spawn BIS_animateMoveSmooth;
    sleep .01;
    _path = [];

  3. You might find this useful, I discovered this little gem in the game files, it is hardly documented anywhere, but BIS used it animate targets and such. (This was written by a BIS dev as far as I know)

    I made a quick demo a long time ago as a proof of concept, please ignore the sound and this was just a test.

    Here is the function:


    BIS_animateMoveSmooth =
       _sleep = 0.01;                    //delay between each anim frame, lower values = smoother animation
       _object = _this select 0;
       _wps = _this select 1;            //array of all animation WPs
       //hover height
       if (count _this > 4) then {
           _hoverHeight = _this select 4;
       //positioning & animating along waypoints ------------------------------------------------------
       _positions = [];        //array of all WP positions
       _distancesStart = [];    //array of WPs distances from the beginning of the animation
       _distancesPrev = [];    //array of WPs distances from the previous WP
       _refWP = _wps select 0;
       _d = 0;
       _dTotal = 0;
           //storing position of each WP
           //it's WP object
           if (typeName(_x) == "OBJECT") then {
               _tmpPos = getPosASL _x;
               if (_x == player) then {
                   _tmpPos = [_tmpPos select 0, _tmpPos select 1, (_tmpPos select 2) + 0.8]; 
           //it's position            
           } else {
               _tmpPos = _x;
           _positions = _positions + [_tmpPos];
           //total from the start
           _d = _x distance _refWP;
           _dTotal = _dTotal + _d;
           _distancesStart = _distancesStart + [_dTotal];
           //from previous WP
           _distancesPrev = _distancesPrev + [_x distance _refWP];
           _refWP = _x;        
       } forEach _wps;
       //current WPs
       _wpStart = 0;
       _wpEnd = _wpStart + 1;
       //count positions
       _posStart = _positions select _wpStart;
       _posEnd = _positions select _wpEnd;    
       //count delta x,y,z
       _deltax = (_posEnd select 0) - (_posStart select 0);
       _deltay = (_posEnd select 1) - (_posStart select 1);
       _deltaz = (_posEnd select 2) - (_posStart select 2);    
       _dir =  [_posStart,_posEnd] call BIS_fnc_dirTo;
       _object setDir (_dir-180);    
       //display object at start position
       if isNil("_hoverHeight") then {
           _object setPosASL (_positions select 0);
       } else {
           _object setPos [(_positions select 0) select 0, (_positions select 0) select 1,_hoverHeight];
       if (count(_this) > 2) then {
           _vmax = _this select 2;
       } else {
           _vmax = 15;
       if (count(_this) > 3) then {
           _a = _this select 3;
       } else {
           _a = 5;
       //acceleration path
       _taccel = _vmax/_a;
       _saccel = 1/2 * _a * _taccel * _taccel;
       //distance (of whole animation)
       _distance = _distancesStart select (count(_distancesStart) - 1);
       //["_distance",_distance] call BIS_debugLog;
       //distance too short
       if (2*_saccel > _distance) then {
           //["DISTANCE IS TOO SHORT"] call BIS_debugLog;
           //["_saccel (raw)",_saccel] call BIS_debugLog;
           //["_taccel (raw)",_taccel] call BIS_debugLog;        
           _saccel = _distance/2;
           _taccel = sqrt(_distance/_a);
           //["_saccel (fixed)",_saccel] call BIS_debugLog;
           //["_taccel (fixed)",_taccel] call BIS_debugLog;        
           //distance is too short -> object wont reach max speed
           _vmax = _a * _taccel;
           //there is no constant speed part in middle
           _sconst = 0;
           _tconst = 0;
       //distance is fine
       } else {
           //["DISTANCE IS FINE"] call BIS_debugLog;
           _sconst = _distance - 2*_saccel;
           _tconst = _sconst/_vmax;
       //total time
       _ttotal = 2*_taccel + _tconst;
       _t = 0;
       _tmax = _taccel;
       _ssaved = 0;
       _animList = [];
       _animPhase = 0;
       _animList = _animList + [{1/2 * _a * _t * _t}];
       _animList = _animList + [{_vmax * _t}];
       _animList = _animList + [{_vmax * _t - 1/2 * _a * _t * _t}];    
       _time = time;
       _tover = 0;
       while {_animPhase < count(_animList)} do {
           _t = _t + _sleep;
           _sleepTime = time;
           sleep _sleep;
           //real sleep time calculations
           _sleepTime = time - _sleepTime;
           _t = _t - _sleep + _sleepTime;
           if (_t > _tmax) then {
               _tover = _t - _tmax;
               _t = _tmax;
           _anim = _animList select _animPhase;
           _s = call _anim;
           //positioning & animating along waypoints --------------------------------------------------
           _movedFromStart = _ssaved + _s;
           //searching for acctual _wpStart & _wpEnd
           while {_movedFromStart > _distancesStart select _wpEnd} do {
               _wpStart = _wpStart + 1;
               _wpEnd = _wpStart + 1;
               //["Current waypoints:",format["%1 -> %2",_wpStart,_wpEnd]] call BIS_debugLog;
               //count positions
               _posStart = _positions select _wpStart;
               _posEnd = _positions select _wpEnd;    
               //count delta x,y,z
               _deltax = (_posEnd select 0) - (_posStart select 0);
               _deltay = (_posEnd select 1) - (_posStart select 1);
               _deltaz = (_posEnd select 2) - (_posStart select 2);
               //set direction
               _dir =  [_posStart,_posEnd] call BIS_fnc_dirTo;
               _object setDir (_dir-180);            
           //progress part -> object positioning
           _movedBetweenWPs = _movedFromStart - (_distancesStart select _wpStart);
           _progress = _movedBetweenWPs / (_distancesPrev select _wpEnd);
           if (_progress > 1) then {
               _progress = 1;
           _posx = (_posStart select 0) + _deltax * _progress;
           _posy = (_posStart select 1) + _deltay * _progress;
           _posz = (_posStart select 2) + _deltaz * _progress;
           if isNil("_hoverHeight") then {
               _object setPosASL[_posx,_posy,_posz];
           } else {
               _object setPos[_posx,_posy,_hoverHeight];
           //["_movedFromStart",_movedFromStart] call BIS_debugLog;
           //["_movedBetweenWPs",_movedBetweenWPs] call BIS_debugLog;
           //["_progress",_progress] call BIS_debugLog;
           //["_posx",_posx] call BIS_debugLog;
           //create a ghost-ball
           _ghostBall = "sign_sphere25cm_ep1" createVehicle [0,0,0];
           _ghostBall setObjectTexture [0,"#(argb,8,8,3)color(0.8,0.5,0.5,0.5,ca)"];
           _ghostBall setPosASL[_posx,_posy,_posz];
           if (_t == _tmax) then {
               _animPhase = _animPhase + 1;
               //[format["Animation ID%1 finished at distance %2 (took %3 secs)!",_animPhase-1,_ssaved + _s,_tmax]] call BIS_debugLog;
               //skip the middle part (animationPhase 1) if its time == 0
               if (_animPhase == 1 && _tconst == 0) then {
                   _animPhase = _animPhase + 1;
                   //["Animation ID1 skipped!"] call BIS_debugLog;
               if (_animPhase == 1) then {
                   _tmax = _tconst;
               } else {
                   _tmax = _taccel;
               //_t = 0;
               _t = _tover;
               _ssaved = _ssaved + _s;
       _pos = _positions select (count(_positions) - 1);
       if isNil("_hoverHeight") then {
           _object setPosASL _pos;
       } else {
           _object setPos [_pos select 0, _pos select 1, _hoverHeight];
    //_sqf = this spawn {_i=0;while {true} do {_i=_i+2;if(_i>360)then{_i=_i-360;};_this setDir _i;sleep 0.01;};};
    BIS_animateRotate =
       _object = _this select 0;
       _dir = getDir(_object);
       _i = _dir;
       while {true} do {
           _i = _i + 2;
           if (_i > 360) then {_i = _i-360;};
           _object setDir _i;
           sleep 0.02;
    BIS_animateUpDown  =
       _sleep = 0.02;    //delay between each anim frame, lower values = smoother animation
       _object = _this select 0;
       _smax = _this select 1;            //animation length [m]
       _tmax = _this select 2;            //animation time [sec]
       _a = 2*_smax/(_tmax*_tmax);        //_acceleration
       _vmax = _a * _tmax;                //animation speed [m/sec]
       _t = 0;
       _pos = getPosASL(_object);
       _startPos = _pos;
       _animList = [];
       _animPhase = 0;
       //move-up and decelerate
       _animList = _animList + [{+1 * (_vmax * _t - 1/2 * _a * _t * _t)}];
       //move-down and accelerate
       _animList = _animList + [{-1 * (1/2 * _a * _t * _t)}];
       //move-down and decelerate
       _animList = _animList + [{-1 * (_vmax * _t - 1/2 * _a * _t * _t)}];    
       //move-up and accelerate
       _animList = _animList + [{+1 * (1/2 * _a * _t * _t)}];
       while {true} do {
           _t = _t + _sleep;
           if (_t > _tmax) then {
               _t = _tmax;
           sleep _sleep;
           _anim = _animList select _animPhase;
           _s = call _anim;
           _object setPosASL[_pos select 0,_pos select 1,(_pos select 2) + _s];
           if (_t == _tmax) then {
               _animPhase = _animPhase + 1;
               _t = 0;
               if (_animPhase == count(_animList)) then {
                   _animPhase = 0;
               _pos = [_pos select 0,_pos select 1,(_pos select 2) + _s];
       //reposition bact to start pos
       _object setPosASL _startPos;

    Compile it like this:

    BIS_animateMoveSmooth = compile preprocessFile "functions_animations.sqf";

    You call it by passing the object to be moved or animated and then providing a list of postions or objects that you want it to path over.


    _nul = [_objectthatsmoving, [[x,y,z], [x,y,z] , [x,y,z], [x,y,z]]] spawn BIS_animateMoveSmooth;

  4. SOM was never written or intended for dedi or multiplier. I think there have been a few improvements along the way to help with MP compatibility, but in my opinion the amount of work involved for the little bit you get with SOM, its not worth it to try and make it work in your MP mission.

    There are several well written missions with random elements to missions or totally random missions.

    MSO as Tupolov already mentioned.

    Domination by xeno

    I think TFOR has some random missions as well.

    Also there is a chopper transport mission, I think its called workhorse or something. I wish I could remember what the exact name and author was.

    Your not going to find any simple scripts that does this, its a big task with lots of scripts to get this type of system into a mission and working for MP and Jip. Thats why you only see custom scripts that are tailored to a specific mission.

  5. rMsgBox

    rMsgBox is a easy and user configurable GUI. I wanted to provide an easy to use message box similar in design and function to the Messagebox in C#. I wanted to handle all the UI scripting while the user focused on passing in their own data to my scripts. rMsgBox can be used as user notification, choice selection, conformation and many other uses.

    Features -

    * All GUI scripting is done - user only has to pass strings and arrays to my setup script.

    * Can be called directly from and addaction or a direct call to the script.

    * The message body can use a string or Structured text.

    * Has 6 elements that the user can configure on the fly.

    * Message

    * Title

    * 4 Buttons

    * Can change button text and button actions.

    * Light weight.

    * Easy to use.


    - Right now the size of the message box does not scale with the contents, so you will have to ensure your text and data does not go out of bounds on the gui. I am working on this and hopefully will be able to solve it.

    How to use rMsgBox in your mission.

    Put the rMsgBox folder in your main mission folder.

    Place this line of code in your descripton.ext


    #include <rmsgbox\rmsg_gui.hpp>[size=2][size=2]

    Thats it. Now you can call rMsgBox in your mission.

    How to pass Parameters to rMsgBox-

    You need to pass the parameters to this file - "rmsgbox\rmsg_gui_setup.sqf"

    They need to be passed as an array.

    Only the first param is required the rest are optional.

    Message,                  -Can use a String or Structured Text
    Title,                        -String
    ["Button 1","Command"],        -Array format, pass two strings - the first is the button text, the second is the command when button is pressed.
    ["Button 2","Command"],        -Array format, pass two strings - the first is the button text, the second is the command when button is pressed.
    ["Button 3","Command"],        -Array format, pass two strings - the first is the button text, the second is the command when button is pressed.
    ["Button 4","Command"]         -Array format, pass two strings - the first is the button text, the second is the command when button is pressed.

    Here is an example:

    _CallrMsgBox = ["My Message","My Title",["Button 1","closeDialog 0;hint 'Button 1'"],["Button 2","hint 'Button 2';"],["Button 3","hint 'Button 3';"],["Button 4","hint 'Button 4';"]] execVM "rmsgbox\rmsg_gui_setup.sqf";
    //if you do not want one of the options, just pass it an empty string, example:
    // This wil leave out the Title and button two.
    _CallrMsgBox = ["My Message","",["Button 1","closeDialog 0;hint 'Button 1'"],["",""],["Button 3","hint 'Button 3';"],["Button 4","hint 'Button 4';"]] execVM "rmsgbox\rmsg_gui_setup.sqf";

    Helpful links:



    Please see the included readme.txt for more information.


    Example mission including the rMsgBox scripts and several examples.

    http://arma2.co/download?file=63541-rMsgBox.utes.zip - Arma2.co


    Just the rMsgBox scripts.

    http://arma2.co/download?file=45095-rmsgbox.zip - Arma2.co









  6. Okay. But, where do I paste it?

    You would do it in a script. Usually people use the onLoad feature to load a scirpt when ever the dialog is called.

    class WF_main_dlg {
    idd = 1775;
    movingEnable = true;
    [color=#ff0000]onLoad = "// The code in here will be called every time your ui element is loaded or created. ";[/color]
    objects[] = {};
    class controlsBackground {

    But if you are using this as a hud of sorts, In the same script you call the ui element right after you create the ui element I would spawn another thread and have your loop in there. Since you will never close the ui element since its a hud.

  7. When you create your ui element, you use a command

    Either createDialog for a dialog or

    CutRsc for a resource.

    A dialog stops the users interface(control) of the game, like the map.

    A resource is just an overlay, and can not be interacted with by the player, like the compass.

    Before you call either one of those, the. Ui element does no exist, its just defined in the description.ext so you can't interact by scripting commands with it untill you create it for the user.

  8. The code deadfast posted should be ran after you create your dialog or cutrsc.

    If your using this like a hud, then you could put this in a loop and have it update the hud every second or two.

    ---------- Post added at 02:40 PM ---------- Previous post was at 02:37 PM ----------

    Also you should take off those AS_PLO prefix tags, you should come up with and use your own prefix. Otherwise you will have compatibility problems if you try and use another gui with those same prefix's on the base classes.

  9. No the only tutorial that I knew of has been taken down on ofpec. Unforntinaty there are not that many people that can write gui's well so there are not that many tutorials. It is probably one of the harder things to do. You just have to go out and dig into them and look at examples and then code it yourself to learn. If you get stuck on something feel free to post the spacific question here and we will be glad to help.

    Here are some important links to get you started.

    First the wiki with examples:


    Gui related commands:


    GUI Editor - Once you know how the basic config set up works and can get one in game working this will help alot with designing and getting a new gui off the ground but it will not do all the work for you.



    Once you get a feel for the basics here are some great examples to learn from: (I would not recommend this till you get your head around it first, cause it can be pretty overwhelming at first.)


    Anything from Dr EyeBall is good stuff.

    Here is a demo mission with just a simple GUI that I did for the Arma2MySQL example mission. It wont do anything with out the Database but you can see how I set it up. and the basics on how to get one into a mission. That's all that's in it is the gui.



  10. Is there anyway of getting this to work with vehicles that spawn in the map randomly? I am using a script that spawns in the vehicles in random towns/cities so I am unable to add anything into their init line as they don't exist in the editor.

    Yes, you just have to pass the information to the script, it doesn't care about where the info comes from.

    So in your veh spawn script, after you create a veh just pass the reference of that veh and the desired perams and execVM the script.

    ---------- Post added at 09:50 AM ---------- Previous post was at 09:46 AM ----------

    _veh = createVehicle ["ah1w", position player, [], 0, "NONE"];[color=#000000][font=Lucida Console]
    _null = [[color=#000000][font=Lucida Console]_veh[/font][/color], 15, 10, 5, TRUE, FALSE] execVM "vehicle.sqf";