Author Topic: NPC Banter Triggers  (Read 15916 times)

0 Members and 1 Guest are viewing this topic.

Offline Amy

  • Global Moderator
  • Level 3
  • *****
  • Posts: 1235
  • Karma: +85/-10
  • Gender: Female
    • View Profile
NPC Banter Triggers
« on: March 22, 2007, 04:01:55 PM »
What is the best way to trigger a banter, an npc to the main character. I was looking at various mods and their coding and wonder which way was best.

Script file
Quote
IF
  InParty(Myself)
  RealGlobalTimerExpired("YasraenaTalkTime","GLOBAL")
  Global("YasraenaRA","GLOBAL",1)
  Global("YasraenaMatch","GLOBAL",1)
OR(15)
  Global("YasraenaTalk","LOCALS",2)
  Global("YasraenaTalk","LOCALS",4)
  Global("YasraenaTalk","LOCALS",6)
  Global("YasraenaTalk","LOCALS",8)
  Global("YasraenaTalk","LOCALS",10)
  Global("YasraenaTalk","LOCALS",12)
  Global("YasraenaTalk","LOCALS",14)
  Global("YasraenaTalk","LOCALS",16)
  Global("YasraenaTalk","LOCALS",18)
  Global("YasraenaTalk","LOCALS",20)
  Global("YasraenaTalk","LOCALS",22)
  Global("YasraenaTalk","LOCALS",24)
  Global("YasraenaTalk","LOCALS",26)
  Global("YasraenaTalk","LOCALS",28)
  Global("YasraenaTalk","LOCALS",30)
THEN
 RESPONSE #100
   RealSetGlobalTimer("YasraenaTalkTime","GLOBAL",3400)
   IncrementGlobal("YasraenaTalk","LOCALS",1)
END
D file
Quote
IF
~Global("YasraenaRA","GLOBAL",1)
Global("YasraenaTalk","LOCALS",10)
Global("YasraenaMatch","GLOBAL",1)
GlobalTimerExpired("YasraenaTalkTime","GLOBAL")~
THEN BEGIN YasraenaTalk5
SAY
This increments the GLOBAL by 1.

Quote
IF ~See(Player1)
!StateCheck(Player1,STATE_SLEEPING)
Global("PcAloraChat1","LOCALS",0)~ THEN BEGIN apc_chat1
SAY ~Don't be so sad <CHARNAME> we'll rescue Imoen from that nasty, nasty evil mage don't you worry!~
++ ~I know we will get her back, I just don't like the idea of her being captured far away from us.~ DO ~SetGlobal("PcAloraChat1","LOCALS",1)~ + chatmore
++ ~I really don't feel like talking about it right now.~ DO ~SetGlobal("PcAloraChat1","LOCALS",1)~ + notalk
END
The bolded is for where it sets the GLOBAL to 1 so it is not repeated.

Offline berelinde

  • Global Moderator
  • Level 3
  • *****
  • Posts: 1011
  • Karma: +102/-31
    • View Profile
Re: NPC Banter Triggers
« Reply #1 on: March 22, 2007, 04:27:11 PM »
This represents the latest and greatest research of the BG1 NPC Project Team. Most of the work was done by Kulyok, though. By using script like this, no talks will ever be dropped because of... well, anything, really. You'll always get your banters in, no matter what.

Code: [Select]

IF
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
Global("ImPCTimerStarted","GLOBAL",0)
Global("ImFriendTalk","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("ImFriendTalkTime","GLOBAL",300)
SetGlobal("ImFriendTalk","GLOBAL",1)
SetGlobal("ImPCTimerStarted","GLOBAL",1)
END

IF
InParty(Myself)
See(Player1)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
RealGlobalTimerExpired("ImFriendTalkTime","GLOBAL")
OR(2)
Global("ImFriendTalk","GLOBAL",1)
Global("ImFriendTalk","GLOBAL",3)
!AreaCheck("FW3300")
GlobalLT("Chapter","GLOBAL",3)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("imoen99")
IncrementGlobal("ImFriendTalk","GLOBAL",1)
SetGlobal("ImFriendTalkCheck","GLOBAL",1)
StartDialogueNoSet(Player1)
END

IF
InParty(Myself)
!See([ENEMY])
See(Player1)
CombatCounter(0)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
RealGlobalTimerExpired("ImFriendTalkTime","GLOBAL")
OR(2)
Global("ImFriendTalk","GLOBAL",2)
Global("ImFriendTalk","GLOBAL",4)
Global("ImFriendTalkCheck","GLOBAL",1)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("imoen99")
StartDialogueNoSet(Player1)
END

X#IMOEN.D lines 3 through 10 become:
CODE
IF WEIGHT #-2 ~
Global("ImFriendTalk","GLOBAL",2)~ THEN BEGIN IMPC1
SAY @0
IF ~~ THEN REPLY @1 DO ~SetGlobal("ImFriendTalk","GLOBAL",3) RealSetGlobalTimer("ImFriendTalkTime","GLOBAL",1800) SetGlobal("ImFriendTalkCheck","GLOBAL",0)~ GOTO IMPC1.1
IF ~~ THEN REPLY @2 DO ~SetGlobal("ImFriendTalk","GLOBAL",3) RealSetGlobalTimer("ImFriendTalkTime","GLOBAL",1800) SetGlobal("ImFriendTalkCheck","GLOBAL",0)~ GOTO IMPC1.1
IF ~~ THEN REPLY @3 DO ~SetGlobal("ImFriendTalk","GLOBAL",3) RealSetGlobalTimer("ImFriendTalkTime","GLOBAL",1800) SetGlobal("ImFriendTalkCheck","GLOBAL",0)~ GOTO IMPC1.2
++ @4 DO ~SetGlobal("ImFriendTalk","GLOBAL",3) RealSetGlobalTimer("ImFriendTalkTime","GLOBAL",1800) SetGlobal("ImFriendTalkCheck","GLOBAL",0)~ + IMPC1Gorion
END

If you or anyone else has any questions, I'd be happy to answer them, to the best of my abilities.

Offline berelinde

  • Global Moderator
  • Level 3
  • *****
  • Posts: 1011
  • Karma: +102/-31
    • View Profile
Re: NPC Banter Triggers
« Reply #2 on: March 22, 2007, 04:31:30 PM »
I'd like to encourage you to consider using GLOBAL instead of LOCALS. Should you ever want to put something in another NPC's script to check Alora's variables, it will make life a lot easier.

BioWare used local variables instead of global ones, but there is no reason to follow suit.

Offline Amy

  • Global Moderator
  • Level 3
  • *****
  • Posts: 1235
  • Karma: +85/-10
  • Gender: Female
    • View Profile
Re: NPC Banter Triggers
« Reply #3 on: March 22, 2007, 05:54:15 PM »
That looks pretty complex.  ???

I was thinking about using GLOBALS since you can do more with that than LOCALS.

Offline berelinde

  • Global Moderator
  • Level 3
  • *****
  • Posts: 1011
  • Karma: +102/-31
    • View Profile
Re: NPC Banter Triggers
« Reply #4 on: March 22, 2007, 06:27:38 PM »
It isn't necessarily complex, but it does look that way. It has a backup script that will prevent the problem of skipped talks, or things like the stuff that can happen in Tsujatha, where he banters with an NPC and doesn't fire off a LT to the PC.

It opens each varaible via script, and then closes it and sets the timer in dialogue. It's been working out well enough to justify recoding the entire BG1 NPC Project to take advantage of it.

There's a tutorial on the subject by Kulyok over at G3. I'd hunt down the link, but I just can't keep my eyes open another minute. It really has been like that, today.

Offline Amy

  • Global Moderator
  • Level 3
  • *****
  • Posts: 1235
  • Karma: +85/-10
  • Gender: Female
    • View Profile
Re: NPC Banter Triggers
« Reply #5 on: March 22, 2007, 06:41:11 PM »
Thanks. I'll go look it up.

Offline Kulyok

  • Level 1
  • *
  • Posts: 336
  • Karma: +16/-17
    • View Profile
    • http://www.pocketplane.net/xan
Re: NPC Banter Triggers
« Reply #6 on: March 23, 2007, 12:20:05 AM »
I agree with berelinde, but I think there's no need for such complexity - I mean, in the tutorial I posted at G3&PPG it was a bit simpler: Check variable may not be needed, after all. Check this out:

http://forums.pocketplane.net/index.php/topic,23822.0.html

Offline Kulyok

  • Level 1
  • *
  • Posts: 336
  • Karma: +16/-17
    • View Profile
    • http://www.pocketplane.net/xan
Re: NPC Banter Triggers
« Reply #7 on: March 23, 2007, 03:08:41 AM »
And as for the working code in an NPC mod, try Tiax from http://www.pocketplane.net/oneday , that is, if you do not mind mad gnomes. I'd say Xan v3, but Xan weighs about 12mb, and Tiax is barely over one.

Offline Solaufein

  • Lord of the Realms
  • Administrator
  • Level 5
  • *****
  • Posts: 5149
  • Karma: +127/-19
  • Gender: Male
  • The night is dark and full of terrors...
    • ICQ Messenger - 251194643
    • Yahoo Instant Messenger - gscott7833
    • View Profile
    • http://teambg.net
Re: NPC Banter Triggers
« Reply #8 on: March 24, 2007, 05:14:21 AM »
Nice tutorial Kulyok. I will keep it in mind myself.
My mods:
Dark Horizons
The Undying
Nikita
IWD2 store

Co-contributor:
Dark Side of the Sword Coast BG1 Weidu
Aurils Bane
Encounters
Saerileth
Baldur's Gate - Enhanced Edition beta tester
Baldur's Gate 2 - Enhanced Edition beta tester
Icewind Dale - Enhanced Edition beta tester

Offline Amy

  • Global Moderator
  • Level 3
  • *****
  • Posts: 1235
  • Karma: +85/-10
  • Gender: Female
    • View Profile
Re: NPC Banter Triggers
« Reply #9 on: March 24, 2007, 06:21:26 PM »
I agree, a good tutorial. I copied and pasted it as a Word document so I can read it while off the internet.