Jump to content

Andy455

Member
  • Content Count

    196
  • Joined

  • Last visited

  • Medals

Posts posted by Andy455


  1. Here is an example from one of my dialogs:

    class TOUR_DMC_MENU_CREATEUNIT
    {	
    idd = 897898;
    movingEnable = true;
    onLoad = "TOUR_DMC_createUnitMenuActive = true; [] spawn TOUR_DMC_fnc_createUnitOnLoad;";
    onUnload = "TOUR_DMC_createUnitMenuActive = false; [] spawn TOUR_DMC_fnc_createUnitCancel";
    
    class controlsBackground
    {
    	class TOUR_DMC_CREATEUNIT_BACKGROUND : RscBackground 
    	{
    		idc = 0;
    		colorBackground[] = TOUR_DMC_COLOR_BACKGROUND;
    		x = "safeZoneX + (safeZoneW / 5)";
    		y = "safeZoneY + (safeZoneH / 7)";
    		w = "safeZoneW / 2";
    		h = "safeZoneH / 1.5";
    		moving = true;
    	};
    };
    
    class objects 
    {
    
    };
    
    class controls 
    {
    	class TOUR_DMC_CREATEUNIT_SIDECOMBO : RscCombo
    	{
    		idc = 1;
    		x = "safeZoneX + (safeZoneW / 4.5)";
    		y = "safeZoneY + (safeZoneH / 4.5)";
    		w = "safeZoneW / 5";
    		h = "safeZoneH / 40";
    		sizeEx = 0.025;
    		size = 0.025;
    		onLBSelChanged  = "[] call TOUR_DMC_fnc_fillFactionCombo";
    	};
    };
    };
    

    As you can see the controls are created inside of the display (the first class bit), this also means the controls can be moved around by clicking and dragging the background with them. As for the problem with the button, have you got an RscButton class defined in your description.ext? This is because it isnt loaded as a resource by default, you have to manually create it in a mission and load it before you can inherit from that class.

    Hope that helped at least a little bit, even if it was just example code :P


  2. You could maybe set its condition of presence to something like:

    (paramsArray select [color="Red"]0[/color] == 1)
    

    And in the description.ext you could have

    // Other params up here
    class AmbCivil
    {
       title = "Ambient Civilains";
       values[] = {1,0};
       texts[] = {"On","Off"};
       default = 1;
    };
    

    Just remember to change the condition of presence to point to the correct element in the params array (WILL ONLY WORK IN MP)


  3. _helo = "MH60S";
    
    //Create the Helo
    _grp = createGroup WEST;
    _helo createUnit [getMarkerPos "heloStart", _grp, "this engineOn true; this flyInHeight 30; helo1 = this", 1];
    
    //Give the helo waypoints
    
    _waypoint1 = (group helo1) addWaypoint [getMarkerPos "LZ1", 0];
    _waypoint1 setWaypointType "MOVE";
    
    helo1 land "GET IN";
    
    // Waituntil all alive units in players group are in the chopper
    waitUntil { {_x in helo1 && alive _x} count units group player >= {alive _x} count units group player };
    
    deleteWaypoint [(group helo1),1];
    
    _waypoint2 = (group helo1) addWaypoint [getMarkerPos "wp2", 0];
    _waypoint2 setWaypointType "MOVE";
    
    _waypoint3 = (group helo1) addWaypoint [getMarkerPos "wp3", 0];
    _waypoint3 setWaypointType "MOVE";
    
    _waypoint4 = (group helo1) addWaypoint [getMarkerPos "wp4", 0];
    _waypoint4 setWaypointType "HOLD";
    
    helo1 land "GET OUT";
    deleteWaypoint [(group helo1),4];
    
    // Waituntil all alive units in players group are out of the chopper
    waitUntil { {_x in helo1 && alive _x} count units group player < 1 };
    
    _waypoint5 = (group helo1) addwaypoint [getMarkerPos "wp5", 0];
    _waypoint5 setWaypointType "MOVE";
    

    Ok, that should fix at least some of your problems. If I have missed something obvious let me know :)


  4. Its not execMovingtarget which actually moves the target ;)

    The function you are looking for is found in: CA\missions_e\bootcamp\BootCamp_Shared\functions\functions_animations.sqf

    Here is the one you want:

    BIS_animateMoveSmooth =
    {
    private["_sleep","_object","_posStart","_posEnd","_deltax","_deltay","_deltaz","_distance","_tmax","_a","_vmax","_t","_ssaved","_animList","_animPhase","_progress","_posx","_posy","_posz","_anim","_taccel","_saccel","_sconst","_tconst"];
    private["_wps","_positions","_distancesStart","_distancesPrev","_refWP","_ghostBall","_time","_hoverHeight","_dir"];
    
    _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;
    
    private["_d","_dTotal","_tmpPos"];
    _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];
    };
    //----------------------------------------------------------------------------------------------
    //----------------------------------------------------------------------------------------------
    
    
    //_vmax
    if (count(_this) > 2) then {
    	_vmax = _this select 2;
    } else {
    	_vmax = 15;
    };
    
    //_a
    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;
    
    private["_sleepTime","_tover"];
    
    _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;
    	};	
    };
    
    private["_pos"];
    
    _pos = _positions select (count(_positions) - 1);
    
    if isNil("_hoverHeight") then {
    	_object setPosASL _pos;
    } else {
    	_object setPos [_pos select 0, _pos select 1, _hoverHeight];
    };	
    };

    Now simply feed that with the target object and an array of waypoints (objects/positions), for example:

    [target1, [wp1, wp2]] spawn BIS_animateMoveSmooth

    Play around with the script to suit your needs (I personally call the function again at the end to loop it).

    Hope I helped ;)

    Andy455


  5. To make the popup targets go down:

    TARGET animate ["terc", 1];

    and back up:

    TARGET animate ["terc", 0];

    To disable auto popup of targets simply put this into your init.sqf or init field of a unit:

    nopop = true;

    With that you can easily use forEach/for loops with an array of target names to lay all targets flat and then pop random ones up each time.

    EDIT: feck didnt see that :(


  6. description.ext

    class but4 : but1 
    {
           text = "Missions";
           action = "call fnc_selectRandomMission";
           y = 0.52;
    };
    

    init.sqf

    fnc_selectRandomMission =
    {
    private ["_rNum"];
    _rNum = floor (random 2);
    switch (_rNum) do
    {
    	case 0:
    	{
    	   execVM "missions\01mission.sqf";
    	   closeDialog 0;
    	};
    	case 1:
    	{
    	  execVM "missions\01mission2.sqf";
    	  closeDialog 0;
    	};
    };
    };
    };
    

    Ok if you just put both of those in, it should work. I haven't tested it though :) might have missed something out.


  7. Instead of creating a waypoint for him to climb up why not simply have him spawn up there? You could do this by putting this into the insurgent's init field:

    this setPosATL [(getPosATL this select 0), (getPosATL this select 1), [color="Red"]4[/color]]

    To adjust height simply change the last element in that array (coloured red) up or down to suit your needs. As a final note remember to put the insurgent on top of the deer stand in the editor else he will spawn up in the air then fall down ;)


  8. myEnd = [[color="Red"]n[/color]] execVM "f\server\f_mpEndBroadcast.sqf";

    If that is exactly how you have it then that could be the problem, I'm not sure what paramaters that script takes but I'm guessing its a number (3 for "END3" when using endmission command). Other than that there isnt much we can do to help unless we can see that script you call.

×