Other great resources: Official JS API docs, Scripting Forum
scavengerPlayer
- Aubergine
Â
Values
The scavenger player always uses a fixed player slot on maps, depending on the number of players the map is designed to accommodate.
maxPlayers: | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
---|---|---|---|---|---|---|---|---|---|
scavengerPlayer value: | 7 | Â 7 | 7 | 7Â | Â 7 | Â 7 | 8Â | 9Â | 10 |
Human / AI player id range: (remember they are zero-indexed | 0..1 | 0..2 | 0..3 | 0..4 | 0..5 | 0..6 | 0..7 | 0..8 | 0..9 |
 If there are no scavengers on the map (scavengers == false
), the value of scavengerPlayer will be -1.
If you are making a custom scavfact.js (the AI script that controls the scavenger faction), scavengerPlayer == me
.
Example
 Remember the scavengerPlayer
constant is only available in Warzone 3.2 and above.
// this is normal way of doing things... if (scavengers) { // scavengers are enabled var scavDroids = enumDroid(scavengerPlayer); // get a list of their droids } Â // but this approach is probably better... if (scavengerPlayer!=-1) { // there are actually scavs on the map var scavDroids = enumDroid(scavengerPlayer); // get a list of their droids }
Notes
Because of bug #3123 early betas weren't able to get lists of scavenger objects via the enumDroid() and enumStruct() functions - they would throw an error stating that the player ID was invalid. In that scenario, the only way for an AI to get information about scavengers is via objects passed in to events such as eventAttacked() and eventObjectSeen().
If the .player property of the attacker or detected object matches the following criteria, it's a scavenger:
maxPlayers ≤ object.player < 12
So, you can get a rough idea of where scavengers are via eventAttacked() when one attacks you, then build a sensor at that location (or send a sensor droid) to see if you can get more scavenger objects via eventObjectSeen().
There appear to be issues enumerating scavenger structures and droids from within rules.js.
It is currently not possible to determine the colour of the scavenger player from within the JS API.
Availability
Requires:
- Warzone 3.2 or above
-  Backport to earlier versions with backport.scavengerPlayer.js
Contents
Jump to:
See also
Related articles:
- Adding Scavengers to Maps – FlaME map editor guide
- scavengers – a boolean value defining whether scavengers are enabled for the current game
- backport.scavengerPlayer.js – backport this constant to earlier versions of Warzone
- scavfact.js – the scavenger faction AI script bundled with Warzone
- Ultimate Scavenger AI Mod – a game mod that replaces the normal scavfact.js with a massively improved version, and also adds a new "Crane" construction droid for scavengers
Â