Jump to content

Photo

Spawning Joinable BG2 NPCs in a Seamless Fashion


7 replies to this topic

#1 CamDawg

CamDawg

    ALL GLORY TO THE HYPNOTOAD

  • Gibberling Poobah
  • 9724 posts
  • Gender:Not Telling

Posted 15 February 2004 - 05:16 PM

I'm a big fan of seamless integration of mods into the game, to the point where it's difficult to tell modded content from original. One thing that's bothered me is that I have yet to see a seemless integration of joinable NPC spawning in BG2. The original characters will always join at a level appropriate to the PC by using four CRE files and some some info in the baldur.sav file. Once they join, they stay at the same level for the rest of the game.

For mod NPCs, to avoid messing with baldur.sav I've observed two approaches. The first involves creating a single CRE file, and then adding XP appropriate to match the PC's. The drawback to this approach is that you can have an NPC join and then have to do level-ups, which says "mod!" The second approach is to create multiple CRE files and then spawn the NPC using the CRE file closest in XP to the PC. The drawback to this approach is that if the PC leaves and returns later to pick up the NPC, the NPC could be several levels behind the PC.

After talking and brainstorming with Grim, he got me thinking about a better way to spawn joinable NPCs. The goal is to have the NPC spawn and join in a similar fashion to Bioware NPCs--their initial joining will be at a similar level to the PC's and then stay the same for the rest of the game if they're kicked out of the party. I haven't seen this approach on any of the NPC mods yet, so apologies if this is already known and/or used. :D

So here's the code I'm using to spawn Delainy at the Mithrest Inn. C!DELA10 to C!DELA15 are creature files for Delainy at different levels and her death variable is C!Delai.

IF
   !Global("C!DelainySpawn","AR0704",1)
   Global("C!DelJoinedOnce","GLOBAL",0)
   XPLT(Player1,280001)
THEN
   RESPONSE #100
      ActionOverride("C!Delai",DestroySelf())
      CreateCreature("C!DELA10",[387.809],6) // Delainy
      SetGlobal("C!DelainySpawn","AR0704",1)
END

IF
   !Global("C!DelainySpawn","AR0704",2)
   Global("C!DelJoinedOnce","GLOBAL",0)
   XPGT(Player1,280000)
   XPLT(Player1,600001)
THEN
   RESPONSE #100
      ActionOverride("C!Delai",DestroySelf())
      CreateCreature("C!DELA11",[387.809],6) // Delainy
      SetGlobal("C!DelainySpawn","AR0704",2)
END

IF
   !Global("C!DelainySpawn","AR0704",3)
   Global("C!DelJoinedOnce","GLOBAL",0)
   XPGT(Player1,600000)
   XPLT(Player1,1000001)
THEN
   RESPONSE #100
      ActionOverride("C!Delai",DestroySelf())
      CreateCreature("C!DELA13",[387.809],6) // Delainy
      SetGlobal("C!DelainySpawn","AR0704",3)
END

IF
   !Global("C!DelainySpawn","AR0704",4)
   Global("C!DelJoinedOnce","GLOBAL",0)
   XPGT(Player1,1000000)
THEN
   RESPONSE #100
      ActionOverride("C!Delai",DestroySelf())
      CreateCreature("C!DELA15",[387.809],6) // Delainy
      SetGlobal("C!DelainySpawn","AR0704",4)
END

Upon the party's entrance to the Mithrest, Delainy is spawned at a level on par with the PC. Should the experience of the PC change to a higher range, then Delainy will be destroyed and recreated at the appropriate level. All this is dependent on Delainy never having joined. Once Delainy joins, the global variable C!DelJoinedOnce is bumped to 1 to prevent Delainy from continuously respawning.

This solution is still not without drawbacks. While unlikely, if the PC were to gain XP and exceed one of the breakpoints while in the presence of Delainy, they could see her disappear and reappear. From a scripting and dialogue standpoint, this approach makes LOCALS variables and the NumTimesTalkedTo trigger worthless, because the NPC could be destroyed and recreated. The workaround is to use GLOBAL variables for triggers and actions until the NPC joins the party.

Edited by CamDawg, 20 May 2004 - 07:55 AM.

Why is this Hypnotoad video so popu... ALL GLORY TO THE HYPNOTOAD.


#2 Barren Fischa

Barren Fischa
  • Retired Gibberlings
  • 187 posts
  • Gender:Male
  • Location:Here and there... Oh, and here too

Posted 05 March 2004 - 08:38 PM

The second approach is to create four CRE files and then spawn the NPC using the CRE file closest in XP to the PC. The drawback to this approach is that if the PC leaves and returns later to pick up the NPC, the NPC could be several levels behind the PC.

That's what happens with the original Bioware NPCs. They'll always be the same level as when you first entered the area they were in.

#3 CamDawg

CamDawg

    ALL GLORY TO THE HYPNOTOAD

  • Gibberling Poobah
  • 9724 posts
  • Gender:Not Telling

Posted 06 March 2004 - 07:17 AM

Well, yes and no.

When I enter the Copper Coronet, the game looks at the level of the PC and spawns Anomen at an appropriate level. If Anomen joins the party, he'll be set at that level for the rest of the game. However, if he does not join, then every time I enter the Copper Coronet the game will re-determine which Anomen to spawn. If I meet Anomen in chapter 2, but don't let him join, when I return in Chapter 6 he will be a higher level Anomen to match the higher XP of the PC.

Why is this Hypnotoad video so popu... ALL GLORY TO THE HYPNOTOAD.


#4 Idobek

Idobek

    Dust Bunny

  • Retired Gibberlings
  • 1001 posts
  • Gender:Male
  • Location:England

Posted 08 March 2004 - 02:42 AM

While unlikely, if the PC were to gain XP and exceed one of the breakpoints while in the presence of Delainy, they could see her disappear and reappear.

You need to set a global to say she has spawned. And then reset it whenever you leave the area.

IF
  Global("C!DelainySpawned","GLOBAL",0)
  !Global("C!DelainySpawn","AR0704",1)
  Global("C!DelJoinedOnce","GLOBAL",0)
  XPLT(Player1,280001)
THEN
  RESPONSE #100
      ActionOverride("C!Delai",DestroySelf())
      CreateCreature("C!DELA10",[387.809],6) // Delainy
      SetGlobal("C!DelainySpawned","GLOBAL",1)
      SetGlobal("C!DelainySpawn","AR0704",1)
END

In area script of all areas that can be accessed from AR0704:
IF
   Global("C!DelainySpawned","GLOBAL",1)
THEN
   RESPONSE #100
      SetGlobal("C!DelainySpawned","GLOBAL",0)
      Continue()
END
Or maybe a block in baldur.bcs:
IF
   Global("C!DelainySpawned","GLOBAL",1)
   !AreaCheck("AR0704")
THEN
   RESPONSE #100
      SetGlobal("C!DelainySpawned","GLOBAL",0)
      Continue()
END

Hmm... I haven't tested the code but I think it should work, you get the idea at least.

Edited by Idobek, 08 March 2004 - 02:42 AM.

Did you know G3 has secret forum rules?
Yep. They're generally of the nature 'don't annoy Idobek.'

#5 Ghreyfain

Ghreyfain

    Gots hat

  • Modders
  • 224 posts
  • Gender:Male
  • Location:Calgary, Canada

Posted 01 April 2004 - 04:47 PM

I've been on a bit of a tutorial binge recently, and happened upon this one. Having just tinkered with adding a BG1 NPC, it struck me that this is geared entirely towards BG2. Go here to read japh's tutorial on how to use ADD_GAME_NPC with WeiDU.

#6 Idobek

Idobek

    Dust Bunny

  • Retired Gibberlings
  • 1001 posts
  • Gender:Male
  • Location:England

Posted 02 April 2004 - 12:11 AM

Um... it is supposed to be geared towards BG2. Cam is trying to improve the NPC spawning process.
Did you know G3 has secret forum rules?
Yep. They're generally of the nature 'don't annoy Idobek.'

#7 Ghreyfain

Ghreyfain

    Gots hat

  • Modders
  • 224 posts
  • Gender:Male
  • Location:Calgary, Canada

Posted 02 April 2004 - 12:41 AM

Well yes, I can see that, but if you want to add a BG1 NPC you're going to have to use the ADD_GAME_NPC function, since BG1 doesn't allow things into your party that aren't already in the baldur.gam file.

#8 CamDawg

CamDawg

    ALL GLORY TO THE HYPNOTOAD

  • Gibberling Poobah
  • 9724 posts
  • Gender:Not Telling

Posted 02 April 2004 - 12:59 AM

At present, I know squat about adding NPCs to BG1 other than they need to be added to the GAM file ionstead of the nice, BG2 way of handling it. Lemme take a look at Japh's tutorial and I'll update this one as appropriate.

Why is this Hypnotoad video so popu... ALL GLORY TO THE HYPNOTOAD.




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users