DeadNPCRespawnCondition - jimdroberts/FishMMO GitHub Wiki
DeadNPCRespawnCondition is a respawn condition class for FishMMO that allows respawning only when all specified NPCs are dead. It checks a list of NPCs and returns true if all are dead or the list is empty/null, ensuring that respawn events are gated by the state of key NPCs in the game world.
-
public List NPCs
The list of NPCs to check for alive/dead status before allowing respawn.
-
public override bool OnCheckCondition(ObjectSpawner spawner)
Checks if the respawn condition is met. Returns true if all NPCs are dead or the list is empty/null. Parameters: - ObjectSpawner spawner: The object spawner requesting the condition check. Returns: bool. True if respawn is allowed, false otherwise. No exceptions are thrown.
- Create a new DeadNPCRespawnCondition and assign it to your spawner's respawn conditions.
- Populate the NPCs list with references to the NPCs that must be dead for respawn to occur.
- Ensure each NPC implements ICharacterDamageController for alive/dead checks.
// Example 1: Assigning the condition to a spawner
DeadNPCRespawnCondition condition = new DeadNPCRespawnCondition();
condition.NPCs = new List<NPC> { npc1, npc2 };
spawner.RespawnConditions.Add(condition);
// Example 2: Checking the condition manually
bool canRespawn = condition.OnCheckCondition(spawner);
- Always ensure the NPCs list is kept up to date with relevant NPCs for the respawn logic.
- Use this condition to gate respawn events on boss or key NPC deaths for more dynamic encounters.
- Handle null NPCs and missing damage controllers gracefully to avoid runtime errors.