Announcement

Collapse
No announcement yet.

Arma - Math - Artillery related question

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Arma - Math - Artillery related question

    Game: Armed Assault / Queen's Gambit
    Format: .sqf

    If I have a D30 artillery unit, with a marker having a radius of 400 x 400, the D30
    being the center of that radius. I have a bottle object found in Empty - Objects
    that I want to travel around the radius of that marker when I use an Addaction
    command for RIGHT and LEFT.

    Question
    What precise formula do I need to make that happen?

    I would greatly appreciate any help any of you more elite scripters may be
    able to provide in solving this problem.

    Optionally

    Through another addaction "Set Target Marker", that uses onmapsingleclick to
    place another bottle object at that location. Once I click on the map, what
    math function working with the above request, can I use to allign first bottle
    as stated above, with the second bottle mentioned here, without exceeding
    the 400x400 circular boundary. This is optional of course, I would really
    appreciate any help in the first question more so than this one.

  • #2
    Re: Arma - Math - Artillery related question

    I do know that it'd have to be based on the coordinate formula: [x= r cos θ, y= r sin θ] where θ is the angle of the point of the circle that x and y lay on, and r is the radius of the circle. What you could try is:

    Code:
    //This will place the marker anywhere on a circle with a radius of _radius at random.
    //"marker_name" is the name of the marker to be moved. In this case the marker must be placed somewhere on the map.
    _radius = 400;
    _theta = round (random 360);
    _xCoord = _radius cos (_theta);
    _yCoord = _radius sin (_theta);
    _posGun = getPos D30;
    _xCoord = _xCoord + _posGun select 0;
    _yCoord = _yCoord + _posGun select 1;
    "marker_name" setMarkerPos [_xCoord, _yCoord];
    or

    Code:
    //This is the addaction.
    //Put this into the init of the unit you want to have the actions
    //Radius and Theta are not local variables this time, they are public due to them being defined in a separate script.
    theta = 0;
    radius = 400; //Radius 
    this addAction ["Move Clockwise", "clockwise.sqf"];
    this addAction ["Move Counter Clockwise", "counterclockwise.sqf];
    Code:
    //clockwise.sqf
    theta = theta + 1;
    _xCoord = radius cos (theta);
    _yCoord = radius sin (theta);
    _posGun = getPos D30;
    _xCoord = _xCoord + _posGun select 0;
    _yCoord = _yCoord + _posGun select 1;
    _marker setMarkerPos [_xCoord, _yCoord];
    Code:
    //counterclockwise.sqf
    theta = theta - 1;
    _xCoord = radius cos (theta);
    _yCoord = radius sin (theta);
    _posGun = getPos D30;
    _xCoord = _xCoord + _posGun select 0;
    _yCoord = _yCoord + _posGun select 1;
    _marker setMarkerPos [_xCoord, _yCoord];
    I'd test these in ArmA2 if they'd work, but I'm not on my desktop right now. Good luck!

    [edit]

    Just noticed you wanted to move an object. All you'd have to do there is just change the last like in the formula part of the scripts to objName setPos [_xCoord, _yCoord]; then it should work for an object rather than a marker.
    Blackpython / ZephyrDark
    Former 31st RECCE Member

    Comment

    Connect

    Collapse

    TeamSpeak 3 Server

    Collapse

    Advertisement

    Collapse

    Twitter Feed

    Collapse

    Working...
    X