![]() |
Scripting methods for mission operation
1 Attachment(s)
Method for mission listing within script
Method for Random selection of missions Method for Triggered missions for Player Method for Objective mission loading for Player Firstly I’d like to point out that I am in a learning curve with C# and the methods outlined may be or may not be the best or most efficient way. In many cases I have revised and improved concepts as I go. Secondly much of the core key aspects or syntax is learned from browsing these forums where I have modified for my own purpose or concepts, as such I wanted to return these alternatives I have been working on to the forums. Thirdly got to thank Kodiak for help on the really sticky bits of C# and how they work with CLOD. Finally, this is work in progress, but at a stage where I’d like some feedback on the scripting. The main purpose of this script is supply a dynamical feel to a mission, by their very nature missions (especially from IL2) have felt scripted and a little sterile. As it happens in my day job I have been developing water management irrigation which simulates rain, the world is chaotic and it in that field applying with chaos changes the reactions more in line with reality. So I am attempting to apply that thought pattern to scripting to simulate a feeling of unknown results. You still have missions, but when they are loaded is unknown. The second purpose of my methods layout is to make life easier on those who are completely lost with scripting, I am attempting to create scripts which are easy to add missions of users own design, and the script is just an engine that more or less can be just dropped in. As Kodiak has pointed out in another thread, use of visual express is advisable. It is free for our purpose so why not, it is just a tool to help nothing more. For the new user of C#, the following layout is setup in blocks of importance (for me anyway), in some cases the order or where the block of script is wrapped is important, but most cases you can place sections just about anywhere and it will still function. Think of the code as lots of small separate scripts talking to each other in a group than a sequential path. (although technically all code is sequential somewhere along the line). First bit of useful code is to do with C# and visual express Setting up regions where you can place blocks of scripting makes editing scripts easier. Visual express sees these (CLOD ignores them), so you can hide sections that are not being worked on. You can use as many as you like # Region [region title here] //Script block here #End region Ok this shows the regions with title of what is contained, if you click the little (-) or (+) to the left of the screen it opens and closes the regions. Note I also add simple txt separators as well for those who may edit with note pad, the line separators block for visual reference. This shows the first part of my methods, “Simplified paths”, here I have the main mission path and sub mission paths, and the type is called a “string” with the abbreviated name I called them “MP”, “MPsub” and ” MPtm”. In the core engine we just call MP, MPsub or MPtm as required, but if the user needs to edit the path they only have to edit the main string. Code:
|
Next block is all the mission lists; here I am using a part of C# “lists”. Here I am making life easier for a user by a simple layout to add user missions, the syntax is quite simple. Also note I have places for mission and messages. To add missions just add a new line within code block brackets and add a coma for each new line, noting the last list line does not have a coma.
new SubM (mission, Message all, Message Red, Message Blue) Code:
/*=========================================*/ Why? You may ask; this is about chance, there will be a chance that on the time period nothing happens. Lists actually numbers missions by their input location, their actual name is irrelevant, and so you can actually list the same mission several times as I have done with the null mission. Example of chance, if you are calling the listed missions by random chance and you had 100 missions where 50 were nulls, 10 were mission x and the rest were single missions. There is 50% chance nothing will happen on the selection time period, there is also 10% chance mission x will load and 1% chance any of the others will load. Basically you can weight the chances of what mission will load by having more of the same mission in the list, but note keeping null missions where nothing happens is important as well. The reason is this allows the frequency of the main timers to run faster, but then not overload the map with too many missions running at once. All missions in the script are randomised selection, I have lists for, Sub missions (SubM), Triggered missions UK (TM100), DE (TM200) and objective lists UK(TM150) and DE(TM250). Note, I use fairly generic naming for all subs, triggered and objective missions and only name the main mission for the title name. Long names in code just wastes space, also makes editing harder. |
The next region block is inputs for timer periods for the core engine, and random input names. If you add more random names, add the random name here. Also the block contains some references to Triggers and 2D locations of trigger locations.
The timers are editable, but note I have setup four periods on fairly tight time periods (1min repeats), where they can overlap at times. Slightly pulsing effect. Again layout is so that edits happen here and you don’t need to touch core engine. Code:
/*=========================================*/ Code:
/*=========================================*/ |
Next block is constants and parameters, although I have listed some despawntime variables in here as well, these are for altered the despawning time period for AI in game, depending on flight paths and so on and mission design you alter this period for ai time in game before despawn. I have 3 timers, for different conditions. The main, despawntime is set to 2700 or 45mins.
Code:
This is Kodiaks last messaging script, but I have modified with abbreviations, because the other code becomes smaller when you do this. The core change is the abbreviation “STxA” which means Screen text to armies and “Tx”, which means text. Code:
|
The first part of my core is a simple timer to test time periods, intension is to edit out later but is there to check time mission has played. There is some error because of delays and it does not display every minute due to being overridden by mission loading text.
Now the core engine, note rt0 is repeat and dt0 is delay start, periods setup in previous code, I set an “int” (interger) “i” as zero as a base of the random selection range, then call the SubM list through the classes input and it becomes SubMs, each mission in the list has its independent list number, this is the random range, zero =>number of missions in list(hence why nulls are important). A mission from the list is randomly selected then loaded, note mission path “MPsub +SubMs[i].MN”, “i” is the list number and MN is mission name, the following line is messages where it selects the mission and relative mission message, MM is mission message. I then wait 2 seconds and display messages to each team, MMR, message to red, MMB message to blue. Code:
That is the core random engine, but I repeat these four times so as to have four timer periods which because of the timing sometimes happen at the same time. Note: messages that appear at the same will only show the last to load. Just one of those things, you could code around that if you wanted too. So far the core operates quite well on its own without triggers and objectives, and on appearance in game behaves different every time I test it. This is even though in the test setup we have only 4 sub missions and 7 null missions. I anticipate having 50 or more in sub selection eventually with 50 nulls or something like that. Total user discretion. |
The next block is triggers, this is a nasty area at the moment due to bugs in CLOD. Here though the focus is on Player activity not AI triggering AI. Some guides on scripting for AI has mostly being posted in other threads, in the script here I only use the AI and general trigger function as text to know what is happening and indirectly triggering player triggers.
The setup in this script is representing Radar ranges. In the mission I have a radar unit as the centre piece location and set the triggers as army pass through, 3 triggers same centre different ranges representing zones. Static46 Stationary.Radar.EnglishRadar1 gb 12025.00 10315.00 50.00 Static44 Stationary.Radar.EnglishRadar1 de 30440.00 31260.00 45.00 [Trigger] uk1 TPassThrough 5 2 12025 10315 15000 uk2 TPassThrough 5 2 12025 10315 10000 uk3 TPassThrough 5 2 12025 10315 5000 de1 TPassThrough 5 1 30440 31260 15000 de2 TPassThrough 5 1 30440 31260 10000 de3 TPassThrough 5 1 30440 31260 5000 in the script the 2D locations are set as the same centre point. Point2d DEr1 = new Point2d(30440, 31260);// radar trigger(Red active) Point2d UKr1 = new Point2d(12025, 10315);// radar trigger(Blue active) Now the tricky bit,the triggers in the mission activate a list to take note of players within the mission where they are listed as Plebs, then I go through those Plebs and refernce against the 2D location and actual location of the Pleb(player). Then set true or false conditions for each zone range, outside all the zones all are false and nothing happens. At the end of these checks is a call condition, if any of the above is true then call TrigMis(), this is the random mission selection trigger set up as a private void. The reason this is separate to the Ontrigger is that I also use the triggered loader for objectives aswell.(yes they are randomised aswell). Before I leave the OnTrigger operation I have typical triggers for AI generating text to players, mainly for checks at this stage, however I do intend to have different missions loading for AI in addition to Player triggering the same zones. Code:
Ok now the second part to trigger operation, the loading of missions. These as you may of guessed are randomly selected as per sub missions, the lists are different for the triggered armies, ie Blue planes spawn for red triggering the radar ranges and visa versa. What spawns though is selected randomly exactly the same way as the core engine. The difference however,is there is a reset function timer. This is so that the trigger zones don’t load a whole pile of missions with every player crossing the line. I should explain the reset funtion a little for those new to C#, here I am using a “Switch” which is a case selection tool, ie in the case of a number being 2 “case 2” is selected and all code within it is run. I simply have a number switching between 1 and 2, when it is 1 the loading sequence is active and when it is 2 the loader is inactive. Actived I set the case select number to 2 then a timer runs which sets a timer in motion for the random generated period to reset the case to 1 again. Hence switch operation. The timer reset period though is randomised between 100 and 900 seconds where each zone can be in operation at different times depending how deep the player enters the radar region. For testing I have messages telling players that the zone is already activated, the intension is that players won’t normally get a message. |
Ok now I am going to jump to objective missions which is blocked region after the AI despawner.
Here I have modified an Onplace enter piece of code, original from the collection at 1C, but when the player enters a plane an objective is created, I trigger the TrigMis(), again this triggers the list of objectives in the objective mission list and randomly selects an objective. The selection times out after 30 minutes (period for testing) before objective reset and another objective mission could be loaded. Every player who enters an aircraft wll get a message of the current objective, the opposing team gets a warning a player enters and gets the message to defend that objective, or they could go after their objective. Again as other random lists of missions sets you can have nulls, (there is plenty to play with anyway), currently even though I have a number of objective missions in the lists for each side there is only one objective mission, I’ve yet to create some more, maybe some users can create some! The time reset is still under consideration, deciding on reset on completion or time reset, or both. At the moment objectives do reset on completion and time resets, but not in the case of non completion. Code:
|
Despawner, I have taken the original code and added reset timers, many of the current users use hard code, if you leave the aircraft the plane despawns. The issue for me with this is in the case of controlling a flight of planes. Eg taking a flight of light bombers to a target and swap from plane to plane to bomb the area then take them home again. Why not!
Anyway I set a timer running on creation, on place leave and added on task completed. I actually have 3 timer periods, set via the editable inputs near start in constants and parameters section. I also added ground object removal for objects after the first base mission. The default is 45mins so be aware of what is going on. Code:
|
Complete code
Code:
|
1 Attachment(s)
Known bugs, On task completed generates one bug I have found. If a path of a flight crosses the last path point of its own path or another operating mission path, even the line from the second to last point to the last point, then that flight that passes over the previous path will trigger the on task completed and despawn. Oh that’s a pain! This bug will trigger for anyone using on task completed so just be aware if planes despawn in places you are not expecting. A method to bypass the bug is to place the last waypoint section to side of flights. Also don’t land planes on takeoff points, the spawning plane with despawn due to being at the operating task completed path.
Finally here is the complete code and mission setup Please test, I am looking for bugs and quirks and general xxxx. *****Updates***** last version 2/3/2012 |
All times are GMT. The time now is 05:10 PM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.