36 lines
1.3 KiB
Plaintext
36 lines
1.3 KiB
Plaintext
const int ITEM_TYPE_WEAPON=1;
|
|
const int ITEM_TYPE_ARMOR=2;
|
|
|
|
void fnMakeMasterwork(object oPC, object oItem, int nType, int nSlot=0)
|
|
{
|
|
object oNew;
|
|
string sOldTag=GetTag(oItem);
|
|
location lWhereMI;
|
|
|
|
if(GetStringLength(sOldTag)>25)sOldTag=GetStringLeft(sOldTag,25);
|
|
if(nSlot!=0)
|
|
{
|
|
if(GetItemInSlot(nSlot,oPC)==oItem)
|
|
{
|
|
SendMessageToPC(oPC,"Item was equipped");
|
|
AssignCommand(oPC,ActionUnequipItem(oItem));
|
|
}
|
|
}
|
|
SendMessageToPC(oPC,"MW tag: "+"rts_mw_"+sOldTag);
|
|
//SendMessageToPC(oPC,"MW resref: "+GetResRef(oItem));
|
|
lWhereMI=GetLocation(oItem);
|
|
SendMessageToPC(oPC,"Location in area: "+GetName(GetAreaFromLocation(lWhereMI)));
|
|
oNew=CopyObject(oItem,GetLocation(oPC),oPC,"rts_mw_"+sOldTag);
|
|
if(oNew==OBJECT_INVALID)SendMessageToPC(oPC,"MW item creation failed");
|
|
if(nType==ITEM_TYPE_WEAPON) AddItemProperty(DURATION_TYPE_PERMANENT,ItemPropertyAttackBonus(1),oNew);
|
|
else if(nType==ITEM_TYPE_ARMOR) AddItemProperty(DURATION_TYPE_PERMANENT,ItemPropertyWeightReduction(IP_CONST_REDUCEDWEIGHT_10_PERCENT),oNew);
|
|
SetPlotFlag(oNew,TRUE);
|
|
SendMessageToPC(oPC,"Destroying: "+GetTag(oItem));
|
|
DestroyObject(oItem);
|
|
if(nSlot!=0)
|
|
{
|
|
SendMessageToPC(oPC,"Equipping: "+GetTag(oNew));
|
|
AssignCommand(oPC,ActionEquipItem(oNew,nSlot));
|
|
}
|
|
}
|