Jump to content

Home

Turning Two Scripts Into One Script?


Keiko

Recommended Posts

Hello,

 

What I am trying to do is put two scripts together, these are the scripts that im using:

 

 

Script #1:

 

void main()

{

 

AddAvailableNPCByObject(NPC_Owen_Star,GetObjectByTag("G0T0"));

 

AddPartyMember(NPC_Owen_star,GetObjectByTag("G0T0"));

 

}

 

 

Script # 2:

 

 

void main()

{

int iDelay = GetScriptParameter(1);

string sTag = GetScriptStringParameter();

 

// Make it so the object can be destroyed, in case it was set to not be destroyable

AssignCommand(GetObjectByTag( sTag ), SetIsDestroyable(TRUE,TRUE,TRUE));

 

DelayCommand( IntToFloat( 1.0 ),DestroyObject( GetObjectByTag( G0T0 ) ) );

}

 

I have a feeling that I need to hook these scripts together using some kind of link, but I dont know what to do, im a scripting N00b, so thanks for you help!:D

 

-Smallz

Link to comment
Share on other sites

Originally posted by DarthSmallz

What I am trying to do is put two scripts together, these are the scripts that im using:

(snip)

 

What are you trying to do? As far as I can see those two scripts do fairly different things. I'll assume what you want is to get rid of G0T0 and spawn another custom party member in its place.

 

If that's the case, this would probably work:

#include "k_inc_glob_party"

void ST_RemoveOldPartyNPC(int nSlot) {
   int nIdx = 0;
   object oNPC = GetObjectByTag(GetNPCTag(nSlot), nIdx);
   while (GetIsObjectValid(oNPC)) {
       if (IsObjectPartyMember(oNPC)) {
           AssignCommand(oNPC, SetIsDestroyable(TRUE));
           DelayCommand(0.1, AssignCommand(oNPC, DestroyObject(OBJECT_SELF)));
           break;
       }
       oNPC = GetObjectByTag(GetNPCTag(nSlot), ++nIdx);
   }

   RemovePartyMember(nSlot);
   RemoveAvailableNPC(nSlot);
}

void ST_AddNewPartyNPC(int nSlot, string sTag) {
   object oNew = GetObjectByTag(sTag);
   if (GetIsObjectValid(oNew)) {
       AddAvailableNPCByObject(nSlot, oNew);
       AddPartyMember(nSlot, oNew); 
   }   
}

void main() {
   int nNPC    = GetScriptParameter(1);
   string sTag = GetScriptStringParameter();

   if (IsAvailableCreature(nNPC)) {
       ST_RemoveOldPartyNPC(nNPC);
   }
   DelayCommand(0.5, ST_AddNewPartyNPC(nNPC, sTag));
}

 

From your script above I assumed the script was intended to be used from a dialog. Attach it to a dialog node, set the first parameter (P1 in DLGEditor) to the slot of the NPC to replace, in this case "3" (which is the value of NPC_G0T0). Then set the StringParam to the tag of the creature to join in that slot instead, in this case "g0t0".

 

That script should remove the standard creature who occupies G0T0s party slot, delete that creature from the game and then add the first new creature with the specified tag to that party slot instead.

 

(Disclaimer: Since I just wrote that script it is entirely untested. It should work, but scripting without testing often tends to be a recipe for trouble even if it compiles... :) )

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...