Explain this for me: set_priority();

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Zgryt
New User
Posts: 19
Joined: Wed Sep 20, 2006 11:53 am

Explain this for me: set_priority();

Post by Zgryt »

How this should be for Ai scripts?
And what will happen when Ai script will be running on set_priority(1)...
And how exactly work this command, what
Docs wrote: Explanation
the priority of a script is how many instructions it executes before switching to another script.
default script priority is 1.
exactly mean?
Shinigami
Former Developer
Posts: 308
Joined: Mon Jan 30, 2006 9:28 am

Re: Explain this for me: set_priority();

Post by Shinigami »

Zgryt wrote:
Docs wrote: Explanation
the priority of a script is how many instructions it executes before switching to another script.
exactly mean?
that means exactly what is written there... if it's set to 1 it will run 1 instruction of this script and than switch to another script. if it's set to 50 it will run 50 insctructions and then switch to another script.

so, if u set, lets say, 1000000, your script will get executed very fast but everything else will stop. e.g. if u don't use sleep or wait_for_event or run_script_to_completition or something like that, your script with priority 100000 will block all other scripts.

use scripts use 1 by default. textcmds use 100 by default. AI-scripts do most time nothing (just waiting for next event), but if u want that they should react very fast, u should choose a higher priority...

Shinigami
Zgryt
New User
Posts: 19
Joined: Wed Sep 20, 2006 11:53 am

Post by Zgryt »

I ask because i had a problem with high sysload... When all Ai had priority between 1 to 10 sysload was between 50%-100%. When i changed the priority to 50 in all Ai scripts, sysload is not higher then 15%. Thats why i couldn't understand how its works...
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

set_priority works in the reverse direction in the case of POL. A priority 1 script isn't the first one looked at. Instead it just says how many instructions will be processed before it passes to the next script. POL only does one instruction at a time. It seems like it does everything at once because say you have a bunch of scripts priority 1, POL will do 1 instruction from the first script, then switch and do 1 instruction from the next script, and so on until it has done every script, then it will go back to the first script and repeat this process. Setting the priority number higher like 50 in a problematic script will actually increase the problems because now POL will do 50 instructions in that script before switching which takes attention away from the other scripts.

What I can suggest in a situation where your shard is using a lot of CPU is to make a www page that evaluates polcore().script_profiles. Make it list everything available so you can see how many instructions each script is doing and which ones are running the highest percentage of instructions. You can then go into these scripts and try to make them more efficient or increase sleeps if they can be without causing a problem. I've done this method with my entire scriptbase and dropped it from averaging about 5 million instructions per minute to well under 1 million. That also dropped CPU from a constant 20% to a constant 0-1%.
DeiviD
Expert Poster
Posts: 79
Joined: Mon Jun 19, 2006 4:48 pm

Post by DeiviD »

yeah, what cwo said :) theres a long_running_scripts available at the 095 distro i think, just put it at your www folder and open it via your browser.

my shard used to go to around 100% sysload with 50 players on, so i checked that longrunningscripts stuff and saw medcheck (meditation checking and mana regeneration) was what used the CPU 89% of the time. i tweaked it, removed a lot of useless stuff and now, with around 80 players on where usually at 1 to 5% sysload.

damn great change i tell ya
Post Reply