/*//////////////////////////////////////////////////////////////////// zone_info.vc created by Ben Lindley December 17, 2006 Usage: Put UpdateZoneInfo() into the startup script of your map and it will update the zone_info array with the zone info for the current map. One instance where I think this would be useful is if you have your own movement engine that doesn't use the player set by SetPlayer(). You could use this zone_info to call zone scripts based on the entity you want to control. For Example: void CallZoneScriptForEntity(int ent) { int e_tx, e_ty, e_zn; e_tx = entity.x[ent] >> 4; // the tile this entity is on e_ty = entity.y[ent] >> 4; e_zn = GetZone(e_tx,e_ty); // the zone this entity is in if((e_zn) && // if not zone 0 (Random(0,254) < zone_info[e_zn].percent) && // and we meet the probability (FunctionExists(zone_info[e_zn].script)) ) // and the zone's script exists CallFunction(zone_info[e_zn].script); // call the zone's script } ////////////////////////////////////////////////////////////////////*/ ////////////////////////////////////////////////////////////////////// struct struct_zone_info { string name; string script; int adj_act; int percent; int delay; } struct_zone_info zone_info[256]; int numzones; void UpdateZoneInfo() { if(!strcmp(curmap.path,"")) { exit("UpdateZoneInfo cannot be called unless there is a map loaded!"); } int f,skip,numlayers; f = FileOpen(curmap.path,FILE_READ); FileSeekPos(f,1298,SEEK_CUR); // skip to the layer data numlayers = FileReadQuad(f); while(numlayers) { FileSeekPos(f,281,SEEK_CUR); FileSeekPos(f,FileReadQuad(f),SEEK_CUR); numlayers--; } FileSeekPos(f,4,SEEK_CUR); skip = FileReadQuad(f); // how much space does layer data take up FileSeekPos(f,skip + 4,SEEK_CUR); // skip layer data and header for zone layer data skip = FileReadQuad(f); // how much space does zone layer data take up FileSeekPos(f,skip,SEEK_CUR); // skip zone layer data numzones = FileReadQuad(f); // read the zone info in, everything above was just for skipping to this int z,c; for(z=0; z0) { zone_info[z].name = zone_info[z].name + chr(c); c = FileReadByte(f); } FileSeekPos(f,255-len(zone_info[z].name),SEEK_CUR); c = FileReadByte(f); while(c>0) { zone_info[z].script = zone_info[z].script + chr(c); c = FileReadByte(f); } FileSeekPos(f,255-len(zone_info[z].script),SEEK_CUR); zone_info[z].percent = FileReadByte(f); zone_info[z].delay = FileReadByte(f); zone_info[z].adj_act = FileReadByte(f); } FileClose(f); } void logZoneInfo() { log("Zone info for " + curmap.path); log("================================"); log("Numzones: " + str(numzones)); int i; for(i=0; i