//Created by Esreyr Fears //on February 2nd, 2006 //start the conversation to choose which alternate humanoid shape to choose. //Modified March 27th, 2006: Allow only 1 widget in the PC's inventory. // Added level checks for item activation (DM's can bypass this) #include "x2_inc_itemprop" #include "x2_inc_switches" void main() { int nEvent = GetUserDefinedItemEventNumber(); object oPC; object oItem; switch(nEvent) { //The following are not used case X2_ITEM_EVENT_SPELLCAST_AT: break; case X2_ITEM_EVENT_ONHITCAST: break; case X2_ITEM_EVENT_EQUIP: break; case X2_ITEM_EVENT_UNEQUIP: break; case X2_ITEM_EVENT_UNACQUIRE: break; //When the Player activates the widget case X2_ITEM_EVENT_ACTIVATE: { //Begin the conversation if requirements are met (DM's can always use this widget) oPC = GetItemActivator(); oItem = GetItemActivated(); int nDruidLevel = GetLevelByClass(CLASS_TYPE_DRUID, oPC); // if (nDruidLevel > 8 || GetIsDMPossessed(oPC) || GetIsDM(oPC)) AssignCommand( oPC, ActionStartConversation(oPC, "alt_shape", TRUE, FALSE) ); // else // SendMessageToPC(oPC, "Requirements not met to use this ability."); break; } //When the Player acquires the widget or logs into the game //This is potentally an expensive fuction call!! case X2_ITEM_EVENT_ACQUIRE: { oPC = GetModuleItemAcquiredBy(); oItem = GetModuleItemAcquired(); //Don't give the widget if the PC alread has one. int itemCount = 0; object oInventory = GetFirstItemInInventory(oPC); while (GetIsObjectValid(oInventory)) { if ( GetTag(oInventory) == "alt_shape_conv") itemCount++; oInventory = GetNextItemInInventory(oPC); if (itemCount > 1) break; //no need to check further. } if (itemCount > 1) DestroyObject(oItem); //originals (usefull for the DM and DM possessed creatures) SetLocalInt(oItem, "original_face", GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) ); SetLocalInt(oItem, "original_shape", GetAppearanceType(oPC) ); SetLocalInt(oItem, "original_pheno", GetPhenoType(oPC) ); SetLocalInt(oItem, "original_tail", GetCreatureTailType(oPC) ); SetLocalInt(oItem, "original_wing", GetCreatureWingType(oPC) ); //Store the original shape, ignore if already set if ( !GetCampaignInt("altershape", "has_been_set", oPC) ) { SetCampaignInt("altershape", "original_face", GetCreatureBodyPart(CREATURE_PART_HEAD, oPC), oPC); SetCampaignInt("altershape", "original_shape", GetAppearanceType(oPC), oPC); SetCampaignInt("altershape", "original_pheno", GetPhenoType(oPC), oPC); SetCampaignInt("altershape", "original_tail", GetCreatureTailType(oPC), oPC); SetCampaignInt("altershape", "original_wing", GetCreatureWingType(oPC), oPC); SetCampaignInt("altershape", "has_been_set", TRUE, oPC); } //change to temp variables SetLocalInt(oItem, "change_face", GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) ); SetLocalInt(oItem, "change_shape", GetAppearanceType(oPC) ); SetLocalInt(oItem, "change_pheno", GetPhenoType(oPC) ); SetLocalInt(oItem, "change_tail", GetCreatureTailType(oPC) ); SetLocalInt(oItem, "change_wing", GetCreatureWingType(oPC) ); //slot 1 variables SetLocalInt(oItem, "slot1_face", GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) ); SetLocalInt(oItem, "slot1_shape", GetAppearanceType(oPC) ); SetLocalInt(oItem, "slot1_pheno", GetPhenoType(oPC) ); SetLocalInt(oItem, "slot1_tail", GetCreatureTailType(oPC) ); SetLocalInt(oItem, "slot1_wing", GetCreatureWingType(oPC) ); //slot 2 variables SetLocalInt(oItem, "slot2_face", GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) ); SetLocalInt(oItem, "slot2_shape", GetAppearanceType(oPC) ); SetLocalInt(oItem, "slot2_pheno", GetPhenoType(oPC) ); SetLocalInt(oItem, "slot2_tail", GetCreatureTailType(oPC) ); SetLocalInt(oItem, "slot2_wing", GetCreatureWingType(oPC) ); break; } } }