Raised This Month: $32 Target: $400
 8% 

[L4D1&2] Scene Processor


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Plugin ID:
4233
Plugin Version:
1.0.1
Plugin Category:
Technical/Development
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    267 
    Plugin Description:
    Provides forwards and natives for manipulation of scenes
    Old 06-06-2014 , 00:24   [L4D1&2] Scene Processor
    Reply With Quote #1

    Scene Processor

    About:
    Yet another reboot of one of my older plugins. This plugin will allow you to modify just about any scenes, to prevent or cause certain scenes to be played out.

    This plugin does nothing of its own other than provide forwards and natives for other plugins to use. See the include file for functions.

    Description:
    Provides forwards and natives for manipulation of scenes.

    Commands:
    No commands are implemented in this plugin.

    Cvars:
    Code:
    // (L4D2 only) Whether the vocalize command will function once again as it did in L4D1, allowing players to type vocalize commands into their console. 0 = Disallow, 1 = Allow
    sceneprocessor_jailbreak_vocalize 1

    Change log:
    Code:
    Version 1.0.1  2014-06-26
    Added 'OnVocalizeCommand' forward.
    Fixed calling 'CancelScene' in SceneStage_SpawnedPost resulting in a server crash.
    
    Version 1.0.0  2014-06-06
    Initial release

    Other related plugins you may be interested in:
    Attached Files
    File Type: zip sceneprocessor.zip (44.4 KB, 9982 views)

    Last edited by Mr. Zero; 08-25-2014 at 03:58.
    Mr. Zero is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 06-06-2014 , 00:26   Re: [L4D1&2] Scene Processor
    Reply With Quote #2

    Scene Processor Include File:
    PHP Code:
    #define SCENEPROCESSOR_VERSION "1.0.1"
    #define SCENEPROCESSOR_LIBRARY "sceneprocessor"

    #define MAX_SCENEFILE_LENGTH    PLATFORM_MAX_PATH // Maximum length of scene files
    #define MAX_VOCALIZE_LENGTH    128 // Maximum length of vocalize strings

    #define SCENE_INITIATOR_WORLD    0    /* All scenes created by the map (such as landmarks, "Down this way", "Through here") 
                         
    * and by the game (such as team mate actions"Let me heal you up""Help I'm falling")
                         * 
    are marked as started by the world, or entity index 0. */
    #define SCENE_INITIATOR_PLUGIN    -1    /* All scenes started by the Scene Processor are by default marked as started by plugin or
                         
    entity index -1. This can be changed in the PerformScene function call. */

    #define DEFAULT_SCENE_PREDELAY 0.0    /* By default all scenes occur the instant they are created */
    #define DEFAULT_SCENE_PITCH 1.0        /* By default all scenes have a pitch of 1.0, or as they are normally heard. 2.0 will make
                         
    it sounds twice as fast but in a high pitched voice0.5 will be half the normal speed 
                         
    * and with low pitched voice. */

    enum SceneStages
    {
        
    SceneStage_Created 1,        /* When scene is created. Contains no information about the scene that is about to
                         * be played out. Guaranteed to occur. */
        
        
    SceneStage_Spawned,        /* When scene is spawned. Everything is filled in but the pre-delay! Change scene
                         * pitch and pre-delay here. */
        
        
    SceneStage_SpawnedPost,        /* Post scene spawned frame. Pre-delay is now filled out. Pre-delay can be changed
                         * here if the scene originally has a pre-delay greater than 0.0. */
        
        
    SceneStage_Started,        /* When scene is started. Time stamp is set. */
        
        
    SceneStage_Cancelled,        /* When scene is cancelled. Happens if the Survivor was interrupted by another scene
                         * or the scene was cancelled post starting. */
        
        
    SceneStage_Completion,        /* When scene is completed. Happens if the Survivor gets to fully perform the scene
                         * with no interruptions or cancellation. Entity index is no longer valid but
                         * information is retained. */
        
        
    SceneStage_Killed        /* When scene is killed. Entity index is no longer valid but information is retained
                         * until end of forward. Guaranteed to occur */
    }

    /**
     * Called on scene stage changed.
     *
     * @param scene        Scene entity index.
     * @param stage        SceneStages value.
     * @noreturn
     */
    forward OnSceneStageChanged(sceneSceneStages:stage);

    /**
     * Called on vocalize command send.
     *
     * @remarks See SCENE_INITIATOR_WORLD and SCENE_INITIATOR_PLUGIN for 
     * non-client initiated vocalizes.
     *
     * @param client    Index of player sending vocalize command.
     * @param vocalize    String of what player wish to vocalize, as typed.
     * @param initiator    Index of entity initiated vocalize command.
     * @return        Plugin_Stop to stop vocalize command.
     *            Plugin_Continue to allow vocalize command.
     */
    forward Action:OnVocalizeCommand(client, const String:vocalize[], initiator);

    /**
     * Returns scene stage.
     *
     * @param scene        Scene entity index.
     * @return        SceneStages value or 0 if scene is not valid.
     */
    native SceneStages:GetSceneStage(scene);

    /**
     * Returns whether scene is valid as a scene.
     *
     * @remarks The scene entity index may still be invalid.
     *
     * @param scene        Scene entity index.
     * @return        True if a valid scene, false otherwise.
     */
    stock bool:IsValidScene(scene)
    {
        return 
    GetSceneStage(scene) != SceneStages:0
    }

    /**
     * Returns scene start time stamp, in engine time.
     *
     * @param scene        Scene entity index.
     * @return        Scene start engine time stamp. 0.0 if the scene has not started yet.
     */
    native Float:GetSceneStartTimeStamp(scene);

    /**
     * Returns scene actor.
     *
     * @param scene        Scene entity index.
     * @return        Actor of the scene. 0 if no one is playing it.
     */
    native GetActorFromScene(scene);

    /**
     * Returns actor's scene.
     *
     * @remarks Only returns scene if it is currently being played out.
     *
     * @param actor        Client index of actor.
     * @return        Scene entity index. INVALID_ENT_REFERENCE if actor currently aren't playing.
     */
    native GetSceneFromActor(actor);

    /**
     * Returns whether actor is already playing a scene.
     *
     * @param actor        Client index of actor.
     * @return        True if actor is busy, false otherwise.
     */
    stock bool:IsActorBusy(actor)
    {
        return 
    GetSceneFromActor(actor) != INVALID_ENT_REFERENCE
    }

    /**
     * Returns scene initiator.
     *
     * @remarks See SCENE_INITIATOR_WORLD and SCENE_INITIATOR_PLUGIN for automated
     * scenes.
     *
     * @param scene        Scene entity index.
     * @return        Initiator of the scene.
     */
    native GetSceneInitiator(scene);

    /**
     * Returns scene file.
     *
     * @param scene        Scene entity index.
     * @param dest        Destination string buffer to copy to.
     * @param len        Destination buffer length (includes null terminator).
     * @return        Number of bytes written
     */
    native GetSceneFile(sceneString:dest[], len);

    /**
     * Returns scene vocalize.
     *
     * @remarks Will only contain the vocalize string if the scene was started by
     * the client them self. Otherwise empty.
     *
     * @param scene        Scene entity index.
     * @param dest        Destination string buffer to copy to.
     * @param len        Destination buffer length (includes null terminator).
     * @return        Number of bytes written
     */
    native GetSceneVocalize(sceneString:dest[], len);

    /**
     * Returns scene pre-delay.
     *
     * @remarks Sadly pre-delay is first fetched on SceneStage_SpawnedPost where
     * altering the pre-delay with SetScenePreDelay might already be too late.
     *
     * @param scene        Scene entity index.
     * @return        Scene pre-delay in seconds.
     */
    native Float:GetScenePreDelay(scene);

    /**
     * Sets scene pre-delay.
     *
     * @remarks Pre-delay can be set on SceneStage_Spawned and sometimes (!) on 
     * SceneStage_SpawnedPost depending on whether the scene originally has a 
     * pre-delay. Once SceneStage_Started fires pre-delay is no longer obeyed.
     *
     * @param scene        Scene entity index.
     * @param preDelay    Scene pre-delay in seconds.
     * @noreturn
     */
    native SetScenePreDelay(sceneFloat:preDelay);

    /**
     * Returns scene pitch.
     *
     * @param scene        Scene entity index.
     * @return        Scene pitch.
     */
    native Float:GetScenePitch(scene);

    /**
     * Sets scene pitch
     *
     * @remarks Scene pitch can be set on SceneStage_Spawned and 
     * SceneStage_SpawnedPost. Setting pitch post spawning results in weird
     * settings such as some clients hearing 1.13 as double as fast instead of 2.0.
     *
     * @param scene        Scene entity index.
     * @param pitch        Scene pitch.
     * @noreturn
     */
    native SetScenePitch(sceneFloat:pitch);

    /**
     * Cancels scene.
     *
     * @remarks Can be used at all scene stages. Scene is validated before sending
     * the cancel input.
     *
     * @param scene        Scene entity index.
     * @noreturn
     */
    native CancelScene(scene);

    /**
     * Performs a scene.
     *
     * @remarks Scene file is used before vocalize string however vocalize string
     * is still saved to scene entity index and can be retrieved for later usage.
     * If vocalize string is used, it is delayed for a short while in order to
     * work if used inside of OnSceneStageChanged. See PerformSceneEx to avoid 
     * this delay.
     *
     * @param client    Client index.
     * @param vocalize    Vocalize string.
     * @param file        Scene file.
     * @param preDelay    Scene pre-delay.
     * @param pitch        Scene pitch.
     * @param initiator    Initiator of the scene.
     * @noreturn
     */
    native PerformScene(client, const String:vocalize[], const String:file[] = ""Float:preDelay DEFAULT_SCENE_PREDELAYFloat:pitch DEFAULT_SCENE_PITCHinitiator SCENE_INITIATOR_PLUGIN);

    /**
     * Performs a scene.
     *
     * @remarks Works the same way as PerformScene however there is no delay when
     * using vocalize string. Not recommend to use inside OnSceneStageChanged if 
     * vocalizes needs to get through.
     *
     * @param client    Client index.
     * @param vocalize    Vocalize string.
     * @param file        Scene file.
     * @param preDelay    Scene pre-delay.
     * @param pitch        Scene pitch.
     * @param initiator    Initiator of the scene.
     * @noreturn
     */
    native PerformSceneEx(client, const String:vocalize[], const String:file[] = ""Float:preDelay DEFAULT_SCENE_PREDELAYFloat:pitch DEFAULT_SCENE_PITCHinitiator SCENE_INITIATOR_PLUGIN); 

    Last edited by Mr. Zero; 06-29-2014 at 16:59.
    Mr. Zero is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 06-06-2014 , 00:40   Re: [L4D1&2] Scene Processor
    Reply With Quote #3

    Scene Processor Example Plugins:

    A couple of example plugins on how to capture and use scenes.

    Funny Pills
    For some reason you can't stop laughing after eating your pills.
    PHP Code:
    /* Includes */
    #include <sourcemod>
    #include <sceneprocessor>

    /* Plugin Information */
    public Plugin:myinfo 
    {
        
    name        "Vocalize Funny Pills",
        
    author        "Buster \"Mr. Zero\" Nielsen",
        
    description    "I feel funny... Ha ha funny.",
        
    version        "1.0.0",
        
    url        "[email protected]"
    }

    /* Globals */
    #define FUNNY_PILLS_DURATION 30.0
    #define FUNNY_PILLS_INTERVAL_MIN 2.0
    #define FUNNY_PILLS_INTERVAL_MAX 7.0
    #define FUNNY_PILLS_VOCALIZE "PlayerLaugh"
    #define FUNNY_PILLS_PITCH_MIN 0.75
    #define FUNNY_PILLS_PITCH_MAX 1.25

    /* Plugin Functions */
    public OnPluginStart()
    {
        
    HookEvent("pills_used"PillsUsed_Event)
    }

    public 
    PillsUsed_Event(Handle:event, const String:name[], bool:dontBroadcast)
    {
        new 
    userid GetEventInt(event"userid")
        new 
    client GetClientOfUserId(userid)
        
        if (
    client <= || client MaxClients || !IsClientInGame(client))
        {
            return
        }
        
        new 
    Handle:pack CreateDataPack()
        
    WritePackCell(packuserid)
        
    WritePackCell(pack_:GetEngineTime())
        
    WritePackCell(pack_:FUNNY_PILLS_DURATION)
        
    CreateTimer(GetRandomFloat(FUNNY_PILLS_INTERVAL_MINFUNNY_PILLS_INTERVAL_MAX), FunnyPills_TimerpackTIMER_FLAG_NO_MAPCHANGE)
    }

    public 
    Action:FunnyPills_Timer(Handle:timerHandle:pack)
    {
        
    ResetPack(pack)
        new 
    client GetClientOfUserId(ReadPackCell(pack))
        
        if (
    client <= || client MaxClients || !IsClientInGame(client) || GetClientTeam(client) != || !IsPlayerAlive(client))
        {
            
    CloseHandle(pack)
            return 
    Plugin_Stop
        
    }
        
        new 
    Float:startTimeStamp Float:ReadPackCell(pack)
        new 
    Float:duration Float:ReadPackCell(pack)
        
        if (
    GetEngineTime() - startTimeStamp duration)
        {
            
    CloseHandle(pack)
            return 
    Plugin_Stop
        
    }
        
        
    PerformScene(clientFUNNY_PILLS_VOCALIZE__GetRandomFloat(FUNNY_PILLS_PITCH_MINFUNNY_PILLS_PITCH_MAX))
        
    CreateTimer(GetRandomFloat(FUNNY_PILLS_INTERVAL_MINFUNNY_PILLS_INTERVAL_MAX), FunnyPills_TimerpackTIMER_FLAG_NO_MAPCHANGE)
        return 
    Plugin_Stop

    DEATH to death screamers!
    Lets provide them with that death they scream so much about.
    PHP Code:
    /* Includes */
    #include <sourcemod>
    #include <sdktools>
    #include <sceneprocessor>

    /* Plugin Information */
    public Plugin:myinfo 
    {
        
    name        "Vocalize Death Scream",
        
    author        "Buster \"Mr. Zero\" Nielsen",
        
    description    "DEATH to death screamers!",
        
    version        "1.0.0",
        
    url        "[email protected]"
    }

    /* Globals */

    /* Plugin Functions */
    public OnSceneStageChanged(sceneSceneStages:stage)
    {
        switch (
    stage)
        {
            case 
    SceneStage_Started:
            {
                new 
    client GetActorFromScene(scene)
                
                if (
    client <= || client MaxClients || !IsClientInGame(client))
                {
                    return
                }
                
                new 
    initiator GetSceneInitiator(scene)
                if (
    initiator != client)
                {
                    return
                }
                
                
    decl String:vocalize[MAX_VOCALIZE_LENGTH]
                if (
    GetSceneVocalize(scenevocalizesizeof(vocalize)) == 0)
                {
                    return
                }
                
                if (!
    StrEqual(vocalize"PlayerDeath"false))
                {
                    return
                }
                
                
    CancelScene(scene)
                
                if (
    GetEntProp(clientProp_Send"m_isFallingFromLedge"))
                {
                    return
                }
                
                new 
    Float:vel[3]
                if (
    GetRandomInt(01))
                {
                    
    vel[0] = -2500.0
                
    }
                else
                {
                    
    vel[0] = 2500.0
                
    }
                
                if (
    GetRandomInt(01))
                {
                    
    vel[1] = -2500.0
                
    }
                else
                {
                    
    vel[1] = 2500.0
                
    }
                
                
    vel[2] = 2000.0
                
                AcceptEntityInput
    (client"DisableLedgeHang"// Make sure they dont hang on to anything
                
                
    TeleportEntity(clientNULL_VECTORNULL_VECTORvel)
                
    SetEntityHealth(client2)
                
    CreateTimer(0.3SetLedgeFallingProp_TimerGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE)
            }
        }
    }

    public 
    Action:SetLedgeFallingProp_Timer(Handle:timerany:userid)
    {
        new 
    client GetClientOfUserId(userid)
        if (
    client && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == && IsPlayerAlive(client))
        {
            
    SetEntProp(clientProp_Send"m_isFallingFromLedge"1)
        }
        return 
    Plugin_Stop


    Last edited by Mr. Zero; 06-06-2014 at 01:02.
    Mr. Zero is offline
    Soduko
    Junior Member
    Join Date: Jul 2013
    Old 08-09-2014 , 04:55   Re: [L4D1&2] Scene Processor
    Reply With Quote #4

    Hey Zero As mentioned in the Anti-Vocalize-Thread, Sceneprofessor is producing errors on my server. Heres the error.log. Please let me know if/how i can provide more information for you to debug this. I'd really enjoy to use your anti-vocalize-spam plugins.


    Code:
    L 08/09/2014 - 11:13:13: [SM] Plugin encountered error 21: Native is not bound
    L 08/09/2014 - 11:13:13: [SM] Native "GetEngineVersion" reported: 
    L 08/09/2014 - 11:13:13: [SM] Displaying call stack trace for plugin "sceneprocessor.smx":
    L 08/09/2014 - 11:13:13: [SM]   [0]  Line 140, sceneprocessor.sp::AskPluginLoad2()
    L 08/09/2014 - 11:13:13: [SM] Unable to load plugin "sceneprocessor.smx": Native "GetSceneStage" was not found

    Last edited by Soduko; 08-09-2014 at 04:56.
    Soduko is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 08-09-2014 , 09:51   Re: [L4D1&2] Scene Processor
    Reply With Quote #5

    What version of SourceMod do you run? This plugin was compiled against 1.6. GetEngineVersion was added in 1.5 according the API reference.
    Mr. Zero is offline
    Soduko
    Junior Member
    Join Date: Jul 2013
    Old 08-09-2014 , 09:59   Re: [L4D1&2] Scene Processor
    Reply With Quote #6

    I just checked. Apparently im running SM 1.5.
    Do you think upgrading to 1.6 might resolve this?

    Code:
    SourceMod Version: 1.5.0-dev+3850
    SourcePawn Engine: SourcePawn 1.1, jit-x86 (build 1.5.0-dev+3850)
    Soduko is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 08-09-2014 , 10:10   Re: [L4D1&2] Scene Processor
    Reply With Quote #7

    At least update to the stable version of 1.5, if you insist running 1.5. Otherwise I see no reason why you would not update to 1.6. That should fix your error.
    Mr. Zero is offline
    Soduko
    Junior Member
    Join Date: Jul 2013
    Old 08-09-2014 , 12:06   Re: [L4D1&2] Scene Processor
    Reply With Quote #8

    Updated to 1.6 and its working fine now. Thx for helping me troubleshoot this and nice plugin!
    Soduko is offline
    DeathChaos25
    Senior Member
    Join Date: Jan 2014
    Location: Puerto Rico
    Old 08-17-2014 , 13:28   Re: [L4D1&2] Scene Processor
    Reply With Quote #9

    I have a question that's been quite the head scratcher for me right now.

    Is there any way to manipulate what scenes SCENE_INITIATOR_WORLD makes someone perform?

    Edit : what I mean by manipulate is alter WHAT scene file it reads from like PerformScene does?

    Last edited by DeathChaos25; 08-17-2014 at 14:43.
    DeathChaos25 is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 08-17-2014 , 22:11   Re: [L4D1&2] Scene Processor
    Reply With Quote #10

    Quote:
    Originally Posted by DeathChaos25 View Post
    I have a question that's been quite the head scratcher for me right now.

    Is there any way to manipulate what scenes SCENE_INITIATOR_WORLD makes someone perform?

    Edit : what I mean by manipulate is alter WHAT scene file it reads from like PerformScene does?
    Sadly you can not change the scene file once it has spawned. The alternative is to using CancelScene and then PerformScene with your wanted new scene file. If you know exactly which scene file you wish to use, instead of vocalize line, I would suggest using PerformSceneEx to make it happen exactly the next frame.

    So just loosely typed: (Changes Coachs adrenaline line into Ellis adrenaline line)
    PHP Code:
    OnSceneStageChanged(sceneSceneStages:stage)
    {
            if (
    stage != SceneStage_Spawned || GetSceneInitiator(scene) == SCENE_INITIATOR_PLUGIN /* Do not capture scenes spawned by the plugin, to prevent a loop */)
                    return
            
            
    decl String:scenefile[MAX_SCENEFILE_LENGTH]
            
    GetSceneFile(scenescenefilesizeof(scenefile))
            if (!
    StrEqual(scenefile"scenes/coach/adrenaline01.vcd"))
                    return
            
            new 
    float:preDelay GetScenePreDelay(scene)
            new 
    float:pitch GetScenePitch(scene)
            new 
    actor GetActorFromScene(scene)
            
    CancelScene(scene)

            if (
    actor 0/* Make sure the actor is valid, there are cases where the "world" uses vocalize lines, such as Whittalker or Virgil the talking boat. */
                    
    PerformSceneEx(actor"""scenes/mechanic/adrenaline01.vcd"preDelaypitch)

    Mr. Zero is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 02:11.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode