Persistent Minimap with GetTileExplored & SetTileExplored
Himmelweiss
Member Posts: 72
So, yesterday i was bored and played arround with the functions GetTileExplored & SetTileExplored so i am justly simply sharing it here.
Script is supposed to run for the Events "Area OnEnter/OnExit" and "Module OnPlayerRest".
So it saves the minimap vision/fogofwar state of the current area to the bio db on every area enter/exit and player rest.
Take/use it at your own risk because it was just a quick test, didn't really run an super hard test cycle with it.
Script is supposed to run for the Events "Area OnEnter/OnExit" and "Module OnPlayerRest".
So it saves the minimap vision/fogofwar state of the current area to the bio db on every area enter/exit and player rest.
Take/use it at your own risk because it was just a quick test, didn't really run an super hard test cycle with it.
const string MINIMAP_DB = "minimap_db";
void main()
{
object oArea = OBJECT_SELF;
object oPC = GetEnteringObject();
if (oPC == OBJECT_INVALID)
oPC = GetExitingObject();
if (oPC == OBJECT_INVALID) {
oPC = GetLastPCRested();
oArea = GetArea(oPC);
}
if(!GetIsPC(oPC)) return;
int iAreaHeight = GetAreaSize(AREA_HEIGHT, oArea);
int iAreaWidth = GetAreaSize(AREA_WIDTH, oArea);
string sAreaResRef = GetResRef(oArea);
string sMap = GetCampaignString(MINIMAP_DB, sAreaResRef, oPC);
string sX;
string sY;
struct sStringTokenizer stTok = GetStringTokenizer(sMap, ",");
while (HasMoreTokens(stTok)) {
stTok = AdvanceToNextToken(stTok);
sX = GetNextToken(stTok);
stTok = AdvanceToNextToken(stTok);
sY = GetNextToken(stTok);
SetTileExplored(oPC, oArea, StringToInt(sX), StringToInt(sY), 1);
//SendMessageToPC(oPC, "explored sX: " + sX + " / sY: " + sY);
}
sMap="";
int x;
int y;
for (x = 0; x < iAreaWidth; x++)
{
for (y = 0; y < iAreaHeight; y++)
{
if (GetTileExplored(oPC, oArea, x, y))
{
sMap += IntToString(x)+","+IntToString(y)+",";
}
}
}
SetCampaignString(MINIMAP_DB, sAreaResRef, sMap, oPC);
}
Post edited by Himmelweiss on
2
Comments
I removed a few extraneous braces and made the layout of a few of the lines consistent with the rest of the code.
TR