game.timevent_add problems

Discussion in 'General Modification' started by marc1967, Jul 27, 2016.

Remove all ads!
  1. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    I am getting unpredictable flakiness with the game.timevent_add() function, which I am using to refresh merchant inventory.

    If I only have one merchant everything always works fine, I've never had a problem once. But a problem arises when there are multiple merchants and more than one timed event happens at the same time. It can work fine for 5-10 times, but then eventually I enter the room and the events never fire, which means they never add another event and then merchant never refreshes his inventory for the rest of the game.

    I am currently solving this by having one merchant refresh the inventory for every merchant in the room, which works for smaller areas. But now I am looking to refresh a larger area with numerous merchants that are all spread out. And the multiple events firing all at once are gonna mess it up from what I have observed.

    1. Is this a known problem with timevent_add()? That is, multiple timed events firing at once causing conflicts?

    2. Should I do inventory refresh with a different system like saving a time stamp in a global variable and triggering the refresh from that instead?

    Looking to tap the knowledge pool here if anyone has experience with this.;)

    Having played with this all day, and reading old threads I've learned a lot about this I never knew, like the timed event only fires when you return to the map where it was added. This explains why I never got Scather one play through since I exited from the broken tower after rescuing Thrommel. And since I only went back to the Temple via the Well after that, the timed event never fired.
     
  2. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Yeah timed events aren't very reliable. If you want something bulletproof you should stick to the timestamp method (which also has the general advantage of operating independently of maps visited).

    I've been meaning to debug the systrm for Temple+ but it's hard to get reliable failures :p I'll try firing multiple events as you suggested and see what I find.
     
  3. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    Thanks, I was just looking for someone to tell me this. The method of setting a timed event within the function called by a previous timed event is neat, but always seems to me like a delicate flower waiting to break.

    If you have time, I noticed that in KOTB 1.0.1 you made a change to the Provisioner's respawn where the timed event method was abandoned, and also both his and the assistant's respawn are now both done in the Assistant's script. Was this releated to the problem of more than one event firing at once?
     
  4. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    I vaguely recall it would sometimes stop firing, possibly for that reason. The other issue was an accumulation of timed events over time, which would empty/respawn the inventory multiple times when entering the map and cause a massive map load time as the game progressed.

    I think you might also be able to get relevant error printouts if you run the ToEE with the tigdebug switch:
    https://github.com/GrognardsFromHell/DllDocumentation/wiki/Command-Line-Arguments
     
Our Host!