PDA

View Full Version : Online Dynamic Campaign with Script


stillborn
05-21-2011, 05:28 PM
Campaign contains 14 static missions chained from red airfield to blue. 6 of them are ground based, 8 of them are naval. campaigh starts by spawning tankers moving towards enemy airfield, if they encounter each other they spawn AA guns over them and start to fight until one side is killed and the next mission towards the defeated side is loaded, if one of the ships is destroyed before encountering enemy the other ship continues to progress. When the ships reach the coast, they disembark and continue as AA trucks, when the trucks reach enemy airfield, spawn points change and players can spawn enemy's aircrafts from captured airfield. if the aa trucks are destroyed, spawn points restore and campaign reverts 3 missions.

Scripts contain a code for destroying aircrafts on player leave, crashland or land with a timeout, also the code does not trigger if the player is still inside or another player entered this aircraft in the meantime. Also airborne left aircrafts are not destroyed but damaged. Player checks contain the server too so you can use it with steam lobby.

I have created new airfields for spawning parked in front of the runway, only two aircrafts spawn in front of the runway, if these points are full the other aircrafts spawn in a tight circle next to them.

FMB has a limit for min airfield radius which also defines the spawning locations for extra aircrafts when all points are full, i overrided it in notepad, if you edit the airfields in main mission dont forget to change these.

There's also a single player version of main mission for testing at 16x, ground war is totally random but you can interact with it with unlimited ammo to preview all the missions quickly.

Server briefing page does not refresh the spawn points after you select army, so if a base capture occurs change your army twice to see the updated spawn points on map to use enemy's airfield.

I've made this campaign to share my approach for dynamic mission loading, feel free to copy/manipulate it, with the same logic and a more tidy-flexible code, multiple dynamic frontlines can be created.


Extract the archive to "missions/Multi/Dogfight/" and launch main mission from dgw_iod_v1_X folder.
latest version: dgw_iod_v1_1(3aa_on_ships)

Ataros
05-22-2011, 11:56 AM
I have created new airfields for spawning parked in front of the runway, only two aircrafts spawn in front of the runway, if these points are full the other aircrafts spawn in a tight circle next to them.

How do you link one airfield point to 3-4 others at the same time? When I set airfield points (AFP) they appear one by one in a row only. Do you experience a bug trying to set more than 5-6 AFPs at an AF?

Many great ideas in your mission.

stillborn
05-23-2011, 12:00 AM
How do you link one airfield point to 3-4 others at the same time? When I set airfield points (AFP) they appear one by one in a row only. Do you experience a bug trying to set more than 5-6 AFPs at an AF?

Many great ideas in your mission.
there is a "add branch" command in the control options - builder category, FMB automatically threats end points as spawn points, the only strange thing i noticed about it is if i dont put at least two points inside the runway, ai aircrafts teleport to the parking points after landing, thanks btw.

Ataros
05-23-2011, 04:12 AM
Thanks a lot. I'd never guess what this command mean ))

btw. There is a Break command there. What does it break?
Show Insert command - what can it be?
Change and Change+ commands - ?

FG28_Kodiak
05-23-2011, 05:52 AM
Can you add a screenshot of the feature, please?
I have a german Version and do not find this interesting option. :rolleyes:

Ataros
05-23-2011, 06:08 AM
The Branch is not in FMB it is in Control Settings. First line.

https://lh4.googleusercontent.com/_SFUSvzV-UZg/Tdn5no3MKuI/AAAAAAAABBM/kM32OGRhbCo/s1440/2011-05-23_100638.jpg

FG28_Kodiak
05-23-2011, 06:34 AM
Oh OK, thanks. ;)

Ataros
05-26-2011, 07:23 AM
Just put the mission up on Repka #3.

Is it designed to run in cycle forever or we should reload it in some time?

I will add more feedback in this post later:

- Errors on misload:
[11:10:55] System.ArgumentOutOfRangeException: index and length should point to a position in a line
[11:10:55] Parameter name: length

- looks like guns do not spawn on ships. the ships just stand one in front of another and do not fight.

- 110-C7 can carry bombs which gives blue side an advantage.

- (will add later if I have more info)

I hope to get some feedback from players in this thread http://forum.1cpublishing.eu/showpost.php?p=289111&postcount=44

I have found a useful link on how to put guns on tankers here http://forum.1cpublishing.eu/showthread.php?t=22740&page=3

stillborn
06-25-2011, 05:32 PM
Just put the mission up on Repka #3.

Is it designed to run in cycle forever or we should reload it in some time?

- Errors on misload:
[11:10:55] System.ArgumentOutOfRangeException: index and length should point to a position in a line
[11:10:55] Parameter name: length

- looks like guns do not spawn on ships. the ships just stand one in front of another and do not fight.



yes it is designed to run in cycle forever which will fail after approximately 2 trillion sub mission loads; also any manual mission load after battle init will result in script error.

i'll look into these errors, i havent tested it with the last version yet. loading a mission manually causes the campaign to stop progressing just like u described, it may be my mistake too, or a possible situation i havent noticed, for example spawning an object fails when there's a wreck on the spawn location, nd ships spawn many random objects when damaged, destroyed or broken into two, if i dont manually destroy those, they will simply hit those wrecks n stop or wont spawn at all, leading to a script error or preventing the campaign to progress, these may have been changed since last patch btw. Script behavior has also changed with the last patches, some of the things we try to do are already being done transparently right now, like removing the landed planes, also the last changelog says that it wont be possible to damage planes with incorrect damagenames, which is present in my code too, idk if this gives an error or continues to work silently without doing nothing. honestly all the reference i have when writing scripts is the names of the methods present in the game's dlls and the campaign's code as an example, i'm not sure if i'm using the right methods or coding with the right approach, somethings i try to do may be intended for a specific purpose or restricted or may lead to error when combined with another. it'll be much more clear and painless when we have a guide or documentation about scripting.

i also plan to change tanker+aa gun configuration with new battle ships that came with the last patch so they can defend themselves while moving and write a statistic collection method, possibly outputting to a text file for simplicity if possible, so we can save or upload those(the count of the aircrafts each side lost, current situation of the front line, etc) with a seperate program or even inside the script. This way in case of any script error or server restart, stats wont be lost and campaign can continue from where it was and users can view an online briefing web page prepared for the current situation of the frontline, check the stats nd so on, even we can downgrade the available aircraft models according to losses or maybe define a victory condition.

Ataros
06-29-2011, 09:52 AM
Thanks a lot! I am sure all Repka #2 and #3 pilots are looking forward to the new version.

steam
06-30-2011, 11:36 AM
Hi.
I ask you to put a lot of anti-aircraft guns at airports so that they can be used for cover from enemy attacks on its territory and prevent voulching.

Skoshi Tiger
07-03-2011, 03:16 AM
btw. There is a Break command there. What does it break?


The break statement terminates the closest enclosing loop or switch statement in which it appears. Control is passed to the statement that follows the terminated statement, if any.

Is this the break you are talking about?


//check if there is any player inside
foreach (Player p in ps)
{
if (p != null)
{
if (p.Place() != null)
{
AiAircraft playerAircraft = (p.Place() as AiAircraft);
if (playerAircraft != null)
{
if (playerAircraft == aircraft)
{
aircraftWillBeDestroyed = false;
break;
}
}
}
}
}


I think the break statement will drop out of the foreach loop. As far as I can see the purpose of the code is to see if any of the planes contained in array ps have a player inside. If any of the array locations contains a player then the loop does not have to continue.

The next section of code checks 'aircraftWillBeDestroyed' if player is present then this is set to false and the section that destroys the aircraft will be skipped.


Cheers!

stillborn
07-07-2011, 04:24 PM
The break statement terminates the closest enclosing loop or switch statement in which it appears. Control is passed to the statement that follows the terminated statement, if any.

Is this the break you are talking about?



I think the break statement will drop out of the foreach loop. As far as I can see the purpose of the code is to see if any of the planes contained in array ps have a player inside. If any of the array locations contains a player then the loop does not have to continue.

The next section of code checks 'aircraftWillBeDestroyed' if player is present then this is set to false and the section that destroys the aircraft will be skipped.


Cheers!

yes the break u mention here interrupts the foreach loop because we found a player inside the plane queued for destroy and there is no need to check other players,this will be a waste of time, there is possibly someone else entered this plane in the meantime and the plane must not be destroyed, i set a boolean value (aircraftWillBeDestroyed) to hold the result because the code continues to execute after foreach loop according to this result.

lol no, sorry i misunderstood, its the "break command" (key command) set in options-controls-builder, exits free view mode in fmb and deselects current object, could be handy if you fine tune the positions of objects in free view mode a lot, by the way this is what i use it for, may be intended for something else.

stillborn
07-07-2011, 10:41 PM
here is version 1.1

changes:


fixed script errors at onactorcreated methods preventing removal of destroyed ship hulls and campaign progress


added aa guns to prevent voulching(optional, respawns each 5mins by default)
*not available at capturable airfields because it will prevent mission progress
if you find aa guns insufficient please suggest a good combination, i didnt put 2cm guns because their combined explosion effects causes shutters and slowdowns


added radius_hide value to all aa guns to prevent ships and base defenses fire on taking off enemy aircrafts, yes unfortunately map is too small, sticked with tanker+aa for the same reason, ships dont have a radius_hide option


raised onboard guns of ships by 2m to prevent collision


changed available aircrafts

Reds:
Aircraft.HurricaneMkI_dH5-20
Aircraft.HurricaneMkI
Aircraft.SpitfireMkI_Heartbreaker
Aircraft.SpitfireMkI
Aircraft.SpitfireMkIa
Aircraft.BlenheimMkIV

Blues:
Aircraft.G50
Aircraft.Bf-109E-1
Aircraft.Bf-109E-3
Aircraft.Bf-110C-4
Aircraft.Ju-87B-2
Aircraft.Ju-88A-1

Both on captured airfields


added error logging (optional) to desktop (works on a seperate lower priority thread)


added campaign status saving (optional) to desktop (works on a seperate lower priority thread), main mission will resume from where it's left on server restart.


added new airfield points and changed airfield radius to make use of game's own cleanup system


campaign now reverts back by 1 mission when invading ground forces are destroyed


dgw_iod_v1_1(3aa_on_ships).zip has two extra guns to protect ships on the move, one Zwillingssockel, one Bofors, these are short range and does not engage ships

Extract the archive to "missions/Multi/Dogfight/" and launch main mission from dgw_iod_v1_1 folder.

Skoshi Tiger
07-08-2011, 02:46 AM
lol no, sorry i misunderstood, its the "break command" (key command) set in options-controls-builder, exits free view mode in fmb and deselects current object, could be handy if you fine tune the positions of objects in free view mode a lot, by the way this is what i use it for, may be intended for something else.

Which just goes to show that great minds can think in completely different ways and go off on completely different tangents! ;)

Thanks for the clarification!

Cheers!

Ataros
07-08-2011, 10:25 AM
here is version 1.1

Thanks a lot, stillborn! Your mission is the most popular in the CloD world right now I think.

added campaign status saving (optional) to desktop (works on a seperate lower priority thread), main mission will resume from where it's left on server restart.

How can we activate this option?

As we experienced issues with team balance red75prime from sukhoi.ru forums added a balancing script to the previous version of your mission. Please find it attached. I hope he will include it in the recent version as well.

Edit
yes unfortunately map is too small, sticked with tanker+aa for the same reason, ships dont have a radius_hide option

It may be interesting to have the warships placed at the outside of islands as targets for bombers only if it is possible. This way they hopefully won't reach airfields with gun fire.

From my experience 2-3 20mm per airfield is fine. Also there is a German recon car #202 IIRC (the only one which can fire upwards) and it is the most efficient AA weapon used on Repka#1 atm.

stillborn
07-08-2011, 06:13 PM
thanks for the tip, i'll look into the code you sent and see if there's anything i can do, the loops i use for player checks may be a bit slow if there are too many players in the server but they are designed to work with all available options, for a fixed server settings, the same things can be done much more efficiently, for example if the server is set not to show aircrafts in the map and set not to allow players to enter currently flying aircrafts than an "onplaceleave event" can be directly connected to a "destroy attempt" after a simple check for other seats(places) in this aircraft, which will be more robust compared to checking all players.

How can we activate this option?
all optional features are on by default, to disable you need to set the "isLogCampaignStatus" boolean values at the beginning of the script(in all files)

It may be interesting to have the warships placed at the outside of islands as targets for bombers only if it is possible. This way they hopefully won't reach airfields with gun fire.
i had prepared a new mission in a bigger map (volcanic islands), i think it will be more suitable for 40+ players, does not have anything dynamic yet, juts refreshes aa guns and ships periodically, has the same code layout with dgw. the thing i like about this map is the bases are behind hills so preventing voulching is easier and does not interfere with mission related objects thus any kind of mission will suit better, also has plenty of neutral space for dogfight. i'll try to prepare a dynamic bomber mission series for this one.

Ataros
07-08-2011, 07:58 PM
Speaking of bomber missions I remember naryv (one of the dev team) included very interesting code in this script http://forum.1cpublishing.eu/showpost.php?p=285348&postcount=133 The code dynamically assigns the most close ground target as a waypoint for bombers to attack.

Also I had an idea for airfields capture mission where objectives are
1) clear all AAA at an airfield - several bombing runs
2) drop paratroopers over the field - different bomber flight with paratroopers dropped over field (if possible)
3) then another 2-3 aircraft has to land on the airfield to deliver supplies and finally capture it.

This scenario can be interesting because stopping bombers has some practical meaning for players in it. Islands map ideally fits this type of scenario I think.

Feel free to use the idea if you like it.

Ralith
07-27-2011, 11:41 PM
Nice job on this mission! It's a lot of fun to play (I spend almost all my MP time on Repka 3 thanks to it), and a great improvement on the bland objectiveless dogfights that used to characterize IL-2. I look forward to further developments! Much respect for wading through the APIs and producing something of quality despite the utter lack of documentation and rarity of reference material.

One comment: If you down your plane on top of an enemy airfield, but don't crash so badly that you're completely destroyed, the AA will fire at your mangled plane for some time, even after your crew is long dead and you've respawned into another aircraft. Not only does this lessen the firepower available to engage actual threats to the airfield, it presents a massive friendly fire hazard to planes taking off or landing there. Would there be some way to get the AA to disregard the target once the crew is dead?

stillborn
07-28-2011, 05:27 PM
As we experienced issues with team balance red75prime from sukhoi.ru forums added a balancing script to the previous version of your mission. Please find it attached. I hope he will include it in the recent version as well.
Speaking of bomber missions I remember naryv (one of the dev team) included very interesting code in this script http://forum.1cpublishing.eu/showpost.php?p=285348&postcount=133

Thank you so much Ataros for the samples and links, they were very useful, i have created a new mission as a successor to DGW which is written from ground up. (link:http://forum.1cpublishing.eu/showthread.php?t=24954)
It does not have af capture ability yet but can be added after the fix for refreshing online briefing page is released.


One comment: If you down your plane on top of an enemy airfield, but don't crash so badly that you're completely destroyed, the AA will fire at your mangled plane for some time, even after your crew is long dead and you've respawned into another aircraft. Not only does this lessen the firepower available to engage actual threats to the airfield, it presents a massive friendly fire hazard to planes taking off or landing there.
Thanks Ralith, the new mission linked above addresses this issue by removing place leaved planes instantly in a 1000m diameter, 10m height cylinder at the center of airfields.

Ataros
08-03-2011, 08:26 AM
Hi!

As you know we added a Spit2 to the captured blue field after reds capture it.
We have an annoying problem with it: after blue recapture the airfield and it becomes blue again reds can still spawn Spit2 on it. Looks like 2 spawnpoints remain in one place (both blue and red).

Could you please have a look at the scripts and check that the red spawnpoint is destroyed after blue recapture the airfield? I have seen code destroying spawnpoints when a field is captured in naryv examples I posted in this forums sections.

stillborn
08-06-2011, 06:33 PM
Hi!

As you know we added a Spit2 to the captured blue field after reds capture it.
We have an annoying problem with it: after blue recapture the airfield and it becomes blue again reds can still spawn Spit2 on it. Looks like 2 spawnpoints remain in one place (both blue and red).

Could you please have a look at the scripts and check that the red spawnpoint is destroyed after blue recapture the airfield? I have seen code destroying spawnpoints when a field is captured in naryv examples I posted in this forums sections.

You'll need to append this piece of script into "iod_walk2.cs", "iod_walk8.cs", "iod_mis2.cs" and "iod_mis8.cs" as in the attachment picture.
foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces())
{
try { bp.destroy(); }
catch (Exception ex) { Console.WriteLine(ex.Message); }
}

Ataros
08-07-2011, 08:07 PM
Thanks a lot! Will try it.