Jump to content


Creating Forced Encounters


  • Please log in to reply
No replies to this topic

#1 -Andyr_-

-Andyr_-
  • Guest

Posted 02 April 2004 - 02:44 AM

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://dragonlance.teambg.net/iesdp/
A calculator with a 'hex' function (thoughtfully provided by Windows )

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:

//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 ~19420~ ~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!

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!

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:

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.

Edited by Andyr, 02 April 2004 - 04:25 AM.