Jump to content
Sign in to follow this  
eggbeast

undercover spy - need syntax error spotting

Recommended Posts

Hiya

After 16 hours of struggling today I've almost cracked a working spy who can pass by enemy checkpoints and then assassinate them or plant bombs / mines or use laser designators - it's ALMOST there.

I just need to debug this code:

_player = player;
_loop=0;
_weaponclass = "";
_player setcaptive false;
_hideweaponon = false;
_drawweaponon = false;

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
if (not (alive _player)) then {_player setcaptive false;loop=1;};

if (_spyactive == 1) and (_hideweaponon (false)) then
{
	_player removeAction _actionId9;
	_actionId9 = _player addAction ["Hide Weapon", "actions\spy\hidew.sqf",[_this,0],1, false,  true,"test2"];
	_hideweaponon = true;
};

sleep 0.1;

if (_spyactive == 3) and (_drawweaponon (false)) then
{
	_player removeAction _actionId9;
	_actionId9 = _player addAction ["Draw Weapon", "actions\spy\draww.sqf",[_this,0],1, false, true,"test2"];
	_drawweaponon = true;
};

_weaponclass = currentWeapon _player;
sleep 0.1;
hint format["weapon type: %1",_weaponclass];

//monitors spy - if no weapon is drawn then spy is concealed
if (_spyactive == 3) and (_weaponclass =="") then
{
	_player setcaptive true;
	hint "you are concealed";
};

_nearbyenemy = (position _player) nearEntities [["Man","Air","Car","Motorcycle","Tank"],15];
sleep 0.1;
hint format["enemies: %1",(count _nearbyenemy)];

//monitors spy - if a weapon is drawn and enemies are within 15m then spy is discovered
if (captive _player) and (_weaponclass !="") and (count _nearbyenemy >1) then
{
	_player setcaptive false;
	hint "The alarm has been raised!";
};
sleep 0.1;

//monitors spy - if NO weapon is drawn but a large number of enemies are within 15m then spy is discovered
if (captive _player) and (count _nearbyenemy >12) then
{
	_player setcaptive false;
	hint "The alarm has been raised!";
};

};

if (_spyactive == 1) and (_hideweaponon (false)) then

keeps coming up with "missing )" and I have no idea why

any thoughts?

Edited by eggbeast

Share this post


Link to post
Share on other sites

try squint from Mac

Share this post


Link to post
Share on other sites

_player = player;
_loop=0;
_weaponclass = "";
_player setcaptive false;
_hideweaponon = false;
_drawweaponon = false;

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
if (not (alive _player)) then {_player setcaptive false;loop=1;};

if ((_spyactive == 1) and (_hideweaponon (false))) then
{
	_player removeAction _actionId9;
	_actionId9 = _player addAction ["Hide Weapon", "actions\spy\hidew.sqf",[_this,0],1, false,  true,"test2"];
	_hideweaponon = true;
};

sleep 0.1;

if ((_spyactive == 3) and (_drawweaponon (false))) then
{
	_player removeAction _actionId9;
	_actionId9 = _player addAction ["Draw Weapon", "actions\spy\draww.sqf",[_this,0],1, false, true,"test2"];
	_drawweaponon = true;
};

_weaponclass = currentWeapon _player;
sleep 0.1;
hint format["weapon type: %1",_weaponclass];

//monitors spy - if no weapon is drawn then spy is concealed
if ((_spyactive == 3) and (_weaponclass =="")) then
{
	_player setcaptive true;
	hint "you are concealed";
};

_nearbyenemy = (position _player) nearEntities [["Man","Air","Car","Motorcycle","Tank"],15];
sleep 0.1;
hint format["enemies: %1",(count _nearbyenemy)];

//monitors spy - if a weapon is drawn and enemies are within 15m then spy is discovered
if ((captive _player) and (_weaponclass !="") and (count _nearbyenemy >1)) then
{
	_player setcaptive false;
	hint "The alarm has been raised!";
};
sleep 0.1;

//monitors spy - if NO weapon is drawn but a large number of enemies are within 15m then spy is discovered
if ((captive _player) and (count _nearbyenemy >12)) then
{
	_player setcaptive false;
	hint "The alarm has been raised!";
};

};

;)

Share this post


Link to post
Share on other sites

thanks guys

ok i got it all working now

sample mission

http://109.70.148.244/gits/Arma/GITSEvolutionSahraniv2.Sara.pbo

requires a few mods listed here:

http://forums.bistudio.com/showthread.php?t=97573&page=2

but you can probably implement this from the code anyway - i'm gonna perfect it and then add it to all my evolution missions

UPDATED 24 March - mostly working well - easy to adapt forotherswanting to try this approach in their missions

in mission.sqm

1, make a civ unit SIDE WEST

		class Item6
	{
		side="WEST";
		class Vehicles
		{
			items=1;
			class Item0
			{
				position[]={9870.5166,139.995,10003.581};
				azimut=92.233902;
				special="NONE";
				id=52;
				side="WEST";
				vehicle="TK_CIV_Takistani04_EP1";
				player="PLAY CDG";
				leader=1;
				skill=0.60000002;
				text="eng15";
			};
		};
	};

2, make a trigger near his spawn point (called fahne)

		class Item64
	{
		position[]={4168.4155,0.44805738,599.65723};
		a=0;
		b=0;
		repeating=1;
		age="UNKNOWN";
		expCond="Player distance Fahne < 10 && player == eng15";
		expActiv="ID_Beamna = Player addAction [""~Go Undercover"",""actions\spy\makespy.sqs""]";
		expDesactiv="Player removeAction ID_Beamna";
		class Effects
		{
		};
	};

makespy code:

if (not (local player)) exitwith {};

//enable later
if (Spymade == 1) exitwith {};

_player = player;

EGG_spyactive = 0;

//if (Player distance fahne > 10) then {exitwith "Your spy uniform is at the main ammo crate"};

BIS_EVO_pallammo = ["pipebomb","pipebomb","BAF_ied_v4","BAF_ied_v2","pipebomb","mine","HandGrenade_East","HandGrenade_East","SmokeShellOrange","Laserbatteries","8Rnd_9x18_MakarovSD","8Rnd_9x18_MakarovSD","8Rnd_9x18_MakarovSD","8Rnd_9x18_MakarovSD","8Rnd_9x18_MakarovSD","8Rnd_9x18_MakarovSD","8Rnd_9x18_MakarovSD","8Rnd_9x18_MakarovSD"];// The players default load out
BIS_EVO_pweapons = ["MakarovSD","Laserdesignator","NVGoggles"]; // The players default load out

removeAllWeapons _player;
{_player addmagazine _x} forEach BIS_EVO_pallammo;
{_player addweapon _x} forEach BIS_EVO_pweapons;

if (count weapons _player > 5) then
{
 private['_type', '_muzzles'];

 _type = ((weapons _player) select 5);
 // check for multiple muzzles (eg: GL)
 _muzzles = getArray(configFile >> "cfgWeapons" >> _type >> "muzzles");

 if (count _muzzles > 1) then
 {
   _player selectWeapon (_muzzles select 0);
 }
 else
 {
   _player selectWeapon _type;
 };
};

//_player selectweapon (handgun _player);

EGG_spyactive = 1;
Spymade = 1;
_monitor = [] execVM "actions\spy\hidden.sqf"; 

hidden code:

_player = player;
//_loop=0;
_weaponclass = "";
_weaponcount =0;
_alarm = false;
_player setcaptive false;
EGG_hideweaponon = false;
EGG_drawweaponon = false;
EGG_spyactive = 1;
EGG_hidetotal = 6;

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{

//reset on death

if (not (alive _player)) then 
{
	_player setcaptive false;
	_player removeAction EGG_actionId9;
	_loop=1;
};

//add HIDE WEAPON action

if (EGG_spyactive == 1 and ! EGG_hideweaponon and EGG_hidetotal >0) then
{
	EGG_actionId9 = _player addAction ["Hide Weapon", "actions\spy\hidew.sqf",[_this,0],1, false,  true,"test2"];
	EGG_hideweaponon = true;
};
sleep 0.1;

//add DRAW WEAPON action

if (EGG_spyactive == 3 and ! EGG_drawweaponon) then
{
	EGG_actionId9 = _player addAction ["Draw Weapon", "actions\spy\draww.sqf",[_this,0],1, false, true,"test2"];
	EGG_drawweaponon = true;
};

_weaponcount = (count weapons _player)-5;//for items
_weaponclass = currentWeapon _player;
//	hintsilent format["weapon type: %1",_weaponclass];
//	hintsilent format["weapon count: %1",_weaponcount];
sleep 0.1;

//monitors spy - if HIDE WEAPON action and no weapon is drawn then spy is concealed

if (EGG_spyactive == 3 and _weaponcount <1 and _weaponclass =="" and !(captive _player) ) then 
{
	_player setcaptive true;
	hintsilent "you are concealed";
};

//monitor nearby enemies (within 15m)

_nearbytargets = [];
_nearbyenemy = 0;
_countnear =0;
_nearbytargets = _player nearTargets 15;//15m from player
sleep 0.1;
_countnear = count _nearbytargets;
_i = 0;
while {_countnear >0 and _i < _countnear} do 
{
	if (((_nearbytargets select _i) select 2) == EAST) then {_nearbyenemy = _nearbyenemy +1};
	_i = _i + 1;
};

//warn when enemy numbers increase

if ( (captive _player) and (_nearbyenemy >2) ) then 
{
	hintsilent "Enemy patrol coming!";
};
//hintsilent format["enemies: %1",_nearbyenemy];

//monitors spy - if a weapon is drawn and enemies are within 15m then spy is discovered

if ( (captive _player) and (_nearbyenemy >0) and (_weaponcount >0) and (!_alarm) ) then {_alarm = true};

//monitors spy - if NO weapon is drawn but a large number of enemies are within 15m then spy is discovered

if (captive _player and _nearbyenemy >8 and (!_alarm) ) then {_alarm = true};

//monitors spy - if he gets in a vehicle with enemy nearby then spy is discovered

if (captive _player and _nearbyenemy >1 and vehicle _player !=_player and (!_alarm) ) then {_alarm = true};
sleep 0.1;

if (_alarm and captive _player) then
{
	_player setcaptive false;
	hintsilent "The alarm has been raised!";
	_alarm = false;
	EGG_hidetotal = EGG_hidetotal -1;
	sleep 0.2;
	hintsilent format["Hides remaining: %1",EGG_hidetotal];
};

//monitors spy - if he gets in a vehicle without enemy nearby then his cover is blown but no alarm is sounded

if (captive _player and _nearbyenemy <1 and vehicle _player !=_player ) then 
{
	_player setcaptive false;
	hintsilent "Your cover is blown";
	sleep 0.2;
};

};

_player removeAction EGG_actionId9;
EGG_spyactive = 0;
Spymade = 0;
exit

hidew code

_player = player;

_pweapon = "";
_nearbytargetsb = [];
_nearbyenemyb = 0;
_countnearb = 0;
_nearbytargetsb = _player nearTargets 15;
sleep 0.1;
_countnearb = count _nearbytargetsb;
_k = 0;
while {_countnearb >0 and _k < _countnearb} do 
{
if (((_nearbytargetsb select _k) select 2) == EAST) then {_nearbyenemyb = _nearbyenemyb +1};
_k = _k + 1;
};

//hintsilent format["enemies2: %1",_nearbyenemyb];

if (_nearbyenemyb >=1) then {hintsilent "Enemies nearby - You must hide before you can conceal your weapon";
} else {

if ( (primaryWeapon _player) != "") then
{
	_pweapon = (primaryWeapon _player);
	_player action ["dropWeapon", _player, _pweapon];
};

BIS_EVO_pallammo = magazines _player;
BIS_EVO_pweapons = weapons _player;
removeAllWeapons _player;
_player action ["handGunOff", _player]; 
EGG_hideweaponon = false;
_player removeAction EGG_actionId9;
EGG_spyactive = 3;
sleep 0.5;
};

draww code

_player = player;

{_player addmagazine _x} forEach BIS_EVO_pallammo;
{_player addweapon _x} forEach BIS_EVO_pweapons;
_player removeAction EGG_actionId9;


if (count weapons _player > 5) then
//first 5 weapons are actually items

{
 private['_type', '_muzzles'];

 _type = ((weapons _player) select 5);//was 0
 // check for multiple muzzles (eg: GL)
 _muzzles = getArray(configFile >> "cfgWeapons" >> _type >> "muzzles");

 if (count _muzzles > 1) then
 {
   _player selectWeapon (_muzzles select 0);
 }
 else
 {
   _player selectWeapon _type;
 };
};
//_player selectweapon (handgun _player);
_player action ["WeaponInHand",_player];
EGG_drawweaponon = false;
EGG_spyactive = 1;

you can now:

spawn as a civ

select "go undercover" at the respawn point

this will give you a load of useful spy stuff (silent pistol, IED's mines etc)

it adds an action "hide weapon"

if there are no enemies about you can hide your weapon

this makes you a "captive" so small numbers of enemies don't engage you, BUT you have no weapons ready

it also enables the action "Draw Weapon" - if you do this with an enemy near, the alarm is raised and enemies will engage you

if you do not draw weapon but you walk near too many enemies then the alarm is raised

if you get in a vehicle with enemies near, the alarm is raised

if the alarm is raised 6 times then you lose the ability to hide

it needs a bit ofwork wo make it really good, but it's a start hey?

spy3.jpg

Edited by eggbeast

Share this post


Link to post
Share on other sites

we're on it now mate

filter for GITS but you need the mods for sahrani etc as above

will port it into the rest of evo once we debug it

im off for a wander through the enemy city now with my silenced pistol and IED's and mines lol

and a beer o fcourse!

Share this post


Link to post
Share on other sites

works pretty well, but as it stands it's a mission breaker - makes it too easy.

gonna play with:

a) setting a budget of time you can be undercover (say 3 mins max) so you want to only use it when absolutely necessary

b) set a max time you can be undercover (say 20 secs) before it defaults off

c) make it easier for enemy to rumble you - maybe have 5 enemies within 15m being enough

d) make it so enemy vehicles spot you instantly

e) block your access to non-civ vehicles

etc

at least we proved it was theoretically possible - so many threads got caught up trying to change the player into civ clothing... which is much harder e.g.

http://forums.bistudio.com/showthread.php?t=93384

http://forums.bistudio.com/showthread.php?t=108145

http://forums.bistudio.com/showthread.php?t=107485

http://forums.bistudio.com/showthread.php?t=77118

http://forums.bistudio.com/showthread.php?t=111907

http://forums.bistudio.com/showthread.php?t=111723

etc

Edited by eggbeast

Share this post


Link to post
Share on other sites

Some ideas:

- a guard bumping into you checks your fake ID. everytime your ID is checked theres a greater chance your cover is blown. you get a msg giving you a hint how good your cover ID still is:

("guard looks calm", "guard raises eyebrow", "guard freezes & checks another time", "guard looks suspicious") - after that last msg you known next time you'll be shot.

- somewhere outside the city is an informant with a van 'selling' you a new fake ID, but it costs score-points. this forces players to leave the area and start over until they run out of score.

Share this post


Link to post
Share on other sites

ok a problem I'm having with this:

I want my spy to have a handgun only

he may pick up a primary weapon but then have to drop it as he can't conceal it

I have searched eveywhere and all through the wikis etc

currentweapon

http://community.bistudio.com/wiki/currentWeapon

slot configs

http://community.bistudio.com/wiki/CfgWeapons_Config_Reference

primaryweapon

http://community.bistudio.com/wiki/primaryWeapon

secondaryweapon

http://community.bistudio.com/wiki/secondaryWeapon

when i removeweapons and then addweapons the pistol appears in his handbut he has to press F to change fire mode to bring the pistol up.

as a result, the trigger that checks if he has a weapon does not engage...

ithe pistol is often referred to as a "HandGun" but nowehere do I see this in the wikis etc.

putting it simply, how can I make this work?

_player = player;

{_player addmagazine _x} forEach BIS_EVO_pallammo;
{_player addweapon _x} forEach BIS_EVO_pweapons;
//adds a makarovsd and ammo etc

_player removeAction EGG_actionId9;

if (count weapons _player > 0) then
{
 private['_type', '_muzzles'];

 _type = ((weapons _player) select 0);
 // check for multiple muzzles (eg: GL)
 _muzzles = getArray(configFile >> "cfgWeapons" >> _type >> "muzzles");

 if (count _muzzles > 1) then
 {
   _player selectWeapon (_muzzles select 0);
 }
 else
 {
   _player selectWeapon _type;
 };
};
//_player selectweapon (handgun _player);
//doesn't work -maybe use secondary?

see this?

_type = ((weapons _player) select 0);

what does weapons _player return?

the wiki does not cover this for a player vs a vehicle

my guess is it returns

["name of primaryweapon","name of secondaryweapon1 e.g. launcher","name of secondaryweapon2 e.g. pistol"]

so if you just had a pistol would it return

["","","name of secondaryweapon2 e.g. pistol"]

meaning that _type select 2 would be the pistol?

---------- Post added at 02:58 PM ---------- Previous post was at 01:07 PM ----------

ok i see that

array weapons = all weapons and items

array items = all items

but is there a way to get the actual weapons that a player has (e.g. rifle, launcher, pistol)?

I'm working on a nested routin atthe moment that gets weapons and then takes out all the items one by one, leaving only the guns... but it can't be this hard surely?

Edited by eggbeast

Share this post


Link to post
Share on other sites

sorted it - the 5 items the unit has (that are not weapons as you and I know them) go first into the array, so the array has to use weapons select 6 to get the first real weapon

loads of dev done on the spy today and its really coming along well

you can find the mission here:

http://forums.bistudio.com/showthread.php?t=97573&page=2

Share this post


Link to post
Share on other sites

ok i updated and tested it a lot

http://forums.bistudio.com/showpost.php?p=1879435&postcount=5

this post now has the updated code in it, and the mission has been updated too

it works a treat and is quite a challenging role to play

the attachable satchels here:

http://www.armaholic.com/page.php?id=9908

work really well with it, as do the BAF IED's

infiltration squad member - SPY - in action:

sneaking up on enemy

http://i162.photobucket.com/albums/t247/eggbeast/spy1.jpg

the aftermath

spy3.jpg

Edited by eggbeast

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  

×