From 4fca2144ed66cd68c5137e25291fc38b15b57ec4 Mon Sep 17 00:00:00 2001 From: Jack Wright <68773585+Ethirix@users.noreply.github.com> Date: Mon, 17 Apr 2023 20:41:30 +0100 Subject: [PATCH 1/2] Added More Configurable Options Added the ability to disable the mod entirely, through `EuphoriaFromWeaponDamage` and `EuphoriaFromMeleeDamage`. Options added: - `EuphoriaFromWeaponDamage` - Sets if Euphoria take over if damaged by weapon - `NormalEuphoriaInRandomize` - Can `Normal` Euphoria be used during `EuphoriaType` randomization. - `StiffFallEuphoriaInRandomize` - Can `StiffFall` Euphoria be used during `EuphoriaType` randomization. - `NarrowStumbleEuphoriaInRandomize` - Can `NarrowStumble` Euphoria be used during `EuphoriaType` randomization. - `WideStumbleEuphoriaInRandomize` - Can `WideStumble` Euphoria be used during `EuphoriaType` randomization. --- Euphorically/Config/EuphoriaConfig.cs | 10 +++++ Euphorically/Euphorically.ini | 14 +++++- Euphorically/Main.cs | 61 +++++++++++++++++++++++++-- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/Euphorically/Config/EuphoriaConfig.cs b/Euphorically/Config/EuphoriaConfig.cs index f6103db..b7524e3 100644 --- a/Euphorically/Config/EuphoriaConfig.cs +++ b/Euphorically/Config/EuphoriaConfig.cs @@ -18,6 +18,11 @@ public EuphoriaConfig(ScriptSettings settings) EuphoriaMinimumChance = settings.GetValue(ConfigName, "EuphoriaMinimumChance", 10); EuphoriaMaximumChance = settings.GetValue(ConfigName, "EuphoriaMaximumChance", 20); EuphoriaAntiSpamTime = settings.GetValue(ConfigName, "EuphoriaAntiSpamTime", 3f); + NormalEuphoriaInRandomize = settings.GetValue(ConfigName, "NormalEuphoriaInRandomize", true); + StiffFallEuphoriaInRandomize = settings.GetValue(ConfigName, "StiffFallEuphoriaInRandomize", true); + NarrowStumbleEuphoriaInRandomize = settings.GetValue(ConfigName, "NarrowStumbleEuphoriaInRandomize", true); + WideStumbleEuphoriaInRandomize = settings.GetValue(ConfigName, "WideStumbleEuphoriaInRandomize", true); + EuphoriaFromWeaponDamage = settings.GetValue(ConfigName, "EuphoriaFromWeaponDamage", true); if (EuphoriaMaximumChance < EuphoriaMinimumChance) { @@ -40,5 +45,10 @@ public EuphoriaConfig(ScriptSettings settings) public readonly int EuphoriaMinimumChance; public readonly int EuphoriaMaximumChance; public readonly float EuphoriaAntiSpamTime; + public readonly bool NormalEuphoriaInRandomize; + public readonly bool StiffFallEuphoriaInRandomize; + public readonly bool NarrowStumbleEuphoriaInRandomize; + public readonly bool WideStumbleEuphoriaInRandomize; + public readonly bool EuphoriaFromWeaponDamage; } } diff --git a/Euphorically/Euphorically.ini b/Euphorically/Euphorically.ini index a9bc8ab..d391a57 100644 --- a/Euphorically/Euphorically.ini +++ b/Euphorically/Euphorically.ini @@ -6,6 +6,11 @@ //WideStumble - 3 //Use the name or number from above for EuphoriaType +//Mod Toggle Config +EuphoriaFromWeaponDamage = true //Will Euphoria take over if damaged by weapon. +EuphoriaFromMeleeDamage = true //Will Euphoria take over if damaged by melee. + +//Base Euphoria Config RandomizeEuphoriaTypes = true //This will randomize the euphoria type used EuphoriaType = Normal //if RandomizeEuphoriaTypes is false, this value will be used instead @@ -17,8 +22,15 @@ RandomizeEuphoriaChance = true //Randomizes the chance the Player is put into Eu EuphoriaMinimumChance = 10 //Minimum chance the Player is put into Euphoria EuphoriaMaximumChance = 20 //Maximum chance the Player is put into Euphoria -EuphoriaFromMeleeDamage = true //Will Euphoria take over if damaged by melee. EuphoriaAntiSpamTime = 3.0 //Time in seconds before the Player can be put into Euphoria after the last one completes. +//Randomization Config +NormalEuphoriaInRandomize = true //Is Normal Euphoria allowed to be randomized +StiffFallEuphoriaInRandomize = true //Is Stiff Fall Euphoria allowed to be randomized +NarrowStumbleEuphoriaInRandomize = true //Is Narrow Stumble Euphoria allowed to be randomized +WideStumbleEuphoriaInRandomize = true //Is Wide Stumble Euphoria allowed to be randomized +//IF ALL ARE FALSE, EuphoriaType WILL TAKE OVER +//IF YOU WISH TO DISABLE THE MOD PLEASE DISABLE EuphoriaFromMeleeDamage AND EuphoriaFromWeaponDamage + [DebugConfig] ShowDebugNotifications = false //Shows debugging notifications - highly recommended false \ No newline at end of file diff --git a/Euphorically/Main.cs b/Euphorically/Main.cs index 9542ca0..6ca8b12 100644 --- a/Euphorically/Main.cs +++ b/Euphorically/Main.cs @@ -37,6 +37,7 @@ private void OnTick(object sender, EventArgs e) _timer = 0; } + Function.Call(Hash.CLEAR_ENTITY_LAST_WEAPON_DAMAGE, Game.Player.Character); return; } @@ -46,6 +47,16 @@ private void OnTick(object sender, EventArgs e) Function.Call(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_WEAPON, Game.Player.Character, 0, 1)) { ThrowNotification("Caught Melee Damage?"); + Function.Call(Hash.CLEAR_ENTITY_LAST_WEAPON_DAMAGE, Game.Player.Character); + return; + } + + if (!_euphoriaConfig.EuphoriaFromWeaponDamage && + (Function.Call(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_WEAPON, Game.Player.Character, 0, 2) && + !Function.Call(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_WEAPON, Game.Player.Character, 0, 1))) + { + ThrowNotification("Caught Weapon Damage?"); + Function.Call(Hash.CLEAR_ENTITY_LAST_WEAPON_DAMAGE, Game.Player.Character); return; } @@ -55,9 +66,51 @@ private void OnTick(object sender, EventArgs e) ThrowNotification("Euphoria Time: " + euphoriaTime + "ms"); - EuphoriaType euphoriaType = _euphoriaConfig.RandomizeEuphoriaTypes - ? (EuphoriaType) _rng.Next(0, 4) - : _euphoriaConfig.EuphoriaType; + EuphoriaType euphoriaType = _euphoriaConfig.EuphoriaType; + + if ((_euphoriaConfig.NormalEuphoriaInRandomize || _euphoriaConfig.StiffFallEuphoriaInRandomize || + _euphoriaConfig.NarrowStumbleEuphoriaInRandomize || + _euphoriaConfig.WideStumbleEuphoriaInRandomize) && _euphoriaConfig.RandomizeEuphoriaTypes) + { + bool foundValidEuphoriaType = false; + while (!foundValidEuphoriaType) + { + EuphoriaType type = (EuphoriaType) _rng.Next(0, 4); + switch (type) + { + case EuphoriaType.Normal: + if (_euphoriaConfig.NormalEuphoriaInRandomize) + { + foundValidEuphoriaType = true; + euphoriaType = type; + } + break; + case EuphoriaType.StiffFall: + if (_euphoriaConfig.StiffFallEuphoriaInRandomize) + { + foundValidEuphoriaType = true; + euphoriaType = type; + } + break; + case EuphoriaType.NarrowStumble: + if (_euphoriaConfig.NarrowStumbleEuphoriaInRandomize) + { + foundValidEuphoriaType = true; + euphoriaType = type; + } + break; + case EuphoriaType.WideStumble: + if (_euphoriaConfig.WideStumbleEuphoriaInRandomize) + { + foundValidEuphoriaType = true; + euphoriaType = type; + } + break; + default: + break; + } + } + } ThrowNotification("Euphoria Type: " + euphoriaType); @@ -81,6 +134,8 @@ private void OnTick(object sender, EventArgs e) private static void RagdollWrapper(Ped ped, int timeInMilliseconds, EuphoriaType euphoriaType) { + Function.Call(Hash.SET_PED_CAN_RAGDOLL, ped, true); + Function.Call(Hash.SET_PED_TO_RAGDOLL, ped, timeInMilliseconds, timeInMilliseconds, (int) euphoriaType, false, false, false); } From be423cee01847c268d061c17751f0f5c2558f293 Mon Sep 17 00:00:00 2001 From: Jack Wright <68773585+Ethirix@users.noreply.github.com> Date: Mon, 17 Apr 2023 20:55:50 +0100 Subject: [PATCH 2/2] Minor Bug Fix Changes a `break` to a `return` in case of wrong or malformed `EuphoriaType` --- Euphorically/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Euphorically/Main.cs b/Euphorically/Main.cs index 6ca8b12..94ede59 100644 --- a/Euphorically/Main.cs +++ b/Euphorically/Main.cs @@ -107,7 +107,7 @@ private void OnTick(object sender, EventArgs e) } break; default: - break; + return; } } }