Left 4 Dead 2

Left 4 Dead 2

View Stats:
Modify endgame credits stats
Hi,

This will be my very first mod, nothing fancy.

I just would like to modify the campaign endgame credits ("outtrotemplate" ??) so that I can include other stats I compiled myself (amount of FF hit points among other things).

A friend of mine showed me another mod ("updated stats crawl") but it does not contain any vscript, it just defines stats_crawl.txt and the "outtrotemplate" key... I don't understand where the "STAT_MOST_TANKS_KILLED" value comes from, I greped all .nut files in left4dead2 directory, and also I googled it... No luck.

I created a vscript (named "coop.nut", otherwise I discovered that it wouldn't be executed...) and I hooked some events in order to compile a few stats.

I successfully save/restore the stats between each map (using SaveTable / RestoreTable).

Now I would like to modify the campaign ending credits so that I can include these new stats.

Any idea how I could do it?

Thank you in advance,

PS : why do I sometimes get "DeepPrintTable function not found" whereas other functions like SaveTable work well? (DeepPrintTable is not found when inside my namespace during a OnGameEvent_round_start_post_nav event, weird)

PS2 : why is my addonimage.jpg not showing, whereas it is a 128px square?
< >
Showing 1-10 of 10 comments
The default stats are not tracked with VScripts, and AFAIK there is no VScript interface to add data to the stat crawl. The STAT_MOST_TANKS_KILLED value was probably already added by the game code, just unused.

DeepPrintTable() does not work in callback functions since it's not a global function, but exsists in the g_ModeScript scope, and the callbacks are not executed there for some reason.

And addonimage.jpg is really picky about the file format. You can get it working by importing it to VTFEdit, and exporting it from there as a jpg.
Hi Rectus, thx !

So you're telling me I will have no way to add data to the endgame stats? I'm gonna cry :'(

Thanks for the explanation about DeepPrintTable!

Regarding the addonimage.jpg, I think I tried this software (I think...) but it was written in russian and I don't read/speak russian. I'll look into it again, thanks!

Also last questions:

1. Using saveTable and restoreTable I had an issue: one of my table keys (named "hit") was renamed in "Hit" after the first map, therefore my stats bugged. How is that even possible that a table key is renamed by Valve??

2. I packed my addon into a vpk and sent it to friends, we played together (I hosted the campaign) but they did not see the stats in the console, but I did. Is it only the host that can make use of OnGameEvent_* hooks?

Thank you Rectus!
The original version[nemesis.thewavelength.net] of VTFEdit is in english.

1. Not sure why it would do that. It might be a bug with the system.

2. Yeah, the scripts are server-side, so console messages will only show up on the host or server. The hooks work for events genarated by all players though, so it's possible to record the stats of everyone playing. The best way to show the stats would probably be using the HUD system, since it shows up for all players. It won't differentiate between players though, so you'd need to show the stats of all players for everyone.
Nice one Rectus for the HUD, thank you! I had been looking into this but what I saw was mainly the use of vslib and it would be a big gun for nothing special...

Showing the stats of all players is fine :)

Thank you Rectus! I will give it a try tonight, hope it will go well (although I would have much more preferred the engame credits version :) maybe Valve will release something about it some day)
Rectus, sorry to bother you... I'm almost good. I still have 2 issues though:

1. The OnGameEvent_final_reportscreen hook does not seem to be called (and I would like to trigger my HUD during the endgame stats screen)

2. I can't get the HUD to function properly. I tried to use datafunc = @() formatStats() in order to update the HUD with a fully formatted message, but it keeps telling me that the index formatStats does not exist... What should I do? (although it is not vital, because I could create the HUD and then remove it after a few seconds though)

Thanks for your help!
1. Not sure about that one. Could be that i´t just doesn't work, or the game event itself doesn't get fired. There is a console command that shows what game events get fired, can't remember what it is called though.

2. That is a scoping issue again. Calling the function as g_ModeScript.formatStats() should work.

Thank you for your answer!

1. Yes it's display_game_events 1, but it does not work for campaigns, only when loading a map (although I could load a finale map, maybe it'll fire the engame screen)

2. Nope it doesn't, I tried that because you told me about it in your previoust post. Instead, I have twice the staticstring value...


function formatStats()
{
return "blabla"
}

newHUD <-
{
Fields =
{
supply = {slot = HUD_FAR_LEFT, staticstring = "Stats: ", datafunc = @() g_ModeScript.formatStats(), name = "stats", flags = HUD_FLAG_NOBG | HUD_FLAG_ALIGN_LEFT}
}
}
HUDSetLayout(newHUD)


It gives me a HUD (not even on the far left side...) with "Stats: Stats:" on it. What am I doing wrong? :-/
(I hope I can add newline characters in my formatStats func, otherwise I don't know how I will display multiline stats)
Oh right, I had problems with getting function calls to work inside a datafunc lambda. It might be possible to make it work by pointing it at a function directly, like: datafunc = g_ModeScript.formatStats

Another option would be to have the lambda return a manually updated variable, like: datafunc = @() g_ModeScript.StatsString

Newlines show up correctly though, and you can move around the HUD slots with HUDPlace(slot,x,y,w,h)
Thank you Rectus! I got it working! It was the staticstring that was incompatible with datafunc, I misread the doc.

Now I just have to find which events will be triggered during campaign credits ending, and also use a timeout (without using the Ticket helper though), so that I can display stats at the beginning of each round.

It may well be working fine in the end! :-D
For what it's worth:

1. I am now using OnGameEvent_player_left_checkpoint instead of (or rather in addition to) player_left_start_area in order to hide the stats as soon as we leave the shelter

2. For the ending, I am using finale_win instead of final_reportscreen (which does not seem to be called)

3. I do not use datafunc, but dataval instead (with static data then)

4. I display the stats once the level is loaded (nothing displayed on very first spawn)

If anyone is insterested in this addon, I would be glad to provide it.

Thanks to Rectus!
< >
Showing 1-10 of 10 comments
Per page: 1530 50

Date Posted: Feb 8, 2015 @ 1:11pm
Posts: 10