Skip to content

Commit

Permalink
✨ add basic gameplay for survival system
Browse files Browse the repository at this point in the history
  • Loading branch information
Roms1383 committed Oct 28, 2024
1 parent 4cb8449 commit 0725cc0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
24 changes: 20 additions & 4 deletions scripts/Addicted/System.reds
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Addicted.Helpers.*
import Addicted.Manager.*
import Addicted.Crossover.AlterNeuroBlockerStatusEffects
import Addicted.Crossover.AlterBlackLaceStatusEffects
import Addicted.Crossover.StressPreventWeanOff
import Addicted.Crossover.ConditionModifier

public class CheckWarnCallback extends DelayCallback {
public let system: wref<AddictedSystem>;
Expand Down Expand Up @@ -345,20 +347,34 @@ public class AddictedSystem extends ScriptableSystem {
for id in ids {
consumption = this.consumptions.Get(id) as Consumption;
let under_influence = false;
let stressed = StressPreventWeanOff(this.GetGameInstance());
if this.IsHard() {
under_influence = this.SleptUnderInfluence(id) && !this.hasDetoxifierEquipped;
if under_influence
{
E(s"slept under influence, no weaning off for \(TDBID.ToStringDEBUG(ItemID.GetTDBID(id)))");
}
if stressed {
E(s"poor overall condition, no weaning off for \(TDBID.ToStringDEBUG(ItemID.GetTDBID(id)))");
}
}
if !under_influence {
if !under_influence && !stressed {
if consumption.current > 0 {
let current = consumption.current;
let daysSinceLastUsed = this.DaysSinceLastConsumption(Generic.Consumable(id));
let next = Max(current - Helper.Resilience(id, daysSinceLastUsed) - this.player.CyberwareImmunity(), 0);
consumption.current = next;
E(s"slept well, weaning off \(ToString(current)) -> \(ToString(next)) for \(TDBID.ToStringDEBUG(ItemID.GetTDBID(id)))");
let resilience = Helper.Resilience(id, daysSinceLastUsed);
let immunity = this.player.CyberwareImmunity();
let condition = ConditionModifier(this.GetGameInstance());
let weanoff = Max(resilience + immunity + condition, 0);
if weanoff == 0 {
let next = Max(current - weanoff, 0);
consumption.current = next;
E(s"didn't sleep well because of overall condition, no weaning off for for \(TDBID.ToStringDEBUG(ItemID.GetTDBID(id))) (modifier: \(ToString(condition)))");
} else {
let next = Max(current - weanoff, 0);
consumption.current = next;
E(s"slept well, weaning off \(ToString(current)) -> \(ToString(next)) for \(TDBID.ToStringDEBUG(ItemID.GetTDBID(id))) (modifier: \(ToString(condition)))");
}
} else {
this.consumptions.Remove(id);
E(s"clean again from \(TDBID.ToStringDEBUG(ItemID.GetTDBID(id)))");
Expand Down
25 changes: 25 additions & 0 deletions scripts/Addicted/crossover/SurvivalSystem.reds
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Addicted.Crossover

@if(ModuleExists("SurvivalSystemModule"))
import SurvivalSystemModule.SurvivalSystem

@if(!ModuleExists("SurvivalSystemModule"))
public func StressPreventWeanOff(game: GameInstance) -> Bool = false;

@if(ModuleExists("SurvivalSystemModule"))
public func StressPreventWeanOff(game: GameInstance) -> Bool = SurvivalSystem.GetInstance(game).GetStressCurrent() > 60.;

@if(!ModuleExists("SurvivalSystemModule"))
public func ConditionModifier(game: GameInstance) -> Int32 = 0;

@if(ModuleExists("SurvivalSystemModule"))
public func ConditionModifier(game: GameInstance) -> Int32 {
let condition = SurvivalSystem.GetInstance(game).GetCurrentCondition();
return condition >= 0.85
? 1
: condition < 0.4
? -1
: condition < 0.25
? -2
: 0;
}

0 comments on commit 0725cc0

Please sign in to comment.