1
0
forked from 0ad/0ad

- Fix garisson and formation aura types

- Implement tech mods for UnitMotion speeds, Fixes #1958, based on patch
by wraitii
- Implement athen_hero_themistocles ship speed aura as a test

This was SVN commit r14058.
This commit is contained in:
sanderd17 2013-10-30 16:12:53 +00:00
parent 2d1be3d47e
commit 60fb5ed1c3
5 changed files with 45 additions and 16 deletions

View File

@ -103,12 +103,12 @@ Auras.prototype.GetType = function(name)
Auras.prototype.IsFormationAura = function(name)
{
return this.GetType(name) == "Formation";
return this.GetType(name) == "formation";
};
Auras.prototype.IsGarrisonAura = function(name)
{
return this.GetType(name) == "GarrisoningStructure";
return this.GetType(name) == "garrison";
};
Auras.prototype.IsRangeAura = function(name)
@ -244,7 +244,7 @@ Auras.prototype.ApplyFormationBonus = function(memberList)
var validList = this.GiveMembersWithValidClass(name, memberList);
for each (var ent in validList)
{
targetUnits.push(e);
this[name].targetUnits.push(e);
this.ApplyBonus(name,e);
}
}
@ -261,7 +261,7 @@ Auras.prototype.ApplyGarrisonBonus = function(structure)
var validList = this.GiveMembersWithValidClass(name, [structure]);
if (validList.length)
{
targetUnits.push(validList[0]);
this[name].targetUnits.push(validList[0]);
this.ApplyBonus(name,validList[0]);
}
}

View File

@ -548,9 +548,9 @@ GuiInterface.prototype.GetTemplateData = function(player, extendedName)
if (template.UnitMotion)
{
ret.speed = {
"walk": +template.UnitMotion.WalkSpeed,
"walk": ApplyValueModificationsToTemplate("UnitMotion/WalkSpeed", +template.UnitMotion.WalkSpeed, player, template),
};
if (template.UnitMotion.Run) ret.speed.run = +template.UnitMotion.Run.Speed;
if (template.UnitMotion.Run) ret.speed.run = ApplyValueModificationsToTemplate("UnitMotion/Run/Speed", +template.UnitMotion.Run.Speed, player, template);
}
if (template.Trader)

View File

@ -0,0 +1,5 @@
{
"affects":["Ship"],
"affectedPlayers":["Player","MutualAlly"],
"modifications":[{"value":"UnitMotion/WalkSpeed","multiply":1.2}]
}

View File

@ -1,10 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_unit_hero_infantry_swordsman">
<Auras>
<ship_speed>
<Type>garrison</Type>
</ship_speed>
<!-- ship build time aura still needs to be made -->
</Auras>
<Identity>
<Civ>athen</Civ>
<GenericName>Themistocles</GenericName>
<SpecificName>Themistoklês</SpecificName>
<Tooltip>Hero Aura: When garrisoned in a ship, all nearby warships are 20% faster. Ships are also built 20% faster during his lifespan.</Tooltip>
<Tooltip>Hero Aura: When garrisoned in a ship, his ship is 20% faster. Ships are also built 20% faster during his lifespan.</Tooltip>
<History>The general whom persuaded the Athenians to invest their income from silver mines in a war navy of 200 Triremes. A key figure during the Persian Wars, he commanded the victorious Athenian navy at the decisive battle of Salamis in 479 BC. Later, he pursued an active policy against the Persians in the Aegean, thereby laying the foundations of future Athenian power. Ostracised by the Athenians, he was forced to flee to the protection of the Persians.</History>
<Icon>units/hele_hero_themistocles.png</Icon>
</Identity>

View File

@ -26,6 +26,7 @@
#include "simulation2/components/ICmpPosition.h"
#include "simulation2/components/ICmpPathfinder.h"
#include "simulation2/components/ICmpRangeManager.h"
#include "simulation2/components/ICmpValueModificationManager.h"
#include "simulation2/helpers/Geometry.h"
#include "simulation2/helpers/Render.h"
#include "simulation2/MessageTypes.h"
@ -109,6 +110,7 @@ public:
componentManager.SubscribeToMessageType(MT_Update_MotionUnit);
componentManager.SubscribeToMessageType(MT_RenderSubmit); // for debug overlays
componentManager.SubscribeToMessageType(MT_PathResult);
componentManager.SubscribeToMessageType(MT_ValueModification);
}
DEFAULT_COMPONENT_ALLOCATOR(UnitMotion)
@ -120,8 +122,8 @@ public:
// Template state:
bool m_FormationController;
fixed m_WalkSpeed; // in metres per second
fixed m_RunSpeed;
fixed m_WalkSpeed, m_OriginalWalkSpeed; // in metres per second
fixed m_RunSpeed, m_OriginalRunSpeed;
ICmpPathfinder::pass_class_t m_PassClass;
ICmpPathfinder::cost_class_t m_CostClass;
@ -284,18 +286,14 @@ public:
m_Moving = false;
m_FacePointAfterMove = true;
m_WalkSpeed = paramNode.GetChild("WalkSpeed").ToFixed();
m_WalkSpeed = m_OriginalWalkSpeed = paramNode.GetChild("WalkSpeed").ToFixed();
m_Speed = m_WalkSpeed;
m_CurSpeed = fixed::Zero();
if (paramNode.GetChild("Run").IsOk())
{
m_RunSpeed = paramNode.GetChild("Run").GetChild("Speed").ToFixed();
}
m_RunSpeed = m_OriginalRunSpeed = paramNode.GetChild("Run").GetChild("Speed").ToFixed();
else
{
m_RunSpeed = m_WalkSpeed;
}
m_RunSpeed = m_OriginalRunSpeed = m_WalkSpeed;
CmpPtr<ICmpPathfinder> cmpPathfinder(GetSystemEntity());
if (cmpPathfinder)
@ -399,6 +397,26 @@ public:
PathResult(msgData.ticket, msgData.path);
break;
}
case MT_ValueModification:
{
const CMessageValueModification& msgData = static_cast<const CMessageValueModification&> (msg);
if (msgData.component != L"UnitMotion")
break;
CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSimContext(), SYSTEM_ENTITY);
fixed newWalkSpeed = cmpValueModificationManager->ApplyModifications(L"UnitMotion/WalkSpeed", m_OriginalWalkSpeed, GetEntityId());
fixed newRunSpeed = cmpValueModificationManager->ApplyModifications(L"UnitMotion/Run/Speed", m_OriginalRunSpeed, GetEntityId());
// update m_Speed (the actual speed) if set to one of the variables
if (m_Speed == m_WalkSpeed)
m_Speed = newWalkSpeed;
else if (m_Speed == m_RunSpeed)
m_Speed = newRunSpeed;
m_WalkSpeed = newWalkSpeed;
m_RunSpeed = newRunSpeed;
}
}
}