backport.eventPickup.js

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

 

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:

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

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 you had a droid less than 1.5 tiles from the item when it was picked up
  • 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)

It should be noted that the ".player" property of the destroyed object will always be "me", so we can't rely on that to avoid the first scenario listed above. (wink)

Luckily, based on extensive play-testing both of these scenarios are very rare. But that doesn't mean they won't happen: You should factor in the possibility of false positives in to your eventPickup() scripting.

Releases

  File Modified

Availability

 Requires backport.js v0.2 and above.

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.

See also

Â