Skip to content

[BUG] EnsureSmokeBreak can't load base game cigarette prefab #85

@k073l

Description

@k073l

Summary

NPCPrefabBuilder.EnsureSmokeBreak fails to load base game cigarette prefab in its default case, instructing devs to use their own prefab or pass in the correct Resources path.

Game Version

Other (specify in Additional Context)

S1API Version

3.0.4

MelonLoader Version

0.7.2 Nightly

Runtime Environment

Mono (Alternate), IL2CPP (Regular)

Steps to Reproduce

  1. Create a NPC with a location based action spec with SmokeBreak behaviour.
  2. Observe warning in ML console.

Expected vs Actual Behavior

Expected: Smoke break behaviour loads and functions correctly.
Actual: S1API fails to configure the necessary prefab.

MelonLoader Log

[WARNING] [NPCPrefabBuilder] EnsureSmokeBreak: Could not load cigarette prefab. The base game may not expose it via Resources. Pass a Resources path to a cigarette prefab in your mod (e.g. EnsureSmokeBreak("MyMod/Cigarette_Lit")) or bundle one in your mod's Resources folder.

What Have You Tried?

  • As expected, not using smoke breaks in the schedule prevents this issue from surfacing.

Also I tried fixing the issue, see Additional Context.

Additional Context

Game Version: 0.4.5f1

Prefab expected by the API no longer exists.
The API, as a fallback, attempts to search existing SmokeCigarette objects to access the prefab on CigarettePrefab, which was removed in 0.4.4f10.

Current approach seems to be to use equippables/cigarette/cigarette_tp prefab, of type TPEquippedItem. SmokeCigarette has a field _cigarrete of type EquippableData, which in turn has a field for TPEquippedItem.
We can use the existing EquippableData, as it seems to only be a holder for prefabs, or create our own if not found.

I tried doing that, which prevented the warning message, however the behaviour wasn't working as expected. NPC wouldn't start smoking per schedule, but it would correct on interaction. If forced to activate, the NPC wouldn't put away the cigarrete, even after the action should have ended and there was another behaviour on the schedule. Error invoking StaggeredInvoke error was observed in the Player.log, which could be related to the change.
Additionally on IL2CPP the game would crash on time change via console command (although the error message suggested another, unrelated mod) after this change.

This leads me to believe that the root cause of this weird behavior is SmokeBreakBehaviour, not necessarily my changes to the prefab instantiation.

It's also possible the prefab instantiation isn't required, since the NPC prefab used by S1API might already have the SmokeCigarette object.

Pre-submission Checklist

  • I have read the installation guide
  • I am using the latest version of S1API
  • I have verified this issue is related to S1API (not general modding support)
  • I am using MelonLoader 0.7.0 or have noted compatibility issues with 0.7.1+
  • I have included my MelonLoader log or relevant excerpts

Metadata

Metadata

Assignees

No one assigned

    Labels

    LowVery minor issue, non gameplay hindering, fix all high prio firstbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions