Tip: eventDestroyed() - feature objects!

For AI and campaign script related discussions and questions

Tip: eventDestroyed() - feature objects!

Postby aubergine » 24 May 2012, 02:12

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
aubergine
Special

User avatar
 
Joined: 09 Oct 2010, 23:58

Re: Tip: eventDestroyed() - feature objects!

Postby aubergine » 24 May 2012, 03:00

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
aubergine
Special

User avatar
 
Joined: 09 Oct 2010, 23:58

Re: Tip: eventDestroyed() - feature objects!

Postby Per » 02 Jun 2012, 18:41

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.
Per
Warzone 2100 Team Member

 
Joined: 03 Aug 2006, 18:39

Re: Tip: eventDestroyed() - feature objects!

Postby aubergine » 02 Jun 2012, 18:47

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
aubergine
Special

User avatar
 
Joined: 09 Oct 2010, 23:58

Re: Tip: eventDestroyed() - feature objects!

Postby Per » 17 Jun 2012, 11:42

eventPickup() only works on pickup-able features, yes.
Per
Warzone 2100 Team Member

 
Joined: 03 Aug 2006, 18:39


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest