Tutorial -- Script how to give the PC an item -1 reply

Please wait...

Gsccc

Your Kotor Modding Helper

50 XP

21st September 2004

0 Uploads

45 Posts

0 Threads

#1 13 years ago

Giving the PC an item via script This tutorial will show you how to, through a script give the pc an item. This is usefull for if you have your pc talking to someone and you want teh npc they are speaking with to give the pc a certain item. void main() { CreateItemOnObject("g_danceroutfit", GetFirstPC(), 1, 0); } As the script suggests, you are literally creating an item on an object, in this case the object is the pc. In the first set of quotes you put the ResRef of the item, it is important you do not put the name of the tag of the item. If you want to find what the tag of a certain item is use kotor tool or a gff editor and see under tag. Next you have the PC's basic tag, this is the tag you use if you want anything that includes the player. Next is the quantity of the item that you are placing, you can change this to whatever number you want. Once you are done with that compile it and you can put it in a dialog or a trigger.

NOTE: this differs from the way you give credits to the pc -Gsccc




Mando

Forum Hermit

50 XP

11th November 2006

0 Uploads

332 Posts

0 Threads

#2 11 years ago

Hmmmm... That script may work for kotor1 but there is an easier way to do it for kotor 2.

Code:

void main() { int nQuantity = 1; CreateItemOnObject("g_w_lghtsbr01", GetFirstPC(), nQuantity); }

In this script i want to get 1 item.

Code:

void main() { int nQuantity = 3; CreateItemOnObject("g_danceroutfit", GetFirstPC(), nQuantity); }

In this script i want to get 3 items.

To compile scripts go to the kotor tool text editor and make your script. use the text editor for your script then save it in the override folder as "myscriptname".nss. Then go to the scripts menu and say script is for kotor/2 (each games use different scripts. The one in this tutorial is for kotor2.) then press F5. you should get this message

Lookup path root set to C://program Files//LucasArts//SWKotOR2 Loaded nwscript.nss form C://program Files//LucasArts//SWKotOR2//Override Compiling: myscriptname.nss Total Execution time = X ms

If it says that then you have sucessfuly compiled your script! If you don't, then try not to get mad and check your scripts. one of the most common reasons may be one of you things is wrong.

Then on the dialouge editor (kotor tool or DLGEditor by Tk102, a very talanted scripter), go to the string of dialouge you want to add the script to.Go to the scripts menu. Under the script option there are 2 things

1)script that fires when spoken 2)script that needs to run

The script that fires when spoken is the bit you need type in the name of your script,without the .nss/.ncs extention. The Needed script is best left alone as many functions in game are required with these.

*NOTE* There are different functions of scripting for kotor1 and 2. This scripting tutorial covers kotor 2 scripts. Also as Gsccc said there is no way to get LS/DS, exp, gold or infuence through these scripts. You may change the resref to a custom item if you use the UTI file in game.

Have fun With scripting!

~Mandalorian16965




theman88

The Force is my ally

50 XP

4th June 2008

0 Uploads

245 Posts

0 Threads

#3 10 years ago

um I still dont under stand how that makes a certain NPC give you a item? you mean by killing them or when you talk to them?




Inyri Forge VIP Member

[Insert User Title Here]

55 XP

15th March 2005

0 Uploads

25,940 Posts

0 Threads

#4 10 years ago

You have to call the script somehow. Dialogue is the most common option, but you can also do it in a variety of other ways.