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
Lag issue when triggering scripts
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#1
Lag issue when triggering scripts

Hey!

I need some hints on how to reduce or remove the lag when the player is triggering scripts. The lag makes the player know they are to expect something, which I do not like hehe.

I have not read so much about the map_cache files, but if I were to play through the entire mod, and then save the cache files it creates when releasing the mod, will it make the scripts lag less, or will it just bug out?

Thanks!

Creator of The Dark Treasure.
(This post was last modified: 05-30-2013, 07:54 PM by Linus Ågren.)
05-25-2013, 06:14 PM
Website Find
ExpectedIdentifier Offline
Member

Posts: 234
Threads: 10
Joined: Sep 2012
Reputation: 11
#2
RE: Lag issue when triggering scripts

(05-25-2013, 06:14 PM)junkfood2121 Wrote: Hey!

I need some hints on how to reduce or remove the lag when the player is triggering scripts. The lag makes the player know they are to expect something, which I do not like hehe.

I have not read so much about the map_cache files, but if I were to play through the entire mod, and then save the cache files it creates when releasing the mod, will it make the scripts lag less, or will it just bug out?

Thanks!

If you're playing sounds and using particle systems when the event is triggered, you need to preload them when entering the map Smile do this by using something like this:

void OnEnter()
{
PreloadParticleSystem("particle.ps");
PreloadSound("sound");
}
(This post was last modified: 05-25-2013, 06:30 PM by ExpectedIdentifier.)
05-25-2013, 06:28 PM
Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#3
RE: Lag issue when triggering scripts

(05-25-2013, 06:28 PM)sonataarctica Wrote:
(05-25-2013, 06:14 PM)junkfood2121 Wrote: Hey!

I need some hints on how to reduce or remove the lag when the player is triggering scripts. The lag makes the player know they are to expect something, which I do not like hehe.

I have not read so much about the map_cache files, but if I were to play through the entire mod, and then save the cache files it creates when releasing the mod, will it make the scripts lag less, or will it just bug out?

Thanks!

If you're playing sounds and using particle systems when the event is triggered, you need to preload them when entering the map Smile do this by using something like this:

void OnEnter()
{
PreloadParticleSystem("particle.ps");
PreloadSound("sound");
}

Thanks for the reply!
I have always wondered what the preload scripts are useful for. Thanks for clearing that one out for me!

Though, the most of the lag comes from enabling / disabling entities. I have made quite a few custom wall / ceiling entities for breaking purposes.

Creator of The Dark Treasure.
05-26-2013, 08:42 AM
Website Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#4
RE: Lag issue when triggering scripts

Bump.
Still haven't found any working approaches.

Creator of The Dark Treasure.
05-29-2013, 04:46 PM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#5
RE: Lag issue when triggering scripts

You can make an extra sound or something falling, like it seemed a cheap scare. Of course, you can say too at the beggining of the story that there are occasional lag-spikes (telling lies and stuff), but... you catched me with this one, junkfood Big Grin

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
05-29-2013, 05:22 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#6
RE: Lag issue when triggering scripts

Can we see the script? If you've got a particularly large loop running with a lot of function calls that could cause it, i haven't personally encountered any noticeable lag enabling/disabling entities

05-29-2013, 06:01 PM
Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#7
RE: Lag issue when triggering scripts

I solved one of the major lag problems. The AutoSave(); caused the lag.

However, the problem still remains when making changes with slightly larger entities, such as a roof breaking script seen below:

PHP Code: (Select All)
void RoofScare(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("default_entity_1"false);
    
SetEntityActive("default_entity_2"true);
    
SetEntityActive("wooden_board02_*"true);
    
SetEntityActive("wooden_board03_*"true);

    
CreateParticleSystemAtEntity("""ps_dust_elevator_crash.ps""Area_BreakDust"false);
    
    
PlaySoundAtEntity("""break_wood.snt""Area_BreakDust"0.0ffalse);


Is there anyway to preload specific entities or anyway to make it lag less when activating them?

Creator of The Dark Treasure.
05-30-2013, 07:11 PM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#8
RE: Lag issue when triggering scripts

This might help you:

http://wiki.frictionalgames.com/hpl2/amn...erformance


Also, are you sure this lag happens with everyone? The problem might be your computer.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
05-30-2013, 07:31 PM
Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#9
RE: Lag issue when triggering scripts

(05-30-2013, 07:31 PM)The chaser Wrote: This might help you:

http://wiki.frictionalgames.com/hpl2/amn...erformance


Also, are you sure this lag happens with everyone? The problem might be your computer.
I have watched the playthroughs people made in the demo, and the lag appears to be there for most of the people, but indeed it has different length on each respective video.

I suppose I will release the mod first, and then release a patch if I find a patch.

Creator of The Dark Treasure.
05-30-2013, 07:54 PM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#10
RE: Lag issue when triggering scripts

Oh, I'm sorry then. You could try to make something different though: Why must everything go together? You can put timers to distribute the falling ceiling, like this:



void RoofScare(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("default_entity_1", false);

CreateParticleSystemAtEntity("", "ps_dust_elevator_crash.ps", "Area_BreakDust", false);

PlaySoundAtEntity("", "break_wood.snt", "Area_BreakDust", 0.0f, false);

AddTimer("", 0.8, "Do");

}

void Do (string &in asTimer)
{
SetEntityActive("default_entity_2", true);
SetEntityActive("wooden_board02_*", true);
SetEntityActive("wooden_board03_*", true);
}

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
(This post was last modified: 05-30-2013, 09:25 PM by The chaser.)
05-30-2013, 09:24 PM
Find




Users browsing this thread: 1 Guest(s)