Skip to content

Commit

Permalink
Merge pull request #1 from Ethirix/Features/DisableableSettings
Browse files Browse the repository at this point in the history
Completed Disableable Settings
  • Loading branch information
Ethirix authored Apr 17, 2023
2 parents f996ed4 + be423ce commit 3bb1701
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Euphorically/Config/EuphoriaConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}
}
14 changes: 13 additions & 1 deletion Euphorically/Euphorically.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
61 changes: 58 additions & 3 deletions Euphorically/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -46,6 +47,16 @@ private void OnTick(object sender, EventArgs e)
Function.Call<bool>(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<bool>(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_WEAPON, Game.Player.Character, 0, 2) &&
!Function.Call<bool>(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;
}

Expand All @@ -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:
return;
}
}
}

ThrowNotification("Euphoria Type: " + euphoriaType);

Expand All @@ -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);
}
Expand Down

0 comments on commit 3bb1701

Please sign in to comment.