Jump to content

How to get a random event mid-mission, based on a trigger?


TheHighwayman

Recommended Posts

Howdy.

 

I am building a mission where the Red Player gives a warning to a Blue AI flight.

 

I would like for the Blue AI to respond with a random choice between two options, after which a trigger and a response is fired. The blue flight might comply, or it might take another action.

 

However, I cannot figure out how to set this up within the editor. Perhaps there is a LUA script? I have minimal experience with scripting.

 

I do know how to make random groups activate, and I can create a random, timed event from the moment of mission start. But I do not know how to fire a random event from a trigger.

 

Any input?

 

Thanks!

Link to comment
Share on other sites

I just thought up an option that could make this work... it's a strange option, but I don't see why it can't work.

 

The EVENT option has "On Destroy" as a choice. I can destroy a unit using a trigger, such as a jeep in the middle of nowhere, in a distant corner of the map. When that happens, it should allow me to set a random option.

 

I'll test and report back. In the meantime, answers to the above question are welcome!


Edited by TheHighwayman
Link to comment
Share on other sites

I am still testing this mission.

 

However, I would like to attach it here so others can have a look at my "Rube Goldberg McGuffin" work, and see if the random trigger works.

 

So far, in one test, I did not see any result.

 

1. The way the trigger works is, once the Americans come too close to Iranian airspace, the Iranian MiG 29s have the option to "warn" them away.

2. The warning destroys a vehicle parked in a distant corner of the map.

3. ON DESTROY a pair of Random 50 Flag On are set. This provides 4 possible outcomes (True/True, True/False, False/True, or False/False). Each outcome sets a flag which in turn activates a "response."

 

But there's a catch. Since the check for the flags happens at the start, the false/false combination fires at the beginning of the mission. So, I have disabled the false/false response from firing.

 

Therefore, there is a 1 in 3 chance of a reply from the Americans, and a 1/4 chance of nothing.

 

What is unclear to me is if this actually works. In the only test I had time to do, I communicated the warning and the vehicle was destroyed. However, I got no responses, so it is possible that false/false resulted. Worse, it is possible that the whole thing is broken. The good news is, even if this Rube Goldberg system of adding a random trigger to the middle of the mission does not work, the mission itself still does work, and all I need to do it add in a message or two to make clear what's happening and what is expected.

 

At this time, I won't be able to test this again until Sunday. I am posting a copy of the mission here for anyone to test, if they wish. It is basically complete and may provide a fun challenge.

 

The player flies a MiG 29 against American F-14s. What is cool is that during the intercept, the Americans do not fire (this part worked fine) and you can fly in formation with them, or get some cool screenshots, a-la-Maverick & Goose. Don't forget your Polaroid camera.

 

Note, a possible outcome of this mission is either the Americans do not violate airspace and you are not cleared to fire. In which case, you will probably simply return to base and land to end the mission. Another possibility is they will bug out after you warn them. However, the most likely event is you will start shooting, and the only real question is when.

 

Additional feedback is welcome.


Edited by TheHighwayman
Link to comment
Share on other sites

Why do you need the ground vehicle to be destroyed to set the trigger?

 

Can't you make the random roll at the start of the mission, and then use that value to determine the reaction to the challenge later in the mission? There's no reason to make the mission wait until the story moment to decide what the outcome will be, that can be predetermined at mission start and the players will never know.

 

At the start of the mission, make a trigger with a random chance to set Flag 1 ON.

 

When the player challenges the American flight, set Flag 2 ON.

 

If Flag 1 is ON and Flag 2 is ON, the American flight does one thing.

 

If Flag 1 is OFF and flag 2 is ON, the American flight does the other thing.

 

Since both actions wait for Flag 2 (the challenge), nothing will happen until the player begins the encounter.

Link to comment
Share on other sites

Set a flag that is required for the condition to be executed.

 

The way random conditions work is that it is a roll of the dice every single second to see if the condition is true, then it executes the action. So if you set it to 10% chance then statistically it should take on average 10 seconds for it to become true. You can combine it with other conditions to decide when a random trigger can be executed. For instance:

 

Once>Random 100% and Flag 1 is True: It will never execute the action until flag 1 is true. The random diceroll will always get the correct value but as long as flag 1 is false it'll just keep rolling. Likewise you can set the random value to something lower and can copy multiple triggers with the same condition and still get random results.

 

Once> Random 10% and Flag 1 is True> Set Flag 1 false and Do action A

Once> Random 10% and Flag 1 is True> Set Flag 1 false and Do action B

Once> Random 10% and Flag 1 is True> Set Flag 1 false and Do action C

 

Whenever flag 1 becomes true then it allows any of the random choices to become true. By setting the flag back to false it prevents other choices to be made. I know I tend to promote that method a bit, but it is a much easier to understand and implement solution than combining boolean flag values.

 

 

In general the problem with "event" conditions with the triggers is that it does not specify which unit caused the event. In your mission the triggers that set flags 2001 and 2002 will occur anytime anything is destroyed. So for starters both flags are false and the condition with both being false is executed immediately. If something gets destroyed then there is a chance 1 gets set to true. If another object is destroyed then it is another chance for a flag to be set true, and so on. Eventually both flags will be set true if enough objects are destroyed. You ultimately should be using an additional flag to decide when a random choice can be made.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

PROMISED UPDATE

 

After studying the answers from both of you, Bunny and Grimes, I have made some changes to the mission and it is working exactly as intended! I am excited to have this new "trick" in my bag, which will help me create richer missions for all to play.

 

Thank you both for the thorough and considered replies.

 

I am attaching the current build of the mission, and unless I find further errors in testing tonight, I will upload it to the User Files section of the site so others can enjoy it.

 

If you like, enjoy this sneak peek at "Rules of Engagement - Gulf Intercept" from the RED side!

 

NOTE: File removed due to question. Attached in the next comment with question.


Edited by TheHighwayman
Link to comment
Share on other sites

Lower then random chance to 10 or lower. It might take a few checks to return true but it will be more randomized. Basically at 40% there is a really a high probability the first or second trigger gets chosen.

 

Alternatively since this is for only one choice to be made, use a trigger to set a random flag value. So when flag 700 is set to true have it set another flag to be a random value of 1 to 4. Then for each choice have it be:

 

Flag X Equals 1 > Do action

Flag X Equals 2 > do action

Flag X Equals 3 >do action

Flag X Equals 4 >do action

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...