Phaerus Posted April 22, 2009 Share Posted April 22, 2009 The past couple of days I finally started with the project of reinstalling all the mods I used to use in order to play the game again on my new PC. One of the mods I wanted to install was an old one, which prevents the player to swim with more than 70% encumbrance: http://tesnexus.com/downloads/file.php?id=3331, but I also noticed that I downloaded another mod with a similar effect: http://tesnexus.com/downloads/file.php?id=3430. The second also prevents the player from swimming if he wears a cuirass of any kind. However, the second mod doesn't work if I load it in the game. Also the first mod has the immersive effect of forcing the player to the bottom of the water he is swimming in, instead of merely preventing him to move any further. For these reasons, I decided to try to get the effect of the second mod into the first, and also change the setting from no cuirass to cuirasses above rating 700 and additionally all armor combinations above an accumulated rate of 1675. The first part, where the player sinks down when he's too heavily encumbered, works, but the second part, about the armor rating, doesn't. I'm a total n00b when it comes to scripting, although I worked myself through some tutorials, and I realize that probably something similar must have been covered by someone else's mod, but I would like to use this opportunity to better learn scripting. Therefore, I'd like to solve this problem regardless of whether other mods solve it, but I don't know how. Could somebody point me to what I'm doing wrong? Below is the script:Scriptname PhaerusSwimming ; Stops player swimming whilst over 70% encumbered or wearing high-rated armor ; High-rated armor is any cuirass with a rate higher than 700 or any combination ; of armor that exceeds the accumulated rate of 1675. float fQuestDelayTime ; To change script run once every 2 seconds short encumbrance ; will hold current encumbrance short maxEncumbrance ; we'll set this to 5 * strength short encumbered ; calculated % encumbered short burdened ; 1 if player is currently not able to swim short armed ; 1 or 2 if the player carries high-rated armor ref refObj ; ref to an obj we'll use to find water bottom begin gameMode set fQuestDelayTime to 2 ; Check encumbrance while player swims if (Player.isSwimming == 1) set encumbrance to player.getAV ENCUMBRANCE set maxEncumbrance to ((player.getAV STRENGTH) * 5) set encumbered to ((maxEncumbrance - encumbrance) / maxEncumbrance ) * 100 if (encumbered < 30 && burdened == 0) message "You are carrying too much to be able to swim!!", 5 set burdened to 1 player.setRestrained 1 set refObj to Player.PlaceAtMe BUGLESwimAid 1, 5, 1 elseif (encumbered >= 30 && burdened == 1) message "Your encumbrance is low enough to swim now.", 5 player.setRestrained 0 set burdened to 0 refObj.disable endif if (player.GetArmorRating > 1675 && armed == 0) message "You cannot swim while wearing such high-rated armor!", 5 set armed to 1 player.setRestrained 1 set refObj to Player.PlaceAtMe BUGLESwimAid 1, 5, 1 if (player.GetArmorRatingupperbody >= 700 && armed <= 1) message "You cannot swim while wearing such a high-rated cuirass!", 5 set armed to 2 player.setRestrained 1 set refObj to Player.PlaceAtMe BUGLESwimAid 1, 5, 1 endif elseif (player.GetArmorRating <= 1675 && player.GetArmorRatingupperbody < 700 && armed >= 1) message "Your current fittings are appropriate for swimming." player.setRestrained 0 set armed to 0 refObj.disable endif endif end Looking through the information pages of the CS Wiki, I noted that the script uses several oldfashioned ways of scripting, such as the PlaceAtMe command. I rely on those because the original NoEncumberedSwimming mod relied on them and since my first concern is to get it all working, I haven't looked yet into scripting that in a more modern way. Link to comment Share on other sites More sharing options...
jonesjoshuar Posted April 22, 2009 Share Posted April 22, 2009 short encumbrance ; will hold current encumbranceshort maxEncumbrance ; we'll set this to 5 * strengthshort encumbered ; calculated % encumberedshort burdened forgive me if im wrong, but when dealing with potential fractions it should be floats? shorts will drop the remainers. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.