bind() and objFromId()

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:

bind() and objFromId()

Post by aubergine »

bind()

Why is player initially set to -1 and then a few lines later set to the player from the passed in object?

Code: Select all

	node.player = -1;
	node.funcName = context->argument(0).toString();
	node.engine = engine;
	node.player = objv.property("player").toInt32();
objFromId()

As mentioned elsewhere, game objects are stored in several lists, one for each player. Would it be worth adding an optional "player" param to objFromId() ?

Syntax becomes:

Code: Select all

objFromId(id[,player])
The in the C++ code you can use IdToPointer(id, player) if the player is specified.

This change won't break existing JS scripts that are using objFromId() because if the player param isn't given the current code deals with that already. And, if the object lists are merged in to a single list at some later date, it's easy to deprecate the player param without breaking scripts that have made use of it.

In my "valut" library I'll always have both the object id and player id, so would prefer to be able to objFromId(id,player) to get best performance.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Post Reply