Log in

View Full Version : Am I on the right track?


moggel
04-10-2012, 01:09 PM
Scripting experts...

A few days ago I started to learn how to script and got alot of help from FG28_Kodiak, my personal "scripting swami" as it is (thanks alot mate ;) ).

I only started to fly CloD some week ago and so far I have managed to complete the offline British campaign. One thing I sorely missed, from first to last flight, is a living breathing world. There where no cars on the roads, no trains, no animals grazing the fields of the green and pleasant land I flew over. The sea was just as empty unless the individual script said otherwise.

So, as a first scripting project I gave myself the task of breathe some semi-dynamic life into. Mainly it was just a good starting point.

I spent a full day of explring, experimenting and coding before it was done but it seems to work quite well. As I fly over the British countryside I now see traffic and wild life automatically.

But now I'm not sure if my solution is optimal and worth using as I move on. Maybe it will turn out to be worthless once I start learning how to build campaigns and/or online missions? Perhaps I should have solved it differently?

So I thought I'd present the solution here and have all you scripting gurus give some feedback and maybe a few good suggestions on how to move on.

I call my little project "LiveMap" and it works like this:

It's based on a class -- "LiveMap" -- that tracks the movement of a "reference actor" and automatically loads sub missons as that actor moves across the map (the reference actor is assumed to be the player but can be any AiActor for experimental/debugging purposes). The logics is based upon FMB sections (the map grid) and as the "reference actor" enters a new section the LiveMap class automatically looks for and loads all missions covering that sector. (LiveMap can also be configured to load all adjacent sections if that is to be preferred.) Each "LiveMap mission" is found using its file name so it's important to name them correctly using this format: "livemap_<X>_<Y>*.mis". For example, the mission covering section X230,Y250 can be called "livemap_230_250.mis". If I would like to separate different types of "life" into several missions covering the same sector that's ok too. Ships, for example, can be put into their own file called "livemap_230_250_ships.mis".

Now, since there is the potential to have the system on its knees if too many sectors are activated the LiveMap class automatically discards sectors after a set period of time (configurable). Also, since some traffic probably should be allowed to live it is possible to overrule the "dispose rules" at runtime using custom logics. Typically large ships and perhaps trains would be allowed to live throughout a full mission. If you see a large tanker heading north off the coast of Ramsgate you'd expect it to still be out there somewhere when you return 20 minutes later.

There's more (dealing with mission re-use, life time and dynamics) but hopefully this will give all you scripting experts enough of an idea to give critisicm. I will have to spend some additional love on making those canned missions seem more dynamic. Otherwise I will start noticing how the same train seems to always head off from the same station every time I fly into a certain sector. But it's a start.

Now, pros and cons as I see it...

PROS:
1. Each sector being covered by a separate mission can be tailored individually to suit the kind of terrain it covers. I would expect alot more car traffic flying over a London suburd than would I over Salisbury for example.
2. Anyone with some FMB competence can contribute to the "LiveMap" project.

CONS:
1. Potentially alot of work producing "sector missions".
2. Each sector is basically static (can be remedied by code to some extent)

Now, let's hear it. Is this an ok solution for adding "life" in a semi-dynamic fashion. Will I be facing problems as I move on to building more advanced stuff like dynamic or online campaigns?

FG28_Kodiak
04-10-2012, 01:27 PM
Would be a great improvement, only problem i see are performance issues like spawn laggs in online games. :cool:

Ataros
04-10-2012, 01:41 PM
1. Potentially alot of work producing "sector missions".

Missions can be generated automatically by script similar to how naryv generates tanks in his sample missions (see an archive in a sticky above).

moggel
04-10-2012, 01:45 PM
Would be a great improvement, only problem i see are performance issues like spawn laggs in online games. :cool:

Yes, I realize that. I tried to do this by spawning a background thread to do the loading but this doesn't seem to fit well with the scripting engine. Seems background threads are ignored. Perhaps I should spend some more time exploring that track? I assumed I could use the "Task" abilities of .NET 4 but I could try using the old "Thread" approach instead...

moggel
04-10-2012, 01:46 PM
Missions can be generated automatically by script similar to how naryv generates tanks in his sample missions (see an archive in a sticky above).

That sounds promising. The reason I started out with this approach was I found no way to "detect" where to place actors dynamically. I'll explore naryv's scripts and see what I've missed. Thanks.

moggel
04-10-2012, 02:05 PM
Missions can be generated automatically by script similar to how naryv generates tanks in his sample missions (see an archive in a sticky above).

Ataros: Can you provide a link to that script? I've browsed through te stickys but the only stuff I found from Naryv was one that positioned the players in different aircrafts and let him/her choose diffently using the order menu.

Apparently my browsing skills aren't good enough...

FG28_Kodiak
04-10-2012, 02:39 PM
äh do you downloaded _tanks from narvy? i added it to
http://forum.1cpublishing.eu/showpost.php?p=406978&postcount=22
and CTF_Rondel in the attachment,

moggel
04-10-2012, 02:50 PM
Thanks Kodiak.

Ataros
04-10-2012, 05:50 PM
In the 1st message here is attached archive. In the archive there is a folder with several scripts by naryv http://forum.1cpublishing.eu/showthread.php?t=26523

He spawns tank groups at position of front-markers but this can be changed to player aircraft position.

moggel
04-10-2012, 06:13 PM
"Front markers" is new to me but it sounds like I would still have to base my solution on sub mission files then? I was toying with an idea to add some spawn points just to have some sort of geographical references on the map but I need to explore that concept more.

Can front markers be classified/tagged somehow? I'm thinking some would be used to spawn road traffic (placed on roads), others are for trains, livestock, ships and so on.

Suppose I need to explore the FMB deeper...

Smokeynz
04-10-2012, 09:41 PM
I wonder if the server would be overally taxed if you have too many players all being tracked and each spawning in objects/missions.

I have a similar zoned arangement in a script development. However to stop multi spawning I have a randomised selector including null missions so that there is chances nothing happens aswell. Once activated though the zone is on timer (randomised period), so that following player does not activate again repeatedly.

As much as we want a open free play, the designer of the missions and pack should consider operations that target players attention to an area. Otherwise you might as well play single player. With that, the zones could be confined to a battle area of importance and thus lower specific mission per zone trigger and importantly the need to have a gazillion missions which do nothing.

5./JG27.Farber
04-11-2012, 07:14 AM
To add more life, I populate the places players will see most and the rest I just leave quite bear. I think its a balance between performance and looking good. I will liven up airfields and targets usually. Maybe the docks. A few barrage balloons. Trains can have a good livening effect as they travel far and are really visable.

But for things like an AAA battery in a wood, just plonk them down ;)
No one will ever see them.

moggel
04-11-2012, 04:56 PM
To add more life, I populate the places players will see most and the rest I just leave quite bear. I think its a balance between performance and looking good. I will liven up airfields and targets usually. Maybe the docks. A few barrage balloons. Trains can have a good livening effect as they travel far and are really visable.

But for things like an AAA battery in a wood, just plonk them down ;)
No one will ever see them.

I would have to agree on most of that. Even road traffic is difficult to detect unless you know it's there. With the Regent Bus being a possible exception of course.

I did write the LiveMap class to support a specified limited region on startup and ignore anything outside so its very easy to have it live up a focues part of the map.