rafradek / sigsegv-mvm

gigantic, obese SourceMod extension library of sigsegv's TF2 mods (mostly MvM related)
Other
63 stars 19 forks source link

Cannot use VScript AddThinkToEnt() in the scope of some entities. #128

Closed mtxfellen closed 1 month ago

mtxfellen commented 1 month ago

The following test was conducted on "mvm_skeleclipse_b7a.bsp".

The popfile below does not function as expected. On a listen server, it correctly prints "Thinking..." every 0.1s to the chat. However, on a sigsegv-mvm instance, it does not print anything after "InitWaveOutput", indicating that the think function was not applied correctly.

WaveSchedule {
    RespawnWaveTime 0
    StartingCurrency 30000
    CanBotsAttackWhileInSpawnRoom no

    Wave {
        InitWaveOutput {
            Target bombpath_choose_random_relay
            Action RunScriptCode
            Param "
                self.AcceptInput(`Trigger`, ``, null, null)

                ClientPrint(null, Constants.EHudNotify.HUD_PRINTTALK,
                    `InitWaveOutput`)

                local ent = SpawnEntityFromTable(`handle_test`, {})
                ent.ValidateScriptScope()

                ent.GetScriptScope().foo <- function() {
                    ClientPrint(null, Constants.EHudNotify.HUD_PRINTTALK,
                        `Thinking...`)
                }

                AddThinkToEnt(ent, `foo`)
            "
        }
    }
}

If the Target value is changed to BigNet, the code functions as expected.

rafradek commented 1 month ago

Yes, because the entity was removed from that map by something. Not sure why you wont be using either tf_gamerules or gamerules as they will always be present on every map