private void HandleServerEventFormationWipedMessage(FormationWipedMessage message) { MatrixFrame cameraFrame = Mission.Current.GetCameraFrame(); Vec3 position = cameraFrame.origin + cameraFrame.rotation.u; MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/squad_wiped"), position); }
public void OnCapturePointOwnerChanged(FlagCapturePoint flagCapturePoint, Team ownerTeam) { this._capturePointOwners[flagCapturePoint.FlagIndex] = ownerTeam; Action <FlagCapturePoint, Team> ownerChangedEvent = this.OnCapturePointOwnerChangedEvent; if (ownerChangedEvent != null) { ownerChangedEvent(flagCapturePoint, ownerTeam); } if (this._myRepresentative == null || this._myRepresentative.MissionPeer.Team == null) { return; } MatrixFrame cameraFrame = Mission.Current.GetCameraFrame(); Vec3 position = cameraFrame.origin + cameraFrame.rotation.u; if (this._myRepresentative.MissionPeer.Team == ownerTeam) { MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/flag_captured"), position); } else { MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/flag_lost"), position); } }
public void OnCapturePointOwnerChanged(FlagCapturePoint flagCapturePoint, Team ownerTeam) { this._capturePointOwners[flagCapturePoint.FlagIndex] = ownerTeam; Action <FlagCapturePoint, Team> ownerChangedEvent = this.OnCapturePointOwnerChangedEvent; if (ownerChangedEvent != null) { ownerChangedEvent(flagCapturePoint, ownerTeam); } if (ownerTeam != null && ownerTeam.Side == BattleSideEnum.Defender && ((double)this._remainingTimeForBellSoundToStop > 8.0 && flagCapturePoint == this._masterFlag)) { this._bellSoundEvent.Stop(); this._bellSoundEvent = (SoundEvent)null; this._remainingTimeForBellSoundToStop = float.MinValue; this._lastBellSoundPercentage += 0.2f; } if (this._myRepresentative == null || this._myRepresentative.MissionPeer.Team == null) { return; } MatrixFrame cameraFrame = Mission.Current.GetCameraFrame(); Vec3 position = cameraFrame.origin + cameraFrame.rotation.u; if (this._myRepresentative.MissionPeer.Team == ownerTeam) { MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/flag_captured"), position); } else { MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/flag_lost"), position); } }
public void CheckReinforcement(int numberOfTroops) { if (!this.IsInitialSpawnOver) { return; } for (int index = 0; index < 2; ++index) { int val1 = numberOfTroops; if (val1 > 0 && this._numberOfTroopsInQueueForReinforcement[index] > 0 && this._missionSides[index].TroopSpawningActive) { int number = Math.Min(MBMath.Floor((float)val1 * this.BattleSizeEffect), this._numberOfTroopsInQueueForReinforcement[index]); this._missionSides[index].SpawnTroops(number, true); InformationManager.AddQuickInformation(this._missionSides[index].IsPlayerSide ? GameTexts.FindText("str_new_reinforcements_have_arrived_for_ally_side") : GameTexts.FindText("str_new_reinforcements_have_arrived_for_enemy_side")); MatrixFrame cameraFrame = Mission.Current.GetCameraFrame(); Vec3 position = cameraFrame.origin + cameraFrame.rotation.u; MBSoundEvent.PlaySound(this._missionSides[index].IsPlayerSide ? SoundEvent.GetEventIdFromString("event:/alerts/report/reinforcements_ally") : SoundEvent.GetEventIdFromString("event:/alerts/report/reinforcements_enemy"), position); int num1 = Math.Min(val1, this._numberOfTroopsInQueueForReinforcement[index]); this._numberOfTroopsInQueueForReinforcement[index] -= num1; int num2 = num1 - number; this.GetActivePhaseForSide((BattleSideEnum)index).RemainingSpawnNumber += num2; Debug.Print("Side: " + (object)(BattleSideEnum)index, color: Debug.DebugColor.Green, debugFilter: 64UL); Debug.Print("NumberOfTroopsRemovedFromQueue: " + (object)num1, color: Debug.DebugColor.Green, debugFilter: 64UL); Debug.Print("NumberOfTroopsAddedToRemainingPool: " + (object)num2, color: Debug.DebugColor.Green, debugFilter: 64UL); } } }
private void OnAgentWentOut(Agent agent, float startTimeInSeconds) { MissionTimer missionTimer = GameNetwork.IsClient ? MissionTimer.CreateSynchedTimerClient(startTimeInSeconds, 10f) : new MissionTimer(10f); if (GameNetwork.IsServer) { this._agentTimers.Add(agent, missionTimer); MissionPeer missionPeer = agent.MissionPeer; NetworkCommunicator communicator = missionPeer != null?missionPeer.GetNetworkPeer() : (NetworkCommunicator)null; if (communicator != null && !communicator.IsServerPeer) { GameNetwork.BeginModuleEventAsServer(communicator); GameNetwork.WriteMessage((GameNetworkMessage) new SetBoundariesState(true, missionTimer.GetStartTime().NumberOfTicks)); GameNetwork.EndModuleEventAsServer(); } } if (this.Mission.MainAgent != agent) { return; } this._mainAgentLeaveTimer = missionTimer; Action <float, float> startTime = this.StartTime; if (startTime != null) { startTime(10f, 0.0f); } MatrixFrame cameraFrame = Mission.Current.GetCameraFrame(); Vec3 position = cameraFrame.origin + cameraFrame.rotation.u; if (Mission.Current.Mode != MissionMode.Battle) { return; } MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/out_of_map"), position); }
private void OnTeamScoresChanged() { if (GameNetwork.IsDedicatedServer || this._battleEndingNotificationGiven || (this._myRepresentative.MissionPeer.Team == null || this._myRepresentative.MissionPeer.Team.Side == BattleSideEnum.None)) { return; } int intValue = MultiplayerOptions.OptionType.MinScoreToWinMatch.GetIntValue(); float num1 = (float)(intValue - this.ScoreboardComponent.GetRoundScore(this._myRepresentative.MissionPeer.Team.Side)) / (float)intValue; float num2 = (float)(intValue - this.ScoreboardComponent.GetRoundScore(this._myRepresentative.MissionPeer.Team.Side.GetOppositeSide())) / (float)intValue; MatrixFrame cameraFrame = Mission.Current.GetCameraFrame(); Vec3 position = cameraFrame.origin + cameraFrame.rotation.u; if ((double)num1 <= 0.100000001490116 && (double)num2 > 0.100000001490116) { MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/battle_winning"), position); this._battleEndingNotificationGiven = true; } if ((double)num2 > 0.100000001490116 || (double)num1 <= 0.100000001490116) { return; } MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/battle_losing"), position); this._battleEndingNotificationGiven = true; }
public void OnMoraleChanged( int attackerMorale, int defenderMorale, int[] capturePointRemainingMoraleGains) { float num1 = (float)attackerMorale / 360f; float num2 = (float)defenderMorale / 360f; if (this._myRepresentative?.MissionPeer.Team != null && this._myRepresentative.MissionPeer.Team.Side != BattleSideEnum.None) { if ((this._capturePointOwners[this._masterFlag.FlagIndex] == null || this._capturePointOwners[this._masterFlag.FlagIndex].Side != BattleSideEnum.Defender) && (double)this._remainingTimeForBellSoundToStop < 0.0) { if ((double)num2 > (double)this._lastBellSoundPercentage) { this._lastBellSoundPercentage += 0.2f; } if ((double)num2 <= 0.400000005960464) { if ((double)this._lastBellSoundPercentage > 0.400000005960464) { this._remainingTimeForBellSoundToStop = float.MaxValue; this._lastBellSoundPercentage = 0.4f; } } else if ((double)num2 <= 0.600000023841858) { if ((double)this._lastBellSoundPercentage > 0.600000023841858) { this._remainingTimeForBellSoundToStop = 8f; this._lastBellSoundPercentage = 0.6f; } } else if ((double)num2 <= 0.800000011920929 && (double)this._lastBellSoundPercentage > 0.800000011920929) { this._remainingTimeForBellSoundToStop = 4f; this._lastBellSoundPercentage = 0.8f; } if ((double)this._remainingTimeForBellSoundToStop > 0.0) { switch (this._myRepresentative.MissionPeer.Team.Side) { case BattleSideEnum.Defender: this._bellSoundEvent = SoundEvent.CreateEventFromString("event:/multiplayer/warning_bells_defender", this.Mission.Scene); break; case BattleSideEnum.Attacker: this._bellSoundEvent = SoundEvent.CreateEventFromString("event:/multiplayer/warning_bells_attacker", this.Mission.Scene); break; } MatrixFrame globalFrame = this._masterFlag.GameEntity.GetGlobalFrame(); this._bellSoundEvent.PlayInPosition(globalFrame.origin + globalFrame.rotation.u * 3f); } } if (!this._battleEndingNotificationGiven || !this._battleEndingLateNotificationGiven) { float num3 = !this._battleEndingNotificationGiven ? 0.25f : 0.15f; MatrixFrame cameraFrame = Mission.Current.GetCameraFrame(); Vec3 position = cameraFrame.origin + cameraFrame.rotation.u; if ((double)num1 <= (double)num3 && (double)num2 > (double)num3) { MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString(this._myRepresentative.MissionPeer.Team.Side == BattleSideEnum.Attacker ? "event:/alerts/report/battle_losing" : "event:/alerts/report/battle_winning"), position); if (this._myRepresentative.MissionPeer.Team.Side == BattleSideEnum.Attacker) { MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/multiplayer/retreat_horn_attacker"), this._retreatHornPosition); } else if (this._myRepresentative.MissionPeer.Team.Side == BattleSideEnum.Defender) { MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/multiplayer/retreat_horn_defender"), this._retreatHornPosition); } if (this._battleEndingNotificationGiven) { this._battleEndingLateNotificationGiven = true; } this._battleEndingNotificationGiven = true; } if ((double)num2 <= (double)num3 && (double)num1 > (double)num3) { MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString(this._myRepresentative.MissionPeer.Team.Side == BattleSideEnum.Defender ? "event:/alerts/report/battle_losing" : "event:/alerts/report/battle_winning"), position); if (this._battleEndingNotificationGiven) { this._battleEndingLateNotificationGiven = true; } this._battleEndingNotificationGiven = true; } } } Action <BattleSideEnum, float> moraleChangedEvent1 = this.OnMoraleChangedEvent; if (moraleChangedEvent1 != null) { moraleChangedEvent1(BattleSideEnum.Attacker, num1); } Action <BattleSideEnum, float> moraleChangedEvent2 = this.OnMoraleChangedEvent; if (moraleChangedEvent2 != null) { moraleChangedEvent2(BattleSideEnum.Defender, num2); } Action <int[]> gainsChangedEvent = this.OnCapturePointRemainingMoraleGainsChangedEvent; if (gainsChangedEvent == null) { return; } gainsChangedEvent(capturePointRemainingMoraleGains); }
public static bool PlaySound(int soundCodeId, ref SoundEventParameter parameter, Vec3 position) { Vec3 position1 = position; return(MBSoundEvent.PlaySound(soundCodeId, ref parameter, ref position1)); }
public override void OnAgentRemoved( Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow) { base.OnAgentRemoved(affectedAgent, affectorAgent, agentState, blow); if (this.UseGold() && affectorAgent != null && (affectedAgent != null && affectedAgent.IsHuman) && (blow.DamageType != DamageTypes.Invalid && (agentState == AgentState.Unconscious || agentState == AgentState.Killed))) { Agent.Hitter assistingHitter = affectedAgent.GetAssistingHitter(affectorAgent.MissionPeer); MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(affectedAgent.Character); if (affectorAgent.MissionPeer != null && affectorAgent.MissionPeer.Representative is FlagDominationMissionRepresentative representative10) { int gainsFromKillData = representative10.GetGoldGainsFromKillData(MPPerkObject.GetPerkHandler(affectorAgent.MissionPeer), MPPerkObject.GetPerkHandler(assistingHitter?.HitterPeer), classForCharacter, false); if (gainsFromKillData > 0) { this.ChangeCurrentGoldForPeer(affectorAgent.MissionPeer, representative10.Gold + gainsFromKillData); } } if (assistingHitter?.HitterPeer != null && !assistingHitter.IsFriendlyHit && assistingHitter.HitterPeer.Representative is FlagDominationMissionRepresentative representative11) { int gainsFromKillData = representative11.GetGoldGainsFromKillData(MPPerkObject.GetPerkHandler(affectorAgent.MissionPeer), MPPerkObject.GetPerkHandler(assistingHitter.HitterPeer), classForCharacter, false); if (gainsFromKillData > 0) { this.ChangeCurrentGoldForPeer(assistingHitter.HitterPeer, representative11.Gold + gainsFromKillData); } } if (affectedAgent.MissionPeer?.Team != null) { IEnumerable <(MissionPeer, int)> goldRewardsOnDeath = MPPerkObject.GetPerkHandler(affectedAgent.MissionPeer)?.GetTeamGoldRewardsOnDeath(); if (goldRewardsOnDeath != null) { foreach ((MissionPeer peer6, int baseAmount6) in goldRewardsOnDeath) { if (baseAmount6 > 0 && peer6?.Representative is FlagDominationMissionRepresentative representative12) { int local_11 = representative12.GetGoldGainsFromAllyDeathReward(baseAmount6); if (local_11 > 0) { this.ChangeCurrentGoldForPeer(peer6, representative12.Gold + local_11); } } } } } } if (affectedAgent.IsPlayerControlled) { affectedAgent.MissionPeer.GetComponent <FlagDominationMissionRepresentative>().UpdateSelectedClassServer((Agent)null); } else { if (MultiplayerOptions.OptionType.NumberOfBotsPerFormation.GetIntValue() <= 0 || this.WarmupComponent != null && this.WarmupComponent.IsInWarmup || (affectedAgent.IsMount || affectedAgent.OwningAgentMissionPeer == null || (affectedAgent.Formation == null || affectedAgent.Formation.CountOfUnits != 1))) { return; } if (!GameNetwork.IsDedicatedServer) { MatrixFrame cameraFrame = Mission.Current.GetCameraFrame(); Vec3 position = cameraFrame.origin + cameraFrame.rotation.u; MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/squad_wiped"), position); } GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new FormationWipedMessage()); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.ExcludeOtherTeamPlayers, affectedAgent.OwningAgentMissionPeer.GetNetworkPeer()); } }