Jump to content


Photo

Banter Randomisation using Scripting


  • Please log in to reply
1 reply to this topic

#1 Zyraen

Zyraen
  • Modder
  • 1402 posts

Posted 21 November 2007 - 09:20 AM

Banter Randomisation

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.

kiyos.jpg____btlbn2.gif____kovaS.jpg
Love between a Law Enforcer and a Fugitive - can such a thing even happen?
SoA Release - Overview / Download Links

Zyraen's Miscellaneous Mods - Ust Natha Accelerator, item tweaks, XP caps, The Ub3r Reaver Kit, and much more...
Spellhold Gauntlet - more than just a Spellhold-Be-Gone
Hidden Kits - hidden dual-classed kits with a twist for progression


#2 Zyraen

Zyraen
  • Modder
  • 1402 posts

Posted 21 November 2007 - 09:35 AM

Banter Randomisation with Too Many Permutations

As mentioned in the post before this, if there are too many permutations it might not make sense to list out all 24 etc or more of them in the Conditionals. What you can use is the following Algorithm

Let's say I have 7 Banter Sets (from 1-7), and I wish to fill 4 slots as follows.

Global("KKStage11", "GLOBAL", ?)
Global("KKStage12", "GLOBAL", ?)
Global("KKStage13", "GLOBAL", ?)
Global("KKStage14", "GLOBAL", ?)

The code would go...

IF
Global("KKStage11Set","GLOBAL",0)
THEN
RESPONSE #0
RESPONSE #100
SetGlobal("KKStage11Set","GLOBAL",1)
SetGlobal("KKStage11", "GLOBAL", 1)
RESPONSE #100
SetGlobal("KKStage11Set","GLOBAL",1)
SetGlobal("KKStage11", "GLOBAL", 2)
RESPONSE #100
SetGlobal("KKStage11Set","GLOBAL",1)
SetGlobal("KKStage11", "GLOBAL", 3)
RESPONSE #100
SetGlobal("KKStage11Set","GLOBAL",1)
SetGlobal("KKStage11", "GLOBAL", 4)
RESPONSE #100
SetGlobal("KKStage11Set","GLOBAL",1)
SetGlobal("KKStage11", "GLOBAL", 5)
RESPONSE #100
SetGlobal("KKStage11Set","GLOBAL",1)
SetGlobal("KKStage11", "GLOBAL", 6)
RESPONSE #100
SetGlobal("KKStage11Set","GLOBAL",1)
SetGlobal("KKStage11", "GLOBAL", 7)
END

IF
Global("KKStage11Set","GLOBAL",1)
OR(2)
Global("KKStage12Set","GLOBAL",0)
GlobalsEqual("KKStage12?,?KKStage11?)
THEN
RESPONSE #0
RESPONSE #100
SetGlobal("KKStage12Set","GLOBAL",1)
SetGlobal("KKStage12", "GLOBAL", 1)
RESPONSE #100
SetGlobal("KKStage12Set","GLOBAL",1)
SetGlobal("KKStage12", "GLOBAL", 2)
RESPONSE #100
SetGlobal("KKStage12Set","GLOBAL",1)
SetGlobal("KKStage12", "GLOBAL", 3)
RESPONSE #100
SetGlobal("KKStage12Set","GLOBAL",1)
SetGlobal("KKStage12", "GLOBAL", 4)
RESPONSE #100
SetGlobal("KKStage12Set","GLOBAL",1)
SetGlobal("KKStage12", "GLOBAL", 5)
RESPONSE #100
SetGlobal("KKStage12Set","GLOBAL",1)
SetGlobal("KKStage12", "GLOBAL", 6)
RESPONSE #100
SetGlobal("KKStage12Set","GLOBAL",1)
SetGlobal("KKStage12", "GLOBAL", 7)
END

IF
Global("KKStage12Set","GLOBAL",1)
OR(3)
Global("KKStage13Set","GLOBAL",0)
GlobalsEqual("KKStage13?,?KKStage11?)
GlobalsEqual("KKStage13?,?KKStage12?)
THEN
RESPONSE #0
RESPONSE #100
(the 7 possible settings)
END

IF
Global("KKStage13Set","GLOBAL",1)
OR(4)
Global("KKStage14Set","GLOBAL",0)
GlobalsEqual("KKStage14?,?KKStage11?)
GlobalsEqual("KKStage14?,?KKStage12?)
GlobalsEqual("KKStage14?,?KKStage13?)
THEN
RESPONSE #0
RESPONSE #100
(the 7 possible settings)
END

IF
Global("KKStage14Set","GLOBAL",1)
!GlobalsEqual("KKStage14?,?KKStage11?)
!GlobalsEqual("KKStage14?,?KKStage12?)
!GlobalsEqual("KKStage14?,?KKStage13?)
THEN
RESPONSE #100
SetGlobal("KKStage14Set","GLOBAL",2)
END

How does it work?
Well for the first slot no magic there, the slot gets filled with a random value from 1-7.
Only After the first slot is fixed, then the 2nd slot is filled with a random value from 1-7. Then the script loops again, and it checks to make sure it does not repeat the value used in the first slot ; if it does, the 2nd slot is filled with another random value
Only After the 2nd slot is fixed with a value different from the 1st, then the 3rd slot is filled with a random value from 1-7. Then the script loops again, and it checks to make sure it does not repeat the value used in the 1st slot or 2nd slot ; if it does, the number is regenerated.
Only After the 3rd slot is fixed with a value different from the 1st and 2nd, then the 4th slot is filled with a random value from 1-7. Then the script loops again, and it checks to make sure it does not repeat the value used in the 1st slot or 2nd slot or 3rd slot; if it does, the number is regenerated.
The last code block is there as you'll only want to complete the seeding and start the Banters running when the 4th slot is filled with a unique number, ie when
Global("KKStage14Set","GLOBAL",2)

The idea is pretty elementary but can be tricky to get a working Algorithm out, hence the provision of this script.
However please note that the order of the code IS important, as after executing an action, the script starts again from the TOP of the Script. Keep this script together as a block, ideally at the bottom of your BAF file, as it may be a little cumbersome on the processor to loop through 5 extra conditions (though from experience, 5 extra IF THEN blocks are negligible workload)

Edited by Zyraen, 21 November 2007 - 09:45 AM.

kiyos.jpg____btlbn2.gif____kovaS.jpg
Love between a Law Enforcer and a Fugitive - can such a thing even happen?
SoA Release - Overview / Download Links

Zyraen's Miscellaneous Mods - Ust Natha Accelerator, item tweaks, XP caps, The Ub3r Reaver Kit, and much more...
Spellhold Gauntlet - more than just a Spellhold-Be-Gone
Hidden Kits - hidden dual-classed kits with a twist for progression