diff --git a/binaries/data/mods/public/audio/attack/weapon/arrowfly.xml b/binaries/data/mods/public/audio/attack/weapon/arrowfly.xml index 1f78400893..893b0b7d80 100644 --- a/binaries/data/mods/public/audio/attack/weapon/arrowfly.xml +++ b/binaries/data/mods/public/audio/attack/weapon/arrowfly.xml @@ -9,8 +9,8 @@ 0 1 1 - 1 - 0.8 + 0.5 + 0.4 1 1.1 0.9 diff --git a/binaries/data/mods/public/audio/voice/hellenes/civ/civ_male_ack.xml b/binaries/data/mods/public/audio/voice/hellenes/civ/civ_male_ack.xml new file mode 100644 index 0000000000..17085c1105 --- /dev/null +++ b/binaries/data/mods/public/audio/voice/hellenes/civ/civ_male_ack.xml @@ -0,0 +1,22 @@ + + + 1 + 1 + 100 + 1 + 360 + 360 + 0 + 1 + 1 + 1 + 0.8 + 1 + 1.1 + 0.9 + 1 + 3 + civ_male_Asyouwish_1.ogg + audio/voice/hellenes/civ + civ_male_Asyouwish_1.ogg + diff --git a/binaries/data/mods/public/audio/voice/hellenes/civ/civ_male_attack.xml b/binaries/data/mods/public/audio/voice/hellenes/civ/civ_male_attack.xml new file mode 100644 index 0000000000..a95e30e72a --- /dev/null +++ b/binaries/data/mods/public/audio/voice/hellenes/civ/civ_male_attack.xml @@ -0,0 +1,22 @@ + + + 1 + 1 + 100 + 1 + 360 + 360 + 0 + 1 + 1 + 1 + 0.8 + 1 + 1.1 + 0.9 + 1 + 3 + civ_male_attack_10.ogg + audio/voice/hellenes/civ + civ_male_attack_10.ogg + diff --git a/binaries/data/mods/public/audio/voice/hellenes/civ/civ_male_select.xml b/binaries/data/mods/public/audio/voice/hellenes/civ/civ_male_select.xml new file mode 100644 index 0000000000..90698c6670 --- /dev/null +++ b/binaries/data/mods/public/audio/voice/hellenes/civ/civ_male_select.xml @@ -0,0 +1,22 @@ + + + 1 + 1 + 100 + 1 + 360 + 360 + 0 + 1 + 1 + 1 + 0.8 + 1 + 1.1 + 0.9 + 1 + 3 + civ_male_yes_1.ogg + audio/voice/hellenes/civ + civ_male_yes_1.ogg + diff --git a/binaries/data/mods/public/gui/session_new/input.js b/binaries/data/mods/public/gui/session_new/input.js index fad791fd66..a81f9dc1de 100644 --- a/binaries/data/mods/public/gui/session_new/input.js +++ b/binaries/data/mods/public/gui/session_new/input.js @@ -202,6 +202,7 @@ function tryPlaceBuilding(queued) "entities": selection, "queued": queued }); + Engine.GuiInterfaceCall("PlaySound", { "name": "order_repair", "entity": selection[0] }); return true; } @@ -504,19 +505,23 @@ function handleInputAfterGui(ev) case "move": var target = Engine.GetTerrainAtPoint(ev.x, ev.y); Engine.PostNetworkCommand({"type": "walk", "entities": selection, "x": target.x, "z": target.z, "queued": queued}); + Engine.GuiInterfaceCall("PlaySound", { "name": "order_walk", "entity": selection[0] }); return true; case "attack": Engine.PostNetworkCommand({"type": "attack", "entities": selection, "target": action.target, "queued": queued}); + Engine.GuiInterfaceCall("PlaySound", { "name": "order_attack", "entity": selection[0] }); return true; case "build": // (same command as repair) case "repair": Engine.PostNetworkCommand({"type": "repair", "entities": selection, "target": action.target, "queued": queued}); + Engine.GuiInterfaceCall("PlaySound", { "name": "order_repair", "entity": selection[0] }); return true; case "gather": Engine.PostNetworkCommand({"type": "gather", "entities": selection, "target": action.target, "queued": queued}); + Engine.GuiInterfaceCall("PlaySound", { "name": "order_gather", "entity": selection[0] }); return true; case "set-rallypoint": @@ -640,6 +645,7 @@ function handleMinimapEvent(target) { case "move": Engine.PostNetworkCommand({"type": "walk", "entities": selection, "x": target.x, "z": target.z, "queued": queued}); + Engine.GuiInterfaceCall("PlaySound", { "name": "order_walk", "entity": selection[0] }); return true; case "set-rallypoint": diff --git a/binaries/data/mods/public/simulation/components/Formation.js b/binaries/data/mods/public/simulation/components/Formation.js index d1fecf43ff..6172a978a9 100644 --- a/binaries/data/mods/public/simulation/components/Formation.js +++ b/binaries/data/mods/public/simulation/components/Formation.js @@ -16,6 +16,18 @@ Formation.prototype.GetMemberCount = function() return this.members.length; }; +/** + * Returns the 'primary' member of this formation (typically the most + * important unit type), for e.g. playing a representative sound. + * Returns undefined if no members. + * TODO: actually implement something like that; currently this just returns + * the arbitrary first one. + */ +Formation.prototype.GetPrimaryMember = function() +{ + return this.members[0]; +}; + /** * Initialise the members of this formation. * Must only be called once. diff --git a/binaries/data/mods/public/simulation/components/GuiInterface.js b/binaries/data/mods/public/simulation/components/GuiInterface.js index e2a50ccdd7..b4137b1ae8 100644 --- a/binaries/data/mods/public/simulation/components/GuiInterface.js +++ b/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -362,6 +362,10 @@ GuiInterface.prototype.SetBuildingPlacementPreview = function(player, cmd) GuiInterface.prototype.PlaySound = function(player, data) { + // Ignore if no entity was passed + if (!data.entity) + return; + PlaySound(data.name, data.entity); }; diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index a5b32c33ae..4d1c0e7424 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -51,9 +51,8 @@ var UnitFsmSpec = { // ignore when we're not in FORMATIONMEMBER }, + // Called when being told to walk as part of a formation "Order.FormationWalk": function(msg) { - this.PlaySound("walk"); - var cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); cmpUnitMotion.MoveToFormationOffset(msg.data.target, msg.data.x, msg.data.z); @@ -65,15 +64,11 @@ var UnitFsmSpec = { // (these will switch the unit out of formation mode) "Order.Walk": function(msg) { - this.PlaySound("walk"); - this.MoveToPoint(this.order.data.x, this.order.data.z); this.SetNextState("INDIVIDUAL.WALKING"); }, "Order.WalkToTarget": function(msg) { - this.PlaySound("walk"); - var ok = this.MoveToTarget(this.order.data.target); if (ok) { @@ -707,9 +702,24 @@ UnitAI.prototype.GetRunSpeed = function() return cmpMotion.GetRunSpeed(); }; +/** + * Play a sound appropriate to the current entity. + */ UnitAI.prototype.PlaySound = function(name) { - PlaySound(name, this.entity); + // If we're a formation controller, use the sounds from our first member + if (this.IsFormationController()) + { + var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation); + var member = cmpFormation.GetPrimaryMember(); + if (member) + PlaySound(name, member); + } + else + { + // Otherwise use our own sounds + PlaySound(name, this.entity); + } }; UnitAI.prototype.SelectAnimation = function(name, once, speed, sound) diff --git a/binaries/data/mods/public/simulation/templates/template_unit_cavalry.xml b/binaries/data/mods/public/simulation/templates/template_unit_cavalry.xml index 19552aadcb..4327775cae 100644 --- a/binaries/data/mods/public/simulation/templates/template_unit_cavalry.xml +++ b/binaries/data/mods/public/simulation/templates/template_unit_cavalry.xml @@ -62,6 +62,11 @@ + + voice/hellenes/civ/civ_male_ack.xml + voice/hellenes/civ/civ_male_attack.xml + voice/hellenes/civ/civ_male_ack.xml + voice/hellenes/civ/civ_male_ack.xml actor/mounted/movement/walk.xml actor/mounted/movement/walk.xml attack/weapon/sword.xml diff --git a/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml b/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml index 4e5d0216d6..fcfeab27ba 100644 --- a/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml +++ b/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml @@ -64,7 +64,7 @@ 1.0 - structures/{civ}_house + structures/{civ}_house structures/{civ}_mill structures/{civ}_farmstead structures/{civ}_field @@ -83,6 +83,11 @@ + + voice/hellenes/civ/civ_male_ack.xml + voice/hellenes/civ/civ_male_attack.xml + voice/hellenes/civ/civ_male_ack.xml + voice/hellenes/civ/civ_male_ack.xml actor/human/movement/walk.xml actor/human/movement/run.xml attack/weapon/sword.xml diff --git a/binaries/data/mods/public/simulation/templates/template_unit_super_infantry.xml b/binaries/data/mods/public/simulation/templates/template_unit_super_infantry.xml index 8de32f0b4e..e9f3d6af8c 100644 --- a/binaries/data/mods/public/simulation/templates/template_unit_super_infantry.xml +++ b/binaries/data/mods/public/simulation/templates/template_unit_super_infantry.xml @@ -54,6 +54,11 @@ + + voice/hellenes/civ/civ_male_ack.xml + voice/hellenes/civ/civ_male_attack.xml + voice/hellenes/civ/civ_male_ack.xml + voice/hellenes/civ/civ_male_ack.xml actor/human/movement/walk.xml actor/human/movement/walk.xml attack/weapon/sword.xml