PoA_PRC8/_module/nss/ac_itemseller.nss
Jaysyn904 8d97886c3f Changed folder name.
Changed folder name.
2022-10-07 21:08:37 -04:00

134 lines
3.6 KiB
Plaintext

//This is the default header for most items converted to the new
//tagbased system.
//Remember to create 2 scripts, one using the template, and name this
//script ac_"tagnameofitemgoeshere" (without the "")
#include "x2_inc_switches"
object oTarget;
object oItem;
int GetIdentifiedGoldPieceValue(object oItem)
{
// Initial flag
int bIdentified = GetIdentified(oItem);
// If not already, set to identfied
if (!bIdentified) SetIdentified(oItem, TRUE);
// Get the GP value
int nGP=GetGoldPieceValue(oItem);
//Cap the max gold for an item at 300,000 gold.(40% the value)
if(nGP >750000)
{
nGP = 750000;
return nGP;}
//Let's make sure the item is worth something!
else if(nGP<100){
nGP = 100;
return nGP;}
//It must be worth more than 10 gold, so let's return it's true value
else
{ return nGP; }
}
void main()
{
// Check if we have the correct event firing the script
//if (GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;
object oPC = GetItemActivator();
object oTarget = GetItemActivatedTarget();
if(GetObjectType(oTarget) != OBJECT_TYPE_ITEM) return;
if(!GetIsObjectValid(oTarget)) return;
//ID The type of item it is..!
int nType;
nType = GetBaseItemType(oItem);
if(nType==BASE_ITEM_ARROW ||nType==BASE_ITEM_BOLT ||
nType==BASE_ITEM_BULLET || nType==BASE_ITEM_DART ||
nType==BASE_ITEM_SHURIKEN || nType==BASE_ITEM_THROWINGAXE)
{
FloatingTextStringOnCreature("The item seller will not buy ammunition, sorry.", oPC, FALSE);
return;
}
int nGP;
nGP = GetIdentifiedGoldPieceValue(oTarget);
//Let's divide that amount by 100
int oGP = nGP/100; //Let's break it down into 100 segments
int pGP = oGP * 40; // 40% of the original value
int nGold = pGP - 38; //All items should return at least 2 GP
//We dont' buy ammo!
if(nType==BASE_ITEM_ARROW ||nType==BASE_ITEM_BOLT ||
nType==BASE_ITEM_BULLET || nType==BASE_ITEM_DART ||
nType==BASE_ITEM_SHURIKEN || nType==BASE_ITEM_THROWINGAXE)
{
if(GetPlotFlag(oItem)==FALSE)
{
//Cap Gold at 5k
if(GetGoldPieceValue(oItem)>=5001)
{GiveGoldToCreature(oPC, 5000);}
else{GiveGoldToCreature(oPC, GetGoldPieceValue(oItem));}
DestroyObject(oTarget,0.0f);
return;
}
else
{
FloatingTextStringOnCreature("You cannot sell plot or undroppable items!", oPC, FALSE);
return;
}
}
if(GetResRef(oTarget)=="nw_it_contain006")
{
GiveGoldToCreature(oPC, 500);
DestroyObject(oTarget,0.0f);
return;
}
if(GetTag(oTarget)=="artifact")
{
GiveGoldToCreature(oPC, 300000);
SetPlotFlag(oTarget, FALSE);
DestroyObject(oTarget,0.0f);
return;
}
if(GetTag(oTarget)=="legend")
{
GiveGoldToCreature(oPC, 200000);
SetPlotFlag(oTarget, FALSE);
DestroyObject(oTarget,0.0f);
return;
}
//If the item is a plot item tell them they can't sell it!
if(GetPlotFlag(oTarget) == TRUE)
{
FloatingTextStringOnCreature("You cannot sell plot items!", oPC, FALSE);
return; //(stop here!)
}
//Let's make sure the player gets 2 gold no matter what.
if(oGP >2)
{
GiveGoldToCreature(oPC, nGold);
DestroyObject(oTarget);
}
//Otherwise give 2 gp.
else
{
GiveGoldToCreature(oPC, 2);
DestroyObject(oTarget);
}
}