Code taken from BTL, with some modifications for ease of viewing.
What this one does is that once the conditions are fulfilled, the Banters are then "seeded", ie fixed in a randomised way particular to that particular game. It requires a bit of planning, so I have banter sets A-D represented by the numbers 1-4 in each of the "KKStage1(1-3)" "GLOBAL".
Note that if you are using this for an individual NPC, you may wish to use "LOCALS" instead. I used Globals because both the CREs of Kova and Kiyone
had to access and modify the variables.
Similarly in BTL I put this inside Baldur.Bcs, but if you are just using 1 NPC I suggest putting it only in that NPC's Script.
This seeding is fairly elementary, since the variations are few given the rulings I wrote above. I would suggest writing out all the possible permutations on paper and then listing them out one by one. HOWEVER if you are using 4 or more banter sets out of X and want PURE randomisation (ie 6C4 permutations would lead to 30 permutations, if my math doesn't fail me), I would suggest a different seeding process which I'll put in a separate post. Still if its for replayability I would suggest 3 out of 5 sets, leading to about 20 purely random variations - that's still a handful.
// Seeding Stage 1 Banters
IF InParty("Kiyone")
InParty("Kova")
Global("BKKChat", "GLOBAL", 7)
Global("KKRomance", "GLOBAL", 1)
Global("KKInStage1x", "GLOBAL", 0)
THEN
RESPONSE #0
RESPONSE #100
SetGlobal("KKInStage1x", "GLOBAL", 1)
SetGlobal("KKStage11", "GLOBAL", 1)
SetGlobal("KKStage12", "GLOBAL", 2)
SetGlobal("KKStage13", "GLOBAL", 3)
RESPONSE #100
SetGlobal("KKInStage1x", "GLOBAL", 1)
SetGlobal("KKStage11", "GLOBAL", 1)
SetGlobal("KKStage12", "GLOBAL", 2)
SetGlobal("KKStage13", "GLOBAL", 4)
RESPONSE #100
SetGlobal("KKInStage1x", "GLOBAL", 1)
SetGlobal("KKStage11", "GLOBAL", 2)
SetGlobal("KKStage12", "GLOBAL", 1)
SetGlobal("KKStage13", "GLOBAL", 3)
RESPONSE #100
SetGlobal("KKInStage1x", "GLOBAL", 1)
SetGlobal("KKStage11", "GLOBAL", 2)
SetGlobal("KKStage12", "GLOBAL", 1)
SetGlobal("KKStage13", "GLOBAL", 4)
RESPONSE #100
SetGlobal("KKInStage1x", "GLOBAL", 1)
SetGlobal("KKStage11", "GLOBAL", 2)
SetGlobal("KKStage12", "GLOBAL", 3)
SetGlobal("KKStage13", "GLOBAL", 1)
RESPONSE #100
SetGlobal("KKInStage1x", "GLOBAL", 1)
SetGlobal("KKStage11", "GLOBAL", 2)
SetGlobal("KKStage12", "GLOBAL", 3)
SetGlobal("KKStage13", "GLOBAL", 4)
RESPONSE #100
SetGlobal("KKInStage1x", "GLOBAL", 1)
SetGlobal("KKStage11", "GLOBAL", 2)
SetGlobal("KKStage12", "GLOBAL", 4)
SetGlobal("KKStage13", "GLOBAL", 1)
RESPONSE #100
SetGlobal("KKInStage1x", "GLOBAL", 1)
SetGlobal("KKStage11", "GLOBAL", 2)
SetGlobal("KKStage12", "GLOBAL", 4)
SetGlobal("KKStage13", "GLOBAL", 3)
END
=========
Because I applied this code to Banters, the standard Interact() Command is used to trigger the conversations between Kova and Kiyone. However if you scripted various things like quests or non-Banter conversation, you'll need to include the relevant conditions in the Scripts of the CRE as well
In any case, each Banter set is Invoked as follows, there are THREE possible entries to each Banter Set, when it occupies slots 1-3. Of course if you're using 4 Banter Set slots it would be 4. After the first line it leads in to the same body, though if you want to there's nothing to stop you from duplicating 4 complete sets.
Note that if you're using non-full-random conditionals, you do not need to provide All 3 entry conditionals. For eg, since I know under my algorithm above that C and D can occur only after B has happened, both C and D would only have 2 entry conditionals ; they cannot possibly occur when
Global("KKInStage1x", "GLOBAL", 1)
as B would not have happened yet.
CHAIN
IF ~Global("KKStage11", "GLOBAL", 1)
Global("Z#TrialClear","GLOBAL",0)
!RealGlobalTimerNotExpired("KKBanterTMin","GLOBAL")
InParty("Kiyone") InMyArea("Kiyone")
Global("KKInStage1x", "GLOBAL", 1)
Global("KKBanter11", "GLOBAL", 0)~ THEN Z#KOVAB KKBanter111in1
~Kiyone, what do you really think of me? About who I am, what I have done, my past, and what danger I'm putting you in just by travelling with you.~
DO ~PlaySound("kkrom1") PlaySong(0)~ EXTERN Z#KIYOB KKBanter111
CHAIN
IF ~Global("KKStage12", "GLOBAL", 1)
Global("Z#TrialClear","GLOBAL",0)
!RealGlobalTimerNotExpired("KKBanterTMin","GLOBAL")
InParty("Kiyone") InMyArea("Kiyone")
Global("KKInStage1x", "GLOBAL", 2)
Global("KKBanter11", "GLOBAL", 0)~ THEN Z#KOVAB KKBanter111in2
~Kiyone, what do you really think of me? About who I am, what I have done, my past, and what danger I'm putting you in just by travelling with you.~
DO ~PlaySound("kkrom1") PlaySong(0)~ EXTERN Z#KIYOB KKBanter111
CHAIN
IF ~Global("KKStage13", "GLOBAL", 1)
Global("Z#TrialClear","GLOBAL",0)
!RealGlobalTimerNotExpired("KKBanterTMin","GLOBAL")
InParty("Kiyone") InMyArea("Kiyone")
Global("KKInStage1x", "GLOBAL", 3)
Global("KKBanter11", "GLOBAL", 0)~ THEN Z#KOVAB KKBanter111in3
~Kiyone, what do you really think of me? About who I am, what I have done, my past, and what danger I'm putting you in just by travelling with you.~
DO ~PlaySound("kkrom1") PlaySong(0)~ EXTERN Z#KIYOB KKBanter111
CHAIN
IF ~~ THEN Z#KIYOB KKBanter111
(blah blah conversation ends)
DO ~SetGlobal("KKBanter11", "GLOBAL", 1)~ EXIT
This next bit is the second Banter of the Banter Set. This ensures that THIS Banter happens immediately after the first Banter Set, ie it ensures A2 happens immediately after A1, B2 after B1, etc etc. This ties in with the SetGlobal("KKBanter11", "GLOBAL", 1) that is set in the last line of CHAIN above this text.
CHAIN
IF ~InParty("Kova") InMyArea("Kova")
Global("Z#TrialClear","GLOBAL",0)
!RealGlobalTimerNotExpired("KKBanterTMin","GLOBAL")
Global("KKBanter11", "GLOBAL", 1)~ THEN Z#KIYOB KKBanter112
~blah blah blah~
DO ~SetGlobal("KKBanter11", "GLOBAL", 2) IncrementGlobal("KKInStage1x", "GLOBAL", 1)~ EXIT
So at the end of this A2 block, KKBanter11 is set to 2 preventing A2 from happening again, whereas the Stage is incremented. This means that if this conversation occurred in Stage 2 it would go on to Stage 3, invoking the next Banter Set ; similarly if it were Stage 1 it would go on to Stage 2. The IncrementGlobal means that regardless of which stage it is currently in, it will simply progress to next stage.
If you were to have this Banter Set composed of 3 Banters, ie A1 A2 A3, you would simply NOT put
IncrementGlobal("KKInStage1x", "GLOBAL", 1).
A3 would fire on the condition
Global("KKBanter11", "GLOBAL", 2),
and at the end of A3 you would put
DO ~SetGlobal("KKBanter11", "GLOBAL", 3) IncrementGlobal("KKInStage1x", "GLOBAL", 1)~ EXIT
to progress to the next Banter Set.
Note that in this example I used 4 Banter Sets, each set composing of 2 Banters, ie A1 A2 B1 B2 C1 C2 D1 D2.
With modifications to the algorithm provided though, there isn't anything to stop the Modder from coding varying lengths of Banter Sets, ie A1 A2 A3 B1 C1 C2 D1 D2 D3 D4.
Btw I use Banter Sets because the topics from one Banter is closely interrelated to the next (like questions leading on). I don't think every Modder does this so you can just use this randomisation simply for random banters / flirts.
Edited by Zyraen, 21 November 2007 - 09:21 AM.