Jump to content

Home

Just a quick check in with the scripters


darthtyren

Recommended Posts

I released my first mod a while back here.

 

I decided I wanted to update it with a way to get the new items in the game without cheating, so I found the script that assigns the advanced classes and added an ActionGiveItem command to each parameter.

 

*I added the stuff in red*

 

// This makes the PC one of the Jedi classes, depending on parameter.
// Param Count = 1, decides which class to make him or her.
// 0 = Weaponmaster
// 1 = Watchman
// 2 = Jedi Master
// 3 = Marauder
// 4 = Sith Assassin
// 5 = Sith Lord
// CFA 10-6-04

void main()
{
   // Grab the Parameter.
   int nScriptNumber = GetScriptParameter( 1 );

   // If Param = 0, then make him a Jedi Weaponmaster.
   if ( nScriptNumber == 0 ) {
       AddMultiClass (CLASS_TYPE_JEDIWEAPONMASTER, GetFirstPC () );
       [color="Red"]ActionGiveItem(object a_robe_43, object GetFirstPC());[/color]
   }

   // If Param = 1, then make him a Jedi Watchman.
   if ( nScriptNumber == 1 ) {
       AddMultiClass (CLASS_TYPE_JEDIWATCHMAN, GetFirstPC () );
       [color="red"]ActionGiveItem(object a_robe_44, object GetFirstPC());[/color]
   }

   // If Param = 2, then make him a Jedi Master.
   if ( nScriptNumber == 2 ) {
       AddMultiClass (CLASS_TYPE_JEDIMASTER, GetFirstPC () );
       [color="red"]ActionGiveItem(object a_robe_45, object GetFirstPC());[/color]
   }

   // If Param = 3, then make him a Sith Marauder.
   if ( nScriptNumber == 3 ) {
       AddMultiClass (CLASS_TYPE_SITHMARAUDER, GetFirstPC () );
       [color="red"]ActionGiveItem(object a_robe_46, object GetFirstPC());[/color]
   }

   // If Param = 4, then make him a Sith Assassin.
   if ( nScriptNumber == 4 ) {
       AddMultiClass (CLASS_TYPE_SITHASSASSIN, GetFirstPC () );
       [color="red"]ActionGiveItem(object a_robe_47, object GetFirstPC());[/color]
   }

   // If Param = 5, then make him a Sith Lord.
   if ( nScriptNumber == 5 ) {
       AddMultiClass (CLASS_TYPE_SITHLORD, GetFirstPC () );
       [color="red"]ActionGiveItem(object a_robe_48, object GetFirstPC());[/color]
   }

}

 

I'm a total n00b when it comes to scripting, so I ask my fellow modders: Does this look right, or am I doing something wrong?

 

I haven't tested yet.

Link to comment
Share on other sites

I released my first mod a while back here.

 

I decided I wanted to update it with a way to get the new items in the game without cheating, so I found the script that assigns the advanced classes and added an ActionGiveItem command to each parameter.

 

*I added the stuff in red*

 

Show spoiler
(hidden content - requires Javascript to show)
// This makes the PC one of the Jedi classes, depending on parameter.
// Param Count = 1, decides which class to make him or her.
// 0 = Weaponmaster
// 1 = Watchman
// 2 = Jedi Master
// 3 = Marauder
// 4 = Sith Assassin
// 5 = Sith Lord
// CFA 10-6-04

void main()
{
   // Grab the Parameter.
   int nScriptNumber = GetScriptParameter( 1 );

   // If Param = 0, then make him a Jedi Weaponmaster.
   if ( nScriptNumber == 0 ) {
       AddMultiClass (CLASS_TYPE_JEDIWEAPONMASTER, GetFirstPC () );
       [color="Red"]ActionGiveItem(object a_robe_43, object GetFirstPC());[/color]
   }

   // If Param = 1, then make him a Jedi Watchman.
   if ( nScriptNumber == 1 ) {
       AddMultiClass (CLASS_TYPE_JEDIWATCHMAN, GetFirstPC () );
       [color="red"]ActionGiveItem(object a_robe_44, object GetFirstPC());[/color]
   }

   // If Param = 2, then make him a Jedi Master.
   if ( nScriptNumber == 2 ) {
       AddMultiClass (CLASS_TYPE_JEDIMASTER, GetFirstPC () );
       [color="red"]ActionGiveItem(object a_robe_45, object GetFirstPC());[/color]
   }

   // If Param = 3, then make him a Sith Marauder.
   if ( nScriptNumber == 3 ) {
       AddMultiClass (CLASS_TYPE_SITHMARAUDER, GetFirstPC () );
       [color="red"]ActionGiveItem(object a_robe_46, object GetFirstPC());[/color]
   }

   // If Param = 4, then make him a Sith Assassin.
   if ( nScriptNumber == 4 ) {
       AddMultiClass (CLASS_TYPE_SITHASSASSIN, GetFirstPC () );
       [color="red"]ActionGiveItem(object a_robe_47, object GetFirstPC());[/color]
   }

   // If Param = 5, then make him a Sith Lord.
   if ( nScriptNumber == 5 ) {
       AddMultiClass (CLASS_TYPE_SITHLORD, GetFirstPC () );
       [color="red"]ActionGiveItem(object a_robe_48, object GetFirstPC());[/color]
   }

}

 

I'm a total n00b when it comes to scripting, so I ask my fellow modders: Does this look right, or am I doing something wrong?

 

I haven't tested yet.

 

Your code is mostly right, but the game wouldn't know what the objects were. The code below will work:

 

// This makes the PC one of the Jedi classes, depending on parameter.
// Param Count = 1, decides which class to make him or her.
// 0 = Weaponmaster
// 1 = Watchman
// 2 = Jedi Master
// 3 = Marauder
// 4 = Sith Assassin
// 5 = Sith Lord
// CFA 10-6-04

void main()
{
   // Grab the Parameter.
   int nScriptNumber = GetScriptParameter( 1 );
   string sItemtag = "";

   // If Param = 0, then make him a Jedi Weaponmaster.
   if ( nScriptNumber == 0 ) {
       AddMultiClass (CLASS_TYPE_JEDIWEAPONMASTER, GetFirstPC () );
       sItemtag = "a_robe_43";
       CreateItemOnObject(sItemtag, GetFirstPC());
   }

   // If Param = 1, then make him a Jedi Watchman.
   if ( nScriptNumber == 1 ) {
       AddMultiClass (CLASS_TYPE_JEDIWATCHMAN, GetFirstPC () );
       sItemtag = "a_robe_44";
       CreateItemOnObject(sItemtag, GetFirstPC());
   }

   // If Param = 2, then make him a Jedi Master.
   if ( nScriptNumber == 2 ) {
       AddMultiClass (CLASS_TYPE_JEDIMASTER, GetFirstPC () );
       sItemtag = "a_robe_45";
       CreateItemOnObject(sItemtag, GetFirstPC());
   }

   // If Param = 3, then make him a Sith Marauder.
   if ( nScriptNumber == 3 ) {
       AddMultiClass (CLASS_TYPE_SITHMARAUDER, GetFirstPC () );
       sItemtag = "a_robe_46";
       CreateItemOnObject(sItemtag, GetFirstPC());
   }

   // If Param = 4, then make him a Sith Assassin.
   if ( nScriptNumber == 4 ) {
       AddMultiClass (CLASS_TYPE_SITHASSASSIN, GetFirstPC () );
       sItemtag = "a_robe_47";
       CreateItemOnObject(sItemtag, GetFirstPC());
   }

   // If Param = 5, then make him a Sith Lord.
   if ( nScriptNumber == 5 ) {
       AddMultiClass (CLASS_TYPE_SITHLORD, GetFirstPC () );
       sItemtag = "a_robe_48";
       CreateItemOnObject(sItemtag, GetFirstPC());
   }
}

 

As to where you went wrong with the above script:

 

You don't need to define the item type when you pass the info to a function. For example, GetFirstPC() is an Object Function and so represents an object when you use it. The game will know it is an object already.

 

Also, ActionGiveItem is an action and is assigned to an object. For this to work, you would have to assign the command to an object and that object would have to have that item in it's possession. Which brings me to my last point.

 

"

"object a_robe_43" -- The game has no clue what this is. For an object to have meaning, you would need to assign something to it. This can be done with a lot of functions depending on the situation.

 

For example:

  • GetObjectByTag -- This is used if the object already exists in the game world, which usually does not count one's inventory...
  • GetFirstPC/GetNextPC -- Cycles through the current party members
  • GetPartyMemberByIndex -- also used to cycle through the current party
  • GetFirstItemInInventory/GetNexItemInInventory -- Cycles through an object's inventory, retruring an object which you can then check the tag against using GetTag.
  • GetItemPossessedBy/GetItemPossessor -- Both of these sees if something has an item, but the first uses the supposed owner and the second uses the item.
  • CreateItemOnObject/CreateItemOnFloor/CreateObject -- The first is for cutscenes, the second will create something in the object's inventory, and the last is used to create any type of item/placeable/creature/door, .etc in general

Link to comment
Share on other sites

EDIT: Thanks, Fair Strides, it worked.

 

As to where you went wrong with the above script:

 

You don't need to define the item type when you pass the info to a function. For example, GetFirstPC() is an Object Function and so represents an object when you use it. The game will know it is an object already.

 

I figured that might be the case, just was checking.

 

Also, ActionGiveItem is an action and is assigned to an object. For this to work, you would have to assign the command to an object and that object would have to have that item in it's possession.

 

Fundamentally, would that mean inside a container, or on another NPC, or in the inventory?

 

Or all three?

 

Which brings me to my last point.

 

"

"object a_robe_43" -- The game has no clue what this is. For an object to have meaning, you would need to assign something to it. This can be done with a lot of functions depending on the situation.

 

For example:

  • GetObjectByTag -- This is used if the object already exists in the game world, which usually does not count one's inventory...
  • GetFirstPC/GetNextPC -- Cycles through the current party members
  • GetPartyMemberByIndex -- also used to cycle through the current party
  • GetFirstItemInInventory/GetNexItemInInventory -- Cycles through an object's inventory, retruring an object which you can then check the tag against using GetTag.
  • GetItemPossessedBy/GetItemPossessor -- Both of these sees if something has an item, but the first uses the supposed owner and the second uses the item.
  • CreateItemOnObject/CreateItemOnFloor/CreateObject -- The first is for cutscenes, the second will create something in the object's inventory, and the last is used to create any type of item/placeable/creature/door, .etc in general

 

So the CreateItemOnObject function would be used to add an item to the inventory using a script? At least, that's what I'm gathering.

 

I'm sorry if I'm not making sense - I have a long way to go to understanding KOTOR Language.

Link to comment
Share on other sites

I know there's a no-double-post rule, but honestly, who would come back to read a re-edited post?

 

OK, so new script, new problem. In the "new game script", a.k.a. a_bet3m4, there's a function that sets the Player's gender as a Global Boolean, 000_PLAYER_GENDER. It, in regards to the script, is as follows:

 

*it's in cyan, a little over halfway down*

// Prototypes
void sub3(object objectParam1, int intParam2);
void sub2();
void sub1();

void sub3(object objectParam1, int intParam2) {
object oRWeapItem = GetItemInSlot(4, objectParam1);
AssignCommand(objectParam1, ActionUnequipItem(oRWeapItem, 1));
if (intParam2) {
	DestroyObject(oRWeapItem, 0.0, 1, 0.0, 1);
}
}

void sub2() {
AddAvailableNPCByTemplate(8, "p_t3m4");
SwitchPlayerCharacter(8);
sub3(GetObjectByTag("t3m4", 0), 1);
SetMinOneHP(GetObjectByTag("t3m4", 0), 1);
AssignCommand(GetObjectByTag("debris", 0), ApplyEffectToObject(0, EffectDamage(25, 8, 0), GetObjectByTag("t3m4", 0), 0.0));
DisableHealthRegen(1);
ApplyEffectToObject(2, EffectVisualEffect(2067, 0), GetObjectByTag("t3m4", 0), 0.0);
}

void sub1() {
if ((GetGlobalNumber("001EBO_Rumble") == 0)) {
	DelayCommand(IntToFloat((Random(10) + 10)), sub1());
	AurPostString("Rumbling", 5, 5, 5.0);
	PlaySound("MetalStrain");
	ApplyEffectToObject(1, EffectVisualEffect(6002, 0), GetFirstPC(), IntToFloat((Random(8) + 1)));
}
}

void main() {
if (GetLoadFromSaveGame()) {
	return;
}
if (GetIsPC(GetEnteringObject())) {
	if ((!GetLocalBoolean(OBJECT_SELF, 30))) {
		SetLocalBoolean(OBJECT_SELF, 30, 1);
		sub1();
		RevealMap([0.0,0.0,0.0], 0xFFFFFFFF);
	}
	if (GetGlobalNumber("002EBO_Door_Override")) {
		object oStar_dorm = GetObjectByTag("star_dorm", 0);
		AssignCommand(oStar_dorm, ActionOpenDoor(oStar_dorm));
	}
	int nGlobal = GetGlobalNumber("001EBO_BEEN_T3_M4");
	if ((!nGlobal)) {
		[color="Cyan"]if ((0 == GetGender(GetFirstPC()))) {
			SetGlobalBoolean("000_PLAYER_GENDER", 1);
		}[/color]
		SetGlobalNumber("001EBO_BEEN_T3_M4", 1);
		DelayCommand(0.2, sub2());
		object oC_medbaypc = GetObjectByTag("MEDBAY_PC", 0);
		if ((!GetIsObjectValid(oC_medbaypc))) {
			object oInvisibleLocationMarker = GetObjectByTag("InvisibleLocationMarker", 0);
			location location1 = GetLocation(oInvisibleLocationMarker);
			oC_medbaypc = CreateObject(1, "c_medbaypc", location1, 0);
			int int9 = GetAppearanceType(GetEnteringObject());
			effect effect1 = EffectDisguise(int9);
			ApplyEffectToObject(2, effect1, oC_medbaypc, 0.0);
			AssignCommand(oC_medbaypc, ActionPlayAnimation(30, 1.0, (-1.0)));
		}
	}
	SetGlobalNumber("GBL_MAIN_SITH_LORD", 0);
	if ((GetGlobalNumber("001EBO_Movie") == 0)) {
		SetGlobalNumber("001EBO_Movie", 1);
		PlayMovie("permov01", 0);
		SetGlobalFadeOut(0.0, 0.0, 0.0, 0.0, 0.0);
		SetFadeUntilScript();
		AssignCommand(GetObjectByTag("Prologue", 0), ActionStartConversation(OBJECT_SELF, "intro", 0, 0, 0, "", "", "", "", "", "", 0, 0xFFFFFFFF, 0xFFFFFFFF, 0));
	}
}
}

 

I could be wrong, but this is my understanding: What the function does is if the GetGender(GetFirstPC()) returns as 0, then the boolean is set to TRUE, which is what the game checks for if a certain action requires the PC to be a male.

 

Now comes the problem: I put the same function in a script that is fired the same way - using the .ARE OnEnter field.

 

void main(){
 if (GetLoadFromSaveGame()) {
   return;
 }
[color="Cyan"]  if ((0 == GetGender(GetFirstPC()))) {
   SetGlobalBoolean("000_PLAYER_GENDER", 1);
 }[/color]
 if ((GetLevelByClass(CLASS_TYPE_JEDISENTINEL, GetFirstPC()) == 1)) {
   SetGlobalNumber("000_PLAYER_CLASS", 1);
 }
 if ((GetLevelByClass(CLASS_TYPE_JEDICONSULAR, GetFirstPC()) == 1)) {
   SetGlobalNumber("000_PLAYER_CLASS", 2);
 }
 PlayMovie("hot01");

}

 

The other functions work, but the Gender one doesn't. I checked the GLOBALVARS.res save file in KotOR Tool, but the Boolean is set to FALSE, or female.

 

BTW, this script is incomplete. I plan on adding two equip functions, a warp to waypoint, and start conversation, all of which is on hold until preparations can be made for the appearance.2da, as well as the UTCs.

Link to comment
Share on other sites

I know there's a no-double-post rule, but honestly, who would come back to read a re-edited post?

 

OK, so new script, new problem. In the "new game script", a.k.a. a_bet3m4, there's a function that sets the Player's gender as a Global Boolean, 000_PLAYER_GENDER. It, in regards to the script, is as follows:

 

*it's in cyan, a little over halfway down*

// Prototypes
void sub3(object objectParam1, int intParam2);
void sub2();
void sub1();

void sub3(object objectParam1, int intParam2) {
object oRWeapItem = GetItemInSlot(4, objectParam1);
AssignCommand(objectParam1, ActionUnequipItem(oRWeapItem, 1));
if (intParam2) {
	DestroyObject(oRWeapItem, 0.0, 1, 0.0, 1);
}
}

void sub2() {
AddAvailableNPCByTemplate(8, "p_t3m4");
SwitchPlayerCharacter(8);
sub3(GetObjectByTag("t3m4", 0), 1);
SetMinOneHP(GetObjectByTag("t3m4", 0), 1);
AssignCommand(GetObjectByTag("debris", 0), ApplyEffectToObject(0, EffectDamage(25, 8, 0), GetObjectByTag("t3m4", 0), 0.0));
DisableHealthRegen(1);
ApplyEffectToObject(2, EffectVisualEffect(2067, 0), GetObjectByTag("t3m4", 0), 0.0);
}

void sub1() {
if ((GetGlobalNumber("001EBO_Rumble") == 0)) {
	DelayCommand(IntToFloat((Random(10) + 10)), sub1());
	AurPostString("Rumbling", 5, 5, 5.0);
	PlaySound("MetalStrain");
	ApplyEffectToObject(1, EffectVisualEffect(6002, 0), GetFirstPC(), IntToFloat((Random(8) + 1)));
}
}

void main() {
if (GetLoadFromSaveGame()) {
	return;
}
if (GetIsPC(GetEnteringObject())) {
	if ((!GetLocalBoolean(OBJECT_SELF, 30))) {
		SetLocalBoolean(OBJECT_SELF, 30, 1);
		sub1();
		RevealMap([0.0,0.0,0.0], 0xFFFFFFFF);
	}
	if (GetGlobalNumber("002EBO_Door_Override")) {
		object oStar_dorm = GetObjectByTag("star_dorm", 0);
		AssignCommand(oStar_dorm, ActionOpenDoor(oStar_dorm));
	}
	int nGlobal = GetGlobalNumber("001EBO_BEEN_T3_M4");
	if ((!nGlobal)) {
		[color="Cyan"]if ((0 == GetGender(GetFirstPC()))) {
			SetGlobalBoolean("000_PLAYER_GENDER", 1);
		}[/color]
		SetGlobalNumber("001EBO_BEEN_T3_M4", 1);
		DelayCommand(0.2, sub2());
		object oC_medbaypc = GetObjectByTag("MEDBAY_PC", 0);
		if ((!GetIsObjectValid(oC_medbaypc))) {
			object oInvisibleLocationMarker = GetObjectByTag("InvisibleLocationMarker", 0);
			location location1 = GetLocation(oInvisibleLocationMarker);
			oC_medbaypc = CreateObject(1, "c_medbaypc", location1, 0);
			int int9 = GetAppearanceType(GetEnteringObject());
			effect effect1 = EffectDisguise(int9);
			ApplyEffectToObject(2, effect1, oC_medbaypc, 0.0);
			AssignCommand(oC_medbaypc, ActionPlayAnimation(30, 1.0, (-1.0)));
		}
	}
	SetGlobalNumber("GBL_MAIN_SITH_LORD", 0);
	if ((GetGlobalNumber("001EBO_Movie") == 0)) {
		SetGlobalNumber("001EBO_Movie", 1);
		PlayMovie("permov01", 0);
		SetGlobalFadeOut(0.0, 0.0, 0.0, 0.0, 0.0);
		SetFadeUntilScript();
		AssignCommand(GetObjectByTag("Prologue", 0), ActionStartConversation(OBJECT_SELF, "intro", 0, 0, 0, "", "", "", "", "", "", 0, 0xFFFFFFFF, 0xFFFFFFFF, 0));
	}
}
}

 

I could be wrong, but this is my understanding: What the function does is if the GetGender(GetFirstPC()) returns as 0, then the boolean is set to TRUE, which is what the game checks for if a certain action requires the PC to be a male.

 

Now comes the problem: I put the same function in a script that is fired the same way - using the .ARE OnEnter field.

 

void main(){
 if (GetLoadFromSaveGame()) {
   return;
 }
[color="Cyan"]  if ((0 == GetGender(GetFirstPC()))) {
   SetGlobalBoolean("000_PLAYER_GENDER", 1);
 }[/color]
 if ((GetLevelByClass(CLASS_TYPE_JEDISENTINEL, GetFirstPC()) == 1)) {
   SetGlobalNumber("000_PLAYER_CLASS", 1);
 }
 if ((GetLevelByClass(CLASS_TYPE_JEDICONSULAR, GetFirstPC()) == 1)) {
   SetGlobalNumber("000_PLAYER_CLASS", 2);
 }
 PlayMovie("hot01");

}

 

The other functions work, but the Gender one doesn't. I checked the GLOBALVARS.res save file in KotOR Tool, but the Boolean is set to FALSE, or female.

 

BTW, this script is incomplete. I plan on adding two equip functions, a warp to waypoint, and start conversation, all of which is on hold until preparations can be made for the appearance.2da, as well as the UTCs.

 

Seeing as it is the OnEnter script, the players aren't technically loaded up yet.

 

Assuming the Player's character is the only one in the party, you can do this:

 

void main(){
 if (GetLoadFromSaveGame()) {
   return;
 }
 if(GetIsPC(GetEnteringObject()))
 {
     object oPC = GetEnteringObject();
     if ((0 == GetGender(oPC))) {
       SetGlobalBoolean("000_PLAYER_GENDER", 1);
     }
     if ((GetLevelByClass(CLASS_TYPE_JEDISENTINEL, oPC) == 1)) {
       SetGlobalNumber("000_PLAYER_CLASS", 1);
     }
     if ((GetLevelByClass(CLASS_TYPE_JEDICONSULAR, oPC) == 1)) {
       SetGlobalNumber("000_PLAYER_CLASS", 2);
     }
[color="Red"]      if ((GetLevelByClass(CLASS_TYPE_JEDIGUARDIAN, oPC) == 1)) {
       SetGlobalNumber("000_PLAYER_CLASS", 3);
     }[/color]
 }
 PlayMovie("hot01");

}

 

However, unless it was designed that way, you forgot a check for Jedi Guardian, so I added it in there.

Link to comment
Share on other sites

That didn't fix it. The GLOBALVARS still says FALSE. My character is definitely a guy, but the game is telling me it's a girl.

 

And I decided I was going to leave the Guardian at a value of 0. Kudos to you, sir, for catching on.

 

In that case, you might try putting the 0 on the right side of the == sign.

 

Also, trying adding this just above it:

 

SendMessageToPC(GetEnteringObject(), "Gender is: " + IntToString(GetGender(GetEnteringObject)));

Link to comment
Share on other sites

It compiled correctly that time. And the message showed up in feedback screen: Gender is: 0.

 

Tried it again with a female: Gender is: 1

 

Opened Up GLOBALVARS: Still not making a difference.

 

EDIT: Okay, so this is very strange, but on a hunch I decided to check out the Globals according to KotOR Tool and match them up against the Globals that KSE shows me. As fortune would have it, the GlobalVars file still says that the Boolean is inactive, but KSE says it is active.

 

Show spoiler
(hidden content - requires Javascript to show)
LmXD3l.jpg

 

I have yet to try anything out with this information. But now I have another question: Wouldn't it be easier just to tell the game to set the value to "TRUE" rather than "1"? Or are they the same?

 

Reason I ask is because I will be using the game's global "Gender Check" scripts at certain points. Those scripts look for "TRUE/FALSE" values, not the numeric "0/1".

 

Again, sorry if I sound like a n00b. I am one.

Link to comment
Share on other sites

Guess what! New post + new script = new problem. Need I say more?

 

Anyway, I was kind of following this tutorial, but rather than destroying the NPC, I wanted the NPC to jump to another waypoint when it reaches the first.

 

*SYNTAX ERROR in ORANGE

void main(){
 object oNPC = GetObjectByTag("Imia");
 object oWaypoint1 = GetWaypointByTag("wp_imiaout");
 object oWaypoint2 = GetWaypointByTag("wp_imia");
 int bRun = FALSE
 [color="DarkOrange"]ActionDoCommand(SetCommandable(TRUE, oNPC));[/color]
 AssignCommand(oNPC, ActionForceMoveToObject(oWaypoint1, bRun));
 AssignCommand(oNPC, ActionDoCommand(JumpToObject(oWayPoint2)));
 ActionResumeConversation();
}

 

Problem is, if I take the command away, then the next line down gets a SYNTAX Error. I don't know what's going on.

Link to comment
Share on other sites

Guess what! New post + new script = new problem. Need I say more?

 

Anyway, I was kind of following this tutorial, but rather than destroying the NPC, I wanted the NPC to jump to another waypoint when it reaches the first.

 

*SYNTAX ERROR in ORANGE

void main(){
 object oNPC = GetObjectByTag("Imia");
 object oWaypoint1 = GetWaypointByTag("wp_imiaout");
 object oWaypoint2 = GetWaypointByTag("wp_imia");
 int bRun = FALSE
 [color="DarkOrange"]ActionDoCommand(SetCommandable(TRUE, oNPC));[/color]
 AssignCommand(oNPC, ActionForceMoveToObject(oWaypoint1, bRun));
 AssignCommand(oNPC, ActionDoCommand(JumpToObject(oWayPoint2)));
 ActionResumeConversation();
}

 

Problem is, if I take the command away, then the next line down gets a SYNTAX Error. I don't know what's going on.

 

int bRun = FALSE needs a ; at the end. And SetCommandable doesn't need the ActionDoCommand at all, so that line should read "SetCommandable(TRUE, oNPC);

Link to comment
Share on other sites

Alright, thanks VP, FS. And don't go anywhere: I'll very likely have more queries for you. :D

 

EDIT:

 

Yep. Here we go again.

 

void main(){
 object oNPC = GetObjectByTag("Imia");
 object oWaypoint1 = GetWaypointByTag("wp_imiaout");
 object oWaypoint2 = GetWaypointByTag("wp_imia");
 int bRun = FALSE;
 SetCommandable(TRUE, oNPC);
 AssignCommand(oNPC, ActionForceMoveToObject(oWaypoint1, bRun));
 [color="DarkOrange"]AssignCommand(oNPC, ActionDoCommand(JumpToObject(oWayPoint2)));[/color]
 ActionResumeConversation();
}

 

It tells me there's something wrong with every little tidbit of the highlighted line except the oNPC.

 

Also, any tips on recompiling the k_align_movie.nss so that it doesn't fire?

Link to comment
Share on other sites

Just so you know, Fair Strides is on modding hiatus for one month.

 

... Okay.

 

On another note, due to all my questions regarding scripts, including the stated unanswered ones, and may more to come, I am asking a moderator to rename this thread to something more appropriate (like 'DarthTyren's Endless Scripting Problems/Questions'). It will now be a more permanent place for me to voice my problems and questions regarding scripting.

Link to comment
Share on other sites

Alright, thanks VP, FS. And don't go anywhere: I'll very likely have more queries for you. :D

 

EDIT:

 

Yep. Here we go again.

 

void main(){
 object oNPC = GetObjectByTag("Imia");
 object oWaypoint1 = GetWaypointByTag("wp_imiaout");
 object oWaypoint2 = GetWaypointByTag("wp_imia");
 int bRun = FALSE;
 SetCommandable(TRUE, oNPC);
 AssignCommand(oNPC, ActionForceMoveToObject(oWaypoint1, bRun));
 [color="DarkOrange"]AssignCommand(oNPC, ActionDoCommand(JumpToObject(oWayPoint2)));[/color]
 ActionResumeConversation();
}

 

It tells me there's something wrong with every little tidbit of the highlighted line except the oNPC.

 

Also, any tips on recompiling the k_align_movie.nss so that it doesn't fire?

 

What does the compiler say when you try to compile?

 

recompiling k_align_movie.nss... not a clue.. I feel like we should have some sort of repo to check these things. I hate having to check the game source for the scripts.

Link to comment
Share on other sites

Show spoiler
(hidden content - requires Javascript to show)
JIN1k1.jpg


You know, sometimes I don't like case-sensitivity. oWaypoint2 ≠ oWayPoint2 :p

After fixing that, it compiled correctly.

OK, next on my list: Is there a way to force the Player to level up? Starting out as a Jedi doesn't make much sense if there are no Force Powers, or points.
Link to comment
Share on other sites

The Endar Spire will not allow you to leave the bridge without leveling. Look there for a source script.

 

Actually, I'm looking for something more like leveling up just after you get your Jedi class. The only problem is that it's compiled only. And it's a KotOR script, not TSL, so I can't "decompile" it in DeNCS.

Link to comment
Share on other sites

Do you need to? Are you perhaps just not looking in the right place?

 

I need to get the tools installed, but many of the source scripts for K1 are actually stored in the modules, or somewhere, IIRC.

 

And then, there is DeNCS for the scripts that do not have source. It won't decompile everything, but it does handle most of the scripts from the game.

 

I found a Decompilation Repository for TSL, but not for K1 or I would link it. You need to identify your module with whereami, and then you can use KTool to look through the module for the script in question. It is probably attached to Master Zhar's dialog tree, but may be in a few other spots.

Link to comment
Share on other sites

Do you need to? Are you perhaps just not looking in the right place?

 

I need to get the tools installed, but many of the source scripts for K1 are actually stored in the modules, or somewhere, IIRC.

 

And then, there is DeNCS for the scripts that do not have source. It won't decompile everything, but it does handle most of the scripts from the game.

 

I found a Decompilation Repository for TSL, but not for K1 or I would link it. You need to identify your module with whereami, and then you can use KTool to look through the module for the script in question. It is probably attached to Master Zhar's dialog tree, but may be in a few other spots.

 

Sadly, that method doesn't work for what Darth Tyren is asking.

 

When you add a new class, it automatically levels you up.

 

However, the level-up thing is both games follows a simple formula.

 

To get to the next level, you need to acquire your level x 1000 exp.

 

To get to level 2, you need 1 x 1000 exp. To get to level two, you need 2 x 1000 exp = 2000 exp.

 

The game keeps a running total of your exp, and for each level, the amount required is that level x 1000 to get the next level.

 

For both games, there are two functions you need: GetXP and GiveXPToCreature.

 

To give enough exp to level up, you could use this:

 

void main()
{
   SetPartyLeader(-1); // This is only required if this script is being run in a party. It just makes sure that we're working with the player character...

   object oPC = GetFirstPC();
   int iLevel = GetLevelByPosition(1, oPC) + GetLevelByPosition(2, oPC) + GetLevelByPosition(3, oPC);

   int iCount;
   int iXP = 0;

   for(iCount = 1; iCount < iLevel; iCount++)
   {
       iXP += 1000 * iCount;
   }

   int iXP_CURRENT = GetXP(oPC);
   int iXP_LEVEL   = iLevel * 1000;
   int iXP_HAVE    = iXP_CURRENT - iXP;
   int iXP_NEEDED  = iXP_LEVEL - iXP_HAVE;

   GiveXPToCreature(oPC, iXP_NEEDED);
//    I've commented the following line out. If you're running this script at the very end of a conversation (on a blue blank node in DLG Editor), then you can un-comment it. Otherwise, leave it commented to avoid breaking the GUI...
//    ShowLevelUpGUI();
}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...