Fiestainabox Posted May 18, 2008 Share Posted May 18, 2008 After ages of dinking around in the Morrowind CS, I've decided to come back to Kotor. The downside is, Kotor's scripting style is a lot different from the morrowind one I'm used to, I got a few quick questions, If you wouldn't mind answering some of them, that would be great #1, in morrowind, theres a command called "Disable" which makes the refrence its attached to dissapear, and stop all scripts on that refrence from running, I'm wondering if theres a similar style thing in kotor. #2 How do I force a NPC to perform an animation? Like forcing someone to dance? and lastly: #3 This one may be blatently simple : / but, in morrowind, you started the script with: "begin <Scriptname>" ....and ended it with: "end <scriptname> Am I right at assuming you gotta start scripts in kotor with: "void main() {" ...and ending them with: "}" I know, it must seem real simple for you guys, for me its like learning to ride a bike all over again : ( Other than that, Morrowind and Kotor are very similar. I love how the scripts are set up in each UTC file in Kotor, but HATE how you have to rely on appearence.2da to set up your appearences, and not to mention how Kotor's Dialog system destroys morrowinds dialog system. Heh, and I'm gonna have to get used to compiling my scripts, Morrowind does it by itself : / Thanks Yall Link to comment Share on other sites More sharing options...
Ferc Kast Posted May 18, 2008 Share Posted May 18, 2008 1)Yes; Here's all you'd need to do that in KotOR. // This will clear all actions void main() { ClearAllActions(); } 2)Here's a sample script of making an npc perform an animation. // This will make "npc_tag" dance void main() { object oNPC = GetObjectByTag("npc_tag"); AssignCommand(oNPC, PlayAnimation(ANIMATION_LOOPING_DANCE, 1.0, 0.5)); } Replace 0.5 for the length in seconds (replace it with -1.0f for a looping animation). Replace ANIMATION_LOOPING_DANCE with the animation you want "npc_tag" to perform. 3) Yes, except for some conditional scripts. (Which I can't remember at the top of my head.) Hope this helps. Link to comment Share on other sites More sharing options...
Fiestainabox Posted May 18, 2008 Author Share Posted May 18, 2008 Awsome, thanks, so "ClearAllActions" will make the a character disappear too? Link to comment Share on other sites More sharing options...
Ferc Kast Posted May 18, 2008 Share Posted May 18, 2008 Awsome, thanks, so "ClearAllActions" will make the a character disappear too? It only stops all scripts running, afaik. It doesn't make a character disappear. Though, I'm unsure how to make a character disappear. Link to comment Share on other sites More sharing options...
Exile007 Posted May 18, 2008 Share Posted May 18, 2008 Awsome, thanks, so "ClearAllActions" will make the a character disappear too? Nope, it will just make the npc "clearallactions." In order to destroy an npc you would use something like this. void main() { DestroyObject(GetObjectByTag("npc_tag")); } Link to comment Share on other sites More sharing options...
Fiestainabox Posted May 18, 2008 Author Share Posted May 18, 2008 Nope, it will just make the npc "clearallactions." In order to destroy an npc you would use something like this. void main() { DestroyObject(GetObjectByTag("npc_tag")); } Great, just what I was looking for, thanks yall! Link to comment Share on other sites More sharing options...
stoffe Posted May 18, 2008 Share Posted May 18, 2008 #1, in morrowind, theres a command called "Disable" which makes the refrence its attached to dissapear, and stop all scripts on that refrence from running, I'm wondering if theres a similar style thing in kotor. KOTOR and Morrowind handles game objects a bit differently if I remember correctly. You can't actually delete anything from the game world in Morrowind, and all objects are pretty much pre-placed, while in Kotor you can create and delete many objects when necessary. You should be able to somewhat simulate the behavior of the enable/disable functions in TESScript (i.e. hide an object present in the game world and later be able to reveal it) in K2:TSL by doing something like: [color=PaleGreen]// ST: Support function, enable creature[/color] void Enable(object oActor) { AssignCommand(oActor, ClearAllActions()); SetLocalBoolean(oActor, 87, FALSE); [color=PaleGreen]// Enable combat AI scripts[/color] EnableRendering(oActor, TRUE); ResetCreatureAILevel(oActor); } [color=PaleGreen]// ST: Support function, disable creature[/color] void Disable(object oActor) { CancelCombat(oActor); AssignCommand(oActor, ClearAllActions()); SetLocalBoolean(oActor, 87, TRUE); [color=PaleGreen]// Disable combat AI scripts[/color] EnableRendering(oActor, FALSE); SetCreatureAILevel(oActor, AI_LEVEL_VERY_LOW); } [color=PaleGreen]// ST: Main function, do things.[/color] void main() { object oNPC = GetObjectByTag("TagOfNPC"); [color=PaleGreen]// ST: Disable the creature with tag TagOfNPC[/color] Disable(oNPC); [color=PaleGreen]// ST: Enable the creature with tag TagOfNPC[/color] Enable(oNPC); } Though in most cases you wouldn't pre-place characters who should appear/disappear dynamically, you just place a waypoint instead and create the creature at it, and destroy them, as needed. Like: void main() { [color=PaleGreen]// ST: Create a creature in UTCfilename.utc at waypoint with tag WP_TagOfNPC[/color] location lLoc = GetLocation(GetWaypointByTag("WP_TagOfNPC")); object oNPC = CreateObject(OBJECT_TYPE_CREATURE, "UTCfilename", lLoc); [color=PaleGreen]// ST: Destroy the creature again[/color] DestroyObject(oNPC); } This one may be blatently simple : / but, in morrowind, you started the script with: Am I right at assuming you gotta start scripts in kotor with: "void main() {" ...and ending them with: "}" NWScript uses a syntax that reminds a bit of C. Scripts will need a starting function where the game begins execution of it. For most scripts this function is called main() and has no return value (void), though in dialog conditional scripts the function is called StartingConditional() and returns an integer value (int). The function name and parameter list is then followed by the { } block delimiters. Everything between those belongs to the function. Like: normal script: void main() { SendMessageToPC(GetFirstPC(), "Hello World!"); } conditional script: int StartingConditional() { return GetGender(GetFirstPC()) == GENDER_MALE; } Overall TESScript is a lot more primitive than NWScript, though there are some things you can do with one that is impossible with the other, and vice versa. not to mention how Kotor's Dialog system destroys morrowinds dialog system. Morrowind barely has a dialog system, it felt more like browsing a bulletin board than talking to someone. Heh, and I'm gonna have to get used to compiling my scripts Kotor may not have a fancy toolset integrating things for you, but if you have a good text editor (like UltraEdit) you can set it up to do it for you with nwnnsscomp. Makes it a lot more hassle-free when you can compile with a mouseclick and see the result directly in the window. Like: Show spoiler (hidden content - requires Javascript to show) Link to comment Share on other sites More sharing options...
Fiestainabox Posted May 18, 2008 Author Share Posted May 18, 2008 Thanks for your reply stoffe, glad to have found someone with experience in TES scripts. Just a few questions NWScript uses a syntax that reminds a bit of C. Scripts will need a starting function where the game begins execution of it. For most scripts this function is called main() and has no return value (void), though in dialog conditional scripts the function is called StartingConditional() and returns an integer value (int). The function name and parameter list is then followed by the { } block delimiters. Everything between those belongs to the function. So the "Startingconditional()" is usually used for dialog? Like the Drop boxes in morrowinds "Text Book" generator? So it would usually be used in somthing like the "Results" box that's in the TESCS? (I haven't looked at the kotor DLG editor in almost a year : /) ...Overall TESScript is a lot more primitive than... Agreed, biggest difference is that TES has a way better 3rd party scripting documentation than Kotors (No offense to you though, your scripts are awesome XD). Plus, you got good old MWSE to help out on the things Bethesda really should have used in the first place. Also, by tossing your two "support function" (of the first script) into a heartbeat script make it so that you could use "Disable" and "Enable" on any script in an area, without having to add your support functions into each little script? Or, does it not work that way? and: void Enable(object oActor) This part is all new to me. So using this style thing allows you to create a Macro like thingy? Lastly, your "oNpc" and "oActor" are those vars default to NWN, or are they yours? If they're yours, switching them to something else wouldn't break anything? Thanks for your awesome scripts Although, ALOT more complex than good old Morrowinds good old "->" XD Thanks EDIT: UltraEdit Link to comment Share on other sites More sharing options...
Darth InSidious Posted May 18, 2008 Share Posted May 18, 2008 Lastly, your "oNpc" and "oActor" are those vars default to NWN, or are they yours? If they're yours, switching them to something else wouldn't break anything? They're placeholder object names. Basically, when you start a script, you need to define all objects in it... void main() { object oNPC = GetObjectByTag("insert_tag_here"); ...before you can tell it to do an action... DelayCommand(0.5, DestroyObject(oNPC)); } You can use other commands apart from "GetObjectByTag" - There's more than a few in NWScript, and if you open any script in the KotOR Tool Text Editor, and select form the drop down box "Script" which game it's for, a list of all available functions for the game appears in the bottom right corner, with a search box above so you can easily find them (so if you typed "Get" [without the quotes], you would get all commands involving the letters in "Get"...). The tag in GetObjectByTag is what's in the tag field of the .ut* file in question. I hope that's comprehensible, and welcome back. Link to comment Share on other sites More sharing options...
Fiestainabox Posted May 18, 2008 Author Share Posted May 18, 2008 Thanks Darth InSidious, totally awesome, and perfectly clear. Heh, now it makes sense, Morrowind doesn't forces you operate right on the references (or, at least, that's how I did it). Which explains why I never really understood NWNscript, you just cleared most of it up for me Also, thanks for the KT tip, didn't even know that, and I'm gonna be sure to use it Link to comment Share on other sites More sharing options...
Watcher07 Posted May 25, 2008 Share Posted May 25, 2008 I didn't want to start a new thread since this one seemed to be right up the line of what I am hoping to find an answer to, but very simple scripting question. Is it safe to assume that all will be well with my script in game when I compile it with nwnnsscomp and resolve the errors it displays? Or does it only catch certain errors and I should use some other medium to test the script? Please bear with my newbness on this as I've been scripting for all of about 45 minutes now. I read through the tutorials and they don't indicate any other kind of testing required, but I just wanted to make sure I wasn't missing anything. Thanks. Link to comment Share on other sites More sharing options...
EnderWiggin Posted May 25, 2008 Share Posted May 25, 2008 If nwnnsscomp doesn't show any errors, it means your script is error free. However, it doesn't always do the thing you want it to, due to other mistakes, such as putting in the wrong resref or npc name, perhaps. So the best thing to do is just throw it into override, go to where you put it, let it run, and see what happens. _EW_ Link to comment Share on other sites More sharing options...
Watcher07 Posted May 25, 2008 Share Posted May 25, 2008 and they say trial by fire isn't fun Thanks for the quick reply. I'm not creating custom ones so much as trying to get a few different scripts to play nicely together (90SK's Super Mod, USM, Peragus prologue issues fixed, etc.), figured it was a good way to dive into scripting. Again, thanks for the quick reply and the help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.