UW2_PRC8/_module/nss/ac_itemseller.nss
Jaysyn904 5197ad9a4d Initial upload
Initial upload
2023-09-25 20:24:01 -04:00

64 lines
1.6 KiB
Plaintext

//Author Unknown..
//Edited By Genisys (guile) - 4/19/09
#include "x2_inc_switches"
///////////////////////////////////////////////////////////////////////
//PROTOTYPE DEFINED
//This returns the Massive Critical Damage to be applied to the weapon
int GetIsAmmo(int nType)
{
int n;
n = FALSE;
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)
{ n = TRUE; }
return n;
}
//Main Script
void main()
{
// Check if we have the correct event firing the script
if (GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;
//Define Variables
object oItem=GetItemActivated();
object oActivator=GetItemActivator();
object oPlayer = GetItemActivator();
object target = GetItemActivatedTarget();
string tag = GetTag(oItem);
//You main script function goes under this line.
{
object oPC = GetItemActivator();
object oTarget = GetItemActivatedTarget();
if(GetObjectType(oTarget) != OBJECT_TYPE_ITEM) return;
if(!GetIsObjectValid(oTarget)) return;
if(GetPlotFlag(oTarget) == TRUE) return;
int iValue = GetGoldPieceValue(oTarget);
int nType = GetBaseItemType(oTarget);
int iAssess = iValue/20;
if(iAssess>=400000)
{ iAssess = 400000; }
if(GetIsAmmo(nType))
{
FloatingTextStringOnCreature("Ammunition cannot be sold!", oPC, FALSE);
return;
}
GiveGoldToCreature(oPC, iAssess);
DestroyObject(oTarget);
}
}