Battledale_PRC8/_module/nss/gc_add_ench_bon.nss

63 lines
1.6 KiB
Plaintext
Raw Normal View History

//Script Name: gc_add_ench_bon
//////////////////////////////////////////
//Created By: Genisys (Guile)
//Created On: 8/30/08
/////////////////////////////////////////
/*
This script goes in the ActionTaken
Event of a Conversation line, it will
add an item property the user selected
to the item, if it's actually in the
slot they chose.
*/
////////////////////////////////////////
#include "x2_inc_itemprop"
//Main Script
void main()
{
object oPC = GetPCSpeaker();
int nSlot = GetLocalInt(oPC, "CRAFT_SLOT");
object oCraft = GetItemInSlot(nSlot ,oPC);
//Let's make sure the items is actually on them!
if (!GetIsObjectValid(oCraft))
{
FloatingTextStringOnCreature("Your not wearing the item!!", oPC, FALSE);
SetLocalInt(oPC, "CRAFT_FAILED", 1);
return;
}
int nCost = GetLocalInt(oPC, "CRAFT_PAYMENT");
effect eEffect;
if(GetGold(oPC)<nCost)
{
FloatingTextStringOnCreature("You do not have enough gold!", oPC, FALSE);
AssignCommand(oPC, ClearAllActions()); //End the conversation!
return;
}
else
{
//Take the cost to craft..
TakeGoldFromCreature(nCost, oPC, TRUE);
eEffect = EffectVisualEffect(VFX_IMP_HOLY_AID);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC, 0.0f);
FloatingTextStringOnCreature("Your item has been crafted.", oPC, FALSE);
}
int nAmount = GetLocalInt(oPC, "CRAFT_SPELL_BONUS");
//What we are adding is AC
itemproperty ipAddAC=ItemPropertyEnhancementBonus(nAmount);
//Remove the Existing FIRST!
IPRemoveMatchingItemProperties(oCraft, ITEM_PROPERTY_ENHANCEMENT_BONUS, DURATION_TYPE_PERMANENT, -1);
//Finally add the Property
IPSafeAddItemProperty(oCraft, ipAddAC, 0.0f, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING, TRUE, TRUE);
}