Jump to content
Sign in to follow this  
jakeplissken

Domination styled script. Need help with the syntax and variables.

Recommended Posts

Hello. I have created this script that will spawn AI and a marker at a random AO. I have it mostly working, but I need help with the task completion and the setSimpleTaskDescription. How do I include the variable _spawn in the name and description of the task like I have with the hint?

/////////////////////////////////////////////////////////
// Randomize placement of a group within several spots
/////////////////////////////////////////////////////////

_spawn = ["Sofia","Molos","Kavala","Negades","Pyrgos","Selekano","Panagia","Feres","Panochori","Syrta","Frini","Rodopoli"] call bis_fnc_selectRandom;

hint format["AAF forces have captured %1, free the town and save Altis!",_spawn];

nul = [_spawn,3,450,[true,false],[false,false,false],false,[30,0],[12,0],"default",nil,nil,nil] execVM "LV\militarize.sqf";

_marker = createMarker ["Enemy AO", position player ];
_marker setMarkerPos getMarkerPos _spawn;
_marker setMarkerShape "ELLIPSE";
_marker setMarkerColor  "ColorOPFOR";
_marker setMarkerSize [450, 450];

A_SIMPLE_TASK = player createSimpleTask ["Free the town."];
A_SIMPLE_TASK setSimpleTaskDestination (getMarkerPos _spawn);

A_SIMPLE_TASK setSimpleTaskDescription [
  "Free the town.",
  "Remove enemy forces.",
  "Captured town."
];
A_SIMPLE_TASK setTaskState "ASSIGNED";

_trg22=createTrigger["Emptydetector", [0.0,0.0,0.]];
_trg22 setTriggerArea[0,0,0,true];
_trg22 setTriggerActivation["GUER","NOT PRESENT",false];
_trg22 setTriggerTimeout [0,0, 0,false ];

if (triggeractivated _trg22) then {
A_SIMPLE_TASK setTaskState "SUCCEEDED";
};

And I am not sure about the triggeractivated code. I want this code at the bottom to activate when all AAF forces in the AO are dead.

Thanks for any help you can give me.

Share this post


Link to post
Share on other sites

well for the trigger activated you can do the following...

waitUntil {triggerActivated _trg22};
A_SIMPLE_TASK setTaskState "SUCCEEDED"; 

or

//the second string is the "OnAct:" field
_trg22 setTriggerStatements ["this","A_SIMPLE_TASK setTaskState 'SUCCEEDED';",""];

Share this post


Link to post
Share on other sites

You have a string within a string so try:

hint format["AAF forces have captured '%1', free the town and save Altis!",_spawn];

//or

hint format["AAF forces have captured %1, free the town and save Altis!", call compile _spawn];

Share this post


Link to post
Share on other sites

I have another question, is it possible to include the variable _spawn in this code?

A_SIMPLE_TASK setSimpleTaskDescription [
  "Free the town.",
  "Remove enemy forces.",
  "Captured town."
];

I want the task to say "Remove enemy forces from Selekano." for example, but I cannot find out how to include a variable in this code."

Thanks.

Share this post


Link to post
Share on other sites

A_SIMPLE_TASK setSimpleTaskDescription [
   format["Free the town of  %1",_spawn], 
   format["Captured town %1",_spawn], 
   format["Remove enemy forces %1",_spawn]
];  

not positive if this works or not, don't got the time right now to test. let me know how it works out.

Share this post


Link to post
Share on other sites

That code works!

This is what I get now. All I need to do now is rewrite the wording and clean up some other things and I should be on the way to completing this mission.

11001526_809468829137028_1777912845006701951_o.jpg

Share this post


Link to post
Share on other sites

Strange, I kill all OPFOR and the trigger will not fire. Is there a way to create a working trigger that will actually allow this to work? I spawned 5 AI and killed them and nothing happened. Please help. This is my complete spawn_ai.sqf. This is run on mission start and spawns AI as well as creating a marker and task, but the trigger will not fire when all AI are dead.

if (isServer) then {

//	_spawn = ["Sofia","Molos","Kavala","Negades","Pyrgos","Selekano","Panagia","Feres","Panochori","Syrta","Frini","Rodopoli", "Athira", "Therisa"] call bis_fnc_selectRandom;

_spawn = "hi";

_marker = createMarker ["AO", position player ];
_marker setMarkerPos getMarkerPos _spawn;
_marker setMarkerShape "ELLIPSE";
_marker setMarkerColor "ColorEAST";
_marker setMarkerSize [500, 500];

nul = [_spawn,3,100,[true,true],[false,false,false],false,[5,0],[12,0],"default",nil,nil,nil] execVM "LV\militarize.sqf"; // Spawning 5 AAF guys.

A_SIMPLE_TASK = player createSimpleTask ["Free the town."];
A_SIMPLE_TASK setSimpleTaskDestination (getMarkerPos _spawn);

A_SIMPLE_TASK setSimpleTaskDescription [
	format["Free the town of %1 and save Altis!",_spawn], 
	format["%1 has been captured!",_spawn], 
	format["Remove enemy forces from %1",_spawn]
];

A_SIMPLE_TASK setTaskState "ASSIGNED";

//	null = [] spawn {
//	  sleep 32;
//	  ["TaskAssigned",["","Clear the occupied town."]] call bis_fnc_showNotification;
//	};


_trg22 = createTrigger ["EmptyDetector", getPos _spawn];
_trg22 setTriggerArea[3500,3500,0,true];
_trg22 setTriggerActivation["GUER","NOT PRESENT",false];
_trg22 setTriggerTimeout [0,0, 0,false ];

if (triggeractivated _trg22) then {
   		A_SIMPLE_TASK setTaskState "SUCCEEDED";
};
}

Thanks for any help you can give me.

Share this post


Link to post
Share on other sites

Take out the if statement that checks the trigger activation and put the following in it's place:

_trg22 setTriggerStatements ["this","A_SIMPLE_TASK setTaskState 'SUCCEEDED';",""];

Share this post


Link to post
Share on other sites

I got it to work. This is the code I am using now.

if (isServer) then {

_spawn = ["Sofia","Molos","Kavala","Negades","Pyrgos","Selekano","Panagia","Feres","Panochori","Syrta","Frini","Rodopoli", "Athira", "Therisa"] call bis_fnc_selectRandom;


_marker = createMarker ["AO", position player ];
_marker setMarkerPos getMarkerPos _spawn;
_marker setMarkerShape "ELLIPSE";
_marker setMarkerColor "ColorEAST";
_marker setMarkerSize [500, 500];

nul = [_spawn,2,500,[true,true],[false,false,false],false,[50,0],[12,0],"default",nil,nil,nil] execVM "LV\militarize.sqf"; // Spawning OPFOR troops.

Task1 = player createSimpleTask ["Free the town."];
Task1 setSimpleTaskDestination (getMarkerPos _spawn);

Task1 setSimpleTaskDescription [
	format["Free the town of %1 and save Altis!",_spawn], 
	format["%1 has been captured!",_spawn], 
	format["Remove enemy forces from %1",_spawn]
];

Task1 setTaskState "CREATED";

_trg = createTrigger ["EmptyDetector", getPos player];
_trg setTriggerArea [30000, 30000, 0, false];
_trg setTriggerActivation ["EAST", "NOT PRESENT", true];
_trg setTriggerStatements ["this", "hint 'The town has been freed. Good work!';Task1 settaskstate 'SUCCEEDED';", "hint 'no civilian near'"];

}

Thanks for your help. Now I can dress up the code and get this finished. Decided to use Iranians instead of Greenbacks.

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  

×