.type of player, etc., 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:

.type of player, etc., objects

Post by aubergine »

Hi,

I'd like to propose that a .type property gets added to the following "object types":

* player objects in the playerData array: .type == PLAYER (new const required)
* derrick objects in the derrickPositions array: .type == POSITION
* position objects in the startPositions array: .type == POSITION
* research objects from findResearch(), enumResearch(), etc: .type == RESEARCH (new const required)

The reason for this is to allow greater standardisation of helper/wrapper functions in scripts, basically to make passing objects around and working with them easier and more consistent.

As an overly-simplified example, I could have a helper function for building a structure - I could pass in an object defining where to build and have it work out how to get the x,y co-ords, so if it sees PLAYER it knows it needs to go look in startPositions to get a POSITION object and so on.

The change should hopefully be trivial to implement, even for 3.1 branch, as its adding a static property to those object definitions, and two new constants, in qtscriptfuncs.cpp. A cursory look at the C++ code shows good centralisation of the object definitions, however I'm not quite confident enough to submit a patch as my C++ skills are decidedly novice. :oops:
"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: .type of player, etc., objects

Post by Per »

Done (3.1). Named the new consts PLAYER_DATA and RESEARCH_DATA, since RESEARCH was taken already, and PLAYER_DATA then seemed more consistent.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: .type of player, etc., objects

Post by aubergine »

Thank you so much!! :)
"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: .type of player, etc., objects

Post by aubergine »

Would it be possible to give the object returned by pickStructLocation() a .type = POSITION?
"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: .type of player, etc., objects

Post by Per »

aubergine wrote:Would it be possible to give the object returned by pickStructLocation() a .type = POSITION?
Good idea. Implemented in f3e5f9b98b1a3cfd7e9dee516070da018bd5b084.
Post Reply