Results 1 to 20 of 20

Thread: Script Activation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: Script Activation

    <B>The puppet ruler script only runs if a gov4 is built on the map somewhere</b>

    And how do you think the game knows when a gov4 is present in a city? And how does the script know to not just endlessly spawn generals for a city?

    The answer to the first is that the background script is constantly checking every city on the map for a gov4.

    The answer to the second is that each city has its own uniquely named client ruler general, that the game "also" checks for in the script. For every city on every turn.

    The size of the client ruler portion of the background script in relation to the rest, is 5 megs of client ruler to 6 megs of the rest of the script.

    In the end, you get around a 50% increase in AI turn speeds by reducing the script size down, and the most convenient way to do it is to remove the client ruler portions that are checking every city on the map.

  2. #2
    EB annoying hornet Member bovi's Avatar
    Join Date
    Jan 2007
    Location
    Norway
    Posts
    11,796

    Default Re: Script Activation

    Code:
    monitor_event BuildingCompleted SettlementBuildingFinished = gov4
    and SettlementName G&#225;wj&#225;m~Sk&#225;ndz&#225;w&#225;rjoz
    Foot is right here, the code only checks when a building is made, not every turn. However, the sheer size of the puppet ruler script (roughly 175000 lines, 40% of the EB script, or 5MB, depending on how you want the figure) seems to cause some slowdown in itself.
    Last edited by bovi; 02-25-2008 at 02:06.

    Having problems getting EB2 to run? Try these solutions.
    ================
    I do NOT answer PM requests for help with EB. Ask in a new help thread in the tech help forum.
    ================
    I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking

  3. #3

    Default Re: Script Activation

    There's no way the script can know when to activate unless something in the game is checking for monitor conditions. The script is running all the time, but I don't know how fast it loops on itself.

    So, it doesn't trigger every turn unless the conditions are met, but game resources are still used up, for every city according to every monitor condition set, for every AI faction turn and human turn.

    As I've noticed with the background script that detects foreign governments in cities I have conquered for it to destroy, it doesn't take effect until some seconds have passed. It's not too much to extend that logic to a script almost twice as long, that the script must take game resources and time for it to run, even if the conditions in the script are not activated.

    Logically speaking, a script has to check every turn otherwise it won't know when the conditions have been met. And this applies to every AI faction, even if the script does not apply to them, but only apply to the human player's actions.

    Usually the code for the game engine takes care of the many variables and conditions, but that's hard coded for RTW in its source code, I believe.

  4. #4

    Default Re: Script Activation

    I take it you don't have any programming experience yourself? Specifically in object-oriented languages such as Java, JavaScript ?

    If, you have ...
    Spoiler Alert, click show to read: 
    Suppose you were to create your own custom 'events' which are very generic: such as BuildingCompleted. Now, each building could fire such an event and does so by notifying a 'Listener' - sending the listener an object containing : source (sender), type of event, additional data (settlement location etc. etc.). Then suppose you were to write a parser of a script. If that parser were to wrap monitor objects around specific conditions, and a monitor object were to have a listener attached and some method to catch events and subsequently evaluate it 'trigger' condition...

    You would have 199 objects rather than 199 times 21 evaluations. So at the cost of some serious RAM you gain a lot of speed. Depending how abusive your script is, this cost of RAM is not so serious at all -- but the run time execution of the code is far superior to that of a lineair evaluation of each scripted statement.
    - Tellos Athenaios
    CUF tool - XIDX - PACK tool - SD tool - EVT tool - EB Install Guide - How to track down loading CTD's - EB 1.1 Maps thread


    ὁ δ᾽ ἠλίθιος ὣσπερ πρόβατον βῆ βῆ λέγων βαδίζει” – Kratinos in Dionysalexandros.

  5. #5

    Default Re: Script Activation

    I never took the time to learn anything about any of the object oriented languages. While your point is valid, that parallel processing has advantages over serial processing, are you then forwarding the proposal that the slow down in AI turn speeds is due to increased usage of ram by the script being parsed?

  6. #6

    Default Re: Script Activation

    Well, not as much parsing (that's what's being done upon loading a campaign from a save...) but rather the simple fact that once created the objects just sit iddle for most of the time in the RAM. RAM that otherwise is not being used, hence the effective 'calculating' power of your PC is lowered because the schedule for the CPU is limitted to what the RAM can cope with.

    If say 200KB of RAM is being used for simply storing all the objects then your effective RAM drops by roughly 20% if you have only 1024MB to spare... Don't think 200KB is particularly heavy for an object oriented language - in fact the concept of object oriented languages dates to roughly the early 80's but the resources required to implement it, meant that only in the later 90's (512 MB of RAM being available) such languages really took off. And Object oriented databases (webdatabases revolving around XML records for instance) are still a thing of the future: for now all major vendors simply assume you use the Relational model, though support for XML is available... Reason? The comparatively heavy memory demand of anything object oriented, doubly so with databases.

    In return you get better code: that is, easier to maintain especially when bugfixing comes into play. (You get the ability to program nearly everything only once in an entire program, and throughout the rest of your code you can simply refer back to the code you need...)
    - Tellos Athenaios
    CUF tool - XIDX - PACK tool - SD tool - EVT tool - EB Install Guide - How to track down loading CTD's - EB 1.1 Maps thread


    ὁ δ᾽ ἠλίθιος ὣσπερ πρόβατον βῆ βῆ λέγων βαδίζει” – Kratinos in Dionysalexandros.

  7. #7
    Ming the Merciless is my idol Senior Member Watchman's Avatar
    Join Date
    Aug 2004
    Location
    Helsinki, Finland
    Posts
    7,967

    Default Re: Script Activation


    ...I dun get it. I'll just assume you have succesfully reversed the polarity on it and be glad I don't need to understand that stuff.
    "Let us remember that there are multiple theories of Intelligent Design. I and many others around the world are of the strong belief that the universe was created by a Flying Spaghetti Monster. --- Proof of the existence of the FSM, if needed, can be found in the recent uptick of global warming, earthquakes, hurricanes, and other natural disasters. Apparently His Pastaness is to be worshipped in full pirate regalia. The decline in worldwide pirate population over the past 200 years directly corresponds with the increase in global temperature. Here is a graph to illustrate the point."

    -Church of the Flying Spaghetti Monster

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO