Perfect InnKeeper scripts and dialogue

Discussion in 'Modding and Scripting Support' started by DarkUnderlord, Nov 21, 2001.

Remove all ads!
Support Terra-Arcanum:

GOG.com

PayPal - The safer, easier way to pay online!
  1. DarkUnderlord

    DarkUnderlord Administrator Staff Member

    Messages:
    4,315
    Likes Received:
    5
    Joined:
    Nov 10, 2001
    Here's a *perfect* (well, as perfect as I think I can get) InnKeeper script and dialog:

    NOTE: The numbers of the scripts and dialog are just the way I ended up having them. If you change the script and dialog numbers, make sure you change anything that references them as well. (ie, the script you tie to the NPC InnKeeper and the script you tie to his beds.)

    -----------------------
    00003InnKeeper.dlg
    -----------------------
    {1}{Welcome to the Inn sir. How may I help you?}{Welcome to the Inn madame. How may I help you?}{}{}{}{}
    // Lines 2 & 3 only seen if PC hasn't rented a room here.
    {2}{I'd like to rent a room please.}{}{5}{gf11 0, gf12 0}{20}{}
    {3}{We wunna get room.}{}{-4}{gf11 0, gf12 0}{20}{}
    // These lines only seen if PC has already rented a room here.
    {4}{I'd like to rent a room please.}{}{5}{gf11 1}{60}{}
    {5}{We wunna get room.}{}{-4}{gf11 1}{60}{}
    {6}{I'd like to rent a room please.}{}{5}{gf12 1}{70}{}
    {7}{We wunna get room.}{}{-4}{gf12 1}{70}{}
    {8}{E:}{}{1}{}{0}{}

    {20}{Certainly sir. How long are you expecting to stay?}{Certainly sir. How long are you expecting to stay?}{}{}{}{}
    {21}{Just the one night please.}{}{5}{}{30}{}
    {22}{Won nite pleese.}{}{-4}{}{30}{}
    {23}{Better make that a week, I'll be in town for a while.}{}{5}{}{40}{}
    {24}{Uhh.. Me need hole week.}{}{-4}{}{40}{}
    {25}{F:}{}{1}{}{0}{}

    {30}{Well then sir, we have two rooms available for rent tonight. One, our pride and joy, is a first class room with all the finery! At only 50 coin for one nights' stay it is certainly worth seeing. Our second room is our... Er... How shall I put this? Oh yes, it is our 'discount' room for those who are lacking in coin. A modest sum of 20 coin will rent you this room for the night. Now then sir, which room would you like to rent?}{Well then madame, we have two rooms available for rent tonight. One, our pride and joy, is a first class room with all the finery! At only 50 coin for one nights' stay it is certainly worth seeing. Our second room is our... Er... How shall I put this? Oh yes, it is our 'discount' room for those who are lacking in coin. A modest sum of 20 coin will rent you this room for the night. Now then madame, which room would you like to rent?}{}{}{}{}
    {31}{Give me first class all the way! [Pay 50 coin]}{}{5}{$$50}{-9}{$$-50, lc0 23, gf12 1}
    {32}{Me wan' good room! [Pay 50 coin]}{}{-4}{}{-9}{$$-50, lc0 23, gf12 1}
    {33}{I'd better take the discount one. [Pay 20 coin]}{}{5}{$$20}{-5}{$$-20, lc0 23, gf11 1}
    {34}{Uhhh... Me better get cheep won. [Pay 20 coin]}{}{-4}{$$20}{-5}{$$-20, lc0 23, gf11 1}
    {35}{Actually, I think I'll need to stay for the whole week.}{}{5}{}{40}{}
    {36}{Uhhh... Akshully, me need hole week.}{}{-4}{}{40}{}
    {37}{F:}{}{1}{}{0}{}

    {40}{Okay then sir, we have two rooms available for the whole week. Our finest room at the special weekly rate of 200 coin is certainly worth seeing. However, if you lack the coin, then I suggest the 'discount' room for a mere 100 coin a week. Now then, which room would you like?}{Okay then sir, we have two rooms available for the whole week. Our finest room at the special weekly rate of 200 coin is certainly worth seeing. However, if you lack the coin, then I suggest the 'discount' room for a mere 100 coin a week. Now then, which room would you like?}{}{}{}{}
    {41}{Give me first class all the way! [Pay 200 coin]}{}{5}{$$200}{-9}{$$-200, lc0 167, gf12 1}
    {42}{Me wan' good room! [Pay 200 coin]}{}{-4}{$$200}{-9}{$$-200, lc0 167, gf12 1}
    {43}{I'd better take the discount one. [Pay 100 coin]}{}{5}{$$100}{-5}{$$-100, lc0 167, gf11 1}
    {44}{Uhhh... Me better get cheep won. [Pay 100 coin]}{}{-4}{$$100}{-5}{$$-100, lc0 167, gf11 1}
    {45}{I'd rather just stay for one night if that's possible.}{}{5}{}{30}{}
    {46}{Uhhh... Me wunna stay for tonite only.}{}{-4}{}{30}{}
    {47}{F:}{}{1}{}{0}{}

    {60}{I'm sorry sir, but you currently have an outstanding rent on our 'discount' bed. I'm afraid that we can't rent you another bed.}{I'm sorry madame, but you currently have an outstanding rent on our 'discount' bed. I'm afraid that we can't rent you another bed.}{}{}{}{}
    {61}{A:}{}{1}{}{0}{}

    {70}{I'm sorry sir, but you currently have the use of our finest bed. You can't have another bed until your current rent expires.}{I'm sorry madame, but you currently have the use of our finest bed. You can't have another bed until your current rent expires.}{}{}{}{}
    {71}{A:}{}{1}{}{0}{}

    {100}{There you go sir, your bed is ready. The door to the 'discount' room is unlocked, you can go in when you're ready. Also, try not to break anything in there. Just because it's cheap doesn't mean you can go in and wreck the place.}{There you go madame. The door to the 'discount' room is unlocked, you can go in when you're ready. Also, try not to break anything in there. Just because it's cheap doesn't mean you can go in and wreck the place.}{}{}{}{}
    {101}{A:}{}{1}{}{0}{}

    {200}{A fine choice sir! Your bed is ready and waiting for you. You will find the door to our best room unlocked, feel free to go in and use it at your pleasure!}{A fine choice madame! You will find the door to our best room unlocked, feel free to go in and use it at your pleasure!}{}{}{}{}
    {201}{A:}{}{1}{}{0}{}

    -----------------------
    00003InnKeeper.scr
    -----------------------
    0. hour: store hours since startup in Local 0
    1. IF Local 0 <= Global Variable 11
    THEN do nothing
    ELSE clear global flag 11
    2. IF Local 0 <= Global Variable 12
    THEN do nothing
    ELSE clear global flag 12
    3. dialog 1
    4. return and SKIP default
    5. hour: store hours since startup in Local 0
    6. Global Variable 11 = Local 0 + Counter 0
    7. dialog 100
    8. return and SKIP default
    9. hour: store hours since startup in Local 0
    10. Global Variable 12 = Local 0 + Counter 0
    11. dialog 200
    12. return and SKIP default

    -----------------------
    00004Inn_Bed_Use.scr
    -----------------------
    0. Local 2 = Counter 0 * 2
    1. goto line Local 2
    2. Local 1 = Global Variable 11
    3. goto line 6
    4. Local 1 = Global Variable 12
    5. goto line 6
    6. hour: store hours since startup in Local 0
    7. IF Local 0 <= Local 1
    THEN return and SKIP default
    ELSE return and RUN default


    -----------------------
    globalvars.mes (in the 'semes' directory)
    -----------------------
    // These gv's store the game HOUR that the rent of the bed expires on. The number stored depends on the time the bed was rented and also for how long the PC rented the bed (a day - 23 hours, or a week - 167 hours).
    // The only check we need to use the bed is to see if the time has expired.
    // If the PC never paid for the bed, or paid for another bed, then time is already expired.
    // Room to make beds rentable for any time period I like. Just have to alter innkeeper dialog and make some new lines changing 'lc0 HOURS'.
    {11}{Stores the HOUR that the PC can no longer use POOR bed number 1.}
    {12}{Stores the HOUR that the PC can no longer use GOOD bed number 2.}

    -----------------------
    globalflags.mes (in the 'semes' directory)
    -----------------------
    // Beds available in Game. We don't use '0' because Counter 0 might be '0' to start off with?
    // Subtract '10' when you tie in a number to the 'counter 0' of the 'use' attachment point for the beds (ie. 11 becomes bed 1, 12 = 2, 13 = 3 etc...)
    // These are only used to check in dialog if the PC can rent a bed again or not.
    {11}{1 - PC has paid for POOR bed.}
    {12}{1 - PC has paid for GOOD bed.}


    Now, here's the killer. All of this is for 2 different beds that you can rent from the InnKeeper. One is a dodgy, cheap rate, discount bed (gv11 and gf11) and the other is a good bed (gv12 and gf12). What you need to do is, in WorldEd, right-click and 'edit' your POOR bed, tie script number '4' (inn_bed_use) to its 'use' attachment point' THEN (making sure you have 'use' selected) click in the 'Counter 0' field at the bottom and put the number '1' in there and click ok. Now, right-click and 'edit' your GOOD bed, tie script number '4' (inn_bed_use) to its 'use' attachment point and (making SURE that you have the 'use' attachment point selected) click in the 'Counter 0' field and put a number '2' in there and click ok. Now, create an NPC InnKeeper and tie script '3' to his 'dialog' attachment point.

    What's happening is this: Let's say the PC (player) rents the GOOD bed for one night with dialog line 31:
    {31}{Give me first class all the way! [Pay 50 coin]}{}{5}{$$50}{-9}{$$-50, lc0 23, gf12 1}

    The PC is paying for the bed ($$-50) and we set Local Counter 0 to 23 (lc0 23 - the PC is renting the bed for 23 hours). Global flag 12 (gf12 1) is set to '1' meaning the PC has rented the bed ('gf' is only used in the dialog when the PC tries to rent a bed and already has one). Now, line '9' of the Innkeeper script is called:
    9. hour: store hours since startup in Local 0
    10. Global Variable 12 = Local 0 + Counter 0
    11. dialog 200
    12. return and SKIP default

    This grabs the CURRENT game hour and stores it in a temporary variable called Local 0. Because we're renting the good bed (gv12 and gf12), then we add 23 hours (Local counter 0 which we just set to 23) to the CURRENT game hour and store it in global variable 12. The value we have stored is the HOUR on which the rent expires. Dialog continues at line 200.

    Then, when the PC USES the bed, script 4 (inn_bed_use) is called:
    0. Local 2 = Counter 0 * 2
    1. goto line Local 2
    2. Local 1 = Global Variable 11
    3. goto line 6
    4. Local 1 = Global Variable 12
    5. goto line 6
    6. hour: store hours since startup in Local 0
    7. IF Local 0 <= Local 1
    THEN return and SKIP default
    ELSE return and RUN default

    Local variable 2 takes the number stored in 'Counter 0' (that we set in WorldEd) from the bed and multiplies it by 2. In this case the good bed has a counter 0 of '2' so 2 * 2 = 4. We then goto that line (line 4), and retrieve the HOUR that the bed expires. We then check the HOUR the bed expires with the CURRENT game hour (script line 7) and if the PC can sleep, then we 'return and SKIP default' else 'return and RUN default'. The default action for a bed is to display the 'piss off, find an inn' line. SKIP that action and you get to sleep (HINT: If you want a bed that you can just sleep in without paying for it or anything, just tie a script with the only action of 'return and SKIP default' to it). NOTE: The check to see if the PC actually rented THIS bed is deceptively done with lines 0 and 7. The time limit would have expired if the PC uses a bed it hasn't rented.

    All of this works just the way I want. There is room to add extra beds if you feel the need (you can figure out how). Incidentally, this is why Part 4 of AMTUT is taking me so long, I just HAD to have the perfect InnKeeper script didn't I? Expect chapters 1 and 2 of AMTUT part 4 to be up *hopefully* by this friday (tips on planning and designing a module and Innkeeper and Expert & Master training scripts). There will be a better explanation of this script in there at:
    http://www.terra-arcanum.com/~amtut/

    NOTE: If SockMonkey could let me have 'Variable Loops' and variable = variable statements like 'Local 1 = Global Variable (Counter 0)' then I could compress the inn_bed_use script down to about 3 lines and wouldn't need that 'goto line' stuff. I could also keep the innkeeper script short. Er... This is more of a note to the developers.

    All of this is fairly similar to what Troika use in their bed scripts (bed scripts which took me a week to figure out :smile: ). Anyway, hope this helps a lot of you. By the way, you should change the dialog so that half-orcs are only allowed to rent the discount bed for an expensive price :smile:
     
Our Host!