protected override void LethalElectrocution(Electrocution electrocution, float shockPower) { PlayerMove.allowInput = false; // TODO: Add sparks VFX at shockSourcePos. SoundManager.PlayNetworkedAtPos(CommonSounds.Instance.Sparks, electrocution.ShockSourcePos); StartCoroutine(ElectrocutionSequence()); string victimChatString, observerChatString; if (electrocution.ShockSourceName != null) { victimChatString = $"The {electrocution.ShockSourceName} electrocutes you!"; observerChatString = $"{gameObject.ExpensiveName()} is electrocuted by the {electrocution.ShockSourceName}!"; } else { victimChatString = $"Something electrocutes you!"; observerChatString = $"{gameObject.ExpensiveName()} is electrocuted by something!"; } Chat.AddCombatMsgToChat(gameObject, victimChatString, observerChatString); var damage = shockPower / ELECTROCUTION_BURNDAMAGE_MODIFIER; if (ELECTROCUTION_MAX_DAMAGE != -1 && damage > ELECTROCUTION_MAX_DAMAGE) { damage = ELECTROCUTION_MAX_DAMAGE; } DealElectrocutionDamage(damage * 0.4f, electrocutedHand); DealElectrocutionDamage(damage * 0.25f, BodyPartType.Chest); DealElectrocutionDamage(damage * 0.175f, BodyPartType.LeftLeg); DealElectrocutionDamage(damage * 0.175f, BodyPartType.RightLeg); }
private void Electrocute(float voltage) { var electrocution = new Electrocution(voltage, registerObject.WorldPosition); var performerLHB = GetComponent <LivingHealthBehaviour>(); performerLHB.Electrocute(electrocution); }
/// <summary> /// Calculates the player's total resistance using a base humanoid resistance value, /// their health and the items the performer is wearing or holding. /// Assumes the player is a humanoid. /// </summary> /// <param name="voltage">The potential difference across the player</param> /// <returns>float resistance</returns> protected override float ApproximateElectricalResistance(float voltage) { // Assume the player is a humanoid float resistance = GetNakedHumanoidElectricalResistance(voltage); // Give the humanoid extra/less electrical resistance based on what they're holding/wearing foreach (var itemSlot in dynamicItemStorage.GetNamedItemSlots(NamedSlot.hands)) { resistance += Electrocution.GetItemElectricalResistance(itemSlot.ItemObject); } foreach (var itemSlot in dynamicItemStorage.GetNamedItemSlots(NamedSlot.feet)) { resistance += Electrocution.GetItemElectricalResistance(itemSlot.ItemObject); } // A solid grip on a conductive item will reduce resistance - assuming it is conductive. if (dynamicItemStorage.GetActiveHandSlot().Item != null) { resistance -= 300; } // Broken skin reduces electrical resistance - arbitrarily chosen at 4 to 1. resistance -= 4 * GetTotalBruteDamage(); // Make sure the humanoid doesn't get ridiculous conductivity. if (resistance < 100) { resistance = 100; } return(resistance); }
/// <summary> /// [Message Handler] Perform cable cutting interaction on server side /// </summary> private void ServerPerformCableCuttingInteraction(NetworkConnection conn, CableCuttingWindow.CableCuttingMessage message) { // get object at target position GameObject hit = MouseUtils.GetOrderedObjectsAtPoint(message.targetWorldPosition).FirstOrDefault(); // get matrix Matrix matrix = hit.GetComponentInChildren <Matrix>(); // return if matrix is null if (matrix == null) { return; } // convert world position to cell position and set Z value to Z value from message Vector3Int targetCellPosition = matrix.MetaTileMap.WorldToCell(message.targetWorldPosition); targetCellPosition.z = message.positionZ; // get electical tile from targetCellPosition ElectricalCableTile electricalCable = matrix.UnderFloorLayer.GetTileUsingZ(targetCellPosition) as ElectricalCableTile; if (electricalCable == null) { return; } // add messages to chat string othersMessage = Chat.ReplacePerformer(othersStartActionMessage, message.performer); Chat.AddActionMsgToChat(message.performer, performerStartActionMessage, othersMessage); // source: ElectricalCableDeconstruction.cs var metaDataNode = matrix.GetMetaDataNode(targetCellPosition); foreach (var ElectricalData in metaDataNode.ElectricalData) { if (ElectricalData.RelatedTile != electricalCable) { continue; } // Electrocute the performer. If shock is painful enough, cancel the interaction. ElectricityFunctions.WorkOutActualNumbers(ElectricalData.InData); float voltage = ElectricalData.InData.Data.ActualVoltage; var electrocution = new Electrocution(voltage, message.targetWorldPosition, "cable"); var performerLHB = message.performer.GetComponent <LivingHealthBehaviour>(); var severity = performerLHB.Electrocute(electrocution); if (severity > LivingShockResponse.Mild) { return; } ElectricalData.InData.DestroyThisPlease(); Spawn.ServerPrefab(electricalCable.SpawnOnDeconstruct, message.targetWorldPosition, count: electricalCable.SpawnAmountOnDeconstruct); return; } }
private void Electrocute(float voltage) { var electrocution = new Electrocution(voltage, registerObject.WorldPosition); var performerLHB = GetComponent <LivingHealthBehaviour>(); performerLHB.Electrocute(electrocution); //doing a shit ton of damage because all mobs have too much hardcoded HP right now //TODO get rid of this part once health rework is done! performerLHB.ApplyDamage(gameObject, 200, AttackType.Internal, DamageType.Tox); }
/// <summary> /// Electrocutes a player, applying effects to the victim depending on the electrocution power. /// </summary> /// <param name="electrocution">The object containing all information for this electrocution</param> /// <returns>Returns an ElectrocutionSeverity for when the following logic depends on the elctrocution severity.</returns> public override LivingShockResponse Electrocute(Electrocution electrocution) { if (playerNetworkActions.activeHand == NamedSlot.leftHand) { electrocutedHand = BodyPartType.LeftArm; } else { electrocutedHand = BodyPartType.RightArm; } return(base.Electrocute(electrocution)); }
bool Electrocute(float voltage) { var performerLHB = interaction.Performer.GetComponent <LivingHealthMasterBase>(); var electrocutionExposure = new Electrocution(voltage, interaction.WorldPositionTarget, interaction.BasicTile.DisplayName); var severity = performerLHB.Electrocute(electrocutionExposure); // If the electrocution was painful, return true to stop other interactions. if (severity >= LivingShockResponse.Painful) { return(true); } return(false); }
private void ServerElectrocute(GameObject obj) { float r = UnityEngine.Random.value; if (r < 0.45) { PlayerScript ply = obj.GetComponent <PlayerScript>(); if (ply != null) { hackingProcess.HackingGUI.RemovePlayer(ply.gameObject); TabUpdateMessage.Send(ply.gameObject, hackingProcess.HackingGUI.Provider, NetTabType.HackingPanel, TabAction.Close); Electrocution elec = new Electrocution(); elec.ElectrocutePlayer(ply.gameObject, (Vector2Int)registerTile.WorldPositionServer, "wire", 9080); } } }
public override void ServerPerformInteraction(TileApply interaction) { string othersMessage = Chat.ReplacePerformer(othersStartActionMessage, interaction.Performer); Chat.AddActionMsgToChat(interaction.Performer, performerStartActionMessage, othersMessage); if (interaction.BasicTile.LayerType != LayerType.Underfloor) { return; } var ElectricalCable = interaction.BasicTile as ElectricalCableTile; if (ElectricalCable == null) { return; } var matrix = interaction.TileChangeManager.MetaTileMap.Layers[LayerType.Underfloor].matrix; var metaDataNode = matrix.GetMetaDataNode(interaction.TargetCellPos); foreach (var ElectricalData in metaDataNode.ElectricalData) { if (ElectricalData.RelatedTile != ElectricalCable) { continue; } // Electrocute the performer. If shock is painful enough, cancel the interaction. ElectricityFunctions.WorkOutActualNumbers(ElectricalData.InData); float voltage = ElectricalData.InData.Data.ActualVoltage; var electrocution = new Electrocution(voltage, interaction.WorldPositionTarget, "cable"); var performerLHB = interaction.Performer.GetComponent <LivingHealthMasterBase>(); var severity = performerLHB.Electrocute(electrocution); if (severity > LivingShockResponse.Mild) { return; } ElectricalData.InData.DestroyThisPlease(); Spawn.ServerPrefab(ElectricalCable.SpawnOnDeconstruct, interaction.WorldPositionTarget, count: ElectricalCable.SpawnAmountOnDeconstruct); return; } }
protected override void PainfulElectrocution(Electrocution electrocution, float shockPower) { // TODO: Add sparks VFX at shockSourcePos. SoundManager.PlayNetworkedAtPos(CommonSounds.Instance.Sparks, electrocution.ShockSourcePos); Inventory.ServerDrop(dynamicItemStorage.GetActiveHandSlot()); // Slip is essentially a yelp SFX. AudioSourceParameters audioSourceParameters = new AudioSourceParameters(pitch: UnityEngine.Random.Range(0.4f, 1.2f)); SoundManager.PlayNetworkedAtPos(CommonSounds.Instance.Slip, registerPlayer.WorldPosition, audioSourceParameters, sourceObj: gameObject); string victimChatString = (electrocution.ShockSourceName != null ? $"The {electrocution.ShockSourceName}" : "Something") + " gives you a small electric shock!"; Chat.AddExamineMsgFromServer(gameObject, victimChatString); DealElectrocutionDamage(5, electrocutedHand); }
private void ServerElectrocute(GameObject obj) { float r = UnityEngine.Random.value; if (r < 0.45) //TODO: Magic number, needs to be fixed. { PlayerScript ply = obj.GetComponent <PlayerScript>(); if (ply != null) { hackingProcess.HackingGUI.RemovePlayer(ply.gameObject); TabUpdateMessage.Send(ply.gameObject, hackingProcess.HackingGUI.Provider, NetTabType.HackingPanel, TabAction.Close); var playerLHB = obj.GetComponent <LivingHealthBehaviour>(); var electrocution = new Electrocution(9080, registerTile.WorldPositionServer, "wire"); //More magic numbers. if (playerLHB != null) { playerLHB.Electrocute(electrocution); } } } }
public void ServerPerformInteraction(HandApply interaction) { if (canNotBeDeconstructed) { Chat.AddExamineMsgFromServer(interaction.Performer, "This APC is too well built to be deconstructed."); return; } float voltage = Voltage * 10; Vector3 shockpos = gameObject.WorldPosServer(); Electrocution electrocution = new Electrocution(voltage, shockpos, "APC"); interaction.Performer.GetComponent <PlayerHealthV2>().Electrocute(electrocution); ToolUtils.ServerUseToolWithActionMessages(interaction, secondsToScrewdrive, $"You start to disconnect the {gameObject.ExpensiveName()}'s electronics...", $"{interaction.Performer.ExpensiveName()} starts to disconnect the {gameObject.ExpensiveName()}'s electronics...", $"You disconnect the {gameObject.ExpensiveName()}'s electronics.", $"{interaction.Performer.ExpensiveName()} disconnects the {gameObject.ExpensiveName()}'s electronics.", () => { WhenDestroyed(null); }); }
protected override void MildElectrocution(Electrocution electrocution, float shockPower) { SoundManager.PlayNetworkedAtPos(CommonSounds.Instance.ElectricShock, registerPlayer.WorldPosition); Chat.AddExamineMsgFromServer(gameObject, $"The {electrocution.ShockSourceName} gives you a slight tingling sensation..."); }