Jump to content

Need Scripting Help


apocalypse1138

Recommended Posts

I'm scripting an item when equipped, gives the player the ability to swim twice as fast using the SwimSpeedMultiplier AV. I think I have gone wrong somewhere as it has no effect as of yet... So what I am doing wrong and what do I need to do to fix it?

 

Here is my current script...

 

scn SwiftSwimItem

Begin OnEquip Player

Message "You can now swim twice as fast!", 5

Player.SetActorValue SwimSpeedMultiplier 2

End

Begin OnUnEquip Player

Message "You can no longer swim twice as fast...", 5

Player.SetActorValue SwimSpeedMultiplier 1

End

 

Thank you for your time and help in advance.

Link to comment
Share on other sites

I'm not really sure what is wrong, but here is a suggestions. The player might have already increased their SwimSpeedModifier elsewhere, so do something like this instead:

 

scn SwiftSwimItem
short origValue

Begin OnEquip Player

set origValue to player.GetActorValue SwimSpeedMultiplier
Message "You can now swim twice as fast!", 5
player.SetActorValue SwimSpeedMultiplier (origValue*2)

End

Begin OnUnEquip Player

Message "You can no longer swim twice as fast...", 5
player.SetActorValue SwimSpeedMultiplier origValue

End

 

Not sure if this will help you, but it was worth a shot

Link to comment
Share on other sites

That sounds good, if it is indeed a variable problem ( the 1 & 2 that I am using)... I will give it a shot and let you know if it works.

 

**I have gotten a warning that (OrigValue*2) is not a valid amount, and it doesn't save***

 

set up a new variable called something like newValue that equals (origValue*2). So the code would look something like this:

 

set origValue to player.GetActorValue SwimSpeedMultiplier

set newValue to (origValue*2)

Message "You can now swim twice as fast!", 5

player.SetActorValue SwimSpeedMultiplier newValue

 

Also, check your capitilizations. I'm not sure if it matters in the CS, but when programming for real it matters a lot...

Link to comment
Share on other sites

It seems that changing the swim speed has no effect, checked the speeds in the debug I changed the multiplier to 200 as 2 has almost no effect, so the new multiplier changed swim speed from 60 to about 180... so how would I make it so it increases the speed attribute by 100 while swimming or something like that?

 

Caps I believe have no effect, at least when I was lava-proofing...

Link to comment
Share on other sites

I'm not really sure what is wrong, but here is a suggestions. The player might have already increased their SwimSpeedModifier elsewhere, so do something like this instead:

 

*snip*

 

Not sure if this will help you, but it was worth a shot

Think what you are looking for is something more like

 

scn SwiftSwimItem
short worn
float origValue
float origval2

Begin OnEquip Player

set origValue to player.GetActorValue SwimSpeedMultiplier
Message "You can now swim faster"
set worn to 1
set origval2 to origvalue * 2
player.SetActorValue SwimSpeedMultiplier origval2

End

Begin OnUnEquip Player

if worn == 1
Message "You can no longer swim twice fast..."
player.SetActorValue SwimSpeedMultiplier origValue
set worn to 0
endif
End

Begin Ondrop Player
if worn == 1
player.SetActorValue SwimSpeedMultiplier origValue
set worn to 0
End[b][/b]

 

Changed the variable to a float since it may make use of decimal values. Math stuff does not work for all variables, and should usually be performed separately with a space between clauses. The effect may not be a perfect doubling of speed due to how the value may be getting used, so adjusted the messages appropriately. You may even need to go back and change it to multiply by 1.5 (other reason for using float) or some other value to get it to work right with high athletics/speed stats. Added a ondrop blocktype as a sort of backup value incase the unequip block doesn't get triggered. Added a control variable to make sure it is only adjusted once.

 

This stat may not be used by the game any more since it was a remnant from Morrowind, so an alternative would be to use an ability that gets applied when swimming with fortifications to athletics and/or speed. It's a bit more complicated to do, but is less likely to interfere with other mods.

Link to comment
Share on other sites

That sounds good, if it is indeed a variable problem ( the 1 & 2 that I am using)... I will give it a shot and let you know if it works.

 

**I have gotten a warning that (OrigValue*2) is not a valid amount, and it doesn't save***

 

set up a new variable called something like newValue that equals (origValue*2). So the code would look something like this:

 

set origValue to player.GetActorValue SwimSpeedMultiplier

set newValue to (origValue*2)

Message "You can now swim twice as fast!", 5

player.SetActorValue SwimSpeedMultiplier newValue

 

Also, check your capitilizations. I'm not sure if it matters in the CS, but when programming for real it matters a lot...

Ah, dang. I haven't modded for ages, and now it's all coming back!

 

Try something like this:

scn SwiftSwimItem
float origValue

Begin OnEquip Player
 set origValue to player.GetActorValue SwimSpeedMultiplier
 set newVal to OrigValue * 2
 Message "You can now swim twice as fast!", 5
 player.SetActorValue SwimSpeedMultiplier newVal
End

Begin OnUnequip Player
 if (player.GetActorValue SwimSpeedMultiplier - newVal == 0) then
player.SetActorValue SwimSpeedMultiplier origValue
 else
set newVal to (newval / 2)
player.SetActorValue SwimSpeedMultiplier newVal
 endif
End

Link to comment
Share on other sites

Since you guys might not notice my new post I'll put an explenation here...

 

The swim speed does not change much with the multiplier at 2... The debug showed it at a change from 60 to 62. With the multiplier at 200... It changed it from 60 to 180. Still no effect though. It doesn't really make a whole lot of sence... but what If when the player had the item equipped, and when swimming, increased speed by 100, or whatever amount would achieve the desired affect. Perhaps a *2, but right now I'm going to settle for a simple faster, yet notably faster.

 

P.S. A bit off-topic, but how do you change your title... Like "Veteran" to a custom one?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...