Jump to content
Sign in to follow this  
G4meM0ment

Scripted Mission Objective/Assignment

Recommended Posts

Hi guys,

I keep trying to create my mission and now I'm at the point to create Missions or Objectives for the players to do, my first one is a simple patroling script which is useable for endless mp players.

I know the code is beginners-style but I even don't know the syntax nor what ArmA 2 Scripts can do... and often I notice buggy or very complicated stuff, so I'm happy to have your suggestions.

This is the code:

_spawnArray = ["patrolCityMark1", "patrolCityMark2", "patrolCityMark3", "patrolCityMark4", "patrolCityMark5", "patrolCityMark6"];
_spawn = _spawnArray select (floor (random (count _spawnArray)));

/////////////////////////////////////////////////////////////
//Create the triggers

_trg = createTrigger ["EmptyDetector", (getMarkerPos _spawn)];
_trg setTriggerArea [80,80,100,false];
_trg setTriggerActivation ["WEST", "PRESENT", false];
_trg setTriggerStatements ["this", "", ""];

_trg2 = createTrigger ["EmptyDetector", (getMarkerPos _spawn)];
_trg2 setTriggerArea [45,45,0,false];
_trg2 setTriggerActivation ["RESISTANCE", "NOT PRESENT", false];
_trg2 setTriggerStatements ["this", "overwatch globalChat 'Any more contacts? No? Ok continue patroling. Over.'; deleteMarker 'patrolCityArea'; deleteWaypoint [_enemys, 1];", ""];

_trgc1 = createTrigger ["EmptyDetector", (getMarkerPos "patrolCityMark1")];
_trgc1 setTriggerArea [10,10,50,false];
_trgc1 setTriggerActivation ["WEST", "PRESENT", false];
_trgc1 setTriggerStatements ["this", "deleteMarker 'patrolCheck1';", ""];

_trgc2 = createTrigger ["EmptyDetector", (getMarkerPos "patrolCityMark2")];
_trgc2 setTriggerArea [10,10,50,false];
_trgc2 setTriggerActivation ["WEST", "PRESENT", false];
_trgc2 setTriggerStatements ["this", "deleteMarker 'patrolCheck2';", ""];

_trgc3 = createTrigger ["EmptyDetector", (getMarkerPos "patrolCityMark3")];
_trgc3 setTriggerArea [10,10,50,false];
_trgc3 setTriggerActivation ["WEST", "PRESENT", false];
_trgc3 setTriggerStatements ["this", "deleteMarker 'patrolCheck3';", ""];

_trgc4 = createTrigger ["EmptyDetector", (getMarkerPos "patrolCityMark4")];
_trgc4 setTriggerArea [10,10,50,false];
_trgc4 setTriggerActivation ["WEST", "PRESENT", false];
_trgc4 setTriggerStatements ["this", "deleteMarker 'patrolCheck4';", ""];

_trgc5 = createTrigger ["EmptyDetector", (getMarkerPos "patrolCityMark5")];
_trgc5 setTriggerArea [10,10,50,false];
_trgc5 setTriggerActivation ["WEST", "PRESENT", false];
_trgc5 setTriggerStatements ["this", "deleteMarker 'patrolCheck5';", ""];

_trgc6 = createTrigger ["EmptyDetector", (getMarkerPos "patrolCityMark6")];
_trgc6 setTriggerArea [10,10,50,false];
_trgc6 setTriggerActivation ["WEST", "PRESENT", false];
_trgc6 setTriggerStatements ["this", "deleteMarker 'patrolCheck6';", ""];

////////////////////////////////
//Create enemy units
_enemys = [getMarkerPos _spawn, RESISTANCE, (configFile >> "CfgGroups" >> "Guerrila" >> "BIS_TK_GUE" >> "Infantry" >> "TK_GUE_Patrol")] call BIS_fnc_spawnGroup;
_members = units _enemys;
{_x setVehicleInit "this disableAI 'AUTOTARGET'; this disableAI 'TARGET';"} forEach _members;
RESISTANCE setFriend [WEST,0]; 

//////////////////////////////////////////////
//Create an waypoint to bring more dynamic
_wp = _enemys addWaypoint [getMarkerPos _spawn, 20];
_wp setWaypointType "GUARD";
_wp setWaypointBehaviour "AWARE";

///////////////////////////////////////////
//Create the marker on the map
_marker = createMarker ["patrolCityArea", (getMarkerPos _spawn)];
_marker setMarkerShape "ELLIPSE";
_marker setMarkerBrush "FDiagonal";
_marker setMarkerColor "ColorRed";
_marker setMarkerSize [40, 40];
_marker setMarkerText "Possible Militia Contact";

_marker1 = createMarker ["patrolCheck1", (getMarkerPos "patrolCityMark1")];
_marker1 setMarkerType "Dot";
_marker1 setMarkerColor "ColorRed";
_marker1 setMarkerText "Patrol checkpoint I";

_marker2 = createMarker ["patrolCheck2", (getMarkerPos "patrolCityMark2")];
_marker2 setMarkerType "Dot";
_marker2 setMarkerColor "ColorRed";
_marker2 setMarkerText "Patrol checkpoint II";

_marker3 = createMarker ["patrolCheck3", (getMarkerPos "patrolCityMark3")];
_marker3 setMarkerType "Dot";
_marker3 setMarkerColor "ColorRed";
_marker3 setMarkerText "Patrol checkpoint III";

_marker4 = createMarker ["patrolCheck4", (getMarkerPos "patrolCityMark4")];
_marker4 setMarkerType "Dot";
_marker4 setMarkerColor "ColorRed";
_marker4 setMarkerText "Patrol checkpoint IV";

_marker5 = createMarker ["patrolCheck5", (getMarkerPos "patrolCityMark5")];
_marker5 setMarkerType "Dot";
_marker5 setMarkerColor "ColorRed";
_marker5 setMarkerText "Patrol checkpoint V";

_marker6 = createMarker ["patrolCheck6", (getMarkerPos "patrolCityMark6")];
_marker6 setMarkerType "Dot";
_marker6 setMarkerColor "ColorRed";
_marker6 setMarkerText "Patrol checkpoint VI";

////////////////////////////////////////////////////////
//Check if triggers are activated
_run = true;
_trgB = false;
_trgc1B = false;
_trgc2B = false;
_trgc3B = false;
_trgc4B = false;
_trgc5B = false;
_trgc6B = false;
_checkCount = 6;
while{_run} do {
if ((triggeractivated _trg) AND (!_trgB)) then {
	hint "Debug: Gegner aktiv!"; 
	{_x enableAI 'AUTOTARGET'; _x enableAI 'TARGET';} forEach _members;
	_trgB = true;
};

if ((triggeractivated _trgc1) AND (!_trgc1B)) then {
	_checkCount = _checkCount - 1;
	hint format["Debug: getriggerd: ",_checkCount]; 
	_trgc1B = true;
};

if ((triggeractivated _trgc1) AND (!_trgc2B)) then {
	_checkCount = _checkCount - 1;
	hint format["Debug: getriggerd: ",_checkCount];
	_trgc2B = true;
};

if ((triggeractivated _trgc1) AND (!_trgc3B)) then {
	_checkCount = _checkCount - 1;
	hint format["Debug: getriggerd: ",_checkCount];
	_trgc3B = true;
};

if ((triggeractivated _trgc1) AND (!_trgc4B)) then {
	_checkCount = _checkCount - 1;
	hint format["Debug: getriggerd: ",_checkCount];
	_trgc4B = true;
};

if ((triggeractivated _trgc1) AND (!_trgc6B)) then {
	_checkCount = _checkCount - 1;
	hint format["Debug: getriggerd: ",_checkCount];
	_trgc6B = true;
};

if (_checkCount == 0) then {hint "Mission finished"; overwatch globalChat 'Good work, it seems the city is save for the moment. Return to base now.'; _run = false;};
sleep 3;
};

The stuff which isn't working is:

1. The counter won't count down I guess, because the if(checkCount == 0) statement doesn't ever trigger....

2. Also the 2nd Trigger won't activate because the Marker I created which should be deleted than stays.

3. I'm not realy sure but I think the script don't works too which sets the AI disabled/enabled.

AND could someone please explain these "head"- messages for example "Battlemage 1-1: OK good work soldiers do now...." which are displayed in missions or in the campaign because I don't know how to send them in the right way I only read something about setGroupID ["Battlemage"]; but I used it wrong I guess....

Thank you very much for your help, this is a awesome community :D

Share this post


Link to post
Share on other sites

Ok May I need to show the lines where the code for the problems are located:

1. Here I create _checkCount as int with size 6, and for every objective I use this if statement to count it -1.

Note: I define _run above as true;

_checkCount = 6;
while{_run} do {
if ((triggeractivated _trgc1) AND (!_trgc1B)) then {
	_checkCount = _checkCount - 1;
	hint format["Debug: getriggerd: ",_checkCount]; 
	_trgc1B = true;
};
if (_checkCount == 0) then {hint "Mission finished"; overwatch globalChat 'Good work, it seems the city is save for the moment. Return to base now.'; _run = false;};
sleep 3;

2. Here I create the trigger which should check if any resistance (Takistan Guerrila) in the area, and if true the marker 'patrolCityArea' should be deleted, but it stays.

_trg2 = createTrigger ["EmptyDetector", (getMarkerPos _spawn)];
_trg2 setTriggerArea [45,45,0,false];
_trg2 setTriggerActivation ["RESISTANCE", "NOT PRESENT", false];
_trg2 setTriggerStatements ["this", "overwatch globalChat 'Any more contacts? No? Ok continue patroling. Over.'; deleteMarker 'patrolCityArea'; deleteWaypoint [_enemys, 1];", ""];

3. Now I try to create untis (it works) and I wanna disable the AI for every unit

_enemys = [getMarkerPos _spawn, RESISTANCE, (configFile >> "CfgGroups" >> "Guerrila" >> "BIS_TK_GUE" >> "Infantry" >> "TK_GUE_Patrol")] call BIS_fnc_spawnGroup;
_members = units _enemys;
{_x setVehicleInit "this disableAI 'AUTOTARGET'; this disableAI 'TARGET';"} forEach _members;

And if the other trigger is activated, which triggers if WEST is present the AI will be activated.

	if ((triggeractivated _trg) AND (!_trgB)) then {
	hint "Debug: Gegner aktiv!"; 
	{_x enableAI 'AUTOTARGET'; _x enableAI 'TARGET';} forEach _members;
	_trgB = true;
};

Share this post


Link to post
Share on other sites

Ok... so no one got any idea, whats the problem? Is the problem ununderstandable? Or do I need to be more specific?

Sry for pushing but I need help with this, I've got no clue what could be wrong here.... because there is also no error in the .RPT file.

Share this post


Link to post
Share on other sites

You should just upload the mission as is for trouble shooting, looking at that many code snippets makes it tough to figure out what the problem is when it might be something you haven't even mentioned perhaps.

Share this post


Link to post
Share on other sites
You should just upload the mission as is for trouble shooting, looking at that many code snippets makes it tough to figure out what the problem is when it might be something you haven't even mentioned perhaps.

Ok, I'll upload the objective code only so you can execute it in any init, with markers, because the problem is it's a very big mission I working on with a friend and should'nt be released now:

Only to make it easier you just need 6 markers named like in the first line of the code ("patrolCityMark1"). I'm sorry if that is a little work, but our mission needs to be secret :P

Scripted Objective Download

By the way the code on top is the whole code.... I only created these little parts because I thought maybe no one wants to browse threw my whole script :P

Share this post


Link to post
Share on other sites

You do realize you uploaded the exact same thing that was already on this page?

How is this supposed to help in any way?

Share this post


Link to post
Share on other sites
You do realize you uploaded the exact same thing that was already on this page?

How is this supposed to help in any way?

I could give you my init and mission sqm as well if you want.

Download with mission.sqm and init.sqf

If that helps you...

Note: In the init are wrong paths to files which aren't included in the downloadable zip package, you need to delte/change them (for example the path for the Zargabad.sqf file. And the name of the mission is normaly "NEW" so you also need to change the directory name from "The_Mission.Zargabad" to "NEW.Zargabad" sorry for this, but else I would had some problems with saving this.

Thanks for your help.

Share this post


Link to post
Share on other sites

Just a few questions:

Seeing that none of those markers and triggers are actually dynamically placed, why don't you just create them in the editor? This would probably prevent you from running into a shitload of issues whenn running this on a server.

Same for the enemy group, who will anyway always spawn in the same place.

You have around 25 lines of code to spawn markers on top of preexisting markers: is that really necessary?

Then you have a long loop that's gonna check every frame if one particular trigger has been triggered, which is exactly what a trigger does, right? That's redundant.

At that moment, if one of your If checks is verified, your checkcount should be equal to 0 after about 6 frames displayed.

I believe you should lay down a clear plan of what you're trying to achieve, and, at first, always use the simplest way to achieve that.

The way I'd probably go about this would be to lay down the markers and triggers in the editor.

Then have them triggers execute a script/function to do what needs to be done when activated only.

Share this post


Link to post
Share on other sites
Just a few questions:

Seeing that none of those markers and triggers are actually dynamically placed, why don't you just create them in the editor? This would probably prevent you from running into a shitload of issues whenn running this on a server.

Same for the enemy group, who will anyway always spawn in the same place.

You have around 25 lines of code to spawn markers on top of preexisting markers: is that really necessary?

Then you have a long loop that's gonna check every frame if one particular trigger has been triggered, which is exactly what a trigger does, right? That's redundant.

At that moment, if one of your If checks is verified, your checkcount should be equal to 0 after about 6 frames displayed.

I believe you should lay down a clear plan of what you're trying to achieve, and, at first, always use the simplest way to achieve that.

The way I'd probably go about this would be to lay down the markers and triggers in the editor.

Then have them triggers execute a script/function to do what needs to be done when activated only.

The mission is a mission with a lot of objectives and this for example should be spawned after a certain time and and if some conditions are finished, I only sended you the stuff which is necesarry to see what I did, we have a whole bunch of more scripts for missions, events, etc. And we don't want a map full of stuff because this could cause lag, I think, also before this mission is triggered, another should be able to work in Zargabad and a lot of triggers which have a lot of stuff in its init line to check if the mission is allowed to be made won't help. What you said about the dynamic placed stuff, I didn't found a way to spawn them with a kind of spawn area/radius.

Share this post


Link to post
Share on other sites

ya know, i kinda have to agree with BlackMamb. it looks as if your taking the hard way about this. is it possible you could use the GAME LOGIC waypoints with the AND/OR conditions to meet your needs ? i have a few smaller missions that have a great deal of possible outcomes for the objective depending on what happens and its all done thru the game logic waypoint conditions that check then activate whats needed to. it would be a lot easier that way instead of creating everything thru 1 huge script.

Share this post


Link to post
Share on other sites
ya know, i kinda have to agree with BlackMamb. it looks as if your taking the hard way about this. is it possible you could use the GAME LOGIC waypoints with the AND/OR conditions to meet your needs ? i have a few smaller missions that have a great deal of possible outcomes for the objective depending on what happens and its all done thru the game logic waypoint conditions that check then activate whats needed to. it would be a lot easier that way instead of creating everything thru 1 huge script.

Ok, if that also works for an big mission which should run about 12 to 24 h and have up to 64 players playing, and about 50 + playable missions and submissions.

Can you explain me that gamelogic waypoints? Or is there an good tutorial anywhere?

Share this post


Link to post
Share on other sites

unfortunatly there isnt a lot of info about the game logic waypoints. it's basically just a way to make an optional action/event/whatever. u can group and sync triggers to logic waypoints to get the specific things depending on waypoint conditions. kind of think of it as a flow chart (did this happen? - go to this), did that happen? go to that),(did this, this, and this happen but not that?- go to this) and so on.. not sure if it would suit your needs, was just a question if it would help make thing easier for ya.

Share this post


Link to post
Share on other sites
unfortunatly there isnt a lot of info about the game logic waypoints. it's basically just a way to make an optional action/event/whatever. u can group and sync triggers to logic waypoints to get the specific things depending on waypoint conditions. kind of think of it as a flow chart (did this happen? - go to this), did that happen? go to that),(did this, this, and this happen but not that?- go to this) and so on.. not sure if it would suit your needs, was just a question if it would help make thing easier for ya.

I'll have a try with that thank you, but anyway I think its easier to have a script which spawns these items and delete them after finishing, because in the map that would be very confusing at least if there would be so much items, and item names. Isn't there any error in my script or didn't you even had a look at it, because you told me about gamelogic and placing in mission editor?

Sorry if that sounds kind of reproachfully, it shouldn't :p

Share this post


Link to post
Share on other sites
In the init are wrong paths to files which aren't included in the downloadable zip package, you need to delte/change them (for example the path for the Zargabad.sqf file ... I only sent you the stuff which is necessary to see what I did, we have a whole bunch of more scripts for missions, events, etc.

I will never ask someone to upload "just part" of a mission. If I ask you to upload your mission I mean the whole mission because often that "whole bunch of more scripts" is where the problem will lay, not in whatever snippet of stuff the poster had included in their first post.

As BlackMamba said, there's probably a way to get rid of most/all of your other stuff by doing everything a different way from scratch. It's impossible to give too much information about a problem, so even if you think something isn't relevant, include it anyway because it just might be. :)

Share this post


Link to post
Share on other sites
I will never ask someone to upload "just part" of a mission. If I ask you to upload your mission I mean the whole mission because often that "whole bunch of more scripts" is where the problem will lay, not in whatever snippet of stuff the poster had included in their first post.

As BlackMamba said, there's probably a way to get rid of most/all of your other stuff by doing everything a different way from scratch. It's impossible to give too much information about a problem, so even if you think something isn't relevant, include it anyway because it just might be. :)

Ok here is my complete mission, finally ^^ I hope it will help :p

Download

Share this post


Link to post
Share on other sites

if it was that big maybe they're still playing it :p. or maybe someones rebuilding it for you, either way Im sure someone will get back to you soon. kylania is very knowledgeable and helpfull also he has a very good website that has taught me alot about building missions in arma.

Share this post


Link to post
Share on other sites

Could you explain again what is it that we need to do / what fails to be done?

There's no briefing, so I took a Littlebird and went to check all patrols points in order (the order is quite odd, by the way).

Every patrol dot marker disappeared when i got there.

I had some hints at some points, but they're not in a language that I can understand, so I had basically no idea what was happening.

You debug itself is bugged, you forgot to add the %1 in your hints.

Edited by BlackMamb

Share this post


Link to post
Share on other sites

I think the problems were that the area marker wasn't being cleared and there's a count down of triggers left that wasn't working. I took a quick look at it last night, but was too busy to do much tinkering.

Share this post


Link to post
Share on other sites

The coutdown is messed up. I already stated that in one of my first messages. It gets down to 0 after a few seconds as soon as you activate one trigger.

Regarding the markers, as I said, markers are created on top of markers, which seems useless.

And I didn't find anything in the script that would try to remove that area Marker.

Share this post


Link to post
Share on other sites
The coutdown is messed up. I already stated that in one of my first messages. It gets down to 0 after a few seconds as soon as you activate one trigger.

Regarding the markers, as I said, markers are created on top of markers, which seems useless.

And I didn't find anything in the script that would try to remove that area Marker.

Can you exlpain me why? Because I used this boolean to check if it has been already counted.

Share this post


Link to post
Share on other sites

Huh. You're right.

Yet it still goes down immediately, but actually stops at 1.

Let me check that again.

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  

×