Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Crashes The Game
Wapez Offline
Senior Member

Posts: 360
Threads: 37
Joined: Mar 2012
Reputation: 19
#1
Script Crashes The Game

Hello Forum Members!

So recently I created a script for our mod, In Lucy's Eyes. After finishing it, I tried it and got an error message. I fixed some simple mistakes in the script, and then I tried it again. I got into the map, and everything worked normally. Until my script was activated.

The game first froze completely, and after a while I managed to tab it down. I saw a BlackBox message saying "Please wait, gathering system information" or something, as well as being stuck on 2% in the loading bar. This same thing happened repeatedly every time I tried the map.

What the script does:
It's a simple "movement puzzle". Six pipes are placed in a corridor, and each one of them release steam into the corridor every few seconds. (For this I have one area inside every pipe, which I spawn particle systems and sounds at, and one larger area in front of every pipe that I check whether the player is colliding with or not during the time the steam is being released) Your goal is to get past it. The steam will deal damage to you as you get hit.

I wanted to randomize and tweak stuff in a specific way, so I made the script a lot more complicated than it had to be. For anyone who hasn't created it I bet it's hard to read, but just let me know if I can help you understand something.

My question is:
Why does the game crash only when the script is activated, and why does it not provide me with an error message?

What is causing the crash?

After seeing the HPL log, I noticed the 18_steam_release.ogg sound was causing some problems. I disabled that sound in the script, but it still crashes. Any help here is much appreciated.

As I mentioned, there is no problem loading the map.

The actual script:
Spoiler below!

PHP Code: (Select All)
void SteamRun(string &in asTimer)
{
    
AddLocalVarInt("SteamSequenceStep"1);
    
float fEventSpeed RandFloat(1.5f3.0f);

    switch(
GetLocalVarInt("SteamSequenceStep")) {
        case 
1:
            
RunSteamFlow(1);
        break;
        case 
2:
            
RunSteamFlow(2);
        break;
        case 
3:
            
RunSteamFlow(3);
        break;
        case 
4:
            
RunSteamFlow(4);
        break;
        case 
5:
            
RunSteamFlow(5);
        break;
        case 
6:
            
RunSteamFlow(6);
        break;
    }
    
    if(
GetLocalVarInt("SteamSequenceStep") < 7){
        
AddTimer("steamloop"fEventSpeed"SteamRun");
    }
    else{ 
        
SetLocalVarInt("SteamSequenceStep"0);

        
AddTimer("steamrestart"RandFloat(5.0f10.0f), "SteamRun");
        
        for(
int i=1;i<=6;i++) SetLocalVarInt("iBlockedSteamArea_"+i0);
    }
}

void RunSteamFlow(int alEventCount){
    
int iSteamArea RandInt(16);
    
int RunCount alEventCount;
    for(
int i=1;i<=6;i++)
        if(
iSteamArea == GetLocalVarInt("iBlockedSteamArea_"+i)){
            
RunSteamFlow(RunCount);
        }
        else{
            
SteamEvent(iSteamArea);
            
SetLocalVarInt("iBlockedSteamArea_"+alEventCountiSteamArea);
        }
}

void SteamEvent(int alCount)
{
    if(
GetLocalVarInt("PlayerInAreaSteamDamage_"+alCount) == 1)
    {
        
GivePlayerDamage(20"BloodSplat"truefalse);     
        
PlaySoundAtEntity("""18_burn_steam""Player"0.0ffalse);
    }

    
CreateParticleSystemAtEntity("damage_steam"+alCount"ps_steam_deadly""AreaSteamCore_"+alCountfalse);
    
//PlaySoundAtEntity("sound_damage_steam"+alCount, "18_steam_release", "AreaSteamCore_"+alCount, 0.2f, false);
    
SetLocalVarInt("iSteamCount"alCount);
    
SetLocalVarInt("iSteamActive_"+alCount1);
    
    
AddTimer("timer"+alCount2.5"TimerStopSteam");
}

void TimerStopSteam(string asTimer)
{
    if(
asTimer == "timer1"){
        
SetLocalVarInt("iSteamActive_1"0);
        
StopSound("sound_damage_steam1"0.3f);
    }
    if(
asTimer == "timer2"){
        
SetLocalVarInt("iSteamActive_2"0);
        
StopSound("sound_damage_steam2"0.3f);
    }
    if(
asTimer == "timer3"){
        
SetLocalVarInt("iSteamActive_3"0);
        
StopSound("sound_damage_steam3"0.3f);
    }
    if(
asTimer == "timer4"){
        
SetLocalVarInt("iSteamActive_4"0);
        
StopSound("sound_damage_steam4"0.3f);
    }
    if(
asTimer == "timer5"){
        
SetLocalVarInt("iSteamActive_5"0);
        
StopSound("sound_damage_steam5"0.3f);
    }
    if(
asTimer == "timer6"){
        
SetLocalVarInt("iSteamActive_6"0);
        
StopSound("sound_damage_steam6"0.3f);
    }
}

void CollidePlayerSteam(string &in asParentstring &in asChildint alState)
{    
    if(
alState == 1SetLocalVarInt("PlayerIn"+asChild1);
    if(
alState == -1SetLocalVarInt("PlayerIn"+asChild0);
    
    
GetSteamActivePos();
    
    if(
alState == && GetLocalVarInt(asChild) == 1)
    {
        
GivePlayerDamage(20"BloodSplat"truefalse);     
        
PlaySoundAtEntity("""18_burn_steam""Player"0.0ffalse);
    }
}

void GetSteamActivePos()
{
    for(
int i=1;i<=6;i++) SetLocalVarInt("AreaSteamDamage_"+iGetLocalVarInt("iSteamActive_"+i));
}

void OnStart()
{
    for(
int i=1i<=6; ++iAddEntityCollideCallback("Player""AreaSteamDamage_"+i"CollidePlayerSteam"false0);
}

void OnEnter()
{
    
AddTimer("steam"RandFloat(7.0f12.0f), "SteamRun");
}

void OnLeave()
{



(Is the window too small to read the script in? Copy it all and paste it into a .hps or .txt file to get a better view.)


HPL log after disabling the sound:
Spoiler below!

Version 1.20
-------- THE HPL ENGINE LOG ------------
Engine build ID 20101021192547

Creating Engine Modules
--------------------------------------------------------
Creating graphics module
Creating system module
Creating resource module
Creating input module
Creating sound module
Creating physics module
Creating ai module
Creating gui module
Creating generate module
Creating haptic module
Creating scene module
--------------------------------------------------------

Initializing Resources Module
--------------------------------------------------------
Creating loader handlers
Creating resource managers
Adding loaders to handlers
--------------------------------------------------------

Initializing Graphics Module
--------------------------------------------------------
Init lowlevel graphics: 1920x1080 bpp:32 fs:1 ms:0 gpufmt:2 cap:'FPProject - Loading...' posSad-1x-1)
Setting video mode: 1920 x 1080 - 32 bpp
Init Glew...OK
Setting up OpenGL
Vendor: ATI Technologies Inc.
Renderer: AMD Radeon HD 7900 Series
Version: 4.2.12430 Compatibility Profile Context 13.152.1.8000
Max texture image units: 32
Max texture coord units: 16
Max user clip planes: 8
Two sided stencil: 1
Vertex Buffer Object: 1
Anisotropic filtering: 1
Max Anisotropic degree: 16
Multisampling: 1
Texture compression: 1
Texture compression S3TC: 1
Auto generate MipMaps: 1
Render to texture: 1
Max draw buffers: 8
Max color render targets: 8
Packed depth-stencil: 1
Texture float: 1
GLSL Version: 4.30
ShaderModel 2: 1
ShaderModel 3: 1
ShaderModel 4: 1
OGL ATIFragmentShader: 1
Setting up G-Bugger: type: 0 texturenum: 3
Adding engine materials
Initializing DevIL
Vendor String: Abysmal Software
Version String: Developer's Image Library (DevIL) 1.6.8pre Aug 12 2006
Version Number: 168
Adding engine post effects
--------------------------------------------------------

Initializing Sound Module
--------------------------------------------------------
Initializing OpenAL
Available OpenAL devices:
0. Generic Software on Speakers (Realtek High Definition Audio)(OpenAL default)
1. Generic Software on 1 - BenQ G2450H (AMD High Definition Audio Device)
Trying to open device 'Generic Software on Speakers (Realtek High Definition Audio)'... Success!
Number of mono sources: 32
Streaming setup: 4 Buffers x 262144 bytes each
--------------------------------------------------------

Initializing Game Module
--------------------------------------------------------
Adding engine updates
Initializing script functions
--------------------------------------------------------

User Initialization
--------------------------------------------------------
WARNING: No resources element found in 'FPProject/config/lang_main/english.lang'
Setting profile: 'Wapez' Path: 'C:\Users\Wilmer\Documents/Amnesia/FP_Main/Wapez/'
ERROR: Couldn't create script '/main/global.hps'
ERROR: Global script '/main/global.hps' could not be created!
-------- Loading map '06_cellar.map' ---------
WARNING: Texture 'C:/Program Files (x86)/Steam/steamapps/common/Amnesia The Dark Descent/static_objects/fp_stuff/ceiling_stone01/CeilingTexture02Diff.jpg' does not have a pow2 size!
WARNING: Texture 'C:/Program Files (x86)/Steam/steamapps/common/Amnesia The Dark Descent/static_objects/fp_stuff/ceiling_stone01/CeilingTexture02Normal.jpg' does not have a pow2 size!
WARNING: Texture 'C:/Program Files (x86)/Steam/steamapps/common/Amnesia The Dark Descent/static_objects/fp_stuff/ceiling_stone01/CeilingTexture02Spec.jpg' does not have a pow2 size!
WARNING: Texture 'C:/Program Files (x86)/Steam/steamapps/common/Amnesia The Dark Descent/static_objects/fp_stuff/floor_planks/Floor03Normal.jpg' does not have a pow2 size!
WARNING: Texture 'C:/Program Files (x86)/Steam/steamapps/common/Amnesia The Dark Descent/static_objects/fp_stuff/floor_planks/Floor03Spec.jpg' does not have a pow2 size!
Cache Loading: 2807 ms
ERROR: Couldn't create SoundEntity 'sounds/ambience/fp_metal_scraping_ambient.snt'
ERROR: Cannot find sound entity 'sounds/ambience/fp_metal_scraping_ambient.snt'
Entities: 2126 ms
Compilation: 40 ms
Total: 5130 ms
Meshes created: 451
Bodies created: 181
-------- Loading complete ---------
--------------------------------------------------------

Game Running
--------------------------------------------------------


Founder & Legally Accountable Publisher of Red Line Games.
Environment & Gameplay Designer and Scripter.
http://moddb.com/mods/in-lucys-eyes
(This post was last modified: 03-11-2014, 01:55 PM by Wapez.)
03-11-2014, 01:54 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: Script Crashes The Game

I think that the fp_metal scraping snt cannot be found. You should maybe make it again. And Ceiling texture 2 diff doesn't have a POW2 size (512x512, 1024x1024). Floor 03 too.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-11-2014, 02:34 PM
Find
Wapez Offline
Senior Member

Posts: 360
Threads: 37
Joined: Mar 2012
Reputation: 19
#3
RE: Script Crashes The Game

Those things are common minor issues in all my maps, but have no impact on gameplay. Does not affect the script or the loading.

Founder & Legally Accountable Publisher of Red Line Games.
Environment & Gameplay Designer and Scripter.
http://moddb.com/mods/in-lucys-eyes
(This post was last modified: 03-11-2014, 02:39 PM by Wapez.)
03-11-2014, 02:39 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#4
RE: Script Crashes The Game

What about the particle? Maybe it's a problem with the ps system itself.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-11-2014, 02:43 PM
Find
Wapez Offline
Senior Member

Posts: 360
Threads: 37
Joined: Mar 2012
Reputation: 19
#5
RE: Script Crashes The Game

The first PS plays before it crashes. I highly doubt that's the problem.

Founder & Legally Accountable Publisher of Red Line Games.
Environment & Gameplay Designer and Scripter.
http://moddb.com/mods/in-lucys-eyes
03-11-2014, 02:57 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#6
RE: Script Crashes The Game

(03-11-2014, 01:54 PM)Wapez Wrote: ERROR: Couldn't create script '/main/global.hps'
ERROR: Global script '/main/global.hps' could not be created!

This tells me there's another issue in your global.hps script. Since you used local variables for the script you posted as well as OnStart/OnEnter etc, that must mean it's from a map's .hps file. Perhaps post your global.hps?

03-11-2014, 03:12 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#7
RE: Script Crashes The Game

Take a look at line #6 below

PHP Code: (Select All)
1  void RunSteamFlow(int alEventCount){
2      int iSteamArea RandInt(16);
3      int RunCount alEventCount;
4      for(int i=1;i<=6;i++)
5          if(iSteamArea == GetLocalVarInt("iBlockedSteamArea_"+i)){
6              RunSteamFlow(RunCount);        <-- Calling itself
7          
}
8          else{
9              SteamEvent(iSteamArea);
10             SetLocalVarInt("iBlockedSteamArea_"+alEventCount11 iSteamArea);
12         }
13 

Shouldn't that be SteamEvent( RunCount ) ?
Cause right now, as you know, that could cause an infinite loop and crash the game.

03-11-2014, 03:15 PM
Find
Wapez Offline
Senior Member

Posts: 360
Threads: 37
Joined: Mar 2012
Reputation: 19
#8
RE: Script Crashes The Game

(03-11-2014, 03:15 PM)Amn Wrote: Take a look at line #6 below

PHP Code: (Select All)
1  void RunSteamFlow(int alEventCount){
2      int iSteamArea RandInt(16);
3      int RunCount alEventCount;
4      for(int i=1;i<=6;i++)
5          if(iSteamArea == GetLocalVarInt("iBlockedSteamArea_"+i)){
6              RunSteamFlow(RunCount);        <-- Calling itself
7          
}
8          else{
9              SteamEvent(iSteamArea);
10             SetLocalVarInt("iBlockedSteamArea_"+alEventCount11 iSteamArea);
12         }
13 

Shouldn't that be SteamEvent( RunCount ) ?
Cause right now, as you know, that could cause an infinite loop and crash the game.

No. That if-statement is only true if iSteamArea becomes the same number as it's been before, to prevent the SteamEvent function to apply to the same area several times during one SteamRun function. It simply generates a new value for the iSteamArea integer until it gets one that hasn't been used already.

I guess it ultimately could become an infinite loop, but it should eventually hit every number. Is this a real problem though?

(03-11-2014, 03:12 PM)Mudbill Wrote:
(03-11-2014, 01:54 PM)Wapez Wrote: ERROR: Couldn't create script '/main/global.hps'
ERROR: Global script '/main/global.hps' could not be created!

This tells me there's another issue in your global.hps script. Since you used local variables for the script you posted as well as OnStart/OnEnter etc, that must mean it's from a map's .hps file. Perhaps post your global.hps?

I don't have a global.hps yet, as one is not needed for the scripts I've been working on. It won't help this script either.

Founder & Legally Accountable Publisher of Red Line Games.
Environment & Gameplay Designer and Scripter.
http://moddb.com/mods/in-lucys-eyes
(This post was last modified: 03-11-2014, 03:41 PM by Wapez.)
03-11-2014, 03:40 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#9
RE: Script Crashes The Game

Hmm, well in that case. I haven't looked THAT much into the script itself if the error lies there, but perhaps you should try thinning out some of the warnings? Just brush up on some of the non-pow2 textures, add the <RESOURCES> tag in your lang, create an empty global.hps file, and investigate why that sound file is bugging you?

If all those warnings and errors were to be cleaned up, we'd know that they are not causing any issues.

03-11-2014, 09:09 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#10
RE: Script Crashes The Game

Well, you can check the Amnesia app in Task Manager when this freeze happens.
If CPU and Mem usage go up, there's a loop of doom in your code. And when it hits the limit, it crashes for sure.
I tested a smaller version of your code, and that's what happens, but I didn't get the crash cause I stopped it, I was afraid it could reboot my pc.

PHP Code: (Select All)
void a ()
{
    for (
int i=0;i<10;i++)
    {     
        if (
i==5) { a(); }
    }    


(This post was last modified: 03-12-2014, 01:24 AM by Daemian.)
03-12-2014, 01:22 AM
Find




Users browsing this thread: 1 Guest(s)