Let's say I wanna use a variable named iLDBobQuest
I'll lay out the events first:
  • 1 = Quest given by Cole
  • 3 = Spoke to Bob
  • 5 = Got Bob's note (I'll do this oddly to show how we can use an event script to notice it has been received)
  • 7 = Spoke to Cole again, and gave him Bob's note

    Some preparation:

    Make Bob's note. When making items, the "resref" or unique name for the whole module is set to be the name you originally give it, without spaces or punctuation. Once set it cannot be changed without making a copy of the object or area. To prevent conflicts with other people's stuff, it is important that you just add your initials in the name to begin with. Thus, I name it ld_bobs_note, then change the name to Bob's Note by editing it after creation. Anyway, that makes the resref "ld_bobs_note" which we need to know later.


    Note I'm leaving some room there between the numbers in case
    I want to add more events in the middle.

    I put in a greeting... like, "Hi, I need someone to find Bob"
    Then I select that text, and click "Text Appears When"
    Then I click on the "Script Wizard" button... number 1 here...

    Then I choose "Local Variable" on this dialog:

    and hit "Next".
    Now, I fill in this dialog.

    I set the variable type to "int"
    I set the variable name to iLDBobQuest
    I set the variable condition to "is less than"
    I leave the value set as "constant int"
    and I set the variable value to 1.
    Then I click "Add" and then "Next"
    Now, give the script a name and save it. I'll use "ld_bob_sc_01" and hit "Finish"
    You can have a look at the script with the editor, but it does all it needs to now. What we've done now is make it so that the "Hi, I need someone to find Bob" thing only shows up until they accept the quest.

    Now, we need to let them accept it, or reject it...
    We add two choices. If they choose "Sorry get someone else to do it." we don't need to do anything. If they choose "Okay, I'll do it!" we need to set that variable to 1. We highlight that choice in the dialog as shown below, then click "Actions Taken" (small arrow) and then click the "Script Wizard" button (big arrow).

    Now click "Set Local Variables" on this dialog:

    Set variable type to "int"
    Set variable name to iLDBobQuest
    Set value type to "constant int"
    Set value to "1"
    As shown below.

    Now, give the script a name and save it. I'll use "ld_bob_at_01" and hit "Finish"

    Okay, that's all done. Now you've "given" the player the quest. For my purposes, I'll be changing your variables to be persistent once you submit the stuff, but leave that to me...
    Since we are already editing Cole's conversation, let's finish it off. Cole needs to:
    1: give the quest... which we've just done
    2: reward them on completion, take any quest items, and mark quest complete
    3: say thanks if complete.

    So, let's do step 2... (shown below).
    Add the text, "Yippee, you found him! Oh, and thanks for bringing me that note." by right clicking "Root" (green arrow) and choosing "Add"
    Highlight that text and click the "Actions Taken" button (small red)
    Click the "Script Wizard" button (big red)
    Check "Give rewards," "Take From the Player," and "Set Local Variables" (blue arrows)
    Click "Next"



    Now we can tell it how much XP, and click the "To Party" checkbox to give it to the whole group.
    You can give an item, and gold, but you get the idea. Clicking the "..." box pulls up an item palette so you can pick an item to give them if you want to give some cool belt or weapon as a reward.
    Anyway... limiting it to only people in the same area is more complex, but an easy change for me to make as long as you've done it this way before sending it to me.
    Moving on... pick the rewards, then hit "Next"
    Now we take away Bob's note. On this dialog, we fill in the tag of the item we want taken. Conveniently, it matches the name we originally gave it of "ld_bobs_note" so we do the following steps:
    1: put "ld_bobs_note" in the blank.
    2: click "Add"
    3: Click "Destroy" to make sure the npc doesn't keep the item
    4: Click "Next"

    Now we have to mark the quest as completed.
    1: Set variable type: int
    2: Set variable name: iLDBobQuest
    3: Set value type: constant int
    4: Set value: 7 (which is the number I decided at the beginning would mean the quest was completed)
    5: Click "Add" (note I already did this time, which put it in the "Local Expressions" window.
    6: Click "Next"

    Final step: save this script. I'm naming mine ld_bob_at_07 because that's the value it sets the variable to.

    Now we need to give some response for anyone who talks to Cole after doing the quest.
    We need to make sure that the reward giving response gets skipped once the quest is done.
    To do this, we put a "Text Appears When" script on the "Yippee..." response.
    1: Highlight the "Yippee..." response
    2: Click "Text Appears When"
    3: Click the "Script Wizard" button
    4: Check "Local Variable" on this dialog:

    and hit "Next".
    5: To prevent this from showing up for people who have already finished, set fields as follows:

  • int (1)
  • iLDBobQuest (2)
  • is less than (3)
  • constant int (4)
  • 7 (5)

  • 6: Click "Add"
    7: To prevent this from showing up for people who haven't found Bob yet, set fields as follows:

  • int (1)
  • iLDBobQuest (2)
  • is greater than (3)
  • constant int (4)
  • 4 (5)

  • 8: Click "Add"
    Once both lines are in there, as shown, we click "Next", and give it a filename and save. I used the name "ld_bob_sc_07" because it is the (S)tarting(C)onditional script checking for value of 7.

    We set this to check for greater than 4, because we know that once it is 5 (decided before I began, list at the top of this), they've spoken to Bob and been given the note. We set it for less than 7 because once the quest is done, the value will be 7.


    Now we need to add a response for people who have begun the quest, but not found Bob.
    These people will have a value for iLDBobQuest of 1.
    Once they speak to Bob, their value gets set to 3
    During that conversation, Bob gives them the note, which will itself set the variable to 5 by a separate method than the script wizard.
    Anyway, point is, for the "Keep looking for Bob" response, the value of iLDBobQuest should be 1.
    Steps:
    1: Add the response by right clicking "Root" and choosing "Add".
    2: Add a "Text Appears When" script which checks Local Variable for the conditions as follows (using the same dialog as above):
    int (1)
    iLDBobQuest (2)
    is less than (3)
    constant int (4)
    2 (5)
    Click "Add"
    Click Next
    Give it a filename and click finish. I'm naming mine ld_bob_sc_02...

    Now for the after completion response.
    Steps:
    1: Add the "Thanks for finding Bob" response by right clicking "Root" and choosing "Add".
    2: Add a "Text Appears When" script which checks Local Variable for the conditions as follows (using the same dialog as above):
    int (1)
    iLDBobQuest (2)
    is greater than (3)
    constant int (4)
    6 (5)
    Click "Add"
    Click Next
    Give it a filename and click finish. I'm naming mine ld_bob_sc_08... because 7 is taken...:)

    Save the conversation. I named this one ld_bob_quest, though it's really Cole's conversation... oh well.

    TADA! That is the beginning and end of the quest. Now we just have to add the conversation with Bob, and the script that gets run when the player receives the note.

    Now we make Bob's conversation. Using the same techniques as before...
    1: We add the first response, "Hi there, I'm Bob... need something?"
    2: Add a "Text Appears When" script that checks for iLDBobQuest to be greater than 0, and less than 3.
    3: Add a player response of "Yeah... Cole sent me to find you."
    4: Add Bob's response of, "Oh. Well, here, take this note to him to let him know where I'll be"
    5: Add an "Actions Taken" script to this one that sets Local Variable iLDBobQuest to be 3, and gives a reward item to the player... The Note (resref="ld_bobs_note"). Give em some XP here too if you want... and maybe some gold to take the note back to Cole.
    This probably seems silly, since we wanted the value to be 5 once they get the note. However, this is a tutorial, and I wanted to show one more trick which will allow you to make things happen when someone picks up, receives, drops, or loses an item... along with some other actions involving items. We'll get to that once Bob's conversation is done.
    Now we add another conversation choice for people that haven't begun the quest (<0), and for people after they find him... (>3)
    1: Add a response onto "Root" that says "Nice day isn't it?"
    2: Normally we'd add a script that checks for values here, but this is the response that should happen if nothing else does, so we don't need to set any conditions here. (Note: if no response above matches its conditions, a lower response will be tried.)
    That's all you need for Bob. Save the conversation.

    Now for how to handle the item "events." You can make a script that gets run for the following events:

    * When the item has the OnHitCastSpell: Unique power property and it hits a target(weapon) or is being hit (armor). (PCs and non PCs)
    * When the Unique Power property of the item is used (PCs only)
    * When the item is equipped (PCs only)
    * When the item is unequipped (PCs only)
    * When the item is acquired (PCs only)
    * When the item is unaquired (PCs only)
    * When a PC or DM casts a spell from one of the standard spellbooks on the item
    To do this is a little trickier than the previous stuff, but it shouldn't be too bad.
    1: In Toolset, click "Tools" menu, and choose "Script Editor"
    2: In Click the "Open an existing file" button or hit CTRL-O. You will see this dialog:

    3: Click the "All Resources" button (small arrow)
    4: Type in "x2_it_example" as the "Resource Name" (big arrow)
    5: Select it and click "Open"

    Now you have an example script open. IMMEDIATELY click the "Save As" button (Ctrl-Alt-S) and save this file by the same name as the tag of the item it corresponds to. Our item is "Bob's Note" which has a resref of "ld_bobs_note" and a tag of "ld_bobs_note". Thus we save our script file as "ld_bobs_note" because that is the tag of the item. This script will now fire any time the events listed above occur.
    Now we need to have it do special stuff. Look through the script for this:
        // * This code runs when the item is acquired
        // * Note that this event fires PCs only
        else if (nEvent == X2_ITEM_EVENT_ACQUIRE)
        {
    
            oPC = GetModuleItemAcquiredBy();
            oItem  = GetModuleItemAcquired();
        }
    


    We want to set a variable during that event. To do so... we add a single line like this:
        // * This code runs when the item is acquired
        // * Note that this event fires PCs only
        else if (nEvent == X2_ITEM_EVENT_ACQUIRE)
        {
    
            oPC = GetModuleItemAcquiredBy();
            oItem  = GetModuleItemAcquired();
            SetLocalInt(oPC, iLDBobQuest, 5);
        }
    

    Tada. Save this script, close the script editor, and save your module. Now make creatures named Cole and Bob, and give them those conversations.