Try some log messages to see what is actually being executed:
That will log the different events both to the screen and into compile.log so you can check back later.
Code:
if(CheckAttribute(chr, "ship.SubmergeDutchman"))
{
TraceAndLog("Setting visibility to 0 for submerged Dutchman");
visibility_range = 0; // Making FD invisible when submerged
chr.ship.OldVis = visibility_range;
}
else
{
CheckAttribute(chr.ship,"OldVis")
{
TraceAndLog("Setting visibility back to original after emerging Dutchman");
visibility_range = chr.ship.OldVis;
}
else
{
TraceAndLog("Restoring default visibility");
visibility_range = 3000.0;
}
}