Skip to content

Trigger for visited area?

lansounetlansounet Member Posts: 1,182
edited August 2012 in General Modding
Say I have a creature that can teleport me to various area through dialogue actions, but I only want the response for each travel option to be available only if the area has been visited before.

Is there a trigger - like VisitedArea("AreaRes") - to allow this? Or do I have to EXTEND_TOP every one of those areas with some
IF
OnCreation()
Global("VisitedThisArea","GLOBAL",0)
THEN
RESPONSE #100
SetGlobal("Visited[Area]","GLOBAL"1)
and check for Global("Visited[Area]","GLOBAL",1) in each response?

Comments

  • ArdanisArdanis Member Posts: 1,736
    More or less yes, check for "Visited[Area]".
  • lansounetlansounet Member Posts: 1,182
    Alright :/ Thanks for the quick answer.
  • CamDawgCamDawg Member, Developer Posts: 3,438
    I strongly discourage the use of OnCreation for, well, anything. There's also no reason these need to sit at the top of an area script.
  • lansounetlansounet Member Posts: 1,182
    edited August 2012
    I was thinking top of the scripts just in case some other mod does an extend_top on it with bugged looping script. Like the current case of DSotSC-BGT (v2.16) Lion's Way extend_top that prevents some BG1NPC content :)

    What's the deal with OnCreation() ?
  • DavidWDavidW Member Posts: 823
    I'd probably do something like

    <<<<<<<< .../mymod-inline/area_add.baf
    IF
    Global("Visited%area%","GLOBAL",0)
    THEN
    RESPONSE #100
    SetGlobal("Visited%area%","GLOBAL"1)
    Continue()
    END
    >>>>>>>>


    ACTION_FOR_EACH area IN ar1234 ar5678 ar9101 BEGIN
    COPY_EXISTING ~%area%.are~ ~override~
    READ_ASCII 0x94 script
    BUT_ONLY
    EXTEND_TOP ~%script%.bcs~ ~.../mymod-inline/area_add.baf~ EVALUATE_BUFFER
    END
  • lansounetlansounet Member Posts: 1,182
    That's pretty much what I did with 1 .baf for each area script, without all the evoluted code and variable replacements :p
  • CuvCuv Member, Developer Posts: 2,535
    edited August 2012
    CamDawg said:

    I strongly discourage the use of OnCreation for, well, anything. There's also no reason these need to sit at the top of an area script.

    I can think of one reason I would use it: Custom Text Screens. Other than that... agree.

  • CamDawgCamDawg Member, Developer Posts: 3,438
    lansounet said:

    I was thinking top of the scripts just in case some other mod does an extend_top on it with bugged looping script. Like the current case of DSotSC-BGT (v2.16) Lion's Way extend_top that prevents some BG1NPC content :)

    What's the deal with OnCreation() ?

    In this particular case, it's entirely superfluous so all it's doing is introducing a point of failure.

    My beef with OnCreation and EXTEND_TOP is mainly my conservative coding nature--I'd rather my own mod fail than break someone else's (i.e. reveal city areas and ar0300 in Tweaks). For whatever reason, I feel like I see OnCreation()/Continue() in particular abused in area scripts when the scripting would be perfectly fine waiting for the next script cycle.
  • lansounetlansounet Member Posts: 1,182
    Points taken!
  • DavidWDavidW Member Posts: 823
    Cam, I agree with the conservatism in principle, But if I put a block at the top of an area script and include a Continue(), I can guarantee that the rest of the script executes correctly. If I put it at the bottom, I can't guarantee that my script will execute correctly, because I don't control the content of the rest of the script and there's no automated way to check if the existing script allows things at the bottom to execute.
  • DavidWDavidW Member Posts: 823
    lansounet said:

    That's pretty much what I did with 1 .baf for each area script, without all the evoluted code and variable replacements :p

    It's a matter of taste whether it's worth doing it my way. The main advantage is that it's easier to debug and much easier to tweak the details later.
Sign In or Register to comment.