Jump to content
Sign in to follow this  
ivan keska

Having only 1 of multiple items spawn

Recommended Posts

I'm currently working on a server with a friend and I'm tasked with editor stuff well he's set with server side stuff. Now I'm trying to set up multiple zones, but only have one appear at a time and not in any order. Well if possible have it where if the zone is occupied for a set amount of time by only one group it's removed and a new zone is randomly selected and activated.

Now i'm thinking of setting the zones to have a chance of spawning, and based on what appears will determine what is removed and what is kept. But this as you can imagine will result in a huge amount of coding, since each possible combination I have to account for. So as you can figure out I don't want to do that.

Share this post


Link to post
Share on other sites

Create triggers with names for your zones in the editor with activation type "None", then drop them in an array in the init.sqf, then select using random statement. Then only activate the conditions of that single zone, leaving the others inactive.

Pseudocode:

zones = [ zone1, zone2, zone3];
_index = random floor (count zones);
_active = zones select _index;
_active setTriggerActivation "ANY";
_active setTriggerStatements [
       "this", // trigger name
       "hint 'Zone activated';", // On trigger activation
       "hint 'Zone deactivated';" // On deactivation
   ];
_zones deleteAt _index; // remove activated zone from array to prevent it from being select again on the next call

Then re-run this code whenever a zone is "complete" and you want the next one to activate.

Depending on what you want and need, there's a whole lot you can do codewise to manipulate triggers. The wiki gives great examples, as does KillzoneKid's tutorial section: http://killzonekid.com/arma-scripting-tutorials-triggers/

Share this post


Link to post
Share on other sites
Create triggers with names for your zones in the editor with activation type "None", then drop them in an array in the init.sqf, then select using random statement. Then only activate the conditions of that single zone, leaving the others inactive.

Pseudocode:

zones = [ zone1, zone2, zone3];
_index = random floor (count zones);
_active = zones select _index;
_active setTriggerActivation "ANY";
_active setTriggerStatements [
       "this", // trigger name
       "hint 'Zone activated';", // On trigger activation
       "hint 'Zone deactivated';" // On deactivation
   ];
_zones deleteAt _index; // remove activated zone from array to prevent it from being select again on the next call

Then re-run this code whenever a zone is "complete" and you want the next one to activate.

Depending on what you want and need, there's a whole lot you can do codewise to manipulate triggers. The wiki gives great examples, as does KillzoneKid's tutorial section: http://killzonekid.com/arma-scripting-tutorials-triggers/

[color="#FF8040"]zones [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color]zone1[color="#8B3E2F"][b],[/b][/color] zone2[color="#8B3E2F"][b],[/b][/color] zone3[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] 
[color="#1874CD"]_index[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]floor[/b][/color] [color="#191970"][b]random[/b][/color] [color="#191970"][b]count[/b][/color] zones[color="#8B3E2F"][b];[/b][/color] 
[color="#1874CD"]_active[/color] [color="#8B3E2F"][b]=[/b][/color] zones [color="#191970"][b]select[/b][/color] [color="#1874CD"]_index[/color][color="#8B3E2F"][b];[/b][/color] 
[color="#1874CD"]_active[/color] [color="#191970"][b]triggerAttachVehicle[/b][/color] [color="#8B3E2F"][b][[/b][/color]squadLeader[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_active[/color] [color="#191970"][b]setTriggerActivation[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"GROUP"[/color][color="#8B3E2F"][b],[/b][/color] [color="#7A7A7A"]"PRESENT"[/color][color="#8B3E2F"][b],[/b][/color] [color="#000000"]true[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_active[/color] [color="#191970"][b]setTriggerStatements[/b][/color] [color="#8B3E2F"][b][[/b][/color] 
       [color="#7A7A7A"]"this"[/color][color="#8B3E2F"][b],[/b][/color] [color="#006400"][i]// trigger name [/i][/color]
       [color="#7A7A7A"]"hint 'Zone activated';"[/color][color="#8B3E2F"][b],[/b][/color] [color="#006400"][i]// On trigger activation [/i][/color]
       [color="#7A7A7A"]"hint 'Zone deactivated';"[/color] [color="#006400"][i]// On deactivation [/i][/color]
   [color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] 
[color="#1874CD"]_zones[/color] [color="#191970"][b]deleteAt[/b][/color] [color="#1874CD"]_index[/color][color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]// remove activated zone from array to prevent it from being select again on the next call [/i][/color][/color]

Made with KK's SQF to BBCode Converter

Corrected the example a little bit. It is floor random, not random floor, also ANY will make trigger activate by everything that is entity including weaponholders and ambient life. GROUP activation is more appropriate in this case.

Share this post


Link to post
Share on other sites

Now if you could explain this like your talking to someone who remembers pretty much nothing about scripting. Note i don't need a huge explanation just something that provides a bit more info then a side note. Also just in case i made a mistake by zone I mean one of those marker zones you can place down and see on the map.

Edited by Ivan Keska

Share this post


Link to post
Share on other sites

It's not rocket science. You'll have to do at least some of the work yourself to understand and apply this. The wiki and KK's tutorials are a great way to get started. As is looking at missions others have created and figuring out how they made it work.

Above code by KK should work just fine if you use triggers instead of markers in the editor. If that's too confusing, you should learn the editor and the biwiki before you try more advanced stuff such as this thread.

Share this post


Link to post
Share on other sites

So after looking up some stuff and all that I think i got something that might work since it's based off a simple script I found. Problem is I think I messed up somewhere,i'm guessing the the marker creation SQF think i didn't write it correctly or taskarray is the wrong array. Anyways here's the set up in the raw form which only difference from the original script is whats in the SQF files under taskarray, reason i want to make sure the default works first before editing it to how i want it.

INIT.sqf code *note trimmed some of it off since it's like 15-20 names"

TaskArray=["TERRITORY_THRONOS_CASTLE.sqf","TERRITORY_KASTRO_CASTLE.sqf","TERRITORY_Sagonisi_Military.sqf","TERRITORY_Terminal.sqf","TERRITORY_Military_Hill.sqf"];

null=[]execVM 'RandomArray.sqf";

RandomArray.sqf *nothing i've change it in from the default i found*

_repeatTasks=false;

if (count TaskArray > 0)

then {

_randomN=floor (random count TaskArray);

_randomScript=TaskArray select _randomN;

null = [] execVM _randomScript;

if (!_repeatTasks)

then {

TaskArray = TaskArray - [_randomScript];

};

}else{

Hint "All tasks Complete";

};

Then the sqf for the createmarker and setmarker stuff, also unlike the default I didn't leave in this bit null=[]execVM "RandomArray.sqf"; the reason i believe that causes it to cycle back and cause another location to spawn which i don't want.

_marker = createMarker ["TERRITORY_Athira_Factory", Athira_Factory ];

"TERRITORY_Athira_Factory" setMarkerShape "ELLIPSE";

"TERRITORY_Athira_Factory" setMarkerColor "ColorYellow";

"TERRITORY_Athira_Factory" setMarkerSize [95, 130];

"TERRITORY_Athira_Factory" setMarkerDir 50;

"TERRITORY_Athira_Factory" setMarkerBrush "DIAGGRID";

** Now i'm trying to get it to randomly select a marker and create it and set it up onto of a hidden one i've placed thus the name without the territory title. Well also not cycling back and reactivating itself thus creating more then one marker. I think i screwed up the creation SQF for the markers, which is why nothing is spawning. Also the place I got the base script from is this video

, which seems like a simple script that can be modified to do what i'm going for.. Also if I missed something really obvious I can't really help it I only have time to do this at like 1 am shortly before I got to bed after working all day, so as you can't imagine I'm pretty out of it.

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  

×