Jump to content
Sign in to follow this  
dnk

Collection of my Broken Scripts

Recommended Posts

Some scripts I made for dynamic task generation. I will post them here, why not? It should be assumed that they are sloppy.

posBravo0 = getPos blu0;
posBravo1 = getPos blu1;
scopeName "name";
while {true} do {
if (!(alive blu1)) then {
	while {alive blu0} do {
		posBravo0 = getPos blu0;
		sleep 600;
	};
	tskBravo = player createSimpleTask ["Locate Team Bravo"];
	tskBravo setSimpleTaskDescription ["We've lost contact with Bravo. Search the coordinates of their last known position, and see what has happened to them.", "Find Bravo", "Find Bravo"];
	tskBravo setSimpleTaskDestination (posBravo0);
	cutText ["NEW FRAGO: Locate Bravo","PLAIN DOWN",0.5];
	tskbravo setTaskState "Assigned"; 
	execVM "tskbravorem0.sqf";
	sleep 3600;
	breakTo "name";
};
if (!(alive blu0)) then {
	while {alive blu1} do {
		posBravo1 = getPos blu1;
		sleep 600;
	};
	tskBravo = player createSimpleTask ["Locate Team Bravo"];
	tskBravo setSimpleTaskDescription ["We've lost contact with Bravo. Search the coordinates of their last known position, and see what has happened to them.", "Find Bravo", "Find Bravo"];
	tskBravo setSimpleTaskDestination (posBravo1);
	cutText ["NEW FRAGO: Locate Bravo","PLAIN DOWN",0.5];
	tskbravo setTaskState "Assigned";
	execVM "tskbravorem1.sqf";
	sleep 3600;
	breakTo "name";
};
posBravo0 = getPos blu0;
posBravo1 = getPos blu1;
sleep 600;
};

This is supposed to generate a task when a two man team has completely died. It will not generate a task when only one has died. The script "tracks" the surviving member with a call every 10 minutes (shorter is probably better, adjust the first sleep command to change the length of the "locstats"). If on the next expected reporting in both members are down, then you get a mission to find the missing squad (or just the sole man) with only the information of his last reporting in to go on.

You could always add a marker to the player's map at the second-to-last reporting in or at his next assigned waypoint if you like. It might help (I think I will do that later). Choose which based on what works best.

Then, you run one of two scripts (although it could be just one script with multiple parts or whatever, but like I said, sloppy). Here is one of them. Basically, you have 1 hour to find the missing man/squad, which is determined by whether you walk within 5m of them. It has two parts to it, so that it is only called once every 10 seconds while the player is far away to save on overhead, then updating once every second when the player gets within 100m. Maybe this is unnecessary, I don't know. Just trying out some optimizations.

_a = 0;
while {_a = _a + 1;_a < 1800;} do {
if ((player distance blu0) < 100) then {
	if ((player distance blu0) < 5) then {
		cutText ["TASK COMPLETED: Locate Bravo","PLAIN DOWN",0.5];
		tskbravo setTaskState "Succeeded"; 
	}; 
	sleep 1;
};
sleep 10;
};
cutText ["TASK CANCELLED: Locate Bravo","PLAIN DOWN",0.5];
tskbravo setTaskState "Failed";

I just made a small edit, so maybe it doesn't work now :rolleyes: but it was working fine before. I'll test it later for sure.

---------- Post added at 11:40 AM ---------- Previous post was at 11:26 AM ----------

Here is another, also meant for a longer, dynamic game (or just if you want to hunt a Colonel in the wild). The point of this is for you to get a mission to hunt down any "high value targets". This could be a Major or just some Sargent who has killed a lot of Majors. I am still beta testing it, but it has worked so far. Not a real milsim sort of script (at least not in the text), but adaptable for it.

a=2;
scopename "start";
a=a-1;
while {a>0} do {
{
	if ((rating _x) > 4200) then {
		joe = _x;
		if (side _x == east) then {
			cutText ["NEW MISSION: Kill the Russian","PLAIN DOWN",0.5];
			tskhivalue = player createSimpleTask ["Kill the Notorious Russian"];
			tskhivalue setSimpleTaskDescription ["This guy is bad, real bad. He's killed a ton of our men and others. He's a threat, simple as that, and a threat that needs to be taken out. Find him, kill him. Good hunting.","Kill Russian", "Kill Russian"];
			tskhivalue setSimpleTaskDestination (getpos _x);
			[joe,0] execVM "tsktarget1.sqf";
			[joe,0] execVM "tsktarget2.sqf";
			breakto "start";
		};
		if (side _x == resistance) then {
			cutText ["NEW MISSION: Kill the Guerrilla","PLAIN DOWN",0.5];
			tskhivalue = player createSimpleTask ["Kill the Notorious Guerrilla"];
			tskhivalue setSimpleTaskDescription ["This guy is bad, real bad. He's killed a ton of our men and others. He's a threat, simple as that, and a threat that needs to be taken out. Find him, kill him. Good hunting.","Kill Guerrilla", "Kill Guerrilla"];
			tskhivalue setSimpleTaskDestination (getpos _x);
			[joe,1] execVM "tsktarget1.sqf";
			[joe,1] execVM "tsktarget2.sqf";
			breakto "start";
		};
	};
} foreach allunits;
sleep 300;
};

Simple enough, I guess. Then it opens two new scripts. The first I show runs a regular check of whether you killed him or not. Since I could not find an actual command that is usable, I had to make an indirect sort of workaround by regularly checking the player's rating. If the guy dies (and they're all team leaders or snipers in my mission; if you think a rifleman might also be used, lower the player score increase to under 200, 1 might be enough), you then check to see if the player's score jumped over the same period by a high amount (indicates that player killed a high value target). If so, you succeed, if not, you fail. Some false negs/positives, of course, but on the whole it should work. Two sets of if-thens for both sides: indies and ruskies.

a = 2;
scopename "start";
a = a -1;
s = _this select 1;
while {a > 0} do {
playerrating = rating player;
sleep 1;
if (!(alive (_this select 0))) then {
	if ((playerrating + 499) < (rating player)) then {
		if (s == 0) then {
			cutText ["TASK COMPLETED: Kill the Notorious Russian","PLAIN DOWN",0.5];
			tskhivalue setTaskState "Succeeded"; 
			breakto "start";
		};
		if (s == 1) then {
			cutText ["TASK COMPLETED: Kill the Notorious Guerrilla","PLAIN DOWN",0.5];
			tskhivalue setTaskState "Succeeded"; 
			breakto "start";
		};
	};
	cutText ["TASK CANCELED: Kill the Notorious Man","PLAIN DOWN",0.5];
	tskhivalue setTaskState "Canceled";
	sleep 5;
};
};

(loopable here by running the first script again, but you need to create a incrementing script that creates a new task like: start the first script with "c=0;" and change the appropriate lines to something like format [tskhivalue%1,c] createsimpletask... etc, etc, maybe?) This second script just updates the guy's position every so often so you're not wandering Chernarus or whatever with absolutely no help. Again, updating faster can help as 5-15min can be a long tail. Still, if you like hunting the wiliest of game... it's a fun bit of hide and seek :D

while {alive (_this select 0)} do {
where = getpos (_this select 0);
sleep 30;
hint "We've got a new lead on that 'problem', check your map for an update.";
tskhivalue setSimpleTaskDestination (where);
sleep (300 + random 300);
};

---------- Post added at 11:43 AM ---------- Previous post was at 11:40 AM ----------

If anyone wants to, they're free to use. Credit where it's due, whatever. They can be done better than this, and maybe they have been already. Just figured I'd share my learning process results is all. Comment on sloppiness is appreciated.

Edited by DNK

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  

×