scripting question..

Discussion in 'Modding and Scripting Support' started by Dj_Unique, Nov 14, 2001.

Remove all ads!
Support Terra-Arcanum:

GOG.com

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

    Dj_Unique Member

    Messages:
    79
    Likes Received:
    5
    Joined:
    Nov 14, 2001
    I'm kinda new to the modding community (but definitely not clueless)
    I've got a question about scripting in Arcanum..
    and the question is:

    How do I make an NPC initiate dialogue with the player?

    (Tried it in a heartbeat script but it didn't work out that way..)

    So could somebody please shed a little light on this issue?

    Thanks in advance..
     
  2. DarkUnderlord

    DarkUnderlord Administrator Staff Member

    Messages:
    4,315
    Likes Received:
    5
    Joined:
    Nov 10, 2001
    Tie this to the heartbeat. It's one I made myself and am using in the Amtut Mod (not the tutorial version). This is the way I got it to work:

    0. If player is within 2 tiles of location X:169 Y:170
    THEN call script 5 at line 2 with triggerer Player and attachee attachee
    ELSE float line 100 aboce attachee
    1. return and RUN default
    2. call script 5 at line 5 with triggerer triggerer and attache attachee in 1 seconds
    3. call script 6 at line 0 with triggerer player and attachee attachee
    4. return and SKIP default
    5. change script attached to attachee at point 19 to script 0
    6. return and SKIP default


    Okay noe for an explanation. The number of this script is '5' I use 'call script' because it doesn't renumber like 'goto' does and as such saves me a lot of pain and trouble.

    Line 0: The NPC will float a line 'Where is he/she?' above his head if the player is not near him. This is not necessary if you don't want it there.

    Line 1: return and RUN is used because the NPC is pacing back and forth, as such RUN keeps him pacing. Not necessary if NPC is not pacing.

    Line 2: This stops the script from constantly being called again and again and again (maybe a problem you had?) It calls THIS script (5) at line 5 in 1 second.

    Line 3: this line calls script '6' which is the default dialog script for the NPC. You know, the standard:
    0. Dialog 1
    1. return and SKIP default

    Line 5: 'change script attached to attachee at point 19 to script 0'. Point '19' is the heartbeat attachemnt point. By changing the script number at this point (which in this case is script number '5' in WorldEd) to '0' we remove this script and preventing it from being called again and again and again immediately after dialog has finished.

    Also, note how I use 'PLAYER' in some cases and NOT triggerer. I found that PLAYER works and triggerer doesn't (if your mod is multiplayer, then you'll have to figure something out yourself). Also, X and Y should be the co-ordinates that the NPC is standing on. SO when the player is within 2 tiles, the NPC will start dialog. This is better than 'obj can see obj' because that can trigger from a whole SCREEN away!! Makes it seem like the NPC should be shouting.

    If you want the NPC to keep talking whenever the Player walks by then you'll have to figure something out yourself. (I'm kind of busy working on Part 4 of a certain tutorial...)

    Hope that helps.

    DarkUnderlord
    ----------------
    Moo... Moo... I'm an Interplay cow.
     
  3. Dj_Unique

    Dj_Unique Member

    Messages:
    79
    Likes Received:
    5
    Joined:
    Nov 14, 2001
    Yay! Helped indeed. Wrote the script, tested the mod, no problems at all. I made a slight modification to the location check, though. My version stores the location of the NPC to 2 local variables (local 0 and local 1) and checks for player position according to these to values. This way there's no need to look up the position of the NPC in WorldEd.
     
Our Host!