Thank you,
Laz
Modifié par Lazarus Magni, 01 septembre 2011 - 11:59 .
Modifié par Lazarus Magni, 01 septembre 2011 - 11:59 .
Modifié par _Guile, 02 septembre 2011 - 02:15 .
Modifié par Lazarus Magni, 02 septembre 2011 - 01:56 .
Modifié par _Guile, 02 septembre 2011 - 02:32 .
Modifié par _Guile, 02 septembre 2011 - 02:12 .
Modifié par Lazarus Magni, 02 septembre 2011 - 02:21 .
//Note this is really not needed because we are working from a conversation!
//The starting conditional script will prevent the PC from getting this far!
/*
if(GetGold(oPC)< nGoldRequired)
{
AssignCommand(oMerchant, ActionSpeakString("You don't have 100,000 gold."));
return;
}
//If they don't have enough (2 or more)...
if(nShards < nRequired)
{
AssignCommand(oMerchant, ActionSpeakString("You need at least 2 shards."));
return;
}
*/
Modifié par _Guile, 05 septembre 2011 - 03:21 .
Lazarus Magni wrote...
Thank you Guile, that helps alot, and was very clear. I will try these ASAP.
Lightfoot8 wrote...
Really it is needed. It stops the PC's from cheating the conversation. ie. starting the conversation, having the line displayed, Dumping there gold and shards on the ground and then selecting the conversation line to get the new shard for nothing.
Modifié par _Guile, 02 septembre 2011 - 03:26 .
Modifié par Lazarus Magni, 02 septembre 2011 - 05:37 .
Modifié par Lazarus Magni, 02 septembre 2011 - 05:55 .
Modifié par Lazarus Magni, 02 septembre 2011 - 07:20 .
Modifié par _Guile, 03 septembre 2011 - 01:25 .
//-----------------------------------------------
// 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) nMaxStack = StringToInt(Get2DAString("baseitems","Stacking",GetBaseItemType(oItem))); nGivenTotal-= nMaxStack;
// if nGiveTotal is postive we still need to give some items.
}while (nGivenTotal>0);
//End main script
}
//-------------------------------------------------------------------------------------------------
// 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 = 2);
////////////////////////////////////////////////////////////////////////////
//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 = 2)
{
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 Lightfoot8, 03 septembre 2011 - 11:24 .
_Guile wrote...
I have a question for you Lightfoot8...
Is declaring the Prototypes before defining them in an Include really necessary or does it provided a benefit to do so?
(Just curious, as this is a more advanced subject I never really asked about.)