|
| 1 | +/// @addtogroup vault Vault |
| 2 | +/// @brief Provides various character/servervault related functions. |
| 3 | +/// @{ |
| 4 | +/// @file nwnx_vault.nss |
| 5 | +#include "nwnx" |
| 6 | + |
| 7 | +const string NWNX_Vault = "NWNX_Vault"; ///< @private |
| 8 | + |
| 9 | +/// @brief A structure containing vault character data. |
| 10 | +struct NWNX_Vault_Character |
| 11 | +{ |
| 12 | + string sFileName; |
| 13 | + string sUUID; ///< May be empty |
| 14 | + |
| 15 | + string sFirstName; |
| 16 | + string sLastName; |
| 17 | + |
| 18 | + int nPortraitId; |
| 19 | + string sPortrait; |
| 20 | + |
| 21 | + int nClass1Id; ///< Will be CLASS_TYPE_INVALID on error. |
| 22 | + int nClass1Level; |
| 23 | + int nClass2Id; ///< Will be CLASS_TYPE_INVALID if no second class. |
| 24 | + int nClass2Level; |
| 25 | + int nClass3Id; ///< Will be CLASS_TYPE_INVALID if no third class. |
| 26 | + int nClass3Level; |
| 27 | + |
| 28 | + int nRace; |
| 29 | + int nGender; |
| 30 | + int nExperience; |
| 31 | + int nGold; |
| 32 | +}; |
| 33 | + |
| 34 | +/// @brief Get the number of characters in oPlayer's vault. |
| 35 | +/// @param oPlayer The player. |
| 36 | +/// @return The number of characters in the vault or 0 on error. |
| 37 | +int NWNX_Vault_GetVaultSize(object oPlayer); |
| 38 | + |
| 39 | + |
| 40 | +/// @brief Load the character vault of oPlayer. |
| 41 | +/// @note Will overwrite a previously loaded vault. Will return 0 for (Player)DMs. |
| 42 | +/// @param oPlayer The player. |
| 43 | +/// @return The number of characters in the vault or 0 on error. |
| 44 | +int NWNX_Vault_LoadVault(object oPlayer); |
| 45 | + |
| 46 | +/// @brief Get the data of the character at nIndex in the last loaded vault. |
| 47 | +/// @param nIndex The index. |
| 48 | +/// @return A NWNX_Vault_Character struct. |
| 49 | +struct NWNX_Vault_Character NWNX_Vault_GetCharacterData(int nIndex); |
| 50 | + |
| 51 | +/// @brief Switch oPlayer's character to another one from their vault. |
| 52 | +/// @warning THIS FUNCTION IS EXPERIMENTAL, BACKUP YOUR SERVERVAULT BEFORE EVEN ATTEMPTING TO USE THIS. |
| 53 | +/// @warning Do not switch between characters with the same UUID, bad things will happen. |
| 54 | +/// @note If something goes catastrophically wrong the player will be disconnected. |
| 55 | +/// @param oPlayer The player. |
| 56 | +/// @param sBICFileName The bic filename without .bic. |
| 57 | +/// @return The new creature object or OBJECT_INVALID on error. |
| 58 | +object NWNX_Vault_SwitchCharacter(object oPlayer, string sBICFileName); |
| 59 | + |
| 60 | +/// @} |
| 61 | + |
| 62 | +int NWNX_Vault_GetVaultSize(object oPlayer) |
| 63 | +{ |
| 64 | + NWNX_PushArgumentObject(oPlayer); |
| 65 | + NWNX_CallFunction(NWNX_Vault, "GetVaultSize"); |
| 66 | + |
| 67 | + return NWNX_GetReturnValueInt(); |
| 68 | +} |
| 69 | + |
| 70 | +int NWNX_Vault_LoadVault(object oPlayer) |
| 71 | +{ |
| 72 | + NWNX_PushArgumentObject(oPlayer); |
| 73 | + NWNX_CallFunction(NWNX_Vault, "LoadVault"); |
| 74 | + |
| 75 | + return NWNX_GetReturnValueInt(); |
| 76 | +} |
| 77 | + |
| 78 | +struct NWNX_Vault_Character NWNX_Vault_GetCharacterData(int nIndex) |
| 79 | +{ |
| 80 | + NWNX_PushArgumentInt(nIndex); |
| 81 | + NWNX_CallFunction(NWNX_Vault, "GetCharacterData"); |
| 82 | + |
| 83 | + struct NWNX_Vault_Character str; |
| 84 | + str.nGold = NWNX_GetReturnValueInt(); |
| 85 | + str.nExperience = NWNX_GetReturnValueInt(); |
| 86 | + str.nGender = NWNX_GetReturnValueInt(); |
| 87 | + str.nRace = NWNX_GetReturnValueInt(); |
| 88 | + str.nClass3Level = NWNX_GetReturnValueInt(); |
| 89 | + str.nClass3Id = NWNX_GetReturnValueInt(); |
| 90 | + str.nClass2Level = NWNX_GetReturnValueInt(); |
| 91 | + str.nClass2Id = NWNX_GetReturnValueInt(); |
| 92 | + str.nClass1Level = NWNX_GetReturnValueInt(); |
| 93 | + str.nClass1Id = NWNX_GetReturnValueInt(); |
| 94 | + str.sPortrait = NWNX_GetReturnValueString(); |
| 95 | + str.nPortraitId = NWNX_GetReturnValueInt(); |
| 96 | + str.sLastName = NWNX_GetReturnValueString(); |
| 97 | + str.sFirstName = NWNX_GetReturnValueString(); |
| 98 | + str.sUUID = NWNX_GetReturnValueString(); |
| 99 | + str.sFileName = NWNX_GetReturnValueString(); |
| 100 | + |
| 101 | + return str; |
| 102 | +} |
| 103 | + |
| 104 | +object NWNX_Vault_SwitchCharacter(object oPlayer, string sBICFileName) |
| 105 | +{ |
| 106 | + NWNX_PushArgumentString(sBICFileName); |
| 107 | + NWNX_PushArgumentObject(oPlayer); |
| 108 | + NWNX_CallFunction(NWNX_Vault, "SwitchCharacter"); |
| 109 | + return NWNX_GetReturnValueObject(); |
| 110 | +} |
0 commit comments