ValveSoftware / Source-1-Games

Source 1 based games such as TF2 and Counter-Strike: Source
634 stars 74 forks source link

TF2 VScript Mega Issue! #4481

Open Joshua-Ashton opened 1 year ago

Joshua-Ashton commented 1 year ago

Hello! Today we are launching a beta branch of TF2 that has support for VScript in the vscript_test branch.

This is a big issue to collate feedback from Mappers/Server Hosts for the TF2 implementation.

Instead of filing individual issues or feature requests, please post anything related to it in here. Thanks!

unclamped commented 1 year ago

Holy hell, amazing! Really looking forward to how this will end up looking like, sounds really promising!

vrad-exe commented 1 year ago

Finally, Bad Apple in Team Fortress 2

Trico-Everfire commented 1 year ago

Finally, we can have actual NPCs in TF2, not just skeletons, murrrasssmus and headless horseman.

Batfoxkid commented 1 year ago

Finally, we can have actual NPCs in TF2, not just skeletons, murrrasssmus and headless horseman.

https://www.youtube.com/watch?v=qTOgDZEuPMg

nosoop commented 1 year ago

Linux dedicated server crashes on startup:

AppFramework : Unable to load module vscript_srv.so!
Unable to load interface VScriptManager010 from vscript_srv.so

Dedicated server instance appears to be missing bin/vscript_srv.so. I'm not familiar with how VScript works, but I assume this is supposed to be working.

(Aside: Do consider having a dedicated issue-tracking repository for this to keep things organized.)

Joshua-Ashton commented 1 year ago

Dedicated server instance appears to be missing bin/vscript_srv.so.

Should be fixed in the next update.

Yakibomb commented 1 year ago

Trying to access netprops, and I'm unable to. I'm also brand spankin new to vscript (started when I heard about this) so here's what I have

function OnPostSpawn()  //executes on script load
{   
    local dispenserobj = SpawnEntityFromTable("obj_dispenser", { teamnum = 3} ) 

    for ( local obj=null; obj = Entities.FindByClassname(obj, "obj_*"); )
    {
        obj.SetOrigin(Vector(90,3436,294)) //use 'getpos' in console to find a better origin
        CNetPropManager.SetPropInt(obj, "m_iHealth", 1)
    }
}

The part CNetPropManager.SetPropInt(obj, "m_iHealth", 1) is recognized by the game but spits out [Accessed null instance] and terminates the rest of the script.

Joshua-Ashton commented 1 year ago

@Yakibomb Hello! It looks like something was wrong with registering the singleton instance for netprops in that build. It will be fixed in the next update

Yakibomb commented 1 year ago

@Joshua-Ashton Awesome!! That's fabulous. Also seems like these aren't working ( spits out [Accessed null instance] )

CBaseEntity.GetHealth() CBaseEntity.GetMaxHealth()

RealBerke commented 1 year ago

You can't pass a string to a function using RunScriptCode input. This problem was present in other games with VScript too. function PrintText(strText) { printl("Test " + strText); } To mark a variable as a string you have to cover it with quotation marks: resim As you do this, output formatting gets broken due to quotation marks also being used in VMF to seperate things. "OnUser1" "!selfRunScriptCodePrintText("Hello");0-1"

https://github.com/mapbase-source/source-sdk-2013/wiki/VScript-in-Mapbase#new-utilities One thing could be done is adding something similar to input above RunScriptCodeQuotable where double apostrophes is replaced by quotation marks during runtime, so it doesn't corrupt the VMF.

AwfulRanger commented 1 year ago

It seems that game event callbacks can be registered, but are never actually ran by the engine. Tested on Windows in both a listen server and a dedicated server.

function OnGameEvent_player_hurt( data ) { printl( "OnGameEvent_player_hurt: " + data ) }

__CollectGameEventCallbacks( this )

This works as expected in L4D2 but in TF2 does nothing (calling __RunGameEventCallbacks manually will run the callback function though).

Shadowysn commented 1 year ago

The part CNetPropManager.SetPropInt(obj, "m_iHealth", 1) is recognized by the game but spits out [Accessed null instance] and terminates the rest of the script.

Convars has the same [Accessed null instance] problem as well.

pivotman319-owo commented 1 year ago

I'm noticing that the functions CBaseEntity::SetTeam(teamnum), CBaseEntity::GetScriptScope() and CBaseEntity::ValidateScriptScope() appear to be absent here in this implementation of VScript; P2 heavily depends on these functions in order to get choreography working properly. CBaseFlex::GetCurrentScene() also appears to be missing from vscript from further inspection.

OnPostSpawn() in choreo\glados.nut:

// OnPostSpawn - this is all the initial setup stuff
function OnPostSpawn()
{
        local i = 0
        //assign a unique id to each scene entity (uses SetTeam because that's the only thing available)
        foreach (val in SceneTable)
        {
            i+=1
            val.vcd.ValidateScriptScope()
            val.vcd.SetTeam(i)
            val.index <- i
        }       
        //Initialize the deferred scene queue
        QueueInitialize()
        PuzzlePreStart()

        //Map specific Spawn stuff
        switch (curMapName)
        {
            case "sp_a1_wakeup":
                EntFire("@glados","runscriptcode","sp_a1_wakeup_start_map()",1.0)
                break
        }
}

What happens inside TF2: VScript error, blaming Validate Script Scope

VScript error, blaming Set Team

samisalreadytaken commented 1 year ago

CBaseEntity::ConnectOutput crashes the game.

CTriggerCamera script description is missing.

Tsuey commented 1 year ago

Quick FYI about a long-standing Squirrel VM bug we fixed with L4D2 on April 14th, just to make sure it's gone in TF2:

image

For over a decade, this very rare and impossible to reproduce bug caused complete VScript failures that led to events, finales, and Mutations to suddenly not work until the map was reloaded. As players run more and more VScripts in TF2, keep this bug in mind, since it was our team's biggest nightmare post-TLS. (Not to be confused with race condition issues that often yielded a similar result, which we've fixed by adjusting the order script runs.)

Joshua-Ashton commented 1 year ago

Convars has the same [Accessed null instance] problem as well.

Yep, I fixed this when I fixed net props. It will also be fixed in the next update.

@Joshua-Ashton Awesome!! That's fabulous. Also seems like these aren't working ( spits out [Accessed null instance] ) CBaseEntity.GetHealth() CBaseEntity.GetMaxHealth()

Are you calling these functions on an actual entity or the class type. Seems like the latter which would give this behaviour.

It seems that game event callbacks can be registered, but are never actually ran by the engine.

Thanks, I will check it out.

samzanemesis commented 1 year ago

nice

Ashetf2 commented 1 year ago

Is entity_activator_context necessary now that we have vscript? https://github.com/ValveSoftware/Source-1-Games/issues/3681

FriskTheFallenHuman commented 1 year ago

Replying to https://github.com/ValveSoftware/Source-1-Games/issues/4481#issuecomment-1304553207

@Joshua-Ashton hey do you guys has this fixed right?

ghost commented 1 year ago

@Joshua-Ashton heyo this is kind of unrelated, but are there any fixes coming for ping spoofing/fake pings in server browser for TF2?

one of communities i regulared just shut down cause competition took their traffic with fake low ping their servers show all ping 10 - 20 and when u join them its actually 300 - 400 in scoreboard

im not tech savvy but its something called anycast with a2s caching they use to spoof ping multiple communities do this and i hate it when i download files for 5 minutes for server with ping 50 then join and realize its 500

horiuchii commented 1 year ago

Could logic_eventlistener's Fetch Event Data functionality be backported aswell?

11/7/2022 Edit: It appears that the Fetch Event Data functionality does in fact exist in the latest version of the vscript-test branch. However, it doesn't appear in the FGD by default.

ghost commented 1 year ago

Functions that stun and scare players (like on trigger_stun, for example) would be handy to have on the CTFPlayerShared class

Shadowysn commented 1 year ago

Could logic_eventlistener's Fetch Event Data functionality be backported aswell?

There's a script function called __CollectEventCallbacks which allows you to define OnGameEvent_x in any script scope and replicate the behavior of logic_eventlistener including fetching event data, and you can even define multiple events to listen to in one scope. Though as of currently it's not working as stated by AwfulRanger, but in due time it'll be fixed.

orinuse commented 1 year ago

Two small things I'll be bringing attention to:

  1. Current description for CBaseEntity::GetBaseVelocity() is `"Get Base? velocity", which.. leaves a lot more to be desired. I'd like the description to be this instead:
Get base velocity, which is any constant velocity currently being imparted onto the entity. (e.g. "trigger_push")

This is based off the one from Left 4 Dead 2's list of vscript functions.

  1. CBaseEntity::GetScriptId() does not return the unique identifier stored in the "m_iszScriptId" prop, but instead the name of its current think function.

The following demonstrates this:

::labrat <- Entities.CreateByClassname("point_script_template")
::labrat.ValidateScriptScope()

local scope = ::labrat.GetScriptScope()
scope["dummythinker"] <- function()
{
    return 1.0
}
AddThinkToEnt(::labrat, "dummythinker")

// ++ Print ++
// -----------
printl("SCRIPT ID: "+::labrat.GetScriptId())
printl("{")
__DumpScope(1, scope)
printl("}")

The output would be something like this:

SCRIPT ID: dummythinker
{
   self = ([0] point_script_template)
   __vname = "_4fca_point_script_template"
   __vrefs = 1
   dummythinker = (function : 0x565F9CC0)
}

Would be appreciated if these were addressed. I also want to give thanks to @Shadowysn for helping me with testing.

SnowshoeIceboot commented 1 year ago

As a TF2 mapper, I'm not very familiar with VScript but will it be possible to remove existing attributes from weapons? Or give players weapons with completely custom stats, not just additional attributes.

Gamecube762 commented 1 year ago
 failed to dlopen /home/steam/TF/bin/vscript_srv.so error=/home/steam/TF/bin/vscript_srv.so: file too short
 failed to dlopen vscript_srv.so error=bin/vscript_srv.so: file too short
AppFramework : Unable to load module vscript_srv.so!
Unable to load interface VScriptManager010 from vscript_srv.so

Linux dedicated server is still failing to start, bin/vscript_srv.so is no longer missing but it fails to load.

Shadowysn commented 1 year ago

As a TF2 mapper, I'm not very familiar with VScript but will it be possible to remove existing attributes from weapons? Or give players weapons with completely custom stats, not just additional attributes.

It depends on whether Valve wants TF2 mappers to make inconsistent weapon behavior with the rest of the game on a specific map. It would be incredibly great for custom maps as a whole, but there's eventually gonna be that one mapper who completely changes every weapons' stats and tries to submit it to a seasonal map roster. And with how Wutville got in... (Thinking about it though, this could work for a Halloween map's bonus special effect) The problem I see with it, is how can these new weapon attribute changes be informed to players?

UndefinedBHVR commented 1 year ago

There appears to currently be no way to respawn a player using vscript. Would you mind exposing ForceRespawn() or ForceRegenerateAndRespawn() to VScript?

Yakibomb commented 1 year ago

@Joshua-Ashton Awesome!! That's fabulous. Also seems like these aren't working ( spits out [Accessed null instance] ) CBaseEntity.GetHealth() CBaseEntity.GetMaxHealth()

Are you calling these functions on an actual entity or the class type. Seems like the latter which would give this behaviour.

Ah, I meant calling it via entity. This was fixed in the most recent update. Thank you!

Shadowysn commented 1 year ago

Replying to https://github.com/ValveSoftware/Source-1-Games/issues/4481#issuecomment-1304503077

Can confirm this, also occurs with __CollectEventCallbacks, the non-wrapper function for purely game events only as opposed to both script and game events with __CollectGameEventCallbacks

Lizard-Of-Oz commented 1 year ago

Feature requests:

Lizard-Of-Oz commented 1 year ago

Another feature request: the ability to make certain entities visible or not on a per-player basis, so that certain players could see the objects while others couldn't, and it wouldn't be tied to a team.

horiuchii commented 1 year ago

Touching a trigger that has an output to run a function doesn't seem to pass on the caller or activator variables the first time touching the trigger, it seems to work as expected the second time touching and onwards. image

Joshua-Ashton commented 1 year ago

@horiuchii Can you provide a test map, please?

horiuchii commented 1 year ago

@horiuchii Can you provide a test map, please?

This map should showcase the issue nicely. You must step on the red square to the right of spawn before you are able to collect the health packs.

https://cdn.discordapp.com/attachments/665797362492637195/1039780955256270872/vscript_bug.7z

Joshua-Ashton commented 1 year ago

Some fixes that are coming in the next vscript_test update that are relevant:

Hopefully these fixes should be live sometime soon.

NotNihilanth commented 1 year ago

Any chance the local player drawing can be applied to func_reflective_glass as well?

Joshua-Ashton commented 1 year ago

This was updated.

Any chance the local player drawing can be applied to func_reflective_glass as well?

Perhaps

Ashetf2 commented 1 year ago

I'm not sure if porting point_worldtext was intentional, but if it was, it is misaligned. You can see in the image that the "K"s aren't aligned and you can see a bit of the same "K" above.

image

FriskTheFallenHuman commented 1 year ago

i don't know if you guys have plans for exposing more mvm stuffs (population, bots, ects) guys over potato.tf and moonlight would love to use vscript since the current things they're doing are basically using rafmod, and also expose gamemodes to vscript too

ghost commented 1 year ago

Feature request:

It seems simple but player's weapon sounds seem to be fully client-side, so server can't stop with vscript minigun from playing shooting sound and you can imagine its loud when 20 heavys stand in one spot shooting beep beep their miniguns Thanks!

hexaflexahexagon commented 1 year ago

In my script referenced by logic_script on map1 I have the following:

function OnGameEvent_player_hurt(params)
{
  // do stuff here
}

if(!("PlayerHurtEventActive" in getroottable()))
{
    __CollectEventCallbacks(this, "OnGameEvent_", "GameEventCallbacks", RegisterScriptGameEventListener)
    ::PlayerHurtEventActive <- true
}

But when I swap to another map using map map2 I get the following error every time I take damage. I'm guessing something isn't being cleared that should be on map change? If I disconnect and then map map2 the error still comes up. The only way I can find to clear it is to fully reboot the game, then launch map2 BEFORE map1.

AN ERROR HAS OCCURED [the index 'GameEventCallbacks' does not exist]

CALLSTACK
*FUNCTION [__RunEventCallbacks()] unnamed line [199]
*FUNCTION [__RunGameEventCallbacks()] unnamed line [226]

LOCALS
[bWarnIfMissing] true
[globalTableName] "GameEventCallbacks"
[prefix] "OnGameEvent_"
[params] TABLE
[event] "player_hurt"
[this] TABLE
[params] TABLE
[event] "player_hurt"
[this] TABLE
horiuchii commented 1 year ago

Could we have the ability to set an overlay on a specific client? Similar in functionality to r_screenoverlay but without the sv_cheats restriction.

FAZ2K commented 1 year ago

Hey, could we please have a "SetClass" function? We already "SetTeam". Thanks!

FriskTheFallenHuman commented 1 year ago

I don't if is on the current agenda but i would love if the training system was exposed to the vscript vm, it would allow mappers to create custom training maps, and also would be cooler if the training hud works outside of the training mode

horiuchii commented 1 year ago

EmitSoundOnClient() does not seem to function properly, client can't hear the sound. Tested with passing in the activator and a player handle separately. Tested only on a Listen Server.

TheShermanTanker commented 1 year ago

Ah yes, time to terrorize MVM robots by re-enabling the hidden headshot abilities of Sniper's SMG and Scout/Engineer's pistol

Seriously though, this is amazing, hope this grows to something big in the future! This makes modding the game with silly things available to more average developers like me instead of being restricted to only the god tier legends capable of editing raw x86 by hand, like @sigsegv-mvm :P

Joshua-Ashton commented 1 year ago

EmitSoundOnClient() does not seem to function properly, client can't hear the sound. Tested with passing in the activator and a player handle separately. Tested only on a Listen Server.

Did you precache the sound?

horiuchii commented 1 year ago

EmitSoundOnClient() does not seem to function properly, client can't hear the sound. Tested with passing in the activator and a player handle separately. Tested only on a Listen Server.

Did you precache the sound?

I can confirm that the sound was precached.

Ran on MultiNewRound const SND_SOUNDNAME = "example/soundname.mp3"; PrecacheSound(SND_SOUNDNAME); "Direct precache of example/soundname.mp3" Prints in console

Ran on trigger touch, doesn't work EmitSoundOnClient(SND_SOUNDNAME, activator);

However, something like this works as expected, also on trigger touch caller.EmitSound(SND_SOUNDNAME);

Lizard-Of-Oz commented 1 year ago

Hi. I'd like to make a few feature requests, assuming they're reasonably easy to implement.