Page 1 of 1
Tip: eventDestroyed() - feature objects!
Posted: 24 May 2012, 03:12
by aubergine
I've just found that eventDestroyed() is called in the following scenarios:
* when you pick-up an oil barrel or artefact
* when you start construction of an oil derrick
In each case, the .player property of the feature object passed in to eventDestroyed() is set to the player who picked up the item or started building on it.
I'm using this to play audio messages, such as "power transferred" when a barrel is picked up, or "construction started" when a derrick is started.
I'm sure there are other uses for this too

Re: Tip: eventDestroyed() - feature objects!
Posted: 24 May 2012, 04:00
by aubergine
Ah, and just when I was about to celebrate the many ways in which this stuff could be used, I've just found that eventDestroyed() gets called with a feature object regardless of which player picks up the barrel/artefact or builds on the derrick. And the featureObject.player property == selectedPlayer regardless of who picked up or built on the feature.

Re: Tip: eventDestroyed() - feature objects!
Posted: 02 Jun 2012, 19:41
by Per
Sorry about that. When eventDestroyed() is called, that information is no longer available.
I've added another event, eventPickup(feature, droid) that should give you what you need.
Re: Tip: eventDestroyed() - feature objects!
Posted: 02 Jun 2012, 19:47
by aubergine
Will eventPickup just be for objects owned by 21, eg. oil drums (barrels) and crates (artefacts)?
I've now created helper functions that determine if, using current 3.1 beta 10 api, a "destroyed" feature was destroyed by one of the player's units. Example code in latest ver of Enhanced SitRep Mod topic in Showcase forum.
I assume that eventDestroyed() will continue to be called even though there is now an eventPickup()? eventDestroyed() will allow me to determine if an oil resource my trucks are heading for has been captured by enemy (via my helper function) and if so I can send them elsewhere.
Also, I note that features don't seem to trigger eventObjectSeen(), which is a great shame as it forces me to rely on enumFeature() to find features I can see, when really I just want to know when a new feature is seen by my sensors/droids.
Re: Tip: eventDestroyed() - feature objects!
Posted: 17 Jun 2012, 12:42
by Per
eventPickup() only works on pickup-able features, yes.