Skip to content

Overwriting default scripts

I'm sure it has happened to others, but I think that in the process of importing erf. I might have accidently overwritten some key piece of coding that deals with the behavior of the PC and NPC's

Is there a way to reimport the default NWN scripts to overwrite any that were changed?

For a risky procedure such as this, I would be sure to make a back up first before trying!

Comments

  • TarotRedhandTarotRedhand Member Posts: 1,481
    Before you do anything else just check that what you think happened, actually did. You need to check the names of the imported scripts to see if any of them actually have the same name as a default script, otherwise it should be impossible for any default built-in scripts to have been overwritten. Not only that, if your problems are actually appearing in modules other than the one you imported the erf into, it will also strongly imply that the erf in question is not the problem because the erf only affects the module it is imported into. Not the whole game. This is just a matter of following Sherlock Holmes dictum -
    "Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth."

    TR
  • nwfan87nwfan87 Member Posts: 99
    @TarotRedhand That sounds like a campaign in it's own making! Specifcally my problem is the ActionJumpToObject and JumpToObject fuction. It seems to have broken somehow. Perhaps this might have to do with an OnHeartbeat Event?

    With the ERF. I know that at some stage I might have chosen to override some of the scripts when importing the files, so that might have been the problem? I'm quite sure that also included default scripts.

    My idea was to find someway of getting all of NWN EE's default script and putting them in some sort of ERF and importing that into the module and overriding all the default scripts. There has to be a default script that deals with the JumpToObject Function.
  • ProlericProleric Member Posts: 1,310
    Those function headers are in nwscript.nss (i.e. built into the engine) so it shouldn't be possible to override them.

    Most likely something else is wrong with the script that isn't working.
  • nwfan87nwfan87 Member Posts: 99
    edited November 2023
    @Proleric mmm... Its very strange every time I seem to work on something, the mod becomes more and more broken. Can't even use the JumpToObject function anymore and even old stuff that worked before, is breaking. Likely will resort in finding workarounds :(

    No chance that when the toolset crashes it causes damage to the mod file?
  • NeverwinterWightsNeverwinterWights Member Posts: 339
    edited November 2023
    @nwfan87 By any chance could you post the exact script you are using and explain the exact scenario that you are trying to use the script in? I know we discussed this in a previous post and tried to get it figured out. Did you try the debugging script? Any results? Different problem?
  • MelkiorMelkior Member Posts: 191
    edited November 2023
    The most likely reason for a JumpToObject failing is because the target doesn't exist. If you're finding the object by tag, then it's possible that the object has been mistagged, most likely due to the ERF importing something over the top and wiping out the original object.
    While The Sherlock Maxim is very useful, you should never discount Occam's Razor:
    "When presented with a choice of explanations for a phenomenon, the simplest explanation is the one most likely to be correct"
    (Edited to add): If you ever accidentally overwrite a default script, my understanding is that the script still exists but is overridden by your same-named script. If you delete your same-named script, then it should be possible to once again select the default script and attach it to an event.
  • nwfan87nwfan87 Member Posts: 99
    @Melkior @NeverwinterWights @Proleric @TarotRedhand

    A moment of victory this morning when I finally got the thing to work! Turns out it was a combination of factors.

    Though I don't like posting exact script online, these were the problems I was having:

    1) order of functions

    My particular script is quite complicated with many things happening in one script + the JumpToObject. I found that by moving the definitions and jump action to the top of the sequence, even putting stuff that happen before the function after the function is executed, seemed to help

    2) This line here: if (GetAreaFromLocation(lLocation2)==OBJECT_INVALID) return;

    Turned out to stop the rest of the script from firing, which lead to

    3) Invalid Area

    I duplicated the area which may or may not have had a fundamental issue. After this I:

    4) Deleted added a new waypoint with a new tag

    I know that sometimes, for some reason, the engine can get confused over long tags or sometimes they just break.

    5) double checked my code with another similar code that works

    Turned out I had made some errors such as using JumpToLocation, and using an incorrect tag.

    6) It was my fault

    Not much else to say, all the time I blamed the system and it was my own oversights. Just the one line or tiniest typo. But the important thing that makes me happy, is that the script now works and I can move on, without thinking something is catastrophically wrong with the mod file.

    Thank you all for your help again! :smiley:



  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited November 2023
    @nwfan87 - I know that sometimes, for some reason, the engine can get confused over long tags or sometimes they just break.
    From the Lexicon -
    Tags are up to 63 characters after some testing, however smaller is usually more manageable. Also note CopyObject caps the length of a tag to 32 characters, which is what the toolset usually defines it as, so 32 might be a better "maximum".
    Note. EE may or may not have altered that size. Without a lot more searching, I don't know if it has or not.

    TR
  • nwfan87nwfan87 Member Posts: 99
    @TarotRedhand Thats very interesting thankyou. I found that tags with more than one underscore e.g THIS_IS_A_WAYPOINT, seems to create a lot of problems with the JumpToObject function. It's fine for int names, but risky for tags.

    I just tags short and simple
Sign In or Register to comment.