Sign in to follow this  
JediArchivist

[K2] Astromech Droid Companion for Mira

Recommended Posts

Recently I have been developing this mod where you can get an Astromech Droid companion for Mira. The Droid is intended to work as a puppet, such as Bao Dur's Remote.

I have been following this great Tutorial found here:

https://web.archive.org/web/20121204061652/http://www.lucasforums.com/showthread.php?t=151438

 

I have encountered a problem with actually triggering the puppet (Droid in our case) to appear. The Tutorial states this: "In order for that script to work, your intended puppet owner must be in the active party when the script is run. As such a good place to run the script would be as part of the script that makes the NPC in question join your party."

I have no idea how to bind the script to the one that makes Mira join my party, so I made a new Dialogue line for Mira that should trigger the script. I have her in my active party as stated in the Tutorial, the problem is that even after triggering the Conversation line that fires the puppet join script, the Droid still does not appear! I have no idea what goes wrong, I tried multiple times, checked and rechecked if the script is set to trigger in the dialogue, etc but it still doesn't work...

 

I'd be more than happy if anyone could lend a helping hand with this mod! If you want to help I'm attaching the mod files and savegame below, with my deepest gratitude!

Here are the files for the mod (drop them into Override):

Droid Companion for Mira.rar

And the savegame I used to test the mod:

Mira Droid Savegame.rar

  • Like 1

Share this post


Link to post
Share on other sites
On 15 aprilie 2020 at 4:06 PM, DarthParametric said:

If you are requesting help, it would be wise to include script source, not just binaries. DeNCS won't decompile either.

Thanks for the tip!

 

I am attaching the .nss uncompiled script files below:

st_ai_puppethb.nss

puppet.nss

They can be opened with Kotor Script Editor, or in the lack of it even Notepad!

The scripts used were taken from the Tutorial and edited accordingly.

Note: For the ST: st_ai_puppethb.ncs file, the Tutorial states that the "k_inc_generic" script generic must be extracted and placed in the same folder if the script will be compiled with Kotor Script Editor or another tool, but it is not necessary to extract and place the "k_inc_generic" in the same folder if the script is to be compiled with Kotor Tool's included script compiler, because it will automatically find and include the script! I have compiled the script with Kotor Tool, so I believe it is ok that I have not included "k_inc_generic" manually.

 

Here they are written out for convenience:

st_ai_puppethb.ncs

Quote

// ST: st_ai_puppethb.nss
#include "k_inc_generic"

void main() {
    object oEnemy = GetNearestCreature( 
        CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN, 
        OBJECT_SELF, 1, 
        CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, 
        CREATURE_TYPE_IS_ALIVE, TRUE
    );
    
    if (!GN_GetSpawnInCondition(SW_FLAG_AI_OFF)) {
        if (GetIsPuppet()
           && (GetIsObjectValid(GetPUPOwner())
           && (GetCurrentAction(OBJECT_SELF) != ACTION_MOVETOPOINT)
           && (GetCurrentAction(OBJECT_SELF) != ACTION_FOLLOWOWNER)
           && !GetIsConversationActive()
           && !GN_GetSpawnInCondition(SW_FLAG_SPECTATOR_STATE)
           && GetCommandable() 
           && (GetDistanceBetween2D(OBJECT_SELF, GetPUPOwner()) > 3.0)

           && (!GetIsObjectValid(oEnemy) || (GetDistanceBetween(oEnemy, OBJECT_SELF) > 20.0))))
        {
            ClearAllActions();
            ActionFollowOwner(2.0);
        }
    }
    
    if (GN_GetSpawnInCondition( SW_FLAG_EVENT_ON_HEARTBEAT ))
        SignalEvent(OBJECT_SELF, EventUserDefined(1001));
}

puppet.ncs

Quote

// -------------------------------------------------------
// Support function: Assign a puppet to a party member
// -------------------------------------------------------
void ST_GivePuppet(int nNPC, int nPUP, string sTemplate) {
    string sTag = "";
    switch (nNPC) {
        case NPC_ATTON:         sTag = "atton";         break;
        case NPC_BAO_DUR:       sTag = "baodur";        break;
        case NPC_CANDEROUS:     sTag = "mand";          break;
        case NPC_G0T0:          sTag = "g0t0";          break;
        case NPC_HANDMAIDEN:    sTag = "handmaiden";    break;
        case NPC_HK_47:         sTag = "hk47";          break;
        case NPC_KREIA:         sTag = "kreia";         break;
        case NPC_MIRA:          sTag = "mira";          break;
        case NPC_T3_M4:         sTag = "t3m4";          break;
        case NPC_VISAS:         sTag = "visasmarr";     break;
        case NPC_HANHARR:       sTag = "hanharr";       break;
        case NPC_DISCIPLE:      sTag = "disciple";      break;
    }
    
    object oOwner = GetObjectByTag(sTag);
    if (GetIsObjectValid(oOwner) && IsObjectPartyMember(oOwner)) {
        location lLoc = Location(GetPosition(oOwner) + AngleToVector(GetFacing(oOwner)) * 2.0, GetFacing(oOwner)-180.0);        
        
        AddAvailablePUPByTemplate(nPUP, sTemplate);
        AssignPUP(nPUP, nNPC);
        object oPUP = SpawnAvailablePUP(nPUP, lLoc);
        AddPartyPuppet(nPUP, oPUP);
        
        SetNPCAIStyle(oPUP, NPC_AISTYLE_PARTY_SUPPORT);
    }
}


// -------------------------------------------------------
// Main function: Example, call above function to assign
// a puppet in st_puppet1.utc to Kreia.
// -------------------------------------------------------
void main() {
    // Spawn the "st_puppet1" UTC as a puppet, assign it to Kreia
    ST_GivePuppet(NPC_MIRA, PUP_OTHER1, "mira_puppet");
}

 

Share this post


Link to post
Share on other sites

AFAIK, these aren't valid NCS files. That may be why it's not working. Try compiling with nwnnsscomp. The NWScript seems fine, it's the output that's strange.

In the meantime, I'll look into the puppet tutorials to gain a better understanding of this. I am writing an updated compiler/decompiler, so this is useful for everyone.

  • Thanks 1

Share this post


Link to post
Share on other sites

AHAHAHAHAHA

I opened these in a hex editor. Didn't think to open them in Notepad. Yeah, they aren't compiled.

  • Thanks 1

Share this post


Link to post
Share on other sites
On 15 aprilie 2020 at 8:41 PM, AmanoJyaku said:

AHAHAHAHAHA

I opened these in a hex editor. Didn't think to open them in Notepad. Yeah, they aren't compiled.

Of course they aren't compiled, they are .nss. The compiled, .ncs files are the ones included with the mod files attached to my first post! Check out the ones there.

The uncompiled .nss files were attached as suggested by DarthParametric, for you to see if there is any problem with the source script.

Share this post


Link to post
Share on other sites
On 15 aprilie 2020 at 10:12 PM, DarthParametric said:

No, your "NCS" files in the archive are just renamed NSS. Open them in a text editor and you'll see.

You are absolutely right, even though they open some HEX info when opened with Kotor Script Editor (and when opening it says "Decompiling...", when opening them in Notepad I get the source script in clear text!

Must have been something with my version of Kotor Tool, I have no idea...

You have my gratitude for letting me know of this, I couldn't wrap my head around what was going wrong!

 

I recompiled them, as instructed by the Tutorial: "In order to compile that script and produce the NCS file the game can use, you must extract the include files k_inc_generic.nss, k_inc_gensupport.nss, k_inc_walkways.nss and k_inc_drop.nss. You can find these files with KotorTool in Kotor II --> BIFs --> scripts.bif --> Script, Source. Extract them and save them in the same folder where you have the nwnnsscomp.exe script compiler. (If you are using the script editor in the latest version of KotorTool you shouldn't need to extract the include files manually; it will find them automatically when needed.)"

I extracted the necessary .nss files in my Kotor Script Editor folder, then compiled my 2 scripts. The attached files resulted:

st_ai_puppethb.ncs

puppet.ncs

They now open as encrypted info in Notepad, so I guess it worked this time...

  • Like 1

Share this post


Link to post
Share on other sites
On 16 aprilie 2020 at 6:46 PM, Sith Holocron said:

Mod approved.

Thanks! You have my gratitude! :)

Happy Easter (in my country Easter is this Sunday)!

  • Like 1

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.

Sign in to follow this