The game.time Method and Making Reliable Timed Events

Discussion in 'General Modification' started by Cerulean the Blue, Dec 28, 2006.

Remove all ads!
  1. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    Last edited: Dec 28, 2006
  2. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    4,925
    Likes Received:
    217
    Cool stuff there Blue, that woodcutter's time event has never triggered propperly for me, I'm glad you got it figured out. Good work guys. :)
     
  3. Elhoim

    Elhoim Member

    Joined:
    Dec 23, 2006
    Messages:
    13
    Likes Received:
    0
    Blue, do you think it´s possible to unify the various time feedbacks? I mean, in the main GUI it tells you the time elapsed since you started, and it´s like that in the rumors tab, but in the quest tab they are by day of the month and it´s kinda confusing having day 1 in one and day 15 in the other.

    Thanks!
     
  4. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    The dates and times in the GUI and the logbook are functions of the game engine, i.e. it would take a major dll hack to change them. So no, that is not going to happen.

    I've added modified versions of Tillahi's and Sargen's scripts to the Timed Event post.

    If I could get people to test these out it would be really helpful. :)
     
    Last edited: Dec 28, 2006
  5. Shiningted

    Shiningted I want my goat back Global Moderator

    Joined:
    Oct 23, 2004
    Messages:
    12,272
    Likes Received:
    207
    Good work Blue :clap: I was going to use nested time thingy's like this for KotB, good to see someone making it easy to do.
     
  6. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,049
    Likes Received:
    223
    Nifty :) I've been waiting for this. I'll test as soon as I can (which could be a while, unfortunately).
     
  7. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    I've Incorporated my Long Interval Timed Event code into an importable module so that it can be used with a call much similar to that of game.timevent_add.

    The following is from the documentation included in TimedEvent.py.
    Code:
      LONG DURATION TIMED EVENT METHOD by Cerulean the Blue
    
    You must put these in the global namespace of your function:
    
    import _include
    from co8Util.TimedEvent import *
    
    Furthermore "import _include" (without quotes) must be included
    in the namespace of utilities.py for the method to function across
    saves and loads.  Without this the game will not be able to import
    co8Util.TimedEvent at startup and the save will be deemed corrupt.
    
    Call form:
    
    timedEventAdd(<function name>, (<arguments>), <interval>, stopFlags=[<stopFlags>], stopVars=[<stopVars>], stopQuests=[<stopQuests>])
    
    <function name> - Name of the function you want executed after 
    the interval.  The function must be in the same module as the 
    call, or imported to the module.
    
    <arguments> - The arguments you want passed to the function 
    separated by comas, i.e. "attachee, triggerer".
    
    <interval> - An int specifying the delay, in hours, till you 
    want the function to execute.
    
    <stopFlags> - OPTIONAL - The flag numbers of global flags that 
    should stop the function from executing separated by comas.  
    If having the flag set should cause the stop just list the flag 
    number.  If not having the flag set should cause the stop, put 
    the flag number and 0 separated by a coma in parenthesis, i.e. (85,0).  
    Any number of stop flags can be passed.
    Example: [58, (51,0)]
    
    <stopVars> - OPTIONAL - Like stopFlags, but for global variables.  
    Put each number of the global variable and the value that should 
    cause the stop, separated by a coma,in parenthesis.  Any number 
    of variables can be listed.
    Example:  [(21, 4), (36, 10)]
    
    <stopQuests> - OPTIONAL - Like stopFlags, but for quests.  Put each 
    quest number and the quest state that should cause the stop, separated 
    by a coma, in parenthesis.  Any number of quests can be listed.
    Example:  [(21, qs_accepted), (101, qs_completed), (34, qs_botched)]
    
    Sample Calls:
    
    2 arguments, 10 hour delay, no stops:  
    timedEventAdd(spawn, (attachee, triggerer), 10)
    
    No arguments, 100 hour delay, flag stops:  
    timedEventAdd(spawn, (), 100, stopFlags=[58, (51,0)])
    
    No arguments, 34 hour delay, variable stops:  
    timedEventAdd(spawn, (), 34, stopVars=[(21,4)])
    
    3 arguments, 56 hour delay, flag and quest stops:  
    timedEventAdd(give_reward, (x,y,z), 56, stopFlags=[82, 132], stopQuests=[(22, qs_completed)])
    
    Logging has been left in to facilitate debugging.  
    The log, named LOG_co8Util.TimedEvent.log, will be 
    in the modules folder of the module being run.
    As you can see timedEventAdd is very similar to game.timevent_add, and can be called virtually identically. It has the added functionality of optionally specifying flags, variables and quest states that will stop the event from happening. These are checked when the delay time has passed, so the timevent sequence always runs to completion. Another difference is that timedEventAdd works with the delay in hours, not milliseconds like timevent_add. Also, timeEventAdd counts time spent resting or passing time toward the delay passing, which timevent_add often does not.

    I recommend using timedEventAdd for delays of more than 24 hours. Use timevent_add for delays of 24 hours or less, unless you absolutely need the added functionality.

    Attached is TimeEvent.py, utilities.py, and a sample script to demonstrate the method. TimeEvent.py should go into the data\scr\co8Util folder. The other two go into the data\scr folder. The sample script also has some documentation of the method included inside it.
     

    Attached Files:

    Last edited: Jan 2, 2007
  8. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    The Woodcutter's, Thrommel's, Tillahi's, and Sargen's scripts altered to use the method posted above. These go in the data\scr folder.
     

    Attached Files:

  9. Zebedee

    Zebedee Veteran Member Veteran

    Joined:
    Apr 2, 2005
    Messages:
    1,755
    Likes Received:
    0
    Can I confirm whether or not the files listed above were added to the CMF?
     
  10. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    4,925
    Likes Received:
    217
    Yes Zebedee, of course you can. ;)

    Actually it is in the latest CMF patch (version 5.0.4 composed by yours truely) if you don't believe me it says so here. :p
     
  11. Zebedee

    Zebedee Veteran Member Veteran

    Joined:
    Apr 2, 2005
    Messages:
    1,755
    Likes Received:
    0
    :dance:

    Always good to make sure there are no misunderstandings and people getting the wrong files in the wrong order. :yes:
     
Our Host!