Add battle detection support to the simulation. Refs #1425 (Patch by Zoot)
The audio code does not yet support actually playing battle music. This was SVN commit r13091.
This commit is contained in:
parent
2d6e3f8ca4
commit
3715985f1a
@ -376,6 +376,11 @@ function onSimulationUpdate()
|
||||
updateResearchDisplay();
|
||||
updateBuildingPlacementPreview();
|
||||
updateTimeElapsedCounter(simState);
|
||||
|
||||
// Update music state on basis of battle state.
|
||||
var battleState = Engine.GuiInterfaceCall("GetBattleState", Engine.GetPlayerID());
|
||||
if (battleState)
|
||||
global.music.setState(global.music.states[battleState]);
|
||||
}
|
||||
|
||||
function updateGroups()
|
||||
|
@ -698,7 +698,7 @@ Attack.prototype.CauseDamage = function(data)
|
||||
}
|
||||
|
||||
Engine.PostMessage(data.target, MT_Attacked,
|
||||
{ "attacker": this.entity, "target": data.target, "type": data.type });
|
||||
{ "attacker": this.entity, "target": data.target, "type": data.type, "damage": -targetState.change });
|
||||
|
||||
PlaySound("attack_impact", this.entity);
|
||||
};
|
||||
|
@ -605,6 +605,13 @@ GuiInterface.prototype.GetStartedResearch = function(player)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns the battle state of the player.
|
||||
GuiInterface.prototype.GetBattleState = function(player)
|
||||
{
|
||||
var cmpBattleDetection = QueryPlayerIDInterface(player, IID_BattleDetection);
|
||||
return cmpBattleDetection.GetState();
|
||||
};
|
||||
|
||||
// Used to show a red square over GUI elements you can't yet afford.
|
||||
GuiInterface.prototype.GetNeededResources = function(player, amounts)
|
||||
{
|
||||
@ -1697,6 +1704,7 @@ var exposedFunctions = {
|
||||
"IsTechnologyResearched": 1,
|
||||
"CheckTechnologyRequirements": 1,
|
||||
"GetStartedResearch": 1,
|
||||
"GetBattleState": 1,
|
||||
"GetNeededResources": 1,
|
||||
"GetNextNotification": 1,
|
||||
|
||||
|
@ -155,6 +155,7 @@ Health.prototype.Reduce = function(amount)
|
||||
|
||||
Engine.PostMessage(this.entity, MT_HealthChanged, { "from": old, "to": this.hitpoints });
|
||||
}
|
||||
state.change = this.hitpoints - old;
|
||||
return state;
|
||||
};
|
||||
|
||||
|
@ -2,5 +2,5 @@ Engine.RegisterInterface("Attack");
|
||||
|
||||
// Message sent from Attack to the target entity, each
|
||||
// time the target is damaged.
|
||||
// Data: { attacker: 123, target: 234 }
|
||||
// Data: { attacker: 123, target: 234, type: "Melee", damage: 123 }
|
||||
Engine.RegisterMessageType("Attacked");
|
||||
|
@ -12,4 +12,5 @@
|
||||
<Player/>
|
||||
<StatisticsTracker/>
|
||||
<TechnologyManager/>
|
||||
<BattleDetection/>
|
||||
</Entity>
|
||||
|
Loading…
Reference in New Issue
Block a user