Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Overview

<file coming soon>
Backports eventPickup() to Warzone 3.1 branch.

Availability

 Requires backport.js

Compatible with all versions of Warzone from 3.1 and above.

The backport will only be applied to the 3.1 branch, in 3.2 the native eventPickup() will be used.

Settings

By default, this backport will iterate through all your droids to work out which one picked up the item. If you have lots of droids, that list can grow long. If several players in the game are using your script, each of those players will be processing their entire list of droids.

If you always use a specific type of droid to pickup/recover items, you can greatly reduce the size of the list being iterated using the "eventPickup" setting.

For example, if you only use construction droids to collect items, you'd update the setting like this:

backport._$.eventPickup = DROID_CONSTRUCT; // filter droid iteration to construction droids

The setting 

Notes

This backport takes advantage of a little-known scenario in eventDestroyed(), namely that the event will be triggered when any feature is removed from the map (eg. a tree is destroyed or an oil barrel is picked up, etc).

Having identified that a collectible item has been picked up, this backport will iterate through a list of your droids until it finds one that's less than 1.5 tiles distance from the destroyed feature.

Obviously, this isn't 100% accurate. There are a few scenarios that will result in "false positives", namely:

  • If some other player picked it up first, but your droid is less than 1.5 tiles from the item that was picked up (I've never seen this happen yet, but that doesn't mean that it wont happen)
  • If you had more than one droid that was less than 1.5 tiles from the item, the backport will always return the first one it finds (which might not be the one that picked it up)

Luckily, based on extensive play-testing these scenarios tend to be very rare. Regardless, you should factor in the possibility of false positives in to your eventPickup() scripting.

Script

  File Modified

See also

  • No labels