diff --git a/_module/are/dragonmarshlowla.are.json b/_module/are/dragonmarshlowla.are.json index 66e24352..3726733c 100644 --- a/_module/are/dragonmarshlowla.are.json +++ b/_module/are/dragonmarshlowla.are.json @@ -11169,7 +11169,7 @@ }, "Version": { "type": "dword", - "value": 20 + "value": 21 }, "Width": { "type": "int", diff --git a/_module/git/dragonmarshlowla.git.json b/_module/git/dragonmarshlowla.git.json index 6b02e1b7..8f8235c7 100644 --- a/_module/git/dragonmarshlowla.git.json +++ b/_module/git/dragonmarshlowla.git.json @@ -9915,7 +9915,7 @@ "id": 14817, "type": "cexolocstring", "value": { - "0": "SP_SR30M15P_RS85_SD02M01_RW_PCR_DS2_CMD060" + "0": "SP_SA_SR33M20P_SD08_RW_PC05R_DS2_CMD060_RS10_RH60" } }, "MapNote": { diff --git a/_module/ncs/69_henchrt_enter.ncs b/_module/ncs/69_henchrt_enter.ncs index bd251035..6d915970 100644 Binary files a/_module/ncs/69_henchrt_enter.ncs and b/_module/ncs/69_henchrt_enter.ncs differ diff --git a/_module/ncs/69_henchstr_exit.ncs b/_module/ncs/69_henchstr_exit.ncs index 4df0b27d..6a56ca64 100644 Binary files a/_module/ncs/69_henchstr_exit.ncs and b/_module/ncs/69_henchstr_exit.ncs differ diff --git a/_module/ncs/7cryptport.ncs b/_module/ncs/7cryptport.ncs index b4215d66..1e563d7c 100644 Binary files a/_module/ncs/7cryptport.ncs and b/_module/ncs/7cryptport.ncs differ diff --git a/_module/ncs/7doortodes.ncs b/_module/ncs/7doortodes.ncs index f882eab9..4eb926c6 100644 Binary files a/_module/ncs/7doortodes.ncs and b/_module/ncs/7doortodes.ncs differ diff --git a/_module/ncs/7portbard.ncs b/_module/ncs/7portbard.ncs index 84bc5861..faa11053 100644 Binary files a/_module/ncs/7portbard.ncs and b/_module/ncs/7portbard.ncs differ diff --git a/_module/ncs/8lakeuprope.ncs b/_module/ncs/8lakeuprope.ncs index 1559ba33..c8446bc1 100644 Binary files a/_module/ncs/8lakeuprope.ncs and b/_module/ncs/8lakeuprope.ncs differ diff --git a/_module/ncs/8river10.ncs b/_module/ncs/8river10.ncs index 201fda3a..4c47c1c5 100644 Binary files a/_module/ncs/8river10.ncs and b/_module/ncs/8river10.ncs differ diff --git a/_module/ncs/8river11.ncs b/_module/ncs/8river11.ncs index db69b3bf..07da4af0 100644 Binary files a/_module/ncs/8river11.ncs and b/_module/ncs/8river11.ncs differ diff --git a/_module/ncs/8river12.ncs b/_module/ncs/8river12.ncs index 2af7390d..37f2dd67 100644 Binary files a/_module/ncs/8river12.ncs and b/_module/ncs/8river12.ncs differ diff --git a/_module/ncs/8river13.ncs b/_module/ncs/8river13.ncs index 6d678af9..ad97fc1e 100644 Binary files a/_module/ncs/8river13.ncs and b/_module/ncs/8river13.ncs differ diff --git a/_module/ncs/8river14.ncs b/_module/ncs/8river14.ncs index 0117f2c4..5047138d 100644 Binary files a/_module/ncs/8river14.ncs and b/_module/ncs/8river14.ncs differ diff --git a/_module/ncs/8river15.ncs b/_module/ncs/8river15.ncs index 9ee8853a..22e73902 100644 Binary files a/_module/ncs/8river15.ncs and b/_module/ncs/8river15.ncs differ diff --git a/_module/ncs/8river16.ncs b/_module/ncs/8river16.ncs index 342911de..be3391d9 100644 Binary files a/_module/ncs/8river16.ncs and b/_module/ncs/8river16.ncs differ diff --git a/_module/ncs/8river17.ncs b/_module/ncs/8river17.ncs index 2b37d33d..f2004376 100644 Binary files a/_module/ncs/8river17.ncs and b/_module/ncs/8river17.ncs differ diff --git a/_module/ncs/8river18.ncs b/_module/ncs/8river18.ncs index c199052d..e18b5e8a 100644 Binary files a/_module/ncs/8river18.ncs and b/_module/ncs/8river18.ncs differ diff --git a/_module/ncs/9ariver1.ncs b/_module/ncs/9ariver1.ncs index ab641a00..416be22e 100644 Binary files a/_module/ncs/9ariver1.ncs and b/_module/ncs/9ariver1.ncs differ diff --git a/_module/ncs/9ariver10.ncs b/_module/ncs/9ariver10.ncs index 1ef3eeb7..0d15148d 100644 Binary files a/_module/ncs/9ariver10.ncs and b/_module/ncs/9ariver10.ncs differ diff --git a/_module/ncs/9ariver11.ncs b/_module/ncs/9ariver11.ncs index 15203b73..1bb8bd5d 100644 Binary files a/_module/ncs/9ariver11.ncs and b/_module/ncs/9ariver11.ncs differ diff --git a/_module/ncs/9ariver12.ncs b/_module/ncs/9ariver12.ncs index 1660d426..cf487d74 100644 Binary files a/_module/ncs/9ariver12.ncs and b/_module/ncs/9ariver12.ncs differ diff --git a/_module/ncs/9ariver2.ncs b/_module/ncs/9ariver2.ncs index 371634d2..0e5eeb62 100644 Binary files a/_module/ncs/9ariver2.ncs and b/_module/ncs/9ariver2.ncs differ diff --git a/_module/ncs/9ariver3.ncs b/_module/ncs/9ariver3.ncs index 24c658e8..e67961d7 100644 Binary files a/_module/ncs/9ariver3.ncs and b/_module/ncs/9ariver3.ncs differ diff --git a/_module/ncs/9ariver4.ncs b/_module/ncs/9ariver4.ncs index ca849bce..25099d41 100644 Binary files a/_module/ncs/9ariver4.ncs and b/_module/ncs/9ariver4.ncs differ diff --git a/_module/ncs/9ariver5.ncs b/_module/ncs/9ariver5.ncs index 551648df..ad5b0d07 100644 Binary files a/_module/ncs/9ariver5.ncs and b/_module/ncs/9ariver5.ncs differ diff --git a/_module/ncs/9ariver6.ncs b/_module/ncs/9ariver6.ncs index f14186ef..a1342cd6 100644 Binary files a/_module/ncs/9ariver6.ncs and b/_module/ncs/9ariver6.ncs differ diff --git a/_module/ncs/9ariver7.ncs b/_module/ncs/9ariver7.ncs index 2dfb4520..52c6e802 100644 Binary files a/_module/ncs/9ariver7.ncs and b/_module/ncs/9ariver7.ncs differ diff --git a/_module/ncs/9ariver8.ncs b/_module/ncs/9ariver8.ncs index 08e700ef..e26e389b 100644 Binary files a/_module/ncs/9ariver8.ncs and b/_module/ncs/9ariver8.ncs differ diff --git a/_module/ncs/9ariver9.ncs b/_module/ncs/9ariver9.ncs index 598851e6..c1af25c8 100644 Binary files a/_module/ncs/9ariver9.ncs and b/_module/ncs/9ariver9.ncs differ diff --git a/_module/ncs/9bportntos.ncs b/_module/ncs/9bportntos.ncs index 8eb7b3cc..dae08107 100644 Binary files a/_module/ncs/9bportntos.ncs and b/_module/ncs/9bportntos.ncs differ diff --git a/_module/ncs/9bportston.ncs b/_module/ncs/9bportston.ncs index 1ca7dd76..b714a66f 100644 Binary files a/_module/ncs/9bportston.ncs and b/_module/ncs/9bportston.ncs differ diff --git a/_module/ncs/9briver1.ncs b/_module/ncs/9briver1.ncs index 3c361890..6ca48cbc 100644 Binary files a/_module/ncs/9briver1.ncs and b/_module/ncs/9briver1.ncs differ diff --git a/_module/ncs/9briver2.ncs b/_module/ncs/9briver2.ncs index 3a8208c6..7affdb42 100644 Binary files a/_module/ncs/9briver2.ncs and b/_module/ncs/9briver2.ncs differ diff --git a/_module/ncs/9bvrokdive.ncs b/_module/ncs/9bvrokdive.ncs index 23e47fbd..b976204f 100644 Binary files a/_module/ncs/9bvrokdive.ncs and b/_module/ncs/9bvrokdive.ncs differ diff --git a/_module/ncs/ab_desctrig_mult.ncs b/_module/ncs/ab_desctrig_mult.ncs index a85b0647..d2298cd0 100644 Binary files a/_module/ncs/ab_desctrig_mult.ncs and b/_module/ncs/ab_desctrig_mult.ncs differ diff --git a/_module/ncs/agycrypt.ncs b/_module/ncs/agycrypt.ncs index a6be480d..ce851a11 100644 Binary files a/_module/ncs/agycrypt.ncs and b/_module/ncs/agycrypt.ncs differ diff --git a/_module/ncs/agypyramid.ncs b/_module/ncs/agypyramid.ncs index 9d092fd6..be2a5695 100644 Binary files a/_module/ncs/agypyramid.ncs and b/_module/ncs/agypyramid.ncs differ diff --git a/_module/ncs/ar_barredoor_f2o.ncs b/_module/ncs/ar_barredoor_f2o.ncs index f55c0fec..4eaa0bf4 100644 Binary files a/_module/ncs/ar_barredoor_f2o.ncs and b/_module/ncs/ar_barredoor_f2o.ncs differ diff --git a/_module/ncs/ar_st_pawn.ncs b/_module/ncs/ar_st_pawn.ncs index a93da072..fde56128 100644 Binary files a/_module/ncs/ar_st_pawn.ncs and b/_module/ncs/ar_st_pawn.ncs differ diff --git a/_module/ncs/spawn_orig_hb.ncs b/_module/ncs/spawn_orig_hb.ncs index 0473d9db..54cdda3b 100644 Binary files a/_module/ncs/spawn_orig_hb.ncs and b/_module/ncs/spawn_orig_hb.ncs differ diff --git a/_module/ncs/spawn_sample_hb.ncs b/_module/ncs/spawn_sample_hb.ncs index 0473d9db..54cdda3b 100644 Binary files a/_module/ncs/spawn_sample_hb.ncs and b/_module/ncs/spawn_sample_hb.ncs differ diff --git a/_module/nss/spawn_cfg_camp.nss b/_module/nss/spawn_cfg_camp.nss index f27636f0..940f290f 100644 --- a/_module/nss/spawn_cfg_camp.nss +++ b/_module/nss/spawn_cfg_camp.nss @@ -1,5 +1,6 @@ // // Spawn Camp +// spawn_cfg_camp.nss // // // CampNumP @@ -18,12 +19,11 @@ // RH000 : Return Home // // -// -// //void main (){} // // -// + +#include "sql_db_partywide" object GetChildByTag(object oSpawn, string sChildTag); object GetChildByNumber(object oSpawn, int nChildNum); @@ -4039,8 +4039,27 @@ at night. */ //:: 1d4+1 Giant Bees case 7: - //:: Aragnak? - {break;} + //:: Aragnak the Red Dragon + { + //:: Initialize Variables + object oArea = GetArea(OBJECT_SELF); + //:: Cycle through PCs in Area + object oPC = GetFirstObjectInArea(oArea); + + while (oPC != OBJECT_INVALID) + { + if (GetIsPC(oPC) == TRUE) + { + SendMessageToPC(oPC, "You see a humongous dragon the color of burnt blood flying high overhead"); + SQLocalsUUID_SetInt(oPC, "SEEN_ARAGNAK", 1); + } + + oPC = GetNextObjectInArea(oArea); + } + + break; + } + //:: Aragnak the Red Dragon case 8: case 9: //:: 1d3 worgs and 1d12 wolves @@ -4643,20 +4662,50 @@ indicated, roll 1d10 using the table below. */ switch (nSpawn) { case 1: case 2: - //:: Merchant ship (off coast) + //:: Merchant ship off coast { - //:: Not sure how to handle this one yet. - break; + //:: Initialize Variables + object oArea = GetArea(OBJECT_SELF); + //:: Cycle through PCs in Area + object oPC = GetFirstObjectInArea(oArea); + + while (oPC != OBJECT_INVALID) + { + if (GetIsPC(oPC) == TRUE) + { + SendMessageToPC(oPC, "You notice a fat merchant ship sailing a good distance off the coast."); + SQLocalsUUID_SetInt(oPC, "SEEN_MERCHANT_SHIP", 1); + } + + oPC = GetNextObjectInArea(oArea); + } + + break; } //:: Merchant ship (off coast) case 3: - //:: Pirate ship (off coast) + //:: Pirate ship off coast { - //:: Not sure how to handle this one yet. - break; + //:: Initialize Variables + object oArea = GetArea(OBJECT_SELF); + //:: Cycle through PCs in Area + object oPC = GetFirstObjectInArea(oArea); + + while (oPC != OBJECT_INVALID) + { + if (GetIsPC(oPC) == TRUE) + { + SendMessageToPC(oPC, "You notice a ship sailing off the coast. It appears to be flying a black flag"); + SQLocalsUUID_SetInt(oPC, "SEEN_PIRATE_SHIP", 1); + } + + oPC = GetNextObjectInArea(oArea); + } + + break; } - //:: Pirate ship (off coast) + //:: Pirate ship (off coast) case 4: case 5: case 6: //:: Pirates - 90% Foraging Party / 10% Raiding Party diff --git a/_module/nss/utl_i_sqluuid.nss b/_module/nss/utl_i_sqluuid.nss new file mode 100644 index 00000000..01b3a980 --- /dev/null +++ b/_module/nss/utl_i_sqluuid.nss @@ -0,0 +1,668 @@ +//:://///////////////////////////////////////////// +//:: Utility Include: SQLocals Campaign +//:: utl_i_sqluuid.nss +//::////////////////////////////////////////////// +/* + Daz wrote these library functions to act as replacements for the usual local + functions: + * GetLocalInt / SetLocalInt / DeleteLocalInt + * GetLocalFloat / SetLocalFloat / DeleteLocalFloat + * GetLocalString / SetLocalString / DeleteLocalString + * GetLocalObject / SetLocalObject / DeleteLocalObject (NB: remember these are references NOT serialised objects) + * GetLocalLocation / SetLocalLocation / DeleteLocalLocation + * Plus a new function for saving just a vector by itself. + This version stores variables in the campaign DB using the UUID of the object as + the identifier, therefore it suggests only using this for oPlayer since their UUIDs + are persistent after server restarts. + Note for players existing OnClientLeave this is still valid, while the + versions in utl_i_sqlplayer is not. +*/ +//::////////////////////////////////////////////// +//:: Based off of the nwscript_utility_scripts project; see for dates/creator info +//:: https://github.com/Finaldeath/nwscript_utility_scripts +//::////////////////////////////////////////////// + +const string SQLLOCALUUID_DATABASE_NAME = "sqllocalsuuid_db"; + +const string SQLOCALSUUID_TABLE_NAME = "sqlocalsuuid_table"; + +const int SQLOCALSUUID_TYPE_ALL = 0; +const int SQLOCALSUUID_TYPE_INT = 1; +const int SQLOCALSUUID_TYPE_FLOAT = 2; +const int SQLOCALSUUID_TYPE_STRING = 4; +const int SQLOCALSUUID_TYPE_OBJECT = 8; +const int SQLOCALSUUID_TYPE_VECTOR = 16; +const int SQLOCALSUUID_TYPE_LOCATION = 32; + +// Returns an integer stored in the campaign DB for oPlayer, or 0 on error +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +int SQLocalsUUID_GetInt(object oPlayer, string sVarName); +// Sets an integer stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to set +// * nValue - Value to store +void SQLocalsUUID_SetInt(object oPlayer, string sVarName, int nValue); +// Deletes an integer stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteInt(object oPlayer, string sVarName); + +// Returns a float stored in the campaign DB for oPlayer, or 0.0 on error +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +float SQLocalsUUID_GetFloat(object oPlayer, string sVarName); +// Sets a float stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to set +// * fValue - Value to store +void SQLocalsUUID_SetFloat(object oPlayer, string sVarName, float fValue); +// Deletes a float stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteFloat(object oPlayer, string sVarName); + +// Returns an string stored in the campaign DB for oPlayer, or "" on error +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +string SQLocalsUUID_GetString(object oPlayer, string sVarName); +// Sets a string stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to set +// * sValue - Value to store +void SQLocalsUUID_SetString(object oPlayer, string sVarName, string sValue); +// Deletes a string stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteString(object oPlayer, string sVarName); + +// Returns an object identifier stored in the campaign DB for oPlayer +// If this is used on a player it might return a "once valid" OID, so check +// with GetIsObjectValid, do not compare to OBJECT_INVALID. +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +object SQLocalsUUID_GetObject(object oPlayer, string sVarName); +// Sets an object identifier stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to set +// * oValue - Value to store +void SQLocalsUUID_SetObject(object oPlayer, string sVarName, object oValue); +// Deletes an object identifier stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteObject(object oPlayer, string sVarName); + +// Returns a vector stored in the campaign DB for oPlayer, or [0.0, 0.0, 0.0] on error +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +vector SQLocalsUUID_GetVector(object oPlayer, string sVarName); +// Sets a vector stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to set +// * vValue - Value to store +void SQLocalsUUID_SetVector(object oPlayer, string sVarName, vector vValue); +// Deletes a vector stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteVector(object oPlayer, string sVarName); + +// Returns a location stored in the campaign DB for oPlayer, or the starting location of the module on error +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +location SQLocalsUUID_GetLocation(object oPlayer, string sVarName); +// Sets a location stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to set +// * lValue - Value to store +void SQLocalsUUID_SetLocation(object oPlayer, string sVarName, location lValue); +// Deletes a location stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteLocation(object oPlayer, string sVarName); + +// Deletes a set of locals stored in the campaign DB for oPlayer matching the given criteria +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * nType - The SQLOCALSUUID_TYPE_* you wish to remove (default: SQLOCALSUUID_TYPE_ALL) +// * sLike - The string to compare with the SQL "like" comparison +// * sEscape - The escape character to use with the SQL "escape" keyword +void SQLocalsUUID_Delete(object oPlayer, int nType = SQLOCALSUUID_TYPE_ALL, string sLike = "", string sEscape = ""); +// Counts a set of locals stored in the campaign DB for oPlayer matching the given criteria +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * nType - The SQLOCALSUUID_TYPE_* you wish to count (default: SQLOCALSUUID_TYPE_ALL) +// * sLike - The string to compare with the SQL "like" comparison +// * sEscape - The escape character to use with the SQL "escape" keyword +int SQLocalsUUID_Count(object oPlayer, int nType = SQLOCALSUUID_TYPE_ALL, string sLike = "", string sEscape = ""); +// Checks a locals stored in the campaign DB for oPlayer is set +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * nType - The SQLOCALSUUID_TYPE_* you wish to check +int SQLocalsUUID_IsSet(object oPlayer, string sVarName, int nType); +// Returns the last Unix time the given variable was updated +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * nType - The SQLOCALSUUID_TYPE_* you wish to check +int SQLocalsUUID_GetLastUpdated_UnixEpoch(object oPlayer, string sVarName, int nType); +// Returns the last UTC time the given variable was updated +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * nType - The SQLOCALSUUID_TYPE_* you wish to check +string SQLocalsUUID_GetLastUpdated_UTC(object oPlayer, string sVarName, int nType); + + +/* INTERNAL */ +void SQLocalsUUID_CreateTable() +{ + sqlquery sql = SqlPrepareQueryCampaign(SQLLOCALUUID_DATABASE_NAME, + "CREATE TABLE IF NOT EXISTS " + SQLOCALSUUID_TABLE_NAME + " (" + + "type INTEGER, " + + "uuid TEXT, " + + "varname TEXT, " + + "value TEXT, " + + "timestamp INTEGER, " + + "PRIMARY KEY(type, uuid, varname));"); + SqlStep(sql); +} + +sqlquery SQLocalsUUID_PrepareSelect(object oPlayer, int nType, string sVarName) +{ + SQLocalsUUID_CreateTable(); + + sqlquery sql = SqlPrepareQueryCampaign(SQLLOCALUUID_DATABASE_NAME, + "SELECT value FROM " + SQLOCALSUUID_TABLE_NAME + " " + + "WHERE type = @type AND uuid = @uuid AND varname = @varname;"); + + SqlBindInt(sql, "@type", nType); + SqlBindString(sql, "@uuid", GetObjectUUID(oPlayer)); + SqlBindString(sql, "@varname", sVarName); + + return sql; +} + +sqlquery SQLocalsUUID_PrepareInsert(object oPlayer, int nType, string sVarName) +{ + SQLocalsUUID_CreateTable(); + + sqlquery sql = SqlPrepareQueryCampaign(SQLLOCALUUID_DATABASE_NAME, + "INSERT INTO " + SQLOCALSUUID_TABLE_NAME + " " + + "(type, uuid, varname, value, timestamp) VALUES (@type, @uuid, @varname, @value, strftime('%s','now')) " + + "ON CONFLICT (type, uuid, varname) DO UPDATE SET value = @value, timestamp = strftime('%s','now');"); + + SqlBindInt(sql, "@type", nType); + SqlBindString(sql, "@uuid", GetObjectUUID(oPlayer)); + SqlBindString(sql, "@varname", sVarName); + + return sql; +} + +sqlquery SQLocalsUUID_PrepareDelete(object oPlayer, int nType, string sVarName) +{ + SQLocalsUUID_CreateTable(); + + sqlquery sql = SqlPrepareQueryCampaign(SQLLOCALUUID_DATABASE_NAME, + "DELETE FROM " + SQLOCALSUUID_TABLE_NAME + " " + + "WHERE type = @type AND uuid = @uuid AND varname = @varname;"); + + SqlBindInt(sql, "@type", nType); + SqlBindString(sql, "@uuid", GetObjectUUID(oPlayer)); + SqlBindString(sql, "@varname", sVarName); + + return sql; +} + +string SQLocalsUUID_LocationToString(location locLocation) +{ + string sAreaId = ObjectToString(GetAreaFromLocation(locLocation)); + vector vPosition = GetPositionFromLocation(locLocation); + float fFacing = GetFacingFromLocation(locLocation); + + return "#A#" + sAreaId + + "#X#" + FloatToString(vPosition.x, 0, 5) + + "#Y#" + FloatToString(vPosition.y, 0, 5) + + "#Z#" + FloatToString(vPosition.z, 0, 5) + + "#F#" + FloatToString(fFacing, 0, 5) + "#"; +} + +location SQLocalsUUID_StringToLocation(string sLocation) +{ + location locLocation; + + int nLength = GetStringLength(sLocation); + + if(nLength > 0) + { + int nPos, nCount; + + nPos = FindSubString(sLocation, "#A#") + 3; + nCount = FindSubString(GetSubString(sLocation, nPos, nLength - nPos), "#"); + object oArea = StringToObject(GetSubString(sLocation, nPos, nCount)); + + nPos = FindSubString(sLocation, "#X#") + 3; + nCount = FindSubString(GetSubString(sLocation, nPos, nLength - nPos), "#"); + float fX = StringToFloat(GetSubString(sLocation, nPos, nCount)); + + nPos = FindSubString(sLocation, "#Y#") + 3; + nCount = FindSubString(GetSubString(sLocation, nPos, nLength - nPos), "#"); + float fY = StringToFloat(GetSubString(sLocation, nPos, nCount)); + + nPos = FindSubString(sLocation, "#Z#") + 3; + nCount = FindSubString(GetSubString(sLocation, nPos, nLength - nPos), "#"); + float fZ = StringToFloat(GetSubString(sLocation, nPos, nCount)); + + vector vPosition = Vector(fX, fY, fZ); + + nPos = FindSubString(sLocation, "#F#") + 3; + nCount = FindSubString(GetSubString(sLocation, nPos, nLength - nPos), "#"); + float fOrientation = StringToFloat(GetSubString(sLocation, nPos, nCount)); + + if (GetIsObjectValid(oArea)) + locLocation = Location(oArea, vPosition, fOrientation); + else + locLocation = GetStartingLocation(); + } + + return locLocation; +} +/* **** */ + +/* INT */ + +// Returns an integer stored in the campaign DB for oPlayer, or 0 on error +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +int SQLocalsUUID_GetInt(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return 0; + + sqlquery sql = SQLocalsUUID_PrepareSelect(oPlayer, SQLOCALSUUID_TYPE_INT, sVarName); + + if (SqlStep(sql)) + return SqlGetInt(sql, 0); + else + return 0; +} + +// Sets an integer stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * nValue - Value to store +void SQLocalsUUID_SetInt(object oPlayer, string sVarName, int nValue) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareInsert(oPlayer, SQLOCALSUUID_TYPE_INT, sVarName); + SqlBindInt(sql, "@value", nValue); + SqlStep(sql); +} + +// Deletes an integer stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteInt(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareDelete(oPlayer, SQLOCALSUUID_TYPE_INT, sVarName); + SqlStep(sql); +} +/* **** */ + +/* FLOAT */ + +// Returns a float stored in the campaign DB for oPlayer, or 0.0 on error +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +float SQLocalsUUID_GetFloat(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return 0.0f; + + sqlquery sql = SQLocalsUUID_PrepareSelect(oPlayer, SQLOCALSUUID_TYPE_FLOAT, sVarName); + + if (SqlStep(sql)) + return SqlGetFloat(sql, 0); + else + return 0.0f; +} + +// Sets a float stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * fValue - Value to store +void SQLocalsUUID_SetFloat(object oPlayer, string sVarName, float fValue) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareInsert(oPlayer, SQLOCALSUUID_TYPE_FLOAT, sVarName); + SqlBindFloat(sql, "@value", fValue); + SqlStep(sql); +} + +// Deletes a float stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteFloat(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareDelete(oPlayer, SQLOCALSUUID_TYPE_FLOAT, sVarName); + SqlStep(sql); +} +/* **** */ + +/* STRING */ + +// Returns an string stored in the campaign DB for oPlayer, or "" on error +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +string SQLocalsUUID_GetString(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return ""; + + sqlquery sql = SQLocalsUUID_PrepareSelect(oPlayer, SQLOCALSUUID_TYPE_STRING, sVarName); + + if (SqlStep(sql)) + return SqlGetString(sql, 0); + else + return ""; +} + +// Sets a string stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * sValue - Value to store +void SQLocalsUUID_SetString(object oPlayer, string sVarName, string sValue) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareInsert(oPlayer, SQLOCALSUUID_TYPE_STRING, sVarName); + SqlBindString(sql, "@value", sValue); + SqlStep(sql); +} + +// Deletes a string stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteString(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareDelete(oPlayer, SQLOCALSUUID_TYPE_STRING, sVarName); + SqlStep(sql); +} +/* **** */ + +/* OBJECT */ + + +// Returns an object identifier stored in the campaign DB for oPlayer +// If this is used on a player it might return a "once valid" OID, so check +// with GetIsObjectValid, do not compare to OBJECT_INVALID. +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +object SQLocalsUUID_GetObject(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return OBJECT_INVALID; + + sqlquery sql = SQLocalsUUID_PrepareSelect(oPlayer, SQLOCALSUUID_TYPE_OBJECT, sVarName); + + if (SqlStep(sql)) + return StringToObject(SqlGetString(sql, 0)); + else + return OBJECT_INVALID; +} + +// Sets an object identifier stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * oValue - Value to store +void SQLocalsUUID_SetObject(object oPlayer, string sVarName, object oValue) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareInsert(oPlayer, SQLOCALSUUID_TYPE_OBJECT, sVarName); + SqlBindString(sql, "@value", ObjectToString(oValue)); + SqlStep(sql); +} + +// Deletes an object identifier stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteObject(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareDelete(oPlayer, SQLOCALSUUID_TYPE_OBJECT, sVarName); + SqlStep(sql); +} +/* **** */ + +/* VECTOR */ + +// Returns a vector stored in the campaign DB for oPlayer, or [0.0, 0.0, 0.0] on error +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +vector SQLocalsUUID_GetVector(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return [0.0f, 0.0f, 0.0f]; + + sqlquery sql = SQLocalsUUID_PrepareSelect(oPlayer, SQLOCALSUUID_TYPE_VECTOR, sVarName); + + if (SqlStep(sql)) + return SqlGetVector(sql, 0); + else + return [0.0f, 0.0f, 0.0f]; +} + +// Sets a vector stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * vValue - Value to store +void SQLocalsUUID_SetVector(object oPlayer, string sVarName, vector vValue) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareInsert(oPlayer, SQLOCALSUUID_TYPE_VECTOR, sVarName); + SqlBindVector(sql, "@value", vValue); + SqlStep(sql); +} + +// Deletes a vector stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteVector(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareDelete(oPlayer, SQLOCALSUUID_TYPE_VECTOR, sVarName); + SqlStep(sql); +} +/* **** */ + +/* LOCATION */ + +// Returns a location stored in the campaign DB for oPlayer, or the starting location of the module on error +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +location SQLocalsUUID_GetLocation(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return GetStartingLocation(); + + sqlquery sql = SQLocalsUUID_PrepareSelect(oPlayer, SQLOCALSUUID_TYPE_LOCATION, sVarName); + + if (SqlStep(sql)) + return SQLocalsUUID_StringToLocation(SqlGetString(sql, 0)); + else + return GetStartingLocation(); +} + +// Sets a location stored in the campaign DB for oPlayer to the given value +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * lValue - Value to store +void SQLocalsUUID_SetLocation(object oPlayer, string sVarName, location lValue) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareInsert(oPlayer, SQLOCALSUUID_TYPE_LOCATION, sVarName); + SqlBindString(sql, "@value", SQLocalsUUID_LocationToString(lValue)); + SqlStep(sql); +} + +// Deletes a location stored in the campaign DB for oPlayer +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to delete +void SQLocalsUUID_DeleteLocation(object oPlayer, string sVarName) +{ + if (!GetIsPC(oPlayer) || sVarName == "") return; + + sqlquery sql = SQLocalsUUID_PrepareDelete(oPlayer, SQLOCALSUUID_TYPE_LOCATION, sVarName); + SqlStep(sql); +} +/* **** */ + +/* UTILITY */ + +// Deletes a set of locals stored in the campaign DB for oPlayer matching the given criteria +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * nType - The SQLOCALSUUID_TYPE_* you wish to remove (default: SQLOCALSUUID_TYPE_ALL) +// * sLike - The string to compare with the SQL "like" comparison +// * sEscape - The escape character to use with the SQL "escape" keyword +void SQLocalsUUID_Delete(object oPlayer, int nType = SQLOCALSUUID_TYPE_ALL, string sLike = "", string sEscape = "") +{ + if (!GetIsPC(oPlayer) || nType < 0) return; + + SQLocalsUUID_CreateTable(); + + sqlquery sql = SqlPrepareQueryCampaign(SQLLOCALUUID_DATABASE_NAME, + "DELETE FROM " + SQLOCALSUUID_TABLE_NAME + " " + + "WHERE uuid = @uuid" + + (nType != SQLOCALSUUID_TYPE_ALL ? "AND type & @type " : " ") + + (sLike != "" ? "AND varname LIKE @like " + (sEscape != "" ? "ESCAPE @escape" : "") : "") + + ";"); + + SqlBindString(sql, "@uuid", GetObjectUUID(oPlayer)); + + if (nType != SQLOCALSUUID_TYPE_ALL) + SqlBindInt(sql, "@type", nType); + if (sLike != "") + { + SqlBindString(sql, "@like", sLike); + + if (sEscape != "") + SqlBindString(sql, "@escape", sEscape); + } + + SqlStep(sql); +} + +// Counts a set of locals stored in the campaign DB for oPlayer matching the given criteria +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * nType - The SQLOCALSUUID_TYPE_* you wish to count (default: SQLOCALSUUID_TYPE_ALL) +// * sLike - The string to compare with the SQL "like" comparison +// * sEscape - The escape character to use with the SQL "escape" keyword +int SQLocalsUUID_Count(object oPlayer, int nType = SQLOCALSUUID_TYPE_ALL, string sLike = "", string sEscape = "") +{ + if (!GetIsPC(oPlayer) || nType < 0) return 0; + + SQLocalsUUID_CreateTable(); + + sqlquery sql = SqlPrepareQueryObject(oPlayer, + "SELECT COUNT(*) FROM " + SQLOCALSUUID_TABLE_NAME + " " + + "WHERE uuid = @uuid " + + (nType != SQLOCALSUUID_TYPE_ALL ? "AND type & @type " : " ") + + (sLike != "" ? "AND varname LIKE @like " + (sEscape != "" ? "ESCAPE @escape" : "") : "") + + ";"); + + SqlBindString(sql, "@uuid", GetObjectUUID(oPlayer)); + + if (nType != SQLOCALSUUID_TYPE_ALL) + SqlBindInt(sql, "@type", nType); + if (sLike != "") + { + SqlBindString(sql, "@like", sLike); + + if (sEscape != "") + SqlBindString(sql, "@escape", sEscape); + } + + if (SqlStep(sql)) + return SqlGetInt(sql, 0); + else + return 0; +} + +// Checks a locals stored in the campaign DB for oPlayer is set +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * nType - The SQLOCALSUUID_TYPE_* you wish to check (default: SQLOCALSUUID_TYPE_ALL) +int SQLocalsUUID_IsSet(object oPlayer, string sVarName, int nType) +{ + if (!GetIsPC(oPlayer) || nType < 0) return 0; + + SQLocalsUUID_CreateTable(); + + sqlquery sql = SqlPrepareQueryObject(oPlayer, + "SELECT * FROM " + SQLOCALSUUID_TABLE_NAME + " " + + "WHERE uuid = @uuid " + + (nType != SQLOCALSUUID_TYPE_ALL ? "AND type & @type " : " ") + + "AND varname = @varname;"); + + SqlBindString(sql, "@uuid", GetObjectUUID(oPlayer)); + + if (nType != SQLOCALSUUID_TYPE_ALL) + SqlBindInt(sql, "@type", nType); + SqlBindString(sql, "@varname", sVarName); + + return SqlStep(sql); +} + +// Returns the last Unix time the given variable was updated +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * nType - The SQLOCALSUUID_TYPE_* you wish to check (default: SQLOCALSUUID_TYPE_ALL) +int SQLocalsUUID_GetLastUpdated_UnixEpoch(object oPlayer, string sVarName, int nType) +{ + if (!GetIsPC(oPlayer) || nType <= 0) return 0; + + SQLocalsUUID_CreateTable(); + + sqlquery sql = SqlPrepareQueryObject(oPlayer, + "SELECT timestamp FROM " + SQLOCALSUUID_TABLE_NAME + " " + + "WHERE type = @type " + + "AND uuid = @uuid" + + "AND varname = @varname;"); + + SqlBindInt(sql, "@type", nType); + SqlBindString(sql, "@uuid", GetObjectUUID(oPlayer)); + SqlBindString(sql, "@varname", sVarName); + + if (SqlStep(sql)) + return SqlGetInt(sql, 0); + else + return 0; +} + +// Returns the last UTC time the given variable was updated +// * oPlayer - a player object (uses GetObjectUUID to identify) +// * sVarName - name of the variable to retrieve +// * nType - The SQLOCALSUUID_TYPE_* you wish to check (default: SQLOCALSUUID_TYPE_ALL) +string SQLocalsUUID_GetLastUpdated_UTC(object oPlayer, string sVarName, int nType) +{ + if (!GetIsPC(oPlayer) || nType <= 0) return ""; + + SQLocalsUUID_CreateTable(); + + sqlquery sql = SqlPrepareQueryObject(oPlayer, + "SELECT datetime(timestamp, 'unixepoch') FROM " + SQLOCALSUUID_TABLE_NAME + " " + + "WHERE type = @type " + + "AND uuid = @uuid" + + "AND varname = @varname;"); + + SqlBindInt(sql, "@type", nType); + SqlBindString(sql, "@uuid", GetObjectUUID(oPlayer)); + SqlBindString(sql, "@varname", sVarName); + + if (SqlStep(sql)) + return SqlGetString(sql, 0); + else + return ""; +} \ No newline at end of file diff --git a/_module/ra_tdog.mod b/_module/ra_tdog.mod index f41bd55d..286449b6 100644 Binary files a/_module/ra_tdog.mod and b/_module/ra_tdog.mod differ diff --git a/_notes/Maps/Rappan_Athuk_Wilderness_Map.png b/_notes/Maps/Rappan_Athuk_Wilderness_Map.png new file mode 100644 index 00000000..b433e0e9 Binary files /dev/null and b/_notes/Maps/Rappan_Athuk_Wilderness_Map.png differ