Skip to content

Commit

Permalink
Merge pull request #124 from Phoenica/main
Browse files Browse the repository at this point in the history
Updated consumable potency / resilience values.
  • Loading branch information
Roms1383 authored Apr 24, 2024
2 parents 5c3765f + eb7a1ba commit 6aca4a2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 30 deletions.
44 changes: 23 additions & 21 deletions scripts/Addicted/Helper.reds
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,34 @@ public func IsLanguageSupported(locale: CName) -> Bool {
}

public class Helper {
public static func Category(id: ItemID) -> Category {
if Generic.IsBlackLace(ItemID.GetTDBID(id))
|| Generic.IsAlcohol(ItemID.GetTDBID(id)) { return Category.Hard; }
return Category.Mild;
}
public static func Potency(id: ItemID, subsequentUse: Bool) -> Int32 {
let consumableName = Generic.Consumable(id);
public static func Potency(id: ItemID) -> Int32 {
let category = Helper.Category(id);
switch(category) {
case Category.Hard:
return 2;
default:
break;
switch(consumableName) {
case Consumable.Alcohol:
case Consumable.Tobacco:
return subsequentUse ? 1 : 4;
case Consumable.BlackLace:
return subsequentUse ? 2 : 8;
case Consumable.HealthBooster:
case Consumable.StaminaBooster:
case Consumable.OxyBooster:
case Consumable.MemoryBooster:
return subsequentUse ? 4 : 6;
}
return 1;
return subsequentUse ? 1 : 2;
}
public static func Resilience(id: ItemID) -> Int32 {
let category = Helper.Category(id);
switch(category) {
case Category.Hard:
return 1;
default:
break;
public static func Resilience(id: ItemID, daysSinceLastConsumed: Int32) -> Int32 {
let consumableName = Generic.Consumable(id);
let resilienceModifier = Min(5, Max(1, daysSinceLastConsumed - 1));
switch(consumableName) {
case Consumable.BlackLace:
case Consumable.Alcohol:
return resilienceModifier * 1;
}
return 2;
return resilienceModifier * 2;
}
public static func Threshold(score: Int32) -> Threshold {
Expand Down
32 changes: 23 additions & 9 deletions scripts/Addicted/System.reds
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,24 @@ public class AddictedSystem extends ScriptableSystem {
return;
}
let before: Threshold;
let after: Threshold;
let amount: Int32;
let hint: Bool;
if Generic.IsAddictive(id) {
let after: Threshold;
let daysPast: Int32;
if Generic.IsAddictive(id) {
let usedToday = this.DaysSinceLastConsumption(Generic.Consumable(id)) == 0;
if this.consumptions.KeyExist(itemID) {
let consumption: ref<Consumption> = this.consumptions.Get(itemID);
before = Helper.Threshold(consumption.current);
amount = Min(consumption.current + Helper.Potency(itemID), 100);
after = Helper.Threshold(amount);
hint = this.Consume(itemID, amount);
amount = Min(consumption.current + Helper.Potency(itemID, usedToday), 100);
} else {
before = Threshold.Clean;
amount = Helper.Potency(itemID);
after = Helper.Threshold(amount);
hint = this.Consume(itemID, amount);
amount = Helper.Potency(itemID, usedToday);
}
after = Helper.Threshold(amount);
hint = this.Consume(itemID, amount);
let consumable: Consumable = Generic.Consumable(id);
if NotEquals(EnumInt(consumable), EnumInt(Consumable.Invalid)) {
let blackboard: ref<IBlackboard> = this.player.GetPlayerStateMachineBlackboard();
Expand Down Expand Up @@ -290,7 +291,8 @@ public class AddictedSystem extends ScriptableSystem {
if !under_influence {
if consumption.current > 0 {
let current = consumption.current;
let next = Max(current - Helper.Resilience(id) - this.player.CyberwareImmunity(), 0);
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)))");
} else {
Expand Down Expand Up @@ -479,6 +481,18 @@ public class AddictedSystem extends ScriptableSystem {
return difference < maximum;
}
private func DaysSinceLastConsumption(consumable: Consumable) -> Int32 {
let last: Float = this.consumptions.LastDose(consumable);
let tms = this.timeSystem.GetGameTimeStamp();
let now = Helper.MakeGameTime(tms);
let today = GameTime.Days(now);
let previous = Helper.MakeGameTime(last);
let previousDay = GameTime.Days(previous);
return today-previousDay;
}
/// if hasn't consumed for a day or more
private func OverOneDay(last: Float) -> Bool {
let tms = this.timeSystem.GetGameTimeStamp();
Expand Down
4 changes: 4 additions & 0 deletions scripts/Addicted/helpers/Generic.reds
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Addicted.*

// effects or items agnostic
public class Generic {
public static func Consumable(id: ItemID) -> Consumable {
let tweakId: TweakDBID = ItemID.GetTDBID(id);
return Generic.Consumable(tweakId);
}
public static func Consumable(id: TweakDBID) -> Consumable {
if Generic.IsAlcohol(id) { return Consumable.Alcohol; }
Expand Down

0 comments on commit 6aca4a2

Please sign in to comment.