Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

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:

Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

Post by aubergine »

Hi All,

Sorry I've not been around much, had some ill health and operations recently but feeling a lot better now :)

I've been updating some docs on the wiki and noticed a few changes to the JS API constants in recent releases:

BEING_DEMOLISHED - this seems to have disappeared somewhere between 3.1 Beta 7..10. Without it, there's no way to know if a building is in the state of demolition (via it's structureObj.status property). If a building is being demolished and the truck gets destroyed, how would a script know to get another truck sent out to finish the demolition? This can cause further issues because structureIdle() could return 'true' for a building that's partially demolished (should a Laser Satellite be able to fire if the LASSAT building is partly demolished?). Can we bring this constant back?

PLAYER_DATA, RESEARCH_DATA - I noticed these two new constants in 3.1 Beta 11. I couldn't find any docs on them - anyone got details of what they are? Also, is PLAYER_DATA related to, or intended to deprecate, the global var 'playerData'? - found what these are, see comment below.
Last edited by aubergine on 07 Oct 2012, 01:22, edited 1 time in total.
"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: Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

Post by aubergine »

Ah, just found out what PLAYER_DATA and RESEARCH_DATA are about: viewtopic.php?f=35&t=9576
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

Post by NoQ »

should a Laser Satellite be able to fire if the LASSAT building is partly demolished?
If it is not yet built, it can't do that either. So the "== BUILT" seems to be a better check for that.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

Post by aubergine »

Agreed.

However, I still feel there should be a way to determine if a building is in the process of being demolished. The obvious scenario is the truck demolishing gets destroyed = you're left with a part-demolished building lingering on the map. I guess a look-up table could be created of truck vs. building being demolished, then check that whenever a truck is destroyed, but if that array gets cruftified (eg. the part-demolished building gets attacked and destroyed by enemy) it's just going to get increasingly messy to deal with.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

Post by NoQ »

Sure it should be fixed if it has actually disappeared, nice you've noticed, just wanted to say that checking both !=BUILT and !=BEING_BUILT is still a workaround.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

Post by aubergine »

From a quick test, in the "being demolished" state, it's being reported as "BUILT" (I could be wrong, still on heavy pain killers from a kidney operation!)
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

Post by NoQ »

Ouch.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

Post by Per »

Hmm. The constant was removed in 8a964f12afbda6d6db25fad69ae1778ce7d3f841. Seems like demolished now is exactly like built, just in reverse. Not sure if I like that, but also not sure if changing that before release is a good idea.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

Post by aubergine »

Looking at that change log it looks like is was removed for code-tidying purposes, based on the incorrect assertion that it wasn't used anywhere, rather than to fix a bug.
"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: Constants - BEING_DEMOLISHED, PLAYER_DATA, RESEARCH_DATA

Post by aubergine »

"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Post Reply