Raised This Month: $51 Target: $400
 12% 

[L4D1&2] Scene Processor


Post New Thread Reply   
 
Thread Tools Display Modes
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 08-18-2014 , 07:09   Re: [L4D1&2] Scene Processor
Reply With Quote #11

Quote:
Originally Posted by Mr. Zero View Post
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.
Thank you, this is exactly what I was looking for.

I think cancelling the scene and immediately performing the new one better fits my needs, as I need the survivors to react to the original scene if possible...

Last edited by DeathChaos25; 08-18-2014 at 07:09.
DeathChaos25 is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 08-19-2014 , 15:09   Re: [L4D1&2] Scene Processor
Reply With Quote #12

First, I'd like to sincerely thank you for your continued patience to all of my questions, not everybody takes the time to kindly and properly inform a stranger online

With that established...

I took your example code and used it to achieve a certain goal *cough*Fake Zoey*cough*.

However, I can't seem to get it to work as I want it to, here's part of the code...

Spoiler


This is just a snippet, there are more i_Types declared and replaced with switches, but I snipped them for the sake of condensation.

The scenes being looked out for are the EXACT scenes I have in my Talker Addon, however, sometimes the scenes are captured, and at other times, they're completely ignored?

Also, I don't know if this is important or not, but the following line give me a "Argument type mismatch" on compile;

PHP Code:

    
new float:preDelay GetScenePreDelay(scene);
    new 
float:pitch GetScenePitch(scene);

// And this line
    
PerformSceneEx(actor""s_VocalizepreDelaypitchSCENE_INITIATOR_PLUGIN
I don't think I'm doing anything wrong, maybe it's how I set up the scene replacement?

Last edited by DeathChaos25; 08-19-2014 at 15:09.
DeathChaos25 is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 08-19-2014 , 22:26   Re: [L4D1&2] Scene Processor
Reply With Quote #13

Quote:
Originally Posted by DeathChaos25 View Post
I took your example code and used it to achieve a certain goal *cough*Fake Zoey*cough*.
While I am completely against this solution as it comes with a myriad of other problems, it should be possible. Do you mind me asking why you are not setting up a Linux dedicated server instead to completely side step this issue?

However I would probably change it so script would not have to continusly loop over strings but instead use a trie in this case since you already know which lines you wish to convert. I have typed up another loose example (e.g. not tested). Complete with debug function to hopefully help you out understand why it is not replacing lines.

Spoiler


Quote:
Originally Posted by DeathChaos25 View Post
Also, I don't know if this is important or not, but the following line give me a "Argument type mismatch" on compile;

PHP Code:

    
new float:preDelay GetScenePreDelay(scene);
    new 
float:pitch GetScenePitch(scene);

// And this line
    
PerformSceneEx(actor""s_VocalizepreDelaypitchSCENE_INITIATOR_PLUGIN
I don't think I'm doing anything wrong, maybe it's how I set up the scene replacement?
That is because you are using float: as a type. However that is a function to convert integers to floats. You want to use Float: (capitalized F) to mark variable as float data type.
PHP Code:
new myInterger 3
new Float:myFloat float(myInterger/* Comes out as 3.0 */ 
Edit:
Also here are some tips if you are new to SourcePawn that I have personal found useful but feel free to skip it.
Over the years, I have come to learn that coding style is probably one of the more important things. If you look back at the various plugins I have made over the years is that I have slowly changed coding style, adopting various things from various authors of other plugins that I have learned from. However it often turns into a some kind of coding mosh pit when looking back and you have learned some new ways of writing code. I have personally found the Linux kernel coding style a really good style for SourcePawn. Of course I will not be a grammar nazi on this point and everyone got their own favourite style of writing, but as a piece of advise, I would suggest picking one and sticking to it. You will find it a lot easier to go back to previous scripts you have done in the past and bring them up to date.

If there is an easier way to accomplish the goal, then take it. SourcePawn can do some pretty cool stuff but over complicating a plugin for the sake of doing it the hard way, can be crippling difficult to debug later down the road. On that note I would also like to say that I personal prefer to do multiple plugins, each having 1000 lines, than one big plugin of 50000 lines. It is a lot easier on the eyes.

The API is your friend. Learn to love it. Search on it frequently. Some people are even nice enough to leave comments if some parameters happens to be confusingly named. Otherwise do not be afraid of asking in the scripting forum section, people are nice as long you search and read on the API first then ask a question.

Last edited by Mr. Zero; 08-20-2014 at 00:49.
Mr. Zero is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 08-20-2014 , 03:09   Re: [L4D1&2] Scene Processor
Reply With Quote #14

Quote:
Originally Posted by Mr. Zero View Post
While I am completely against this solution as it comes with a myriad of other problems, it should be possible. Do you mind me asking why you are not setting up a Linux dedicated server instead to completely side step this issue?

Edit:
Also here are some tips if you are new to SourcePawn that I have personal found useful but feel free to skip it.
Over the years, I have come to learn that coding style is probably one of the more important things. If you look back at the various plugins I have made over the years is that I have slowly changed coding style, adopting various things from various authors of other plugins that I have learned from. However it often turns into a some kind of coding mosh pit when looking back and you have learned some new ways of writing code. I have personally found the Linux kernel coding style a really good style for SourcePawn. Of course I will not be a grammar nazi on this point and everyone got their own favourite style of writing, but as a piece of advise, I would suggest picking one and sticking to it. You will find it a lot easier to go back to previous scripts you have done in the past and bring them up to date.

If there is an easier way to accomplish the goal, then take it. SourcePawn can do some pretty cool stuff but over complicating a plugin for the sake of doing it the hard way, can be crippling difficult to debug later down the road. On that note I would also like to say that I personal prefer to do multiple plugins, each having 1000 lines, than one big plugin of 50000 lines. It is a lot easier on the eyes.

The API is your friend. Learn to love it. Search on it frequently. Some people are even nice enough to leave comments if some parameters happens to be confusingly named. Otherwise do not be afraid of asking in the scripting forum section, people are nice as long you search and read on the API first then ask a question.
Thank You for your suggestions, I assure you I'll take all of your advice to heart.

I'm definitely most likely switching to Linux, but I want to see just how far a "Fake" Zoy can be achieved before moving on, as I understand that replacing almost every line from Nicks scenes can make the plugin as big as probably more than 100,000 lines...

I initially considered dividing it into "sections" (read: multiple plugins), but then my server would end up with around 20 plugins more that all technically do the same thing.

But yes, I am very new to coding in general, not just sourcepawn, but I am always willing to learn and experiment

Edit : Tried it out, various mixed results.

Firstly, it turns out that, even though the scene is correctly named "IncapacitatedInitial" (as it also named in ALL of the talker response files) the scene actually spawns as "incapacitatedinitial", case sensitive was being our demise here.

After getting the lines corrected, It worked... !

The first time only though, after that, the server crashes after successfully replacing the line, but before it vocalizes.

After the first crash, the same crash kept repeating without working again.

VALVe just WANTS us to switch over to Linux huh?

xD

Last edited by DeathChaos25; 08-20-2014 at 07:01.
DeathChaos25 is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 08-20-2014 , 07:54   Re: [L4D1&2] Scene Processor
Reply With Quote #15

Quote:
Originally Posted by DeathChaos25 View Post
Firstly, it turns out that, even though the scene is correctly named "IncapacitatedInitial" (as it also named in ALL of the talker response files) the scene actually spawns as "incapacitatedinitial", case sensitive was being our demise here.
You can find all of the scene files in your local L4D2 folder under [...]\Steam\SteamApps\common\Left 4 Dead 2\left4dead2\scenes for L4D2 crew and [...]\Steam\SteamApps\common\Left 4 Dead 2\left4dead2_dlc2\scenes for L4D1 crew.
File paths are case sensitive as you have noticed and all scenes are in lower case.

Quote:
Originally Posted by DeathChaos25 View Post
The first time only though, after that, the server crashes after successfully replacing the line, but before it vocalizes.

After the first crash, the same crash kept repeating without working again.
If you based it on my script above, you should be able to find debug lines in the error logs. Do please share so we can see where the crash occurs. I have had issues in the past with Scene Processor killing scenes in a critical stage, causing the server to crash. We may have stumbled upon another one.
Mr. Zero is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 08-20-2014 , 18:37   Re: [L4D1&2] Scene Processor
Reply With Quote #16

Quote:
Originally Posted by Mr. Zero View Post
If you based it on my script above, you should be able to find debug lines in the error logs. Do please share so we can see where the crash occurs. I have had issues in the past with Scene Processor killing scenes in a critical stage, causing the server to crash. We may have stumbled upon another one.
Tested again, this time, the vocalizes worked perfectly for about 20 attempts or so, and just when I though it was safe, BAM!, insta crashes every attempt on server restart.

There aren't any error logs either, just regular logs, here they are,

Spoiler


As you can see, on each attempt, I made some differences, most notably, the last one.

While the original scene that spawns HAS to be all lowercase, the replacement scene can be written correctly as from the talker file,
incapacitatedinitial can be replaced with IncapacitatedInitial, but not vice versa.

I also tried PerformScene (not Ex) and the same results, I even tried adding a vocalize command into PerformScene (and Ex) and still got the crash.

I don't know if it makes a difference, but, whenever SRCDS crashes, it takes me out of fullscreen and Windows gives me the "SRCDS has stopped working" error where it normally does not error on crash when I try to do stupid S*** like loading m_survivorCharacter 5


Also, I made a plugin some time ago that was meant to compliment this one, except that one deals with Radial Menus and Vocalizations, in that one, the replacement scenes are all also written with Uppercases where needed (like AskReady for example), here's what I mean;

Spoiler
Again, just a snippet of an old plugin, but this one works flawlessly, I'm guessing it's because of the difference in how the scenes are created and sent to the actor?

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

Quote:
Originally Posted by DeathChaos25 View Post
Tested again, this time, the vocalizes worked perfectly for about 20 attempts or so, and just when I though it was safe, BAM!, insta crashes every attempt on server restart.

There aren't any error logs either, just regular logs, here they are,
Hm, I do not see anything unusual regarding the destruction and creation of scenes. If the server crashed due to the way Scene Processor kills the scene, as it did in the past, the logs would have stopped at "Cancelling scene...". Of course not fool proof and the previous bug might still be there.

Try changing the scene replacement time to SceneStage_Started instead of SceneStage_Spawned. I got a feeling that it may be the issue at hand.

On the off chance this is not the issue, lets make sure the files are precached. Throw precache_all_survivors 1 into your server config file. It may be Zoey scenes or sound files are not precached.
Mr. Zero is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 08-20-2014 , 21:03   Re: [L4D1&2] Scene Processor
Reply With Quote #18

Quote:
Originally Posted by Mr. Zero View Post
Hm, I do not see anything unusual regarding the destruction and creation of scenes. If the server crashed due to the way Scene Processor kills the scene, as it did in the past, the logs would have stopped at "Cancelling scene...". Of course not fool proof and the previous bug might still be there.

Try changing the scene replacement time to SceneStage_Started instead of SceneStage_Spawned. I got a feeling that it may be the issue at hand.

On the off chance this is not the issue, lets make sure the files are precached. Throw precache_all_survivors 1 into your server config file. It may be Zoey scenes or sound files are not precached.
Scenestage_Started did the trick, but i also threw the precache cvar into the config just in case.

I'll let you know if the crash rears it's ugly head again, but i have a feeling it won't, for now at least...

Edit : Going through the talker files, I found this section;

Spoiler


However, it says noscene, I'm guessing SceneProcessor won't be able to pick and interrupt these lines, any Idea of what I could do for them?

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

Quote:
Originally Posted by DeathChaos25 View Post
However, it says noscene, I'm guessing SceneProcessor won't be able to pick and interrupt these lines, any Idea of what I could do for them?
If it is a spoken line, it will also spawn a scene entity, which the plugin will pick up.

See my "No Lost Call" plugin (attached) for an example of stopping L4D2 Survivors keep calling out for help when they are the only one (everyone else have changed to a L4D1 character).

And just for short form:
PHP Code:
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 != SCENE_INITIATOR_WORLD) {
                return
            }
            
            
decl String:file[PLATFORM_MAX_PATH]
            if (
GetSceneFile(scenefilesizeof(file)) == 0) {
                return
            }
            
            if (
StrContains(file"lostcall"false) == -1) {
                return
            }
            
            
CancelScene(scene)
        }
    }

Also if I were you, when trying to find scenes, make a debug plugin that just prints all of the scenes out when created. On scene started, get scene file name and print it to chat. That way you will know if the scene processor can pick it up.
Attached Files
File Type: zip vocalizenolostcall_release.zip (16.5 KB, 184 views)

Last edited by Mr. Zero; 08-21-2014 at 19:52.
Mr. Zero is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 08-23-2014 , 21:00   Re: [L4D1&2] Scene Processor
Reply With Quote #20

I took your suggestion in making a separate plugin that logs EVERY scene created, but I had assumed correctly, and the call for rescue lines don't actually spawn a scene, I guess that's something that we can't correct then.

Also, just a small vid of the current progress...

For some reason, sometimes the replacement scene is delayed too much, like in the video, the incapacitatedinitial line was so delayed that it was interrupted by the incapacitatedhurt one instead, but that's a non issue as the delay is only noticeable when using grenades, as they are called almost after the grenade toss is done.

In case you're wondering what the plugin looks like right now...

Spoiler


And this is only about barely 30% of Nick's scenes, this'll look waaaaaaaaaaaaaaaayyyyyyy bigger when I'm done

(Hint : Nick still has roughly about 1,000 - 1,300 more scenes to go...

Last edited by DeathChaos25; 08-23-2014 at 21:32.
DeathChaos25 is offline
Reply



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 11:33.


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