droids - .armed and .group properties

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:

droids - .armed and .group properties

Post by aubergine »

Currently the .armed and .group props only get added if applicable to the droid. However, this means that in JS there's often going to be additional checks (regardless of how simple they are) to accommodate these transient properties.

Could the https://github.com/Warzone2100/warzone2 ... tfuncs.cpp be updated to something like this:

Code: Select all

	if (isVtolDroid(psDroid))
	{
		value.setProperty("armed", 100.0 / (double)asWeaponStats[psDroid->asWeaps[0].nStat].numRounds
		                  * (double)psDroid->asWeaps[0].ammo);
		// why doesn't the above property have a "QScriptValue::ReadOnly" setting?
	}
	else
	{
		value.setProperty("armed", -1, QScriptValue::ReadOnly);
	}
	if (psDroid->psGroup)
	{
		value.setProperty("group", (int)psDroid->psGroup->id, QScriptValue::ReadOnly);
	}
	else
	{
		value.setProperty("group", -1, QScriptValue::ReadOnly);
	}
This way the .armed and .group properties always exist so when scripts are checking those props they won't need to first check to see if they exist.
"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: droids - .armed and .group properties

Post by Per »

Would it be better if they returned null?
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: droids - .armed and .group properties

Post by aubergine »

yes, null is fine.
"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: droids - .armed and .group properties

Post by Per »

Done. (for 3.2)
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: droids - .armed and .group properties

Post by aubergine »

Could structureObj.modules be set to null (rather than property not existing) if the structure doesn't have modules, in a similar way to .armed and .group properties on droids?
"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: droids - .armed and .group properties

Post by aubergine »

Also, .range is defaulting to -1 if the structure or droid doesn't have a weapon - could it default to null for consistency with other props mentioned above?

Also, does range apply to sensors? From the code it looks like just weapons, but I don't know enough about the C++ objects being used to work out whether psStruct->asWeaps.nStat could contain a sensor?
"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: droids - .armed and .group properties

Post by Per »

Ok, modules and range are now null. Not sure about sensors and range.
Post Reply