Jump to content
Sign in to follow this  
wickedstigma

Control Structure problem [If and switch]

Recommended Posts

Hi everyone. Im making the new Simple Artillery Support v2.0 and there is something that is slowing me down.... a lot. And I cant find what the hell is wrong with it. the thing is that after setting default values and reading custom values, I can really use a variable to create a different set of settings. Here is the code:


//Set default values
//-----------------------------------------

_artilleryTarget 		= "artilleryTarget";	// Main target
_firingMode 			= "NORMAL";		// Normal or Battery One
_ordinance 			= "ARTY_Sh_122_HE";	// Type of ordinance
_typeofFire 			= "none";		// Type of Fire Mission - (FFE, Zone & Sweep, Smoke Screen, etc.)
_amountofRounds 		= 10;			// Number of rounds to be delivered on target
_proximity 			= 6;			// For anti personel ordinance, will explode @ _explosionAltitude value
_ceaseFireSwitch 		= false;		// To order cease fire when you order Fire For Effect
_numberofGuns 			= 6;			// Number of cannons to shoot on Battery One
_spawnHeight 			= 500;			// Ordinance spawn hegiht 
_spawnDelay 			= 60;			// Time for fire mission to splash
_spawnPosition 			= "none";		// Used for different patterns and types of fire missions
_initialDelay 			= 60;			// Initial delay of custom fire missions
_roundDelay 			= 6;			// Delay between rounds
_roundCounter 			= 0;			// Counts number of rounds been shot
_spread				= 100;			// Spread of fire mission
_pattern			= "none";		// tight, spread, scatter, 
_ffe				= false;		// Switch for the Fire for Effect Fire mission
_artilleryStrikePos		= [0,0,0];		// Artillery strike position to spawn bomb and have a correct spread

hint "Setting defaults [COMPLETE]";
sleep 3;

//-----------------------------------------
//Variable Tester
//-----------------------------------------


hintc format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];


//-----------------------------------------


//Read custom values
//-----------------------------------------

{

switch (_x select 0) do {

	case "mode"	      : { _firingMode 	  = _x select 1};

	case "ammo"           : { _ordinance 	  = _x select 1};

	case "type"	      : { _typeofFire 	  = _x select 1};

	case "proximity"      : { _proximity 	  = _x select 1};

	case "guns" 	      : { _numberofGuns   = _x select 1};

	case "initDelay"      : { _initDelay  	  = _x select 1};

	case "roundDelay"     : { _roundDelay 	  = _x select 1};

	case "amount"         : { _amountofRounds = _x select 1};

	case "spread"         : { _spread     	  = _x select 1};

	case "pattern"        : {
		switch (_x select 1) do { 

			// Changes presets according to the type of pattern you choose

			case "tight"   : { _amountofRounds = 10; _spread = 50 ; _roundDelay = 2.2};
			case "spread"  : { _amountofRounds = 12; _spread = 150; _roundDelay = 4  };
			case "scatter" : { _amountofRounds = 16; _spread = 300; _roundDelay = 5  };
			case "harrass" : { _amountofRounds = 8 ; _spread = 100; _roundDelay = 3  };
			case "suppress": { _amountofRounds = 20; _spread = 200; _roundDelay = 3  };
		};
	}; 
};

} forEach _this;

hint "Setting custom Fire Mission [COMPLETE]";
sleep 3;


//-----------------------------------------
//Variable Tester
//-----------------------------------------

hintc format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];

//-----------------------------------------

[color="Red"]

switch (_typeofFire) do {


case "FFE" : {_ffe = true};


};

if (_ffe = true) the {

hint "Fire for Effect";
[color="Orange"][i]// I will place later the code here for the fire mission or to add the action of fire for effect to the player[/i][/color]

};

[/color]

I am calling it through:

nul = [["ammo","ARTY_Sh_105_HE"],["type","FFE"],["amount",200],["spread",200],["roundDelay",0]] execVM "simple_artillery_strike_v2.0.sqf";

The red part of the first code is what is giving me a huge headache. So my formal questions are the following:

  1. What is wrong with the if and the switch? I basically want to turn _ffe to true so I can run just a part of the code when _ffe = true.
  2. How can I manage variables from one script to another? Lets say I take this script and after _ffe = true this adds an action to the player for fire for effect, which will open another script when you use it, but will need to take info from the main script.
  3. How can I create a sub-menu like when you use Sec Ops Module (SOM) to call in Artillery Support. If I cant do this what I'm going to do is add the options through the player actions.
  4. Is there a way to explode a shell in mid air without making it hit an object? For example, what I do is I spawn a baseball.... yeah, i know, dirty dirty way of doing it......, and setVelocity to 0,0,10 so it goes upwards in the shell direction and it makes it explode at any height I want. It works, but I want a less dirty version of doing it.

Thanks for all the help in advance!

Share this post


Link to post
Share on other sites

Not sure about switch, not done much with it, but I can see what's up with the IF statement:

if (_ffe = true)

Comparisons in IF statements use two equals signs, so (_ffe == true) would be right - except ArmA doesn't seem to like truisms. _ffe contains true/false, so you're asking if true equals true, perfectly valid except not in ArmA it seems.

Instead just use the bool condition:

if (_ffe)

ArmA will then read that as "if TRUE" or "if FALSE" and act accordingly. Might even fix your switch issue.

Share this post


Link to post
Share on other sites

if (_ffe = true) the {

Thats not a condition, but a value assignment.

= vs ==

Share this post


Link to post
Share on other sites

thanks to both of you. Im going to try it and post back in a few minutes.

---------- Post added at 11:57 AM ---------- Previous post was at 11:36 AM ----------

I tried the following without success...

[color="Orange"]
// Check if _ffe was getting the true value[/color]
_ffe = true;
hintc format ["Fire for effect value: %1", _ffe];

[color="Orange"]
// Check if _typeofFire = "FFE" then hint[/color]

if (_typeofFire == "FFE") then {hint "Fire for effect!}; [color="Red"]// The code doesnt pass this point of the code[/color]

_ffe = false;
hintc format ["Fire for effect value: %1", _ffe];

if (_ffe) then {hint "Fire for Effect Shot!"};


I tried it with the last code switch, with the double ==, and with the _ffe alone. But it didn't work.

Share this post


Link to post
Share on other sites

You forgot the second " after the hint (Fire for effect!) message ;)

E: your "Fire for Effect Shot!" hint wont be triggered because you set _ffe to false. The if condition means that it must be true.

if (!(_ffe)) then {hint "Fire for Effect Shot!"}; would trigger.

Edited by MichaelGER

Share this post


Link to post
Share on other sites

Is the part after the hint "Fire for effect!" not working or is the hint also not working?

If the hint works: see my edit

If it doesnt work:

// Check if _ffe was getting the true value
_ffe = true;
hintc format ["Fire for effect value: %1", _ffe];


// Check if _typeofFire = "FFE" then hint

hintc format ["%1",_typeofFire];

//if (_typeofFire == "FFE") then {hint "Fire for effect!}; // The code doesnt pass this point of the code

_ffe = false;
hintc format ["Fire for effect value: %1", _ffe];

if (_ffe) then {hint "Fire for Effect Shot!"};

try this. it will tell you the value of _typeofFire. If the value isnt "FFE" you found the problem

E: i see you have already a hint with debug. is the typeofFire value "FFE"?

Share this post


Link to post
Share on other sites

nope, the other hintc show the value of _typeofFire first as none when I set defaults and then it shows FFE. so the var is actually getting the FFE. Even though I cant make the if or the switch case work.

---------- Post added at 01:08 PM ---------- Previous post was at 12:48 PM ----------

You forgot the second " after the hint (Fire for effect!) message ;)

E: your "Fire for Effect Shot!" hint wont be triggered because you set _ffe to false. The if condition means that it must be true.

if (!(_ffe)) then {hint "Fire for Effect Shot!"}; would trigger.

I saw your edit now and tried it right away. It didnt work either. I set up so the value changed before the if and it dint work either.

Edited by wickedstigma

Share this post


Link to post
Share on other sites

Ive built in some diag_logs. Maybe we can see some errors in the arma2.rpt now.

//Set default values
//-----------------------------------------
_debug = true;

if (_debug) then {
diag_log "Starting debug";
};

_artilleryTarget 		= "artilleryTarget";	// Main target
_firingMode 			= "NORMAL";		// Normal or Battery One
_ordinance 			= "ARTY_Sh_122_HE";	// Type of ordinance
_typeofFire 			= "none";		// Type of Fire Mission - (FFE, Zone & Sweep, Smoke Screen, etc.)
_amountofRounds 		= 10;			// Number of rounds to be delivered on target
_proximity 			= 6;			// For anti personel ordinance, will explode @ _explosionAltitude value
_ceaseFireSwitch 		= false;		// To order cease fire when you order Fire For Effect
_numberofGuns 			= 6;			// Number of cannons to shoot on Battery One
_spawnHeight 			= 500;			// Ordinance spawn hegiht 
_spawnDelay 			= 60;			// Time for fire mission to splash
_spawnPosition 			= "none";		// Used for different patterns and types of fire missions
_initialDelay 			= 60;			// Initial delay of custom fire missions
_roundDelay 			= 6;			// Delay between rounds
_roundCounter 			= 0;			// Counts number of rounds been shot
_spread				= 100;			// Spread of fire mission
_pattern			= "none";		// tight, spread, scatter, 
_ffe				= false;		// Switch for the Fire for Effect Fire mission
_artilleryStrikePos		= [0,0,0];		// Artillery strike position to spawn bomb and have a correct spread

hint "Setting defaults [COMPLETE]";
if (_debug) then {
diag_log "Settings defaults complete";
};
sleep 3;

//-----------------------------------------
//Variable Tester
//-----------------------------------------


hintc format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];

if (_debug) then {
diag_log format ["Fire for effect switch: %1 type of fire: %2",_ffe, _typeofFire];
};


//-----------------------------------------


//Read custom values
//-----------------------------------------

{

switch (_x select 0) do {

	case "mode"	      : { _firingMode 	  = _x select 1; if (_debug) then {diag_log format ["Mode var got the value %1",_x select 1];}};

	case "ammo"           : { _ordinance 	  = _x select 1; if (_debug) then {diag_log format ["ammo var got the value %1",_x select 1];}};

	case "type"	      : { _typeofFire 	  = _x select 1; if (_debug) then {diag_log format ["type var got the value %1",_x select 1];}};

	case "proximity"      : { _proximity 	  = _x select 1; if (_debug) then {diag_log format ["proximity var got the value %1",_x select 1];}};

	case "guns" 	      : { _numberofGuns   = _x select 1; if (_debug) then {diag_log format ["guns var got the value %1",_x select 1];}};

	case "initDelay"      : { _initDelay  	  = _x select 1; if (_debug) then {diag_log format ["initDelayvar got the value %1",_x select 1];}};

	case "roundDelay"     : { _roundDelay 	  = _x select 1; if (_debug) then {diag_log format ["roundDelay var got the value %1",_x select 1];}};

	case "amount"         : { _amountofRounds = _x select 1; if (_debug) then {diag_log format ["amount var got the value %1",_x select 1];}};

	case "spread"         : { _spread     	  = _x select 1; if (_debug) then {diag_log format ["spread var got the value %1",_x select 1];}};

	case "pattern"        : { 
		diag_log format ["pattern var got the value %1",_x select 1];
		switch (_x select 1) do { 

			// Changes presets according to the type of pattern you choose

			case "tight"   : { _amountofRounds = 10; _spread = 50 ; _roundDelay = 2.2};
			case "spread"  : { _amountofRounds = 12; _spread = 150; _roundDelay = 4  };
			case "scatter" : { _amountofRounds = 16; _spread = 300; _roundDelay = 5  };
			case "harrass" : { _amountofRounds = 8 ; _spread = 100; _roundDelay = 3  };
			case "suppress": { _amountofRounds = 20; _spread = 200; _roundDelay = 3  };
		};
	}; 	if (_debug) then {diag_log format ["amount of rounds: %1 spread: %2 rounddelay: %3",_amountofRounds, _spread,  _roundDelay];}
};

} forEach _this;

hint "Setting custom Fire Mission [COMPLETE]";
sleep 3;


//-----------------------------------------
//Variable Tester
//-----------------------------------------

hintc format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];

if (_debug) then {
diag_log format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];
};

//-----------------------------------------


// Check if _ffe was getting the true value
_ffe = true;
hintc format ["Fire for effect value: %1", _ffe];

if (_debug) then {
diag_log format ["Fire for effect value: %1", _ffe];
};


// Check if _typeofFire = "FFE" then hint

if (_typeofFire == "FFE") then {hint "Fire for effect!"; if (_debug) then {diag_log "if 1 triggered";}}; // The code doesnt pass this point of the code

_ffe = false;
hintc format ["Fire for effect value: %1", _ffe];

if (_debug) then {
diag_log format ["Fire for effect value: %1", _ffe];
};

if (!(_ffe)) then {hint "Fire for Effect Shot!"; if (_debug) then {diag_log "if 2 triggered";}};

if (_debug) then {
diag_log "end debugging";
};

Share this post


Link to post
Share on other sites

Here it is, its says Buffer to small - nowhere to write the data like 100 times


Buffer to small - nowhere to write the data
Buffer to small - nowhere to write the data


=====================================================================
== C:\Program Files\Bohemia Interactive\ArmA 2\arma2.exe
== "C:\Program Files\Bohemia Interactive\ArmA 2\arma2.exe" 
=====================================================================
Exe timestamp: 2010/05/22 11:47:33
Current time:  2010/06/19 14:11:56

Unsupported language English in stringtable
Unsupported language English in stringtable
Unsupported language English in stringtable
Exe version: 1.05.62017


=====================================================================
== C:\Program Files\Bohemia Interactive\ArmA 2\arma2.exe
== "C:\Program Files\Bohemia Interactive\ArmA 2\arma2.exe" -mod=@ace;@acex;@acex_pla;@acex_sm;@bb_units;@cba;@ffaa;@ffaa_pickup_terrorista;@ffa_terroristas_v1.1;@mma;@mma_xeh;@ou_air_beta;@zcommon;@a10_camo;@fastrope -nosplash -winxp -cpuCount=4 
=====================================================================
Exe timestamp: 2010/05/22 11:47:33
Current time:  2010/06/19 14:13:02

Conflicting addon ou_air in 'ou_air_cfg\', previous definition in 'ou_air\'
Unsupported language English in stringtable
Unsupported language English in stringtable
Unsupported language English in stringtable
Updating base class AnimationSources->, by ou_air_cfg\config.bin/cfgVehicles/ou_ch_53d/AnimationSources/
Updating base class MH60S->ou_ch_53d, by ou_air_cfg\config.bin/cfgVehicles/ou_ch_46e/
Updating base class AnimationSources->, by ou_air_cfg\config.bin/cfgVehicles/ou_ch_46e/AnimationSources/
Updating base class ->BulletBase, by ca\weapons\config.bin/CfgAmmo/B_9x18_Ball/
Updating base class ->BulletBase, by ca\weapons\config.bin/CfgAmmo/B_556x45_SD/
Updating base class ->MissileCore, by ca\weapons\config.bin/CfgAmmo/MissileBase/
Updating base class ->MissileBase, by ca\weapons\config.bin/CfgAmmo/M_Stinger_AA/
Updating base class ->Grenade, by ca\weapons\config.bin/CfgAmmo/GrenadeHand/
Updating base class ->CA_Magazine, by ca\weapons\config.bin/CfgMagazines/VehicleMagazine/
Updating base class ->CA_Magazine, by ca\weapons\config.bin/CfgMagazines/HandGrenade/
Updating base class ->Pistol, by ca\weapons\config.bin/cfgWeapons/M9/
Updating base class ->M9, by ca\weapons\config.bin/cfgWeapons/M9SD/
Updating base class ->M16A2, by ca\weapons\config.bin/cfgWeapons/M16A2GL/
Updating base class ->rifle, by ca\weapons\config.bin/cfgWeapons/M24/
Updating base class ->rifle, by ca\weapons\config.bin/cfgWeapons/M240/
Updating base class ->rifle, by ca\weapons\config.bin/cfgWeapons/M249/
Updating base class ->rifle, by ca\weapons\config.bin/cfgWeapons/MP5SD/
Updating base class ->MP5SD, by ca\weapons\config.bin/cfgWeapons/MP5A5/
Updating base class ->rifle, by ca\weapons\config.bin/cfgWeapons/G36a/
Updating base class ->G36a, by ca\weapons\config.bin/cfgWeapons/G36K/
Updating base class ->LauncherCore, by ca\weapons\config.bin/cfgWeapons/Launcher/
Updating base class ->Launcher, by ca\weapons\config.bin/cfgWeapons/Stinger/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_Light/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier2/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_GL/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_Officer/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_SL/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_TL/
Updating base class ->USMC_Soldier_AT_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_LAT/
Updating base class ->USMC_Soldier_AT_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_AT/
Updating base class ->USMC_Soldier_AT_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_HAT/
Updating base class ->USMC_Soldier_AT_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_AA/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_Medic/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_AR/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_Soldier_MG/
Updating base class ->USMC_SoldierS_Sniper, by ca\characters2\config.bin/CfgVehicles/USMC_SoldierS_SniperH/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_SoldierM_Marksman/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_SoldierS/
Updating base class ->USMC_Soldier_Base, by ca\characters2\config.bin/CfgVehicles/USMC_SoldierS_Engineer/
Updating base class ->FR_Base, by ca\characters2\config.bin/CfgVehicles/FR_TL/
Updating base class ->FR_Base, by ca\characters2\config.bin/CfgVehicles/FR_R/
Updating base class ->FR_Base, by ca\characters2\config.bin/CfgVehicles/FR_Marksman/
Updating base class ->FR_Base, by ca\characters2\config.bin/CfgVehicles/FR_Corpsman/
Updating base class ->FR_Base, by ca\characters2\config.bin/CfgVehicles/FR_AR/
Updating base class ->FR_Base, by ca\characters2\config.bin/CfgVehicles/FR_GL/
Updating base class ->FR_Base, by ca\characters2\config.bin/CfgVehicles/FR_Sapper/
Updating base class ->FR_Base, by ca\characters2\config.bin/CfgVehicles/FR_AC/
Updating base class ->HMMWV_Base, by ca\wheeled\config.bin/CfgVehicles/HMMWV_M2/
Updating base class ->HMMWV_Base, by ca\wheeled\config.bin/CfgVehicles/HMMWV_TOW/
Updating base class ->HMMWV_Base, by ca\wheeled\config.bin/CfgVehicles/HMMWV_MK19/
Updating base class ->SkodaBase, by ca\wheeled\config.bin/CfgVehicles/datsun1_civil_1_open/
Updating base class ->Car, by ca\wheeled\config.bin/CfgVehicles/hilux1_civil_1_open/
Updating base class ->Turrets, by ca\wheeled\datsun_armed\config.bin/CfgVehicles/Pickup_PK_base/Turrets/
Updating base class ->MainTurret, by ca\wheeled\datsun_armed\config.bin/CfgVehicles/Pickup_PK_base/Turrets/MainTurret/
Updating base class ->Pickup_PK_base, by ca\wheeled\datsun_armed\config.bin/CfgVehicles/Pickup_PK_GUE/
Updating base class ->Turrets, by ca\wheeled\hilux_armed\config.bin/CfgVehicles/Offroad_DSHKM_base/Turrets/
Updating base class ->MainTurret, by ca\wheeled\hilux_armed\config.bin/CfgVehicles/Offroad_DSHKM_base/Turrets/MainTurret/
Updating base class ->Offroad_DSHKM_base, by ca\wheeled\hilux_armed\config.bin/CfgVehicles/Offroad_DSHKM_Gue/
Updating base class ->Turrets, by ca\wheeled\hilux_armed\config.bin/CfgVehicles/Offroad_SPG9_Gue/Turrets/
Updating base class ->MainTurret, by ca\wheeled\hilux_armed\config.bin/CfgVehicles/Offroad_SPG9_Gue/Turrets/MainTurret/
Updating base class ->FlagCarrierCore, by ca\misc3\config.bin/CfgVehicles/FlagCarrier/
Updating base class Turrets->Turrets, by x\acex_sm\addons\c_sound_veh_armor\config.bin/CfgVehicles/BMP2_Base/Turrets/
Updating base class MainTurret->MainTurret, by x\acex_sm\addons\c_sound_veh_armor\config.bin/CfgVehicles/BMP2_Base/Turrets/MainTurret/
Updating base class RocketPods->Launcher, by x\zeu\addons\cfg_core_ai_engagement\config.bin/CfgWeapons/SPG9/
Updating base class Turrets->Turrets, by x\ace\addons\c_vehicle\config.bin/CfgVehicles/BMP2_Base/Turrets/MainTurret/Turrets/
Updating base class MainTurret->MainTurret, by x\ace\addons\c_vehicle\config.bin/CfgVehicles/AAV/Turrets/MainTurret/
Updating base class Launcher->RocketPods, by x\ace\addons\c_vehicle\config.bin/CfgWeapons/SPG9/
Exe version: 1.05.62017
47.393 (0) XEH: PreInit Started
52.664 (0) XEH: PreInit Finished
0:00:59.579 (0:00:00.500) [x\cba\addons\common\init.sqf:4] MISSINIT: missionName=intro, worldName=utes, isMultiplayer=false, isServer=true
62.211 (0.7) XEH: PostInit Started
65.613 (1.464) XEH: PostInit Finished
0:01:05.614 (0:00:01.464) [x\cba\addons\versioning\versioning.sqf:5] : cba_versioning_versions=["#CBA_HASH#",["cba","ace","acex","acexpla"],[[[0,4,0,97],-1],[[1,1,1,356],-1],[[1,1,1,236],-1],[[1,1,1,19],-1]],[[0,0,0],0]]
131.737 (0) XEH: PreInit Started
137.161 (0) XEH: PreInit Finished
0:02:18.609 (0:00:00.000) [x\cba\addons\common\init.sqf:4] MISSINIT: missionName=SimpleArtillery               ?¯??trikeV2e0, worldName=utes, isMultiplayer=false, isServer=true
138.623 (0) XEH: PostInit Started
142.488 (0) XEH: PostInit Finished
0:02:22.569 (0:00:00.000) [x\cba\addons\versioning\versioning.sqf:5] : cba_versioning_versions=["#CBA_HASH#",["cba","ace","acex","acexpla"],[[[0,4,0,97],-1],[[1,1,1,356],-1],[[1,1,1,236],-1],[[1,1,1,19],-1]],[[0,0,0],0]]
"Starting debug"
"Settings defaults complete"
"Fire for effect switch: false type of fire: none"
"ammo var got the value ARTY_Sh_105_HE"
"type var got the value FFE"
"amount var got the value 10"
"spread var got the value 0"
"roundDelay var got the value 1"
"Fire For Effect Switch: false \nType of Fire: FFE"
"Fire for effect value: true"
"if 1 triggered"
"Fire for effect value: false"
"if 2 triggered"
"end debugging"
539.31 (0) XEH: PreInit Started
544.805 (0) XEH: PreInit Finished
0:09:06.266 (0:00:00.000) [x\cba\addons\common\init.sqf:4] MISSINIT: missionName=SimpleArtillery               ?¯??trikeV2e0, worldName=utes, isMultiplayer=false, isServer=true
546.28 (0) XEH: PostInit Started
548.094 (0) XEH: PostInit Finished
0:09:08.147 (0:00:00.000) [x\cba\addons\versioning\versioning.sqf:5] : cba_versioning_versions=["#CBA_HASH#",["cba","ace","acex","acexpla"],[[[0,4,0,97],-1],[[1,1,1,356],-1],[[1,1,1,236],-1],[[1,1,1,19],-1]],[[0,0,0],0]]
Error in expression <

_battery = _this select 0;
_coords = [getPosASL "remora" select 0, getPosASL r>
 Error position: <getPosASL "remora" select 0, getPosASL r>
 Error getposasl: Type String, expected Object
File C:\Users\User\Documents\ArmA 2\missions\SimpleArtillery               ?´??trikeV2e0.utes\evilarty.sqf, line 12

Share this post


Link to post
Share on other sites
Error position: <getPosASL "remora" select 0, getPosASL r>

Error getposasl: Type String, expected Object

Couldn't see a getPosASL command in your code - it seems to take exception to whatever you've put in there.

Share this post


Link to post
Share on other sites

Yes, assuming 'remora' is an object, just remove the quotes around it. Strings not allowed.

Share this post


Link to post
Share on other sites

Lol. remora is just an internal joke with a friend. But yes, its actually the target.First I made a marker, but then I changed it to a car so I could use the getPosASL. Im going to take the quoptes out and check if it works. Ill post back in a few minutes with any results.

---------- Post added at 05:00 PM ---------- Previous post was at 04:57 PM ----------

Ok, I got confused with the remora target since thats for another code.... why is that what appears in my rpt instead of what the debug of my script? anyway, Im going to check it out and post back the new rpt

---------- Post added at 05:18 PM ---------- Previous post was at 05:00 PM ----------

Ok, I moved the RPT to another folder, deleted everything else on the test map and left only the trigger with the debug code MichaelGER did and runned everything again. This is what the RPT says now.


680.041 (0) XEH: PreInit Started
685.636 (0) XEH: PreInit Finished
0:11:26.896 (0:00:00.000) [x\cba\addons\common\init.sqf:4] MISSINIT: missionName=SimpleArtillery               ?¯??trikeV2e0, worldName=utes, isMultiplayer=false, isServer=true
686.905 (0) XEH: PostInit Started
688.478 (0) XEH: PostInit Finished
0:11:28.483 (0:00:00.000) [x\cba\addons\versioning\versioning.sqf:5] : cba_versioning_versions=["#CBA_HASH#",["cba","ace","acex","acexpla"],[[[0,4,0,97],-1],[[1,1,1,356],-1],[[1,1,1,236],-1],[[1,1,1,19],-1]],[[0,0,0],0]]
"Starting debug"
"Settings defaults complete"
"Fire for effect switch: false type of fire: none"
"ammo var got the value ARTY_Sh_105_HE"
"type var got the value FFE"
"amount var got the value 10"
"spread var got the value 0"
"roundDelay var got the value 1"
"Fire For Effect Switch: false \nType of Fire: FFE"
"Fire for effect value: true"
"if 1 triggered"
"Fire for effect value: false"
"if 2 triggered"
"end debugging"


It keeps stopping at this point:


hintc format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];

I mean it shows the hint but after that it doesnt make anything else.

Share this post


Link to post
Share on other sites

It keeps stopping at this point:


hintc format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];

I mean it shows the hint but after that it doesnt make anything else.

Ok thats strange. The script seems to run til the end because of the debug rpt entries.

The rpt entries are there but the hints are missing.

Maybe the hints just dont get displayed? But no idea why.

Share this post


Link to post
Share on other sites

I don't know how your code looks like at this point, but if something like this is:

if (_ffe) then {hint "Fire for Effect Shot!"};

is still in it, then you might wanna close that statement inside the if-block. And how about some code indentation, which would make it a lot easier to spot syntax errors.

Try:

if (_ffe) then 
{
  hint "Fire for Effect Shot!"[color="Red"];[/color]
};

It's not easy to output a meanigful error message if you've got syntax errors in there.

Share this post


Link to post
Share on other sites
I don't know how your code looks like at this point, but if something like this is:

if (_ffe) then {hint "Fire for Effect Shot!"};

is still in it, then you might wanna close that statement inside the if-block. And how about some code indentation, which would make it a lot easier to spot syntax errors.

Try:

if (_ffe) then 
{
  hint "Fire for Effect Shot!"[color="Red"];[/color]
};

It's not easy to output a meanigful error message if you've got syntax errors in there.

I actually do indent my code. Here is the script without the debug code:


//Simple Artillery Strike v 2.0

//Set default values
//-----------------------------------------

_artilleryTarget 		= "artilleryTarget";	// Main target
_firingMode 			= "NORMAL";		// Normal or Battery One
_ordinance 			= "ARTY_Sh_122_HE";	// Type of ordinance
_typeofFire 			= "none";		// Type of Fire Mission - (FFE, Zone & Sweep, Smoke Screen, etc.)
_amountofRounds 		= 10;			// Number of rounds to be delivered on target
_proximity 			= 6;			// For anti personel ordinance, will explode @ _explosionAltitude value
_ceaseFireSwitch 		= false;		// To order cease fire when you order Fire For Effect
_numberofGuns 			= 6;			// Number of cannons to shoot on Battery One
_spawnHeight 			= 500;			// Ordinance spawn hegiht 
_spawnDelay 			= 60;			// Time for fire mission to splash
_spawnPosition 			= "none";		// Used for different patterns and types of fire missions
_initialDelay 			= 60;			// Initial delay of custom fire missions
_roundDelay 			= 6;			// Delay between rounds
_roundCounter 			= 0;			// Counts number of rounds been shot
_spread				= 100;			// Spread of fire mission
_pattern			= "none";		// tight, spread, scatter, 
_ffe				= false;		// Switch for the Fire for Effect Fire mission
_artilleryStrikePos		= [0,0,0];		// Artillery strike position to spawn bomb and have a correct spread

hint "Setting defaults [COMPLETE]";
sleep 3;

//-----------------------------------------
//Variable Tester
//-----------------------------------------


hintc format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];


//-----------------------------------------


//Read custom values
//-----------------------------------------

{

switch (_x select 0) do {

	case "mode"	      : { _firingMode 	  = _x select 1};

	case "ammo"           : { _ordinance 	  = _x select 1};

	case "type"	      : { _typeofFire 	  = _x select 1};

	case "proximity"      : { _proximity 	  = _x select 1};

	case "guns" 	      : { _numberofGuns   = _x select 1};

	case "initDelay"      : { _initDelay  	  = _x select 1};

	case "roundDelay"     : { _roundDelay 	  = _x select 1};

	case "amount"         : { _amountofRounds = _x select 1};

	case "spread"         : { _spread     	  = _x select 1};

	case "pattern"        : {
		switch (_x select 1) do { 

			// Changes presets according to the type of pattern you choose

			case "tight"   : { _amountofRounds = 10; _spread = 50 ; _roundDelay = 2.2};
			case "spread"  : { _amountofRounds = 12; _spread = 150; _roundDelay = 4  };
			case "scatter" : { _amountofRounds = 16; _spread = 300; _roundDelay = 5  };
			case "harrass" : { _amountofRounds = 8 ; _spread = 100; _roundDelay = 3  };
			case "suppress": { _amountofRounds = 20; _spread = 200; _roundDelay = 3  };
		};
	}; 
};

} forEach _this;

hint "Setting custom Fire Mission [COMPLETE]";
sleep 3;


//-----------------------------------------
//Variable Tester
//-----------------------------------------

hintc format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];

//-----------------------------------------

sleep 2;

_ffe = true;
hintc format ["Fire for effect value: %1", _ffe];

if (_typeofFire == "FFE") then {hint "Fire for effect! 123456789"};

_ffe = false;
hintc format ["Fire for effect value: %1", _ffe];

if (_ffe) then {hint "Fire for Effect Shot!"};

_ffe = true;
if (!(_ffe)) then {hint "Fire for Effect Shot!"};

/* This is the part that will execute the fire mission after the freaking if works.

//Fire Mode and Fire Mission Execution
//-----------------------------------------

_artilleryStrikePos = [getMarkerPos _artilleryTarget select 0, getMarkerPos _artilleryTarget select 1, 100];

for "_x" from 1 to _amountofRounds do {

		//Creates the slected _ammo at the selected _height

		_artilleryStrike = createVehicle [_ordinance, _artilleryStrikePos, [], _spread, "NONE"];

		// Sets direction of the artillery round and velocity

		_artilleryStrike setvectorup [0,9,0.1];

		_artilleryStrike setVelocity [0,0,-100];

		//Delays the code for the selected amount of time

		sleep _roundDelay;
	};

*/

And this is the script with the debugging code of MichaelGER


//Set default values
//-----------------------------------------
_debug = true;

if (_debug) then {
diag_log "Starting debug";
};

_artilleryTarget 		= "artilleryTarget";	// Main target
_firingMode 			= "NORMAL";		// Normal or Battery One
_ordinance 			= "ARTY_Sh_122_HE";	// Type of ordinance
_typeofFire 			= "none";		// Type of Fire Mission - (FFE, Zone & Sweep, Smoke Screen, etc.)
_amountofRounds 		= 10;			// Number of rounds to be delivered on target
_proximity 			= 6;			// For anti personel ordinance, will explode @ _explosionAltitude value
_ceaseFireSwitch 		= false;		// To order cease fire when you order Fire For Effect
_numberofGuns 			= 6;			// Number of cannons to shoot on Battery One
_spawnHeight 			= 500;			// Ordinance spawn hegiht 
_spawnDelay 			= 60;			// Time for fire mission to splash
_spawnPosition 			= "none";		// Used for different patterns and types of fire missions
_initialDelay 			= 60;			// Initial delay of custom fire missions
_roundDelay 			= 6;			// Delay between rounds
_roundCounter 			= 0;			// Counts number of rounds been shot
_spread				= 100;			// Spread of fire mission
_pattern			= "none";		// tight, spread, scatter, 
_ffe				= false;		// Switch for the Fire for Effect Fire mission
_artilleryStrikePos		= [0,0,0];		// Artillery strike position to spawn bomb and have a correct spread

hint "Setting defaults [COMPLETE]";
if (_debug) then {
diag_log "Settings defaults complete";
};
sleep 3;

//-----------------------------------------
//Variable Tester
//-----------------------------------------


hintc format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];

if (_debug) then {
diag_log format ["Fire for effect switch: %1 type of fire: %2",_ffe, _typeofFire];
};


//-----------------------------------------


//Read custom values
//-----------------------------------------

{

switch (_x select 0) do {

	case "mode"	      : { _firingMode 	  = _x select 1; if (_debug) then {diag_log format ["Mode var got the value %1",_x select 1];}};

	case "ammo"           : { _ordinance 	  = _x select 1; if (_debug) then {diag_log format ["ammo var got the value %1",_x select 1];}};

	case "type"	      : { _typeofFire 	  = _x select 1; if (_debug) then {diag_log format ["type var got the value %1",_x select 1];}};

	case "proximity"      : { _proximity 	  = _x select 1; if (_debug) then {diag_log format ["proximity var got the value %1",_x select 1];}};

	case "guns" 	      : { _numberofGuns   = _x select 1; if (_debug) then {diag_log format ["guns var got the value %1",_x select 1];}};

	case "initDelay"      : { _initDelay  	  = _x select 1; if (_debug) then {diag_log format ["initDelayvar got the value %1",_x select 1];}};

	case "roundDelay"     : { _roundDelay 	  = _x select 1; if (_debug) then {diag_log format ["roundDelay var got the value %1",_x select 1];}};

	case "amount"         : { _amountofRounds = _x select 1; if (_debug) then {diag_log format ["amount var got the value %1",_x select 1];}};

	case "spread"         : { _spread     	  = _x select 1; if (_debug) then {diag_log format ["spread var got the value %1",_x select 1];}};

	case "pattern"        : { 
		diag_log format ["pattern var got the value %1",_x select 1];
		switch (_x select 1) do { 

			// Changes presets according to the type of pattern you choose

			case "tight"   : { _amountofRounds = 10; _spread = 50 ; _roundDelay = 2.2};
			case "spread"  : { _amountofRounds = 12; _spread = 150; _roundDelay = 4  };
			case "scatter" : { _amountofRounds = 16; _spread = 300; _roundDelay = 5  };
			case "harrass" : { _amountofRounds = 8 ; _spread = 100; _roundDelay = 3  };
			case "suppress": { _amountofRounds = 20; _spread = 200; _roundDelay = 3  };
		};
	}; 	if (_debug) then {diag_log format ["amount of rounds: %1 spread: %2 rounddelay: %3",_amountofRounds, _spread,  _roundDelay];}
};

} forEach _this;

hint "Setting custom Fire Mission [COMPLETE]";
sleep 3;


//-----------------------------------------
//Variable Tester
//-----------------------------------------

hintc format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];

if (_debug) then {
diag_log format ["Fire For Effect Switch: %1 \nType of Fire: %2", _ffe, _typeofFire];
};

//-----------------------------------------


// Check if _ffe was getting the true value
_ffe = true;
hintc format ["Fire for effect value: %1", _ffe];

if (_debug) then {
diag_log format ["Fire for effect value: %1", _ffe];
};


// Check if _typeofFire = "FFE" then hint

if (_typeofFire == "FFE") then {hint "Fire for effect!"; if (_debug) then {diag_log "if 1 triggered";}}; // The code doesnt pass this point of the code

_ffe = false;
hintc format ["Fire for effect value: %1", _ffe];

if (_debug) then {
diag_log format ["Fire for effect value: %1", _ffe];
};

if (!(_ffe)) then {hint "Fire for Effect Shot!"; if (_debug) then {diag_log "if 2 triggered";}};

if (_debug) then {
diag_log "end debugging";
};

---------- Post added at 05:54 PM ---------- Previous post was at 05:53 PM ----------

I also tried what you told me about semi colon after the hint.

Share this post


Link to post
Share on other sites
I also tried what you told me about semi colon after the hint.

So why is this error still in your script?

if (_typeofFire == "FFE") then {hint "Fire for effect! 123456789"};

if (_ffe) then {hint "Fire for Effect Shot!"};

if (!(_ffe)) then {hint "Fire for Effect Shot!"};

three times? :rolleyes:

I'd also suggest to indent if-blocks too, no matter if they are small enough to be written on one line. It would really help reading (or modifying) your script.

Altough commented out, I'd recommend to use some paranthesis for constructs such as:

_artilleryStrikePos = [getMarkerPos _artilleryTarget select 0, getMarkerPos _artilleryTarget select 1, 100];

Instead of getMarkerPos _artilleryTarget select 0 and need to write getMarkerPos (_artilleryTarget select 0). As a general rule, you should always put some paranthesis around array selection statements or chances are high that you will confuse the interpreter. The thing is, this again is a syntax error and thus the output might be not that helpful/precise.

Sure, one might overdo it with paranthesis like in if (!(_ffe)) then ... which might be written as if (!_ffe) then .... But at least this isn't going to bite you in the ass, hehe. :)

And if this all still fails, might I ask how exactly you are calling/executing this script?

Share this post


Link to post
Share on other sites

Ok, thanks for the tips. the 3 ifs where just to keep changing the value of _ffe and then test it with the ifs. Im calling it through:

 nul = [["ammo","ARTY_Sh_105_HE"],["type","FFE"],["amount",10],["spread",0],["roundDelay",1]] execVM "simple_artillery_strike_v2.0DEBUG.sqf"; 

I will indent everything put the getMarkerPos as you told me, but imo its going to be the same since I have that way of setting up the position of the target and it works perfectly. But in the end i dont lose anything for trying it so Ill try it and will post back. Thanks btw.

---------- Post added at 08:42 PM ---------- Previous post was at 08:13 PM ----------

Ok, I tried something else, i made another script just with 2 vars and 1 if to see if worked, and it did:

_name = "wicked";
_num = 26;

if (_name == "wicked") then {


hint "he is 26"


};

I copy/paste and subst. vars and it didt work, so I added inside the part that changes _typeofFire something else to see if something changed:



	case "type"	      : {

		_typeofFire = _x select 1;

		hint "type of fire set succesfuly! Redirecting in 10 seconds"; 

		sleep 10;



	};

After doing this, guess what, the variable changed to FFE but it doesnt show the hint but its seems to wait the 10 seconds since it takes 10 secinds to show the next

hint "Setting custom Fire Mission [COMPLETE]"; that shows that the switch is complete . This might be a start in the problem.

Share this post


Link to post
Share on other sites

Has anyone come up with a solution or why the if is not working? Ive tried a lot, and believe me, a lot of stuff and it keeps doing the same thing.What I was planning to do is to do the following:

1) After the script defines defaults and passes through the switch, I might pass the variables to another script that will have the "if" to define what kind of artillery support you need. After defining the kind of fire mission, this will call another script for the fire mission, for example smokescreen.sqf or fireforeffect.sqf . Thing is how do I pass the variables from script to script and how do I call a script from inside a script?

2) Make the script so when you call it with the radio triggered trigger (lol), it will add different actions to the player, the player will have access through the different kinds artillery support from this actions. It will be like the options SOM gives you when you call the artillery support but instead of having them in a separate menu, you will have it on the action menu.

What do you think guys?

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  

×