41 lines
1.3 KiB
Plaintext
41 lines
1.3 KiB
Plaintext
#include "x2_inc_switches"
|
|
#include "colors_inc"
|
|
#include "inc_system_const"
|
|
|
|
void main()
|
|
{
|
|
if(GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_UNEQUIP) return;
|
|
|
|
object oPC = GetPCItemLastUnequippedBy();
|
|
object oItem = GetPCItemLastUnequipped();
|
|
int iBaseType = GetBaseItemType(oItem);
|
|
|
|
// Only fires for belts, which are used as armor in REO
|
|
if(iBaseType != BASE_ITEM_BELT && iBaseType != BASE_ITEM_ARMOR) return;
|
|
|
|
|
|
// Can't unequip armor during combat
|
|
if(GetIsInCombat(oPC) && iBaseType == BASE_ITEM_BELT)
|
|
{
|
|
SetLocalInt(oItem, ARMOR_SKIP_MODULE_ON_EQUIP, TRUE);
|
|
SendMessageToPC(oPC, ColorTokenRed() + "You cannot unequip armor during combat." + ColorTokenEnd());
|
|
AssignCommand(oPC, ClearAllActions());
|
|
AssignCommand(oPC, ActionEquipItem(oItem, INVENTORY_SLOT_CHEST));
|
|
DelayCommand(1.0, DeleteLocalInt(oItem, ARMOR_SKIP_MODULE_ON_EQUIP));
|
|
return;
|
|
}
|
|
|
|
// When clothes are unequipped, so is armor (belt)
|
|
if(iBaseType == BASE_ITEM_ARMOR)
|
|
{
|
|
object oBelt = GetItemInSlot(INVENTORY_SLOT_BELT, oPC);
|
|
|
|
// Make sure there's actually a belt to unequip
|
|
if(GetIsObjectValid(oBelt))
|
|
{
|
|
AssignCommand(oPC, ClearAllActions());
|
|
AssignCommand(oPC, ActionUnequipItem(oBelt));
|
|
}
|
|
}
|
|
}
|