Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //a script for replenishing mines
- //when game starts, it search the map and saves positions and tile numbers of all mineable tiles
- //during the game, it replaces mineable tiles with starting tiles when called,
- //effectively restoring mined tiles
- //should be compatible with about any map
- //no idea if there was something like an "onTileChanged" event at the time of writing
- //that would allow a much cleaner and faster script
- //this script can make map loading several seconds longer and
- //cause a minor "hiccup" every time replenishing is called
- var
- infminOptions: array [1..27] of integer; //these variables are used in the script (copy and paste them under var)
- infminTiles: array [1..256] of array [1..256] of array [1..4] of integer;
- infmini1,infmini2,infmini3: integer;
- infminp1,infminp2: integer;
- //Following 2 procedures replenish mines, insert them between variables and game procedures that call them
- Procedure SetInfiniteMines; //this procedure saves the original state of the map
- begin
- for infmini1:= 1 to 14 do
- begin
- infminOptions [infmini1]:=infmini1+127;
- end;
- infminOptions [14]:=195;
- for infmini1:= 1 to 12 do
- begin
- infminOptions [infmini1+15]:=infmini1+143;
- end;
- infminp1:=1;
- infminp2:=1;
- for infmini1:=1 to States.MapWidth-1 do
- for infmini2:=1 to States.MapHeight-1 do
- begin
- for infmini3:=1 to 27 do
- if (States.MapTileType(infmini1,infmini2) = infminOptions [infmini3]) then
- begin
- infminTiles[infminp1][infminp2][1]:=infmini1;
- infminTiles[infminp1][infminp2][2]:=infmini2;
- infminTiles[infminp1][infminp2][3]:=States.MapTileType(infmini1,infmini2);
- infminTiles[infminp1][infminp2][4]:=States.MapTileRotation(infmini1,infmini2);
- infminp2:=infminp2+1;
- end;
- if (infminp2 = States.MapWidth-1) then
- begin
- infminp2:=1;
- infminp1:=infminp1+1;
- end;
- end;
- end;
- Procedure ReplenishMines; //this procedure restores the original state of the map
- begin
- if infminp1 = 1 then
- begin
- for infmini1:=1 to infminp2 do
- begin
- Actions.MapTileSet (infminTiles[1][infmini1][1],infminTiles[1][infmini1][2],infminTiles[1][infmini1][3],infminTiles[1][infmini1][4]);
- end;
- end;
- if infminp1 <> 1 then
- begin
- for infmini1:=1 to (infminp1-1) do
- for infmini2:=1 to States.MapWidth-1 do
- begin
- Actions.MapTileSet (infminTiles[infmini1][infmini2][1],infminTiles[infmini1][infmini2][2],infminTiles[infmini1][infmini2][3],infminTiles[infmini1][infmini2][4]);
- end;
- for infmini2:=1 to infminp2 do Actions.MapTileSet (infminTiles[infminp1][infmini2][1],infminTiles[infminp1][infmini2][2],infminTiles[infminp1][infmini2][3],infminTiles[infminp1][infmini2][4]);
- end;
- end;
- //these 2 procedures need to be called in game's procedures to do their job
- procedure OnMissionStart;
- begin
- SetInfiniteMines; //has to be called before replenishing starts
- end;
- procedure OnTick;
- begin
- if (States.GameTime mod 300 = 5) then //every 30 seconds (300 ticks), can be set to whatever map maker wants
- ReplenishMines;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement