Jump to content

Scope of MYAREA


temnix

Recommended Posts

I've run into a very inconvenient property of MYAREA-scope variables, in area scripts. Unlike in creature scripts, where MYAREA refers to the particular place the creature is, like the second floor of "Jovial Juggler," changes to MYAREA variables in area scripts of master areas don't apply to slave (local) areas. For example, if you put SetGlobal("VAR","MYAREA",1) in the main script of Beregost, it is not going to be set for streets and inns. Instead one has to write ActionOverride(Currently-Active-Character,SetGlobal("VAR","MYAREA",1)).

This doesn't make much difference if globals need to be only set-unset, it just takes more code to override the action of every party member, in whichever corner they may happen to be, in addition to the impersonal global-setting for the main script. Even then it only covers the areas they are in. If they visit a new house and nobody stays behind on the street to keep the master area active, VAR won't be there. Still, it could be manageable. But if you need to increment MYAREA, this becomes a problem, because the results are going to depend on whether the active characters are on the streets or somewhere inside at the moment the variable changes. In a solo game, where just one character's position needs to be accounted for, code ActionOverride(Player1,IncrementGlobal("VAR","MYAREA",1)) IncrementGlobal("VAR","MYAREA",1)) increases VAR by 1 point for the slave area (only this room or floor) and 1 point for the main area if triggered inside, so if the original value was equal, it still be, but by 2 points for the main area and by zero for any slave area if triggered outside.

Suggestions of alternatives are welcome.

Link to comment

Are you saying that the moment you enter a slave area, the Global("VAR","MYAREA",1) (with MYAREA being the master area) won't be available for trigger if no NPC is still in the master area, but if executing e.g. SetGlobal("VAR","MYAREA",1) via the master area script inside a slave area, the master area MYAREA variable will be set? This sounds like an inconsistency to me.

To give suggestions to your actual problem, I would need more info to what you try to achieve and why you need to use area variables and why you can't just patch the slave areas too, or use spelled out area variables (with "arxxxx" instead of "MYAREA").

Link to comment

It is a confusing situation. And I don't completely understand it myself. I know that the setting and the reading of valuables are consistent in that from a slave area they are neither set nor read for the master area or for the rest of the area complex, all those other slave areas. If you set VAR at 1 in AR3303 and exit to AR3300, it won't be detected there. And vice versa: VAR set to 1 at AR3300 won't be detected in slave areas. The problem here is that a master area like AR3300 plays two roles: it is a sort of overseer for the smaller areas, who don't need to have scripts of their own, but it is also itself an area like them. And this is where the scope problem comes in: what does MYAREA apply to in AR3300? Only to itself, it turns out. The "overseer" role of a master area is that its GLOBAL-level variables work for the slave areas. Even timers of creatures left in the master area finish correctly when it is inactive, in the LOCALS scope anyway, and GLOBAL too, I'm sure. Nobody from the party needs to be there. But when it comes to the MYAREA scope...

I need all this for a Reputation system that would be local as well as global. Crimes and achievements are supposed to lower or raise local reputation. New master areas, where the party hasn't been yet, would set its Reputation to 10 the first time they are entered. Returning to a place, reputation should spring back to the local value, but global reputation should catch up after a while and update the local reputation, and itself become adjusted by it. I more or less had this worked out when I ran into the fact that instead of one MYAREA value that could be factored in, an area complex has a MYAREA for every place, all unconnected. Changing one doesn't do anything to others and isn't recognized there.

Setting an area-specific global like "AR3300" instead isn't going to work because there is no telling how many and which slave areas there are for a master area. I would need to know this to patch them with checks. But it seems that the slave relation is established the first time the party enters an area from a master area, if it isn't a master area itself. I copied a sub-area for AR0800 as AR0720, teleported the party there in a new game. The moment I stepped through the door into a former connection, AR0800, the script for that area began to apply and continued after everyone returned inside. It looks like I made AR0720 into a slave of AR0800.

Edited by temnix
Link to comment

As Lauriel says, can't you instead use global vars instead of myarea for regions? Master-slave relationship isn't particularly reliable.

E.g. patch this into all master regions:

IF
  !Global("current_region","global",3300)
THEN
  RESPONSE #100
    SetGlobal("current_region","global",3300)
END

For reputation change use SetGlobal("change_rep","global",1).

Finally, put this into baldur.bcs:

IF
  GlobalGT("change_rep","global",0)
  Switch("current_region","global")
THEN
  RESPONSE #1100
    IncrementGlobal("rep_1100","global",1)
    IncrementGlobal("change_rep","global",-1)
  RESPONSE #3300
    IncrementGlobal("rep_3300","global",1)
    IncrementGlobal("change_rep","global",-1)
END

IF
  GlobaLT("change_rep","global",0)
  Switch("current_region","global")
THEN
  RESPONSE #1100
    IncrementGlobal("rep_1100","global",1)
    IncrementGlobal("change_rep","global",1)
  RESPONSE #3300
    IncrementGlobal("rep_3300","global",1)
    IncrementGlobal("change_rep","global",1)
END

 

Edited by Ardanis
Link to comment

An update: the script of a master area doesn't recognize a MYAREA-scope variable, set from another area, even written specifically for the master area. In AR2301 there is no way at all to set "VAR","AR2300",1. The conditions for setting that variable are recognized (if the triggers are GLOBAL, and GLOBAL variables are written, too), but the local variable doesn't change. It doesn't even help to add a presence check for characters: TriggerOverride(Player1,AreaCheck("AR2300")) returns true in any slave area. I'm seriously fed up with this.

Edited by temnix
Link to comment

It turns out I might have been wrong about MYAREA. I just don't know to what extent exactly. The areas where I tested its stubborness, a house by the side of the road and a couple other places like that, turned out to be on the list of master areas of the game, for absolutely no reason, so the greater area's script didn't reach there.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...