Gender Restrictions on items

Hi I have a module and loaded the CEP into it. I see I get an item property of Use Limitation Gender:*

I noted the * so does that mean that I will need to script around this property to get it to work?

I put it on an item and it didn’t seem to do anything as any character of any race or gender was able to equip the item. Some models I want to use don’t have a model for male or female so I need to be able to do that restriction. Is there something I am missing in CEP or do I need to code that myself?

Thanks,

You need to check the item property in the module scripts. I’ll dig out the code when I’m back at my desk.

afaik you need to code it yourself, custom item properties do nothing by default and needs to be scripted but I never found code for this in CEP, can’t really say I was looking very thoroughly though, I don’t see any benefit of this property. AFAIK this property was made because some equippable items doesn’t have models for female or rather there is model for each gender and they don’t fit the opposite one.

You’re correct

OK here’s the code.

For PCs, CEP has a built in function. In the module OnPlayerEquipItem, add

#include "zep_inc_main"

at the beginning and

ZEPGenderRestrict(oItem,oPC);

as the last line of the main() body of the script.

This forces an instant unequip with a message explaining why.

For companions, it’s not that easy, because no event fires when they equip an item. My solution is to prevent players from giving them the item in the first place, in the module OnAcquireItem event.

You will need zep_inc_main again. At the end of the main() section, add

     object oAcquirer   = GetModuleItemAcquiredBy();
     object oMaster     = GetMaster(oAcquirer);

    if (!GetIsPC(oAcquirer))
      if (GetIsObjectValid(oMaster))
        {
          int bInvalid = FALSE;

          if (GetItemHasItemProperty(oItem, ITEM_PROPERTY_USE_LIMITATION_GENDER))
            {
              itemproperty ipGenderProperty=GetFirstItemProperty(oItem);

              while ((GetIsItemPropertyValid(ipGenderProperty))
                   &&(GetItemPropertyType(ipGenderProperty) != ITEM_PROPERTY_USE_LIMITATION_GENDER))
                {
                  ipGenderProperty=GetNextItemProperty(oItem);
                }

              if (GetItemPropertySubType(ipGenderProperty) != GetGender(oAcquirer))
                {
                  bInvalid = TRUE;
                }
            }

           if (bInvalid)
             {
                  AssignCommand(oMaster, zRecoverItem(oAcquirer, oItem));
                  return;
             }
         }

The function definition is

// Recover illegal item from companion

void zRecoverItem(object oOwner, object oItem)
{
                  object oPC = OBJECT_SELF;

                  ClearAllActions(TRUE);
                  ActionTakeItem(oItem, oOwner);
                  ActionDoCommand(OpenInventory(oPC, oPC));
                  ActionDoCommand(OpenInventory(oOwner, oPC));
                  SendMessageToPC(oPC, "The " + GetStringLowerCase(GetName(oItem)) + " doesn't fit " + GetName(oOwner));
}

Some similar scripts, including earlier versions of mine, have a loophole when all three inventories (player, companion, merchant) are open simultanously. The code above fixes that.

It can probably be tidied up a bit.

Proleric you are the best!

Thanks so much. I am going to need to poke around in the CEP code and docs a little more for sure.

This is a feature I’d enjoy seeing Beamdog add, where it is red if you are not the same gender, like how armor is red if you do not meet the requirements to wear it. So it is engine detection vs. script detected.

FP!

Hmmmm my toolset isn’t seeing this / can’t find it. Any idea which HakPak it is in?

My guess would be one of the CEP erf files.

Found it in cep2_add_sb_v1.erf.

smh … I forgot to import the ERF’s on this new module…

Thanks for that, not sure where my head was at.

zep_inc_main is in cep2_add_sb_v1.hak.

No need to import the erf unless you need it for some other reason.

In general, to find resources in CEP haks (amongst many other things), there are free file explorers (for example, I use Free Commander for Win10).