Okay SA, it looks like various pre-determined encounters new to v7 aren't working reliably as you suggested earlier, so ... How does your sceduling system in script-daemon work? I looked at the .py files you altered for Thrommel et al and 00439script_daemon and I have no idea what any of that means, so can you lay out a sample script for me here specifically? About all I can deduce is the stuff invoked from 00439 in the script where the PE is set, the setting of a time stamp, and the subsequent reference to it in 00439. Thanks!
Sure, let's analyze prince Thrommels scripting: Script Daemon Code: Code: ## Thrommel Reward Encounter - 2 weeks if tpsts('s_thrommel_reward', 14*24*60*60) == 1 and get_f('s_thrommel_reward_scheduled') == 0: set_f('s_thrommel_reward_scheduled') if game.global_flags[278] == 0 and not (3001 in game.encounter_queue): # ggf278 - have had Thrommel Reward encounter game.encounter_queue.append(3001) The heart of the code is the tpsts() function. tpsts() receives two inputs: 1. Time Stamp Name This is a string, which is why I use inverted commas; it has to match the time stamp recorded via record_time_stamp(). 2. Time (in seconds) tpsts stands for "Time Passed Since Time Stamp", which is kind of a misnomer because it doesn't return the time, but rather checks if enough time has passed. Basically, what it does, is to check the current Game Time, and see whether or not it exceeds the Time Stamp by the specified amount of time. If the specified Time Stamp hasn't been recorded yet, it returns 0. In Thrommel's case, I inserted a record_time_stamp('s_thrommel_reward') in his schedule_reward() function, in addition to the ordinary game.timevent_add. script_daemon.py then checks via tpsts() if enough time has passed every time you enter a new map and every time you rest. If two weeks have passed (two weeks = 14 days * 24 hours * 60 min * 60 sec) since the time stamp was recorded, it adds the encounter to the queue. I also added a flag called 's_thrommel_reward_scheduled' which signifies whether the encounter has been added to the queue already, to prevent it from being added more than once. The usage is straightforward - get_f() to check the value, set_f() to set the value to 1. You may substitute this for an ordinary global flag. As for a sample script, I'm not sure I can lay out anything substantially different than Thrommel's... Code: ## schedule an event for 24 hours from now if tpsts('[event name]', [time in seconds, e.g. 24*60*60 is 24 hours]) == 1 and get_f('[event has already fired flag]') == 0: set_f('[event has already fired flag]') [do stuff, e.g. game.encounter_queue.append(...)] Hope that helps, if you have any more questions feel free to ask...
Thanks ... it may be a bit before I try to implement it (trying to squash mundane bugs atm), but I'm sure I'll have more questions then.
Okay, I seem to have gotten this to work. :thumbsup: Couple questions though ... I notice in testing that it can take a significantly longer time than specified for the encounter to fire. I found this for both my own (set at 20 days) and Prince Thrommel's (set at 14 days). In Thrommel's case I rested for like 20 days and then ran around the worldmap and didn't get the encounter until maybe after four or five trips. In my case I rested for 21 days and ran around and never got the encounter, then tried again and rested for 28 days and ran around and finally got it after four or five trips. Is that WAI? (Note that this 'testing' is of the straight variety - get the thing scheduled, then head out immediately to pass time and start running around, etc.) From what I recall, the vanilla system would generally hit the moment your time had elapsed ... but then again 'generally' is pretty meaningless for ToEE. I noticed that the flags for 'Thrommel reward has occurred' et al in 00439 don't ever get set anywhere as far as I can tell. Should they, or am I missing something? (Would their not being set cause the encounter to get rescheduled in perpetuity?) Anyway good stuff - I hope this will solve all our timed event problems.
1. You're supposed to get the event scheduled as soon as you change maps. (re. resting, it seems that it is scripted to trigger the check in specific maps only - Temple & Moathouse, and even if it was more general, it only works on yellow tent areas) Did you get REs at all? And when does it appear in the queue? Note that it's possible to have no REs at all, even if there's one in the game.encounter_queue. It's also possible to modify the likelyhood of getting an RE, I think. IIRC there's a 1 in 20 chance for every step on the worldmap, and it's defined in check_random_encounter. As for your scheduled event, can you post the script file so I may take a look? 2. It's set inside random_encounter.py - check the predetermined_encounter function. It generally sets flag [ ID - 3000 + 277 ], which in Thrommel's case is 3001 - 3000 + 277 = 278.
Yes, occasionally I would get other REs. Interestingly the encounter number never appeared in the queue that I saw (though while I checked it several times I didn't check it every time). IIRC that's different from vanilla in that the encounter would appear in the queue the moment it was scheduled. Pertinent scripts are attached. I added the encounter for Ranth's bandits, which you may not be familar with yet. It gets set in Wilfrick's dialogue (file not included). I pretty much just copied one of your scripts and changed the particulars. Global variable 923 is only there to show which event was scheduled. (Delays vary based on alignment.) Also global flag 885 is checked based on my assumption that Thrommel and Co.'s were random flags set elsewhere, so it's never actually set. Although I guess based on what you said, flag 288 is being set, since it's encounter #3011. That flag's already taken (as are many in that range), so I'll have to change the encounter number as well as probably most of those other new ones in there.
You are definitely supposed to get a queue entry as soon as the timer's up. There's no other way to get a special encounter but to add to that queue. The timing system is just there to ensure it gets queued up. Tell me, when you test it, how do you go about it? Specifically, do you ever stop at Hommlet? I'm asking because the scripting assumes one of your PCs carries the san_new_map script from script_daemon. They get assigned that script in the Hommlet map. Does your test party go through there, or do you just teleport straight to Wilfrick and attempt to test it that way? Other than that, I have no idea why it wouldn't work. E.g. Thrommel works fine on my end. Also, I think you can save some space in the scheduling thing by calculating the time according to the var 923: (16 + game.global_vars[923])*24*60*60 Because it seems they all point to the same event...
I may well have gotten a queue entry when the timer was up and not noticed it, but I'm pretty certain the original system entered the encounter into the queue as soon as it was scheduled. (At least whenever I would test it, I'd do whatever routine to schedule the event and then check the queue via the console and it would be listed there. I guess I could be wrong ... sometimes it's hard to keep all this stuff straight.) Yes, I go to Hommlet. My normal routine is to travel between Hommlet, Nulb, and Verbobonc, and being as Hommlet auto-exists on the worldmap it's a guaranteed stop, evben if the others aren't. Does Thrommel's encounter fire for you the moment the time elapses, or is it just sometime after that, e.g. could be hours, days, or weeks? Yeah it's always the same event, different delays.
Try this. 1. Verify that the san_new_map script is used: go through game.party[x].scripts[38]. One of them should return 439. If it doesn't, you should visit one of the outdoor locations containing generic_spawner first. 2. Liberate Thrommel. Including his departure of course. 2a. Go to another map. (necessary to make sure it's not the ordinary game.timevent method that's scheduling it) 3. Pass 14 days. 4. Go to yet another map (you can either travel elsewhere, or just enter a building; just don't go back to where Thrommel departed from you). At this point, you should have the encounter in the queue, because these are the bare requirements. If you don't, then it's ToEE's fault, and I quit.
As you were typing that I was trying this (after resetting flag numbers and encounter numbers properly, etc.) Talked to Wilfrick to set Ranth's Bandits encounter in motion (scheduled for 20 days later). Looked at game.encounter_queue in console - no 3434 (its new number). Walked out to Verbo exterior. Looked at game.encounter_queue in console - no 3434. Traveled to Hommlet via worldmap. Looked at game.encounter_queue in console - no 3434. Entered Welcome Wench. Looked at game.encounter_queue in console - no 3434. Passed time for 22 days (assuming 20 days + 24 hours + 60 minutes + 60 seconds). Looked at game.encounter_queue in console - no 3434. Exited to Hommlet exterior. Looked at game.encounter_queue in console - 3434 now listed. Headed for Verbobonc and got waylayed by Ranth's bandits. Does that sound like it's working right? Seems good to me as long as it consistently happens that way.
Yep, that's how it should be. (keep in mind what I mentioned about the 1:20 chance for for an encounter for every map step, though; e.g. the Verbobonc - Hommlet route is made up of 20 steps, which means about 64% chance of encounter)