Author Topic: Trouble with area script  (Read 1493 times)

Offline Meira

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Female
  • I'm the snow on your lips
    • Amber's Home
Trouble with area script
« on: December 06, 2004, 12:23:30 PM »
While testing something completely different we ran across a strange problem I didn't know could exist. As usual, I have a script appended to an area script (AR1005 in our case) that spawns a creature (and does some assorted things). Up to now it has worked just fine, but now I noticed that if one loads a save game in which the area in question has been visited before the mod was installed, the game uses the "old" version of the area script without the appended bits.

This is strange, because for example Kelsey uses exactly the same kind of method but spawns OK even if you visit the Government district without Kelsey installed, save the game, install Kelsey, load the game and revisit the Government district.

Could this have something to do with the fact that AR1000 (Gov. dist.) is a "master area"(listed in MASTAREA.2DA) and AR1005 is not? Or have I just forgotten to do something that forces the area to reload its script upon re-entry?
 

Online Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Trouble with area script
« Reply #1 on: December 06, 2004, 12:57:08 PM »
You have assigned a new script to the area and Kelsey extends the existing area script?

-Echon
« Last Edit: December 06, 2004, 12:58:42 PM by Echon »

Offline Meira

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Female
  • I'm the snow on your lips
    • Amber's Home
Re: Trouble with area script
« Reply #2 on: December 06, 2004, 01:11:11 PM »
No, area AR1005 already has an area script (AR1005.BCS) to which we appended our script using EXTEND_TOP (I think Kelsey uses EXTEND_BOTTOM but that shouldn't make a difference here).

Offline Ghreyfain

  • Moderator
  • Planewalker
  • *****
  • Posts: 4705
  • Gender: Male
    • Pocket Plane Group
Re: Trouble with area script
« Reply #3 on: December 06, 2004, 01:13:46 PM »
Care to paste the script snippet?
Earn Money Sleeping.

Offline Meira

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Female
  • I'm the snow on your lips
    • Amber's Home
Re: Trouble with area script
« Reply #4 on: December 06, 2004, 01:44:33 PM »
Well, here is the relevant script that gets appended to the area .bcs file, but what is strange is the fact that if you begin a new game or load a save in which the area has not been visited prior to the installation of the mod, everything works like a charm, but if you load a save game in which the area was visited before the mod was installed, nothing in the following script works. There should be nothing wrong with the script itself, but is looks as if the game uses the unextended version of the area script if the area has been visited previously (when the mod was not yet installed). I know that some information about previously visited areas is included in the save game, but I don't think that the whole area script gets saved. Could it be an issue with cache or something...?

So here's the script: (and yes, we have checked that it really gets added to the relevant .bcs file)

IF
   Global("M#PrisonKDeact","AR1005",0)
   !Dead("prisonk1")   
   GlobalGT("M#AmberRescue","GLOBAL",0)
   GlobalLT("M#AmberRescue","GLOBAL",7)
THEN
   RESPONSE #100
   Deactivate("prisonk1")
   SetGlobal("M#PrisonKDeact","AR1005",1)      
END

IF
   Global("M#AmberRescue","GLOBAL",1)
   Global("M#MaxTGSpawn","AR1005",0)
THEN
   RESPONSE #100
   CreateCreature("m#maxtg",[907.486],0)
   SetGlobal("M#MaxTGSpawn","AR1005",1)
END

IF
   Global("M#AmberRescue","GLOBAL",1)
   Global("M#AmberSpawn","AR1005",0)
   !Dead("m#amber")
   XPLT(Player1,300000)
THEN
   RESPONSE #100
   SetGlobal("M#AmberSpawn","AR1005",1)
   SetGlobal("M#AmberLvl","GLOBAL",10)
   CreateCreature("m#ambr10",[775.415],13)   
END

IF
   Global("M#AmberRescue","GLOBAL",1)
   Global("M#AmberSpawn","AR1005",0)
   !Dead("m#amber")
   XPGT(Player1,299999)
   XPLT(Player1,800000)
THEN
   RESPONSE #100
   SetGlobal("M#AmberSpawn","AR1005",1)
   SetGlobal("M#AmberLvl","GLOBAL",12)
   CreateCreature("m#ambr12",[775.415],13)   
END

IF
   Global("M#AmberRescue","GLOBAL",1)
   Global("M#AmberSpawn","AR1005",0)
   !Dead("m#amber")
   XPGT(Player1,799999)
   XPLT(Player1,1000000)
THEN
   RESPONSE #100
   SetGlobal("M#AmberSpawn","AR1005",1)
   SetGlobal("M#AmberLvl","GLOBAL",14)
   CreateCreature("m#ambr14",[775.415],13)   
END

IF
   Global("M#AmberRescue","GLOBAL",1)
   Global("M#AmberSpawn","AR1005",0)
   !Dead("m#amber")
   XPGT(Player1,999999)
THEN
   RESPONSE #100
   SetGlobal("M#AmberSpawn","AR1005",1)
   SetGlobal("M#AmberLvl","GLOBAL",15)
   CreateCreature("m#ambr15",[775.415],13)   
END

IF
   OR(4)
     Global("M#AmberRescue","GLOBAL",1)
     Global("M#AmberRescue","GLOBAL",2)
     Global("M#AmberRescue","GLOBAL",3)
       Global("M#AmberRescue","GLOBAL",4)
   !Global("M#CellDoorL","GLOBAL",1)
THEN
   RESPONSE #100
   CloseDoor("DOOR06")
   Lock("DOOR06")
   SetGlobal("M#CellDoorL","GLOBAL",1)
END

Offline Ghreyfain

  • Moderator
  • Planewalker
  • *****
  • Posts: 4705
  • Gender: Male
    • Pocket Plane Group
Re: Trouble with area script
« Reply #5 on: December 06, 2004, 02:20:46 PM »
Are you sure this works when you test it with a new game?  If AR1005 isn't in mastarea.2da, as you say, then none of the area globals you use should work at all.  Personally, I'd just switch them to GLOBAL to make things easier in general.  If it still doesn't work that way, we'll be able to look for other errors.
Earn Money Sleeping.

Online Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Trouble with area script
« Reply #6 on: December 06, 2004, 02:51:28 PM »
Are you sure that only master areas can have area globals? I just thought they could not be stored in the savegame, like LOCALS.

-Echon

Offline jcompton

  • Niche Exploiter
  • Administrator
  • Planewalker
  • *****
  • Posts: 7246
Re: Trouble with area script
« Reply #7 on: December 06, 2004, 02:53:05 PM »
At least in BG2, LOCALS _are_ stored in the saved game.
Cespenar says, "Kelsey and friends be at the Pocket Plane? Ohhh yesssss!" http://www.pocketplane.net

Offline Meira

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Female
  • I'm the snow on your lips
    • Amber's Home
Re: Trouble with area script
« Reply #8 on: December 06, 2004, 03:08:53 PM »
Quote
Are you sure this works when you test it with a new game?  If AR1005 isn't in mastarea.2da, as you say, then none of the area globals you use should work at all.  Personally, I'd just switch them to GLOBAL to make things easier in general.  If it still doesn't work that way, we'll be able to look for other errors.

Yes, we have tested this area (and other areas that use local variables but are not in the mastarea.2da) with a new game that was created with the mod installed and also with save games that were created before the mod was installed but in which we hadn't yet visited the area in question. Everything worked just fine. I didn't even know that areas have to be in mastarea.2da in order to use local variables in them (I knew they had to be listed in it for weather to work, though...).

The problem occurred only when the area had already been visited before the mod was installed. So you think using globals instead of area locals could solve the problem?

EDIT: I switched the area locals to globals, which made no difference at all when tested. :(
« Last Edit: December 06, 2004, 03:53:17 PM by Meira »

Offline SimDing0™

  • Back In Black
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3496
  • Gender: Male
  • Word Enhancer
Re: Trouble with area script
« Reply #9 on: December 06, 2004, 04:13:02 PM »
I dunno where the myth that areas have to be in mastarea.2da to allow them to have their own variables came from, but it's certainly not true. I've got many a working script using them without 2da entries. On the other hand, they DO tend not to work for no apparent reason.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: