The How-To Thread

Discussion in 'General Modification' started by Gaear, Feb 24, 2008.

Remove all ads!
  1. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,038
    Likes Received:
    42
    I know we have the 'Well Whaddya Know' thread already, but that's not a thread for discussion. Let's use this for Q&A on how to do stuff, as a lot of ToEE modding has the appearance of being very 'secret' for whatever reason.

    I will start off:

    • Do we have unlimited availability for new flags? I've been referring to Sitra Achara's flags and variables list lately, which has large stretches of blank entries in it. So even if they aren't exactly 'unlimited,' are there a lot available? Also, can we please post and maintain a frequently updated and complete flags and variables list somewhere? It's kind of stupid that people like me should have to guess at this stuff, particularly given that all I've wanted to do (until now possibly, anyway) is look at it.
    • How do you add new flags? I don't really want to do this, but sometimes there seems to be little alternative, particularly if you want to avoid that foolish repeat dialogue stuff that makes ToEE look so amateurish: (one day in Hommlet) - "Burne, I've cracked the case of the ToEE! Can I have a quest?" / (the next day) - "Burne, I've cracked the case of the ToEE! Can I have a quest?"
    • Is there some way other than using flags to make a dialogue option appear only once?
     
  2. Zebedee

    Zebedee Veteran Member Veteran

    Joined:
    Apr 2, 2005
    Messages:
    1,755
    Likes Received:
    0
    You add new flags by making them up :)

    Honestly - just make sure it doesn't conflict with a current flag and set the flag to it's required state when you want that state/event to be recorded and then reset it when you want it to change.

    Blue did once comment to me to use variables instead of flags as there is a limit to how many flags we can use without things going ditzy. From what I recall, flags have 2 states (yes/no) and variables can have 8 (or more?) but use the same amount of game memory. So one variable can be used a lot more often and flexibly than a simple flag. Perhaps Blue can confirm or clarify this should he be passing through at some point.
     
  3. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,038
    Likes Received:
    42
    So I need only conjure them in my head and they'll work? :blink:

    Maybe I should start small: what file(s) in ToEE is information about flags stored in?
     
  4. Zebedee

    Zebedee Veteran Member Veteran

    Joined:
    Apr 2, 2005
    Messages:
    1,755
    Likes Received:
    0
    Yes. Think of a number (any number) and as long as it doesn't conflict with a currently existing flag, and you've used the right syntax in the .py or the .dlg, that flag then magically exists. (NB: there may be a limit to the maximum number you can use - I've never tested that part properly - never needed to as we're nowhere near above 200 atm ...)

    They )or their current state to be precise) are stored in the game memory (whichever file that is or if such a file exists...). Hence Blue mentioning there is finite space for them and variables. If you want to track down which flags have been used, you'll have to trawl through the /scr and /dlg files.
     
    Last edited: Feb 25, 2008
  5. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    The flags have a cap of 999. Lots have been used: but not many variables. Variables are great for advancing simple story states. Variables have in some cases been used to store quite large numbers - certainly 4 digits (thousands).
    Like I do for KotB? :cool:

    For something like Burne, you should be using the personal or individual flags. As you say, there is no point putting a global flag on something that is not a global event: Burne's own personal flags would do the trick nicely.

    Luckily (or not) Burne already uses some thanks to Blue's "get him to join without breaking his inventory" mod. Have a look at Burne's script:

    Code:
    def set_switch_flag( attachee, value ): # Sets switch flag in object field where it is stored.  Set to 1 in dialog if NPC is joining party.  Set to 0 in Switch_NPC after NPC has been added to party.
    	attachee.obj_set_int( obj_f_npc_pad_i_5, value )
    	return attachee.obj_get_int( obj_f_npc_pad_i_5 )
    So you can't use flag 5, its busy. But you can use 3 and 4. In a dlg file they will look like this:

    {600}{So I have a long boring story to tell. Have you heard it before?}{So I have a long boring story to tell. Have you heard it before?}{}{}{}{}
    {601}{Yes.}{}{1}{npc.obj_get_int( obj_f_npc_pad_i_3 ) != 0}{0}{}
    {602}{No.}{}{1}{npc.obj_get_int( obj_f_npc_pad_i_3 ) == 0}{610}{}

    {610}{Once upon a time...}{Once upon a time...}{}{}{}{npc.obj_set_int( obj_f_npc_pad_i_3, 1 )}

    This is all outlined in my Flags Tutorial Part 2.

    One minor hitch with Burne - there's two of him, one that joins, one that stands around and sells you stuff. So be aware of that: setting individual flags on one doesn't set them on the other (because they are individual to each mob, obviously). So you'd want to use this for dialogue that is exclusive to in-party or not-in-party Burne, not common to both, or take it into account some other way.
     
    Last edited: Feb 25, 2008
  6. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,038
    Likes Received:
    42
    Precisely.

    Thanks for the rest. Am I correct in assuming then that there is no master file in ToEE called 'flags' or something like that that archives flags and variables and processes them in some way?
     
  7. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    Alas, no. Don't we wish. The engine processes most things on the fly (it seems to me), and the game writes that stuff into the saves, I think.
     
  8. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,038
    Likes Received:
    42
    Question: what's the difference between 'if' and 'elif' as used in .py files?

    We typically see blocks of code starting with an 'if' line (one or more), followed by one or more 'elif' lines, and typically ending with an 'else' line. I assume the first 'if' line means to check that code first, and the 'else' line means that if nothing else in the code is true, do this, but I've never been able to determine any difference between a midrange line starting with 'if' or 'elif.'
     
  9. krunch

    krunch moving on in life

    Joined:
    Aug 9, 2005
    Messages:
    3,280
    Likes Received:
    0
    if = 'if'

    elif = 'else if'

    It is similar (related) to an if-then argument in basic, turbo pascal, etc.

    The first 'if' in the line of a script is denoted as 'if' whereas each following 'if' after that in the same routine of the script is an 'else if'.

    Here is what takes place when something has 3 possibilities.
    The 1st possibility is an if, the 2nd possibility is an elif, the 3rd possibility is an elif and, then, a return is performed to complete the task.

    if condition do -> else if condition do -> else if condition do -> return
     
    Last edited: Mar 7, 2008
  10. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,038
    Likes Received:
    42
    Okay, so are you saying that an 'elif' is the same as an 'if' that is not in the first line of code?
     
  11. Cujo

    Cujo Mad Hatter Veteran

    Joined:
    Apr 4, 2005
    Messages:
    3,636
    Likes Received:
    1
    yes, eg

    Code:
    Conditional example 4 - if / elif / else
     
    faren = input("Enter a temperature ") * 9.0 / 5 + 32
    print "That degrees converts to",faren
    if faren > 212:
        print "Steam"
    elif faren > 112:
        print "Very Hot Water"
    elif faren > 32:
        print "Water"
    else:
        print "Ice"
    print "Program completed"
     
  12. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    Since I am easily confused by jargon and didn't understand those explanations, I will add my own:

    A group of 'elif's will function in series, a group of 'if's will function in parallel, to give it a circuit-board explanation. Elif's will seek out the 'correct' one to apply - if's will apply each correct one. Cujo gave a good example of 'elif's, here is an example of 'if's from Liv's new AI thing:
    Code:
    	for obj in game.party[0].group_list():	## find number of enemy and distances
    		if (obj.distance_to(npc) <= 5 and critter_is_unconscious(obj) == 0 and obj.stat_level_get( stat_hp_current ) >= 1 and (not obj.d20_query(Q_Prone)) and (not obj.d20_query(Q_CoupDeGrace))):
    			enemyclose = enemyclose + 1
    
    		if (obj.distance_to(npc) <= 5 and critter_is_unconscious(obj) == 0 and obj.stat_level_get( stat_hp_current ) >= 10 and (not obj.d20_query(Q_Prone)) and (not obj.d20_query(Q_CoupDeGrace)) and (obj.stat_level_get(stat_level_sorcerer) >= 2 or obj.stat_level_get(stat_level_wizard) >= 2) ):
    			casterclose = casterclose + 1
    
    		if (obj.distance_to(npc) <= 10 and obj.distance_to(npc) >= 6 and critter_is_unconscious(obj) == 0 and obj.stat_level_get( stat_hp_current ) >= 1 and (not obj.d20_query(Q_Prone)) and (not obj.d20_query(Q_CoupDeGrace))):
    			enemymedium = enemymedium + 1
    
    		if (obj.distance_to(npc) <= 25 and obj.distance_to(npc) >= 11 and critter_is_unconscious(obj) == 0 and obj.stat_level_get( stat_hp_current ) >= 1 and (not obj.d20_query(Q_Prone)) and (not obj.d20_query(Q_CoupDeGrace))):
    			enemyfar = enemyfar + 1
    
    		if (obj.distance_to(npc) <= 10 and obj.d20_query(Q_Prone) and obj.stat_level_get( stat_hp_current ) >= 1 and (not obj.d20_query(Q_Helpless))):
    			obj.float_mesfile_line( 'mes\\skill_ui.mes', 106 )
    			prone = prone + 1
    
    		if (obj.distance_to(npc) <= 5 and obj.d20_query(Q_Helpless) and obj.stat_level_get( stat_hp_current ) >= 0):
    			helpless = helpless + 1
    			obj.float_mesfile_line( 'mes\\skill_ui.mes', 107 )
    
    		if (obj.distance_to(npc) <= 5 and obj.stat_level_get( stat_hp_current ) <= -1 and (not obj.d20_query(Q_Dead))):
    			dying = dying + 1
    			obj.float_mesfile_line( 'mes\\skill_ui.mes', 108 )
    Each condition advances a variable by one: more than one condition may be true (an enemy may be close, AND prone, AND helpless, AND dying). It builds up a large picture of what is going, rather than a series of 'elif's which would grab the first 'true' response then end.
     
  13. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,038
    Likes Received:
    42
    Thanks, Ted. Precisely the answer I was looking for. :)
     
  14. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,038
    Likes Received:
    42
    Q1: Are there any known issues with editing the invensource.mes file? I've read (in mostly older threads) that it's one nasty bastard of a file. I aspire to make only minor changes to it: add a hat, subtract a jacket, etc., for cosmetic reasons.

    Q2: What's the current status of invensource.mes as it may relate to shopkeepers' inventories? It seemed to be suggested in places that this was modified somehow so that invensource.mes doesn't control that any longer, or that .mob files always controlled that. Or something. True, or a horrible lie? I would like, for example, to clear out Jinnerth's inventory of cloaks so that he's not wearing them, but if I do that will he no longer offer them for sale?

    I haven't had any issues changing inventory for items NPCs are wearing, but I don't want to screw over shopkeepers' inventories.

    There's a lot of confusing info out there, such as there being separate prototypes for shopkeeper NPCs (as opposed to their adventuring counterparts), inventory refresh issues (some do, some don't), etc. Any light you may be able to shine on this matter would be appreciated. :)

    [edit]

    Okay, I found the shop inventories. Sorry, I was suffering from the 'wall of text' stupefication effect. :blush:

    It appears that the situation, as I read elsewhere, is still that adding items to invensource.mes shop lists has no effect on in-game shop inventories. But you can swap out personal inventory items to your heart's content.
     
    Last edited: Apr 15, 2008
  15. Salk

    Salk Established Member

    Joined:
    Jan 2, 2006
    Messages:
    258
    Likes Received:
    0
    I trust you're gonna do nice spring cleanings here, Gaear!

    Thanks for your work on this!
     
Our Host!