Code Monkey home page Code Monkey logo

escape-route-interface's Introduction

[L4D2] Escape Route Interface

This is a very useful SourceMod plugin that allows developers to access the Escape Route entity and, for example, spawn specific items or infected along the survivors' escape route. If you've ever wanted to spawn Special Infected on the Survivor Path as the game does, then this is the tool.

You'll need to download the NavMesh Library as well because this whole system is built upon the NavMesh.

There's a plugin that demonstrates this system by spawning a witch on the escape route. I encourage you to check out the code to get an idea of how something like this works in Left 4 Dead.

API

methodmap CEscapeRoute
{
    /*
     * @param flFlowPercent     Player progress in percent along the flow as decimal (0.0 - 1.0)
     */
    public static native void GetPositionOnPath( float flFlowPercent, float flVecPosOut[3] );
};

/*
 * Returns the reference of the escape_route entity.
 */
native CEscapeRoute TheEscapeRoute();

/*
 * @param iTeam                     Team index (2 - 4).
 * @param nPlayerCount              (Optional) Total amount of players.
 * @param iHighestFlowPlayer        (Optional) Player who is furthest ahead according to flow distance.
 * @param fFlags                    Optional flags for filtering players.
 *
 * @return                          Flow distance, if applicable.
 */
native float GetHighestFlowDistance( int iTeam,
    int& nPlayerCount = 0,
    int& iHighestFlowPlayer = 0,
    FlowDistanceFilter eFlags = view_as< FlowDistanceFilter >( 0 ),
    TerrorNavAreaFlowType eFlowType = TerrorNavAreaFlow_TowardGoal );

Example Code

This piece of code was taken from the CDirectorVersusMode::UpdateVersusBossSpawning() function:

float vecPos[3];
CEscapeRoute.GetPositionOnPath( flFlowPercent, vecPos );

TerrorNavArea adrArea = view_as< TerrorNavArea >( CNavMesh.GetNavArea( vecPos ) );
if ( adrArea )
{
    for ( CNavArea.MakeNewMarker(); !adrArea.IsMarked(); adrArea = adrArea.GetNextEscapeStep() )
    {
        // Useful to detour and include custom rules here so that the game also respects them
        if ( adrArea.IsValidForWanderingPopulation() )
        {
            // We're afraid of water
            if ( !adrArea.IsUnderwater() )
            {
                float flVecCenter[3];
                adrArea.GetCenter( flVecCenter );
                flVecCenter[2] += 10.0;
                if ( ZombieManager.IsSpaceForZombieHere( flVecCenter ) && !adrArea.m_fPotentiallyVisibleToSurvivorFlags/* spawn them out of player sight */ )
                {
                    bool bSpawned = ZombieManager.SpawnWitch( adrArea, { 0.0, 0.0, 0.0 }/* we don't care; it's just a demo */, false/* spawn them right in the center */ );
                    if ( bSpawned )
                    {
                        SearchSurroundingAreas_RemoveWanderersScan( adrArea, flVecCenter, director_threat_clear_radius.FloatValue );
                    }

                    break;
                }
            }
        }

        adrArea.Mark();
    }
}

Requirements

Docs

Supported Platforms

  • Windows
  • Linux

Supported Games

  • Left 4 Dead 2

escape-route-interface's People

Contributors

justin-chellah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.