Improve ownership changes by only giving the cp of the old owner to the new owner.
This was SVN commit r16755.
This commit is contained in:
parent
30efa73a38
commit
204dcf201c
@ -25,7 +25,7 @@ function init(initData, hotloadData)
|
||||
// Pick a random background and initialise it
|
||||
g_BackgroundCode = Math.floor(Math.random() * g_BackgroundLayerData.length);
|
||||
var layerset = g_BackgroundLayerData[g_BackgroundCode];
|
||||
for (var i = 0; i < layerset.length; i++)
|
||||
for (var i = 0; i < layerset.length; ++i)
|
||||
{
|
||||
var layer = layerset[i];
|
||||
var guiObj = Engine.GetGUIObjectByName("background["+i+"]");
|
||||
|
@ -253,22 +253,28 @@ Capturable.prototype.OnTerritoryDecayChanged = function(msg)
|
||||
|
||||
Capturable.prototype.OnOwnershipChanged = function(msg)
|
||||
{
|
||||
if (this.cp.length)
|
||||
{
|
||||
if (!this.cp[msg.from])
|
||||
return; // nothing to change
|
||||
|
||||
// Was already initialised, this happens on defeat or wololo
|
||||
// transfer the points of the old owner to the new one
|
||||
this.cp[msg.to] += this.cp[msg.from];
|
||||
this.cp[msg.from] = 0;
|
||||
this.RegisterCapturePointsChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
// initialise the capture points when created
|
||||
var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
|
||||
for (let i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i)
|
||||
if (i == msg.to)
|
||||
this.cp[i] = this.maxCp;
|
||||
else
|
||||
this.cp[i] = 0;
|
||||
}
|
||||
this.CheckTimer();
|
||||
|
||||
// if the new owner has no capture points, it means that either
|
||||
// * it's being initialised now, or
|
||||
// * it changed ownership for a different reason (defeat, atlas, ...)
|
||||
if (this.cp[msg.to])
|
||||
return;
|
||||
|
||||
// initialise the capture points when created
|
||||
this.cp = [];
|
||||
var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
|
||||
for (let i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i)
|
||||
if (i == msg.to)
|
||||
this.cp[i] = this.maxCp;
|
||||
else
|
||||
this.cp[i] = 0;
|
||||
};
|
||||
|
||||
Engine.RegisterComponentType(IID_Capturable, "Capturable", Capturable);
|
||||
|
Loading…
Reference in New Issue
Block a user