A few different ways you could do this. Not sure how many hats are available since I never used em. You could make a tagbased script for each hat. Or you could give all the hats the same tag(assuming you don't need to use the tags for anything else) or you could add a piece of code to your modules OnPlayerEquip script with a list of all the tags and perform the actions there.
I'm going to take the simplest route here and just say that all the hat tags will be the same.
This script does not need any checks for cloak or tag because it is a tag based script we already know it is a cloak and its tag. This will automaitcally remove a helmet if one of the cloak/hats is equipped.
#include "x2_inc_switches"
void main()
{
int nEvent = GetUserDefinedItemEventNumber();
if (nEvent != X2_ITEM_EVENT_EQUIP) return;
object oPC = GetPCItemLastEquippedBy();
object oHelm = GetItemInSlot(INVENTORY_SLOT_HEAD, oPC);
AssignCommand(oPC, ActionUnequipItem(oHelm));
}
NOTE: This will be a bit trickier in reverse. If someone equips a helmet then the cloak should be removed if it's tag is that of the cloak/hat (again using the same tag for all the hats will come in handy here). This would probably be best if it were a piece of code added to the OnPlayerEquipItem.
Hope that helps. Good luck.
Modifié par GhostOfGod, 23 mars 2011 - 08:36 .