Useful test script + notes

Discussion in 'General Modification' started by Sitra Achara, Apr 25, 2008.

Remove all ads!
  1. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    I've made my own little script for testing scripting/modding, and thought it might be useful to others, so here it is...

    Usage Instructions:

    1. Place it in the \scr folder
    2. Type in the console from t import *

    Primary Features

    1. Tons of teleport shortcuts.
    2. t() function - transfers you to Hommlet with hacked stats and equipment (including Temple robes and Eye of Flame cloaks).
    3. Speeds up your party's walking speed when the file is imported.*
    4. Loads up the other useful .py files from Co8, and some of those files' functions are replicated here for convenience.
    5. Many other functions, see inside file.
      • idall() - IDs all items.
      • hpav() - checks if a party member's HP is below average ( sum of class-specific HD/2 + level/2). If so, set it to the calculated average.
      • killkos() - applies massive damage to critters marked as KOS.

    Scripting Notes
    The notes file is just a handy reference I've compiled from other Co8 resources, summarizing things I've found useful while scripting/modding stuff. Could be useful to new modders as well.

    *Including summoned animals. If this irks you, delete the speedup() command execution at the start of the file (around line 14)
     

    Attached Files:

    • notes.txt
      File size:
      44.1 KB
      Views:
      8
    • t.rar
      File size:
      7.4 KB
      Views:
      3
    Last edited: Jun 25, 2010
  2. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,654
    Likes Received:
    352
    You'll have to change the last bit - the rotations are based on pi apparently ;) - but otherwise very useful :clap:
     
  3. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,029
    Likes Received:
    42
    Nice. :)

    Could this somehow be used to add a 'bedtime' movie for resting, like the old goldbox games used to do? Or even a 'getting busy with Jenelda' movie for when you get the fade to black thing in the brothel? Seriously, that could be cool and funny - maybe just creeky bedsprings audio over a black screen. Brothel patronage would be more satisfying that way.

    And if you could identify what type of environment you were resting in, you could play a campfire movie for the wilderness, some type of safe and snug (snoring carelessly) movie for inns, etc., etc. They would need only be a few seconds long so as to not irritate people with the delay. I've always found ToEE's magical insta-passage of time kind of unfullfilling, myself.
     
  4. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Don't forget the sheep :)
    Yeah, I think it could quite easily be added to the brothel fades. Dunno about the resting, though. My guess is that it'd require fiddling with the dll.
     
  5. Half Knight

    Half Knight Gibbering Mouther

    Joined:
    May 16, 2007
    Messages:
    2,148
    Likes Received:
    1
    I could provide those. :grin:
    Don't forget the "thump" noise of the bed's header against the wall ;)

    No problem with the whip noise, but i pass at the sheep's moan :eek:mg:


    Jokes aside, a quick secuence of small tgas could add some image...like the "loading" screen of many games :)
     
  6. rbc

    rbc Shoggoth

    Joined:
    Aug 3, 2007
    Messages:
    26
    Likes Received:
    0
    Yup! If you take "facing directly away from the camera" to mean "north", as Agetian's original table does, then the rotation value is compass heading in radians. That is,

    0 (exactly) = N
    0.785398163397... = NE
    1.57079632679... = E
    2.35619449019... = SE
    3.14159265359... = S
    3.92699081699... = SW
    4.71238898038... = W
    5.49778714378... = NW
    6.28318530718... = N again

    Of course, there is no possible need for that much precision -- but if you do want to be as exact as possible, then just add

    from math import pi

    to your scripts, and for east do obj.rotation = pi/2.

    you could also pick any number of degrees and use obj.rotation = degrees / 180 * pi; particularly useful in isometric view are 120 and 240 degrees (2*pi/3 and 4*pi/3 radians).

    I love math! :)


    But to comment on your script itself, I wonder about the effect of setting your ability scores above a hundred -- have you seen any problems with game play?
     
  7. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,654
    Likes Received:
    352
    Script.py will be changed in the next bug-fix I upload to reflect this, btw (not for a few days though).
    O yeah, this should be a priority :thumbsup: easy enough to move the speaker next to Jenelda and make them prone, too, for that blink of an eye - I did that with the Corporal in KotB (not sure if anyone noticed it). Touches like this really add to the game imho.
     
  8. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,029
    Likes Received:
    42
    How would you trigger the movies - via dilaogue?

    If you guys seriously think this would be a good idea we could do it, BUT ... I think there would have to be separate movies for each of the whores, because you can't cover each of their offerings with a generic movie and still have it be meaningful. For example, there would be far different things happening in Jenelda's room than in Charlotte's room. So we'd need 5 movies, one for Ophelia, Charlotte, Mary, the sisters, and Jenelda each. But then this leads to the questions: at what point does the payoff become overshadowed by the cost (added payload of large movie files to the download), and at what point does it become creepy? (One movie for eliciting laughs about the prostitutes is cool; 5 movies for detailing all their offerings might seem to enter sex offender territory.)
     
  9. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,654
    Likes Received:
    352
    Don't forget seperate Mary movies - sheep or rooster? ;)

    I guess to trigger it we use the game.fade thing or whatever triggers the movie when you pick up the golden skull (don't have the files in front of me atm).
     
  10. GuardianAngel82

    GuardianAngel82 Senior Member

    Joined:
    Oct 3, 2007
    Messages:
    3,481
    Likes Received:
    5
    Don't forget the marriages:
    Bedsprings and Melanie saying something perky
    Fruella complaining
    Or the Temple:
    (I already click thru the Curry Leaf "How about I join you..." conversation a dozen times each time I go through. Paida's husband should go KOS on my party when I walk in.)
     
  11. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    It just occured to me that what I said about playing movies on resting was wrong - you can very easily play the movies from the random_encounters.py file (by inserting the fade command in there). I just tested this myself while mucking with the file. Identifying the environment is as easy as typing if game.leader.area == whatever or game.leader.map == whatever, depending on what resolution you want (you could even script it to play a unique movie or sound while resting in Wonnilon's hideout corner by detecting the party's location - I used a similar technique to allow safe resting in there).

    Oh, and this is also a good oppurtunity to update the attached files in the first post :)

    edit: it looks like it only works for 'yellow tent' areas. Green tent and time passing areas don't call the functions inside the file, except for can_sleep (which isn't usable for this end - I've tried). And even in yellow tent areas, you need to be careful with it - playing the fade on a successful camping means playing the fade for every hour you rest, unless you switch it off with some flag or something.
    The easiest implementation (which I've tested first) is putting it inside encounter_exists, when one of the checks succeeds. I.e. when you get a sleep/wilderness encounter.
     
    Last edited: May 9, 2008
  12. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,029
    Likes Received:
    42
    Back onto this business for a moment -

    I realize now that in the case of resting or fornication there wouldn't even have to be a movie. The script seems to call a sound to play and a measured delay, so there's your movie right there. At the cost of a little.mp3 instead of a big old .bik.

    So would this involve nothing more than adding 'from t import *' to the whores' .py files, and then

    Code:
    {10}{Give it to me!}{Give it to me!}{}{}{}{}
    {11}{Here it comes!}{}{1}{game.fade(48800,[sex sounds code],0,5) }{0}{}
    to their dialogue files?

    On a related note, I'd also like to add a bard music sound to the Kent dialogue where he asks bards to play him a tune. Would doing so simply entail the same routine?
     
  13. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    You don't even need the t script file, game.fade is an elementary function of ToEE. (maybe "from toee import *", but that's probably already there in the script file)

    As for the dialogue, well, you'd probably want to avoid the fade in that case. I vaguely recall a command to play sound separately though...

    Ok, I've checked, the game apparently has several functions related to sound:
    sound()
    sound_local_loc()
    sound_local_obj()
    sound_local_xy()

    In case you're wondering, the way to find all these functions uses a Python command called dir(). It lists all the functions (methods, as they are called) associated with an object. In ToEE, there's an object called 'game', so typing dir(game) lists all the functions mentioned above and more. (dir itself is a core command of Python)
    Of course, the early Python savvy modders already did this - there's a thread somewhere with all these functions listed. The problem is usually figuring out what arguments are passed to the functions, but in this case I suspect it shouldn't be too hard. I've tested sound(), and it seems to respond to sound(sound_id), with sound_id being the sound file's ID as defined in one of the snd_something.mes files (you're probably familiar with these).
     
  14. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,029
    Likes Received:
    42
    Thanks, Sitra. I can't get any of those sound codes to work, unfortunately. :( I can get a sound to fire from the game.fade command, but as you say the fade part looks silly in the Kent scenario. Plus, the dialogue isn't supposed to end there, so Kent says "That was great!" while the sound is playing, and, I think the continued dialogue causes a hang in the fade (permanent black screen).

    All in all it's not worth it in the case of Kent (funny how it takes hours to come to a conclusion like that ;)), but we can certainly do it for the whores.
     
    Last edited: Jun 13, 2008
  15. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Ah, I know why it didn't work for you - I forgot to mention that you call the function similarly to game.fade:
    game.sound(#)

    Like I said, the functions I listed, much like fade() and fade_and_teleport(), are methods of the Python object called 'game' (functions belonging to the object, if you will). So in order to call them, you have to type game.function_name(...).

    But as you said, Kent's comment follows immediately after, before the sound finishes playing, and the fade breaks the dialogue... although, one possible solution to this is to end the dialogue when you pick the line that plays the sound, and add a time event set to fire a few seconds afterwards (or however long the sound plays) and re-initiate dialogue. Of course, the player could run away during that time or initiate combat or whatever, so this could be tricky to bulletproof properly... this is one case where playing a .bik movie with the fade command could actually be useful, to prevent the player from pulling script-breaking stunts like that.

    I've done something similar (a fade command from within dialogue, and adding a time event to resume dialogue after the fade ends) in my traders' mod, when the party searches the area and fails to find the traders due to not having the tracking feat. I can provide more details if you want.

    If you want to keep things simple, you could add an intermediate line -
    "Can you sing for me?"
    -{Sure thing boy}{...}{game.sound(song_id)}
    "[the boy listens to your singing, entranced]"
    -{[continue]}
    "Wow! that was awesome! yadda yadda..."

    Once again, the player could ruin it by clicking continue too soon, but that's their own fault, and if they do so they probably don't care anyway.
     
    Last edited: Jun 13, 2008
Our Host!