Skip to content

Commit

Permalink
Merge pull request #789 from Logg-y/master
Browse files Browse the repository at this point in the history
Treasure map update, stats database migration and performance tweaks
  • Loading branch information
Logg-y authored Aug 7, 2023
2 parents e2394ed + 7a9dd97 commit 344168d
Show file tree
Hide file tree
Showing 39 changed files with 1,720 additions and 160 deletions.
2 changes: 2 additions & 0 deletions linux_run_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ rm server/database/treasures.sqlite3
rm server/database/spawns.sqlite3
rm server/database/prettify.sqlite3
rm server/database/tmapsolutions.sqlite3
rm server/database/areadistances.sqlite3

mkdir server/override
mkdir server/config
Expand All @@ -48,6 +49,7 @@ cp seeded_database/treasures.sqlite3 server/database/treasures.sqlite3
cp seeded_database/randspellbooks.sqlite3 server/database/randspellbooks.sqlite3
cp seeded_database/prettify.sqlite3 server/database/prettify.sqlite3
cp seeded_database/tmapsolutions.sqlite3 server/database/tmapsolutions.sqlite3
cp seeded_database/areadistances.sqlite3 server/database/areadistances.sqlite3

cp server/env/env.2da server/override/env.2da
cp server/env/env_dm.2da server/override/env_dm.2da
Expand Down
2 changes: 2 additions & 0 deletions linux_run_server_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ rm database/treasures.sqlite3
rm database/spawns.sqlite3
rm database/prettify.sqlite3
rm database/tmapsolutions.sqlite3
rm database/areadistances.sqlite3

cp seeded_database/spawns.sqlite3 database/spawns.sqlite3
cp seeded_database/treasures.sqlite3 database/treasures.sqlite3
cp seeded_database/randspellbooks.sqlite3 database/randspellbooks.sqlite3
cp seeded_database/prettify.sqlite3 database/prettify.sqlite3
cp seeded_database/tmapsolutions.sqlite3 database/tmapsolutions.sqlite3
cp seeded_database/areadistances.sqlite3 database/areadistances.sqlite3

docker-compose -f docker-compose-dev.yml down
docker-compose -f docker-compose-dev.yml up --no-recreate -d
2 changes: 2 additions & 0 deletions linux_run_server_dev_seed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ rm seeded_database/randspellbooks.sqlite3
rm seeded_database/treasures.sqlite3
rm seeded_database/spawns.sqlite3
rm seeded_database/prettify.sqlite3
rm seeded_database/areadistances.sqlite3
rm seeded_database/tmapsolutions.sqlite3

cp database/spawns.sqlite3 seeded_database/spawns.sqlite3
cp database/treasures.sqlite3 seeded_database/treasures.sqlite3
cp database/randspellbooks.sqlite3 seeded_database/randspellbooks.sqlite3
cp database/prettify.sqlite3 seeded_database/prettify.sqlite3
cp database/areadistances.sqlite3 seeded_database/areadistances.sqlite3
cp database/tmapsolutions.sqlite3 seeded_database/tmapsolutions.sqlite3
Binary file added seeded_database/areadistances.sqlite3
Binary file not shown.
Binary file modified seeded_database/prettify.sqlite3
Binary file not shown.
Binary file modified seeded_database/randspellbooks.sqlite3
Binary file not shown.
Binary file modified seeded_database/spawns.sqlite3
Binary file not shown.
Binary file modified seeded_database/tmapsolutions.sqlite3
Binary file not shown.
Binary file modified seeded_database/treasures.sqlite3
Binary file not shown.
15 changes: 15 additions & 0 deletions src/git/icelakes.git.json
Original file line number Diff line number Diff line change
Expand Up @@ -13225,6 +13225,21 @@
"type": "cexostring",
"value": "polar"
}
},
{
"__struct_id": 0,
"Name": {
"type": "cexostring",
"value": "connection1"
},
"Type": {
"type": "dword",
"value": 3
},
"Value": {
"type": "cexostring",
"value": "river_mirar"
}
}
]
},
Expand Down
31 changes: 23 additions & 8 deletions src/git/lith.git.json
Original file line number Diff line number Diff line change
Expand Up @@ -19454,7 +19454,7 @@
},
"Cost": {
"type": "dword",
"value": 7
"value": 0
},
"Cursed": {
"type": "byte",
Expand Down Expand Up @@ -20544,7 +20544,7 @@
},
"Cost": {
"type": "dword",
"value": 7
"value": 0
},
"Cursed": {
"type": "byte",
Expand Down Expand Up @@ -21804,7 +21804,7 @@
},
"Cost": {
"type": "dword",
"value": 7
"value": 0
},
"Cursed": {
"type": "byte",
Expand Down Expand Up @@ -22894,7 +22894,7 @@
},
"Cost": {
"type": "dword",
"value": 7
"value": 0
},
"Cursed": {
"type": "byte",
Expand Down Expand Up @@ -24154,7 +24154,7 @@
},
"Cost": {
"type": "dword",
"value": 7
"value": 0
},
"Cursed": {
"type": "byte",
Expand Down Expand Up @@ -25244,7 +25244,7 @@
},
"Cost": {
"type": "dword",
"value": 7
"value": 0
},
"Cursed": {
"type": "byte",
Expand Down Expand Up @@ -26473,7 +26473,7 @@
},
"Cost": {
"type": "dword",
"value": 7
"value": 0
},
"Cursed": {
"type": "byte",
Expand Down Expand Up @@ -27563,7 +27563,7 @@
},
"Cost": {
"type": "dword",
"value": 7
"value": 0
},
"Cursed": {
"type": "byte",
Expand Down Expand Up @@ -98474,6 +98474,21 @@
"type": "int",
"value": 1
}
},
{
"__struct_id": 0,
"Name": {
"type": "cexostring",
"value": "connection1"
},
"Type": {
"type": "dword",
"value": 3
},
"Value": {
"type": "cexostring",
"value": "ud_maker1"
}
}
]
},
Expand Down
15 changes: 15 additions & 0 deletions src/git/river_mirar.git.json
Original file line number Diff line number Diff line change
Expand Up @@ -10327,6 +10327,21 @@
"type": "cexostring",
"value": "highland"
}
},
{
"__struct_id": 0,
"Name": {
"type": "cexostring",
"value": "connection1"
},
"Type": {
"type": "dword",
"value": 3
},
"Value": {
"type": "cexostring",
"value": "icelakes"
}
}
]
},
Expand Down
19 changes: 17 additions & 2 deletions src/git/ud_maker1.git.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
},
"Cost": {
"type": "dword",
"value": 1579
"value": 105299
},
"Cursed": {
"type": "byte",
Expand Down Expand Up @@ -1941,7 +1941,7 @@
},
"Cost": {
"type": "dword",
"value": 1579
"value": 105299
},
"Cursed": {
"type": "byte",
Expand Down Expand Up @@ -53709,6 +53709,21 @@
"type": "cexostring",
"value": "ud_maker4"
}
},
{
"__struct_id": 0,
"Name": {
"type": "cexostring",
"value": "connection1"
},
"Type": {
"type": "dword",
"value": 3
},
"Value": {
"type": "cexostring",
"value": "lith"
}
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/nss/0e_load_menu.nss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "0i_win_layouts"
#include "0i_database"

void main ()
void main()
{
string sKey = GetPCPublicCDKey(OBJECT_SELF, TRUE);
if (GetCampaignInt(sKey, "pc_menu_disabled") != 1)
Expand Down
4 changes: 2 additions & 2 deletions src/nss/area_hb.nss
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ void main()
if (nFurthestLinkedAreaOffRefresh > 0 && nFurthestLinkedAreaOffRefresh < REFRESH_HEARTBEAT_COUNT)
{
// Waiting for another area doesn't affect our refresh counter, so don't spam the log too hard with this
//if (nRefresh % 20 == 0)
if (1)
if (nRefresh % 20 == 0)
//if (1)
{
SendDebugMessage("Can't refresh " + sResRef + " due to linked area not being ready, furthest count = " + IntToString(nFurthestLinkedAreaOffRefresh), TRUE);
}
Expand Down
55 changes: 55 additions & 0 deletions src/nss/area_init.nss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#include "inc_debug"
#include "util_i_csvlists"
#include "nwnx_area"
Expand Down Expand Up @@ -265,12 +266,32 @@ void main()
int nHighGold = GetLocalInt(oModule, "placeable_value_high_" + sACR);
json jKeepTreasures = JsonArray();

int nNextTransitionIndex = 1;
while (1)
{
if (GetLocalString(oArea, "connection" + IntToString(nNextTransitionIndex)) == "")
{
break;
}
nNextTransitionIndex++;
}

int nThisTreasureGold;

// Loop through all objects in the area and do something special with them
while (GetIsObjectValid(oObject))
{
nType = GetObjectType(oObject);

// The warden tele script is used... for more things that just wardens now
// Doors and placeables can have it too!
string sWardenTeleWP = GetLocalString(oObject, "warden_tele_wp");
if (sWardenTeleWP != "" && GetIsObjectValid(GetObjectByTag(sWardenTeleWP)))
{
object oTargetArea = GetArea(GetObjectByTag(sWardenTeleWP));
SetLocalString(oArea, "connection" + IntToString(nNextTransitionIndex), GetResRef(oTargetArea));
nNextTransitionIndex++;
}

// tag merchants/quest NPCs that are plot/immortal as dm_immune
// these types should never be skipped
Expand Down Expand Up @@ -365,6 +386,11 @@ void main()

// all doors are plot
SetPlotFlag(oObject, TRUE);
if (GetIsObjectValid(GetTransitionTarget(oObject)))
{
SetLocalString(oArea, "connection" + IntToString(nNextTransitionIndex), GetResRef(GetArea(GetTransitionTarget(oObject))));
nNextTransitionIndex++;
}

if (GetStringLeft(GetResRef(oObject), 5) != "_home")
{
Expand Down Expand Up @@ -552,6 +578,15 @@ void main()
SetPlotFlag(oObject, TRUE);
}
break;
case OBJECT_TYPE_TRIGGER:
{
if (GetIsObjectValid(GetTransitionTarget(oObject)))
{
SetLocalString(oArea, "connection" + IntToString(nNextTransitionIndex), GetResRef(GetArea(GetTransitionTarget(oObject))));
nNextTransitionIndex++;
}
break;
}
}
oObject = GetNextObjectInArea(oArea);
}
Expand Down Expand Up @@ -616,6 +651,26 @@ void main()
}
SendDebugMessage(sResRef+" loaded trap spawn points: "+IntToString(nTrapSpawnPoints), TRUE);
}

// Connections: rewrite these to make sure there aren't any duplicates
// The area distance graph calculation is already bad enough, don't make it worse!
json jConnections = JsonArray();
for (i=1; i<nNextTransitionIndex; i++)
{
string sConnection = GetLocalString(oArea, "connection" + IntToString(i));
DeleteLocalString(oArea, "connection" + IntToString(i));
if (JsonFind(jConnections, JsonString(sConnection)) == JsonNull())
{
jConnections = JsonArrayInsert(jConnections, JsonString(sConnection));
}
}
WriteTimestampedLogEntry("Area connections (found " + IntToString(nNextTransitionIndex-1) + " transitions total): " + JsonDump(jConnections));
int nLength = JsonGetLength(jConnections);
for (i=1; i<=nLength; i++)
{
string sConnect = JsonGetString(JsonArrayGet(jConnections, i-1));
SetLocalString(oArea, "connection" + IntToString(i), sConnect);
}

//==========================================
// SET AREA AS INITIALIZED
Expand Down
2 changes: 1 addition & 1 deletion src/nss/dev_allarealoot.nss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// this script may take a while to run, spot check certain areas only
// note, the global column won't be that accurate if this is the case
const int LIMITED_SAMPLE_SIZE = 0;
const int LIMITED_SAMPLE_SIZE = 1;

void RunOnArea(object oDev, json jAreas, int nState=0)
{
Expand Down
22 changes: 20 additions & 2 deletions src/nss/dev_test.nss
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
#include "nui_playerstats"
#include "inc_treasuremap"
#include "inc_loot"

void main()
{
ShowPlayerStatsUI(GetFirstPC());

int nStart = GetMicrosecondCounter();
object oMap = SetupProgenitorTreasureMap(12, GetArea(OBJECT_SELF), 1);
CopyTierItemToObjectOrLocation(oMap, OBJECT_SELF);
SendDebugMessage("time = " + IntToString(GetMicrosecondCounter() - nStart));

/*
sqlquery sql = SqlPrepareQueryCampaign("areadistances", "EXPLAIN QUERY PLAN SELECT areadest from areadists " +
"WHERE areasource = @areasource AND distance <= @distance;");
SqlBindString(sql, "@areasource", GetTag(GetArea(GetFirstPC())));
SqlBindInt(sql, "@distance", 1000);
SqlStep(sql);
SpeakString(SqlGetString(sql, 0));
SpeakString(SqlGetString(sql, 1));
SpeakString(SqlGetString(sql, 2));
SpeakString(SqlGetString(sql, 3));
*/

}
15 changes: 10 additions & 5 deletions src/nss/dlg_andriel_act.nss
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ void main()
IncrementPlayerStatistic(oPC, "items_bought");

int nACR = GetHitDice(oPC);
int nVariability = GetHitDice(oPC) / 4;
// ACR of map = HD � HD/4 rounded down
nACR = nACR + 1 + Random(nVariability*2) - nVariability;

object oMap = SetupProgenitorTreasureMap(nACR, "Highcliff. It was purchased from " + GetName(OBJECT_SELF));
// ACR of map = HD +/- 1
nACR = nACR + Random(3) - 1;

object oMap = SetupProgenitorTreasureMap(nACR, GetArea(OBJECT_SELF), 0, "It was purchased from " + GetName(OBJECT_SELF) +": there is no telling where it was originally from, nor where the treasure might be.");
// Andriel's altered map difficulty
int nRoll = d100();
if (nRoll <= 80) { SetTreasureMapDifficulty(oMap, TREASUREMAP_DIFFICULTY_HARD); }
else if (nRoll <= 85) { SetTreasureMapDifficulty(oMap, TREASUREMAP_DIFFICULTY_MEDIUM); }
else if (nRoll <= 90) { SetTreasureMapDifficulty(oMap, TREASUREMAP_DIFFICULTY_EASY); }
else { SetTreasureMapDifficulty(oMap, TREASUREMAP_DIFFICULTY_MASTER); }
CopyTierItemToObjectOrLocation(oMap, oPC);
SQLocalsPlayer_SetInt(oPC, "andriel_lastbuy", SQLite_GetTimeStamp());
}
Loading

0 comments on commit 344168d

Please sign in to comment.