Fog of war script
PostPosted: 04 Jul 2013, 11:57
Hello. I just wanted to share my Fog of War script. Currently, it works for fight maps only (buildings probably don't reveal the map, and I'm unsure whether it would work fast enough). The code is quite... lame, I would say, but I believe there's no better way to implement FOW at the moment.
Also, I uploaded an example of a map (I used Enter the Heat, with TDL's permission) that works with the mode. The only changes to the map were making it a special map and obviously adding the script - it should work on any fight map though.
- Code:
procedure RevealFog(Units: array of Integer; P: Integer); var I, X, Y: Integer; begin for I := 0 to (Length(Units)-1) do begin X := States.UnitPositionX(Units[I]); Y := States.UnitPositionY(Units[I]); Actions.FogRevealCircle(P, X, Y, 9); end; end; procedure OnMissionStart; var P: Integer; begin for P := 0 to 7 do Actions.FogCoverAll(P); end; procedure OnTick; var P, R: Integer; var Units, Units2: array of Integer; begin for P := 0 to 7 do if ( (States.GameTime + P) mod 10 = 0) and (not(States.PlayerDefeated(P))) then begin Actions.FogCoverAll(P); Units := States.PlayerGetAllUnits(P); RevealFog(Units, P); for R := 0 to 7 do begin if States.PlayerAllianceCheck(P,R) then begin Units2 := States.PlayerGetAllUnits(R); RevealFog(Units2, P); end; end; end; end; procedure OnPlayerDefeated(P: Integer); var I: Integer; begin Actions.FogRevealAll(P); end;