62 lines
2.4 KiB
Plaintext
62 lines
2.4 KiB
Plaintext
#include "x2_inc_switches"
|
|
#include "colors_inc"
|
|
#include "inc_system_const"
|
|
#include "x2_inc_itemprop"
|
|
|
|
void main()
|
|
{
|
|
if(GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_EQUIP) return;
|
|
|
|
object oPC = GetPCItemLastEquippedBy();
|
|
object oItem = GetPCItemLastEquipped();
|
|
int iBaseType = GetBaseItemType(oItem);
|
|
|
|
|
|
// If this item was clothes then make sure the item has the OnHitCastSpell: Unique Power property
|
|
// as this spell is used to handle durability for armor.
|
|
if(iBaseType == BASE_ITEM_ARMOR)
|
|
{
|
|
// Check for item property
|
|
itemproperty ipCastSpell = GetFirstItemProperty(oItem);
|
|
while(GetIsItemPropertyValid(ipCastSpell))
|
|
{
|
|
if(GetItemPropertyType(ipCastSpell) == ITEM_PROPERTY_ONHITCASTSPELL)
|
|
{
|
|
// OnHit Cast Spell: Unique Power
|
|
if(GetItemPropertySubType(ipCastSpell) == IP_CONST_ONHIT_CASTSPELL_ONHIT_UNIQUEPOWER)
|
|
{
|
|
//SendMessageToPC(oPC, "OnHit: Unique Power found. Bailing out of armor_mod_equip"); // DEBUG
|
|
return;
|
|
}
|
|
}
|
|
ipCastSpell = GetNextItemProperty(oItem);
|
|
}
|
|
|
|
// By this point we know the item equipped was armor but it doesn't have the OnHit Cast Spell: Unique Power
|
|
// item property. We need to give the item property to the armor.
|
|
IPSafeAddItemProperty(oItem, ItemPropertyOnHitCastSpell(IP_CONST_ONHIT_CASTSPELL_ONHIT_UNIQUEPOWER, 40));
|
|
//SendMessageToPC(oPC, "Adding item property OnHit: Unique Power."); // DEBUG
|
|
}
|
|
|
|
// The rest only fires for belts, which are used as armor in REO
|
|
if(iBaseType != BASE_ITEM_BELT) return;
|
|
|
|
// Can't equip armor during combat
|
|
if(GetIsInCombat(oPC) && !GetLocalInt(oItem, ARMOR_SKIP_MODULE_ON_EQUIP))
|
|
{
|
|
SendMessageToPC(oPC, ColorTokenRed() + "You cannot equip armor during combat." + ColorTokenEnd());
|
|
AssignCommand(oPC, ClearAllActions());
|
|
AssignCommand(oPC, ActionUnequipItem(oItem));
|
|
return;
|
|
}
|
|
|
|
// Can't equip armor without clothes on
|
|
if(!GetIsObjectValid(GetItemInSlot(INVENTORY_SLOT_CHEST, oPC)))
|
|
{
|
|
SendMessageToPC(oPC, ColorTokenRed() + "You must have clothes equipped before armor can be equipped." + ColorTokenEnd());
|
|
AssignCommand(oPC, ClearAllActions());
|
|
AssignCommand(oPC, ActionUnequipItem(oItem));
|
|
return;
|
|
}
|
|
}
|