...
For more information on configuring this file, see audio.wrf.
rules.js (download)
This is one of Warzone's Config files - it initialises players when the game starts, checks victory conditions and a bunch of other stuff.
...
This is achieved by listening to a bunch of game Events and then relaying them on to the reporting API in rules.report.js.
rules.init.js (download)
This script contains all the player initialisation code and data that gets called from eventGameInit() in rules.js.
...
You'll notice that the native Javascript Array object's forEach() and some() functions are used quite a lot - these make it easy to iterate through arrays, calling a function on each item in the array, without needing to define custom variables and loops. While they might look a bit odd at first, I highly recommend them as they're really quick and easy to use once you get used to them.
rules.report.js (download)
This file is much too big to describe in detail, but we'll take a look at a few things...
...
Code Block | ||
---|---|---|
| ||
// custom attacked reports... report.attacked.custom = function(obj, attacker) { if (obj.type != DROID) return; // custom: vtols attacked while fleeing the battlefield if (isFixVTOL(obj)) { if (!!attacker && isAntiAir(attacker)) return "custom.abort"; if (isRepairing(obj)) return "custom.rearm"; if (isRetreating(obj)) return "custom.return"; } else { if (isRepairing(obj)) return "custom.repairs"; if (isRetreating(obj)) return "custom.retreat"; } } |
rules.report.msg.js (download)
This script is really just a huge object definition - it works as a look-up table between a game object's classification string (generated by code in rules.report.js) and an object that defines what should happen in relation to it.
...