Aller au contenu

Photo

override existing scripts


  • Veuillez vous connecter pour répondre
20 réponses à ce sujet

#1
1Parmenides

1Parmenides
  • Members
  • 188 messages
I see an existing script that I would like to modify.  Am I supposed to "save as" to my module in some way?  (doing so raises complaints about the file being used).  If you grab a script, it's read only.  There is a process where you can "check out" a script and "check in."  Does this edit the core of the game?  I don't think I want to do that.  I just wonder what the best way is to have a nss/ncs to thrown into the module override. 

#2
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
What I did (which didn't work, but it should work this way so it will at least get you started)



- Create a new module (don't edit the single player module ever)

- Use "Check out" on the script you want to change

- Make your changes and save the script

- Recompile the script (if it's a core script, _h scripts can't be recompiled as far as I can see)

- Export the script using "Without any dependencies"





This will give you the nss/ncs files, I placed them in the overwrite folder but my changes aren't taken into effect when creating a new game. I do however know it should work this way with maybe one or two things that I missed. Not that this will help you fix it, let's hope it gets the attention of someone who knows what to do ;)

#3
Talian Kross

Talian Kross
  • Members
  • 239 messages
Pretty much like Joshua stated.

  • Check out script;
  • Edit it as necessary;
  • Save script;
  • Export script (right-click on it in palette and export [without dependencies]); and
  • Check in script.
This will export the script to your Documents/"My Documents" (Vista/XP) directory: ./BioWare/Dragon Age/packages/core/override/toolsetexport.

Unfortunately, as you surmised, this may permanently effect (globally) the campaign files as far as the toolset is concerned, but my above procedure was actually done inside a custom mod, so that may factor in to things.  (Refer to my "Gray Area" section below.)

To remove the override as far as the game is concerned, just delete the .nss/.nsc files from the above override directory.)

So, for instance, say I decide to override the _Ability_Scripts/Skills/skill_stealth script.  I do the above steps and just add a little floaty message ("I'm such a sneak."):

Posted Image


Gray Area:

The problem is I can get rid of this override in-game just by removing the script from the override/toolset directory, but as far as the toolset is concerned, the script has been modified, and all future check outs will contain the change.  The version control scheme used in the toolset is not incredibly robust, so the only way I can currently find to undo the change is to restore the previous, BioWare version.  This is done via right-clicking on the script and selecting "Resource History" and then selecting "Restore Resource" on the version you want to restore.

What i don't like about that is that it doesn't really undo changes; it just checks in a new version which is identical to the old version.  Superficially, it gets the job done, but internally, it's still a little messy. 

This may just be a "current session" caching issue/artifact.  I actually did the above mod inside a new module (Addin).  After closing the module and exiting and then restarting the toolset, the version history restored itself to its original state, and the script was indeed the original. *shrug*

Update: No, I was wrong.  It does definitely permanently change the code database regardless of what module I currently have open.  When I actually double-click on the script to open it, the "clean state" of the version history is updated to reflect the recent changes.

So though I haven't tested this, the better way may be along the lines of never checking in or out the file, just make a copy of it and stick the results in the base override directory.  (Having not tried it that way, I can't be any more specific unfortunately.)

Modifié par Talian Kross, 16 novembre 2009 - 10:38 .


#4
Talian Kross

Talian Kross
  • Members
  • 239 messages
Alright.  Here's how you do it without affecting anything globally.

  • Right-click on script and do a "Open Local Copy.";
  • Edit it as necessary;
  • Save script.
This will place the script (both .nsc and .ncs files) in your Documents/"My Documents" (Vista/XP) directory: ./BioWare/Dragon Age/packages/core/override/toolsetexport.


At this point, it's your responsibility to go manually copy the .nss file (the text file) some place else for safe keeping.  To remove the override, simply delete the files from the above override directory.

Unfortunately, without utilizing the toolset's version control mechanism, I can't readily think of an "easy" way to maintain such a mod.  With the above method, each time you open the toolset and then "Open Local Copy" the script, you'll have to manually copy and paste your changes from your previously copied version.

Maybe someone knows a better way.

Modifié par Talian Kross, 16 novembre 2009 - 11:02 .


#5
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Talian, I don't see you recompiling the script, did you just forget to name it or is it simply not necessary to do so?



I edited core_player and some other files using check out/recompile/export and placing it in the override directory but the changes don't seem to work when starting a new game. The things I changed where current health after resurrect and changed healing potion from instant to over-time effect but both changes didn't kick in? Any idea what might be causing this?


#6
Talian Kross

Talian Kross
  • Members
  • 239 messages

Joshua Raven wrote...

Talian, I don't see you recompiling the script, did you just forget to name it or is it simply not necessary to do so?

You compile the script by saving it.  As far as I know, there is no explicit "Compile" command--I wish there were. :)

As far as your specific problem, based on your post on the old forum, aren't you trying to override an include file?  You can't really do that, not easily anyway.

#7
AND04

AND04
  • Members
  • 154 messages
hmm, well it would be better to override the events with a custom event-handler (just define your event-script in the events.xls 2DA File and create a M2DA File - don't forget to send a HandleEvent to the original Handler if your aren't handling all aspects of it - aka only the Looting part of the USE Event in my case: http://social.bioware.com/project/690/ )

#8
Talian Kross

Talian Kross
  • Members
  • 239 messages

AND04 wrote...
http://social.bioware.com/project/690/

But as you state in your description, you refuse to release the source code, so how exactly is this helpful to us (to learn from)?

I mean, looking at the Wiki Entry, events.xls is virtually undocumented, so coming in here and just telling us to use it with no other explanation is somewhat--oh, I don't know--mean?  Unhelpful?  :P

Modifié par Talian Kross, 17 novembre 2009 - 02:15 .


#9
AND04

AND04
  • Members
  • 154 messages
tztz - what do you think i was doing the last couple minutes:

social.bioware.com/wiki/datoolset/index.php/Event_override

:innocent:

Modifié par AND04, 17 novembre 2009 - 02:25 .


#10
Talian Kross

Talian Kross
  • Members
  • 239 messages
Ah, good.  I figured it was probably that simple, but without the inclination to do trial-and-error testing (I'm busy with other pressing mod priorities at the moment), you can never be sure.

And good job updating the Wiki.  I have the highest respect for guys like you.  I never like updating wiki's (any wiki) myself as I just don't like the responsibility that comes with doing that. :)

#11
DangerousFat

DangerousFat
  • Members
  • 18 messages
So, if for instance I wanted to edit the item_constants_h.nss to increase the amount of stamina that deep mushrooms restore, I would open a local copy, change that number and then save it and I'm done? The game will simply look in "/BioWare/Dragon Age/packages/core/override/toolsetexport" for that file and override the original game one?

#12
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
 I have a related question about this which I've been unable to solve for the past two days;

What if I wanted to change the amount of health after a resurrection?

- I opened up effect_resurrection_h
- I edited line 52 to read

float fHealth = MaxF(1.0f,GetMaxHealth(oCreature) * 0.05);

instead of

float fHealth = MaxF(1.0f,GetMaxHealth(oCreature) * 0.25);

- I opened up player_core, as this script loads effect_h, which in return loads effect_resurrection_h.
- I saved/recompiled and exported player_core and saved it to the overwrite folder.

However, in both an existing game as in a new game, the health after a resurrection is still 25% instead of the new 5%.

What am I doing wrong here? :crying:

#13
Talian Kross

Talian Kross
  • Members
  • 239 messages
To you both, no header file (for sure any script ending with a "_h" suffix and also several others) can be overridden explicitly.  You need to track down the actual script that is referencing the include file of interest and make the change there instead.  It's that script that is actually being compiled and used, and it's that script that you need to override.

Think of it this way.  The #include statement you see at the top of scripts is synonymous with, in plain English, "copy and paste."  It tells the compiler to go fetch that include file and literally paste its contents into this file.  So, you see, it's not the header file that is really being compiled; it's the invoking script that had the #include statement that is being compiled, and that is the script you will need to edit and override.

If you really just want to only make the change in the header file, then only option is to include each and every script that references that header file, whether directly or indirectly.  See, you have to also keep in mind that include files themselves also reference other include files.  So just because your specific include file isn't in a script's #include list doesn't necessary mean it's not being not being referenced indirectly.

This is why, again, it is never a good idea, especially in this environment where there are no dependency checks, to modify an include file directly.

#14
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Okay, that's perfectly clear. I was under the impression that you could edit header files, because the core file in which the header file was included actually parses all the code in the header file before it is compiled. I come from a webdevelopment world and I figured it was the same as php include() which just takes everything from a different file and literally parses it in the main file before executing the code.



Now that that's out of the way. Could you pretty please help me out with this one example so I can get a feeling about how to tackle these things?



As said, I did find the code I want to edit in the effect_resurrection_h header file. If I can't edit that file (or I can but shouldn't) how would I go about and reach the same result without touching that header file?



Hope you can help me out here. I have a ton of knowledge on webprogramming, just not on C++

#15
Talian Kross

Talian Kross
  • Members
  • 239 messages
Reading your original post in its entirety, I see now that you stated you were already
(and correctly) trying to override the script (player_core) and not the
header file, so my guess would be that the change you made in that header file is actually being used in other script.

Doing a quick trace:

player_core.nss (897): bEventHandled = HandleEvent_Resurrection(OBJECT_SELF, ev);
player_core.nss (37):  int HandleEvent_Resurrection(object oCreature, event ev)
player_core.nss (43):  Injury_DetermineInjury(oCreature);
sys_injury.nss (147): void Injury_RemoveInjury (object oCharacter, int nInjury)
sys_injury.nss (149): effect[] eEffects = GetEffects(oCharacter, EFFECT_TYPE_INVALID, INJURY_ABILITY_EFFECT_ID + nInjury);

That's probably the magic line.  So a quickie "let's just see if this works" test, stop overriding player_core and instead override sys_injury.nss.  You'll probably need to check out that effects header as well so the toolset will know to use your local version instead of the one stored in the database.  (Warning: All of this, even your first implementation, modifies the core game files permanently.  Refer to all my "blah blah blah" text above in my original two replies in this thread.)

At any rate,if that doesn't work as expected, then it's still probably on the right track.  The proper way to do it, though, is NOT to modify the header file directly.  Instead, in sys_injury.nss, in Injury_RemoveInjury() function, you would add code to check is the injury is death and apply your changes accordingly.  If you can't do it there, then backtrack to the original call on line 43 of player_core.nss.

Caveat:  This is just a first glance, so for all I know, the health restoration is actually taking place someplace entirely different.  I don't know, but you (hopefully) get the idea.

#16
DangerousFat

DangerousFat
  • Members
  • 18 messages
My apologies, I am a programmer by study and profession, but I'm used to my own code. This is the first time I've ever modded a game before. I'm confused as to why I cannot override a constant in the header file when that seems like exactly what I want to do. lol That information isn't being DECLARED anywhere else, so I don't understand why I'm looking for something somewhere else.

Thanks!

Modifié par DangerousFat, 19 novembre 2009 - 12:22 .


#17
orpheus333

orpheus333
  • Members
  • 695 messages
From my experiance the items_constants_h script can be edited, saved and exported to the core/override folder. With no issues or bugs in game.

social.bioware.com/project/698/

It all works perfectly well. The only issue is future mods that may try and override the item_constants_h script as well. THis could be fixed by adding my own #include in the items_singletarget script. But im no programmer and that seems like it might be difficult to get working. Evens till the items_singletarget.ncs maybe overrided as well.


Anyhow it all seems to be working fine for me. but in thsi case i am just adding new pointers and constants for new items. There shouldn't be any conflicts directly right?

Modifié par andyr1986, 19 novembre 2009 - 01:01 .


#18
jacobmsn

jacobmsn
  • Members
  • 16 messages

andyr1986 wrote...
Anyhow it all seems to be working fine for me. but in thsi case i am just adding new pointers and constants for new items. There shouldn't be any conflicts directly right?


I have been playing around with this and I believe it is correct that you cannot export header files directly since they are not compiled to ncs files. It is the actual nss scripts (not header files) that needs to be exported.

I think that the reason why it works for you probably is that only your new item is using the new constant in the contants header. All other scripts using this header will not know anything about it - in effect the other scripts see the original version of it. 

In fact, although I have not tried I think that the .ncs file is the only important one in your distribution of your add-in. The .nss files are just source for people so they can see what you did.

Modifié par jacobmsn, 19 novembre 2009 - 09:44 .


#19
Talian Kross

Talian Kross
  • Members
  • 239 messages

DangerousFat wrote...

My apologies, I am a programmer by study and profession, ...!


Okay, you should understand the following then.

I have two files: foo.h and foo.cpp.

/*--------------------------------------------
foo.h
--------------------------------------------*/
#ifndef _FOO_H_
#define _FOO_H_
#define SOME_CONSTANT 10
#endif _FOO_H_


/*--------------------------------------------
foo.cpp
--------------------------------------------*/
#include "stdio.h" // NOTE: the forum s/w parses angled brackets as HTML, hence the quotes
#include "foo.h"

int main()
{
int nNum;

    nNum = SOME_CONSTANT;
    printf( "Constant = %d.", nNum );
    return 0;
}


Now, it's foo.cpp that is compiled into an object file (foo.obj), and then the linker turns that foo.obj into foo.exe for you to excute.  Translating this to DA:O...

foo.cpp --> foo.nss  (script - source code)
foo.obj --> foo.ncs (compiled script -- what the engine reads in and uses)

So you can change the constant in foo.h all day long, but unless you recompile foo.cpp to produce a new foo.obj, the engine will still be using the original version, obviously, since no new one has been created.

Modifié par Talian Kross, 19 novembre 2009 - 11:36 .


#20
Nodrak

Nodrak
  • Members
  • 144 messages

DangerousFat wrote...

My apologies, I am a programmer by study and profession, but I'm used to my own code. This is the first time I've ever modded a game before. I'm confused as to why I cannot override a constant in the header file when that seems like exactly what I want to do. lol That information isn't being DECLARED anywhere else, so I don't understand why I'm looking for something somewhere else.

Thanks!


This should be something that will guide you to the result you are looking for:

http://social.biowar...57400/blog/932/

#21
DangerousFat

DangerousFat
  • Members
  • 18 messages
Bless you both, that's exactly what "I" needed... people tell me what files I need without ever giving me the understanding of what those files actually are. Understanding now what the ncs and nss files actually ARE is most definitely what will help me.



Much appreciated guys.