Bahger Posted April 1, 2011 Posted April 1, 2011 A while ago I asked about how to set up a mission with random target assignments so that, once the player enetered a trigger zone, a series of triggers with randomized conditions would ensure that the same target assignment of three would not occur first on successive plays. I'm using Grimes' elegant formula: (Switched Condition) Play Message Conditions > Set Flag 10 (All Switched Conditions) Flag 10 is True && Random 30% && Flag 1 is False > Set Flag 1, Flag 10 Off, Play Message A Flag 10 is True && Random 30% && Flag 2 is False > Set Flag 2, Flag 10 Off, Play Message B Flag 10 is True && Random 30% && Flag 3 is False > Set Flag 3, Flag 10 Off, Play Message C The problem is that the program cycles through all the targets (in randomized order) every time the player revisits the initial trigger zone, when what I have decided I want is this, for replayability: - I will create 5 targets, with accompanying radio messages, spawning them to coincide with the narrative/players actions/triggers, if necessary. Each should be given a 20% chance of selection by the program. - Player enters initial trigger zone (a CAP hold at a waypoint) - Player is assigned one of the above 5 targets on a randomised basis - Player hits target - Player returns to the CAP hold - Player is assigned another randomised target - This ends the target assignment phase. Player receives message to RTB The idea is that the player never knows which two out of the 5 targets he will receive. In fact, of course, I could make 10 targets each with a 10% probabability of selection assigned. I don't want the player to be able to receive all targeting assignments on one play-through, every time he returns to the CAP trigger zone. Is there a way I can adapt the logic I already have to acccomplish this? Grimes? This could be a good mission so I'm grateful for any help in ironing out the kinks. Thanks!
Grimes Posted April 1, 2011 Posted April 1, 2011 Just add additional logic to the conditions for starting a new task. Player in Zone && Flag X is False > Set flag 10, Set Flag X When each target is destroyed> Clear Flag X If you want it limited to just 2 targets use flag iteration to keep track of how many times it could select a mission. Player in Zone && Flag X is False && Flag Y is less than 2> Set Flag 10, Set Flag X, Flag Y Increase 1 The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Bahger Posted April 2, 2011 Author Posted April 2, 2011 Thanks, Grimes, as ever. Can you explain flag iteration? I've never got my head around what "Flag less than..." or "Flag more than..." actually mean.
RichardG Posted April 2, 2011 Posted April 2, 2011 Is this lua code, or actual functions from the mission editor? I'm trying to learn the editor.
Grimes Posted April 2, 2011 Posted April 2, 2011 Richard, these are triggers. The first column has the trigger name and how it is executed. The middle are the conditions that need to be true for it to execute. The last column are the actions that execute. Badger, Flag iteration is simply a math counter. All flags have a default value of 0 or false. Flag increase and flag decrease act as addition and subtraction. The Flag is greater than or less than conditions act as comparisons. So each time a mission gets chosen it would add the value "1" to a given flag. You could even make it so once its completed it subtracts 1 from the same flag. The condition requires that flag Y be less than 2. Since we don't have "greater than or equal to" or even "flag equals x" we must use simple greater/less than to figure out whether it can execute or not. In this example, the first time it runs it will see that Y=0 and it will execute. The next time Y=1 (and is less than 2) so it will run. If the player is still in the zone it will not execute because Y=2. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Bahger Posted April 2, 2011 Author Posted April 2, 2011 (edited) OK, Grimes, I think I get it. This is not the way my mind works but I'm determined to master it and I believe I have wrapped my head around the concept. In the attached .miz: Flag 4 = The initial condition for every task, Unit in zone "Hold". Before each task is assigned I want the player to be established in a hold, therefore in each case there is the following condition: Flag 4 True && Flag 4 + 60 "Trigger Trigger" (You need to be a fan of The Clash to get why this is amusing) is merely the zone for the "Activate Mission Conditions" trigger. Do I still need it? I have added victory triggers for each of the 3 assignments to clear the associated flag when the mission objective is destroyed. I think my flag iteration logic in each trigger, referencing the other two triggers, is correct but this is most likely where I am making a conceptual mistake. Once again, would you take a look? 30 seconds of your time = 2 hours of me tearing what's left of my hair out. You will definitely receive credit on the mission. Thank you! Edited April 2, 2011 by Bahger
Grimes Posted April 2, 2011 Posted April 2, 2011 Uhm, each time you choose the mission you need to turn "Flag 10 Off" otherwise it will continue to select the other two missions. "Flag 4 is true && Time Since Flag 4 is true" is redundant. Time since flag only works if the flag is true. So get rid of the "flag 4 is true". How you setup the flag iteration is.... not the way to do it, delete those. The victory triggers break the mission selection. "flag 1" indicates that the mission is no longer available to be chosen/ it is active. I suggest you break each task into 3 triggers each. First is to select the mission "aka set flag to 1, Clear Flag 10" 2nd is to play the message, "Flag 1 is True && Group is Alive && some condition saying you want a message to play> Play message 1. I assume flag 4 is supposed to be part of the trigger that plays a message... if so make activating it a switched condition and clear flag 4 after each message. last is the completed info, "Flag 1 is true && Group is Dead> Flag 11 Decrease by 1 When you select a mission, Check flag 11 is less than 2 (or whatever) AND Unit in zone> Set Flag 10, Flag 11 increase 1. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Bahger Posted April 2, 2011 Author Posted April 2, 2011 (edited) What a dunderhead you must think I am. OK, I think I've got it. Will test it. Thanks for your patience. Edit: Made those changes. They seem to work, although when I tried to increase the target number to 5 (each with 20% probability) the mission kept selecting the same target in the first instance, so I abandoned that and went back to the 3 target/30% version, which randomised the initial selection as it should. What I need to do now is figure out a way, once the player has destroyed 2 targets of the 3 that the program randomly selects, that no more target assignments become available, even if he returns to the hold (which triggers additional target assignments). This way, you have to play the mission more than once to be assigned all available targets. Ideally I'd like to be able to set it up so that it assigns 2 out of 5 rather than 2 out of 3 each time but it appears that I am already exceeding my very limited mathematical skills. Updated file posted. Edited April 2, 2011 by Bahger
Grimes Posted April 2, 2011 Posted April 2, 2011 Add another math counter to the conditions for selecting the mission. Flag 13 is less than 2 > All of the select mission stuff, Flag 13 increase 1 The way this works is on the first mission flag 13 = 0, so it can select a mission. It now equals "1" and is therefore less than 2, it will allow another mission to be selected if the other conditions are true. It now equals "2" and is therefore not less than 2, so it will not trigger again. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Recommended Posts