override existing scripts
#1
Posté 16 novembre 2009 - 03:33
#2
Posté 16 novembre 2009 - 08:38
- 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
Posté 16 novembre 2009 - 10:23
- 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.
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."):

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.
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
Posté 16 novembre 2009 - 10:56
- Right-click on script and do a "Open Local Copy.";
- Edit it as necessary;
- Save script.
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
Posté 16 novembre 2009 - 11:03
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
Posté 16 novembre 2009 - 11:37
You compile the script by saving it. As far as I know, there is no explicit "Compile" command--I wish there were.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?
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
Posté 17 novembre 2009 - 01:51
#8
Posté 17 novembre 2009 - 02:12
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)?AND04 wrote...
http://social.bioware.com/project/690/
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?
Modifié par Talian Kross, 17 novembre 2009 - 02:15 .
#9
Posté 17 novembre 2009 - 02:24
social.bioware.com/wiki/datoolset/index.php/Event_override
:innocent:
Modifié par AND04, 17 novembre 2009 - 02:25 .
#10
Posté 17 novembre 2009 - 03:57
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
Posté 17 novembre 2009 - 10:47
#12
Posté 17 novembre 2009 - 10:04
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?
#13
Posté 17 novembre 2009 - 10:33
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
Posté 17 novembre 2009 - 10:48
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
Posté 17 novembre 2009 - 11:46
(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
Posté 19 novembre 2009 - 12:20
Thanks!
Modifié par DangerousFat, 19 novembre 2009 - 12:22 .
#17
Posté 19 novembre 2009 - 12:54
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
Posté 19 novembre 2009 - 09:42
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
Posté 19 novembre 2009 - 11:11
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
Posté 20 novembre 2009 - 12:38
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
Posté 20 novembre 2009 - 05:29
Much appreciated guys.





Retour en haut






