# For Mod Authors

## <mark style="color:yellow;">Lifecycle Events</mark>

Dark Future exposes the following lifecycle event hooks that you can listen for using Codeware's [custom events](https://github.com/psiberx/cp2077-codeware/wiki#custom-events).

<table data-full-width="true"><thead><tr><th width="184">Lifecycle Hook</th><th width="440">Event Name</th><th>Description</th></tr></thead><tbody><tr><td>Init</td><td><code>DarkFuture.Main.MainSystemLifecycleInitEvent</code></td><td>Event that fires when Dark Future begins starting up all subsystems (either initially or when the game is loaded). Occurs before any of Dark Future's systems are initialized.</td></tr><tr><td>InitDone</td><td><code>DarkFuture.Main.MainSystemLifecycleInitDoneEvent</code></td><td>Event that fires when Dark Future is finished starting all subsystems (either initially or when the game is loaded).</td></tr><tr><td>Resume</td><td><code>DarkFuture.Main.MainSystemLifecycleResumeEvent</code></td><td>Event that fires when Dark Future begins resuming all subsystems. Occurs if the user toggled "Enable Dark Future" to On after having turned it Off.</td></tr><tr><td>ResumeDone</td><td><code>DarkFuture.Main.MainSystemLifecycleResumeDoneEvent</code></td><td>Event that fires when Dark Future is finished resuming all subsystems.</td></tr><tr><td>Suspend</td><td><code>DarkFuture.Main.MainSystemLifecycleSuspendEvent</code></td><td>Event that fires when Dark Future begins suspending all subsystems. Occurs if the user toggled "Enable Dark Future" to Off.</td></tr><tr><td>SuspendDone</td><td><code>DarkFuture.Main.MainSystemLifecycleSuspendDoneEvent</code></td><td>Event that fires when Dark Future is done suspending all subsystems.</td></tr></tbody></table>

Here's an example of how these lifecycle hooks might be used:

{% code fullWidth="true" %}

```swift
import DarkFuture.Main.{
  MainSystemLifecycleInitEvent,
  MainSystemLifecycleInitDoneEvent,
  MainSystemLifecycleResumeEvent,
  MainSystemLifecycleResumeDoneEvent,
  MainSystemLifecycleSuspendEvent,
  MainSystemLifecycleSuspendDoneEvent
}

public class MyEventListener extends ScriptableService {
  private cb func OnLoad() {
    GameInstance.GetCallbackSystem().RegisterCallback(n"DarkFuture.Main.MainSystemLifecycleInitEvent", this, n"OnMainSystemLifecycleInitEvent", true);
    GameInstance.GetCallbackSystem().RegisterCallback(n"DarkFuture.Main.MainSystemLifecycleInitDoneEvent", this, n"OnMainSystemLifecycleInitDoneEvent", true);
    GameInstance.GetCallbackSystem().RegisterCallback(n"DarkFuture.Main.MainSystemLifecycleResumeEvent", this, n"OnMainSystemLifecycleResumeEvent", true);
    GameInstance.GetCallbackSystem().RegisterCallback(n"DarkFuture.Main.MainSystemLifecycleResumeDoneEvent", this, n"OnMainSystemLifecycleResumeDoneEvent", true);
    GameInstance.GetCallbackSystem().RegisterCallback(n"DarkFuture.Main.MainSystemLifecycleSuspendEvent", this, n"OnMainSystemLifecycleSuspendEvent", true);
    GameInstance.GetCallbackSystem().RegisterCallback(n"DarkFuture.Main.MainSystemLifecycleSuspendDoneEvent", this, n"OnMainSystemLifecycleSuspendDoneEvent", true);
  }
    
  private cb func OnMainSystemLifecycleInitEvent(event: ref<MainSystemLifecycleInitEvent>) {
      // Started initializing subsystems!
  }
    
  private cb func OnMainSystemLifecycleInitDoneEvent(event: ref<MainSystemLifecycleInitDoneEvent>) {
      // Finished initializing subsystems!
  }
    
  private cb func OnMainSystemLifecycleResumeEvent(event: ref<MainSystemLifecycleResumeEvent>) {
      // Started resuming subsystems after a shutdown!
  }
    
  private cb func OnMainSystemLifecycleResumeDoneEvent(event: ref<MainSystemLifecycleResumeDoneEvent>) {
      // Finished resuming subsystems after a shutdown!
  }
    
  private cb func OnMainSystemLifecycleSuspendEvent(event: ref<MainSystemLifecycleSuspendEvent>) {
      // Started suspending subsystems!
  }
    
  private cb func OnMainSystemLifecycleSuspendDoneEvent(event: ref<MainSystemLifecycleSuspendDoneEvent>) {
      // Finished suspending subsystems!
  }
}
```

{% endcode %}

## <mark style="color:yellow;">Basic Need Value Change Event</mark>

There is an event that fires whenever a Basic Need (Nerve, Hydration, Nutrition, Energy) changes its value that you can listen for using Codeware's [custom events](https://github.com/psiberx/cp2077-codeware/wiki#custom-events).

<table data-full-width="true"><thead><tr><th width="219">Event</th><th width="440">Event Name</th><th>Description</th></tr></thead><tbody><tr><td>Need Value Change</td><td><code>DarkFuture.Needs.NeedValueChangedEvent</code></td><td>Fires when any Basic Need changes its value.</td></tr></tbody></table>

Here's an example of usage.

{% code fullWidth="true" %}

```swift
import DarkFuture.Needs.{
  DFNeedType,
  DFNeedValueChangedEventDatum,
  NeedValueChangedEvent
}

/*
public enum DFNeedType {
  None = 0,
  Hydration = 1,
  Nutrition = 2,
  Energy = 3,
  Nerve = 4
}

public struct DFNeedValueChangedEventDatum {
  public let needType: DFNeedType;
  public let newValue: Float;
}
*/

public class MyEventListener extends ScriptableService {
  private cb func OnLoad() {
    GameInstance.GetCallbackSystem().RegisterCallback(n"DarkFuture.Needs.NeedValueChangedEvent", this, n"OnNeedValueChangedEvent", true);
  }
    
  private cb func OnNeedValueChangedEvent(event: ref<NeedValueChangedEvent>) {
      let data: DFNeedValueChangedEventDatum = event.GetData();
      
      let needType: DFNeedType = data.needType; // Was this an update for Nerve, Hydration, Nutrition, or Energy?
      let newValue: Float = data.newValue; // What was the new value for the need?
  }
}
```

{% endcode %}

## <mark style="color:yellow;">Consumables</mark>

Below is a quick list of all TweakDBIDs for new Consumables added by Dark Future, and their gameplay purpose, as well as consumables in the game that have had their functionality significantly changed.

In Dark Future, <mark style="color:yellow;">Narcotics</mark> and <mark style="color:yellow;">Cigarettes</mark> are new classifications of consumables similar to Food, Drinks, and Alcohol. Because they have distinct gameplay purposes and feed unique Addictions, they should be handled as their own types of consumables.

Other types of consumables that have more generalized gameplay uses are noted as "beneficial", below.

<table data-full-width="true"><thead><tr><th width="253">Item Name</th><th>TweakDBID</th><th>Notes</th></tr></thead><tbody><tr><td>Vargas Black Label</td><td>DarkFutureItem.CigarettePackC</td><td>Cigarette.</td></tr><tr><td>Yeheyuan Filters</td><td>Items.GenericJunkItem23</td><td>Cigarette. (This item exists in the base game as a Junk Item; it was converted into a consumable.)</td></tr><tr><td>Morley Fusion</td><td>Items.GenericJunkItem24</td><td>Cigarette. (This item exists in the base game as a Junk Item; it was converted into a consumable.)</td></tr><tr><td>Mr. Whitey</td><td>Items.LowQualityFood6</td><td>Narcotic (no longer Food). Combat use allowed.</td></tr><tr><td>Mr. Whitey Mint</td><td>Items.MediumQualityFood11</td><td>Narcotic (no longer Food). Combat use allowed.</td></tr><tr><td>Mr. Whitey Crystal</td><td>Items.MediumQualityFood14</td><td>Narcotic (no longer Food). Combat use allowed.</td></tr><tr><td>Mr. Whitey Spiced</td><td>Items.MediumQualityFood15</td><td>Narcotic (no longer Food). Combat use allowed.</td></tr><tr><td>Black Lace Mk. 1</td><td>Items.BlackLaceV0</td><td>Narcotic. Combat use allowed.</td></tr><tr><td>Black Lace Mk. 2</td><td>Items.BlackLaceV1</td><td>Narcotic. Combat use allowed.</td></tr><tr><td>Emergency Cardioregulator</td><td>DarkFutureItem.NerveRestoreDrug</td><td>Narcotic. Combat use allowed.</td></tr><tr><td>Glitter</td><td>DarkFutureItem.Glitter</td><td>Narcotic. Combat use allowed.</td></tr><tr><td>Addiquit</td><td>DarkFutureItem.AddictionTreatmentDrug</td><td>Beneficial consumable. Helps cure Addictions.</td></tr><tr><td>Endotrisine</td><td>DarkFutureItem.EndotrisineDrug</td><td>Beneficial consumable. Cures Humanity Loss.</td></tr><tr><td>Immunosuppressant</td><td>DarkFutureItem.ImmunosuppressantDrug</td><td>Beneficial consumable. Cures Cyberpsychosis. Suppresses the Humanity Loss rate increase from cyberware.</td></tr></tbody></table>

Certain <mark style="color:yellow;">Food</mark> and <mark style="color:yellow;">Drinks</mark> that come from vending machines have both positive and (minor) negative gameplay effects, in order to encourage players to seek out higher-quality food at Food Vendors. The list of these "low quality" food and drink items that can negatively impact the player in Dark Future are listed below.

| Item Name                  | TweakDBID                 |
| -------------------------- | ------------------------- |
| ChroManticore Lime         | Items.GoodQualityDrink2   |
| ChroManticore Carnival     | Items.GoodQualityDrink4   |
| Spunky Monkey              | Items.LowQualityDrink4    |
| Spunky Monkey Mint         | Items.LowQualityDrink5    |
| Cirrus Cola Classic        | Items.LowQualityDrink6    |
| Cirrus Cola Corn and Lemon | Items.LowQualityDrink7    |
| Cirrus Cola Blood Breeze   | Items.LowQualityDrink8    |
| NiCola Blue                | Items.LowQualityDrink9    |
| NiCola                     | Items.LowQualityDrink10   |
| NiCola Fire                | Items.MediumQualityDrink1 |
| NiCola Sakura              | Items.MediumQualityDrink2 |
| Naranjita Classic          | Items.MediumQualityDrink5 |
| Naranjita Zero             | Items.MediumQualityDrink6 |
| ChroManticore              | Items.MediumQualityDrink7 |
| Moonchies                  | Items.LowQualityFood5     |
| Orgiantic Omniflave        | Items.LowQualityFood7     |
| Pop-Turd                   | Items.LowQualityFood8     |
| Sojasil Dynamite           | Items.LowQualityFood9     |
| Cat Food                   | Items.LowQualityFood11    |
| Holobites Grape Pie        | Items.LowQualityFood12    |
| Holobites Mint Pie         | Items.LowQualityFood13    |
| Holobites Peach Pie        | Items.LowQualityFood14    |
| Orgiantic Salsa Agave      | Items.LowQualityFood15    |
| Orgiantic Vinegar Chili    | Items.LowQualityFood16    |
| Moonchies Andromeda        | Items.LowQualityFood17    |
| Moonchies Pulsar           | Items.LowQualityFood18    |
| Moonchies Sour Planet      | Items.LowQualityFood19    |
| Leelou Beans Lagoon        | Items.LowQualityFood20    |
| Leelou Beans Meyer Lemon   | Items.LowQualityFood21    |
| Leelou Beans Plantain      | Items.LowQualityFood22    |
| Leelou Beans Tropical      | Items.LowQualityFood23    |
| Sojasil Eruption           | Items.LowQualityFood24    |
| Sojasil Molotov Cocktail   | Items.LowQualityFood25    |
| Sojasil Nitroglycerin      | Items.LowQualityFood26    |
| Sojasil Radioactive        | Items.LowQualityFood27    |
| Sojasil Second Impact      | Items.LowQualityFood28    |
| Slaughterhouse Jerky       | Items.MediumQualityFood3  |
| Burrito XXL                | Items.MediumQualityFood4  |
| Slaughterhouse Prime       | Items.MediumQualityFood7  |
| Burrito XXL Rosado         | Items.MediumQualityFood12 |
| Burrito XXL Turquesa       | Items.MediumQualityFood13 |
| Shwabshwab Grape           | Items.MediumQualityFood17 |
| Shwabshwab Ketchup         | Items.MediumQualityFood18 |
| Shwabshwab Bue             | Items.MediumQualityFood19 |
| Slaughterhouse Veggie      | Items.MediumQualityFood20 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.darkfuture2077.com/for-mod-authors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
