Allow to play different sound when building new structure and when repairing existing structure

Entities have different sound entries for build and repair orders in
templates but currently only one is used.
This patch is using build order for foundations and repair order for
anything else.
Also playing correctly order_build when placing new construction.

Differential Revision: https://code.wildfiregames.com/D2276
Fixes: #5374
Reviewed by: @Freagarach
This was SVN commit r23221.
This commit is contained in:
Angen 2019-12-07 18:42:26 +00:00
parent 0fa06de9b6
commit 4b8c82bbcb
4 changed files with 21 additions and 10 deletions

View File

@ -310,7 +310,7 @@ function tryPlaceBuilding(queued)
"autocontinue": true,
"queued": queued
});
Engine.GuiInterfaceCall("PlaySound", { "name": "order_repair", "entity": selection[0] });
Engine.GuiInterfaceCall("PlaySound", { "name": "order_build", "entity": selection[0] });
if (!queued)
placementSupport.Reset();
@ -367,7 +367,7 @@ function tryPlaceWall(queued)
if (hasWallSegment)
{
Engine.PostNetworkCommand(cmd);
Engine.GuiInterfaceCall("PlaySound", { "name": "order_repair", "entity": selection[0] });
Engine.GuiInterfaceCall("PlaySound", { "name": "order_build", "entity": selection[0] });
}
return true;

View File

@ -351,7 +351,7 @@ var g_UnitActions =
});
Engine.GuiInterfaceCall("PlaySound", {
"name": "order_repair",
"name": action.foundation ? "order_build" : "order_repair",
"entity": selection[0]
});
@ -364,18 +364,23 @@ var g_UnitActions =
!playerCheck(entState, targetState, ["Player", "Ally"]))
return false;
return { "possible": true };
return {
"possible": true,
"foundation": targetState.foundation
};
},
"preSelectedActionCheck": function(target, selection)
{
if (preSelectedAction != ACTION_REPAIR)
return false;
if (getActionInfo("repair", target, selection).possible)
let actionInfo = getActionInfo("repair", target, selection);
if (actionInfo.possible)
return {
"type": "repair",
"cursor": "action-repair",
"target": target
"target": target,
"foundation": actionInfo.foundation
};
return {
@ -386,25 +391,29 @@ var g_UnitActions =
},
"hotkeyActionCheck": function(target, selection)
{
let actionInfo = getActionInfo("repair", target, selection);
if (!Engine.HotkeyIsPressed("session.repair") ||
!getActionInfo("repair", target, selection).possible)
!actionInfo.possible)
return false;
return {
"type": "repair",
"cursor": "action-repair",
"target": target
"target": target,
"foundation": actionInfo.foundation
};
},
"actionCheck": function(target, selection)
{
if (!getActionInfo("repair", target, selection).possible)
let actionInfo = getActionInfo("repair", target, selection);
if (!actionInfo.possible)
return false;
return {
"type": "repair",
"cursor": "action-repair",
"target": target
"target": target,
"foundation": actionInfo.foundation
};
},
"specificness": 11,

View File

@ -106,6 +106,7 @@
<order_attack>voice/{lang}/civ/civ_{phenotype}_attack.xml</order_attack>
<order_gather>voice/{lang}/civ/civ_{phenotype}_gather.xml</order_gather>
<order_repair>voice/{lang}/civ/civ_{phenotype}_repair.xml</order_repair>
<order_build>voice/{lang}/civ/civ_{phenotype}_build.xml</order_build>
<order_garrison>voice/{lang}/civ/civ_{phenotype}_garrison.xml</order_garrison>
<walk>actor/human/movement/walk.xml</walk>
<run>actor/human/movement/run.xml</run>

View File

@ -69,6 +69,7 @@
<order_walk>voice/{lang}/civ/civ_{phenotype}_walk.xml</order_walk>
<order_gather>voice/{lang}/civ/civ_{phenotype}_gather.xml</order_gather>
<order_repair>voice/{lang}/civ/civ_{phenotype}_repair.xml</order_repair>
<order_build>voice/{lang}/civ/civ_{phenotype}_build.xml</order_build>
<order_garrison>voice/{lang}/civ/civ_{phenotype}_garrison.xml</order_garrison>
<walk>actor/human/movement/walk.xml</walk>
<run>actor/human/movement/run.xml</run>