Tsuey / L4D2-Community-Update

Help us shape the potential future of L4D2 vanilla.
68 stars 22 forks source link

logic_relay outputs do not properly carry the !caller #487

Open alexiscoutinho opened 5 months ago

alexiscoutinho commented 5 months ago

Description

logic_relay outputs like OnTrigger and OnUserX do not properly forward the caller entity to the !caller target. Instead, the !caller target points to the relay itself. The !self and !activator targets work fine by the way.

A possible workaround for entities spawned via tables, if you don't care about the real activator, is to inject the real caller in the activator parameter of EntFire:

//button
OnIn =
{
    cmd1 = "!selfRunScriptCodeEntFire( \"relay_name\", \"Trigger\", \"\", 0, self )0-1"
}
//relay
OnTrigger =
{
    cmd1 = "!activatorFireUser10-1"
    ...
}

Reproduction steps

script_execute the script below:

SpawnEntityFromTable( "script_func_button", {
    spawnflags = 1024
    origin = GetListenServerHost().EyePosition()
    extent = "8 8 8"
    connections =
    {
        OnPressed =
        {
            cmd1 = "relay_nameTrigger0-1"
        }
        OnUser1 =
        {
            cmd1 = "!selfRunScriptCodeprintl(\"Success!\")0-1"
        }
    }
} )

SpawnEntityFromTable( "logic_relay", {
    targetname = "relay_name"
    connections =
    {
        OnTrigger =
        {
            cmd1 = "!callerFireUser10-1"
        }
        OnUser1 =
        {
            cmd1 = "!selfRunScriptCodeprintl(\"Failure\")0-1"
        }
    }
} )

Take a step backwards then press the button (turn on picker mode if you can't find the invisible button). When you press it, you will see "Failure" instead of "Success!" in the console.