Jump to content

TARGET Listmode function help


Recommended Posts

Hi, -posted from simhq a little while ago but haven't had a bite from there.

 

I'm trying to write my own scripts in Target for a DCS: MiG-21bis profile (Script Editor not GUI). I have no prior programming experience so this is quite challenging and rewarding in itself as I chip away.

 

I'm trying to replicate the listmode code on pg. 51 of the manual where you can cycle a list back/forwards

 

 

include "FC2_MIG_29C_Macros.ttm"

int listmode, index; //master modes list function & index

int main()

{

if(Init(&EventHandle)) return 1;

listmode = SEQ(_8__Gunsight_Reticle_Switch,

_7__Air_To_Ground_Mode,

_6__Longitudinal_Missile_Aiming_Mode,

_5__Close_Air_Combat_HMD_Helmet_Mode,

_4__Close_Air_Combat_Bore_Mode,

_3__Close_Air_Combat_Vertical_Scan_Mode,

_2__Beyond_Visual_Range_Mode,

_1__Navigation_Modes);

//China Hat is used for Modes selection---------------

MapKey(&Throttle, CHF, EXEC("index = (index+1)%8; ActKey(KEYON+PULSE+X(listmode, index));")); // forward

MapKey(&Throttle, CHB,EXEC("index = (index+7)%8; ActKey(KEYON+PULSE+X(listmode, index));")); // 7 is 8-1

= backward

}

int EventHandle(int type, alias o, int x)

{

DefaultMapping(&o, x);

}

 

 

 

The problem is after compiling and attempting to run the script I get:

Runtime Error: Symbol not found: _11__S3_4 in main ( line 11 in MiG-21bis.tmc ). Even a copy/paste of the manual code has this problem.

 

So I'm stuck I have no idea how to fix this. Any help would be much appreciated

 

I'll include my woeful work in progress :D

MiG-21bis.tmc

 

 

include "target.tmh"

include "MiG-21bis-Macro.ttm"

 

int listmode, index;

 

int main()

{

if(Init(&EventHandle)) return 1;

 

// Weapon Selection List ****************

listmode = SEQ(

_11__S3_4,

_10__S1_2,

_9__B1_4,

_8__B3_4,

_7__B1_2,

_6__AA3_4,

_5__AA1_2,

_4__AA4,

_3__AA3,

_2__AA2,

_1__AA1);

 

 

//JOYSTICK*******************************

 

MapKey(&Joystick, TG1, FireGuns);

MapKey(&Joystick, S2, WeaponRelease);

MapKey(&Joystick, S4, WheelBrakes);

MapKey(&Joystick, H2U, TargetLock);

//MapKey(&Joystick, H2D, );

 

//Weapon Selection List****************************************

MapKey(&Joystick, H2R, EXEC("index = (index+1)%11; ActKey(KEYON+PULSE+X(listmode, index));")); // forward

MapKey(&Joystick, H2L, EXEC("index = (index+10)%11; ActKey(KEYON+PULSE+X(listmode, index));")); // 10 is 11-1 = backward

//***************************************************************

MapKey(&Joystick, H1U, PULSE+TrimPitchDown);

MapKey(&Joystick, H1D, PULSE+TrimPitchUp);

//MapKey(&Joystick, H1L, );

//MapKey(&Joystick, H1R, );

 

MapAxis(&Joystick, JOYX, DX_X_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);

SetSCurve(&Joystick, JOYX, 0, 0, 0, 0, 0);

MapAxis(&Joystick, JOYY, DX_Y_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);

SetSCurve(&Joystick, JOYY, 0, 0, 0, 0, 0);

 

//THROTTLE************************************

 

MapKey(&Throttle, SPDF, PULSE+AirBrakesOn);

MapKey(&Throttle, SPDM, PULSE+AirBrakesOff);

MapKey(&Throttle, SPDB, PULSE+AirBrakesOn);

MapKey(&Throttle, BSF, PULSE+RadarOn);

MapKey(&Throttle, BSM, PULSE+RadarStandby);

MapKey(&Throttle, BSB, PULSE+RadarOff);

MapKey(&Throttle, LTB, SEQ(PULSE+SAURecovery, PULSE+SAUCancel));

MapKey(&Throttle, FLAPU, PULSE+FlapsUp);

MapKeyR(&Throttle, FLAPU, PULSE+FlapsDown);

MapKey(&Throttle, FLAPD, PULSE+FlapsDown);

MapKeyR(&Throttle, FLAPD, PULSE+FlapsUp);

MapKey(&Throttle, CSU, TDCUp);

MapKey(&Throttle, CSD, TDCDn);

//MapKey(&Throttle, CSL,);

//MapKey(&Throttle, CSR,);

MapKey(&Throttle, LDGH, SEQ(CHAIN(PULSE+GearLockReleased, PULSE+GearHandleUp, D(4000), PULSE+GearHandleNeutral, PULSE+GearLockEngaged), CHAIN(PULSE+GearHandleDown, D(4000),PULSE+GearHandleNeutral)));

 

MapAxis(&Throttle, SCX, DX_XROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);

SetSCurve(&Throttle, SCX, 0, 0, 0, 0, 0);

MapAxis(&Throttle, SCY, DX_YROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);

SetSCurve(&Throttle, SCY, 0, 0, 0, 0, 0);

MapAxis(&Throttle, THR_RIGHT, DX_Z_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);

SetJCurve(&Throttle, THR_RIGHT, 50, 50);

MapAxis(&Throttle, THR_LEFT, DX_ZROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);

SetSCurve(&Throttle, THR_LEFT, 0, 0, 0, 0, 0);

MapAxis(&Throttle, THR_FC, DX_SLIDER_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);

SetSCurve(&Throttle, THR_FC, 0, 0, 0, 0, 0);

 

}

int EventHandle(int type, alias o, int x)

{

DefaultMapping(&o, x);

}

 

 

MiG-21bis-Macro.ttm

 

 

// Gear / Brakes / Chute ************************

define GearHandleDown L_SHIFT+'g'

define GearLockEngaged R_CTL+'g'

define GearLockReleased R_SHIFT+'g'

define GearHandleNeutral L_CTL+'g'

define GearHandleUp 'g'

 

define ABSOn R_CTL+R_SHIFT+'w'

define ABSOff R_SHIFT+'w'

define DragButtonOpen R_ALT+R_CTL+'d'

define DragButtonClosed R_ALT+'d'

define DragChute 'p'

define DragChuteDisconnect R_CTL+R_SHIFT+'p'

define EmergencyBrakeOn L_CTL+L_SHIFT+'w'

define EmergencyBrakeOff L_CTL+'w'

define NoseBrakeOn L_ALT+L_CTL+'w'

define NoseBrakeOff L_ALT+'w'

define WheelBrakes 'w'

 

// ENGINE ****************************************

 

define AfterburnerMaxOff R_ALT+R_SHIFT+']'

define AfterburnerMaxOn R_ALT+']'

define EmergencyAfterburnerOff L_ALT+L_CTL+'e'

define EmergencyAfterburnerOn L_ALT+'e'

define DropCentreFuelPod R_CTL+PGUP

define DropWingFuelPod R_CTL+PGDN

define WingFuelPodOpen R_CTL+R_SHIFT+PGDN

define WingFuelPodClosed R_CTL+PGDN

 

// FLIGHT CONTROLS ***********************************

 

define AirBrakesOn 'c'

define AirBrakesOff 'd'

define FlapsDown 'f'

define FlapsUp L_SHIFT+'f'

define FlapsTakeOff L_ALT+'f'

define FlapsLanding L_CTL+'f'

define TrimPitchDown L_SHIFT+'t'

define TrimPitchUp L_CTL+'t'

 

// WEAPONS ********************************

 

define WeaponRelease L_ALT+SPC

define FireGuns SPC

define Reload1 L_ALT+'1'

define Reload2 L_ALT+'2'

define Reload3 L_ALT+'3'

define ASPMainModeAuto L_SHIFT+'3'

define ASPMainModeManual L_CTL+'3'

define ASPModeBomb L_CTL+'2'

define ASPModeGyro L_SHIFT+'4'

define ASPModeGun L_SHIFT+'1'

define ASPModeMissile L_CTL+'4'

define ASPModeRockets L_CTL+'1'

define ASPModeShooting L_SHIFT+'2'

define ASPGunsightOff R_CTL+R_SHIFT+'v'

define ASPGunsightOn R_SHIFT+'v'

define NetOff R_CTL+R_SHIFT+'x'

define NetOn R_SHIFT+'x'

define PipperOff R_CTL+R_SHIFT+'c'

define PipperOn R_SHIFT+'c'

define MasterAir L_WIN+'1'

define MasterGround L_WIN+'2'

define AAModeIR L_WIN+'4'

define AAModeNeutral L_ALT+L_WIN+'4'

define AAModeSAR L_WIN+'3'

define AA1 '1'

define AA2 '2'

define AA3 '3'

define AA4 '4'

define AA1_2 '-'

define AA3_4 '0'

define B1_2 '5'

define B3_4 '6'

define B1_4 '7'

define S1_2 '8'

define S3_4 '9'

 

// AUTOPILOT ***********************************

 

define SAUHoldAlt 'j'

define SAULowAltRecoveryOff R_ALT+R_SHIFT+'s'

define SAULowAltRecoveryOn R_CTL+'s'

define SAURecovery 'a'

define SAUStabilise L_ALT+'a'

define SAUCancel L_ALT+L_CTL+'a'

define SAUCancelLanding R_ALT+R_SHIFT+'a'

define SAULandingAuto R_ALT+'a'

define SAULandingCommand R_SHIFT+'a'

 

// RADIO ************************

 

define Intercom '\'

define CoverMe L_WIN+'x'

define RTF L_WIN+'t'

define AwacsBandit L_WIN+'q'

define AttackMyTgt L_WIN+'c'

 

// RADAR *****************************

 

define RadarCont L_SHIFT+'q'

define RadarIFF L_SHIFT+'a'

define RadarLowSpeed L_SHIFT+'s'

define RadarPassive L_SHIFT+'e'

define RadarReset L_CTL+L_SHIFT+'f'

define RadarTemp L_SHIFT+'w'

define RadarWeather L_SHIFT+'r'

define RadarOff L_CTL+L_SHIFT+'4'

define RadarOn L_SHIFT+L_ALT+'4'

define RadarStandby L_ALT+'4'

define TargetLock ENT

define TDCDn 'l'

define TDCUp 'o'

 

// LIGHTS ***************************

 

define LightsLandOn L_ALT+'l'

define LightsLandOff L_ALT+L_CTL+'l'

define LightsLandTaxi L_CTL+'l'

define LightNavMax L_SHIFT+'l'

define LightNavMed L_ALT+L_SHIFT+'l'

define LightNavMin L_CTL+L_ALT+'l'

define LightNavOff L_SHIFT+L_ALT+'l'

 

// MISC ***************************

 

define Eject L_CTL+'e'

 

 


Edited by Rooks
Link to post
Share on other sites

I don't see any of those definitions in your Macro file. You have definitions for things like

 

define AA1 '1'

define AA2 '2'

define AA3 '3'

define AA4 '4'

 

... but then in your tmc you are calling

 

_4__AA4,

_3__AA3,

_2__AA2,

_1__AA1);

 

EDIT: I think I see your mistake (in understanding the example from the manual). When the manual has '_1_' that is part of the name assigned. It has nothing to do with the target listmode function. As a matter of fact, IIRC, those are the actual command names, including the '_1_' part, from Flaming Cliff 2 (which is what the example code was designed for).

 

Your listmode could read,

 

int dwarfslist, index;
...
dwarfslist = SEQ(
Happy,
Grumpy,
Sneezy,
Dopey,
Bashful,
Doc,
Sleepy);

 

and it would work just fine (as long as you define the names in your macro file).

 

EDIT2: Btw, from a glance at your tmc, I would say you are coming along just fine. This problem was really due to the manual not being overly clear.


Edited by cichlidfan
  • Like 1

ASUS ROG Maximus VIII Hero, i7-6700K, Noctua NH-D14 Cooler, Crucial 32GB DDR4 2133, Samsung 950 Pro NVMe 256GB, Samsung EVO 250GB & 500GB SSD, 2TB Caviar Black, Zotac GTX 1080 AMP! Extreme 8GB, Corsair HX1000i, Phillips BDM4065UC 40" 4k monitor, VX2258 TouchScreen, TIR 5 w/ProClip, TM Warthog, VKB Gladiator Pro, Saitek X56, et. al., MFG Crosswind Pedals #1199, VolairSim Pit, Rift CV1 :thumbup:

Link to post
Share on other sites

Thanks for having a look at that for me. That example makes it much clearer thanks!. I only have the manual to go from so its a bit of trial and error when I get to something I don't quite understand.

Still, I'm really amazed by the potential of scripting your own profile.

 

I'll have a bit more of a plug today and see how I go.

Thanks again for the pointers Cichlidfan

 

Edit: Thanks! Got it working, I understand how it works now, you're right I misunderstood the manual.


Edited by Rooks
Success
Link to post
Share on other sites

Good deal. The manual is not the best but most of it does the job. I learned a lot by trial and error as well and it has served me well enough.

 

A second set of eyes is also handy sometimes so feel free to post questions/problems.

ASUS ROG Maximus VIII Hero, i7-6700K, Noctua NH-D14 Cooler, Crucial 32GB DDR4 2133, Samsung 950 Pro NVMe 256GB, Samsung EVO 250GB & 500GB SSD, 2TB Caviar Black, Zotac GTX 1080 AMP! Extreme 8GB, Corsair HX1000i, Phillips BDM4065UC 40" 4k monitor, VX2258 TouchScreen, TIR 5 w/ProClip, TM Warthog, VKB Gladiator Pro, Saitek X56, et. al., MFG Crosswind Pedals #1199, VolairSim Pit, Rift CV1 :thumbup:

Link to post
Share on other sites

Ok so diving in the deep end way over my head again :doh:

I'm trying to have 2 master modes AA & AG with 2 subtypes SAR/IR and Bomb/Rocket. Each master mode limiting weapon selection to just cycling AA or AG using logic flags.

There is probably numerous ways to do it but I'm trying to learn different things, so flags it is this time.

 

I'm running into problems on how to use functions & indexes properly (mostly syntax problems) and then how to use them with if/else. ie bolded sections

may have gone overboard on functions

 

 

Also is there are any other suggested reading you would recommend?

 

 

Snippet:

...
char AirGroundMode; //Air/Ground Master Mode Flag
char Bomb_Missile; // Submode Flag
[b]int AAWeaponselect, AGWeaponselect, index;[/b]
int AAWeaponListFor, AGWeaponListFor, AAWeaponListBack, AGWeaponListBack, SARMode, IRMode, AGMode, BombMode;

int main()

//Mastermode Flags - AA=1/AG=0; Bomb=1/Rockets=0 ***********
AirGroundMode=1;
Bomb_Missile=1;

[b]// AA/AG Weapon Selection List ****************
AAWeaponselect = SEQ(AA1, AA2, AA3, AA4, AA1_2, AA3_4);
AGWeaponselect = SEQ(B1_2, B3_4, B1_4, S1_2, S3_4);[/b]

[b]AAWeaponListFor  = EXEC("index = (index+1)%6; ActKey(KEYON+PULSE+X(AAWeaponselect, index));");
AGWeaponListFor  = EXEC("index = (index+1)%5; ActKey(KEYON+PULSE+X(AGWeaponselect, index));");
AAWeaponListBack  = EXEC("index = (index+5)%6; ActKey(KEYON+PULSE+X(AAWeaponselect, index));");
AGWeaponListBack  = EXEC("index = (index+4)%5; ActKey(KEYON+PULSE+X(AGWeaponselect, index));");[/b]

// SAR Master Mode ***********
SARMode = CHAIN(PULSE+AAModeSAR, D(), PULSE+ASPModeMissileRockets, D(), PULSE+ASPModeShooting, D(), PULSE+ASPMainModeAuto, D(), PULSE+ASPModeMissile);
// IR Master Mode ************
IRMode = CHAIN(PULSE+AAModeIR, D(), PULSE+ASPModeMissileRockets, D(), PULSE+ASPModeShooting, D(), PULSE+ASPMainModeAuto, D(), PULSE+ASPModeMissile);
// Rocket Master Mode ********
AGMode = CHAIN(PULSE+AAModeNeutral, D(), PULSE+ASPModeMissileRockets, D(), PULSE+ASPModeShooting, D(), PULSE+ASPMainModeAuto);
// Bombing Master Mode *******
BombMode = CHAIN(PULSE+AAModeNeutral, D(), PULSE+ASPModeMissileRockets, D(), PULSE+ASPModeShooting, D(), PULSE+ASPMainModeAuto, D(), PULSE+TacticalCoverOpen, D(), PULSE+TacticalReleaseOn);

[b]//Weapon Selection List****************************************
MapKey(&Joystick, H2R, EXEC("if(AirGroundMode) ActKey(PULSE+AAWeaponListFor); else ActKey(PULSE+AGWeaponListFor);")); // forward
MapKey(&Joystick, H2L, EXEC("if(AirGroundMode) ActKey(PULSE+AAWeaponListBack); else ActKey(PULSE+AGWeaponListBack);")); // backward
//***************************************************************
[/b]
//China Hat
MapKey(&Throttle, CHF, CHAIN(EXEC("if(AirGroundMode) ActKey(PULSE+SARMode); else ActKey(PULSE+AGMode);"), EXEC("Bomb_Missile=1;"))); //SAR or Rocket Select
MapKey(&Throttle, CHM, 0);
MapKey(&Throttle, CHB, CHAIN(EXEC("if(AirGroundMode) ActKey(PULSE+IRMode); else ActKey(PULSE+BombMode);"), EXEC("Bomb_Missile=0;"))); //IR or Bomb Select
//EAC
MapKey(&Throttle, EACON, CHAIN(PULSE+MasterAir, EXEC("AirGroundMode=1;"))); // , PULSE+TacticalReleaseOff, D(), PULSE+TacticalCoverClosed));
MapKey(&Throttle, EACOFF, CHAIN(PULSE+MasterGround, EXEC("AirGroundMode=0;")));

 

MiG-21bis.tmc

 

 

include "target.tmh"
include "MiG-21bis-Macro.ttm"


char AirGroundMode; //Air/Ground Master Mode Flag
char Bomb_Missile; // flag
int AAWeaponselect, AGWeaponselect, index;
int AAWeaponListFor, AGWeaponListFor, AAWeaponListBack, AGWeaponListBack, SARMode, IRMode, AGMode, BombMode;

int main()
{
if(Init(&EventHandle)) return 1;

//exclude unused controllers
Exclude(&HCougar);
Exclude(&T16000);
Exclude(&LMFD);
Exclude(&RMFD); 

//Mastermode Flags - AA=1/AG=0; Bomb=1/Rockets=0 ***********
AirGroundMode=1;
Bomb_Missile=1;

// AA/AG Weapon Selection List ****************
AAWeaponselect = SEQ(AA1, AA2, AA3, AA4, AA1_2, AA3_4);
AGWeaponselect = SEQ(B1_2, B3_4, B1_4, S1_2, S3_4);

AAWeaponListFor  = EXEC("index = (index+1)%6; ActKey(KEYON+PULSE+X(AAWeaponselect, index));");
AGWeaponListFor  = EXEC("index = (index+1)%5; ActKey(KEYON+PULSE+X(AGWeaponselect, index));");
AAWeaponListBack  = EXEC("index = (index+5)%6; ActKey(KEYON+PULSE+X(AAWeaponselect, index));");
AGWeaponListBack  = EXEC("index = (index+4)%5; ActKey(KEYON+PULSE+X(AGWeaponselect, index));");

// SAR Master Mode ***********
SARMode = CHAIN(PULSE+AAModeSAR, D(), PULSE+ASPModeMissileRockets, D(), PULSE+ASPModeShooting, D(), PULSE+ASPMainModeAuto, D(), PULSE+ASPModeMissile);
// IR Master Mode ************
IRMode = CHAIN(PULSE+AAModeIR, D(), PULSE+ASPModeMissileRockets, D(), PULSE+ASPModeShooting, D(), PULSE+ASPMainModeAuto, D(), PULSE+ASPModeMissile);
// Rocket Master Mode ********
AGMode = CHAIN(PULSE+AAModeNeutral, D(), PULSE+ASPModeMissileRockets, D(), PULSE+ASPModeShooting, D(), PULSE+ASPMainModeAuto);
// Bombing Master Mode *******
BombMode = CHAIN(PULSE+AAModeNeutral, D(), PULSE+ASPModeMissileRockets, D(), PULSE+ASPModeShooting, D(), PULSE+ASPMainModeAuto, D(), PULSE+TacticalCoverOpen, D(), PULSE+TacticalReleaseOn);

//JOYSTICK*******************************
//Buttons
MapKey(&Joystick, TG1, FireGuns);
MapKey(&Joystick, TG2, 0);
MapKey(&Joystick, S1, 0);
MapKey(&Joystick, S2, WeaponRelease);
MapKey(&Joystick, S3, TrackIRCentre);
MapKey(&Joystick, S4, WheelBrakes);

//Hat 1 Coolie
MapKey(&Joystick, H1U, PULSE+TrimPitchDown);
MapKey(&Joystick, H1D, PULSE+TrimPitchUp);
MapKey(&Joystick, H1L, TEMPO(PULSE+KneeboardLeft, KneeboardGlance));
MapKey(&Joystick, H1R, TEMPO(PULSE+KneeboardRight, PULSE+KneeboardToggle));

//Hat 2 TMS
MapKey(&Joystick, H2U, TargetLock);
MapKey(&Joystick, H2D, PULSE+RadarReset);
//Weapon Selection List****************************************
MapKey(&Joystick, H2R, EXEC("if(AirGroundMode) ActKey(PULSE+AAWeaponListFor); else ActKey(PULSE+AGWeaponListFor);")); // forward
MapKey(&Joystick, H2L, EXEC("if(AirGroundMode) ActKey(PULSE+AAWeaponListBack); else ActKey(PULSE+AGWeaponListBack);")); // backward
//***************************************************************

//Hat3 DMS
MapKey(&Joystick, H3U, SEQ(PULSE+LowAltFilter, PULSE+LowAltUp, PULSE+LowAltOff));
MapKey(&Joystick, H3D, PULSE+RadarLowSpeed);
MapKey(&Joystick, H3L, PULSE+RadarIFF);
MapKey(&Joystick, H3R, RadarWeather);

//Hat 4 CounterMeasures
MapKey(&Joystick, H4U, SPRDASODrop);
MapKey(&Joystick, H4D, 0);
MapKey(&Joystick, H4L, 0);
MapKey(&Joystick, H4R, 0);
MapKey(&Joystick, H4P, SPRDStart);

MapAxis(&Joystick, JOYX, DX_X_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
SetSCurve(&Joystick, JOYX, 0, 0, 0, 0, 0);
MapAxis(&Joystick, JOYY, DX_Y_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
SetSCurve(&Joystick, JOYY, 0, 0, 0, 0, 0);

//THROTTLE************************************
//Coolie Hat
MapKey(&Throttle, CSU, TDCUp);
MapKey(&Throttle, CSD, TDCDn);
MapKey(&Throttle, CSL, 0);
MapKey(&Throttle, CSR, 0);
//Slew Control
MapKey(&Throttle, SC, TEMPO(PULSE+DragChute, CHAIN(PULSE+DragButtonOpen, D(), DOWN+DragChuteDisconnect, D(500), UP+DragChuteDisconnect, PULSE+DragButtonClosed), 800));
//Throttle Button
MapKey(&Throttle, LTB, SEQ(PULSE+SAURecovery, PULSE+SAUCancel));
//Mic Switch
MapKey(&Throttle, MSU, 0);
MapKey(&Throttle, MSD, 0);
MapKey(&Throttle, MSL, 0);
MapKey(&Throttle, MSR, 0);
MapKey(&Throttle, MSP, 0);
//Speed Brake
MapKey(&Throttle, SPDF, PULSE+AirBrakesOn);
MapKey(&Throttle, SPDM, PULSE+AirBrakesOff);
MapKey(&Throttle, SPDB, PULSE+AirBrakesOn);
//Boatswitch
MapKey(&Throttle, BSF, PULSE+RadarOn);
MapKey(&Throttle, BSM, PULSE+RadarStandby);
MapKey(&Throttle, BSB, PULSE+RadarOff);
//China Hat
MapKey(&Throttle, CHF, CHAIN(EXEC("if(AirGroundMode) ActKey(PULSE+SARMode); else ActKey(PULSE+AGMode);"), EXEC("Bomb_Missile=1;"))); //SAR or Rocket Select
MapKey(&Throttle, CHM, 0);
MapKey(&Throttle, CHB, CHAIN(EXEC("if(AirGroundMode) ActKey(PULSE+IRMode); else ActKey(PULSE+BombMode);"), EXEC("Bomb_Missile=0;"))); //IR or Bomb Select
//Pinkie Switch
MapKey(&Throttle, PSF, CHAIN(PULSE+LightsLandOff, PULSE+LightNavOff)); //Hostile
MapKey(&Throttle, PSM, CHAIN(PULSE+LightsLandOff, PULSE+LightNavMed)); //Navigation
MapKey(&Throttle, PSB, CHAIN(PULSE+LightsLandOn, PULSE+LightNavMax)); //Landing
//Fuel
MapKey(&Throttle, EFLNORM, 0);
MapKey(&Throttle, EFLOVER, 0);
MapKey(&Throttle, EFRNORM, 0);
MapKey(&Throttle, EFROVER, 0);
//Engine
MapKey(&Throttle, EOLIGN, 0);
MapKey(&Throttle, EOLNORM, 0);
MapKey(&Throttle, EOLMOTOR, 0);
MapKey(&Throttle, EORIGN, 0);
MapKey(&Throttle, EORNORM, 0);
MapKey(&Throttle, EORMOTOR, 0);
//APU
MapKey(&Throttle, APUON, 0);
MapKey(&Throttle, APUOFF, 0);
//Landing Gear Horn
MapKey(&Throttle, LDGH, SEQ(CHAIN(PULSE+GearLockReleased, PULSE+GearHandleUp, D(4000), PULSE+GearHandleNeutral, PULSE+GearLockEngaged), CHAIN(PULSE+GearHandleDown, D(4000),PULSE+GearHandleNeutral)));
//Flaps
MapKey(&Throttle, FLAPU, PULSE+FlapsUp);
MapKeyR(&Throttle, FLAPU, PULSE+FlapsDown);
MapKey(&Throttle, FLAPD, PULSE+FlapsDown);
MapKeyR(&Throttle, FLAPD, PULSE+FlapsUp);
//EAC
MapKey(&Throttle, EACON, CHAIN(PULSE+MasterAir, EXEC("AirGroundMode=1;"))); // , PULSE+TacticalReleaseOff, D(), PULSE+TacticalCoverClosed));
MapKey(&Throttle, EACOFF, CHAIN(PULSE+MasterGround, EXEC("AirGroundMode=0;")));
//Radar Alt
MapKey(&Throttle, RDRNRM, 0);
MapKey(&Throttle, RDRDIS, 0);
//Autopilot
MapKey(&Throttle, APDIS, 0);
//AP Mode
MapKey(&Throttle, APPAT, 0);
MapKey(&Throttle, APAH, 0);
MapKey(&Throttle, APALT, 0);

//Axes
MapAxis(&Throttle, THR_RIGHT, DX_Z_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
//SetSCurve(&Throttle, THR_RIGHT, 0, 0, 0, 0);
MapAxis(&Throttle, THR_LEFT, DX_ZROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
//SetSCurve(&Throttle, THR_LEFT, 0, 0, 0, 0, 0);
MapAxis(&Throttle, THR_FC, DX_SLIDER_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
SetSCurve(&Throttle, THR_FC, 0, 0, 0, 0, 0);
MapAxis(&Throttle, SCX, DX_XROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
SetSCurve(&Throttle, SCX, 0, 0, 0, 0, 0);
MapAxis(&Throttle, SCY, DX_YROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
SetSCurve(&Throttle, SCY, 0, 0, 0, 0, 0);

}
int EventHandle(int type, alias o, int x)
{
DefaultMapping(&o, x);
}

 

 

 

MiG-21bis.ttm

 

 

// Gear / Brakes / Chute  ************************
define GearHandleDown L_SHIFT+'g'
define GearLockEngaged R_CTL+'g'
define GearLockReleased R_SHIFT+'g'
define GearHandleNeutral L_CTL+'g'
define GearHandleUp 'g'

define ABSOn R_CTL+R_SHIFT+'w'
define ABSOff R_SHIFT+'w'
define DragButtonOpen R_ALT+R_CTL+'d'
define DragButtonClosed R_ALT+'d'
define DragChute 'p'
define DragChuteDisconnect R_CTL+R_SHIFT+'p'
define EmergencyBrakeOn L_CTL+L_SHIFT+'w'
define EmergencyBrakeOff L_CTL+'w'
define NoseBrakeOn L_ALT+L_CTL+'w'
define NoseBrakeOff L_ALT+'w'
define WheelBrakes 'w'

// ENGINE ****************************************

define AfterburnerMaxOff R_ALT+R_SHIFT+']'
define AfterburnerMaxOn R_ALT+']'
define EmergencyAfterburnerOff L_ALT+L_CTL+'e'
define EmergencyAfterburnerOn L_ALT+'e'
define DropCentreFuelPod R_CTL+PGUP
define DropWingFuelPod R_CTL+PGDN
define WingFuelPodOpen R_CTL+R_SHIFT+PGDN
define WingFuelPodClosed R_CTL+PGDN

// FLIGHT CONTROLS ***********************************

define AirBrakesOn 'c'
define AirBrakesOff 'd'
define FlapsDown 'f'
define FlapsUp L_SHIFT+'f'
define FlapsTakeOff L_ALT+'f'
define FlapsLanding L_CTL+'f'
define TrimPitchDown L_SHIFT+'t'
define TrimPitchUp L_CTL+'t'

// WEAPONS ********************************

define WeaponRelease L_ALT+SPC
define FireGuns SPC
define Reload1 L_ALT+'1'
define Reload2 L_ALT+'2'
define Reload3 L_ALT+'3'
define ASPMainModeAuto L_SHIFT+'3'
define ASPMainModeManual L_CTL+'3'
define ASPModeBomb L_CTL+'2'
define ASPModeGyro L_SHIFT+'4'
define ASPModeGun L_SHIFT+'1'
define ASPModeMissile L_CTL+'4'
define ASPModeMissileRockets L_CTL+'1'
define ASPModeShooting L_SHIFT+'2'
define ASPGunsightOff R_CTL+R_SHIFT+'v'
define ASPGunsightOn R_SHIFT+'v'
define NetOff R_CTL+R_SHIFT+'x'
define NetOn R_SHIFT+'x'
define PipperOff R_CTL+R_SHIFT+'c'
define PipperOn R_SHIFT+'c'
define MasterAir L_WIN+'1'
define MasterGround L_WIN+'2'
define AAModeIR L_WIN+'4'
define AAModeNeutral L_ALT+L_WIN+'4'
define AAModeSAR L_WIN+'3'
define AA1 '1'
define AA2 '2'
define AA3 '3'
define AA4 '4'
define AA1_2 '-'
define AA3_4 '0'
define B1_2 '5'
define B3_4 '6'
define B1_4 '7'
define S1_2 '8'
define S3_4 '9'
define TacticalReleaseOn R_CTL+'='
define TacticalReleaseOff R_ALT+R_SHIFT+'='
define TacticalCoverOpen R_ALT+'='
define TacticalCoverClosed R_ALT+R_CTL+'='

// AUTOPILOT ***********************************

define SAUHoldAlt 'j'
define SAULowAltRecoveryOff R_ALT+R_SHIFT+'s'
define SAULowAltRecoveryOn R_CTL+'s'
define SAURecovery 'a'
define SAUStabilise L_ALT+'a'
define SAUCancel L_ALT+L_CTL+'a'
define SAUCancelLanding R_ALT+R_SHIFT+'a'
define SAULandingAuto R_ALT+'a'
define SAULandingCommand R_SHIFT+'a'

// RADIO ************************

define Intercom '\'
define CoverMe L_WIN+'x'
define RTF L_WIN+'t'
define AwacsBandit L_WIN+'q'
define AttackMyTgt L_WIN+'c'

// RADAR *****************************

define RadarCont L_SHIFT+'q'
define RadarIFF L_SHIFT+'a'
define RadarLowSpeed L_SHIFT+'s'
define RadarPassive L_SHIFT+'e'
define RadarReset L_CTL+L_SHIFT+'f'
define RadarTemp L_SHIFT+'w'
define RadarWeather L_SHIFT+'r'
define RadarOff L_CTL+L_SHIFT+'4'
define RadarOn L_SHIFT+L_ALT+'4'
define RadarStandby L_ALT+'4'
define TargetLock ENT
define TDCDn 'l'
define TDCUp 'o'
define LowAltUp L_ALT+L_SHIFT+'5'
define LowAltFilter L_ALT+'5'
define LowAltOff L_CTL+L_SHIFT+'5'

// LIGHTS ***************************

define LightsLandOn L_ALT+'l'
define LightsLandOff L_ALT+L_CTL+'l'
define LightsLandTaxi L_CTL+'l'
define LightNavMax L_SHIFT+'l'
define LightNavMed L_ALT+L_SHIFT+'l'
define LightNavMin L_SHIFT+L_WIN+'l'
define LightNavOff L_CTL+L_SHIFT+'l'

// COUNTERMEASURES*****************
define SPRDASODrop L_CTL+SPC
define SPRDStart L_SHIFT+SPC

// MISC ***************************

define Eject L_CTL+'e'
define KneeboardToggle R_CTL+UARROW
define KneeboardRight R_CTL+RARROW
define KneeboardLeft R_CTL+LARROW
define KneeboardGlance R_SHIFT+UARROW
define KneeboardMark R_CTL+DARROW
define TrackIRCentre L_ALT+F12

 

 


Edited by Rooks
Missing bits
Link to post
Share on other sites

I'll take a look at this tonight and see if I can help. You should be aware, however, that I am not a coder but just an old systems guy who has figured a few things out.

 

As for reading, to the best of my knowledge, Target is similar to lua scripting so stuff on lua scripting can be helpful but keep in mind that little things are liable to be different still.

 

EDIT: After taking a quick look, I can see that this is going to take a minute or three to comprehend. ;)


Edited by cichlidfan

ASUS ROG Maximus VIII Hero, i7-6700K, Noctua NH-D14 Cooler, Crucial 32GB DDR4 2133, Samsung 950 Pro NVMe 256GB, Samsung EVO 250GB & 500GB SSD, 2TB Caviar Black, Zotac GTX 1080 AMP! Extreme 8GB, Corsair HX1000i, Phillips BDM4065UC 40" 4k monitor, VX2258 TouchScreen, TIR 5 w/ProClip, TM Warthog, VKB Gladiator Pro, Saitek X56, et. al., MFG Crosswind Pedals #1199, VolairSim Pit, Rift CV1 :thumbup:

Link to post
Share on other sites

I guess my scripting could use a bit of clarity :wassat: Yeah just found a ton of basic errors too. Embarrassing...

The point of this is really a working tutorial for me not to be super efficient, but still.

 

 

The thing I can't get on my own is the 2 weapon lists using 2 indexes for cycling AA or AG (I know I only have one index listed there atm.) and then how to call each one up. I've tried numerous ways and now just stuck.

 

The logic flags I've made much more progress over the weekend since I posted. Kept going over the manual examples and am reasonably confident with those now :blink:

 

EDIT: Simply could I call up the functions as so using if/else? (or similar) I'm just stuck on the syntax for this one.

 

int AAWeaponselect, AGWeaponselect, index1, index2;

AAWeaponselect = SEQ(AA1, AA2, AA3, AA4, AA1_2, AA3_4); //index1
AGWeaponselect = SEQ(B1_2, B3_4, B1_4, S1_2, S3_4); //index2

EXEC("if([color="Red"]xxxx[/color]) ActKey(index1 = (index1+1)%6); ActKey(KEYON+PULSE+X(AAWeaponselect, index1)); else ActKey(index2 = (index2+1)%5; ActKey(KEYON+PULSE+X(AGWeaponselect, index2));"); //if xxxx is true then use index1 else use index2


Edited by Rooks
brain exploding
Link to post
Share on other sites

If you have the other thing sorted then I will leave it alone. There is a more direct way of doing what (I think) you were doing, without the flags, but there is probably nothing gained or lost with either method.

 

As for this, it looks straight forward but give me a little bit to look at it. There is one immediate thought though. When you write a statement like that long EXEC, if you format it something like this it will be easier to read and easier for you to keep track of where you are in the statement when you are editing it.

 

EXEC("if(xxxx)  //if xxxx is true then use index1 else use index2
	ActKey(index1 = (index1+1)%6);
	ActKey(KEYON+PULSE+X(AAWeaponselect, index1));
else 
	ActKey(index2 = (index2+1)%5; 
	ActKey(KEYON+PULSE+X(AGWeaponselect, index2));");

 

EDIT: Assuming you are still using the EAC switch to select AA or AG mode, and On is for AA then you want your 'if' statement to look like this:

 

EXEC("if(Throttle[EACON])")

 

You can do the same with three position switches and it is easier/simpler than setting a flag when you flip the switch since the switch has it's own flag built in.


Edited by cichlidfan

ASUS ROG Maximus VIII Hero, i7-6700K, Noctua NH-D14 Cooler, Crucial 32GB DDR4 2133, Samsung 950 Pro NVMe 256GB, Samsung EVO 250GB & 500GB SSD, 2TB Caviar Black, Zotac GTX 1080 AMP! Extreme 8GB, Corsair HX1000i, Phillips BDM4065UC 40" 4k monitor, VX2258 TouchScreen, TIR 5 w/ProClip, TM Warthog, VKB Gladiator Pro, Saitek X56, et. al., MFG Crosswind Pedals #1199, VolairSim Pit, Rift CV1 :thumbup:

Link to post
Share on other sites

Cool.

 

There is a lot you can do with Target so have fun.

ASUS ROG Maximus VIII Hero, i7-6700K, Noctua NH-D14 Cooler, Crucial 32GB DDR4 2133, Samsung 950 Pro NVMe 256GB, Samsung EVO 250GB & 500GB SSD, 2TB Caviar Black, Zotac GTX 1080 AMP! Extreme 8GB, Corsair HX1000i, Phillips BDM4065UC 40" 4k monitor, VX2258 TouchScreen, TIR 5 w/ProClip, TM Warthog, VKB Gladiator Pro, Saitek X56, et. al., MFG Crosswind Pedals #1199, VolairSim Pit, Rift CV1 :thumbup:

Link to post
Share on other sites
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...