Help with Weapon Script

Sorry If I’m being a pain and going about this the wrong way, I’ve never used the site before.

Basically I’m trying to create a system when the game only let you equip one weapon type. (You will be able to pick your weapon type but after that you’re stuck with it) I did try making a weapon switch an int to 1 when equipped that stops your weapon just being unequipped again, but I ran into problems with putting another weapon into the off hand, and I can’t think of a way around this. (I did try to set up some kind of righthandweapon int and lefthandweapon int but that was tricky on the same weapon)

Again, sorry if I’m going about this wrong and thank you for the help.

Alexandra.

Hi new person. :slight_smile: You are in the correct place.

In theory, this should be as simple as marking which baseitemtypes are (or aren’t) usable for this player, and automatically unequipping prohibited baseitemtypes.

    object oItem = GetPCItemLastEquipped();
    object oPC   = GetPCItemLastEquippedBy();

    // Unequip check for prohibited baseitemtypes:
    int nBaseItemType = GetBaseItemType(oItem);
    if (GetLocalInt(oPC, "PROHIBIT_BASEITEMTYPE_"+IntToString(nBaseItemType)))
        {
        AssignCommand(oPC, ClearAllActions());
        AssignCommand(oPC, ActionWait(0.3));
        AssignCommand(oPC, ActionDoCommand(SendMessageToPC(oPC, "You can't equip "+GetName(oItem)+".")));
        AssignCommand(oPC, ActionUnequipItem(oItem));
        AssignCommand(oPC, ActionDoCommand(SetCommandable(TRUE, oPC)));
        DelayCommand(0.01, SetCommandable(FALSE, oPC));
        }

Combine that with flagging items not-allowed-to-equip by baseitemtype:

    SetLocalInt(oPC, "PROHIBIT_BASEITEMTYPE_"+IntToString(BASE_ITEM_RAPIER), TRUE);

You could switch it around, and prohibit equipping anything for which a manual exception isn’t made, too.

Is this for a PW or for a singleplayer module? :open_mouth: PWs would need to store the players’ individual settings for what they are or aren’t allowed to equip into a database, as opposed to the “store as local vars” method here.

Thank you very much for the help

I’m not great at scripting but I should be able to get it working with your help now, so thank you.

The module is Singleplayer.

Alexandra.

1 Like

Anytime. Don’t hesitate to shout when you hit the next snag. It is zero percent a bother, and there’s usually someone around who has the answer ready. :slight_smile:

Could adding ItemPropertyLimitUseByRace(IP_CONST_RACIALTYPE_ABERRATION) to any forbidden item in OnAcquireItem and removing it in OnUnAcquireItem be a viable alternative to equip/unequip? It wouldn’t require any local vars (and thus avoid any sync issues) EDIT: on items, of course. I don’t remember if Use Magic Device can override that.

Giving it a try, I can confirm that high enough ranks of UMD bypass the racialtype-based use limitation. :thinking: It’s a nice idea, though. Could be something for modules with class-restrictions.

Hm, I have two solutions then, both attack UMD, effectively disabling it for PC or anyone:

  1. less elegant, but easier:
    EffectSkillDecrease(SKILL_USE_MAGIC_DEVICE, 100) for PC.

  2. avoids skill decrease status:
    Override Skillvsitemcost.2da and put **** in all SkillReq* columns.

EDIT: This should not prevent items from being identified (that’s what DeviceCostMax column is for), but if using **** does not yield the desired results, putting 1000 instead should work.

1 Like