Allies only share vision when researching a tech. Based on patch by niektb. Fixes #2055
This was SVN commit r16795.
This commit is contained in:
parent
1830c6346b
commit
cc4af6d2d4
BIN
binaries/data/mods/public/art/textures/ui/session/portraits/technologies/shared_los.png
(Stored with Git LFS)
Normal file
BIN
binaries/data/mods/public/art/textures/ui/session/portraits/technologies/shared_los.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,7 +1,9 @@
|
||||
function Player() {}
|
||||
|
||||
Player.prototype.Schema =
|
||||
"<a:component type='system'/><empty/>";
|
||||
"<element name='SharedLosTech' a:help='Allies will share los when this technology is researched. Leave empty to never share LOS.'>" +
|
||||
"<text/>" +
|
||||
"</element>";
|
||||
|
||||
Player.prototype.Init = function()
|
||||
{
|
||||
@ -19,10 +21,12 @@ Player.prototype.Init = function()
|
||||
"metal": 300,
|
||||
"stone": 300
|
||||
};
|
||||
this.tradingGoods = [ // goods for next trade-route and its proba in % (the sum of probas must be 100)
|
||||
// goods for next trade-route and its proba in % (the sum of probas must be 100)
|
||||
this.tradingGoods = [
|
||||
{ "goods": "wood", "proba": 30 },
|
||||
{ "goods": "stone", "proba": 35 },
|
||||
{ "goods": "metal", "proba": 35 } ];
|
||||
{ "goods": "metal", "proba": 35 },
|
||||
];
|
||||
this.team = -1; // team number of the player, players on the same team will always have ally diplomatic status - also this is useful for team emblems, scoring, etc.
|
||||
this.teamsLocked = false;
|
||||
this.state = "active"; // game state - one of "active", "defeated", "won"
|
||||
@ -40,7 +44,7 @@ Player.prototype.Init = function()
|
||||
"wood": markForTranslation("Wood"),
|
||||
"metal": markForTranslation("Metal"),
|
||||
"stone": markForTranslation("Stone"),
|
||||
}
|
||||
};
|
||||
this.disabledTemplates = {};
|
||||
this.disabledTechnologies = {};
|
||||
this.startingTechnologies = [];
|
||||
@ -114,7 +118,7 @@ Player.prototype.GetPopulationCount = function()
|
||||
|
||||
Player.prototype.AddPopulation = function(num)
|
||||
{
|
||||
this.popUsed += num;
|
||||
this.popUsed += num;
|
||||
};
|
||||
|
||||
Player.prototype.SetPopulationBonuses = function(num)
|
||||
@ -445,15 +449,18 @@ Player.prototype.SetDiplomacyIndex = function(idx, value)
|
||||
|
||||
Player.prototype.UpdateSharedLos = function()
|
||||
{
|
||||
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
if (!cmpRangeManager)
|
||||
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
|
||||
let cmpTechnologyManager = Engine.QueryInterface(this.entity, IID_TechnologyManager);
|
||||
if (!cmpRangeManager || !cmpPlayerManager || !cmpTechnologyManager)
|
||||
return;
|
||||
|
||||
var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
|
||||
if (!cmpPlayerManager)
|
||||
let sharedLos = [];
|
||||
if (!cmpTechnologyManager.IsTechnologyResearched(this.template.SharedLosTech))
|
||||
{
|
||||
cmpRangeManager.SetSharedLos(this.playerID, [this.playerID]);
|
||||
return;
|
||||
|
||||
var sharedLos = [];
|
||||
}
|
||||
for (var i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i)
|
||||
if (this.IsMutualAlly(i))
|
||||
sharedLos.push(i);
|
||||
@ -662,6 +669,12 @@ Player.prototype.OnPlayerDefeated = function(msg)
|
||||
cmpGUIInterface.PushNotification(notification);
|
||||
};
|
||||
|
||||
Player.prototype.OnResearchFinished = function(msg)
|
||||
{
|
||||
if (msg.tech == this.template.SharedLosTech)
|
||||
this.UpdateSharedLos();
|
||||
};
|
||||
|
||||
Player.prototype.OnDiplomacyChanged = function()
|
||||
{
|
||||
this.UpdateSharedLos();
|
||||
|
@ -373,10 +373,9 @@ TechnologyManager.prototype.ResearchTechnology = function(tech)
|
||||
if (cmpPlayerEntityLimits)
|
||||
cmpPlayerEntityLimits.UpdateLimitsFromTech(tech);
|
||||
|
||||
// Call the related trigger event
|
||||
var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
|
||||
cmpTrigger.CallEvent("ResearchFinished", {"player": playerID, "tech": tech});
|
||||
|
||||
// always send research finished message
|
||||
Engine.PostMessage(this.entity, MT_ResearchFinished, {"player": playerID, "tech": tech});
|
||||
|
||||
for (var component in modifiedComponents)
|
||||
{
|
||||
Engine.PostMessage(SYSTEM_ENTITY, MT_TemplateModification, { "player": playerID, "component": component, "valueNames": modifiedComponents[component]});
|
||||
|
@ -234,6 +234,14 @@ Trigger.prototype.OnGlobalTrainingFinished = function(msg)
|
||||
// See function "SpawnUnits" in ProductionQueue for more details
|
||||
};
|
||||
|
||||
// Handles "OnTrainingFinished" event.
|
||||
Trigger.prototype.OnGlobalResearchFinished = function(msg)
|
||||
{
|
||||
this.CallEvent("ResearchFinished", msg);
|
||||
// The data for this one is {"player": playerID,
|
||||
// "tech": tech}
|
||||
};
|
||||
|
||||
Trigger.prototype.OnGlobalOwnershipChanged = function(msg)
|
||||
{
|
||||
this.CallEvent("OwnershipChanged", msg);
|
||||
|
@ -1,2 +1,4 @@
|
||||
Engine.RegisterInterface("TechnologyManager");
|
||||
|
||||
Engine.RegisterMessageType("ResearchFinished");
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"genericName": "Carthography",
|
||||
"description": "By means of trading and travelling people explored beyond the boundaries of their lands and drew maps of it in order to share and memorize their discoveries.",
|
||||
"cost": {"food": 100, "wood": 0, "stone": 0, "metal": 100},
|
||||
"requirements": {"tech": "phase_village"},
|
||||
"icon": "shared_los.png",
|
||||
"researchTime": 40,
|
||||
"tooltip": "Player sees what his allies see.",
|
||||
"modifications": [{"value": "Player/sharedLos", "replace": true}],
|
||||
"soundComplete": "interface/alarm/alarm_upgradearmory.xml"
|
||||
}
|
@ -48,7 +48,9 @@
|
||||
</CivilCentre>
|
||||
</LimitRemovers>
|
||||
</EntityLimits>
|
||||
<Player/>
|
||||
<Player>
|
||||
<SharedLosTech>unlock_shared_los</SharedLosTech>
|
||||
</Player>
|
||||
<StatisticsTracker/>
|
||||
<TechnologyManager/>
|
||||
</Entity>
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity>
|
||||
<Player/>
|
||||
<Player>
|
||||
<SharedLosTech/>
|
||||
</Player>
|
||||
</Entity>
|
||||
|
@ -51,6 +51,7 @@
|
||||
<BatchTimeModifier>0.7</BatchTimeModifier>
|
||||
<Technologies datatype="tokens">
|
||||
speed_trader_01
|
||||
unlock_shared_los
|
||||
</Technologies>
|
||||
<Entities datatype="tokens">
|
||||
units/{civ}_support_trader
|
||||
|
Loading…
Reference in New Issue
Block a user