//:://///////////////////////////////////////////// //:: tk_itemnamer //:: //:: Tag-based script. //::////////////////////////////////////////////// /* Implements an item that when activated, allows a player to rename the target item, if the target is in the player's inventory. */ //::////////////////////////////////////////////// //:: Created By: The Krit //:: Created On: May 21, 2007 //::////////////////////////////////////////////// // The associated conversation uses custom tokens // 1145 and 1146. ////////////////////////////////////////////////// // Local variables are not cleaned up upon an // aborted conversation because in a certain // situation, the conversation's abort script // is called after the next execution of this // script. ////////////////////////////////////////////////// #include "x2_inc_switches" // Setting a local integer with the following name to 1 on an item will prevent // this script from changing that item's name. const string TK_ITEMNAMER_Excluded = "TK_ITEMNAMER_Excluded"; void main() { // We're only implementing activation. if ( GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE ) return; // Signal that the script handled this. SetExecutedScriptReturnValue(); object oPC = GetItemActivator(); object oTarget = GetItemActivatedTarget(); // Check: Valid target. if ( !GetIsObjectValid(oTarget) ) { FloatingTextStrRefOnCreature(83384, oPC); // "* Failure - Invalid Target *" return; } // Check: Target is currently possessed. if ( GetItemPossessor(oTarget) != oPC ) { FloatingTextStrRefOnCreature(83354, oPC); // "* Failure: Item must be in your possession *" return; } // Check: Target is identified. if ( !GetIdentified(oTarget) ) { FloatingTextStringOnCreature("* Failure: Item must be identified *", oPC); return; } // Check: Target is not plot. // (Comment this out if plot items are allowed to be renamed by players.) if ( GetPlotFlag(oTarget) ) { FloatingTextStringOnCreature("* Failure: Plot items may not be renamed *", oPC); return; } // Check: Target is not excluded. // (This gives a module builder a way to exclude key items from being renamed.) if ( GetLocalInt(oTarget, TK_ITEMNAMER_Excluded) ) { FloatingTextStringOnCreature("* Failure: " + GetName(oTarget) + " is not approved for renaming *", oPC); return; } // Remember the target. SetLocalObject(oPC, "TK_ITEMNAMER_Target", oTarget); // Start the conversation that will allow the item to be renamed. AssignCommand(oPC, ClearAllActions()); AssignCommand(oPC, ActionStartConversation(oPC, "tk_itemnamer", TRUE, FALSE)); }