REO-EE/_module/nss/outfit_menu.nss
Jaysyn904 f82740bbbd Initial commit
Initial commit
2024-02-22 13:22:03 -05:00

445 lines
15 KiB
Plaintext

// Modified by Zunath
#include "inc_system_const"
#include "inc_mysql_tables"
#include "inc_pc_functions"
#include "colors_inc"
#include "zzdlg_main_inc"
const string RESPONSE_PAGE = "outfit_menu_responses";
const string PAGE_MAIN = "main_page";
const string PAGE_SAVE_OUTFIT = "save_outfit_page";
const string PAGE_LOAD_OUTFIT = "load_outfit_page";
const string PAGE_DELETE_OUTFIT = "delete_outfit_page";
//////////////////////
// SYSTEM VARIABLES //
//////////////////////
// Name of the array which tracks whether or not a player has stored an outfit in a particular slot.
// Use with GetLocalArrayInt and SetLocalArrayInt
const string OUTFIT_ARRAY = "PC_OUTFIT_ARRAY";
// Number of slots a player can store outfits to
// If you increase this, be sure to add more columns to the CHARACTER_INFO_TABLE table
const int OUTFIT_SLOT_COUNT = 10;
/////////////////////////
// TEMPORARY VARIABLES //
/////////////////////////
void ClearTemporaryVariables()
{
object oPC = dlgGetSpeakingPC();
}
// Prototypes
void MainPageInit();
void MainPageSelect();
void SaveOutfitInit();
void SaveOutfitSelect();
void LoadOutfitInit();
void LoadOutfitSelect();
void DeleteOutfitInit();
void DeleteOutfitSelect();
void OnInit()
{
dlgChangeLabelNext("Next page");
dlgChangeLabelPrevious("Previous page");
dlgChangePage(PAGE_MAIN);
dlgActivatePreservePageNumberOnSelection();
dlgActivateResetResponse();
}
// Create the page
void OnPageInit( string sPage )
{
DeleteList( RESPONSE_PAGE, dlgGetSpeakingPC() );
if( sPage == PAGE_MAIN ) MainPageInit( );
else if(sPage == PAGE_SAVE_OUTFIT) SaveOutfitInit();
else if(sPage == PAGE_LOAD_OUTFIT) LoadOutfitInit();
else if(sPage == PAGE_DELETE_OUTFIT) DeleteOutfitInit();
dlgSetActiveResponseList( RESPONSE_PAGE );
}
// Handles any selection.
void OnSelection( string sPage )
{
if ( sPage == PAGE_MAIN ) MainPageSelect( );
else if(sPage == PAGE_SAVE_OUTFIT) SaveOutfitSelect();
else if(sPage == PAGE_LOAD_OUTFIT) LoadOutfitSelect();
else if(sPage == PAGE_DELETE_OUTFIT) DeleteOutfitSelect();
}
void OnReset( string sPage )
{
ClearTemporaryVariables();
dlgChangePage( PAGE_MAIN );
dlgResetPageNumber( );
}
void OnAbort( string sPage )
{
ClearTemporaryVariables();
DeleteList( RESPONSE_PAGE, dlgGetSpeakingPC() );
}
void OnEnd( string sPage )
{
ClearTemporaryVariables();
DeleteList( RESPONSE_PAGE, dlgGetSpeakingPC() );
}
void OnContinue( string sPage, int iContinuePage )
{
}
// Message handler
void main()
{
dlgOnMessage();
}
// Specific scripting starts here
// MAIN PAGE START
void MainPageInit( )
{
object oPC = dlgGetSpeakingPC();
object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE);
string sMessage = ColorTokenGreen() + "Outfit Management Menu\n\n" + ColorTokenEnd();
sMessage += "You can save, load, and delete stored outfits from this menu. Please select an option.\n";
dlgSetPrompt(sMessage);
dlgAddResponseAction(RESPONSE_PAGE, "Save Outfit");
dlgAddResponseAction(RESPONSE_PAGE, "Load Outfit");
dlgAddResponseAction(RESPONSE_PAGE, "Delete Outfit");
dlgAddResponseAction(RESPONSE_PAGE, "Back", ColorTokenBlue());
dlgDeactivateResetResponse();
dlgActivateEndResponse( "End" );
}
void MainPageSelect( )
{
object oPC = dlgGetSpeakingPC();
object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE);
if(dlgIsSelectionEqualToName("Save Outfit"))
{
dlgChangePage(PAGE_SAVE_OUTFIT);
}
else if(dlgIsSelectionEqualToName("Load Outfit"))
{
dlgChangePage(PAGE_LOAD_OUTFIT);
}
else if(dlgIsSelectionEqualToName("Delete Outfit"))
{
dlgChangePage(PAGE_DELETE_OUTFIT);
}
else if(dlgIsSelectionEqualToName("Back"))
{
dlgEndDialog();
AssignCommand(oPC, ActionStartConversation(oPC, "x0_skill_ctrap", TRUE, FALSE));
}
}
void SaveOutfitInit()
{
object oPC = dlgGetSpeakingPC();
object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE);
object oClothes = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
string sMessage;
string sColor;
dlgAddResponseAction(RESPONSE_PAGE, "Refresh");
// Player doesn't have clothes equipped
if(!GetIsObjectValid(oClothes))
{
sMessage = "You do not have clothes equipped. Equip some clothes and then choose 'Refresh' to try again.\n";
}
// Player's clothes are equipped - show the save outfit options
else
{
sMessage = "Please select which slot you would like to save your equipped outfit to.\n\n";
sMessage += "Slots marked in " + ColorTokenGreen() + "green " + ColorTokenEnd() + "have an outfit saved.\n\n";
sMessage += "Slots marked in " + ColorTokenRed() + "red " + ColorTokenEnd() + "are currently empty.\n";
int iSlot;
for(iSlot = 1; iSlot <= OUTFIT_SLOT_COUNT; iSlot++)
{
// Color is green if an outfit is currently saved in that slot
if(GetLocalArrayInt(oDatabase, OUTFIT_ARRAY, iSlot))
{
dlgAddResponseAction(RESPONSE_PAGE, "Save Outfit to Slot " + IntToString(iSlot), ColorTokenGreen());
}
// Otherwise the color is red
else
{
dlgAddResponseAction(RESPONSE_PAGE, "Save Outfit to Slot " + IntToString(iSlot), ColorTokenRed());
}
}
}
dlgSetPrompt(sMessage);
dlgActivateResetResponse("Back", ColorTokenBlue());
}
void SaveOutfitSelect()
{
object oPC = dlgGetSpeakingPC();
object oClothes = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE);
int iPCID = GetLocalInt(oDatabase, PC_ID_NUMBER);
// Player got super naked - tell them they can't save their clothes
if(!GetIsObjectValid(oClothes))
{
FloatingTextStringOnCreature(ColorTokenRed() + "You do not have clothes equipped." + ColorTokenEnd(), oPC, FALSE);
}
// Otherwise store the clothes into the correct field of the CHARACTER_INFO_TABLE table
else if(dlgIsSelectionEqualToName("Save Outfit to Slot 1"))
{
SetLocalArrayInt(oDatabase, OUTFIT_ARRAY, 1, TRUE);
StoreMySQLObject(CHARACTER_INFO_TABLE, "Outfit_1", iPCID, oClothes);
}
else if(dlgIsSelectionEqualToName("Save Outfit to Slot 2"))
{
SetLocalArrayInt(oDatabase, OUTFIT_ARRAY, 2, TRUE);
StoreMySQLObject(CHARACTER_INFO_TABLE, "Outfit_2", iPCID, oClothes);
}
else if(dlgIsSelectionEqualToName("Save Outfit to Slot 3"))
{
SetLocalArrayInt(oDatabase, OUTFIT_ARRAY, 3, TRUE);
StoreMySQLObject(CHARACTER_INFO_TABLE, "Outfit_3", iPCID, oClothes);
}
else if(dlgIsSelectionEqualToName("Save Outfit to Slot 4"))
{
SetLocalArrayInt(oDatabase, OUTFIT_ARRAY, 4, TRUE);
StoreMySQLObject(CHARACTER_INFO_TABLE, "Outfit_4", iPCID, oClothes);
}
else if(dlgIsSelectionEqualToName("Save Outfit to Slot 5"))
{
SetLocalArrayInt(oDatabase, OUTFIT_ARRAY, 5, TRUE);
StoreMySQLObject(CHARACTER_INFO_TABLE, "Outfit_5", iPCID, oClothes);
}
else if(dlgIsSelectionEqualToName("Save Outfit to Slot 6"))
{
SetLocalArrayInt(oDatabase, OUTFIT_ARRAY, 6, TRUE);
StoreMySQLObject(CHARACTER_INFO_TABLE, "Outfit_6", iPCID, oClothes);
}
else if(dlgIsSelectionEqualToName("Save Outfit to Slot 7"))
{
SetLocalArrayInt(oDatabase, OUTFIT_ARRAY, 7, TRUE);
StoreMySQLObject(CHARACTER_INFO_TABLE, "Outfit_7", iPCID, oClothes);
}
else if(dlgIsSelectionEqualToName("Save Outfit to Slot 8"))
{
SetLocalArrayInt(oDatabase, OUTFIT_ARRAY, 8, TRUE);
StoreMySQLObject(CHARACTER_INFO_TABLE, "Outfit_8", iPCID, oClothes);
}
else if(dlgIsSelectionEqualToName("Save Outfit to Slot 9"))
{
SetLocalArrayInt(oDatabase, OUTFIT_ARRAY, 9, TRUE);
StoreMySQLObject(CHARACTER_INFO_TABLE, "Outfit_9", iPCID, oClothes);
}
else if(dlgIsSelectionEqualToName("Save Outfit to Slot 10"))
{
SetLocalArrayInt(oDatabase, OUTFIT_ARRAY, 10, TRUE);
StoreMySQLObject(CHARACTER_INFO_TABLE, "Outfit_10", iPCID, oClothes);
}
}
void LoadOutfitInit()
{
object oPC = dlgGetSpeakingPC();
object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE);
object oClothes = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
string sMessage;
dlgAddResponseAction(RESPONSE_PAGE, "Refresh");
// Player doesn't have clothes equipped
if(!GetIsObjectValid(oClothes))
{
sMessage = "You do not have clothes equipped. Equip some clothes and then choose 'Refresh' to try again.\n";
}
// Player's clothes are equipped - show the save outfit options
else
{
sMessage = "Please select which outfit you would like to load.\n";
int iSlot;
for(iSlot = 1; iSlot <= OUTFIT_SLOT_COUNT; iSlot++)
{
// Only display the slots that have outfits saved to them
if(GetLocalArrayInt(oDatabase, OUTFIT_ARRAY, iSlot))
{
dlgAddResponseAction(RESPONSE_PAGE, "Load Outfit in Slot " + IntToString(iSlot), ColorTokenGreen());
}
}
}
dlgSetPrompt(sMessage);
dlgActivateResetResponse("Back", ColorTokenBlue());
}
void LoadOutfitSelect()
{
object oPC = dlgGetSpeakingPC();
object oClothes = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE);
int iPCID = GetLocalInt(oDatabase, PC_ID_NUMBER);
// Player got super naked - tell them they can't load their clothes
if(!GetIsObjectValid(oClothes) && !dlgIsSelectionEqualToName("Refresh"))
{
FloatingTextStringOnCreature(ColorTokenRed() + "You do not have clothes equipped." + ColorTokenEnd(), oPC, FALSE);
}
else if(dlgIsSelectionEqualToName("Load Outfit in Slot 1"))
{
DestroyObject(oClothes);
oClothes = RetrieveMySQLObject(CHARACTER_INFO_TABLE, "Outfit_1", iPCID, "ID", "", oPC);
AssignCommand(oPC, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
}
else if(dlgIsSelectionEqualToName("Load Outfit in Slot 2"))
{
DestroyObject(oClothes);
oClothes = RetrieveMySQLObject(CHARACTER_INFO_TABLE, "Outfit_2", iPCID, "ID", "", oPC);
AssignCommand(oPC, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
}
else if(dlgIsSelectionEqualToName("Load Outfit in Slot 3"))
{
DestroyObject(oClothes);
oClothes = RetrieveMySQLObject(CHARACTER_INFO_TABLE, "Outfit_3", iPCID, "ID", "", oPC);
AssignCommand(oPC, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
}
else if(dlgIsSelectionEqualToName("Load Outfit in Slot 4"))
{
DestroyObject(oClothes);
oClothes = RetrieveMySQLObject(CHARACTER_INFO_TABLE, "Outfit_4", iPCID, "ID", "", oPC);
AssignCommand(oPC, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
}
else if(dlgIsSelectionEqualToName("Load Outfit in Slot 5"))
{
DestroyObject(oClothes);
oClothes = RetrieveMySQLObject(CHARACTER_INFO_TABLE, "Outfit_5", iPCID, "ID", "", oPC);
AssignCommand(oPC, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
}
else if(dlgIsSelectionEqualToName("Load Outfit in Slot 6"))
{
DestroyObject(oClothes);
oClothes = RetrieveMySQLObject(CHARACTER_INFO_TABLE, "Outfit_6", iPCID, "ID", "", oPC);
AssignCommand(oPC, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
}
else if(dlgIsSelectionEqualToName("Load Outfit in Slot 7"))
{
DestroyObject(oClothes);
oClothes = RetrieveMySQLObject(CHARACTER_INFO_TABLE, "Outfit_7", iPCID, "ID", "", oPC);
AssignCommand(oPC, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
}
else if(dlgIsSelectionEqualToName("Load Outfit in Slot 8"))
{
DestroyObject(oClothes);
oClothes = RetrieveMySQLObject(CHARACTER_INFO_TABLE, "Outfit_8", iPCID, "ID", "", oPC);
AssignCommand(oPC, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
}
else if(dlgIsSelectionEqualToName("Load Outfit in Slot 9"))
{
DestroyObject(oClothes);
oClothes = RetrieveMySQLObject(CHARACTER_INFO_TABLE, "Outfit_9", iPCID, "ID", "", oPC);
AssignCommand(oPC, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
}
else if(dlgIsSelectionEqualToName("Load Outfit in Slot 10"))
{
DestroyObject(oClothes);
oClothes = RetrieveMySQLObject(CHARACTER_INFO_TABLE, "Outfit_10", iPCID, "ID", "", oPC);
AssignCommand(oPC, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
}
}
void DeleteOutfitInit()
{
object oPC = dlgGetSpeakingPC();
object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE);
int iSlot;
for(iSlot = 1; iSlot <= OUTFIT_SLOT_COUNT; iSlot++)
{
// Only display the slots that have outfits saved to them
if(GetLocalArrayInt(oDatabase, OUTFIT_ARRAY, iSlot))
{
dlgAddResponseAction(RESPONSE_PAGE, "Delete Outfit in Slot " + IntToString(iSlot), ColorTokenGreen());
}
}
dlgActivateResetResponse("Back", ColorTokenBlue());
}
void DeleteOutfitSelect()
{
object oPC = dlgGetSpeakingPC();
object oClothes = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE);
int iPCID = GetLocalInt(oDatabase, PC_ID_NUMBER);
if(dlgIsSelectionEqualToName("Delete Outfit in Slot 1"))
{
DeleteLocalArrayInt(oDatabase, OUTFIT_ARRAY, 1);
NullMySQLField(CHARACTER_INFO_TABLE, "Outfit_1", iPCID);
}
else if(dlgIsSelectionEqualToName("Delete Outfit in Slot 2"))
{
DeleteLocalArrayInt(oDatabase, OUTFIT_ARRAY, 2);
NullMySQLField(CHARACTER_INFO_TABLE, "Outfit_2", iPCID);
}
else if(dlgIsSelectionEqualToName("Delete Outfit in Slot 3"))
{
DeleteLocalArrayInt(oDatabase, OUTFIT_ARRAY, 3);
NullMySQLField(CHARACTER_INFO_TABLE, "Outfit_3", iPCID);
}
else if(dlgIsSelectionEqualToName("Delete Outfit in Slot 4"))
{
DeleteLocalArrayInt(oDatabase, OUTFIT_ARRAY, 4);
NullMySQLField(CHARACTER_INFO_TABLE, "Outfit_4", iPCID);
}
else if(dlgIsSelectionEqualToName("Delete Outfit in Slot 5"))
{
DeleteLocalArrayInt(oDatabase, OUTFIT_ARRAY, 5);
NullMySQLField(CHARACTER_INFO_TABLE, "Outfit_5", iPCID);
}
else if(dlgIsSelectionEqualToName("Delete Outfit in Slot 6"))
{
DeleteLocalArrayInt(oDatabase, OUTFIT_ARRAY, 6);
NullMySQLField(CHARACTER_INFO_TABLE, "Outfit_6", iPCID);
}
else if(dlgIsSelectionEqualToName("Delete Outfit in Slot 7"))
{
DeleteLocalArrayInt(oDatabase, OUTFIT_ARRAY, 7);
NullMySQLField(CHARACTER_INFO_TABLE, "Outfit_7", iPCID);
}
else if(dlgIsSelectionEqualToName("Delete Outfit in Slot 8"))
{
DeleteLocalArrayInt(oDatabase, OUTFIT_ARRAY, 8);
NullMySQLField(CHARACTER_INFO_TABLE, "Outfit_8", iPCID);
}
else if(dlgIsSelectionEqualToName("Delete Outfit in Slot 9"))
{
DeleteLocalArrayInt(oDatabase, OUTFIT_ARRAY, 9);
NullMySQLField(CHARACTER_INFO_TABLE, "Outfit_9", iPCID);
}
else if(dlgIsSelectionEqualToName("Delete Outfit in Slot 10"))
{
DeleteLocalArrayInt(oDatabase, OUTFIT_ARRAY, 10);
NullMySQLField(CHARACTER_INFO_TABLE, "Outfit_10", iPCID);
}
}