Jump to content


Photo

Fair Strides' Script Shack


  • Please log in to reply
110 replies to this topic

#21 JCarter426

JCarter426

    Jedi Knight

  • M478_Staff
  • 281 posts

Posted 21 February 2017 - 03:34 PM

I would point out that stoffe's tutorial was for K2, and is not entirely accurate for K1. K1 has far fewer booleans, and the notes about which are available in NWScript are incorrect, and I remember having trouble with local numerics as well.



#22 Fair Strides

Fair Strides

    Aurora Engine Operator

  • Administrators
  • 2,203 posts
  • LocationOregon, USA

Posted 21 February 2017 - 04:16 PM

I would point out that stoffe's tutorial was for K2, and is not entirely accurate for K1. K1 has far fewer booleans, and the notes about which are available in NWScript are incorrect, and I remember having trouble with local numerics as well.

This, exactly this. This is why I tried and failed to use local numerics in the Pazaak Tournament in K1. I forget the particulars, but I think I was having issues with updating already-set ones when keeping track of info.


(By the way, if you ever want to ask about one of the quotes, feel free to send me a PM)

 

My personal, made-up quote: "To know is good, but to act is better."

"Words are just words, thoughts thoughts, but actions...actions are progress." - Fair Strides

"Intelligence and respect are all it takes to get along fine. Not a bad trade off, huh?" - EwigD from GameFaqs

"And regarding butchering the language, I have been to the internet. The language is well butchered regularly." - Malkior

 

"You can either live with the lies or die with the truth. Who would rather lie to live than die for telling the truth?" - Fair Strides


#23 jc2

jc2

    Kyramud

  • Members
  • PipPipPipPip
  • 289 posts
  • LocationAlderaan 19 BBY

Posted 22 February 2017 - 09:30 AM

Local buffoon here! How do you open a door?

 

So i'm trying to open a door on Manaan that closes itself. I don't know why it does this. It will open, then close. Not instantly but when you reload the module.

 

I wrote a script that would fire after a dialogue happened, which would open the door while you were in the module. It isn't working though. The door stays shut. I attempted to use the ActionOpenDoor function. 

Attached Files


KOTOR FOR LIFE

"To ponder and find relevance, one must seek out a quote," because his own words lack the credibility to endeavor to explain his rather odd disposition.

 

Grey Jedi "Shanilia" > http://deadlystream..../1044-shanilia/

 

Thank you FS for past and current modding help! 


#24 Fair Strides

Fair Strides

    Aurora Engine Operator

  • Administrators
  • 2,203 posts
  • LocationOregon, USA

Posted 22 February 2017 - 09:42 AM

Local buffoon here! How do you open a door?

 

So i'm trying to open a door on Manaan that closes itself. I don't know why it does this. It will open, then close. Not instantly but when you reload the module.

 

I wrote a script that would fire after a dialogue happened, which would open the door while you were in the module. It isn't working though. The door stays shut. I attempted to use the ActionOpenDoor function. 

 

The important thing is that you will NEVER need to use the period and the extension in scripting. Some other things to point out without actually checking the files in question (the files in the level):

 

1. If the DoDoorAction doesn't work, then AssignCommand(GetObjectByTag("<tag of door>"), ActionOpenDoor(GetObjectByTag("<tag of door>"))); should work.

2. If there is more than one copy of that door in the level, then the script would have probably opened the very first instance of that door. I can go over that a bit more in the next stream.


  • jc2 likes this

(By the way, if you ever want to ask about one of the quotes, feel free to send me a PM)

 

My personal, made-up quote: "To know is good, but to act is better."

"Words are just words, thoughts thoughts, but actions...actions are progress." - Fair Strides

"Intelligence and respect are all it takes to get along fine. Not a bad trade off, huh?" - EwigD from GameFaqs

"And regarding butchering the language, I have been to the internet. The language is well butchered regularly." - Malkior

 

"You can either live with the lies or die with the truth. Who would rather lie to live than die for telling the truth?" - Fair Strides


#25 Kexikus

Kexikus

    Jedi Master

  • Members
  • PipPipPipPipPip
  • 1,345 posts

Posted 22 February 2017 - 10:54 AM

The door could also be locked.

IIRC doors won't open even with scrpits while they're locked. So try and add

SetLocked("<door tag without <> >", FALSE);

But most likely your issue is the file extension in the script. This may be due to a wrong understanding, so let me try and clear this up. What you reference here is NOT the file name but the file tag set in the .ut* file. Usually it's the same (maybe it even has to be the same) but the tag obviously has no file extension which is why you don't use it.

That said, you NEVER use file extensions as FS said even when you actually reference files like in the ExecuteScript() function.


  • jc2 likes this

#26 N-DReW25

N-DReW25

    Little Fixer

  • Members
  • PipPipPipPipPip
  • 624 posts
  • LocationSuper Secret GenoHaradan Base

Posted 22 February 2017 - 11:21 AM

Just going to drop a small script request! What is the script that when a hostile NPC reaches 1HP they start a conversation?



#27 bead-v

bead-v

    Evil Malachor Overlord

  • Premium Member
  • 351 posts
  • LocationSlovenia

Posted 22 February 2017 - 12:22 PM

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 :P

 

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 :P : all of this is for TSL. K1 is likely the same, but can have differences.



#28 jc2

jc2

    Kyramud

  • Members
  • PipPipPipPip
  • 289 posts
  • LocationAlderaan 19 BBY

Posted 22 February 2017 - 07:24 PM

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!


KOTOR FOR LIFE

"To ponder and find relevance, one must seek out a quote," because his own words lack the credibility to endeavor to explain his rather odd disposition.

 

Grey Jedi "Shanilia" > http://deadlystream..../1044-shanilia/

 

Thank you FS for past and current modding help! 


#29 N-DReW25

N-DReW25

    Little Fixer

  • Members
  • PipPipPipPipPip
  • 624 posts
  • LocationSuper Secret GenoHaradan Base

Posted 23 February 2017 - 03:16 AM

This is definitely not the case in TSL, but I haven't yet opened a single door per script in K1 :P

 

 

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 :P : 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?



#30 bead-v

bead-v

    Evil Malachor Overlord

  • Premium Member
  • 351 posts
  • LocationSlovenia

Posted 23 February 2017 - 03:42 PM

//:: 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 :) :P


Edited by bead-v, 23 February 2017 - 03:44 PM.

  • jc2 likes this

#31 jc2

jc2

    Kyramud

  • Members
  • PipPipPipPip
  • 289 posts
  • LocationAlderaan 19 BBY

Posted 05 March 2017 - 07:21 PM

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. 

 

Attached Files


KOTOR FOR LIFE

"To ponder and find relevance, one must seek out a quote," because his own words lack the credibility to endeavor to explain his rather odd disposition.

 

Grey Jedi "Shanilia" > http://deadlystream..../1044-shanilia/

 

Thank you FS for past and current modding help! 


#32 Fair Strides

Fair Strides

    Aurora Engine Operator

  • Administrators
  • 2,203 posts
  • LocationOregon, USA

Posted 07 March 2017 - 12:21 AM

Sorry for not replying beforehand. I usually don't during the weekends. You want to remove the < in "<SHANILIA" in SHANILIAv4.nss.

 

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.


  • jc2 likes this

(By the way, if you ever want to ask about one of the quotes, feel free to send me a PM)

 

My personal, made-up quote: "To know is good, but to act is better."

"Words are just words, thoughts thoughts, but actions...actions are progress." - Fair Strides

"Intelligence and respect are all it takes to get along fine. Not a bad trade off, huh?" - EwigD from GameFaqs

"And regarding butchering the language, I have been to the internet. The language is well butchered regularly." - Malkior

 

"You can either live with the lies or die with the truth. Who would rather lie to live than die for telling the truth?" - Fair Strides


#33 Quanon

Quanon

    Jedi Knight

  • Members
  • PipPipPipPip
  • 346 posts
  • LocationHarelbeke

Posted 28 March 2017 - 08:04 AM

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:

Spoiler


#34 JCarter426

JCarter426

    Jedi Knight

  • M478_Staff
  • 281 posts

Posted 28 March 2017 - 08:47 AM

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.



#35 Fair Strides

Fair Strides

    Aurora Engine Operator

  • Administrators
  • 2,203 posts
  • LocationOregon, USA

Posted 29 March 2017 - 07:01 AM

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.


(By the way, if you ever want to ask about one of the quotes, feel free to send me a PM)

 

My personal, made-up quote: "To know is good, but to act is better."

"Words are just words, thoughts thoughts, but actions...actions are progress." - Fair Strides

"Intelligence and respect are all it takes to get along fine. Not a bad trade off, huh?" - EwigD from GameFaqs

"And regarding butchering the language, I have been to the internet. The language is well butchered regularly." - Malkior

 

"You can either live with the lies or die with the truth. Who would rather lie to live than die for telling the truth?" - Fair Strides


#36 jc2

jc2

    Kyramud

  • Members
  • PipPipPipPip
  • 289 posts
  • LocationAlderaan 19 BBY

Posted 07 April 2017 - 04:59 PM

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;
}

KOTOR FOR LIFE

"To ponder and find relevance, one must seek out a quote," because his own words lack the credibility to endeavor to explain his rather odd disposition.

 

Grey Jedi "Shanilia" > http://deadlystream..../1044-shanilia/

 

Thank you FS for past and current modding help! 


#37 Fair Strides

Fair Strides

    Aurora Engine Operator

  • Administrators
  • 2,203 posts
  • LocationOregon, USA

Posted 07 April 2017 - 05:08 PM

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;

}


(By the way, if you ever want to ask about one of the quotes, feel free to send me a PM)

 

My personal, made-up quote: "To know is good, but to act is better."

"Words are just words, thoughts thoughts, but actions...actions are progress." - Fair Strides

"Intelligence and respect are all it takes to get along fine. Not a bad trade off, huh?" - EwigD from GameFaqs

"And regarding butchering the language, I have been to the internet. The language is well butchered regularly." - Malkior

 

"You can either live with the lies or die with the truth. Who would rather lie to live than die for telling the truth?" - Fair Strides


#38 jc2

jc2

    Kyramud

  • Members
  • PipPipPipPip
  • 289 posts
  • LocationAlderaan 19 BBY

Posted 07 April 2017 - 05:21 PM

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. 


KOTOR FOR LIFE

"To ponder and find relevance, one must seek out a quote," because his own words lack the credibility to endeavor to explain his rather odd disposition.

 

Grey Jedi "Shanilia" > http://deadlystream..../1044-shanilia/

 

Thank you FS for past and current modding help! 


#39 Fair Strides

Fair Strides

    Aurora Engine Operator

  • Administrators
  • 2,203 posts
  • LocationOregon, USA

Posted 07 April 2017 - 05:23 PM

That would be a typo. :) The intent was to type this ||.


  • jc2 likes this

(By the way, if you ever want to ask about one of the quotes, feel free to send me a PM)

 

My personal, made-up quote: "To know is good, but to act is better."

"Words are just words, thoughts thoughts, but actions...actions are progress." - Fair Strides

"Intelligence and respect are all it takes to get along fine. Not a bad trade off, huh?" - EwigD from GameFaqs

"And regarding butchering the language, I have been to the internet. The language is well butchered regularly." - Malkior

 

"You can either live with the lies or die with the truth. Who would rather lie to live than die for telling the truth?" - Fair Strides


#40 jc2

jc2

    Kyramud

  • Members
  • PipPipPipPip
  • 289 posts
  • LocationAlderaan 19 BBY

Posted 09 April 2017 - 09:20 PM

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. 

KOTOR FOR LIFE

"To ponder and find relevance, one must seek out a quote," because his own words lack the credibility to endeavor to explain his rather odd disposition.

 

Grey Jedi "Shanilia" > http://deadlystream..../1044-shanilia/

 

Thank you FS for past and current modding help! 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users