Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Persistent Minimap with GetTileExplored & SetTileExplored

HimmelweissHimmelweiss Member Posts: 72
edited February 2019 in Builders - Scripting
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.

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
dunahan
Sign In or Register to comment.