PDA

View Full Version : Tasks & Stats in continuous online campaign


stillborn
07-28-2011, 05:02 PM
Here is an online mission which records and/or uploads 768 different events in game. I hope this helps making our online play more fun.

About Mission:

There are 4 ai controlled frontlines in which ships and armors try to reach the enemy's base in the same path, base defenses and 2 bomber missions in which Wellingtons and He111s bomb an area between enemy airfields. These continuous missions are inside script and loaded into ram at battle start to reduce loading times.

About Gameplay

Each side has two airfields and the aircrafts users can spawn are below:
For Air Tasks
------[Red] SpitfireMkIa, SpitfireMkI, HurricaneMkI
------[Blue] Bf-109E-1, Bf-109E-3, G50
For Ground Tasks
------[Red] BlenheimMkIV, HurricaneMkI
------[Blue] Ju-88A-1, Aircraft.BR-20M, Bf-109E-1
For Naval Tasks
------[Red] BlenheimMkIV
------[Blue] Ju-88A-1
also selectable bombs are limited for a balanced play
To complete a task you need to at least damage an internal part or cut a limb of an actor of your task type
Bombers spawn approximately 10km behind your base, travel all the map, bomb their target and return back to where they started, after that they turn in a circle a few times and disappear, you should consider this if you are heading to a bomber behind enemy lines and outside the map. Unfortunately they are too dumb to land and removing them by damaging leads to unfair stat collection so do not engage bombers outside the map.


Everything is written from ground up according to the examples from devs. I have included a balance system based on red75prime from sukhoi.ru's balance code which is modified not to use dictionary for performance and to be compatible with stat collection. For max performance stats processing is done asynchronously in a seperate single thread which sleeps automatically when there's nothing to be done.If you experience lags try lowering stbSr_Worker thread priority in line 140 and/or increasing queue length in line 99.

Files must be in the "missions/multi/dogfight/StbVolcanicIslands2/" folder to work. Stats are read back by default (optional) every time server/battle is restarted so collecting dta for a week or month is possible. Different stats like "tasks completed per place enters" or "ace of the week/month" can be variated.

More details about campaign can be found in attachment pics and readme.txt, i have also included the visual studio solution in zip so you can benefit from its syntax correction, dont forget to update reference paths of core.dll, gameworld.dll and part.dll in solution explorer's reference folder if you plan to use visual studio solution.

All my methods and variables have stb prefix so you can integrate your own code without any worries. You can even integrate the script to another map directly by just setting "all the boolean variables except the ones related to stat collection&balance" to false at the "customizable variables region".


Latest version (1.1) is here (http://forum.1cpublishing.eu/showpost.php?p=321748&postcount=15)

adonys
07-28-2011, 07:47 PM
thank you, mate, I'll have a look.

SNAFU
07-28-2011, 08:49 PM
Alter Schwede, :-o:-P

I hear what you say, but I don´t understand a word. I wish I could follow your script, above the 5th line... :grin:

Anyhow, looks great! :cool:

SNAFU
07-28-2011, 09:08 PM
Your mission is now running on our test server (III./JG27TestServer) for a try, will report back tomorrow evening (UTZ+2).

stillborn
07-28-2011, 09:41 PM
Your mission is now running on our test server (III./JG27TestServer) for a try, will report back tomorrow evening (UTZ+2).

you should be able to see my stats in the log right now :grin:
please report any mission related errors you experience from the StbVolcanicIslands2_errorlog.txt

SNAFU
07-29-2011, 05:35 AM
Here the stats:
http://www.india499.server4you.de/JG27_Snafu/stats/StbVolcanicIslands2_playerstats_low.htm

Seem to work! :cool:

But I have no "StbVolcanicIslands2_errorlog.txt" on the disk, sorry. Do I have to create that file, so it can write into?

Ataros
07-29-2011, 07:58 AM
Hi, stillborn!

Thanks a lot for your mission again! Just had a quick look at it. Looks fantastic!

I did not see any frontline on the map. I assume it should move depending on tanks progress? Moving frontline gives players incentive to fight harder.

Could you please write a very short briefing for the mission explaining what sides can achieve, e.g. moving frontline, capturing some objectives, etc. I think it is important for players to know what they should concentrate on, e.g. if shooting down bombers or destroying ships helps to move frontline. How AI bombers select targets? I would like to have a short description to post on the forums to attract more players to the servers running this mission.

BTW. On Repka #3 we added Spit2 to the captured blue airfield. It is a good incentive for everyone to fight for it now.

Also I have a small request especially important for this new mission as it has only 4 airfields. Vulching is a big problem for small maps with few airfields. Could you please include a script damaging attacker's plane if someone damages enemy within 1200m diameter and 1000m altitude from an airfield? Maybe you have better idea how to prevent vulching on small maps.

What are the balancing rules? Is it progressive like 15 seconds if there are 10% more fighters, 30 seconds if 20% more fighters, 1 minute if 30%, 3 minuted if 40%, etc. or something like this?

Could you please include air kill per death, air kill per sortie, current streak, max streak into statistics and same for ground and ship kills? Do I understand you correctly that statistics will be continuous for months and years of the server life? I.e. each pilot's record can be viewed from the very beginning? I did not get what you mean by "Different stats like "tasks completed per place enters" or "ace of the week/month" can be variated." Can not see anything like this in stat sample.

Thank you for great code again!

PS. What do you think of writing a mission like this one? http://www.adw.alkar.net/en/static/rules/index.html

Ataros
07-29-2011, 09:48 AM
Need urgent help, please!

When trying to run the mission on Repka #2 server we get a pop-up window "Can`t open / create file". This prevents server from automatically restarting the mission twice a day as we do with other missions. What could be causing it and can it be fixed?

btw. Server has a Russian version of the game and OS (Win Server 2003 x32). Thus system uses comma as decimal separator, not a decimal point. This caused some issues in other missions. BigRepa changed paths in your mission to match x32 version.

StbVolcanicIslands2_errorlog.txt is not created either.

Edit.
Attached is the mission with paths edited for x32 version. Please have a look if it does not miss anything.

stillborn
07-29-2011, 12:08 PM
Need urgent help, please!

When trying to run the mission on Repka #2 server we get a pop-up window "Can`t open / create file". This prevents server from automatically restarting the mission twice a day as we do with other missions. What could be causing it and can it be fixed?

btw. Server has a Russian version of the game and OS (Win Server 2003 x32). Thus system uses comma as decimal separator, not a decimal point. This caused some issues in other missions. BigRepa changed paths in your mission to match x32 version.

StbVolcanicIslands2_errorlog.txt is not created either.

Edit.
Attached is the mission with paths edited for x32 version. Please have a look if it does not miss anything.

ive checked the file the only different lines are upload related ones at the top, make sure the "user account credentials application(game) uses" have read/write/create etc permissions for the folder StbVolcanicIslands2 and the ftp username and password has the same permissions for the upload path. Some windows user accounts may have read write change permission but not create, this is more typical in server environments, make sure the game is running as administrator.

the path creation method i used has some hardcoded dumb approach, like this:
1. get the application path => (which is "C:\Users\user01\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\cache" in my computer)
2. crop last 5 chars => ("C:\Users\user01\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\")
3. append "missions\Multi\Dogfight\StbVolcanicIslands2\" to it => ("C:\Users\user01\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\StbVolcanicIslands2\")
4. create all the absolute full file names from this => ("C:\Users\user01\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\StbVolcanicIslands2\ StbVolcanicIslands2_playerstats_low.htm" etc etc)

maybe cache folder is named something else in russian version or you have uploaded it to "C:\Program Files (x86)\Steam\steamapps\common\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\StbVolcanicIslands2" instead, sorry i forgot to mention this, but you have a user stat in the file with name "satar" which means all this progress completed correctly and it wrote to the file successfully and you dont have to care about the explanation in the upper paragraph.:grin:

Currently my system has a different default CultureInfo too (uses comma as decimal separator). I've created an invariant culture info(en-US) variable and used it in all required string conversions in all threads. So you dont have to worry about different system settings, this is very very low probability but there may be an extra change required because of the Russian game version, cant tell it without testing.

just make sure you use ToString(stb_nf) or "ToString(stbSr_nf) in stat recorder class" instead of ToString() if you want to add anything in the future.

But I have no "StbVolcanicIslands2_errorlog.txt" on the disk, sorry. Do I have to create that file, so it can write into?
StbVolcanicIslands2_errorlog.txt is not created unless there is an error, its totally fine if you dont see it.

Ataros
07-29-2011, 12:29 PM
The problem is we have to close the pop-up window "Can not read/write file" manually when restarting the mission. Then it works fine.

BigRepa told he had to change paths from "Program Files (x86)" to "Program Files" because server runs x32 version. Could this be a reason? Can it be avoided (no mention of (x86) in path names?

stillborn
07-29-2011, 03:01 PM
I did not see any frontline on the map. I assume it should move depending on tanks progress? Moving frontline gives players incentive to fight harder.

I was planning to create dynamic frontmarkes placed at the positions of ships&tanks and updated periodically but i had no time, this is relatively easy and not cpu intensive, will include this feature when i have time.

Could you please write a very short briefing for the mission explaining what sides can achieve
Mission Info is in the attachment, I had prepared a better info for mission but lost it when my raid array failed, :( anyway this would be useful too.

What are the balancing rules?
there are two modes for balance either by fighter ratio difference or by fighter count difference. Default values are these:

stb_FighterBalanceActive = true
used for enabling/disabling balance system
stb_BalanceFightersByRatio = true
means balance will be checked according to ratio difference
stb_DesiredRatio = 2.0
means if one side's fighter count is greater than 2 times the other side's fighter count, new players at the high ratio side will be blocked from spawning fighters, this scales well with changing total player count whereas setting BalanceFightersByRatio to false makes the balance system check for a current fighter count difference which is the constant value defined in DesiredDelta. For example DesiredDelta = 5 means there can only be 5 more fighters on a side regarless of total player count
stb_DesiredDelta = 5
stb_MinCountForBalance = 10
this means the code wont block any player(fighter) if total player count is lower than 10 even if the ratio or difference is above the desired values.


Could you please include air kill per death,...
collecting stats for deaths(ondead events) is a little bit more tricky, for example you damaged a ship, its burning but not dead yet, you exit and changed side, than the ship died, game's onActorDead event triggers and you seem to kill your own ship, because the parameters on this event are just references which are up to date. The same is true for reverse and opens a door for easy unfair score gain by attacking your own side, with missions allowing side change, in script there is no easy way to know "the initiators side(army) when the related events occured" causing another event even if you recorded army change times for each player manually and checked them with event times, This is also much hard&complex to write and very cpu intensive compared to current stat collection system. The right way to go this far in my opinion is in c++ not managed c#. The game also has a nice score system for the kills in which your score increases even depending on how well you hit a target. (i got 7 score points when i killed a ship by dropping a bomb to water, a few meters next to it but it gave 17 score points when i dropped the bomb right into its belly) It also seems to resolve these conflicts. There's no need to do the same calculations on the script which the game already does, it could be a good idea to ask the devs for a tip or example about this.

About different/variated stats:
if you stop the battle, move the "StbVolcanicIslands2_playerstats_full.txt" and "StbVolcanicIslands2_playerstats_low.htm" files to another folder manually and restart the battle, it will create the stats from scratch. This way you can archive them daily/weekly or however you like and can give the player with most air kills a nick or award. etc. i'll write an example about the things like "tasks per placeEnters" shortly.

Ataros
07-29-2011, 03:22 PM
Thanks a lot for all the answers.

This is how a path to cache looks
C:\Documents and Settings\Администратор\Мои документы\1C SoftClub\il-2 sturmovik cliffs of dover\cache

This is Russian WinServer 2003 x32, contains Cyrillic letters. Can this cause the problem?

stillborn
07-29-2011, 04:18 PM
Thanks a lot for all the answers.

This is how a path to cache looks
C:\Documents and Settings\Администратор\Мои документы\1C SoftClub\il-2 sturmovik cliffs of dover\cache

This is Russian WinServer 2003 x32, contains Cyrillic letters. Can this cause the problem?

attachment has a modified version for you, i hope this resolves the error.

i dont think its caused by Cyrillic letters, the cs files containing nonstandart chars are saved as utf8 by default unless you force them to save as ascii, i think its the Path.GetDirectoryName(System.Reflection.Assembly.G etExecutingAssembly().Location) command that returns something different in win server 2003.

make sure you extracted the modified archive to

"C:\Documents and Settings\Администратор\Мои документы\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\StbVolcanicIslands2\"

, not the one inside program files so "StbVolcanicIslands2.cs" file location should be like this:

"C:\Documents and Settings\Администратор\Мои документы\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\StbVolcanicIslands2\ StbVolcanicIslands2.cs"

stillborn
07-29-2011, 06:32 PM
here's a file explaining which types of damages goes where in stats htm

stillborn
08-09-2011, 04:07 PM
Here is version 1.1
Changes:

added dynamic frontmarker creation from ground and naval unit positions
added "last place online" and "tasks per place enter" columns to stats
fixed stats html client side sortability
stats html is automatically sorted by tasks per place enter when opened
stats html is now standalone, does not require any css or js
added a servername option for stats html
increased upload interval to 133 secs and made some minor adjustments to other timings
ship hulls are now removed
ai bomber difficulties are all ace (0.99)
reduced the number of ai bomber to 3 for each side
mission runs at least 2x faster due to reduced ai bombers and minor tweaks in stat thread
fixed OnPlaceEnter and OnPlaceLeave script bugs
"removal of unused planes and ai" script is more stable
mission is now in dll form for easier integration with other scripts


StbViMission.dll must be in the folder where Launcher.exe is.
You can put the "StbVi.cs" and "StbVi.mis" files anywhere you like and run the mission from there.
If you want to edit the mission further, visual studio solution for the dll is in the second zip.

Please turn on "Cannot Swith Planes" difficulty option when running this mission because Blues can get into He111s by pressing AltF1 but reds cant use Wellingtons.

Btw it seems like game only lets me to load dlls from the folder where Launcher.exe is.
I used "//$reference StbViMission.dll" for import at the top of the script.
"Assembly.LoadFrom" and similar methods work fine but they are useless because i use this dll to define the class type of mission at the top.
If you find a way to include folders with "//$reference" or another way to reference a dll from another folder (without editing an xml or ini, just from inside the mission script) please suggest.

41Sqn_Banks
08-09-2011, 04:31 PM
You can give the path the the dll relative to the path with the launcher.exe, for example:

//$reference parts/il2dce/IL2DCE.Mission.dll

stillborn
08-09-2011, 05:09 PM
You can give the path the the dll relative to the path with the launcher.exe, for example:

//$reference parts/il2dce/IL2DCE.Mission.dll


Thanks for the help. I tried this now by moving the "StbViMission.dll" into parts folder and changing the top line in "StbVi.cs" to "//$reference parts/StbViMission.dll" but it didnt work.
Your example naming seems to be identical to the namespaces you use, maybe i should wrap my custom class in a namespace according to the dlls folder (yes i havent used a namespace). or some kind of default compiler option for my net4.0 runtime is different and messing things up.

41Sqn_Banks
08-09-2011, 06:34 PM
This is really strange.

http://code.google.com/p/il2dce/source/browse/trunk/IL2DCE/Campaigns/IL2DCE.GameServer.cs

I can load assemblies with the following script.

However I get a exception because Core is not marked as serializable. Do you have a similar problem and have to mark classes you use within a mission as serializable?

stillborn
08-09-2011, 09:02 PM
I guess its good to access "imported objects with //$reference" after everything is loaded and initialized. From what i see things differ a bit before and after the initialization of a mission. For example one strange thing i noticed is: The first version of this mission had "Assembly.GetExecutingAssembly().Location" command inside OnBattleStarted Method, which returned a path with "1cSoftClub" in it but the same command returns the launcher.exe path when used as a variable's default value at the top.

I never had an issue with serializability when both deriving the Mission class from a custom class and when using/accessing another class.

if you are not saving your class or another object inside with its current state intentionally, probably something in the process of packing your dll and/or loading it requires serialization, to save or to send it somewhere in memory as a stream, etc. try using alternative approaches when importing/accessing your classes. Hope this helps.

Btw i'm just curious, is there a specific purpose of importing gamePlay.dll via //$reference, which is as far as i know, identical to this
using maddox.game;
using maddox.game.play;
it would be good to know if there are extra things accessible with that way :grin:

41Sqn_Banks
08-09-2011, 09:13 PM
I had to import gamePlay.dll because I cast a IGamePlay object to GameDef. GameDef is defined within this assembly and is otherwhise not know. In fact this gives a lot of new possibilities because GameDef has some useful methods (like the Chat event).

With "using" you only don't need to write always the namespace before you access something of it but it doesn't load the assembly.

stillborn
08-09-2011, 09:28 PM
wow this is great, will give it a try, thanks a lot!:grin:

41Sqn_Banks
08-09-2011, 09:30 PM
// IL2DCE: A dynamic campaign engine for IL-2 Sturmovik: Cliffs of Dover
// Copyright (C) 2011 Stefan Rothdach
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//$reference parts/IL2DCE/IL2DCE.dll
//$reference parts/core/gamePlay.dll
//$debug

using System;
using maddox.game;
using maddox.game.world;

public class Mission : AMission
{
public override void OnBattleStarted()
{
base.OnBattleStarted();
maddox.game.GameDef game = GamePlay as maddox.game.GameDef;

game.EventChat += new GameDef.Chat(Game_EventChat);
}

void Game_EventChat(IPlayer from, string msg)
{
if (msg.Contains("!hello"))
{
GamePlay.gpLogServer(new Player[] { from }, "Hello World!", null);
}
}

}


This script is also causing the serialization exception. It looks like the usage of GameDef forces the serialization. This is really a shame as capturing the chat would be very useful for multiplayer missions ... but writing a multiplayer addin was successful so far :(

stillborn
08-10-2011, 01:55 AM
no matter what i tried i couldnt manage to create a reference to gamedev object, all castings i tried returned null in Init method, probably would get serialization error instead in OnBattleStarted method, since GameDev is abstract and its constructor which the game uses needs an IGameInterface, there must be a way to keep it as a reference with the right type. i guess "as" operator tries to serialize gameplay for conversion. idk if gameplay can be casted like this directly or indirectly. which makes me think devs may have done this to restrict these parts from users. it would be better to ask for a proper way for this, maybe they can include new methods/properties for us in the future to interact more extensively.

41Sqn_Banks
08-10-2011, 06:33 AM
Did you check if GamePlay is null before the cast?

Basicly you can do the cast using

maddox.game.GameDef game = (maddox.game.GameDef)GamePlay;

- this will cause a exception if cast fails

or

maddox.game.GameDef game = GamePlay as maddox.game.GameDef;

- this will return null if cast fails.

I tried both and both did work. Of course I still get the serialization exception.

Ataros
08-12-2011, 10:12 AM
Hi, Stillborn!

Is it possible to reduce number of destroyer ships by about 30-50%?
We have complains that it is not possible to have dogfights above them due to their uber AAA.

BTW some stats from Repka 2 http://r2.repka.su/

Thanks for the mission again!

Wandalen
08-29-2011, 09:33 PM
Hi, Stillborn!


BTW some stats from Repka 2 http://r2.repka.su/



How did you do that mate?? trying to find out how to get the stats up but not mutch to find in google plz help ;-)

Ataros
08-30-2011, 07:14 AM
How did you do that mate?? trying to find out how to get the stats up but not mutch to find in google plz help ;-)

The code is included in this mission by stillborn. If you open files there is place to enter your ftp address and password. The rest is done by the mission :) I can not explain how, as I am only a user. There are some details in original stillborn's post. He mentiones that anyone can use this stat code with any other mission. Someone else from this forum uses this stat with a different mission. I've seen a link in someones sig.

Wandalen
08-30-2011, 07:16 PM
Thanks Ataros :) overlooked it after searching various forums half the day to my eyes bleeds ;-)
Must get me some stronger glases :cool: