Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional healers gameplay #94

Merged
merged 7 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
**/.DS_Store

/book/site
!scripts/
scripts/*
!scripts/Addicted
/archives/**/*.cpmodproj
/archives/**/*.zip
/archives/**/layout.xml
Expand Down
50 changes: 50 additions & 0 deletions scripts/Addicted/Attunement.reds
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module Addicted

import Addicted.System.AddictedSystem
import Addicted.Helpers.Generic

@wrapMethod(ConsumableTransitions)
protected final func ChangeConsumableAnimFeature(stateContext: ref<StateContext>, scriptInterface: ref<StateGameScriptInterface>, newState: Bool) -> Void {
let item: ItemID;
let id: TweakDBID;
let addictive: Bool;
let consumable: Consumable;
let threshold: Threshold;
let player: ref<PlayerPuppet>;
let system: ref<AddictedSystem>;
wrappedMethod(stateContext, scriptInterface, newState);
item = this.GetItemIDFromWrapperPermanentParameter(stateContext, n"consumable");
id = ItemID.GetTDBID(item);
addictive = Generic.IsAddictive(id);
if addictive {
player = scriptInterface.GetPlayerSystem().GetLocalPlayerMainGameObject() as PlayerPuppet;
system = AddictedSystem.GetInstance(player.GetGame());
consumable = Generic.Consumable(id);
threshold = system.Threshold(consumable);
if EnumInt(threshold) >= EnumInt(Threshold.Severely) {
let itemType: gamedataItemType = TweakDBInterface.GetItemRecord(id).ItemType().Type();
let inCombat: Bool = (scriptInterface.GetPlayerSystem().GetLocalPlayerMainGameObject() as PlayerPuppet).IsInCombat();
let isPerkFasterHealingUnlocked: Bool = PlayerDevelopmentSystem.GetData(scriptInterface.executionOwner).IsNewPerkBought(gamedataNewPerkType.Tech_Left_Perk_2_3) > 0;
let consumableAnimFeature: ref<AnimFeature_ConsumableAnimation> = new AnimFeature_ConsumableAnimation();
consumableAnimFeature.useConsumable = false;
switch itemType {
case gamedataItemType.Con_Injector:
consumableAnimFeature.consumableType = 0;
if inCombat && isPerkFasterHealingUnlocked {
consumableAnimFeature.animationScale = 1.65 + 0.15;
} else {
consumableAnimFeature.animationScale = 1.15 + 0.3;
};
break;
case gamedataItemType.Con_Inhaler:
consumableAnimFeature.consumableType = 1;
if inCombat && isPerkFasterHealingUnlocked {
consumableAnimFeature.animationScale = 1.50 + 0.1;
} else {
consumableAnimFeature.animationScale = 1.15 + 0.2;
};
};
scriptInterface.SetAnimationParameterFeature(n"ConsumableFeature", consumableAnimFeature, scriptInterface.executionOwner);
}
}
}
16 changes: 15 additions & 1 deletion scripts/Addicted/Definitions.reds
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,18 @@ public class Consumptions {
}
return highest;
}
public func HighestThreshold(addiction: Addiction) -> Threshold {
let consumables = Helper.Consumables(addiction);
let highest: Threshold = Threshold.Clean;
let current: Threshold;
for consumable in consumables {
current = this.Threshold(consumable);
if EnumInt(current) > EnumInt(highest) {
highest = current;
}
}
return highest;
}
/// total consumption for a given consumable
/// each consumable can have one or many versions (e.g maxdoc and bounceback have 3+ versions each)
public func TotalConsumption(consumable: Consumable) -> Int32 {
Expand Down Expand Up @@ -384,14 +396,16 @@ enum Addiction {
Anabolics = 1,
Neuros = 2,
BlackLace = 3,
Alcohol = 4,
}

public static func Addictions() -> array<Addiction> {
return [
Addiction.Healers,
Addiction.Anabolics,
Addiction.Neuros,
Addiction.BlackLace
Addiction.BlackLace,
Addiction.Alcohol
];
}

Expand Down
2 changes: 2 additions & 0 deletions scripts/Addicted/Helper.reds
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class Helper {
return [Consumable.MemoryBooster, Consumable.NeuroBlocker];
case Addiction.BlackLace:
return [Consumable.BlackLace];
case Addiction.Alcohol:
return [Consumable.Alcohol];
default:
break;
}
Expand Down
18 changes: 17 additions & 1 deletion scripts/Addicted/System.reds
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AddictedSystem extends ScriptableSystem {
private persistent let warnings: Uint32 = 0u;

private let updateSymtomsID: DelayID;

private let healingRechargeDurationModifier: ref<gameStatModifierData>;

private final func OnPlayerAttach(request: ref<PlayerAttachRequest>) -> Void {
let player: ref<PlayerPuppet> = GetPlayer(this.GetGameInstance());
Expand Down Expand Up @@ -189,11 +189,27 @@ public class AddictedSystem extends ScriptableSystem {
this.Hint(id);
}
if NotEquals(EnumInt(before), EnumInt(after)) {
if Generic.IsHealer(id) { this.UpdateHealingChargeDuration(this.player); }
this.Warn(before, after);
}
}
}

// HealingItemsRecharge - HealingItemsRechargeDuration (on consumption)
private func UpdateHealingChargeDuration(player: ref<PlayerPuppet>) -> Void {
let system = AddictedSystem.GetInstance(player.GetGame());
let threshold = system.Threshold(Addiction.Healers);
let serious = Helper.IsSerious(threshold);
let stats: ref<StatsSystem> = GameInstance.GetStatsSystem(player.GetGame());
if serious && !IsDefined(this.healingRechargeDurationModifier) {
this.healingRechargeDurationModifier = RPGManager.CreateStatModifier(gamedataStatType.HealingItemsRechargeDuration, gameStatModifierType.Multiplier, 0.8);
stats.AddModifier(Cast<StatsObjectID>(player.GetEntityID()), this.healingRechargeDurationModifier);
} else if !serious && IsDefined(this.healingRechargeDurationModifier) {
stats.RemoveModifier(Cast<StatsObjectID>(player.GetEntityID()), this.healingRechargeDurationModifier);
this.healingRechargeDurationModifier = null;
}
}

public func OnDissipated(id: TweakDBID) -> Void {
this.Hint(id);
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/Addicted/helpers/Generic.reds
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class Generic {
return Addiction.Neuros;
case Consumable.BlackLace:
return Addiction.BlackLace;
case Consumable.Alcohol:
return Addiction.Alcohol;
default:
break;
}
Expand Down
22 changes: 22 additions & 0 deletions scripts/Addicted/managers/AudioManager.reds
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ public class AudioManager extends IScriptable {

private let callbackID: DelayID;

private let audioStimMultiplier: ref<gameStatModifierData>;
private let audioStimMultiplierActive: Bool = false;

public func Register(player: ref<PlayerPuppet>) -> Void {
E(s"register audio manager");
this.audioStimMultiplier = RPGManager.CreateStatModifier(gamedataStatType.AudioStimRangeMultiplier, gameStatModifierType.Additive, 0.2);
let board: ref<IBlackboard>;
if player != null {
this.owner = player;
Expand Down Expand Up @@ -168,6 +172,10 @@ public class AudioManager extends IScriptable {
}

public func Play(tracked: ref<TrackedHint>) -> Void {
let ongoing = !tracked.got.IsLoop();
if ongoing && !this.audioStimMultiplierActive {
this.ToggleAudioStims(true);
}
let policy = this.ToPolicy();
E(s"-----------------------------------------------");
E(s"play");
Expand All @@ -189,6 +197,10 @@ public class AudioManager extends IScriptable {
public func Stop(sound: CName) -> Void {
GameInstance.GetAudioSystem(this.owner.GetGame())
.Stop(sound, this.owner.GetEntityID(), n"Addicted");
let finished = ArraySize(this.oneshot) == 0;
if finished && this.audioStimMultiplierActive {
this.ToggleAudioStims(false);
}
}

public func StopAll() -> Void {
Expand Down Expand Up @@ -403,4 +415,14 @@ public class AudioManager extends IScriptable {
this.InvalidateState();
}
}

private func ToggleAudioStims(active: Bool) -> Void {
let stats: ref<StatsSystem> = GameInstance.GetStatsSystem(this.owner.GetGame());
if active {
stats.AddModifier(Cast<StatsObjectID>(this.owner.GetEntityID()), this.audioStimMultiplier);
} else {
stats.RemoveModifier(Cast<StatsObjectID>(this.owner.GetEntityID()), this.audioStimMultiplier);
}
this.audioStimMultiplierActive = active;
}
}
6 changes: 3 additions & 3 deletions tweaks/Addicted/healers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ BaseStatusEffect.$(threshold)WeakenedHealthBooster:
$instances:
- { threshold: Notably, modifier: 1.07, modifiers: 7 }
- { threshold: Severely, modifier: 1.03, modifiers: 3 }
$base: BaseStatusEffect.$(prefix)HealthBooster
$base: BaseStatusEffect.HealthBooster
packages:
- $base: BaseStatusEffect.HealthBooster_inline0
stats:
Expand All @@ -109,7 +109,7 @@ BaseStatusEffect.$(threshold)WeakenedBlackmarket_HealthBooster:
$instances:
- { threshold: Notably, modifier: 1.15, modifiers: 15, malus: -0.6, maluses: 60 }
- { threshold: Severely, modifier: 1.1, modifiers: 10, malus: -0.7, maluses: 70 }
$base: BaseStatusEffect.$(prefix)HealthBooster
$base: BaseStatusEffect.Blackmarket_HealthBooster
packages:
- $base: BaseStatusEffect.Blackmarket_HealthBooster_inline0
stats:
Expand All @@ -122,7 +122,7 @@ BaseStatusEffect.$(threshold)WeakenedBlackmarket_HealthBooster:
statType: BaseStats.StaminaRegenRateMult
value: $(malus)
uiData:
$base: BaseStatusEffect.$(prefix)HealthBooster_inline$(inline)
$base: BaseStatusEffect.Blackmarket_HealthBooster_inline3
iconPath: $(threshold)WeakenedHealthBooster
intValues: [ $(modifiers), $(maluses) ]

Expand Down