Tales of Maj'Eyal

Tales of Maj'Eyal

Not enough ratings
Stealth.lua (line 29 Bad Argument) Detection Bug Fix
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
11.498 KB
11 May @ 12:27pm
1 Change Note ( view )

Subscribe to download
Stealth.lua (line 29 Bad Argument) Detection Bug Fix

Description
A dirty patch to avoid calculating detection for actors in memory but not deployed, just "died" actors, characters in transition from level to level, or dummy actors (projectiles, etc).

Skipping the check in that case is correct and safe.
If self.x or self.y is nil, then the player (or entity using stealth) is not placed on the map — so:
No stealth detection should occur.
The entity should not be visible to or interactable with enemies.
It’s either during initialization, level transition, or removal.

Detailed Scenarios Where self.x/y Might Be nil:

1. Actor Not Yet Spawned or Placed
During character creation or special scripted spawns (e.g. timed events).
self.x/y are set when placed via game.level:addEntity(self, "actor", x, y)

2. During Level Transitions
Between zones or levels, actors are temporarily de-referenced.
self.x/y are nil until the actor is placed into the new map.
This happens mid-turn during some engine states.

3. Just After Death or Teleport/Phasing
If the actor dies or is removed, the coordinates may be unset immediately.
If an effect lingers (like a stealth aura) post-removal, the logic might still be triggered once.

4. Fake or Preview Actors
Some systems create "preview" or "clone" versions of the player to run simulations (e.g. projected stats).
These often lack map presence.