Tip: eventDestroyed() - feature objects!

For AI and campaign script related discussions and questions
Post Reply
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Tip: eventDestroyed() - feature objects!

Post 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 :)
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Tip: eventDestroyed() - feature objects!

Post 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. :(
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Tip: eventDestroyed() - feature objects!

Post 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.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Tip: eventDestroyed() - feature objects!

Post 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.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Tip: eventDestroyed() - feature objects!

Post by Per »

eventPickup() only works on pickup-able features, yes.
Post Reply