Jump to content
Sign in to follow this  
scajolly

Conditions, reducing server load, IF/WaitUntil, etc

Recommended Posts

In my MP mission are quite a lot of conditioned scripts. Some of these scripts are a condition "isNil "variable1"", others have "!triggeractivated trig AND !isNil "samson" AND (!alive dude OR ((damage model)>0.5)) etc" - meaning a lot of IFs and ANDs and ORs.

How often are these evaluations made? Is there any way I can forcibly delay evaluations to every so-and-so many frames, and/or are there ways of mimicking a "waitUntil" that will put less strain on the server? In particular when scripts are called, and these have extra conditions, I fear the workload may adversely affect server performance.

Share this post


Link to post
Share on other sites

Triggers are checked twice per second.

code in a waitUntil are checked every frame (many times per second).

If you are using triggers then there's not anything you can do. In scripts you can add a sleep command as Enders says.

waitUntil {sleep 3.0; !isNil "samson"} will be less demanding than just a waitUntil without the sleep.

Unless you have like a 100 triggers or 20 scripts running I wouldn't even worry a bit (depends also on the trigger and scripts ofc.).

Edited by Muzzleflash

Share this post


Link to post
Share on other sites

In fact you can express any WaitUntil statement by an equivalent While statement, by negating the condition in the Waituntil check. Where waituntil checks the condition on each frame (what in fact could eat lots of performance), using an equivalent while statement you are in control of the check interval.

One example:

  1. WaitUntil{not isNil "variable"}; // checks variable to be nil each frame
  2. While{isNil "variable"} do{sleep 1}; // checks variable not to be nil each second

The first variant pauses the script until variable is nil. The second variant throws the script into a sleep-loop, means, pauses the script, too, until variable is nil. So in its result, both variants are equivalent, i.e., have the same effect.

The only thing you may need to get familiar with (if you're new to propositional calculus) is to negate especially long statements using ANDs, ORs etc.

Keywords you should search for in the internet:

- Propositional calculus

- Truth table

- De Morgan's laws

Share this post


Link to post
Share on other sites
I would like to include this to the list Bon posted:

- Karnaugh map. Usable if you have very long statements.

I need to ask you, how exactly would one go about applying this to a scenario where a long and complex statement is made?

Share this post


Link to post
Share on other sites
I need to ask you, how exactly would one go about applying this to a scenario where a long and complex statement is made?

You can use Karnaugh map to simplify your statement.

Here is a tutorial of some sort: link

Share this post


Link to post
Share on other sites

@Bonn:

You can simply put the sleep into the waitUntil loop. I.e.: waitUntil {sleep 1;!isNil variable}

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×