server icon indicating copy to clipboard operation
server copied to clipboard

🐛 DYNAMIC_LOOKUP does not function properly when using non-mob npcs

Open neuromancerxi opened this issue 2 years ago • 2 comments

  • [x] I have paid attention to this example and will edit again if need be to not break the formatting, or I will be ignored
  • [x] I have searched existing issues to see if the issue has already been opened, and I have checked the commit log to see if the issue has been resolved since my server was last updated
  • [x] I have read and understood the Contributing Guide

Branch affected by issue

base

Steps to reproduce

Convert an NPCID to dynamic lookup, e.g.:

zones[xi.zone.SOUTHERN_SAN_DORIA_S] =
{
    npc =
    {
        SHIXO = DYNAMIC_LOOKUP,
    },
}

return zones[xi.zone.SOUTHERN_SAN_DORIA_S]

Call the ID in script, e.g.:

xi.extravaganza.shadowEraHide(ID.npc.SHIXO)

Results in errors in map log:

[map][warn] Invalid zone requested: 4095 (GetZone:113)
[map][warn] luautils::GetNPCByID NPC doesn't exist (-1) (GetNPCByID:871)
[map][error] luautils::onNpcSpawn: ./scripts/globals/extravaganza.lua:46: attempt to index a nil value
[map][error] Could not complete id lookup for Southern_San_dOria_[S].ID.npc.SHIXO (operator():815)

May be related to #2429 #2655 seems to have the same behavior for ID.npc.AQUILLINA

[map][error] Could not complete id lookup for Bastok_Markets.ID.npc.AQUILLINA (operator():815)

Expected behavior

Dynamic Lookup should succeed, returning the ID value.

neuromancerxi avatar Sep 13 '22 13:09 neuromancerxi

Take a look through #2614

I had a similar issue with this recently and tried my best to explain how I was able to fix this though I do not believe this is the correct method or solution to this problem.

N3ckB3ard avatar Sep 13 '22 14:09 N3ckB3ard

Doing some local testing to see if I can reproduce. So far, things have been working as expected: Southern San d'Oria [S] IDs.lua

    npc =
    {
        SHIXO = DYNAMIC_LOOKUP,
    },

On server start: [09/13/22 10:24:16:008][map][debug] New value for Southern_San_dOria_[S].ID.npc.SHIXO = 17105699 (luautils::PopulateIDLookups::<lambda_5f3e848c1769160430d5bb3e4e86e747>::()::<lambda_a85c7395daf0098e4dcc16c0e51947b5>::operator ():808)

It looks like this issue stems from load order, since it appears that onZoneInitialize is called prior to mob loading.

[09/13/22 10:27:37:380][map][info] do_init: loading zones (do_init:257)
[09/13/22 10:28:05:078][map][lua] -1 (lua_print:145)
[09/13/22 10:28:05:161][map][debug] Applying override: xi.zones.GM_Home.Zone.onInitialize (moduleutils::TryApplyLuaModules:229)
[09/13/22 10:28:05:173][map][lua] Making regional conquest NPCs available in: Port_Bastok (lua_print:145)

claywar avatar Sep 13 '22 14:09 claywar

DYNAMIC_LOOKUP is deprecated, please re-open if this is still valid with GetFirstID etc.

zach2good avatar Apr 30 '24 19:04 zach2good