private static string HicBurp(Match m) { string x = m.ToString(); string hicburp = ""; if (DMMath.Prob(10)) { int hicburptext = Random.Range(1, 4); switch (hicburptext) { case 1: hicburp = "- burp... "; break; case 2: hicburp = "- hic- "; break; case 3: hicburp = "- hic! "; break; case 4: hicburp = "- buuuurp... "; break; } } else { hicburp = x; } return(hicburp); }
/// <summary> /// Applies trauma damage to the body part, checks if it has enough protective armor to cancel the trauma damage /// </summary> public void ApplyTraumaDamage(TraumaticDamageTypes damageType = TraumaticDamageTypes.SLASH, bool ignoreSeverityCheck = false) { if (Severity < DamageSeverity.Bad && ignoreSeverityCheck == false) { return; } //We use dismember protection chance because it's the most logical value. if (DMMath.Prob(SelfArmor.DismembermentProtectionChance) == false) { if (damageType == TraumaticDamageTypes.SLASH) { currentSlashDamageLevel += 1; } if (damageType == TraumaticDamageTypes.PIERCE) { currentPierceDamageLevel += 1; } } //Burn and blunt damage checks for it's own armor damage type. if (damageType == TraumaticDamageTypes.BURN) { TakeBurnDamage(); } if (damageType == TraumaticDamageTypes.BLUNT && DMMath.Prob(SelfArmor.Melee * 100) == false) { TakeBluntDamage(); } }
public void TakeBluntDamage() { void TakeBluntLogic(BodyPart bodyPart) { if (bodyPart.currentBluntDamageLevel == TraumaDamageLevel.SMALL && DMMath.Prob(dislocationAutoHealPercent)) { bodyPart.currentBluntDamageLevel = TraumaDamageLevel.NONE; AnnounceJointHealEvent(); return; } bodyPart.currentBluntDamageLevel += 1; AnnounceJointDislocationEvent(); } foreach (ItemSlot slot in OrganStorage.GetIndexedSlots()) { if (slot.IsEmpty) { return; } if (slot.Item.gameObject.TryGetComponent <BodyPart>(out var bodyPart)) { if (bodyPart.CanBeBroken) { TakeBluntLogic(bodyPart); } } } }
private void SpawnItems(PoolData poolData) { if (poolData == null) { return; } var itemPool = poolData.RandomItemPool; if (itemPool == null) { Debug.LogError($"Item pool was null in {gameObject.name}"); return; } var item = poolData.RandomItemPool.Pool.PickRandom(); var spread = fanOut ? Random.Range(-0.5f, 0.5f) : (float?)null; if (!DMMath.Prob(item.Probability)) { return; } var maxAmt = Random.Range(1, item.MaxAmount + 1); Spawn.ServerPrefab( item.Prefab, gameObject.RegisterTile().WorldPositionServer, count: maxAmt, scatterRadius: spread); }
private void RollRandomPool(MatrixInfo matrixInfo) { for (int i = 0; i <= lootCount; i++) { PoolData pool = null; // Roll attempt is a safe check in the case the mapper did tables with low % and we can't find // anything to spawn in 5 attempts int rollAttempt = 0; while (pool == null) { if (rollAttempt >= MaxAmountRolls) { continue; } var tryPool = poolList.PickRandom(); if (DMMath.Prob(tryPool.Probability)) { pool = tryPool; } else { rollAttempt++; } } SpawnItems(pool); } }
/// <summary> /// Update Loop, runs every 1 second /// </summary> private void EmitterUpdate() { if (CustomNetworkManager.IsServer == false) { return; } if (isOn == false && alwaysShoot == false) { return; } if (voltage < minVoltage && alwaysShoot == false) { spriteHandler.ChangeSprite(2); return; } //Reset sprite if power is now available TogglePower(isOn); //Shoot 75% of the time, to add variation if (DMMath.Prob(25)) { return; } ShootEmitter(); }
private void FinishHack(HandApply interaction) { if (DMMath.Prob(chanceToFailHack)) { Chat.AddActionMsgToChat(interaction.Performer, "Your attempt to hack the shuttle console failed", $"{interaction.Performer.ExpensiveName()} failed to hack the shuttle console"); return; } Chat.AddActionMsgToChat(interaction.Performer, "You hack the shuttle console", $"{interaction.Performer.ExpensiveName()} hacked the shuttle console"); beenEmagged = true; if (GameManager.Instance.ShuttleSent) { return; } Chat.AddSystemMsgToChat("\n\n<color=#FF151F><size=40><b>Escape Shuttle Emergency Launch Triggered!</b></size></color>\n\n", MatrixManager.MainStationMatrix); Chat.AddSystemMsgToChat("\n\n<color=#FF151F><size=40><b>Escape Shuttle Emergency Launch Triggered!</b></size></color>\n\n", GameManager.Instance.PrimaryEscapeShuttle.MatrixInfo); SoundManager.PlayNetworked(SingletonSOSounds.Instance.Notice1); GameManager.Instance.ForceSendEscapeShuttleFromStation(10); }
private void SpawnItems(PoolData poolData) { if (poolData == null) { return; } var itemPool = poolData.RandomItemPool; if (itemPool == null) { Logger.LogError($"Item pool was null in {gameObject.name}", Category.ItemSpawn); return; } var item = poolData.RandomItemPool.Pool.PickRandom(); var spread = fanOut ? Random.Range(-0.5f, 0.5f) : (float?)null; if (!DMMath.Prob(item.Probability)) { return; } var maxAmt = Random.Range(1, item.MaxAmount + 1); var worldPos = gameObject.AssumedWorldPosServer(); var pushPull = GetComponent <PushPull>(); Spawn.ServerPrefab(item.Prefab, worldPos, count: maxAmt, scatterRadius: spread, sharePosition: pushPull); }
public void ServerPerformInteraction(HandApply interaction) { if (isReadyToBeHit == false) { isReadyToBeHit = true; Chat.AddExamineMsg(interaction.Performer, "You pull the tip of the nofruit and watch as multiple colors flash in front of you!"); StartCoroutine(CycleSprites()); return; } if (interaction.UsedObject == null || interaction.UsedObject.Item().Size < ItemSize.Medium) { var hasObject = interaction.UsedObject ? "a more" : "a"; Chat.AddExamineMsg(interaction.Performer, $"You need {hasObject} blunt object to hit this!"); return; } StopCoroutine(CycleSprites()); if (DMMath.Prob(1f)) { Spawn.ServerPrefab(facehugger, gameObject.AssumedWorldPosServer()); return; } else { Spawn.ServerPrefab(chanceToSpawn[currentIndex].fruit, gameObject.AssumedWorldPosServer()); } _ = Despawn.ServerSingle(gameObject); }
private static string HicBurp(Match m) { string x = m.ToString(); string hicburp = ""; if (DMMath.Prob(40)) { int hicburptext = Random.Range(1, 4); if (hicburptext == 1) { hicburp = " burp "; } else if (hicburptext == 2) { hicburp = " hic- "; } else if (hicburptext == 3) { hicburp = " hiccup- "; } else if (hicburptext == 4) { hicburp = " buuuurp "; } } else { hicburp = x; } return(hicburp); }
private void SignalStrengthHandler(SignalReceiver receiver, SignalEmitter emitter, SignalDataSO signalDataSo, ISignalMessage signalMessage = null) { SignalStrength strength = GetStrength(receiver, emitter, signalDataSo.SignalRange); if (strength == SignalStrength.HEALTHY) { receiver.ReceiveSignal(strength, signalMessage); } if (strength == SignalStrength.TOOFAR) { emitter.SignalFailed(); } if (strength == SignalStrength.DELAYED) { StartCoroutine(DelayedSignalRecevie(receiver.DelayTime, receiver, strength, signalMessage)); return; } if (strength == SignalStrength.WEAK) { Random chance = new Random(); if (DMMath.Prob(chance.Next(0, 100))) { StartCoroutine(DelayedSignalRecevie(receiver.DelayTime, receiver, strength, signalMessage)); } emitter.SignalFailed(); } }
private static void InternalSpark(GameObject gameObject, Vector3 worldPos, float chanceToSpark, bool expose) { //Clamp just in case chanceToSpark = Mathf.Clamp(chanceToSpark, 1, 100); //E.g will have 25% chance to not spark when chanceToSpark = 75 if (DMMath.Prob(100 - chanceToSpark)) { return; } var result = Spawn.ServerPrefab(CommonPrefabs.Instance.SparkEffect, worldPos, gameObject != null ? gameObject.transform.parent : null); if (result.Successful == false) { return; } if (expose) { //Try start fire if possible var reactionManager = MatrixManager.AtPoint(worldPos.RoundToInt(), true).ReactionManager; reactionManager.ExposeHotspotWorldPosition(worldPos.To2Int(), 1000); } SoundManager.PlayNetworkedAtPos(CommonSounds.Instance.Sparks, worldPos, sourceObj: gameObject.OrNull()); }
public override void InternalDamageLogic() { if (!onCooldown) { if (RelatedPart.CurrentInternalBleedingDamage > RelatedPart.MaximumInternalBleedDamage / 2) { Chat.AddActionMsgToChat(RelatedPart.HealthMaster.gameObject, "You gasp for air; but you drown in your own blood from the inside!", $"{RelatedPart.HealthMaster.playerScript.visibleName} gasps for air!"); RelatedPart.HealthMaster.HealthStateController.SetSuffocating(true); } else { RelatedPart.InternalBleedingLogic(); } if (DMMath.Prob(coughChanceWhenInternallyBleeding)) { Chat.AddActionMsgToChat(RelatedPart.HealthMaster.gameObject, "You cough up blood!", $"{RelatedPart.HealthMaster.playerScript.visibleName} coughs up blood!"); RelatedPart.CurrentInternalBleedingDamage -= 4; //TODO: TAKE BLOOD var bloodLoss = new ReagentMix(); RelatedPart.HealthMaster.CirculatorySystem.ReadyBloodPool.TransferTo(bloodLoss, RelatedPart.CurrentInternalBleedingDamage); MatrixManager.ReagentReact(bloodLoss, RelatedPart.HealthMaster.gameObject.RegisterTile().WorldPositionServer); } onCooldown = true; StartCoroutine(CooldownTick()); } }
/// <summary> /// Applies trauma damage to the body part, checks if it has enough protective armor to cancel the trauma damage /// and automatically checks how big is the body part's cut size. /// </summary> public void ApplyTraumaDamage(float tramuaDamage, TraumaticDamageTypes damageType = TraumaticDamageTypes.SLASH) { //We use dismember protection chance because it's the most logical value. if (DMMath.Prob(SelfArmor.DismembermentProtectionChance * 100) == false) { if (damageType == TraumaticDamageTypes.SLASH) { currentSlashCutDamage += MultiplyTraumaDamage(tramuaDamage); } if (damageType == TraumaticDamageTypes.PIERCE) { currentPierceDamage += MultiplyTraumaDamage(tramuaDamage); } CheckCutSize(); } //Burn and blunt damage checks for it's own armor damage type. if (damageType == TraumaticDamageTypes.BURN) { TakeBurnDamage(MultiplyTraumaDamage(tramuaDamage)); } if (damageType == TraumaticDamageTypes.BLUNT) { if (DMMath.Prob(SelfArmor.Melee * 100) == false) { TakeBluntDamage(tramuaDamage); } } }
protected override void OnAttackReceived(GameObject damagedBy = null) { if (damagedBy == null) { StartFleeing(damagedBy); } if (health.OverallHealth < -20f) { //30% chance the mob decides to flee: if (DMMath.Prob(fleeChance)) { StartFleeing(damagedBy, 5f); return; } } if ((damagedBy is null) != false || damagedBy.transform == mobMeleeAttack.followTarget) { return; } //80% chance the mob decides to attack the new attacker if (DMMath.Prob(attackLastAttackerChance) == false) { return; } var playerScript = damagedBy.GetComponent <PlayerScript>(); if (playerScript != null) { BeginAttack(damagedBy); } }
private void AIObjectives() { if (DMMath.Prob(GameManager.Instance.MalfAIRecieveTheirIntendedObjectiveChance)) { AddObjective(aiTraitorObjective); } }
private void TrySpark() { //Has to be broken and have power to spark if (mState != LightMountState.Broken || powerState == PowerState.Off) { return; } //25% chance to do effect and not already doing an effect if (DMMath.Prob(75) || currentSparkEffect != null) { return; } var worldPos = registerTile.WorldPositionServer; var result = Spawn.ServerPrefab(CommonPrefabs.Instance.SparkEffect, worldPos, gameObject.transform.parent); if (result.Successful) { currentSparkEffect = result.GameObject; //Try start fire if possible var reactionManager = MatrixManager.AtPoint(worldPos, true).ReactionManager; reactionManager.ExposeHotspotWorldPosition(worldPos.To2Int()); SoundManager.PlayNetworkedAtPos(SingletonSOSounds.Instance.Sparks, worldPos, sourceObj: gameObject); } }
/// <summary> /// Applies trauma damage to the body part, checks if it has enough protective armor to cancel the trauma damage /// and automatically checks how big is the body part's cut size. /// </summary> public void ApplyTraumaDamage(float tramuaDamage, TramuticDamageTypes damageType = TramuticDamageTypes.SLASH) { //We use dismember protection chance because it's the most logical value. if (DMMath.Prob(SelfArmor.DismembermentProtectionChance * 100) == false) { if (damageType == TramuticDamageTypes.SLASH) { currentSlashCutDamage += tramuaDamage; } if (damageType == TramuticDamageTypes.PIERCE) { currentPierceDamage += tramuaDamage; } CheckCutSize(); } //Burn damage checks for it's own armor damage type. if (damageType == TramuticDamageTypes.BURN) { //Large cuts and parts in terrible condition means less protective flesh against fire. if (currentSlashDamageLevel == SlashDamageLevel.LARGE || Severity >= DamageSeverity.Critical) { TakeBurnDamage(tramuaDamage * 1.25f); } else { TakeBurnDamage(tramuaDamage); } } }
private void DestroyObjects(IEnumerable <Vector3Int> coords) { var damage = 100; if (CurrentStage == SingularityStages.Stage5 || CurrentStage == SingularityStages.Stage4) { damage *= (int)CurrentStage; } foreach (var coord in coords) { var objects = MatrixManager.GetAt <RegisterTile>(coord, true); foreach (var objectToMove in objects) { if (objectToMove.gameObject == gameObject) { continue; } if (objectToMove.ObjectType == ObjectType.Player && objectToMove.TryGetComponent <PlayerHealthV2>(out var health) && health != null) { if (health.RegisterPlayer.PlayerScript != null && health.RegisterPlayer.PlayerScript.mind != null && health.RegisterPlayer.PlayerScript.mind.occupation != null && health.RegisterPlayer.PlayerScript.mind.occupation == OccupationList.Instance.Get(JobType.CLOWN)) { health.Gib(); ChangePoints(DMMath.Prob(50) ? -1000 : 1000); return; } health.Gib(); ChangePoints(100); }
/// <summary> /// Try spark at world pos /// </summary> /// <returns>Null if the spark failed, else the new spark object.</returns> public static GameObject TrySpark(Vector3 worldPos, float chanceToSpark = 75, bool expose = true) { //Clamp just in case chanceToSpark = Mathf.Clamp(chanceToSpark, 1, 100); //E.g will have 25% chance to not spark when chanceToSpark = 75 if (DMMath.Prob(100 - chanceToSpark)) { return(null); } var result = Spawn.ServerPrefab(CommonPrefabs.Instance.SparkEffect, worldPos); if (result.Successful) { if (expose) { //Try start fire if possible var reactionManager = MatrixManager.AtPoint(worldPos.RoundToInt(), true).ReactionManager; reactionManager.ExposeHotspotWorldPosition(worldPos.To2Int(), 1000); } SoundManager.PlayNetworkedAtPos(SingletonSOSounds.Instance.Sparks, worldPos); return(result.GameObject); } return(null); }
public void OnTeleportEnd() { if (DMMath.Prob(10)) { Spawn.ServerPrefab(mutatedFood, gameObject.AssumedWorldPosServer()); _ = Despawn.ServerSingle(gameObject); } }
/// <summary> /// Generates a set of valid objectives for a player based on their antag type. /// Will set them up and ensure all targets are unique. /// Amount to generate does not include the escape objective. /// </summary> /// <param name="player">The player receiving these objectives</param> /// <param name="antag">The antag type</param> /// <param name="amount">How many objectives to generate, not including escape objectives</param> public List <Objective> GenerateObjectives(PlayerScript player, Antagonist antag) { int amount = antag.NumberOfObjectives; // Get all antag core and shared objectives which are possible for this player List <Objective> objPool = antag.CoreObjectives.Where(obj => obj.IsPossible(player)).ToList(); if (antag.CanUseSharedObjectives) { objPool = objPool.Concat(SharedObjectives).Where(obj => obj.IsPossible(player)).ToList(); } if (objPool.Count == 0) { amount = 0; Logger.LogWarning($"No objectives available, only assigning escape type objective", Category.Antags); } List <Objective> generatedObjs = new List <Objective>(); Objective newObjective; for (int i = 0; i < amount; i++) { // Select objective and perform setup e.g. assign owner and targets newObjective = PickRandomObjective(ref objPool); newObjective.DoSetup(player.mind); generatedObjs.Add(newObjective); // Trim any objectives which aren't possible // Should be done everytime an objective is assigned and setup, // otherwise all targets could be taken already! objPool = objPool.Where(obj => obj.IsPossible(player)).ToList(); if (objPool.Count == 0) { // No objectives left to give so stop assigning break; } } if (antag.NeedsEscapeObjective) { // Add one escape type objective if needed // Be careful not to remove all escape objectives from AntagData newObjective = PickRandomObjective(ref EscapeObjectives, false); newObjective.DoSetup(player.mind); generatedObjs.Add(newObjective); } if (antag.ChanceForGimmickObjective != 0 && DMMath.Prob(antag.ChanceForGimmickObjective)) { // Add one gimmick objective newObjective = PickRandomObjective(ref GimmickObjectives, false); newObjective.DoSetup(player.mind); generatedObjs.Add(newObjective); } return(generatedObjs); }
protected override void Start() { base.Start(); if (DMMath.Prob(10)) { itemAttributes.ServerSetArticleName("spess cube"); } }
private void OnThrown(ThrowInfo info) { if (DMMath.Prob(chanceToBreak)) { Spawn.ServerPrefab(brokenItem, gameObject.AssumedWorldPosServer()); SoundManager.PlayNetworkedAtPos(useCustomSound ? customSound : SingletonSOSounds.Instance.GlassBreak01, gameObject.AssumedWorldPosServer()); Despawn.ServerSingle(gameObject); } }
protected override void DoRandomAction() { if (DMMath.Prob(5)) { StartCoroutine(ChaseTail(Random.Range(1, 4))); } StartFleeing(gameObject, 10f); }
public void OnEmp(int EmpStrength = 0) { foreach (Cable cable in Cables) { if (DMMath.Prob(50)) { cable.Impulse(); } } }
public void OnEmp(int EmpStrength) { Watts -= EmpStrength * 100; Mathf.Clamp(Watts, 0, MaxWatts); if (EmpStrength > 50 && DMMath.Prob(25)) { isBroken = true; } }
public void OnEmp(int EmpStrength) { if (CurrentCharge > 10000000 && DMMath.Prob(25) && isExploding == false) { isExploding = true; TrySpark(); Chat.AddLocalMsgToChat($"<color=red>{gameObject.ExpensiveName()} starts to spit out sparks and smoke! No way this can end good...", gameObject); StartCoroutine(Emp()); } batterySupplyingModule.CurrentCapacity -= EmpStrength * 1000; }
public void TakeBluntLogic(LivingHealthMasterBase healthmaster, BodyPart containedIn) { if (currentBluntDamageLevel == TraumaDamageLevel.SMALL && DMMath.Prob(dislocationAutoHealPercent)) { currentBluntDamageLevel = TraumaDamageLevel.NONE; AnnounceJointHealEvent(healthmaster, containedIn); return; } currentBluntDamageLevel += 1; AnnounceJointDislocationEvent(healthmaster, containedIn); }
private void UpdateSignalStatusStatus() { if (pizza.IsArmed) { status.Value = "Awaiting Signal.."; status.Element.color = dangerColor; return; } status.Value = DMMath.Prob(25f) ? "Ready to oga some bogas" : "Explosive Unarmed.."; status.Element.color = safeColor; }