A starting conditional is a script that goes in the paceholder (white box) of a line... in the TextAppearsWhen Tab, so if you click a line and look down to the right, you will see you are usually on the TextAppearsWhen Tab, in that white box, select edit, and paste script 1 there... save it under a name...
For the sake of saving you some time & frustrations, as you may need this script for other shards colors, etc... I made a more versatile version for you, which you could always use scripts 1 & 2 (Just save it under a new name FIRST, and then make alterations to the settings to configure it to a different item). Script 3 however would never change (the include)...
EDITED: Fixed as Lightfoot8 Prescribed below, thanks Lightfoot8
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Script 1 (This goes in the TextAppearWhen Tab for the line you wish to check to see if the PC has enough of the required items &/or Gold ) This line will NOT show if they are NOT qualified!
(This should be the NPC's line in red, as an option, and it should be above line #2 that the NPC speaks)
//----------------------------------------------------------------
//Script Name =
//Required Include (Don't remove)
#include "item_conv_inc"
int StartingConditional()
{
// ***SETTINGS***
//Set this to the # of the Item they must have
int nRequired = 2;
//Set this to 0 if they DO NOT require gold
int nGoldRequired = 100000; //Amount of gold they need
//Set the tagname of the item they must have to get the item given
string sItemTagName = "tagname";
/////////////////////////////////////////////////////////////////
//WARNING: Don't touch anything below!
/////////////////////////////////////////////////////////////////
object oPC = GetPCSpeaker();
// Custom Function that returns the # of a particular item
// (included stack counts) that the PC has on them
int nCount = GetIemCount(oPC, sItemTagName);
if (nCount >= nRequired && GetGold(oPC) >= nGoldRequired)
{ return TRUE; }
else
{ return FALSE; }
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Script 2: This goes on the line where the PC will select the option to actually trade in the required items &/or gold to get the item, it will actually end the conversation and they should recieve the item if they are indeed qualified, otherwise they will get a message instead!
//-----------------------------------------------
//-----------------------------------------------
// Script Name =
??
//Required Includes DONT TOUCH
#include "item_conv_inc"
void main()
{
// ***SETTINGS***
//Set this to the # of the Item they must have
int nRequired = 2;
//Set this to 0 if they DO NOT require gold
int nGoldRequired = 100000; //Amount of gold they need
//Set the tagname of the item they must have to get the item given
string sItemTagName = "tagname";
string sName = "Name of Item Goes Here";
//Set this to the resref of the item they will recieve (if qualified)
//this is NOT the tagname!
string sItemResRef = "resref";
//Set this to the # of the item you wish to give
//(If the item given is stackable it will be stacked!)
int nGivenTotal = 1; //Default = 1; (Give only one by default)
/////////////////////////////////////////////////////////////////
//WARNING: Don't Alter Anything below!!!
/////////////////////////////////////////////////////////////////
object oPC = GetPCSpeaker();
int nStackSize;
int nCount = GetIemCount(oPC, sItemTagName);
//This part will prevent exploits (like dropping gold to prevent losing it etc)
if(nCount < nRequired)
{
FloatingTextStringOnCreature("You must have " +
IntToString(nRequired) + sName +"!", oPC, FALSE);
return;
}
if(GetGold(oPC) < nGoldRequired)
{
FloatingTextStringOnCreature("You don't have " +
IntToString(nGoldRequired) + " gold on you!", oPC, FALSE);
return;
}
//Obviously we are continuing if they have enough shards..
//Take 2 of them from the PC
DestroyNumItems(oPC, sItemTagName, nRequired);
//take gold
TakeGoldFromCreature(nGoldRequired, oPC, TRUE);
//Give the PC X of the item to be given
object oItem;
int nMaxStack;
do
{
oItem = CreateItemOnObject(sItemResRef, oPC,nGivenTotal);
// if nMaxStack is 0 we need to get is value.
if(!nMaxStack) Get2DAString("baseitems","Stacking",GetBaseItemType(oItem));
nGivenTotal-= nMaxStack;
// if nGiveTotal is postive we still need to give some items.
}while (nGivenTotal>0);
//End main script
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Script 3: This script should just be pasted into the script editor, and saved... (DO NOT ALTER IT!)
This script is only used by Script 1 & 2, it's only for saving space in Script 1 & 2
//-------------------------------------------------------------------------------------------------
// Include Script Name = item_conv_inc (Save it Under THIS Name!)
// This is an include script, it's saved under the name (item_conv_inc)
// This script has 2 Custom Fucntions which...
// a) Return How many of a particular item the PC Has (GetItemCount)
//
Destroys X of a given item by tagname, (can reduce Item StackSize)
//////////////////////////////////////////////////////////////////////////////
//Declare All Prototypes
int GetIemCount(object oPC, string sTag);
void DestroyNumItems(object oTarget, string sTag, int nToDestroy);
////////////////////////////////////////////////////////////////////////////
//Prototypes Defined
//Define Prototype
int GetIemCount(object oPC, string sTag)
{
int i = 0;
string sIT;
int nStackSize;
object oItem = GetFirstItemInInventory(oPC);
//Continue till there are 0 left to destroy...
while (GetIsObjectValid(oItem))
{
sIT = GetTag(oItem);
if (sIT == sTag)
{
nStackSize = GetItemStackSize(oItem);
i += nStackSize;
}
oItem = GetNextItemInInventory(oPC);
}
//Tell the script how many "shards" they have (included all stacked count)
return i;
}
//Define Prototype
void DestroyNumItems(object oTarget, string sTag, int nToDestroy)
{
float fDelay;
int nStackSize;
int nAdj;
string sIT; // Item Tagname
object oItem = GetFirstItemInInventory(oTarget);
//Continue till there are 0 left to destroy...
while (GetIsObjectValid(oItem) && nToDestroy >= 1)
{
sIT = GetTag(oItem);
nStackSize = GetItemStackSize(oItem);
//If they have 2 Shards & This is indeed a Shard (item)
if (sIT == sTag) //Obviously they have at least 1 stack size
{
fDelay += 0.03;
if(nStackSize <= nToDestroy)
{
DestroyObject(oItem, fDelay);
nToDestroy -= nStackSize;
if(!nToDestroy) break;
}
else
{
SetItemStackSize(oItem,nStackSize - nToDestroy);
break;
}
}
oItem = GetNextItemInInventory(oTarget);
}
}
Modifié par _Guile, 05 septembre 2011 - 03:21 .