Its been along time since I have played NWN but I’m glad I’m back.
I apologize ahead of time my scripting knowledge is a bit rusty.On to the matter at hand, I am having trouble scripting something and would like some help.
This script is called from a conversation under the actions taken tab
I have the conversation set up like this.
Search the bookcaseYes.No.When someone clicks on yes I would like them to get an item in their inventory but only a 50% chance on getting the item. I hope that makes sense. Any help would be appreciated
bookcase help
Débuté par
Surek
, sept. 08 2012 12:19
#1
Posté 08 septembre 2012 - 12:19
#2
Posté 08 septembre 2012 - 01:49
if(Random(2)) CreateItemOnObject(<item ref>, GetPCSpeaker());
Kato
Kato
Modifié par Kato_Yang, 08 septembre 2012 - 01:49 .
#3
Posté 08 septembre 2012 - 01:55
[Edit: thats what I get for being long winded... Kato beat me to it]
The function you need is CreateItemOnObject
You should check out the lexicon for other functions as well:
http://palmergames.c...xicon_1_69.html
That function will go in a script you create which is executed by the "Yes" conversation option. And it will go in the "Main" of that script.
Since you also want a chance of this object showing up there are a number of ways to do this. The most straight forward is to wrap an if statement around the CreateItemOnObject function
Example (pseudo code)
void main()
{
object oPC = GetPCSpeaker();
if(d2() ==1)
{
string sItemResref = "enter_the_item_resref_here";
CreateItemOnObject(sItemResref, oPC);
}
else
{
// PC does not get any item
// perhaps a good place to provide a failure message as follows
FloatingTextStringOnCreature(GetName(oPC)+" finds nothing on the "+GetName(OBJECT_SELF)+".", oPC);
}
}
The function you need is CreateItemOnObject
You should check out the lexicon for other functions as well:
http://palmergames.c...xicon_1_69.html
That function will go in a script you create which is executed by the "Yes" conversation option. And it will go in the "Main" of that script.
Since you also want a chance of this object showing up there are a number of ways to do this. The most straight forward is to wrap an if statement around the CreateItemOnObject function
Example (pseudo code)
void main()
{
object oPC = GetPCSpeaker();
if(d2() ==1)
{
string sItemResref = "enter_the_item_resref_here";
CreateItemOnObject(sItemResref, oPC);
}
else
{
// PC does not get any item
// perhaps a good place to provide a failure message as follows
FloatingTextStringOnCreature(GetName(oPC)+" finds nothing on the "+GetName(OBJECT_SELF)+".", oPC);
}
}
Modifié par henesua, 08 septembre 2012 - 01:56 .
#4
Posté 08 septembre 2012 - 02:35
Just wanted to thank both of you it works great.
#5
Posté 09 septembre 2012 - 12:59
Make sure the conversation can only be done once, or the player will just keep doing it until they get the item, or they just keep getting the item over and over again.
You can prevent this by putting a local on the PC.
You can prevent this by putting a local on the PC.





Retour en haut







