The Black Wyrm Lair Forums
The Black Wyrm's Lair Terms of Use Help Search Members Calendar

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> BGII: Creating forced encounters..., Like the Drizzt one.
Andyr
post Sep 9 2004, 11:24 AM
Post #1


A fool and a knave


Forum Member
Posts: 153
Joined: 21-July 04
From: Oxford, UK




Note: Apparantly the scripting command I use here is only available in Bg2 - ToB


If you've played BG2, you'll probably remember the one-off encounter with everyone's (least?) favourite drow ranger Drizzt shortly after leaving the Underdark... Would you like to be able to force similar encounters in your mod? I wanted to, and I've figured out a method for doing, and here it is.

Firstly, the resources I used (which you'll probably have anyway) were:

WeiDU http://www.WeiDU.org
Near Infinity http://www.idi.ntnu.no/~joh/ni
The IESDP http://iesdp.gibberlings3.net
A calculator with a 'hex' function (thoughtfully provided by Windows smile.gif)

I'll start by describing what I myself was trying to do. I was trying to add an encounter which would trigger once when the player had a certain NPC in their party and left the Umar Hills (AR1100), taking them to a custom area of my design (which I called A#book). I did not want it to be possible to return to A#book once you had been there.

The file WORLDMAP.WMP controls random encounter areas and probabilities. Open it up in Near Infinity, and click on the Edit tab. The bottom field should be called Map Entry 0- click on Edit again.

You should be looking at (well, in my copy of BG2 at least) 13 fields, then 24 named Area Entry x and 164 named Area Link x. The IESDP explains each worldmap area has an Area Entry, and each exit from the area has an Area Link. Looking in the Area Entry for AR1100 (number 7), I see this uses Area Link fields 57-66 (it shows which ones are exits North, South, East and West).

Go examine one of them, and look in the IESDP too. You'll notice that all the Area Link entries for AR1100 have None specified in the Random Encounter section: So firstly, we need to fix that. What I'm going to do is use WeiDU to change Random Encounter Area 1 for each area link to read A#book. The IESDP tells us this field is stored at offset 2c in the Area Link, so we add this to the offset of the start of the Area Link and use WRITE_ASCII to fill in our custom area. I did this for all area links from AR1100- I want to make sure the encounter is accessible from wherever you try to go. A couple of points to note:

1. You don't need the .ARE extension for the custom area when you WRITE_ASCII.
2. WeiDU doesn't seem to want to install if you use the number in hexadecimal, so convert your offset back to decimal.
3. The offset between each area link is D8, or 216, so you can simply add this value to work out the offset of the next area link you need to patch.
4. The worldmap file is saved in your save games too. So, to see the changes you make, you need to start a new game after patching WORLDMAP.WMP. I made the mistake of not doing so a few times and was most dismayed why it didn't appear to have worked.

My .TP2 code then looked like this. Note the comments (//text) are purely for my visual aid:

QUOTE

//Creating random encounters from Umar Hills (AR1100, Area links 57-76) to custom area A#book.
COPY_EXISTING ~Worldmap.WMP~ ~override/Worldmap.wmp~
WRITE_ASCII ~18556~ ~A#book~ //link 57
WRITE_ASCII ~18772~ ~A#book~ //link 58
WRITE_ASCII ~18988~ ~A#book~ //link 59
WRITE_ASCII ~19204~ ~A#book~ //link 60
WRITE_ASCII ~19gibberlings3.netgibberlings3.net420~ ~A#book~ //link 61
WRITE_ASCII ~19636~ ~A#book~ //link 62
WRITE_ASCII ~19852~ ~A#book~ //link 63
WRITE_ASCII ~20068~ ~A#book~ //link 64
WRITE_ASCII ~20284~ ~A#book~ //link 65
WRITE_ASCII ~20500~ ~A#book~ //link 66
WRITE_ASCII ~20716~ ~A#book~ //link 67
WRITE_ASCII ~20932~ ~A#book~ //link 68
WRITE_ASCII ~21148~ ~A#book~ //link 69
WRITE_ASCII ~21364~ ~A#book~ //link 70
WRITE_ASCII ~21580~ ~A#book~ //link 71
WRITE_ASCII ~21796~ ~A#book~ //link 72
WRITE_ASCII ~22012~ ~A#book~ //link 73
WRITE_ASCII ~22228~ ~A#book~ //link 74
WRITE_ASCII ~22444~ ~A#book~ //link 75
WRITE_ASCII ~22660~ ~A#book~ //link 76
Note that since there were originally no random encounters from AR1100 the probability of one was set to 0: This is good for us. You may need to set it to 0 yourself if you plan to use an area with existing random encounters, though.

So, now there is an encounter area to link to. You just need to use scripting to trigger it. As I said before, I wanted my encounter to happen the first time party left the Umar Hills with my NPC certain conditions, so I added the following to my NPC's override script. Note I've removed the conditions but left in a global variable to remind you you need to set one to make sure it only happens once!

QUOTE

IF
(Some Conditions)
Global("Set","GLOBAL",0)
THEN
RESPONSE #100
SetGlobal("Set","GLOBAL",1)
SetEncounterProbability("AR1100","AR0700",100)
SetEncounterProbability("AR1100","AR0400",100)
SetEncounterProbability("AR1100","AR0300",100)
SetEncounterProbability("AR1100","AR0500",100)
SetEncounterProbability("AR1100","AR0800",100)
SetEncounterProbability("AR1100","AR0900",100)
SetEncounterProbability("AR1100","AR1000",100)
SetEncounterProbability("AR1100","AR1400",100)
SetEncounterProbability("AR1100","AR1300",100)
SetEncounterProbability("AR1100","AR1200",100)
SetEncounterProbability("AR1100","AR0020",100)
SetEncounterProbability("AR1100","AR1404",100)
SetEncounterProbability("AR1100","AR1304",100)
SetEncounterProbability("AR1100","AR2000",100)
SetEncounterProbability("AR1100","AR1900",100)
SetEncounterProbability("AR1100","AR1700",100)
SetEncounterProbability("AR1100","AR2500",100)
SetEncounterProbability("AR1100","AR2600",100)
SetEncounterProbability("AR1100","AR1800",100)
SetEncounterProbability("AR1100","AR1600",100)
SetEncounterProbability("AR1100","AR2100",100)
SetEncounterProbability("AR1100","AR1500",100)
SetEncounterProbability("AR1100","AR2300",100)
SetEncounterProbability("AR1100","AR2800",100)
END


This sets the probability of encounters from AR1100 to basically anywhere else on the worldmap (as these areas are the other places with Area Entry entries in WORLDMAP.WMP) to 100. And since we've set the custom area A#book as the random encounter area, this is where they'll go. Simple! biggrin.gif

Finally, you need to at some point set the probabilities of encounters back to 0 to ensure you don't keep revisiting the area. This is again simple:

QUOTE
IF
(Some other conditions)
Global("Set","GLOBAL",1)
THEN
RESPONSE #100
SetGlobal("Set","GLOBAL",2)
SetEncounterProbability("AR1100","AR0700",0)
SetEncounterProbability("AR1100","AR0400",0)
SetEncounterProbability("AR1100","AR0300",0)
SetEncounterProbability("AR1100","AR0500",0)
SetEncounterProbability("AR1100","AR0800",0)
SetEncounterProbability("AR1100","AR0900",0)
SetEncounterProbability("AR1100","AR1000",0)
SetEncounterProbability("AR1100","AR1400",0)
SetEncounterProbability("AR1100","AR1300",0)
SetEncounterProbability("AR1100","AR1200",0)
SetEncounterProbability("AR1100","AR0020",0)
SetEncounterProbability("AR1100","AR1404",0)
SetEncounterProbability("AR1100","AR1304",0)
SetEncounterProbability("AR1100","AR2000",0)
SetEncounterProbability("AR1100","AR1900",0)
SetEncounterProbability("AR1100","AR1700",0)
SetEncounterProbability("AR1100","AR2500",0)
SetEncounterProbability("AR1100","AR2600",0)
SetEncounterProbability("AR1100","AR1800",0)
SetEncounterProbability("AR1100","AR1600",0)
SetEncounterProbability("AR1100","AR2100",0)
SetEncounterProbability("AR1100","AR1500",0)
SetEncounterProbability("AR1100","AR2300",0)
SetEncounterProbability("AR1100","AR2800",0)
END


Thanks to SimDing0 and MaxTeamBG for helping me figure some of this stuff out. smile.gif


--------------------
"We are the Gibberlings Three, as merry a band as you ever did see..." - Home of IE mods.

<jcompton> Suggested plugs include "Click here so Compton doesn't ban me. http://www.pocketplane.net/ub"
Go to the top of the page
 
Quote Post
Echon
post Sep 9 2004, 03:08 PM
Post #2





Forum Member
Posts: 57
Joined: 22-July 04
From: Denmark




QUOTE(Andyr @ Sep 9 2004, 11:24 AM)
Note: Apparantly the scripting command I use here is only available in Bg2 - ToB

Sucks!

Anyway, I think I will be able to do it by overwriting the existing random encounter areas with some scripting.

-Echon


--------------------
Go to the top of the page
 
Quote Post
Andyr
post Sep 9 2004, 07:37 PM
Post #3


A fool and a knave


Forum Member
Posts: 153
Joined: 21-July 04
From: Oxford, UK




Cool, well if you get it working then I'm sure a tutorial would be appreciated! smile.gif


--------------------
"We are the Gibberlings Three, as merry a band as you ever did see..." - Home of IE mods.

<jcompton> Suggested plugs include "Click here so Compton doesn't ban me. http://www.pocketplane.net/ub"
Go to the top of the page
 
Quote Post
jastey
post Oct 7 2004, 10:32 PM
Post #4





Forum Member
Posts: 1366
Joined: 22-August 04
From: Germany




QUOTE(Andyr @ Sep 9 2004, 01:24 PM)
Note: Apparantly the scripting command I use here is only available in Bg2 - ToB

Does that mean for BGII with ToB installed or only in the ToB part?

Question: Would it be possible to use the script to code an encounter that should happen before the player goes into one specific area? If I see it right it should be possible in a quite similar way.

Very useful tutorial, thanks! smile.gif

This post has been edited by jastey: Oct 7 2004, 10:33 PM
Go to the top of the page
 
Quote Post
Andyr
post Oct 7 2004, 11:12 PM
Post #5


A fool and a knave


Forum Member
Posts: 153
Joined: 21-July 04
From: Oxford, UK




Only with ToB installed.

Yeh, I guess it could be possible, though you may have to change the area links from every area your aforementioned one can be entered from in that case...


--------------------
"We are the Gibberlings Three, as merry a band as you ever did see..." - Home of IE mods.

<jcompton> Suggested plugs include "Click here so Compton doesn't ban me. http://www.pocketplane.net/ub"
Go to the top of the page
 
Quote Post
SConrad
post Apr 21 2005, 06:29 PM
Post #6





Forum Member
Posts: 22
Joined: 29-July 04
From: Adelaide, Australia




I've done this another way; by fixing it all in the tp2 so there's no need for scripting.

Full info here.

I can't be bothered to explain every little detail in it now, all the other tp2-ninjas will understand what I'm doing, and the rest can ask and I will answer. smile.gif

Note that I coded this before I actually realised that there is a "# of area entries" inside the .wmp, and I was too proud over my own code for keeping track on the number of area entries to change it. I did add an additional check, though. Also note that I added a check for the area from G3A. I dunno if there's any other mods adding areas to the worldmap which doesn't use AR****.are, but I'll add them if needed.

CODE
// Update the worldmap to make sure the random encounter in between Waukeen and Slums happens
COPY_EXISTING ~worldmap.wmp~ ~override~
 READ_LONG 0xc "map_off"
 SET "entry"       = ("%map_off%" + 0xb8)
 SET "outer_check" = 0
 SET "inner_check" = 0
 SET "num_ent"     = 0
 WHILE ("%outer_check%" = 0) BEGIN
   READ_ASCII ("%entry%" + 0x8) "area" (2)
   READ_ASCII ("%entry%" + 0x8) "spec_area" (6)
   WHILE (("%spec_area%" STRING_COMPARE_CASE "AR0700" = 0) AND ("%inner_check%" = 0)) BEGIN
     READ_SHORT ("%entry%" + 0x50)                   "nlink"
     READ_SHORT ("%entry%" + 0x50 + 0x8)             "wlink"
     READ_SHORT ("%entry%" + 0x50 + 0x8 + 0x8)       "slink"
     READ_SHORT ("%entry%" + 0x50 + 0x8 + 0x8 + 0x8) "elink"
     SET "inner_check" = 1
   END
   PATCH_IF (("%area%" STRING_COMPARE_CASE "AR" = 0) OR ("%area%" STRING_COMPARE_CASE "G3" = 0)) BEGIN
     SET "num_ent" = ("%num_ent%" + 1)
   END ELSE
   PATCH_IF ("%area%" STRING_COMPARE_CASE "AR" = 1) BEGIN
     SET "outer_check" = 1
   END
   SET "entry" = ("%entry%" + 0xf0)
 END
 SET "patching_done" = 0
 READ_LONG  0x30 "area_num"
 WHILE (("%patching_done%" = 0) AND ("%num_ent%" = "%area_num%")) BEGIN
   SET "1stlink" = (("%map_off%" + 0xb8) + ("%num_ent%" * 0xf0) + ("%nlink%" * 0xd8))
   SET "2ndlink" = (("%map_off%" + 0xb8) + ("%num_ent%" * 0xf0) + ("%wlink%" * 0xd8))
   SET "3rdlink" = (("%map_off%" + 0xb8) + ("%num_ent%" * 0xf0) + ("%slink%" * 0xd8))
   SET "4thlink" = (("%map_off%" + 0xb8) + ("%num_ent%" * 0xf0) + ("%elink%" * 0xd8))
   PATCH_IF ("1stlink" > 0) BEGIN
     WRITE_ASCII ("%1stlink%" + 0x2c) ~ARSC#0~
     WRITE_SHORT ("%1stlink%" + 0x54) 101
   END
   PATCH_IF ("2ndlink" > 0) BEGIN
     WRITE_ASCII ("%2ndlink%" + 0x2c) ~ARSC#0~
     WRITE_SHORT ("%2ndlink%" + 0x54) 101
   END
   PATCH_IF ("3rdlink" > 0) BEGIN
     WRITE_ASCII ("%3rdlink%" + 0x2c) ~ARSC#0~
     WRITE_SHORT ("%3rdlink%" + 0x54) 101
   END
   PATCH_IF ("4thlink" > 0) BEGIN
     WRITE_ASCII ("%4thlink%" + 0x2c) ~ARSC#0~
     WRITE_SHORT ("%4thlink%" + 0x54) 101
   END
   SET "patching_done" = 1
 END
BUT_ONLY_IF_IT_CHANGES


--------------------
Spellhold Studios

sconrad.NET

Khadion NPC-mod - Team leader, head designer
Hubelpot NPC-mod - Team leader, coder
NPC Damage - Coder
PC Soundsets - Coder, voice actor
Brythe NPC-mod - Designer
DragonLance TC - Glory of Istar - Designer
The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
The Jerry Zinger Show - Producer

Iron Modder 5 - Winner
Go to the top of the page
 
Quote Post
Yacomo
post Apr 22 2005, 05:53 AM
Post #7





Forum Member
Posts: 18
Joined: 18-March 05
From: Zug, Switzerland




QUOTE(SConrad @ Apr 21 2005, 07:29 PM)
Note that I coded this before I actually realised that there is a "# of area entries" inside the .wmp, and I was too proud over my own code for keeping track on the number of area entries to change it. I did add an additional check, though. Also note that I added a check for the area from G3A. I dunno if there's any other mods adding areas to the worldmap which doesn't use AR****.are, but I'll add them if needed.

Hi SConrad,

Nice coding! But there are indeed mods that add areas different from AR**** to the worldmap. One that comes to mind is Bonehill which adds 'BH', think TDD adds 'DD', but not 100% sure. If you want to have a look a large bunch of them have been added to my worldmap mod. But checking for the '# of area entries' would probably be the best solution cool.gif

Regards,

Yacomo


--------------------
Go to the top of the page
 
Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:



- Lo-Fi Version Time is now: 14th November 2024 - 03:33 PM