#include "zep_inc_craft2" void main() { object oPC = GetPCSpeaker(); object oItem = GetLocalObject(oPC, "ZEP_CR_ITEM"); object oNew; string sLastChat = GetLocalString(oPC,"TD_QUILLCHAT"); string sPreRead; int nPart = GetLocalInt(oPC, "ZEP_CR_PART"); int nCurrApp; int nSlot; int iLastChat = StringToInt(sLastChat); if ( nPart == ITEM_APPR_ARMOR_MODEL_TORSO ) { string sAC = Get2DAString("parts_chest", "ACBONUS", iLastChat); // Fetch the stringlist that holds the ID's for this part sPreRead = GetLocalString(GetModule(), "ZEP_IDPreReadAC_" + GetStringLeft(sAC, 1)); if ( sPreRead == "" ) // list didn't exist yet, so generate it sPreRead = ZEP_PreReadArmorACList(sAC); // if ( nMode == ZEP_CR_PART_PREV ) // sPreRead = GetLocalString(GetModule(), "ZEP_IDPreReadACR_" + GetStringLeft(sAC, 1)); } else { // Fetch the stringlist that holds the ID's for this part sPreRead = GetLocalString(GetModule(), "ZEP_IDPreRead_" + IntToString(nPart)); if ( sPreRead == "" ) // list didn't exist yet, so generate it sPreRead = ZEP_PreReadArmorPartList(nPart); // if ( nMode == ZEP_CR_PART_PREV ) // sPreRead = GetLocalString(GetModule(), "ZEP_IDPreReadR_" + IntToString(nPart)); } // Find the current ID in the stringlist and pick the one coming after that string sID; string sCurrApp = IntToString(iLastChat); int n = FindSubString(sPreRead, ":"+sCurrApp+":"); sID = GetSubString(sPreRead, n+GetStringLength(sCurrApp)+2, 5); n = FindSubString(sID, ":"); sID = GetStringLeft(sID, n); if ( sID=="" && nPart == ITEM_APPR_ARMOR_MODEL_TORSO ) { sID = GetSubString(sPreRead, 1, 5); n = FindSubString(sID, ":"); sID = GetStringLeft(sID, n); } nCurrApp = StringToInt(sID); SetLocalInt(oPC, "ZEP_CR_CHANGED", TRUE); oNew = CopyItemAndModify(oItem, ITEM_APPR_TYPE_ARMOR_MODEL, nPart, nCurrApp, TRUE); object oBackup = CopyItem(oItem, ZEP_GetZEPWorkContainer(OBJECT_SELF), TRUE); SetLocalObject(oPC, "ZEP_CR_BACKUP", oBackup); DestroyObject(oItem); SetLocalObject(oPC, "ZEP_CR_ITEM", oNew); nSlot = INVENTORY_SLOT_CHEST; AssignCommand(oPC, ClearAllActions(TRUE)); AssignCommand(oPC, ActionEquipItem(oNew, nSlot)); }