N-DReW25 1,337 Posted February 22, 2017 Just going to drop a small script request! What is the script that when a hostile NPC reaches 1HP they start a conversation? Quote Share this post Link to post Share on other sites
bead-v 251 Posted February 22, 2017 The door could also be locked. IIRC doors won't open even with scrpits while they're locked. This is definitely not the case in TSL, but I haven't yet opened a single door per script in K1 Just going to drop a small script request! What is the script that when a hostile NPC reaches 1HP they start a conversation? You need to put a custom OnDamage script into the NPC's .utc and use SetMinOneHP() before the battle, so they don't die. In the script, when the HP is as low as you want, CancelCombat(), ClearAllActions() and ChangeToStandardFaction() for all the creatures involved, then ActionStartConversation(). If you want the same to happen when the PC hits low HP, then you make a similar script but put it in OnEndCombatRound. I should probably put this disclaimer in my signature : all of this is for TSL. K1 is likely the same, but can have differences. Quote Share this post Link to post Share on other sites
jc2 581 Posted February 22, 2017 Thank you FS, Thank you Kexikus, I woke up realizing I should have used the assigncommand function. Yes, thank you for clearing that up about the .utd; i knew it didn't work for .uti files, but I hadn't tried doors. My script works! This is great! 1 Quote Share this post Link to post Share on other sites
N-DReW25 1,337 Posted February 23, 2017 This is definitely not the case in TSL, but I haven't yet opened a single door per script in K1 You need to put a custom OnDamage script into the NPC's .utc and use SetMinOneHP() before the battle, so they don't die. In the script, when the HP is as low as you want, CancelCombat(), ClearAllActions() and ChangeToStandardFaction() for all the creatures involved, then ActionStartConversation(). If you want the same to happen when the PC hits low HP, then you make a similar script but put it in OnEndCombatRound. I should probably put this disclaimer in my signature : all of this is for TSL. K1 is likely the same, but can have differences. Thanks, but can you please put the script in a format that I can copy and paste like what DarthRevan101 did in his post in this thread at the beginning? Quote Share this post Link to post Share on other sites
bead-v 251 Posted February 23, 2017 (edited) //:: k_def_damage01 /* Default On Damaged Script */ //:: Created By: Preston Watamaniuk //:: Copyright (c) 2002 Bioware Corp. #include "k_inc_switch" #include "k_inc_debug" void main(){ object oPC = GetFirstPC(); if(GetCurrentHitPoints(OBJECT_SELF) < 10 && GetStandardFaction(OBJECT_SELF) == STANDARD_FACTION_HOSTILE_1){ CancelCombat(OBJECT_SELF); CancelCombat(oPC); ClearAllActions(); AssignCommand(oPC, ClearAllActions()); ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_NEUTRAL); AssignCommand(oPC, ActionStartConversation(OBJECT_SELF, "yourconvo")); } ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_DEFAULT_EVENT_ON_DAMAGE); } You should decide yourself if you want to ClearAllEffects() as well, and if you want to SetMinOneHP() back to FALSE after the battle. Also, this assumes the PC is fighting only one NPC. K1 modders double check my code please Edited February 23, 2017 by bead-v 1 Quote Share this post Link to post Share on other sites
jc2 581 Posted March 5, 2017 Hey again! (Edited from last post) I've gotten 3 GetGlobalNumber scripts to work, but I've messed up on one of the two following scripts. Either Shaniliav4 or Shaniliav5, most likely Shaniliav5. Instead of trying to lock the dialogue behind the PC, I decided I wanted to allow the PC to have the conversations again. Therefore, I used the >= to do this. It worked for one of the int StartingConditional scripts (Shaniliav3); however, when I tried the same trick again for Shaniliav5 it didn't work. I tested the dialogue file repeatedly, placing the Int StartingCondtional into the "determining Script availbility" and the void main SetGlobalNumber into the "script that fires." I'm almost sure it wasn't a simple mistake of placing the script into the wrong place. To clarify exactly what I did. PC speaks firing the first int StartingConditional (Shaniliav1), Shanilia responds firing the first main void SetGlobalNumber script (Shaniliav2), then an additional dialogue option appears with Shaniliav3 as the "Script determine Availability." Shanilia responds firing Shaniliav4. The problem was that the next dialogue option was not shown, I placed Shaniliav5 into it as the "Script determine Availability." Capitalization was kept while placing the scripts into the dlg file, I just didn't want to constantly capitalize them here. P.S. I don't know how to disable the XML to make it white only. None of my script shows up in colors from what I can tell. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted March 7, 2017 Sorry for not replying beforehand. I usually don't during the weekends. You want to remove the Also, the color-coding talk was solely if you try to post code using the button in the post toolbar. It pops up a box with a dropdown menu and a place to enter your code. 1 Quote Share this post Link to post Share on other sites
Quanon 263 Posted March 28, 2017 Hello, fellow modders! I'm in need of some advice. Trying to get a script right for a container to appear on Tatooine anchor head. This script only needs to work once! It basicly spawns a container with goodies, I'm in doubt on where to put the script? On a dialogue or someplace else?So far this is what I got: void main() { object oContainer=GetObjectByTag("q_helmbox"); if (oContainer==OBJECT_INVALID) { vector vContainer=Vector (109.00, 67.15, 3.75); location lContainer=Location(vContainer, 0.0); oContainer= CreateObject(OBJECT_TYPE_PLACEABLE, "q_helmbox", lContainer); CreateItemOnObject("q_darkhelm", oContainer); CreateItemOnObject("q_mask226", oContainer); CreateItemOnObject("q_mask227", oContainer); CreateItemOnObject("q_masshelm", oContainer); CreateItemOnObject("q_praethelm", oContainer); CreateItemOnObject("q_spikehelm", oContainer); CreateItemOnObject("q_darthdark", oContainer); CreateItemOnObject("q_darthlght", oContainer); CreateItemOnObject("q_darthmass", oContainer); } } Quote Share this post Link to post Share on other sites
JCarter426 1,215 Posted March 28, 2017 Script looks fine to me. I'd suggest taking k_ptat17_enter, renaming that to something, and then adding ExecuteScript("WHATEVER_YOU_NAMED_THE_OTHER_SCRIPT", OBJECT_SELF, -1); to the end of your script. You'll run into compatibility issues with other mods that edit the on enter script, but those are few and it's relatively easy to fix on a case by case basis. Also I don't think this matters, but if it does matter I might as well tell you: GetIsObjectValid(object oObject) That's the function I usually use to check if an object is valid. I think your way should work, but just in case it doesn't, you know. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted March 29, 2017 Sorry I hadn't responded to the PM, Q. I've been busy the last few days... :| Your code should work and is functionally identical to JCarter's mention of GetIsObjectValid, so that's good. Since you're trying to make this as compatible as possible, I would ask you when you plan to make these items available. If you want them available as soon as you hit Tatooine, then you can add the script as an action script on the first available line that you find in the Customs Officer's welcoming DLG, tat17_01cust_01.dlg in tat_m17ab. At a quick glance, you can attach this script to either the "This will cover any future landings" or "Now, as a customs officer, I can" lines in his opening dialog to spawn your item. This bit of dialog is only ran once, just after you pay the docking fee. 2 Quote Share this post Link to post Share on other sites
jc2 581 Posted April 7, 2017 How would I got about using a single script to check if a boolean number was set to either 3 or 5? This is my current script, but it doesn't seem to accept the second conditional. Should I try something with param1 or param2? Any help would be appreciated. int StartingConditional() /// I want both three and five of the Numb boolean to /// allow the converation to become available { if(GetGlobalNumber("JC2Side_Quest") == 5) { return TRUE; } return FALSE; if(GetGlobalNumber("JC2Side_Quest") == 3) { return TRUE; } return FALSE; } Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted April 7, 2017 The reason the second conditional is ignored is because the "return FALSE;" above it is executed immediately, since it's not in its own block. So you're aborting your script halfway through. Usually when you want to check multiple conditions, you can string them together in the condition block ( the if( ) ) using either "!!" or "&&" (these mean "OR" and "AND" respectively). In your code, that would look like this: int StartingConditional() /// I want both three and five of the Numb boolean to /// allow the converation to become available { if(GetGlobalNumber("JC2Side_Quest") == 5 || GetGlobalNumber("JC2Side_Quest") == 3) { return TRUE; } return FALSE; } As a sidenote, I personally hate having to re-type the same bit over and over again, so if it's something that will be checked multiple times, I usually store it in a variable. To use your code as an example: int StartingConditional() /// I want both three and five of the Numb boolean to /// allow the converation to become available { int iQuest = GetGlobalNumber("JC2Side_Quest"); if(iQuest == 3 || iQuest == 5) { return TRUE; } return FALSE; } Quote Share this post Link to post Share on other sites
jc2 581 Posted April 7, 2017 The reason the second conditional is ignored is because the "return FALSE;" above it is executed immediately, since it's not in its own block. So you're aborting your script halfway through. Usually when you want to check multiple conditions, you can string them together in the condition block ( the if( ) ) using either "!!" or "&&" (these mean "OR" and "AND" respectively). In your code, that would look like this: Thanks FS! Just tested it out and it works beautifully, I am curious though. When i typed in "!!" it didn't work, I tried typing in "!" Instead, I wrote "||" and I was able to get the script. I'm confused about what you mean by using the exclamation marks. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted April 7, 2017 That would be a typo. The intent was to type this ||. 1 Quote Share this post Link to post Share on other sites
jc2 581 Posted April 9, 2017 Hey FS, I've run into another issue. My script has a way of only partially working. This is for K1. int StartingConditional() { return Random(2) == 0; } It manages to fire and cycle the one-liners, but no sound comes out. I've added custom voice overs, which will work, if and only if, I don't use this script and if I allow the PC to reply to the NPC. Is there some way I can tell the game to play a sound file from the streamwaves folder with script? Could I possibly add a script that includes this random effect but also starts a .dlg file, and then, should I just make several dlg files that only have one-liners in them? Any help would be appreciated. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted April 9, 2017 This tends to be more of a dialog thing, but it could be that the one-liner dialog (I don't know what you have for text in the one-liner, if anything) could be playing too fast and skipping the audio file. For that, you can try setting the Delay of the one-liner entry in the .dlg file to 6 or so when you click on the line. It's not an issue of audio format, since you are able to get it to play. Hmm... As for playing the audio through script from the streamwaves folder, maybe not. However, from what I've seen, you should be able to put the file in streamsounds and use the PlaySound function with the name of the audio file. 2 Quote Share this post Link to post Share on other sites
jc2 581 Posted April 9, 2017 It's not an issue of audio format, since you are able to get it to play. Hmm... As for playing the audio through script from the streamwaves folder, maybe not. However, from what I've seen, you should be able to put the file in streamsounds and use the PlaySound function with the name of the audio file. You're a bloody genius, this works. (second option with PlaySound script function) Thanks! 1 Quote Share this post Link to post Share on other sites
jc2 581 Posted April 19, 2017 Hey FS, I've been using the GetObjectByTag and the ChangeToStandardFaction, but I cannot seem to change the faction of copies of the UTC. For instance, I have three "tat_thug1" but only one of them changes faction. It reads, "// - nNth: the nth object with this tag may be requested" so I'm thinking I might have to do GetObjectByTag("tat_thug1", 1); then GetObjectByTag("tat_thug1", 2) ? Or would it be the total GetObjectByTag("tat_thug1", 3); instead? Thanks in advance! Quote Share this post Link to post Share on other sites
bead-v 251 Posted April 19, 2017 The nNth should be a 0-based index. So the first tat_thug1 would be GetObjectByTag("tat_thug1", 0). And then 1 and 2 for the other two. 1 Quote Share this post Link to post Share on other sites
VarsityPuppet 1,085 Posted April 19, 2017 The nNth should be a 0-based index. So the first tat_thug1 would be GetObjectByTag("tat_thug1", 0). And then 1 and 2 for the other two. I can give you 2 good reasons to always start at 0 0) It's common practice 1) It takes care of off by one errors 2 Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted April 20, 2017 @jc2: You guessed correctly the first time and would need to add 1 every time. If you know for sure all the copies need to be changed, you can usually get away with this: void main() { string sTag = "tat_thug1"; int iIndex = 0; while(GetIsObjectValid(GetOjbectByTag(sTag, iIndex)) == TRUE) { ChangeToStandardFaction(oTarget, STANDARD_FACTION_HOSTILE_1); iIndex++; } } @bead-v and VP: Thanks for adding that bit of info. I've been busy all day. Though I will point out the obvious: most non-computer systems start counting from 1, not 0. So the 0-index system isn't exactly an intuitive thing for someone to pick up on. 2 1 Quote Share this post Link to post Share on other sites
jc2 581 Posted April 20, 2017 So I've been trying to apply stealth to units, but I'm not sure how to do it. I can't seem to either find the correct 2da file with the effects, and/or my script is flawed. Edit: I used the visualeffects.2da to come up with the number 8002. void main () { object oC =GetObjectByTag("g_mandalor02", 0); SetCommandable(TRUE, oC); ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectInvisibility(8002), oC, 100.00); } Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted April 20, 2017 I've never actually done this myself, but you should be able to do the following: void main() { object oTarget = GetObjectByTag("g_mandalor02"); effect eInvisible = EffectInvisibility(INVISIBILITY_TYPE_NORMAL); eInvisible = EffectLinkEffects(EffectVisualEffect(VFX_DUR_INVISIBILITY), eInvisible); eInvisible = EffectLinkEffects(EffectVisualEffect(VFX_DUR_STEALTH_PULSE), eInvisible); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eInvisible, oTarget); } You can and probably should play around with it to see if there's a difference with the second two Effect lines commented out. Same thing with a difference between "DURATION_TYPE_PERMANENT" and "DURATION_TYPE_INSTANT". 1 Quote Share this post Link to post Share on other sites
jonathan7 15 Posted April 29, 2017 Forgive a total noob question, Scripting never was my strong point. Is there a way to fire a script which adds a custom robe to Atton or Disciple when they become a Jedi? Currently this is implemented in their .dlg which is what is causing the incompatibility with TSL:RCM and Force Fashion Quote Share this post Link to post Share on other sites
JCarter426 1,215 Posted April 29, 2017 All party members are made Jedi with the same script, a_makejedi, and it's already divided into different trees for each party member. So all you'd have to do is attach the item spawning to the appropriate trees and recompile. Of course, that will cause incompatibility with any other mods that alter that script, but it's the most minimally intrusive way I can think of. Quote Share this post Link to post Share on other sites