Morrowind scripting: on detecting player swimming
Posted 02 May 2010 - 10:44 PM
Xiran, on 02 May 2010 - 09:37 AM, said:
What I need now is a mod that includes interiors acting as exteriors, since I don't know if the same method works for them as well. Could someone tell me what mod to download?
MerFolks by Dale Stocker & Fernelf has some submerged interiors that you could use for testing.
It is not so easy to test for player underwater in interiors, as there is not a "GetInteriorBehavingAsExterior" like function, a possible detection method in interiors is testing for player swimming sounds. Here is a (untested) example script:
begin ab01underWaterCheckScript ; interior water check based on Zappara's temperature mod script ; player must be moving / not levitating to emit splash sounds short goodWater short pcUnderWater float z1 if ( GetInterior ) if ( GetWaterLevel < -5000000 ) ; (*) interior with no water thanks to MCP water level fix set goodWater to 0 elseif ( player->GetSoundPlaying "FootWaterRight" ) set goodWater to 1 elseif ( player->GetSoundPlaying "FootWaterLeft" ) set goodWater to 1 else set goodWater to 0 endif else set goodWater to 1 endif if ( goodWater ) set z1 to ( player->GetPos Z ) set z1 to ( z1 - GetWaterLevel ) if ( z1 < -64 ) ; this is just an example, probably it would be better ; change -64 to something good for all races set pcUnderWater to 1 else set pcUnderWater to 0 endif endif float delay if ( delay > 0 ) set delay to ( delay - GetSecondsPassed ) return endif if ( pcUnderWater ) MessageBox "player under water detected" set delay to 4 endif end
Note: (*) updated to take advantage of Morrowind Code Patch revised GetWaterLevel function