L4D2 EMS/GnomeHunter tutorial 8

From Valve Developer Community
Jump to: navigation, search

Message Tickers

The Mutation System allows you to display messages on the HUD for players. If your Mutation's VScript supplies a function called SetupModeHUD() the Mutation System it will call it when your Mutation starts up.

Inside SetupModeHUD() you can create a table with some information about your HUD and then use HUDLoadLayout( table ) to load it:

// HUD setup
function SetupModeHUD( )
	ModeHUD <-
             Fields =
		gamename    = { slot = HUD_MID_TOP, name = "mutation_name", dataval = "Gnome Hunter!" }

	// load the ModeHUD table
	HUDSetLayout( ModeHUD )

In addition to displaying strings you can display variables. In this case we're just displaying the title "Gnome Hunter!" but we could also display other information like how many infected we've killed.

@@@TODO: more detail on hud slots, data types, scope [id actually say we have that detail in the appendix... what we should do here is have 1 dynamic element so we can show how that works]

You can also display any text string on the screen as a message ticker. Add the Ticker_AddToHud() function call inside your SetupModeHUD() function:

// Set up a message ticker that will be displayed below the Mutation's HUD
Ticker_AddToHud( ModeHUD, "Find the gnome! (Hint: it is glowing green)" )

Now go back to GetNextStage() and use the the Ticker_NewStr() function to customize the ticker message for each stage of gameplay:

// SECOND_STAGE ticker - display ticker string based on gnome state
Ticker_NewStr( "Here come the infected! Defend yourselves!" )

// THIRD_STAGE ticker
Ticker_NewStr( "Phew... you cleared out all the infected." )

// FOURTH_STAGE ticker
Ticker_NewStr( "You saved the gnome!  Good job. Resetting..." )

You can also display a string when the gnome is picked up. Place this ticker call inside GnomePickedUp():

Ticker_NewStr("Take the gnome to the locker up the stairs!")

In GnomeDropped(), remind the Survivors to pick it up again:

Ticker_AddToHud( ModeHUD, "Pick up the gnome! (Hint: it is glowing green)" )

And one more for when the gnome is placed in the locker. Add this inside the slow poll where the gnome kill() method is called:

// Display some ticker text confirming the rescue of the gnome
Ticker_NewStr("You saved the gnome! Kill all remaining infected to win!")

What next?

NEXT -->