Left 4 Dead 2/Scripting/Script Functions/rr ProcessRules

From Valve Developer Community
Jump to: navigation, search

Function Description

void rr_ProcessRules(handle rulesArray)

Processes the rulesArray table/array to a concept that is then added to the Response System. Will override any existing concepts.
This is an incomplete implementation of custom talker concepts for VScript, but it is mostly functional. These concepts will last until the next map load or change.

This can be an effective system for scripts to utilize, allowing you to create concepts for both custom and vanilla campaigns while having minimal conflicts with other talker files.

Beware though, some values like predelay may not be implemented.


Parameters

Type Name Description
handle rulesArray The table/array to use for creating/overriding talker concepts.


Example

// Create a new concept for Nick to say "Close the door!" as well as another different concept for Coach. This can then be used with the SpeakResponseConcept input for custom maps and scripts. The included scripts are required if you wish to make a followup function, otherwise they are unnecessary.

IncludeScript("response_testbed", null)

local newrules =
[
    {
        name = "TestCustomConceptGambler", // The name of the concept. This will override any other concept with the same name
        criteria = // Criteria
        [
            [ "concept", "CustomConcept" ], // Required. The name to be used by SpeakResponseConcept and other parts of the game
            [ "who", "Gambler" ] // Survivor name. Acts like IsGambler
        ],
        responses =
        [
            {    scenename = "scenes/Gambler/CloseTheDoor01.vcd",    },
            {    scenename = "scenes/Gambler/CloseTheDoor02.vcd",    }
        ],
        group_params = g_rr.RGroupParams({ permitrepeats = true, sequential = false, norepeat = false })
    },
        // Multiple tables can be fit into one array to process more than one concept with just one table!
    {
        name = "CoachWantsPancakesButGetsClownsInstead",
        criteria =
        [
            [ "concept", "CoachPancakeTalk" ],
            [ "who", "Coach" ]
        ],
        responses =
        [
            {    scenename = "scenes/Coach/EllisInterrupt09.vcd",    },   // I'm listening, but this better be about pancakes!
            {    scenename = "scenes/Coach/ReactionNegative02.vcd",    }, // What the-
            {    scenename = "scenes/Coach/SeeClowns01.vcd",    }         // CLOWNS?!
        ],
        group_params = g_rr.RGroupParams({ permitrepeats = false, sequential = true, norepeat = false })
    },
        // This demonstrates the "followup" function to allow for chained responses.
    {
        name = "FollowupDemonstration",
        criteria =
        [
            [ "concept", "NickPouncedButEllisDontCare" ],
            [ "who", "Gambler" ]
        ],
        responses =
        [
            {    scenename = "scenes/Gambler/ScreamWhilePounced01.vcd",  followup = RThen( "mechanic",  "PlayerLaugh", {additionalcontext="null"}, 0.1 ) } //This makes Ellis play the PlayerLaugh response 0.1 seconds after Nick's scene finishes.
        ],
        group_params = g_rr.RGroupParams({ permitrepeats = true, sequential = false, norepeat = false })
    },
]
// Add the concept
g_rr.rr_ProcessRules( newrules );