Home   Help Search Login Register  

Author Topic: Need help to get the skeet-machine shoot the skeets  (Read 3473 times)

0 Members and 1 Guest are viewing this topic.

Offline weamdreaver

  • Members
  • *
Need help to get the skeet-machine shoot the skeets
« on: 08 Jun 2009, 13:45:19 »
Does anyone know how to get the skeet-machine to shoot the skeets?
I've found some scripts. But I cant get the machine to work.

I have tried it with the simple command in the init of a skeet-machine:
this exec "launch_skeet.sqf"
or
this exec "skeet_program.sqf"

But with no success.

The scripts can be found here:
Arma2/Addons/missions.pbo/armory/Data/Scripts/Tryout/prichals/skeetShooting

launch_skeet.sqf
Quote
/*
File: launch_skeet.sqf
Author: Joris-Jan van 't Land / Pepa Zemánek

Description:
Launches a single skeet.

Parameter(s):
_this select 0: skeet machine (Object).

Returns:
Success flag (Boolean).
*/

private ["_machine"];
_machine = _this select 0;

if (!(isnil "_machine")) then
{
LIB_skeetFired = LIB_skeetFired + 1;

_machine say "LaunchSkeet";

private ["_disc", "_discPos"];
_discPos = [_machine, 0.6, 180] call BIS_fnc_relPos;
_disc = "SkeetDisk" createVehicle [(_discPos select 0), (_discPos select 1), 0.7];
_disc setPos [(_discPos select 0), (_discPos select 1), 0.7];

LIB_dynObjs = LIB_dynObjs + [_disc];
LIB_chalObjs = LIB_chalObjs + [_disc];

private ["_vel", "_ehCode"];
_vel = [[0, -1, 0], (direction _machine)] call BIS_fnc_rotateVector2D;
_disc setVelocity [(-(_vel select 0) * 9), ((_vel select 1) * 9), 10 + (random 2)];

_ehCode =
{
private ["_disc"];
_disc = _this select 0;

//Only score a hit while the skeet is airborne.
if (((position _disc) select 0) > 0.1) then
{
LIB_skeetHit = LIB_skeetHit + 1;
if ((_disc distance player) > 100) then
{
LIB_skeetScore = LIB_skeetScore + 3;
}
else
{
LIB_skeetScore = LIB_skeetScore + 2;
};
};

LIB_dynObjs = LIB_dynObjs - [_disc];
LIB_chalObjs = LIB_chalObjs - [_disc];
deleteVehicle _disc;
};

_disc addEventHandler ["killed", _ehCode];

sleep 1;

//Make sure the skeet flies a bit longer than normal physics would cause.
_vel = velocity _disc;

private ["_i"];
_i = 0;

while {(((position _disc) select 2) > 0.1) && (alive _disc)} do
{
_disc setVelocity [(_vel select 0) / (1 + (_i / 10)), (_vel select 1) / (1 + (_i / 10)), (_vel select 2) / (1 + _i)];
_i = _i + 0.1;
sleep 0.1;
};

LIB_skeetLanded = LIB_skeetLanded + 1;
};

true



skeet_program.sqf
Quote
/*
File: skeet_program.sqf
Author: Joris-Jan van 't Land

Description:
The skeet launcher program.

Parameter(s):
_this select 0: skeet machines (Array of Objects).

Returns:
Success flag (Boolean).
*/

scopeName "root";

private ["_machines"];
_machines = _this select 0;

while {(LIB_skeetFired < 20) && LIB_skeetProgram} do
{
private ["_available", "_launched"];
_available = +_machines;
_launched = 0;

for "_i" from 0 to ((count _machines) - 1) do
{
if (((_launched == 0) || ((random 1) > 0.7)) && (LIB_skeetFired < 20)) then
{
private ["_machine"];
_machine = _available call BIS_fnc_selectRandom;

private ["_handle"];
_handle = [_machine] execVM "ca\missions\armory\data\scripts\tryout\pricha ls\s keetShooting\launch_skeet.sqf";

_available = _available - [_machine];
_launched = _launched + 1;
};
};

[10 + (random 5), 0, true] call LIB_safeDelayFunction;
};

LIB_skeetProgram = false;

true

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Need help to get the skeet-machine shoot the skeets
« Reply #1 on: 08 Jun 2009, 15:27:59 »
Not alot of people have had a chance to play with this yet. So it might be beneficial to provide a small sample mission that we can look at and help you out.
Xbox Rocks

Offline weamdreaver

  • Members
  • *
Re: Need help to get the skeet-machine shoot the skeets
« Reply #2 on: 08 Jun 2009, 16:13:59 »
Ok, here is my shooting range I am testing with.

Unfortunately the only missions in ARMA2 with the skeet-machine in are the ones in the armory imho. But I can not find any *.sqm in the armory. So I cant compare how the skeet-machine has to be build into the mission.


Edit:
Sorry, there was an error in my first uploaded test1.Chernarus. I corrected that with test2.Chernarus
« Last Edit: 08 Jun 2009, 16:18:31 by weamdreaver »

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Need help to get the skeet-machine shoot the skeets
« Reply #3 on: 08 Jun 2009, 16:26:39 »
Actually the first mission in the campaign has it, when your on the aircraft carrier.

I don't see how you're executing/starting the skeet machine??
Xbox Rocks

Offline weamdreaver

  • Members
  • *
Re: Need help to get the skeet-machine shoot the skeets
« Reply #4 on: 08 Jun 2009, 16:36:36 »
Well, that is my problem too. I dont know how to start the machine.
this exec "launch_skeet.sqf" does not work.

Oh, ok. I havent started the campaign yet.
I will try to look into the mission.


Edit:
When try to open FirstToFight (is that the mission you are referring to?) in the editor it crashes. :confused:


Edit2:
Ok, I think that skeet_program.sqf is the main script that controls the launch_skeet.sqf. I corrected the path in the skeet_program.sqf.

original

_handle = [_machine] execVM "ca\missions\armory\data\scripts\tryout\pricha ls\s keetShooting\launch_skeet.sqf";

now

_handle = [_machine] execVM "launch_skeet.sqf";

But it still shoots no skeets.  :confused:




Edit3:
I have found another script that has something to do with the skeet shooting.
I tried it, but with no luck again. With this script Arma2 crashes during the loading of the mission or after a few seconds into the mission.

skeeShooting.sqf

Quote
/*
   File: skeetShooting.sqf
   Author: Joris-Jan van 't Land

   Description:
   Clear the skeet shooting range.
   
   Parameter(s):
   _this select 0: side ID.
   _this select 1: type ID.
   _this select 2: config entry.
*/

scopeName "root";

disableSerialization;

private ["_sid", "_tid", "_entry"];
_sid = _this select 0;
_tid = _this select 1;
_entry = _this select 2;

LIB_chalChoice = -1;
LIB_pChalInit = true;

//Incoming challenge texts.
private ["_handle"];
_handle =
  • execVM (LIB_path + "incomingChallenge.sqf");

waitUntil {scriptDone _handle};
if (!LIB_tryout || LIB_goingBack) then {breakOut "root"};

//Show primary challenge acceptance dialog.
_dlg = createDialog "RscLibrary_Challenge";
waitUntil {dialog};

private ["_dialog", "_title", "_description", "_image", "_cTitle"];
_dialog = findDisplay 10002;
_title = _dialog displayCtrl 20001;
_description = _dialog displayCtrl 20002;
_image = _dialog displayCtrl 20005;
_cTitle = localize "STR_LIB_CHAL_SKEET_SHOOT";
_title ctrlSetText _cTitle;
_description ctrlSetStructuredText (parseText ((localize "STR_LIB_CHAL_SKEET_SHOOT_BRIEFING") + "<br /><br />" + (localize "STR_LIB_CHAL_ACCEPT")));
_image ctrlSetText "challenge_skeet_shooting_co.paa";

//Wait for choice or end of LIB_Tryout or close dialog.
waitUntil
{
   !dialog
   ||
   !LIB_Tryout
   ||
   LIB_chalChoice != -1   
};

if (!dialog || !LIB_Tryout) then
{
   //Decline - end challenge.
   closeDialog 100002;
   LIB_pChalInit = false;
   LIB_pChal = -1;
}
else
{
   closeDialog 100002;
   if (LIB_chalChoice == 1) then
   {   
      //Decline - end challenge.
      LIB_pChalInit = false;
      LIB_pChal = -1;
   }
   else
   {
      LIB_chalObjs = [];
      LIB_chalMrk = [];
      LIB_chalGrp = [];
      
      //Accept - fade out and in, build challenge.
      titleCut ["", "BLACK OUT", 1];      
      [1, 0, true] call LIB_safeDelayFunction;
      
      startLoadingScreen [localize "STR_LIB_LOADING_ENTRY", "RscLibrary_Load"];
      
      private ["_waterMode"];
      _waterMode = [_tid] call LIB_waterModeFunction;
   
      private ["_pos"];
      _pos = [[], 0, -1, 30, _waterMode, 20 * (pi / 180), 0, LIB_blackList] call BIS_fnc_findSafePos;
      
      [_sid, _tid, _entry, _pos, "fixed"] call LIB_respawnFunction;
      (vehicle player) setDir 0;
      
      //Create firing zone.
      private ["_handle"];
      if (_tid in [6, 7, 8, 11]) then
      {
         _handle = [_pos, _entry, _sid, _tid, 0] execVM (LIB_path + "tryout\prichals\skeetShooting\spawnSmallArms.sqf");
      }
      else
      {
         _handle = [_pos, _entry, _sid, _tid, 0] execVM (LIB_path + "tryout\prichals\skeetShooting\spawnHeavyArms.sqf");
      };
      
      //Create skeet machines (3 positions).
      private ["_pos1", "_pos2", "_pos3"];
      _pos1 = [(_pos select 0) - 20, (_pos select 1) + 10, 0];
      _pos2 = [_pos select 0, (_pos select 1) + 10, 0];
      _pos3 = [(_pos select 0) + 20, (_pos select 1) + 10, 0];
      
      //Add concrete blocks under the machines when in water.
      if (_tid == 5) then
      {
         _pos1 = [_pos1 select 0, (_pos1 select 1) + 5, -1.5];
         _pos2 = [_pos2 select 0, (_pos2 select 1) + 5, -1.5];
         _pos3 = [_pos3 select 0, (_pos3 select 1) + 5, -1.5];
         
         private ["_block1", "_block2", "_block3"];
         _block1 = "Land_ConcreteBlock" createVehicle _pos1;
         _block2 = "Land_ConcreteBlock" createVehicle _pos2;
         _block3 = "Land_ConcreteBlock" createVehicle _pos3;
         LIB_dynObjs = LIB_dynObjs + [_block1, _block2, _block3];
         LIB_chalObjs = LIB_chalObjs + [_block1, _block2, _block3];
         
         _block1 setPos _pos1;
         _block2 setPos _pos2;
         _block3 setPos _pos3;
         
         _pos1 = [_pos1 select 0, _pos1 select 1, 0.6];
         _pos2 = [_pos2 select 0, _pos2 select 1, 0.6];
         _pos3 = [_pos3 select 0, _pos3 select 1, 0.6];
      };
      
      private ["_machine1", "_machine2", "_machine3"];
      _machine1 = "SkeetMachine" createVehicle _pos1;
      _machine2 = "SkeetMachine" createVehicle _pos2;
      _machine3 = "SkeetMachine" createVehicle _pos3;
      LIB_dynObjs = LIB_dynObjs + [_machine1, _machine2, _machine3];
      LIB_chalObjs = LIB_chalObjs + [_machine1, _machine2, _machine3];
      
      _machine1 setPos _pos1;
      _machine2 setPos _pos2;
      _machine3 setPos _pos3;
      
      _machine1 setDir (180 + 45);
      _machine2 setDir 180;
      _machine3 setDir (180 - 45);
      
      //Detect player death.
      private ["_player"];
      _player = player;

      //Player waypoint.
      private ["_wp1"];
      _wp1 = (group player) addWaypoint [_pos, 0];
      _wp1 setWaypointType "HOLD";
      _wp1 setWaypointDescription (localize "STR_LIB_CHAL_SKEET_SHOOT_TASK_SHORT");
      
      //Player task.
      private ["_task", "_descShort"];
      _descShort = localize "STR_LIB_CHAL_SKEET_SHOOT_TASK_SHORT";
      _task = player createSimpleTask [_cTitle];
      _task setSimpleTaskDescription [localize "STR_LIB_CHAL_SKEET_SHOOT_TASK_DESC", _descShort, _descShort];
      player setCurrentTask _task;
      
      player createDiaryRecord ["diary", [_cTitle, localize "STR_LIB_CHAL_SKEET_SHOOT_BRIEFING"]];
      
      ["random", "daynight", "any"] call LIB_weatherTodFunction;
      
      //Eventhandler for accuracy.
      LIB_shotsFired = 0;
      (vehicle player) addEventHandler ["Fired", {LIB_shotsFired = LIB_shotsFired + (_this call LIB_shotsFiredFunction)}];
      
      //Main marker.
      private ["_marker"];
      _marker = createMarker ["LIB_marker_skeetShooting1", _pos];
      _marker setMarkerType "hd_flag";
      _marker setMarkerColor "ColorBlack";
      _marker setMarkerText _cTitle;
      LIB_dynMrk = LIB_dynMrk + [_marker];
      LIB_chalMrk = LIB_chalMrk + [_marker];
      
      endLoadingScreen;
      
      titleCut ["", "BLACK IN", 1];
      [1, 0, true] call LIB_safeDelayFunction;

      LIB_pChalInit = false;
      
      LIB_skeetHit = 0;
      LIB_skeetFired = 0;
      LIB_skeetLanded = 0;
      LIB_skeetScore = 0;
      LIB_skeetProgram = true;
      
      private ["_endCause", "_timer", "_leftZoneTooLong", "_timeLeftZone", "_timesLeftZone"];
      _endCause = -1;
      _timer = 0;
      _leftZoneTooLong = false;
      _timeLeftZone = 0;
      _timesLeftZone = 0;
      
      //How many skeets may be missed?
      private ["_maxMiss"];
      if (cadetMode) then {_maxMiss = 12} else {_maxMiss = 8};
      
      private ["_hintHeader"];
      _hintHeader = parseText ("<t size='1.2' color='#ffff7700'>" + _cTitle + "</t><br /><br />");
      
      while {true} do
      {
         if (!LIB_tryout) exitWith
         {
            _endCause = 0;
         };
         
         if (LIB_abortChallenges) exitWith
         {
            _endCause = 5;
         };

         if (_player != player) exitWith
         {
            _endCause = 1;
         };

         if (_timer == 4) then
         {
            //Start launching skeets.
            _handle = [[_machine1, _machine2, _machine3]] execVM "skeet_program.sqf";
         };
         
         if (({(damage _x) > 0} count [_machine1, _machine2, _machine3]) > 0) exitWith {_endCause = 6};
         
         private ["_hintBody"];
         _hintBody = format [(localize "STR_LIB_CHAL_FIRING_RANGE_SHOTS_FIRED") + " " + "%1" + "<br />", LIB_shotsFired];
         _hintBody = _hintBody + (format [(localize "STR_LIB_CHAL_SKEET_SHOOT_HIT") + "<br />", LIB_skeetHit, LIB_skeetFired]);
         
         private ["_acc"];
         _acc = 0;
         if (LIB_skeetHit > 0) then
         {
            _acc = round ((LIB_skeetHit / LIB_shotsFired) * 100);
         };         
         _hintBody = _hintBody + (format [(localize "STR_LIB_CHAL_FIRING_RANGE_ACCURACY") + " " + "%1%2", _acc, "%"]);
         
         //Detect exit firing zone.
         //Give warning first.
         if (!((vehicle _player) in (list LIB_firingZoneTrigger))) then
         {
            if (_timeLeftZone < 10) then
            {
               if (_timeLeftZone == 0) then {_timesLeftZone = _timesLeftZone + 1};
               
               _timeLeftZone = _timeLeftZone + 1;
               _hintBody = _hintBody + "<br /><br />" + (localize "STR_LIB_CHAL_FIRING_RANGE_LEFT_AREA") + "<br />" + (localize "STR_LIB_CHAL_FIRING_RANGE_GET_BACK");
               _hintBody = _hintBody + "<br />";
            }            
            else
            {
               _leftZoneTooLong = true;
            };
         }
         else
         {
            _timeLeftZone = 0;
         };
         
         if (_timesLeftZone > 1) then {_leftZoneTooLong = true};
         
         //Abort because of exiting too often or too long.
         if (_leftZoneTooLong) exitWith
         {
            _endCause = 3;
         };         
         
         LIB_pChalHint = composeText [_hintHeader, parseText _hintBody];
         call LIB_challengeHintFunction;

         //All skeets launched.
         if (!LIB_skeetProgram) exitWith
         {
            _endCause = 2;
         };
         
         //Missed too many skeets.
         if ((LIB_skeetLanded - LIB_skeetHit) > _maxMiss) exitWith
         {
            _endCause = 4;
         };
         
         _timer = _timer + 1;
         sleep 1;
      };
      
      switch (_endCause) do
      {
         //Died.
         case 1:
         {
            _task setTaskState "FAILED";
            
            _hintBody = parseText ((localize "STR_LIB_CHAL_DIED") + "<br /><br /><t color='#ffff0000'>" + (localize "STR_LIB_CHAL_FAILED") + "</t>");
            LIB_pChalHint = composeText [_hintHeader, _hintBody];
            call LIB_challengeHintFunction;
            
            
  • call LIB_challengeMusicFunction;

            
            LIB_pChalInit = true;
         };
         
         //Finished.
         case 2:
         {
            _task setTaskState "SUCCEEDED";
            
            _hintBody = (format [(localize "STR_LIB_CHAL_FIRING_RANGE_SHOTS_FIRED") + " " + "%1" + "<br />", LIB_shotsFired]);
            
            private ["_ptMsg"];
            _ptMsg = "";
            if (LIB_skeetHit > 0) then
            {
               _ptMsg = " (<t color='#ff0000ff'>+%3</t>)";
            };            
            _hintBody = _hintBody + (format [(localize "STR_LIB_CHAL_SKEET_SHOOT_HIT") + _ptMsg + "<br />", LIB_skeetHit, LIB_skeetFired, LIB_skeetScore]);
            
            private ["_accScore"];
            _accScore = 0;
            
            private ["_acc", "_accMsg"];
            _acc = 0;
            if (LIB_skeetHit > 0) then
            {
               _acc = round ((LIB_skeetHit / LIB_shotsFired) * 100);
            };
            _accMsg = "";
            if (_acc >= 85) then
            {
               _accScore = 15;
               _accMsg = " (<t color='#ff0000ff'>+10</t>)";
            };
            
            _hintBody = _hintBody + (format [(localize "STR_LIB_CHAL_FIRING_RANGE_ACCURACY") + " " + "%1%2" + _accMsg + "<br />", _acc, "%"]);
            
            private ["_nightScore"];
            _nightScore = 0;
            if (call LIB_isNightFunction) then
            {
               _hintBody = _hintBody + ("<br />" + (localize "STR_LIB_CHAL_NIGHT_BONUS") + "<br />");
               _nightScore = 10;
            };
            
            _hintBody = _hintBody + "<br />";            
            _hintBody = _hintBody + ("<t color='#ff00ff00'>" + (localize "STR_LIB_CHAL_COMPLETED") + "</t>");
            LIB_pChalHint = composeText [_hintHeader, parseText _hintBody];
            call LIB_challengeHintFunction;
            
            [1] call LIB_challengeMusicFunction;
            
            LIB_pChalInit = true;
            
            [5, 0, false] call LIB_safeDelayFunction;
            
            private ["_points"];
            _points = LIB_skeetScore + _nightScore + _accScore + 10;            
            [_points] call LIB_addPointsFunction;
         };
         
         //Left area.
         case 3:
         {
            _task setTaskState "FAILED";
            
            _hintBody = parseText ((localize "STR_LIB_CHAL_FIRING_RANGE_LEFT_AREA") + "<br /><br /><t color='#ffff0000'>" + (localize "STR_LIB_CHAL_FAILED") + "</t>");
            LIB_pChalHint = composeText [_hintHeader, _hintBody];
            call LIB_challengeHintFunction;
            
            
  • call LIB_challengeMusicFunction;

            
            LIB_pChalInit = true;
         };
         
         //Too many missed.
         case 4:
         {
            _task setTaskState "FAILED";
            
            _hintBody = parseText ((localize "STR_LIB_CHAL_SKEET_SHOOT_MANY_MISSED") + "<br /><br /><t color='#ffff0000'>" + (localize "STR_LIB_CHAL_FAILED") + "</t>");
            LIB_pChalHint = composeText [_hintHeader, _hintBody];
            call LIB_challengeHintFunction;
            
            
  • call LIB_challengeMusicFunction;

            
            LIB_pChalInit = true;
         };
         
         //Aborted.
         case 5:
         {
            _task setTaskState "FAILED";
            
            _hintBody = parseText ((localize "STR_LIB_CHAL_ABORTED") + "<br /><br /><t color='#ffff0000'>" + (localize "STR_LIB_CHAL_FAILED") + "</t>");
            LIB_pChalHint = composeText [_hintHeader, _hintBody];
            call LIB_challengeHintFunction;
            
            
  • call LIB_challengeMusicFunction;

            
            LIB_pChalInit = true;
         };
         
         //Damaged skeet machines.
         case 6:
         {
            _task setTaskState "FAILED";
            
            _hintBody = parseText ((localize "STR_LIB_CHAL_SKEET_SHOOT_MACHINES") + "<br /><br /><t color='#ffff0000'>" + (localize "STR_LIB_CHAL_FAILED") + "</t>");
            LIB_pChalHint = composeText [_hintHeader, _hintBody];
            call LIB_challengeHintFunction;
            
            
  • call LIB_challengeMusicFunction;

            
            LIB_pChalInit = true;
         };
         
         default {};
      };
      
      //Try to make sure the player isn't killed after the challenge ended.
      if (alive _player) then {_player setCaptive true};
      
      LIB_skeetProgram = false;
      
      [3, 0, true] call LIB_safeDelayFunction;
      
      if (LIB_tryout) then
      {      
         LIB_pChalHint = "";
         call LIB_challengeHintFunction;

         if ((_endCause != 1) && !LIB_respawning) then
         {
            titleCut ["", "BLACK OUT", 1];
            
            [1, 0, true] call LIB_safeDelayFunction;
            
            (vehicle player) removeAllEventHandlers "Fired";
         };
         
         call LIB_cleanChallengeFunction;
         
         LIB_pChalInit = false;
         LIB_chalFinish = time;
         LIB_pChal = -1;
         
         //Respawn unless the player died during the challenge.
         if ((_endCause != 1) && !LIB_respawning) then
         {
            [_sid, _tid, _entry, [], "random"] call LIB_respawnFunction;
            
            titleCut ["", "BLACK IN", 1];
         };
      };
   };
};

true
« Last Edit: 09 Jun 2009, 20:13:25 by weamdreaver »