HouseOfAmon Posted May 20, 2006 Share Posted May 20, 2006 I dont know if this is where I am supposed to post this but the other forums were locked, so... and about that, why is that happening, are the other forums closed down, or is just my browser, I am rather curious to why this is going on, eveytime I try to post in the appropriate areas, I get "this forum is no longer accepting post" error... Have the labs been shutdown, or did they just die, or restricted hours maybe... just curious, and trying to avoid an angry mod telling me to post in the right place.. Anyways, I need to make a script im working on, be constantly on, or as close to constant as possible, the only thing I can think of is integrating it into every area of the games heartbeat, but i havent really done that before, or at all Or know what that means.. To be honest.. I have mainly been doing script updates, and such to get the language down, for instance, I took d3's force choke anyone mod, and added a horrified effect to it, so after they choke they become scared, if you hurt them, they get really scared, I like it, it adds to the fun of doing it, to see them respond... So anyways, I have never had to start my own script as that part has been done for me by the mod authors, and just dropping it in the override didnt work.. I looked into this injecting thing, but I dont get it.. So if that is how I have to do this, how would I go about it, or is there a better way,... Can I attach it to the exile maybe.. Then it would be in affect as long as he is present??? This would be the way to go, if thats possible, then it would run constantly rather than every six seconds, then there would be no inconsistencies, I need this to run a once per frame or else it will still be flawed.. You guys are gonna love this if it works, Im pretty sure it hasnt been done,.. its a bug fix.. To what is in my opinion the most annoying bug in the game.. Also if anyone has detailed info on how the influence system works, I need this bad, ie,.. how do certain characters respond to the PC's alignment, also how that changes as he becomes a jedi mast/sith lord, I need to know how each individual pc responds, to male female, or else this fix wont work exactly right, I got the code already in place, and it compiles, so I just need the details, and a way to run the script in every area of the game, and this will work... BTW, to be clear about this, I mean there light/dark influence, not the influence you gain through talking to them, but that info is probably needed as well, but I just want to make them stop jumping from light master to dark masters, thats so annoying, especially when you have restricted items on them, the next thing you know they are fighting without a sabar because they no longer have the light/dark prerequisites... or have stripped naked.. thats always fun, to turn around and see your companions, disarmed and disrobed... Its like, did I miss something, yall have a party without me?? you should ease up on the juma juice.. As a last resort, I could always make them mirror the player, and have very similar rating, thats how its setup right now, they just match him, thats why I need the info to make the special cases, like gender, master/lord, so I can expand the code a little, but if I cant get that info, just getting this script to run as it is now will make them follow the exiles path, if he is dark so too will they, etc,. etc... Thats why it has to be every frame, so if you do something good or bad they can match it immediately... Rather than six seconds later, or on a area transition, or any other way it might be done.. Link to comment Share on other sites More sharing options...
RedHawke Posted May 20, 2006 Share Posted May 20, 2006 Please post in the right place... you said it first! Strange though Holowan Labs is open for me... I'll move it there for you. Are you sure you were not trying to post in one of locked tutorial forums? Edit: If you can't respond to this post then PM me if you can and I'll ask about this issue with the higher-ups. Link to comment Share on other sites More sharing options...
HouseOfAmon Posted May 20, 2006 Author Share Posted May 20, 2006 Please post in the right place... you said it first! Strange though Holowan Labs is open for me... I'll move it there for you. Are you sure you were not trying to post in one of locked tutorial forums? Edit: If you can't respond to this post then PM me if you can and I'll ask about this issue with the higher-ups. oddly enough its letting me post here, but when I went to holowan labs, scripting, it was locked, so I will have to figure out exacty where this is exactly so I can post there in the future... srry. edit... Okay I see now, you post in the "general area" rather than clicking into the scripting area.. so those are just tutorial sections,... I was wondering what was going on.. I just saw scripting in big bold print, and was like yep, thats what I want.. lol.. I didnt read the fine print..hehe.. So I got it figured now.. Link to comment Share on other sites More sharing options...
stoffe Posted May 20, 2006 Share Posted May 20, 2006 Can I attach it to the exile maybe.. Then it would be in affect as long as he is present??? This would be the way to go, if thats possible, then it would run constantly rather than every six seconds, then there would be no inconsistencies, I need this to run a once per frame or else it will still be flawed.. This is a script that is meant to always run throughout the game, and not just trigger once, when a specific event takes place (such as a dialog line is spoken or the player crosses a trigger), correct? Keep in mind that the NWScript script engine is rather slow compared to that used in many other games. You'll want to avoid having complex scripts running too often or it may result in noticable slowdowns in-game. A standard heartbeat script runs roughly every 3 seconds for party members, depending on how busy the game engine is. It is possible to make a script run more often repeatedly by using DelayCommand() with a recursive function. (A loop won't work for this, since the game engine will assume that a script that runs for longer than 2-3 seconds has crashed, and will automatically terminate it.) Do note however that delays shorter than 0.1 seconds tend to be unreliable since the game engine won't always be able to keep up with running them that quickly for whatever reason there is. Also note that if your script is complex enough to take long to execute the delay might be longer since it'd include the time it takes to reach your recursive call. Also note that you should keep recursive scripts as simple as possible if they are meant to run over long periods of time, since it may slow things down otherwise. As for triggering the script, there are no global, game-wide normal scripts or event hooks that always run. The "highest" up you can come with event hooks is on a module level. This means that if you need to make something run OnHeartbeat throughout the game for all modules you'd need to modify all the module.ifo files (and either modify the module RIMs or repackage them to MOD files, since you can't put that file in override). Or do the same with the ARE file for the area, since there is just one area per module in the KotOR games. This is a lot of work, and not really feasible for a mod you intend to share with others. A simpler solution could be to run the custom function off the AI scripts of one of your party members. This could be done in two ways: Modify the generic AI script, k_ai_master. This would make it possible to run your script whenever a creature AI script is run. Obviously you'll need to limit it down so your function only runs under certain conditions, and only runs if it isn't already running. This is probably, from the modder's perspective, the simplest solution, but it makes your mod incompatible "out of the box" with other Mods that modify the core AI scripts, such as beancounters Hardcore mod or my Modified AI. Modify the UTC of one of your party members to substitute one of the generic AI event scripts assigned in their template to a custom one you make yourself, and then make that script. The script would essentially be a clone of their normal one, with your additional function call inserted. The advantage of this is that you don't need to mess with the core AI scripts, any changes you do will only affect this particular party member. The disadvantages are that the mod will only work if that character hasn't joined the party yet in the game, since UTC templates are only used when a character is first spawned into the game. It will also be incompatible with any mods that modify the same UTC template, unless some form of installer utility (like for example KISS or TSLPatcher) is used to modify the template in-place if present. Link to comment Share on other sites More sharing options...
HouseOfAmon Posted May 20, 2006 Author Share Posted May 20, 2006 Not exactly what I hoping to hear, but I figured as much, what of this .utc method, will it work if say for instance I leave that character on teh Ebon Hawk, or do they have to be an active party member? To your question of complexity, not really, its a series of if statements, so only one would run, the one that is currently true, inside the statement are just 11 variable setting commands it just changes each of the npc's light/dark to mirror the PC, the whole thing probably takes no more than one second to execute, I knew writing it that it had to be simple especially to run globally, so I think I got that covered, but once activate it in game, I will know.. till then its just speculaion.. What I have found to cause this bug, is that the npc's light/dark levels arent stored in globals, so just adding globals for these to be stored in would fix the problem as well, thats why the exile never experiences this, his is alignment is stored in g_pc_align_val so its always there to be referenced, but the npc's on the other hand are stored dynamincally by the scripts, so if one of these scripts fails you see the bug... I could be wrong... But this seems to be the cause.. ( which is why saving causes the bug ) it seems to kill the script, and lose the values, and you have to wait till the script is triggered again before there light/dark rating returns to normal) Also I had a thought, you mentioned it terminating scripts, so could I possible add ti to an item, similar to the whereami armband, activate the script in that manner, and then make a script loop, where the original script runs, and right before ceasing, it would call a clone script, which performs the same function, then that script after executing calls the original script creating a "script loop".. is that feasible, I would still have to activate it once per session though, but it would cut down on editing.. Thoughts? This would create an infinite loop or a hacked global if you will, and allow for me to delay with the DelayCommand function... I think it is an excellent idea... Would area transitions interfere with this? Or are scripts constant enough to not be terminated by those? Link to comment Share on other sites More sharing options...
stoffe Posted May 20, 2006 Share Posted May 20, 2006 Also I had a thought, you mentioned it terminating scripts, so could I possible add ti to an item, similar to the whereami armband, activate the script in that manner, and then make a script loop, where the original script runs, and right before ceasing, it would call a clone script, which performs the same function, then that script after executing calls the original script creating a "script loop".. is that feasible, I would still have to activate it once per session though, but it would cut down on editing.. Thoughts? This would create an infinite loop or a hacked global if you will, and allow for me to delay with the DelayCommand function... I think it is an excellent idea... Would area transitions interfere with this? Or are scripts constant enough to not be terminated by those? I suppose you could do it like that, though as I said I would use a recursive function call put in DelayCommand(), since I think that's a bit easier... like: void ST_DoMyStuff() { if (SomeCondition()) { blablablah(); } DelayCommand(1.0, ST_DoMyStuff()); } void main() { ST_DoMyStuff(); } This would run the code in the ST_DoMyStuff() function once per second as long as the object running the script is valid. Remember that objects only are valid as long as the module they are within is loaded, i.e. the script will stop whenever your party transitions to a new area. Thus you'll have to keep track of if the script is already running, and if not, restart it, to make sure it's only run once. (If such a script was started several times it'd slow down the game conciderably.) You can do this with local variables, but it's probably a lot easier not to bother with that and just rely on the heartbeat script of the object running the script keeping it running, and not make the script run an infinite recursion, but just a number of times per heartbeat. Like: // Custom heartbeat script for NPC. void ST_OncePerSecond(int i) { // This is what should happen.... SendMessageToPC(GetPartyLeader(), "Running once per second script!"); // This makes the function run more times before the next HB occurs. if (i < 3) { DelayCommand(1.0, ST_OncePerSecond(++i)); } } void main() { // Run the default party member heartbeat script. ExecuteScript("k_hen_heartbt01", OBJECT_SELF); // Run the function containing the stuff that should be checked // more frequently than once per HB. ST_OncePerSecond(1); } This would make the code in ST_OncePerSecond() (just printing out a message to the feedback log in the example above) run roughly once per second. Link to comment Share on other sites More sharing options...
HouseOfAmon Posted May 20, 2006 Author Share Posted May 20, 2006 hmm.. I will see what I can do, all I can say is dont hold your breath waiting for this to be released, because Im a perfectionist when it comes to my coding, I mean, its not always pretty to look at, sometimes it a down right hack job, but if I release it, it works just like its supposed to. And this project, its gonna be huge, I mean every npc responds different to your alignment, not to mention your gender, and the amount of influence you have over them... Alright, well I appreciate your help stoffe, I will try to get this done, but for my first actual mod, I sure picked a dandy of a project.. So thanks again, I will try out your idea and see how it goes.. later.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.