Jump to content

Home

Scripting Question


TriggerGod

Recommended Posts

I'm gonna make some new lightsabers for TSL, and I'm gonna do something that'll involve minor(?) scripting.

What I want is depending on what alignment you make Revan (DS or LS) you get a certain lightsaber at a certain point in the game. What would the script for that be?

Link to comment
Share on other sites

Hmmm.... You're going to want a script that checks the Global used... Then within it the give item script......

 

Man, I wish I could script worth a darn!

 

Yeah, that's how it would be done.

 

@OP - It depends whether or not you just want it to be put directly into the player's inventory or spawned into a container. Once you provide us with that we can help you with the script.

 

_EW_

Link to comment
Share on other sites

Assuming you have no intention of changing the character back from revan:

void main(){
   object oSelf = OBJECT_SELF;

   [color="DeepSkyBlue"]// As far as I am aware there is no different LS or DS models of revan since (s)he wears a mask.[/color]
   ChangeObjectAppearance(oSelf,  22); [color="DeepSkyBlue"]// Line 22 - Unique_Darth_Revan[/color]
   [color="DeepSkyBlue"]// You could do gender checks and use:
   //     372 - Revan Female (CUTSCENE)
   //     371 - Revan Male (CUTSCENE)
   // I am unsure on how limited the animations are on those though[/color]

   [color="DeepSkyBlue"]// Alignment check, assumes neutral is lightside.[/color]
   if ( GetAlignmentGoodEvil(oSelf) >= 50 )
       CreateItemOnObject("[color=yellow]lightside_saber_resref[/color]", oSelf);
   else
       CreateItemOnObject("[color=yellow]darkside_saber_resref[/color]", oSelf);
}

 

I'm guessing that this will be launched from a dialog node, in which case you might want to edit that dialog that has kreia blabing at you about how she is impressed and all.

 

If you intend to change the players appearence back later then, unless the game has a GlobalNumber for this, you might want to set a LocalNumber on the player for you to call later.

Link to comment
Share on other sites

so, correct me if I'm wrong, but this is what I think is my script:

void main(){
   object oSelf = OBJECT_SELF;

   ChangeObjectAppearance(oSelf,  22); // Line 22 - Unique_Darth_Revan
   //     372 - Revan Female (CUTSCENE)
   //     371 - Revan Male (CUTSCENE)

   // Alignment check, assumes neutral is lightside.
   if ( GetAlignmentGoodEvil(oSelf) >= 50 )
       CreateItemOnObject("lightside_revan_saber", oSelf);
   else
       CreateItemOnObject("darkside_revan_saber", oSelf);

I'm not sure on this, as I'm still a n00b to scripting.

Link to comment
Share on other sites

Sure thats your script.

Basically when executed it changes your characters appearence to Darth Revan (Line 22 in Appearance.2da) and if your darkside it gives you an item with the ResRef (filename) of darkside_revan_saber and if your lightside or neutral, lightside_revan_saber.

Link to comment
Share on other sites

Wait a second here, Glovemaster.

 

@Trigger - you never said you wanted to become Revan. Just that you wanted a saber based on Revan's alignment.

This is for K2, right? And it isn't for your alignment, it's for Revan's?

 

This script isn't right at all. The syntax is ok, but the effects are wrong.

 

_EW_

Link to comment
Share on other sites

OK, I've created the script. This is what I do now:

Save as .nss

Go to korriban, and fight, see if the script executes.

You skipped a couple of important steps. First you need to convert the *.NSS source script to the compiled *.NCS version, then you need to set up the script so that it is called by something. Scripts don't magically execute themselves... as saddening as that is. x.x
Link to comment
Share on other sites

*stares blankly like someone in Advance Algebra or Chemestry*

...

Down goes that mini-work between my other project...

 

I practically used that script... so I don't know the NSS

 

Ok, this post is not clear at all. What the heck are you trying to say by "I practically used that script... so I don't know the NSS"? That sentence makes no sense whatsoever.

 

My question is simple. What do you want the script to do? Be clear.

 

And Inyri is telling you that you have to compile the script and then attach it somewhere so it will execute.

 

We're not being overly complicated ;)

 

_EW_

Link to comment
Share on other sites

Ok, this post is not clear at all. What the heck are you trying to say by "I practically used that script... so I don't know the NSS"? That sentence makes no sense whatsoever.

I copied the above script GM gave..

My question is simple. What do you want the script to do? Be clear.
Give me a lightsaber depending on Revan's alignment after the battle (At the end of Kreia's dialog)

 

And Inyri is telling you that you have to compile the script and then attach it somewhere so it will execute.

 

We're not being overly complicated ;)

 

_EW_

Well, to me... I'm still new to scripting....

Link to comment
Share on other sites

Scripts don't magically execute themselves... as saddening as that is. x.x

QTF. :p

 

It seems I've misinterpretted what it is that you are trying to do exactly and after re-reading I still don't quite get it.

What I want is depending on what alignment you make Revan (DS or LS) you get a certain lightsaber at a certain point in the game.

What exactly do you mean by "what alignment you make Revan" when you have no influence over Revans alignment in TSL at that point? Do you mean at the start where attons arguing with you about Revan?

 

My brains must have just taken "Make revan" and "Recieve lightsaber". :p

Link to comment
Share on other sites

:lol:

Right :^: well heres the new script:

void main(){
   object oSelf = OBJECT_SELF;

   if ( GetGlobalNumber(52) == 0 ) [color=deepskyblue]// Line 52 - 101PER_Revan_End
   // Now this is difficult since I have no idea what number means what, but I ASSUME 0 is a lightside ending. Worth a try?[/color]
       CreateItemOnObject("lightside_revan_saber", oSelf);
   else
       CreateItemOnObject("darkside_revan_saber", oSelf);
}

Link to comment
Share on other sites

OK, after looking through the scripting tut section, I figured out what to do. This is my testscript.nss, which when I try to compile using KTool, has an error.

Script:

void main(){
   object oSelf = OBJECT_SELF;

   if ( GetGlobalNumber(52) == 0 ) // Line 52 - 101PER_Revan_End
          CreateItemOnObject("lightside_revan_saber", oSelf);
   else
       CreateItemOnObject("darkside_revan_saber", oSelf);
}

 

The error says something along the lines of "Error: Type Mismatch in parameter 1 in call to "GetGlobalNumber"

From the error, I think that the value after GetGlobalNumber(52) should be 1...

 

EDIT:

1) Sorry for the double post

2) I tried making the 0 a 1, and that didn't work :(

Link to comment
Share on other sites

OK, after looking through the scripting tut section, I figured out what to do. This is my testscript.nss, which when I try to compile using KTool, has an error.

Script:

void main(){
   object oSelf = OBJECT_SELF;

   if ( GetGlobalNumber(52) == 0 ) // Line 52 - 101PER_Revan_End
          CreateItemOnObject("lightside_revan_saber", oSelf);
   else
       CreateItemOnObject("darkside_revan_saber", oSelf);
}

 

The error says something along the lines of "Error: Type Mismatch in parameter 1 in call to "GetGlobalNumber"

From the error, I think that the value after GetGlobalNumber(52) should be 1...

 

EDIT:

1) Sorry for the double post

2) I tried making the 0 a 1, and that didn't work :(

 

Your script is very close, but you forgot the bracket after the "if" function.

 

Use this :):

void main(){
   object oSelf = OBJECT_SELF;
   int Revan=GetGlobalNumber("101PER_Revan_End");
   if (Revan == 0 )
   {
          CreateItemOnObject("lightside_revan_saber", oSelf);
   }
   else
       CreateItemOnObject("darkside_revan_saber", oSelf);
}

 

I probably used too many declarations of variables but yeah. :p

Link to comment
Share on other sites

You access global variables by their name tag, not the 2DA line index.

D'oh! I'm suddenly getting stupider :( I think I need some coffee.

 

but you forgot the bracket after the "if" function.

You don't actually need the {, } brackets if the result is only one action/command-thing.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...