Fair Strides

Fair Strides' Script Shack

Recommended Posts

lol I almost didn't mention that because I was like "what are the odds of that!" :lol:  Anyway, glad it's working now! :D

You saved an entire project, LOL! One final script and the entire project is COMPLETE. How would I go about delaying a conversation from happening in a script? I tried using the DelayCommand but I'm getting parameter mismatches. ( I can never make a script myself  :turned:  :turned:, here's my script.

 

void main(){

    object oNPC = GetObjectByTag("KreiaEvil");
    DelayCommand(2.0, AssignCommand(ActionStartConversation(oNPC, OBJECT_SELF, "FinalKreia"));
}

A total mess! anyway, any help is appreciated, I'm gonna work on the TSLPatcher now and hopefully I'll have an answer by the time I come back (Because I take long to do everything  :mad2: )

Share this post


Link to post
Share on other sites

I tried using the DelayCommand but I'm getting parameter mismatches.

 

Your DelayCommand() is fine, the problem is that you put the object you're assigning the action to inside ActionStartConversation() instead of AssignCommand(), and you're missing one ). Here's what it should look like:

void main(){
    object oNPC = GetObjectByTag("KreiaEvil");
    DelayCommand(2.0, AssignCommand(oNPC, ActionStartConversation(OBJECT_SELF, "FinalKreia")));
}

Share this post


Link to post
Share on other sites

Without knowing which character (whether they're an NPC, the Player, or a party member), here's something:

 

 

 

void main()
{
    object oTarget = GetObjectByTag("");
    int iSlot;
    for(iSlot = 0; iSlot <= 19; iSlot++)
    {
        if(iSlot >= 14 && iSlot <= 17) { continue; }

        AssignCommand(oTarget, ActionUnequipItem(GetItemInSlot(iSlot, oTarget), TRUE));
    }
}

 

 

 

That is for KotOR 2. To make it work for KotOR 1, simply change the "iSlot

Share this post


Link to post
Share on other sites

Without knowing which character (whether they're an NPC, the Player, or a party member), here's something:

 

 

 

void main()
{
    object oTarget = GetObjectByTag("");
    int iSlot;
    for(iSlot = 0; iSlot <= 19; iSlot++)
    {
        if(iSlot >= 14 && iSlot <= 17) { continue; }

        AssignCommand(oTarget, ActionUnequipItem(GetItemInSlot(iSlot, oTarget), TRUE));
    }
}

 

 

 

That is for KotOR 2. To make it work for KotOR 1, simply change the "iSlot <= 19;" to "iSlot <= 17;"

 

This is for a party member, I should've been more specific. With this script will the items go back to your inventory or just disappear?

Share this post


Link to post
Share on other sites

This script will simply unequip the items, not destroy them. Also, to make it work, replace the "" in "GetObjectByTag("");" with "", only don't use the marks.

  • Like 1

Share this post


Link to post
Share on other sites

This script will simply unequip the items, not destroy them. Also, to make it work, replace the "" in "GetObjectByTag("");" with "<tag of your party member>", only don't use the < > marks.

 

Works great, thanks for the help!

Share this post


Link to post
Share on other sites

@Reztea: Why are you even MAKING a script for that? Just check the boolean in the conversation using the default boolean check code? (c_glob_bool_set)

Share this post


Link to post
Share on other sites

How could I make it so that a door, after being opened, closes again after a few seconds? (For KotOR I)

 

I used modified Manaan door scripts for my Jolees Hut mod:

 

k_pman_door04.nss (attached to the UTDs OnOpen script tab)

 

 

 

void main()

{

DelayCommand(10.0f,SignalEvent(OBJECT_SELF,EventUserDefined(20)));

}

 

 

 

k_pman_door05.nss (attached to the UTDs OnUserDefined script tab)

 

 

 

void main()
{
    int nEvent = GetUserDefinedEventNumber();
    switch (nEvent)
    {
        case 20:
        {
            float fDistance = GetDistanceToObject(GetNearestObject(OBJECT_TYPE_CREATURE));
            if(fDistance >= 0.0 && fDistance <= 3.0)
            {
                DelayCommand(10.0f,SignalEvent(OBJECT_SELF,EventUserDefined(20)));
            }
            else
            {
                ActionCloseDoor(OBJECT_SELF);
            }
        }
        break;
    }
}

 

 

Share this post


Link to post
Share on other sites

I used modified Manaan door scripts for my Jolees Hut mod:

 

k_pman_door04.nss (attached to the UTDs OnOpen script tab)

 

 

 

void main()

{

DelayCommand(10.0f,SignalEvent(OBJECT_SELF,EventUserDefined(20)));

}

 

 

 

k_pman_door05.nss (attached to the UTDs OnUserDefined script tab)

 

 

 

void main()
{
    int nEvent = GetUserDefinedEventNumber();
    switch (nEvent)
    {
        case 20:
        {
            float fDistance = GetDistanceToObject(GetNearestObject(OBJECT_TYPE_CREATURE));
            if(fDistance >= 0.0 && fDistance <= 3.0)
            {
                DelayCommand(10.0f,SignalEvent(OBJECT_SELF,EventUserDefined(20)));
            }
            else
            {
                ActionCloseDoor(OBJECT_SELF);
            }
        }
        break;
    }
}

 

 

 

Thank you!

  • Like 1

Share this post


Link to post
Share on other sites

Assuming this "specific door" is a unique .utd file in the level and only spawned/used once in the .git file, you can attach a script to the OnOpen slot:

 

 

 

void main()
{
    if(GetLocalBoolean(OBJECT_SELF, 10) < 0)
    {
        SetLocalBoolean(OBJECT_SELF, 10, 1);

        DelayCommand(0.5, AssignCommand(GetFirstPC(), ActionStartConversation(GetObjectByTag("<tag of NPC>"), "<name of dialog>")));
    }
}

 

 

 

That should work for you. The local boolean stuff is just to make the conversation only activate once.

Share this post


Link to post
Share on other sites

Assuming this "specific door" is a unique .utd file in the level and only spawned/used once in the .git file, you can attach a script to the OnOpen slot:

 

 

 

void main()
{
    if(GetLocalBoolean(OBJECT_SELF, 10) < 0)
    {
        SetLocalBoolean(OBJECT_SELF, 10, 1);

        DelayCommand(0.5, AssignCommand(GetFirstPC(), ActionStartConversation(GetObjectByTag("<tag of NPC>"), "<name of dialog>")));
    }
}

 

 

 

That should work for you. The local boolean stuff is just to make the conversation only activate once.

Pretty sure I made a small mistake here, the script is not working. The only way I can actually get my NPC to speak his dialogue is to approach him and start dialogue normally. My tag of NPC is "mod_vulkar01.utc" and the dialogue is "tar03_vulkar031.dlg".

 

Here is my script

 

void main()
{
    if(GetLocalBoolean(OBJECT_SELF, 10) < 0)
    {
        SetLocalBoolean(OBJECT_SELF, 10, 1);
 
        DelayCommand(0.5, AssignCommand(GetFirstPC(), ActionStartConversation(GetObjectByTag("mod_vulkar01"), "tar03_vulkar031")));
    }
}

 
I think I may have done something wrong with my script above. I do also have a unique utd in the git so that cannot be the issue (I hope)

Share this post


Link to post
Share on other sites

The if condition has to be either == 0 or < 1, as the boolean is either 0 or 1, so it'll never be smaller than 0 which is why the condition is never fulfilled in your case.

Share this post


Link to post
Share on other sites

The kotor script doesn't really have a bool data type, it just uses int for it, but still, it's good to think of it separately, having either the value 'true' or 'false'.

 

Since you want the if() to pass if the boolean is false, it's best to write:

if ( !GetLocalBoolean(OBJECT_SELF, 10) ) { ... }

Or if you only want it to pass if it's true:

if ( GetLocalBoolean(OBJECT_SELF, 10) ) { ... }

For the same reason, writing this

SetLocalBoolean(OBJECT_SELF, 10, TRUE);

instead of this

SetLocalBoolean(OBJECT_SELF, 10, 1);

is better. Logically it's exactly equivalent, TRUE is defined as 1 in nwscript.nss. Using TRUE and FALSE will just help you keep the Boolean and Number functions apart in your mind, and it's more readable when you or somebody else reads the code (after a while).

 

Also, I'm not sure, but Get...Boolean() may not return 1 for when it's true, so you could get in trouble writing GetLocalBoolean() == 1 or GetLocalBoolean() == TRUE. Just keep in mind that Get...Boolean() already returns the true/false value, you don't need to == it.

Share this post


Link to post
Share on other sites

I am trying to make a Seppuku cutscene where a hostile NPC will reach 1hp then a dialogue will fire and the NPC will perform a Seppuku (Stabbing themselves with a Melee Weapon) and the NPC will drop dead. With that out of the way what are the scripts, I will need to actually fulfill this cutscene?

 

I think I have the 1hp script right here but not the rest

 

 

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

Also is it possible to do a Seppuku with a Vibrosword weapon or does it have to be a Lightsaber?

Share this post


Link to post
Share on other sites

Also, I'm not sure, but Get...Boolean() may not return 1 for when it's true, so you could get in trouble writing GetLocalBoolean() == 1 or GetLocalBoolean() == TRUE. Just keep in mind that Get...Boolean() already returns the true/false value, you don't need to == it.

The Local functions (not the global ones, mind you) will either return 0 or NOT 0, so FALSE or !FALSE. It's a weird quirk they seem to have. Mine was originally a typo on that, since the idea was to see if it was > 0, not

 

I am trying to make a Seppuku cutscene where a hostile NPC will reach 1hp then a dialogue will fire and the NPC will perform a Seppuku (Stabbing themselves with a Melee Weapon) and the NPC will drop dead. With that out of the way what are the scripts, I will need to actually fulfill this cutscene?

 

I think I have the 1hp script right here but not the rest

 

Also is it possible to do a Seppuku with a Vibrosword weapon or does it have to be a Lightsaber?

In the DLG file in question for that scene (852nih.dlg, second main branch), Visas plays the 1431 Meditate2 animation, assigned from the dialog file itself, not through script. Given that, I don't know if the animation is custom to her model, or the general animation.

 

As for your code, the following should do fine:

 

 

 

void main()
{
    object oPC = GetFirstPC();
    SetMinOneHP(OBJECT_SELF, TRUE); // Makes it so the NPC can't die.

    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);
        SetMinOneHP(OBJECT_SELF, FALSE);

        AssignCommand(oPC, ActionStartConversation(OBJECT_SELF, "yourconvo"));
    }

    ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_DEFAULT_EVENT_ON_DAMAGE);
}  

 

 

Share this post


Link to post
Share on other sites

In the DLG file in question for that scene (852nih.dlg, second main branch), Visas plays the 1431 Meditate2 animation, assigned from the dialog file itself, not through script. Given that, I don't know if the animation is custom to her model, or the general animation.

Kreia uses the animation during the Jedi Enclave Scene so I'll hope it's a General Animation.

 

 

 

As for your code, the following should do fine:

I forgot to mention the dialogue the NPC will mention has a conditional called 

 

 

c_batudead

 

I'll assume I'd need to change my NPC to Minimum 1hp in the Utc file in order for this to work. Two questions where will I place this new script in order for it to work and will the script need the "// Makes it so the NPC can't die." to work or is that there for the sake of direction?

Share this post


Link to post
Share on other sites

Is there a script to level up a party member? I've got a script to give them a Jedi class but it doesn't level them up once they get the class added, so they have to be levelled up in game manually. Is there a script to level up the character by 1 without affecting anyone else? (For KotOR 1)

void main()
{
AddMultiClass( CLASS_TYPE_JEDIGUARDIAN, GetObjectByTag(""));

}

Share this post


Link to post
Share on other sites

Hello! I was wondering if someone could tell me how I goofed this line of code; whenever I try to compile it it says 'Error: Syntax error at ","'.

 

Here's the specific line:

                      AssignCommand(GetObjectByTag("Juhani", 0), ActionMoveToLocation((-77.5775390625, -51.8112106323242, 0), 213.749927975663, 0), 0, 1.0);

And here's the chunk it's part of, if that's relevant:

                  else {
                    if ((nParam1 == 10)) {
                      AssignCommand(GetObjectByTag("Juhani", 0), ActionMoveToLocation((-77.5775390625, -51.8112106323242, 0), 213.749927975663, 0), 0, 1.0);
                      AssignCommand(GetObjectByTag("Bastila", 0), ActionMoveToObject(GetObjectByTag("wp_bastila_1", 0), 0, 1.0));
                    }

Share this post


Link to post
Share on other sites

I'll assume I'd need to change my NPC to Minimum 1hp in the Utc file in order for this to work. Two questions where will I place this new script in order for it to work and will the script need the "// Makes it so the NPC can't die." to work or is that there for the sake of direction?

This script would need to go in the OnDamaged script slot. Also, you will not need to set the Minimum 1 Hp setting in the UTC file, as that's done in the script with the "SetMinOneHP" function.

 

And the "//" denotes a comment in the code, purely for explanation.

 

Is there a script to level up a party member?

No, there is no auto-level function, unfortunately. Also, you can l9ck the Party Selection screen with SetAreaUnescapable function. S value of TRUE should disable it and calling the function again with a value of FALSE should re-enable it.

 

Hello! I was wondering if someone could tell me how I goofed this line of code; whenever I try to compile it it says 'Error: Syntax error at ","'.

 

Here's the specific line:

 

AssignCommand(GetObjectByTag("Juhani", 0), ActionMoveToLocation((-77.5775390625, -51.8112106323242, 0), 213.749927975663, 0), 0, 1.0);
I don't have the modding tools on me at the moment to look up the functions at the moment, but I know the compiler isn't seeing a valid location and I don't think the 0 inside the location section is required...

 

ActionMoveToLocation(Location(Vector(-77.5775390625, -51.8112106323242, 0.0), 213.749927975663), 0, 1.0);

Share this post


Link to post
Share on other sites

I don't have the modding tools on me at the moment to look up the functions at the moment, but I know the compiler isn't seeing a valid location and I don't think the 0 inside the location section is required...

 

ActionMoveToLocation(Location(Vector(-77.5775390625, -51.8112106323242, 0.0), 213.749927975663), 0, 1.0);

Thank you! But now it says the error is at ";".

 

I think these are the functions?

void ActionMoveToLocation(location lDestination, int bRun=FALSE);

location Location(vector vPosition, float fOrientation);

vector Vector(float x=0.0f, float y=0.0f, float z=0.0f);

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.