the RUBE library - work in progress
A hotchpotch of Arma2 functions, aimed to offer tools to build better random missions (like in something coherent, meaningful and whatnot..). Evaluating the world in some meaningful way, finding reasonable positions, planing routes from A to B, spawning lots of stuff and interesting behaviour (well, not yet), computing the convex hull of stuff to spawn even more stuff, ...
The ultimate aim is to be able to offer a set of `recepies` such as spawnForestCamp (of any faction) including the desired infrastructure/-type aswell as units with appropriate behaviour. Or a spawnRoadBlockade, spawnFOB, ... procedural stuff building stuff, if you will, as opposed to the given set of fixed compositions.
You will note, that I'm not there yet. Some ideas are carried out pretty poorly (some stuff is just silly and bound to be removed), other stuff doesn't even work yet... But feel free to take what you might find usefull, rip it apart, enhance it, use it.
I hope that one day, I can proudly present you a mission that will use this stuff, spawning stuff for you to enjoy infinitely. Don't hold your breath though. :/
loading the RUBE library might look something like this (init.sqf):
//////////////////////////////////////////////////////////////
// loading RUBE function library
// (which includes the BIS functions library; so there is
// no need to place the module on the map/in the editor)
[] call (compile preprocessFileLineNumbers "RUBE\init.sqf");
waitUntil{!(isnil "RUBE_fnc_init")};
And you'll also need a description.ext with the following contents:
#include "RUBE\core.hpp"
#include "RUBE\common.hpp"
class RscTitles
{
#include "RUBE\rsctitles.hpp"
};
class CfgSounds
{
#include "RUBE\sounds.hpp"
};
latest work:
- RUBE weather (generator/engine)
- A pseudo-scientific weather generator, generating forecast for n days, based on a seasonal model (out of many), statistically verified with a small test suite... (see details, summary). So weather will be continuous/permanent (e.g. for a campaign) and forecastable (including a nice weather report dialog; notebook and print-version). That is: the quality of a forecast rapidly drops with only a few days, which is realised by mutating/evolving days more, the further they're in the future...
And then we have the weather engine, a small finite state machine, that makes the weather with respect to the given weather data/forecast...
what RUBE weather models:
- Temperature (including transitions from rain to snow, lapse rate, diurnal cycle, ...)
- Atmospheric pressure (twice, once for the local system, once for the surrounding/imaginary one, s.t. we can work with some pressure coefficients and a pressure system classification, telling us whether we have a Low or a High...).
Pressure - of course - decreases with altitude (modeled up to the troposphere) and as pressure decreases, so does
the temperature (inversion's aren't modeled), while wind speeds increase, which leads to less fog up there...
- Different storm-models (widespread, daytime heating storms, ...) depeding on pressure and latitude and stuff.
- Fog and radiation/ground fog for which we have a diurnal cycle too with three main phases (sunrise, daytime, sunset) and which is affected by wind speeds and stuff.
Then we have a color filter that depends on the temperature, the season and the daytime, s.t. a winter really looks cold and summer rather warm...
what RUBE weather does not model:
- Humidity. There is no dew point, there's no equilibrium or saturation vapor pressure. What we have is overcast and precipitation (and maybe fog) as monthly averages defined by the season model. For the precipitation there is a precipitation chance (as in days per month with precipitation) and there's a monthly average intensity for it. Thus it rains by chance, biased by the season model (and in the end by the pressure system; we bias the environmental/surrounding pressure such that we should got the desired amount of local Low's, aka rainy days...) and that's it.
And while this is a drop'n'forget (at least if you use the RUBE library as addon and run the module), you may pretty much customize/script anything. You can manipulate all the forecast data prior to launching the weather engine. Or you can write your own `disturbance masks` (by which those storm-models are realized): by those you can throttle overcast and precipitation by means of a linearly interpolated keyframe-approach over the day. Basically you can tweak the whole band (minimum, maximum) and the disturbance mask's exponents for its oscillators (which are biased by latitude by default)... so all in all you still should have full control over the weather, and be able to script it as your missions needs it.
Btw. that forecast stack of weather data for n days can be absolutely abused, s.t. a forecast for one day could be the forecast of a much smaller time-entity... by simply manipulating the forecast data on your own and resetting the weather engine as desired... (for example you could transition to a drastically different weather on some event by scripting; all there is to this is the weather engine's cycle time as a natural delay for the transition; though you could tweak this time too, so...)
usefull highlights guaranteed to already work as promised:
- RUBE_makeDraggable, RUBE_makeDroppable & RUBE_makeBuildable
- Dragging stuff around (like ammocrates or supplies) and letting stuff beeing dragged around by AI. Simply releasing stuff again or drop it onto a vehicles or even tents cargo area or let the AI do it. Let the AI unload a fully loaded truck and other cool stuff. Oh and an alternative to CoIn where you initially spawn building sites instead of the desired structures, on which units can work, as long as enough supplies/draggables are around... (droppables use the RUBE_rectanglePacker, so every vehicle is naturally limited by its cargo area; needs to be manually measured, which is already done for probably all usefull core objects from A2/AO)
Check out the RUBE drag'n'drop demo mission
- RUBE_insertSort & RUBE_shellSort
- Not only yet another set of the most primitive sort algorithms there are, but this babies will take a selector-function, allowing you to sort (or shuffle!) any given datastructure. The selector may simply access a property of a given item in the list or compute new a value, based on multiple properties of the item.
- RUBE_extractConfigEntries
- Powerful tool to easily extract data from config files.
- RUBE_samplePeriphery & RUBE_analyzePeriphery
- Retrieve usefull information about the terrain at a given position. Looking for hilltops? Valleys? Then this is for you. (see)
- RUBE_convexHull
- Are you kidding me? Sure. But think about it, you've spawned some stuff that should represent some sort of stuff like a base and you're missing a fence around it? No problem, pass your objects, and we'll compute the convex hull and now we're ready to spawn the fence or the sandbags around our stuff, e.g. with RUBE_spawnObjectChain.
- RUBE_rectanglePacker
- So there is this area we know is empty and we'd like to fill this space with lots of random stuff... sounds like an awefull job? Try the rectanglePacker. Wanna spawn a random paintball arena? Try the rectanglePacker.
- RUBE_randomWalk
- Bounded, one-dimensional random walk generator (sines of two independent 1d walkers are summed up and divided by two to create random interference within a limited band) to model the weather, the wall street and everything.
Adjustable "intensity" with a separate base and random part, a uniform range [-1, 1] which can be transformed to an absolute range of [0,1], and then further multiplied as desired...
- RUBE_randomGauss
- The world isn't evenly distributed. 99% know this. So why do you still use random to model your stuff? This function will give you normally distributed random numbers, using the Box-Muller transform.
- RUBE_descriptiveStatistics
- And once you start messing with distributions, you need tools to measure your results. Because... distributions are prude, fragile bitches. :/
- RUBE_histogram
- And once you start messing with distributions... yeah, we know. This function is as well intended for testing purposes. Therefore it prints a nice histogram right to your diag_log-file (set your font to monospace). Of course, you may aswell just grab the calculated data and feed your dialogs or something with it. I don't care.
Lovely, aren't they? :D
- RUBE_neville
- Polynomial interpolation using Neville's algorithm.
- RUBE_bezier
- Calculate bézier curves for map drawings, some clever functions (such as coloring functions for your ppEffects, depending on daytime, overcast, rain or something...), object spawning, animation or just for nice camera shots. Functions of higher order are supported (up to a degree of 20; 21 control points). Can process an array of scalar or an array of arrays of scalar (such as positional data).
- RUBE_bspline
-
Calculate some B-splines of any degree using de Boor's algorithm with clamped, uniformly spaced knots... Just in case bézier curves didn't do it. Beware though: the insane recursion of this algorithm ass-rapes arma's scripting engine. Poor thing. :)
- RUBE_spawnObjects
- Spawning objects is always fun.
- RUBE_spawnObjectChain
- Spawning them in a chain? Like in fences and sandbags? Groovie. Though make sure the place is even (no gradient) for you may not be that happy with the results otherwise :/
- RUBE_spawnObjectCircle
- For all circle jerkers out there... or if you need a nice campfire, or a mg-nest, or a round arena to fight in like men.
- RUBE_spawnObjectCloud
- Don't really care? Neither do I. So just let's spawn that stuff there.
- RUBE_spawnObjectGrid
- A grid? Well, you may just use the border- and corner-elements, and there, you have a nice sandbag fort.
- RUBE_spawnTable
- And a chair and stuff upon the table.
- RUBE_findRoute & RUBE_plotRoute
- Ambush. Ambush! Aaaaambush!!!! And supply routes, and escort missions, and .. really, there is so much more than ambushing the shit out of shit. Give it a try. Compute the most efficient route or detours from here to there, anywhere, aslong as the road network isn't fucked up - which unfortunately isn't that uncommon. :/