Jump to content
Sign in to follow this  
Rydygier

Problematic Scripts Museum presents an exhibit: Drunken Marathoner

Recommended Posts

Exhibit No. 00001/20131111/Ryd



DRUNKEN MARATHONER

1. The file

Package contains demo mission, where script is activated via Juliet radio channel (0-0-0):

2. What this does?

Our specialists after long research determined following:

- script grabs all crossroad segments inside designated area;

- combines them randomly in pairs;

- for each pair performs camera run from A to B along the road network;

- finishes after last pair run;

- player, by pressing any keybord key, can pause the run and place himself at currently visible spot to investigate it. At any time can resume run by choosing action menu option.

User can run the script as is, then whole map is covered (note - for Altis this means really long road network analyze and pathfinding delays), or to select only chosen area. To do so must be placed on map (best circular) trigger named
RydDM_InitPlace
. Its position and angle determines initial camera position and angle, while its radius determines chosen area around center. Then script will look for dead ends only inside such area, still routes may sometimes lead also outside that radius.

User can also set:

- custom run speed by defining
RydDM_Speed
variable with positive number. Recommended values are 10 to 100 (default 30), where lower number means faster run;

- custom height above road surface in meters -
RydDM_Level
, 1.5 by default;

- additional visual effects (turned on by default) -
RydDM_Effects
(true/false).

3. Purpose

Unknown.

This exhibition has been prepared by courtesy of:
Problematic Scripts Museum
. Exhibits so far:

Script you can freely modify, copy, "cannibalize", to use in your projects. It is released under APL-SA license. I'll be grateful for notification about each such usage.

Edited by Rydygier

Share this post


Link to post
Share on other sites

Perhaps I need more coffee but after reading I still have no idea what this is :p

Share this post


Link to post
Share on other sites

Quite correctly. :) It was quick excersice of combining several scripts into one, strange idea. Doing that was nice fun yesterday evening, effect is enjoyable to me, purpose is... secondary issue here. Just try. Launch and watch, how camera runs across the island. It can be used as kind of automated, dynamic island tour for people too lazy for more active tourism (eg me). :) Or perhaps a source of inspirations for something more practical?

Edited by Rydygier

Share this post


Link to post
Share on other sites

ah ok now I understand.... I do enjoy a good tour so I'll check it out :)

Share this post


Link to post
Share on other sites

Looks really funny, definately something to work on. I really miss a good map of the islands with points of interest or good mission areas. Since the Arma maps getting bigger and bigger it's quite time consuming to find a good spot for a mission idea.

Share this post


Link to post
Share on other sites
Looks really funny, definately something to work on. I really miss a good map of the islands with points of interest or good mission areas. Since the Arma maps getting bigger and bigger it's quite time consuming to find a good spot for a mission idea.

That inspired me to add some small feature (link updated with DM 1.1):

Player, by pressing any keybord key, can pause the run and place himself at currently visible spot to investigate it. At any time can resume run by choosing action menu option.

Edited by Rydygier

Share this post


Link to post
Share on other sites

Sounds great, will try it later. "Purpose incoming." :D

Share this post


Link to post
Share on other sites

Haha this sounds cool.. You don't need a purpose if your having fun !!

Share this post


Link to post
Share on other sites

Noted an interesting issue. Usually path for next run is calculated pretty quick. But sometimes it takes so long, one may think, script failed. But no. In most such cases script is fine, but sensitive on some game issues.

Some background: probably most fancy part of DM is code responsible for pathfinding from A to B using roads. If all is OK it works fast and effect may be like this:

Path1

But if code can't find roughly straigth path, begins interesting part (well, at least could be interesting for some scripters). In such case it looks elsewhere until find route or use up all possibilities. On map of Altis size road network is so big, build with so many road segments, it may take dozens of minutes.

But when and why code can't find reasonable path between two road segments? When are not connected directly nor through other road segments. That happens, when eg one end is on separated, small island:

Path2

Or when encounters road network issue, where two segments, while visually connected, in terms of scripting are separated. For human eye there is connection, for script based on roadsConnectedTo command, is dead end. In such case, if possible, code takes detour:

Path3

or is as lost, as for separated island case, if is located on part of the road network completely isolated because of disconnected segments.

Hard to find good soultion (except devs fixing road network segments connection). I'm using backup code, that uses nearRoads instead roadsConnectedTo, but to keep decent performance, it is used only on supposed dead ends, not when only side branch leading to end segment is isolated (can't recognize such situation unless backup is used all the time instead of roadsConnectedTo).

Solution for now to reduce that problem: I'll change the script, so will run not between dead ends, but between crossroads.

Despite it is charming, decided to sober a bit our Marathoner, so added some code to hopefully get rid of these weird opposite-direction-turns.

Edited by Rydygier

Share this post


Link to post
Share on other sites

interesting.. I wonder if you could run through the entire road network once and using near roads, build an array of patches like a lookup table to tell broken segments where to go(as long as there is another road segment within a certain distance). then you would only need roadsConnectedTo making all subsequent calls faster.

you could run that once and then copytoclipboard and copy it to a file to #include in your code (i wonder how big a file like that would be...and how many broken segments there are)

I haven't looked at this yet. what sort of algorithm are you using? Is it using the corners of roads as nodes or are you using each road peice as a node?

edit: I just had a look... very nice work. must have taken you a while

Edited by Kunsa
RRRAAWWWRRRR!!!!

Share this post


Link to post
Share on other sites

DM took me several hours so far. But it is a compilation of previously created pieces of code, only parts was made from a scratch. Pathfinder took several days from 0 to complete.

you could run that once and then copytoclipboard and copy it to a file to #include in your code (i wonder how big a file like that would be...and how many broken segments there are)

I tried to gather into such saved for later array some road segments (dead end segments), but such array looks like [18229933: , 1389200: , etc], where in later use elements no longer reffer to the actual road segment object and all array returns only syntax error (due to ":" I suppose).

Seems, that there is much more broken connections per area, than eg on Chernarus map. I wonder, why...

what sort of algorithm are you using? Is it using the corners of roads as nodes or are you using each road peice as a node?

That was one year ago, when I created this, but if I remeber correctly, it runs from A to the next crossroad, and saves that series of segments as kind of "worm", saves also its endings (further directions possible to choose, like "antennae"), also into another, one, cumulative array of endings and organises them in this array in such order, so closest to B antennae is first element always and so on. Then chooses not checked yet "antennae" ending closest to B from that colective array (first element), and continues next step (new "worm") that way until encounter next crossroad etc. It does that until it reacheas B segment itself or there is no longer "antennae" to check. "A tail" of any worm (first road segment) is always an antennae of some other worm or A segment. Now we have "a tree" of connected (tail+antennae) "worms" collected in one array, thal looks like: [[[worm1 body (segments from crossorad to crossroad)],[antennae1],B reached?]],[[worm2 body],[antennae2],B reached?]], etc], where some branches leads nowhere, and other, linked together, form needed path from A to B. To sift off only good path, code is reversing order of worms in the array. Now first worm is that containing our goal (B segment). So its "body" is first element of reversed final path (path from B to A). Now code goes through all other worms and marks to deletion subsequent worms until finds a worm connected with latest worm of final path. Then that worm becomes a refference, and foreach loop goes further, marking to deletion subsequent worms until finds a worm connected with new refference's tail. When all worms are checked that way, all marked for deletion are deleted from worms array. That way we cut all branches except "tree trunk" (it is intersting, that this, seemingly reckless, way we are get rid only all "blind" branches without a risk of "accidental" deletion part of the good path - this trunk. Apparently order of worms in worms array ensures that), chain of worms leading from B to A. Last part is to reverse final path array again and connect all worm bodies in to one path - a chain of road segments leading from A to B.

Code is interesting, although not guarantees optimal path.

Example:

5pxc.jpg

S - start

E - end

Blue - worms' bodies (deleted)

Yellow - not checked antennae

Green triangles - final path

big green dot - places of supposed segments disconnection, where backup segment search was used.

Red numbers - supposed dead ends.

Edited by Rydygier

Share this post


Link to post
Share on other sites
Guest

Release frontpaged on the Armaholic homepage.

===============================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×