Jump to content
Sign in to follow this  
six_ten

Scripted attachTo static weapons on vehicle -- how to add AI gunners?

Recommended Posts

I finally got cannons aboard my ship with attachTo (thanks to Gnat and a few others for posts and scripts that helped me understand how).

So my ship has guns, but no gunners. My earlier version of the ship had all the guns coded into the config, and AI manned the guns, but when I ported it from A2OA over to A3 the camera "broke" and I couldn't get the guns to face out the ports, only forward or back. With the attachTo method and memory points it works great. I'm planning set this up so in a multiplayer mission some ships can be human controlled and others can be AI patrols, raiders, merchants, etc.

The deck is walkable, so a human player can move about the deck and get into a gun position. What I'd like to do now is make it so AI can man the ships. Can someone help me to do that? (In simple language as I'm just starting to learn.)

I'm using a modified version of Gnat's script from his Fast Sea Frame:

In main config Sloop_Base:

 class EventHandlers
 {
  init = "[_this select 0] execVM ""\ART\ART_Water\Scripts\Rigging_Init.sqf"";";
 };

Then the script Rigging_Init:

//----------------------------------------
//script by Gnat
//mp fix by armatech
//modified by Six_Ten
//----------------------------------------
// if you use it, credit me as appropraite
//----------------------------------------
_ship = _this select 0;
if (!local _ship) exitWith {};
//_xx = 10 preloadObject "RHIB";
//_xx = 10 preloadObject "RHIB2Turret";
//_xx = 10 preloadObject "Stinger_Pod";
//Get var form ship
_check = _ship getVariable "boatsloaded";
//Check is var is empty/not set
if(isnil ("_check"))then
{
//load ships and set var
//Broadcasts ships loaded

_ship setVariable ["boatsloaded", 99,true];

//run boat loading scripts
_ladder = "Sloop_Rigging_Ratlines" createvehicle[0,0,0];
_ladder attachto [_ship,[0.0,-3.25,-2.35]];

////////////////////////////////////////////////////////////////////////////////////
///  Begin Gundeck
////////////////////////////////////////////////////////////////////////////////////
///  Port

_P1Cannon = "Gun_Swivel_Halfpdr" createvehicle[0,0,0];
_P1Cannon attachto [_ship,[0,0,0],"P1Gun"];
_P1Cannon setDir -45;

_P2Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
_P2Cannon attachto [_ship,[0,0,0],"P2Gun"];
_P2Cannon setDir -70;
_P3Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
_P3Cannon attachto [_ship,[0,0,0],"P3Gun"];
_P3Cannon setDir -90;
_P4Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
_P4Cannon attachto [_ship,[0,0,0],"P4Gun"];
_P4Cannon setDir -90;

_P5Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
_P5Cannon attachto [_ship,[0,0,0],"P5Gun"];
_P5Cannon setDir -90;
_P6Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
_P6Cannon attachto [_ship,[0,0,0],"P6Gun"];
_P6Cannon setDir -90;

/// Starboard 
_S1Cannon = "Gun_Swivel_Halfpdr" createvehicle[0,0,0];
_S1Cannon attachto [_ship,[0,0,0],"S1Gun"];
_S1Cannon setDir 45;
_S2Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
_S2Cannon attachto [_ship,[0,0,0],"S2Gun"];
_S2Cannon setDir 70;

_S3Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
_S3Cannon attachto [_ship,[0,0,0],"S3Gun"];
_S3Cannon setDir 90;
_S4Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
_S4Cannon attachto [_ship,[0,0,0],"S4Gun"];
_S4Cannon setDir 90; 

_S5Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
_S5Cannon attachto [_ship,[0,0,0],"S5Gun"];
_S5Cannon setDir 90;

_S6Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
_S6Cannon attachto [_ship,[0,0,0],"S6Gun"];
_S6Cannon setDir 90;


////////////////////////////////////////////////////////////////////////////////////
///  End Gundeck
////////////////////////////////////////////////////////////////////////////////////
};

http://i.imgur.com/A6RBi9R.jpg (212 kB) (212 kB)

...

http://makearmanotwar.com/entry/Fzvd2RZSpc#.VBTjD8zD_yM

Edited by Six_Ten

Share this post


Link to post
Share on other sites

You should use createVehicleCrew after each vehicle creation.

_P1Cannon = "Gun_Swivel_Halfpdr" createvehicle[0,0,0]; 
createVehicleCrew  _P1Cannon; 
_P1Cannon attachto [_ship,[0,0,0],"P1Gun"]; 
_P1Cannon setDir -45; 

...and so on

Share this post


Link to post
Share on other sites

Hm i wonder why you didnt get it to work with just the config...

I have a couple of turrets on a tank that show sidewards, and they work without problem. The important bit is, that the default position in the model has to be facing forward (as well as the memory points etc). You controll the final angle ingame via the turret rotation options. That way the camera is rotated correctly.

2014-09-1911_52_29-chzjupq.jpg2014-07-07_00003snu0j.jpg

turret config bit

class TurretCargoGunRight1: NewTurret {					
minElev=-10; maxElev=+60; initElev=+5;
minTurn=-135; maxTurn=-45; initTurn=-90;
//etc etc etc
};

modelcfg animations bit is just like any regular turret

			class CargoLG_R_1_Trav {   //traverse
			type="rotationY";
			source="cargoLG_r_1_trav_AnimSrc"; 
			selection="cargoLG_r_1_trav";
			axis="ax_cargoLG_r_1_trav"; 
			animPeriod=0;  
			minValue="rad -360";
			maxValue="rad +360";
			angle0="rad -360";
			angle1="rad +360";
			memory = 1;
		};
		class CargoLG_R_1_Elev: CargoLG_R_1_Trav {  //elevate
               type="rotationX";
			source="cargoLG_r_1_elev_AnimSrc"; 
			selection="cargoLG_r_1_elev";
			axis="ax_cargoLG_r_1_elev"; 
		};

Share this post


Link to post
Share on other sites

I have been reconstructing my files since they were destroyed by a trojan, and now for some reason my script version has stopped working.

As it is now, no flags, no guns and no rigging appear. Also the boarding script is broken.

What have I missed? Any idea why this is broken?

model.cfg


class Rotation
{
type = "rotation";
memory = 1;
minValue = 0;
maxValue = 1;
angle0 = 0;
angle1 = 1;
};



class CfgSkeletons
{
class Default
{
 isDiscrete = 1;
 skeletonInherit = "";
 skeletonBones[] = {};
};

class Vehicle: Default {};

class Ship: Vehicle
{
 skeletonInherit="Vehicle";
 skeletonBones[]={};
};

class civilian_boatSkeleton: Ship
{
 skeletonInherit = "ship";
 skeletonBones[] = 
 {



  "Compass",
  "", 
  "drivingWheel",
  "",   
  "Rudder",
  "",  
  "damageHide",
  "",
///////////////////////////////////////////////////////////////////   

  "Rudder_unhide","Rudder",
  "Rudder_hide","Rudder"

///////////////////////////////////////////////////////////////////  
 };
};
};      
class CfgModels
{
class Rotation;

class Default
{
 sectionsInherit="";
 sections[] = {};
 skeletonName = "";
}; 

class Vehicle: Default
{
 sections[] =
 {
  "zasleh"
 };
};


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
//    END SLOOP BASE BEGIN SLOOP BERMUDA
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class Sloop_Bermuda: Vehicle
{
 skeletonName = "civilian_boatSkeleton";
 sections[] = 
 {
  "camo",
  "Hull",
  "zbytek",
  "Compass", 
  "drivingWheel", 
  "Rudder"
 };

 class Animations
 {
  // destruct START
  class damageHide
  {
   type="hide";
   source="damage";
   selection="damageHide";
   hideValue=1.0;
  };

  class damageHideVez:damageHide
  {
   selection="OtocVez";
  };

  class damageHideHlaven:damageHide
  {
   selection="OtocHlaven";
  };
/////////////////////////////////////////////////////////////////////// 

  class Rudder_destruct
  {
   type="hide";
   selection="Rudder_hide";
   source="HitRudder";
   minValue = 0; // upravit na 0.99
   maxValue = 1; // upravit na 1.0
   hidevalue = 0.99999;
  };   

  class Rudder_destruct_unhide
  {
   type="hide";
   selection="Rudder_unhide";
   source="HitRudder";
   minValue = 0; 
   maxValue = 1; 
   hidevalue = 0.00000;
   UnHidevalue = 1.00000;
  };
///////////////////////////////////////////////////////////////////////   
 class Compass
  {
   type="rotation";
   source="direction";
   selection="Compass";
   axis="Compass_Axis";
   memory=1;
   minValue=-3.141590;
   maxValue=3.141590;
   angle0=-3.141593;
   angle1=3.141593;
  };   

  class drivingWheel
  {
   type = "rotation";
   source = "drivingWheel";
   selection = "drivingWheel";
   axis = "drivingWheel_Axis";
   memory = 1;
   minValue = -1;
   maxValue = 1;
   angle0 = -2;
   angle1 = 2;
  };
  class Rudder: drivingWheel
  {
   selection = "Rudder_hide";
   axis = "Rudder_Axis";
   angle0 = 1.308997;
   angle1 = -1.308997;
  };
 };
};
};

config.cpp

////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
#define _ARMA_
//ndefs=5
enum {
StabilizedInAxesNone = 0,
StabilizedInAxisX = 1,
StabilizedInAxisY = 2,
StabilizedInAxesBoth = 3,
StabilizedInAxesXYZ = 4
};
//Class ART_Water : config.bin{
class CfgPatches
{
class ART_Water
{
 units[] = {"Sloop","Sloop_Rigging_Ratlines","Sloop_Merchant","Sloop_American","Sloop_Militia","Sloop_British","Sloop_Loyalist"};
 weapons[] = {"Cannon_Half_pdr","Cannon_Four_pdr"};
 requiredVersion = 0.1;
 requiredAddons[] = {"A3_Boat_F","ART_Base","ART_Weapons"};
 magazines[] = {};
 ammo[] = {};
};
};
class DefaultEventhandlers;
class CfgVehicles
{
class Land_PierLadder_F;
class Sloop_Rigging_Ratlines: Land_PierLadder_F
{
 scope = 2;
 displayName = "Ratlines";
 vehicleClass = "1776_Seamanship";
 mapSize = 0.01;
 Icon = "\ART\ART_Fortification\Data\UI\map_Tent_BellOfArms_CA.paa";
 model = "\ART\ART_Water\Sloop_Rigging_Ratlines.p3d";
 armor = 150;
 ladders[] = {{ "P_Ratline_Start","P_Ratline_End" },{ "S_Ratline_Start","S_Ratline_End" }};
};

class Ship;
class Ship_F: Ship
{
 class ViewPilot;
 class AnimationSources;
 class Eventhandlers;
 class HitPoints
 {
  class HitRudder
  {
   armor = 0.00125;
   material = -1;
   name = "Rudder";
   visual = "";
   passThrough = 0.0;
   explosionShielding = 0;
   radius = 0.1;
  };
  class HitHull
  {
   armor = 1;
   material = 50;
   name = "Hull";
   visual = "zbytek";
   passThrough = 1;
   explosionShielding = 1;
  };
  class HitWaterline
  {
   armor = 1;
   material = 50;
   name = "Waterline";
   visual = "zbytek";
   passThrough = 1;
   explosionShielding = 1;
  };
  class HitMainMast
  {
   armor = 1.2;
   material = 60;
   name = "MainMast";
   visual = "";
   passThrough = 1;
   radius = 0.1;
  };
  class HitBowsprit
  {
   armor = 1;
   material = 50;
   name = "Bowsprit";
   visual = "zbytek";
   passThrough = 1;
   explosionShielding = 1;
  };
 };
};

class Sloop_Bermuda: Ship_F
{
 class NewTurret;
 class Turrets;
 class ViewOptics;
 class EventHandlers;
 side = 3;
 faction = "CIV_F";
 vehicleClass = "1776_Seamanship";
 displayName = "Bermuda Sloop";
 model = "\ART\ART_Water\Sloop_Bermuda.p3d";
 picture = "\A3\Weapons_F\Data\placeholder_co.paa";
 Icon = "\ART\ART_Water\Data\UI\map_sloop_ca.paa";
 mapSize = 19.8;
 cost = 20000;
 accuracy = 0.5;
 collisionEffect = "collisionEffect";
 class HitPoints: HitPoints
 {
  class HitRudder: HitRudder
  {
   armor = 0.00125;
   material = 60;
   name = "Rudder";
   visual = "zbytek";
   passThrough = 1;
   radius = 0.5;
  };
  class HitHull
  {
   armor = 1;
   material = 50;
   name = "Hull";
   visual = "zbytek";
   passThrough = 1;
   explosionShielding = 1;
  };
  class HitWaterline
  {
   armor = 1;
   material = 50;
   name = "Waterline";
   visual = "zbytek";
   passThrough = 1;
   explosionShielding = 1;
  };
  class HitMainMast
  {
   armor = 1.2;
   material = 60;
   name = "MainMast";
   visual = "zbytek";
   passThrough = 1;
   radius = 0.1;
  };
  class HitBowsprit
  {
   armor = 1;
   material = 50;
   name = "Bowsprit";
   visual = "zbytek";
   passThrough = 1;
   explosionShielding = 1;
  };
 };
 class AnimationSources
 {
  class HitRudder
  {
   source = "Hit";
   hitpoint = "HitRudder";
   raw = 1;
  };
  class Proxy
  {
   source = "user";
   animPeriod = 1;
   initPhase = 0;
  };
 };
 leftEngineEffect = "LEngEffectsSmall";
 rightEngineEffect = "REngEffectsSmall";
 simulation = "shipx";
 maxSpeed = 80;
 overSpeedBrakeCoef = 0.8;
 enginePower = 1235;
 engineShiftY = 1.1;
 waterLeakiness = 10.0;
 turnCoef = 1.5;
 thrustDelay = 0.25;
 waterLinearDampingCoefY = 2;
 waterLinearDampingCoefX = 2.0;
 waterAngularDampingCoef = 1.2;
 waterResistanceCoef = 0.015;
 rudderForceCoef = 2.0;
 rudderForceCoefAtMaxSpeed = 2.0;
 idleRpm = 200;
 redRpm = 1200;
 class complexGearbox
 {
  GearboxRatios[] = {"R1",-0.782,"N",0,"D1",2.0,"D2",1.85,"D3",1.75};
  TransmissionRatios[] = {"High",1.0};
  gearBoxMode = "auto";
  moveOffGear = 1;
  driveString = "D";
  neutralString = "N";
  reverseString = "R";
 };
 brakeDistance = 3;
 driverAction = "driver_boat01";
 driverLeftHandAnimName = "drivingWheel";
 driverRightHandAnimName = "drivingWheel";
 cargoAction[] = {"passenger_low01"};
 cargoIsCoDriver[] = {0};
 ejectDeadDriver = 0;
 transportSoldier = 24;

 class TransportItems
 {
  class _xx_FirstAidKit
  {
   name = "FirstAidKit";
   count = 6;
  };
 };

 armor = 2000;
 damageResistance = 0.00882;
 attenuationEffectType = "OpenCarAttenuation";
 insideSoundCoef = 1;
 soundEngineOnInt[] = {"a3\Sounds_F\vehicles\boat\Motor_Boat\engine_start","db-5",1.0};
 soundEngineOnExt[] = {"a3\Sounds_F\vehicles\boat\Motor_Boat\engine_start","db-5",1.0,300};
 soundEngineOffInt[] = {"a3\Sounds_F\vehicles\boat\Motor_Boat\engine_stop","db-5",1.0};
 soundEngineOffExt[] = {"a3\Sounds_F\vehicles\boat\Motor_Boat\engine_stop","db-5",1.0,300};
 buildCrash0[] = {"A3\sounds_f\Vehicles\soft\noises\crash_building_01","db0",1,200};
 buildCrash1[] = {"A3\sounds_f\Vehicles\soft\noises\crash_building_02","db0",1,200};
 buildCrash2[] = {"A3\sounds_f\Vehicles\soft\noises\crash_building_03","db0",1,200};
 buildCrash3[] = {"A3\sounds_f\Vehicles\soft\noises\crash_building_04","db0",1,200};
 soundBuildingCrash[] = {"buildCrash0",0.25,"buildCrash1",0.25,"buildCrash2",0.25,"buildCrash3",0.25};
 WoodCrash0[] = {"A3\sounds_f\Vehicles\soft\noises\crash_mix_wood_01","db0",1,200};
 WoodCrash1[] = {"A3\sounds_f\Vehicles\soft\noises\crash_mix_wood_02","db0",1,200};
 WoodCrash2[] = {"A3\sounds_f\Vehicles\soft\noises\crash_mix_wood_03","db0",1,200};
 WoodCrash3[] = {"A3\sounds_f\Vehicles\soft\noises\crash_mix_wood_04","db0",1,200};
 WoodCrash4[] = {"A3\sounds_f\Vehicles\soft\noises\crash_mix_wood_05","db0",1,200};
 WoodCrash5[] = {"A3\sounds_f\Vehicles\soft\noises\crash_mix_wood_06","db0",1,200};
 soundWoodCrash[] = {"woodCrash0",0.166,"woodCrash1",0.166,"woodCrash2",0.166,"woodCrash3",0.166,"woodCrash4",0.166,"woodCrash5",0.166};
 ArmorCrash0[] = {"A3\sounds_f\Vehicles\soft\noises\crash_vehicle_01","db0",1,200};
 ArmorCrash1[] = {"A3\sounds_f\Vehicles\soft\noises\crash_vehicle_02","db0",1,200};
 ArmorCrash2[] = {"A3\sounds_f\Vehicles\soft\noises\crash_vehicle_03","db0",1,200};
 ArmorCrash3[] = {"A3\sounds_f\Vehicles\soft\noises\crash_vehicle_04","db0",1,200};
 soundArmorCrash[] = {"ArmorCrash0",0.25,"ArmorCrash1",0.25,"ArmorCrash2",0.25,"ArmorCrash3",0.25};

 class Sounds
 {
  class IdleOut
  {
   sound[] = {"A3\Sounds_F\vehicles\boat\Motor_Boat\engine_idle","db-7",1.0,300};
   frequency = "0.95 + ((rpm/1000) factor[(100/1000),(250/1000)])*0.15";
   volume = "engineOn*(((rpm/1000) factor[(100/1000),(150/1000)])* ((rpm/1000) factor[(270/1000),(200/1000)]))";
  };
  class Engine
  {
   sound[] = {"A3\Sounds_F\vehicles\boat\Motor_Boat\engine_1","db-4",1.0,350};
   frequency = "0.85 + ((rpm/1000) factor[(200/1000),(370/1000)])*0.2";
   volume = "engineOn*(((rpm/1000) factor[(190/1000),(250/1000)])* ((rpm/1000) factor[(380/1000),(280/1000)]))";
  };
  class EngineMidOut
  {
   sound[] = {"A3\Sounds_F\vehicles\boat\Motor_Boat\engine_3","db-2",1.0,380};
   frequency = "0.85 + ((rpm/1000) factor[(280/1000),(480/1000)])*0.2";
   volume = "engineOn*(((rpm/1000) factor[(250/1000),(350/1000)])* ((rpm/1000) factor[(480/1000),(390/1000)]))";
  };
  class EngineMaxOut2
  {
   sound[] = {"A3\Sounds_F\vehicles\boat\Motor_Boat\engine_4","db-1",1.0,440};
   frequency = "0.86 + ((rpm/1000) factor[(380/1000),(580/1000)])*0.2";
   volume = "engineOn*(((rpm/1000) factor[(370/1000),(440/1000)])* ((rpm/1000) factor[(585/1000),(495/1000)]))";
  };
  class EngineMaxOut3
  {
   sound[] = {"A3\Sounds_F\vehicles\boat\Motor_Boat\engine_5","db0",1.0,500};
   frequency = "0.85 + ((rpm/1000) factor[(490/1000),(800/1000)])*0.2";
   volume = "engineOn*(((rpm/1000) factor[(460/1000),(550/1000)])* ((rpm/1000) factor[(780/1000),(620/1000)]))";
  };
  class EngineMaxOut4
  {
   sound[] = {"A3\Sounds_F\vehicles\boat\Motor_Boat\engine_6","db2",1.0,550};
   frequency = "0.85 + ((rpm/1000) factor[(650/1000),(1000/1000)])*0.2";
   volume = "engineOn*((rpm/1000) factor[(600/1000),(800/1000)])";
  };
  class WaternoiseOutW0
  {
   sound[] = {"A3\Sounds_F\vehicles\boat\SFX\voda-o-bok-lodi-0-speed1","db-3",1.0,150};
   frequency = "1";
   volume = "(speed factor[4, 1])";
  };
  class WaternoiseOutW1
  {
   sound[] = {"A3\Sounds_F\vehicles\boat\SFX\voda-o-bok-lodi-20-speed","db-2",1.0,250};
   frequency = "1";
   volume = "((speed factor[2, 6]) min (speed factor[6, 4]))";
  };
  class WaternoiseOutW2
  {
   sound[] = {"A3\Sounds_F\vehicles\boat\SFX\voda-o-bok-lodi-50-speed","db0",1.0,350};
   frequency = "1";
   volume = "(speed factor[3, 9])";
  };
 };

 class Reflectors{};
 class Damage
 {
  tex[] = {};
  mat[] = {"ART\ART_Water\Data\Sloop_Hull.rvmat","ART\ART_Water\Data\Sloop_Hull_damage.rvmat","ART\ART_Water\Data\Sloop_Hull_destruct.rvmat","ART\ART_Water\Data\Sloop_Rig.rvmat","ART\ART_Water\Data\Sloop_Rig_damage.rvmat","ART\ART_Water\Data\Sloop_Rig_destruct.rvmat"};
 };

 extCameraPosition[] = {0,10.0,-18.0};
 rightFastWaterEffect = "RFastWaterEffects";
 waterEffectSpeed = 5;
 engineEffectSpeed = 5;
 waterFastEffectSpeed = 15;

 class UserActions
 {
  class BoardTheVessel
  {
   displayName = "Board the Vessel";
   position = "zamerny";
   onlyforplayer = 1;
   radius = 10;
   condition = "not (player in this)";
   statement = "[this, player] execVM ""\ART\ART_Water\Scripts\Boarding.sqf""";
  };
 };

 hiddenSelections[] = {"Camo_Hull","Camo_Rig"};
 hiddenSelectionsTextures[] = {"\ART\ART_Water\Data\Sloop_Hull_CO.paa","\ART\ART_Water\Data\Sloop_Rig_CO.paa"};
};

class Sloop_American: Sloop_Bermuda
{
 scope = 2;
 displayName = "American Navy Sloop";
 side = 1;
 faction = "UnitedStates";
 crew = "Pvt2dVirginiaRegt_1777";
 class AnimationSources: AnimationSources
 {
  class Proxy: Proxy
  {
   initPhase = 1;
  };
 };
 hiddenSelectionsTextures[] = {"\ART\ART_Water\Data\Sloop_Hull_CO.paa"};
 class EventHandlers
 {
  init = "[_this select 0] execVM ""\ART\ART_Water\Scripts\Rigging_Init.sqf"";";
 };
};

};
//};

Rigging_Init.sqf


//----------------------------------------
//script by Gnat
//mp fix by armatech
//----------------------------------------
// if you use it, credit me as appropraite
//----------------------------------------
_ship = _this select 0;
if (!local _ship) exitWith {};
//_xx = 10 preloadObject "RHIB";
//_xx = 10 preloadObject "RHIB2Turret";
//_xx = 10 preloadObject "Stinger_Pod";
//Get var form ship
_check = _ship getVariable "boatsloaded";
//Check is var is empty/not set
if(isnil ("_check"))then
{
//load ships and set var
//Broadcasts ships loaded

_ship setVariable ["boatsloaded", 99,true];

//run boat loading scripts
_ladder = "Sloop_Rigging_Ratlines" createvehicle[0,0,0];
_ladder attachto [_ship,[0.0,-3.25,-2.35]];
_flag = "Flag_US_Navy" createvehicle[0,0,0];  
_flag attachto [_ship,[0.0,-4.9,11.0]]; 
////////////////////////////////////////////////////////////////////////////////////
///  Begin Gundeck
////////////////////////////////////////////////////////////////////////////////////
///  Port

_P1Cannon = "Gun_Swivel_Halfpdr" createvehicle[0,0,0];
createVehicleCrew  _P1Cannon; 
_P1Cannon attachto [_ship,[0,0,0],"P1Gun"];
_P1Cannon setDir -45;

_P2Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
createVehicleCrew  _P3Cannon; 
_P2Cannon attachto [_ship,[0,0,0],"P2Gun"];
_P2Cannon setDir -70;
_P3Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
createVehicleCrew  _P3Cannon; 
_P3Cannon attachto [_ship,[0,0,0],"P3Gun"];
_P3Cannon setDir -90;
_P4Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
createVehicleCrew  _P4Cannon; 
_P4Cannon attachto [_ship,[0,0,0],"P4Gun"];
_P4Cannon setDir -90;

_P5Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
createVehicleCrew  _P5Cannon; 
_P5Cannon attachto [_ship,[0,0,0],"P5Gun"];
_P5Cannon setDir -90;
_P6Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
createVehicleCrew  _P6Cannon; 
_P6Cannon attachto [_ship,[0,0,0],"P6Gun"];
_P6Cannon setDir -90;

/// Starboard 
_S1Cannon = "Gun_Swivel_Halfpdr" createvehicle[0,0,0];
createVehicleCrew  _S1Cannon; 
_S1Cannon attachto [_ship,[0,0,0],"S1Gun"];
_S1Cannon setDir 45;
_S2Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
createVehicleCrew  _S2Cannon; 
_S2Cannon attachto [_ship,[0,0,0],"S2Gun"];
_S2Cannon setDir 70;

_S3Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
createVehicleCrew  _S3Cannon; 
_S3Cannon attachto [_ship,[0,0,0],"S3Gun"];
_S3Cannon setDir 90;
_S4Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
createVehicleCrew  _S4Cannon; 
_S4Cannon attachto [_ship,[0,0,0],"S4Gun"];
_S4Cannon setDir 90; 

_S5Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
createVehicleCrew  _S5Cannon; 
_S5Cannon attachto [_ship,[0,0,0],"S5Gun"];
_S5Cannon setDir 90;

_S6Cannon = "Gun_Naval_4pdr" createvehicle[0,0,0];
createVehicleCrew  _S6Cannon; 
_S6Cannon attachto [_ship,[0,0,0],"S6Gun"];
_S6Cannon setDir 90;


////////////////////////////////////////////////////////////////////////////////////
///  End Gundeck
////////////////////////////////////////////////////////////////////////////////////
};



Edited by Six_Ten

Share this post


Link to post
Share on other sites
Hm i wonder why you didnt get it to work with just the config...

I cannot (and after weeks of trying) get the optics for the gunners to look in the direction of the cannon.

Yesterday I rebuilt the gundeck using your method (which was the way I used to do it) but no matter what i can't get the damned gunners to look in the right direction, and the cannons will not fire correctly.

If I post my model and config could you take a look at it? I still can't get the scripts to work either, so now I don't even have that as a backup method.

Edited by Six_Ten

Share this post


Link to post
Share on other sites

I rotated my carriage and barrel proxies to be parallel with the gunwales, but even changing the initial rotation in the config they do not turn to be perpendicular in game. Unless I rotate them in the p3d they stay pointing forward.

Share this post


Link to post
Share on other sites

if you want to make the guns face an specific direction and restrict them in which direction they face just point them forward in O2 and in the turret config set the angles that can face.

For example with this they would face starbord with a 15º arc of fire to every side

minTurn = 75;

maxTurn = 100;

initTurn = 90;

For making the same with the bord facing guns in their turret configs the angles would have to be set like this

minTurn = 255;

maxTurn = 285;

initTurn = 270;

Share this post


Link to post
Share on other sites

This is now working well. My cannons attach, the gunners appear, and the guns fire and animate correctly.

However, a problem remains:

When I am the driver of the boat the cannons and gunners appear to be outside the ship, that is, they seem to be drawn first, then the boat.

Driver view, guns drawn before ship, incorrect.

GqSrrRF.jpg

Walking on deck, first person, correct.

8Poir7J.jpg

From the gunner's point of view, the sides of the ship are drawn first, then the guns, so they do not appear to stick through the gunports, but look like they're totally inside the ship.

First Person Gunner View, ship drawn before guns, incorrect.

2t2j9zo.jpg

How do I fix this so they look like they're in proper position on the deck?

Edited by Six_Ten

Share this post


Link to post
Share on other sites

Has nobody else encountered a similar problem with attached static weapons?

Share this post


Link to post
Share on other sites

have you tried alpha sorting

select your entire hull and then -> Faces-> move to bottom (in Object Builder)

Select all proxies and move to top... maybe it works

Share this post


Link to post
Share on other sites
have you tried alpha sorting

select your entire hull and then -> Faces-> move to bottom (in Object Builder)

Select all proxies and move to top... maybe it works

He's using attachto for the weapons.

To my knowledge there's no way to fix this, it plagued 'fire from vehicle' scripts in arma 2 aswell.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×