I did a bar where you have to sheath you weapons when you enter. Now intead of having the guard just tell someone to do it, sheath their weapon you could have that happen too. Treating it more as a command effect. Guard: Sheath your Weapon, and then execute that action. Something to consider also is that you would have to do it for both hands, unless they are carrying a two-handed weapon. You can actually get bows but sadly no funtion for melee weapons. What I mean is that there is a function that checks for bows:
// Returns TRUE if the given opponent is wielding a
// ranged weapon.
int GetIsWieldingRanged(object oAttacker)
So without listing all the weapons you could also just unequip what the PC is carrying in their hands, assuming they will be weapons, though it could be a torch I suppose.
This is the script for interior inhabited areas like Inns, houses, etc...
#include "NW_I0_GENERIC"
void main()
{
object oPC = GetEnteringObject();
object oDatabase = GetItemPossessedBy(oPC, "database");
object oArea = GetArea(oPC);
if (!GetIsPC(oPC))
return;
object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
object oItem1 = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);
location lLocation = GetLocation(oPC);
if (GetIsObjectValid(oItem))
{
AssignCommand(oPC, ActionUnequipItem(oItem));
}
if (GetIsObjectValid(oItem1))
{
AssignCommand(oPC, ActionUnequipItem(oItem1));
}
//can't enter with weapons equipped,torches, shields...
}
You could make an exception for torches checking the left hand and returning the script at that point. Then onequipped I check the area for the variable No_Weapon and if it's set to 1 the PC is auto-unequipped of their weapons.
Now for your particular case you may not want this but it might be useful for some other areas, like a boxing arena where you can't use weapons. Which is what I originally designed it for.
Cheers!
You could also use the function:
// * Returns TRUE if the weapon equipped is capable of damaging oVersus.
int GetIsWeaponEffective(object oVersus=OBJECT_INVALID, int bOffHand=FALSE)
Where both weapons are checked, and if they are effective, i.e, they can damage the caller then they meet the
criteria of weapons and can be called as such or unequipped. About the only reason to list all the weapons that
I can think of is that you could actually have the guard refer to the weapon, sheath your long-sword or sheath you great axe of slaying gibbering gibbons, which adds some flavor to the world.
Modifié par ffbj, 04 septembre 2010 - 05:26 .