Could someone please take a look at this script

Post » Fri Feb 18, 2011 9:13 pm

The script works, as far as debugging goes (I've left some prtinc's in there), but I don't notice a difference in my speed. It is a simple script designed to make you sprint. But when I satisfy all the conditions to sprint, I don't notice a difference in my speed in-game. Is it because I have the speed boost from sprinting set too low? It seems to be a reasonable amount. I should say, fatigue gets deducted as it should, but I don't notice any speed physical increases.

ScriptName aaaLSSprintScriptfloat fQuestDelayTimeshort vSprintKeyshort sSpeedBoostshort sHAPenaltyshort sIsSprintingshort sFatigueCheckshort vUserBoostshort sBoostBegin GameMode				Set fQuestDelayTime to 0.1	Set vSprintKey to aaaLSVariables.sSprintKey	Set vUserBoost to aaaLSVariables.sUserBoost		If (IsKeyPressed3 vSprintKey) && (IsKeyPressed3 17 || IsKeyPressed3 30 || IsKeyPressed3 32) && (Player.IsSwimming == 0 && Player.IsSneaking == 0) && (Player.GetFatiguePercentage > 0.15)		Set sIsSprinting to 1		Set sBoost to 1		If sBoost == 1			Set sSpeedBoost to vUserBoost			If sSpeedBoost == 100 || sSpeedBoost == 125 || sSpeedBoost == 150				Player.ModActorValue2 Speed sSpeedBoost			Else 				Player.ModActorValue2 Speed 100			EndIf						If Player.GetActorValue Speed >= 254				Player.SetActorValue Speed 254			EndIf			PrintC "Key %.0f Speed %.0f", vSprintKey sSpeedBoost						Set sHAPenalty to Player.GetBaseAV2 HeavyArmor / 2			Player.ModActorValue2 HeavyArmor sHAPenalty		EndIf				Player.ModActorValue2 Fatigue -10		If Player.GetBaseAV2 Athletics >= 150						Player.ModActorValue2 Fatigue 5		EndIf		Return	Else		If sSpeedBoost != 0			Set sHAPenalty to Player.GetBaseAV2 HeavyArmor * 2			Player.ModActorValue2 HeavyArmor sHAPenalty			Set sHAPenalty to 0			Set sSpeedBoost to 0			Set sBoost to 0		EndIf	EndIf	End


Would appreciate some insight.
Thanks.
User avatar
TOYA toys
 
Posts: 3455
Joined: Sat Jan 13, 2007 4:22 am

Post » Fri Feb 18, 2011 11:06 pm

I posted the above while I was in the middle of troubleshooting. I debugged some more, and for some reason, the PC speed attribute is not getting modified.
User avatar
Mandi Norton
 
Posts: 3451
Joined: Tue Jan 30, 2007 2:43 pm

Post » Sat Feb 19, 2011 12:17 am

Do you ever see your console message?
User avatar
Laura
 
Posts: 3456
Joined: Sun Sep 10, 2006 7:11 am

Post » Fri Feb 18, 2011 10:12 pm

Yes. I figured it out. Apparently there a limitation to ModActorValue2. It can only be used for skills, not attributes. I used the vanilla function, ModActorValue, and all works fine.

Thanks.
User avatar
john palmer
 
Posts: 3410
Joined: Fri Jun 22, 2007 8:07 pm

Post » Fri Feb 18, 2011 10:32 pm

Where did that come from? Looking at the docs on both the CS wiki, and the OBSE documentation page, neither mentions that little tidbit.
User avatar
k a t e
 
Posts: 3378
Joined: Fri Jan 19, 2007 9:00 am

Post » Fri Feb 18, 2011 10:44 pm

Well, that may not be entirely accurate. But all I know for sure is, ModActorValue2 does not affect speed. It may affect other attributes, but I tried everything and it would not modify my speed according to what I wanted it to.

While I have you reading this thread, HeyYou...take a look at my finished script, please. I have been reading a little about script optimization, but I am still fairly new to scripting. Are there any optimizations you can spot that would make the script less invasive?

ScriptName aaaLSSprintScriptfloat fQuestDelayTimeshort vSprintKeyshort sSpeedBoostshort sHAPenaltyshort sIsSprintingshort sFatigueCheckshort vUserBoostshort sBoostBegin GameMode				Set fQuestDelayTime to 0.1	Set vSprintKey to aaaLSVariables.sSprintKey	Set vUserBoost to aaaLSVariables.sUserBoost			If (IsKeyPressed3 vSprintKey) && (IsKeyPressed3 17 || IsKeyPressed3 30 || IsKeyPressed3 32) && (Player.IsSwimming == 0 && Player.IsSneaking == 0) && (Player.GetFatiguePercentage > 0.15)		Set sIsSprinting to 1		If sSpeedBoost == 0			Set sSpeedBoost to vUserBoost			If sSpeedBoost == 100 || sSpeedBoost == 125 || sSpeedBoost == 150				Player.ModActorValue Speed sSpeedBoost			Else 				Player.ModActorValue Speed 100			EndIf						Set sHAPenalty to Player.GetBaseAV2 HeavyArmor / 2			Player.ModActorValue2 HeavyArmor sHAPenalty		EndIf				Player.ModActorValue Fatigue -10		If Player.GetBaseAV2 Athletics >= 150						Player.ModActorValue Fatigue 7		EndIf		Return	Else		If sSpeedBoost != 0			If sSpeedBoost == 100 || sSpeedBoost == 125 || sSpeedBoost == 150				Set sSpeedBoost to -sSpeedBoost				Player.ModActorValue Speed sSpeedBoost			Else				Player.ModActorValue Speed -100			EndIf						Set sHAPenalty to Player.GetBaseAV2 HeavyArmor * 2			Player.ModActorValue2 HeavyArmor sHAPenalty			Set sHAPenalty to 0			Set sSpeedBoost to 0			Set sBoost to 0		EndIf	EndIf	End


Thanks.
User avatar
Céline Rémy
 
Posts: 3443
Joined: Sat Apr 07, 2007 12:45 am

Post » Sat Feb 19, 2011 4:29 am

In this loop:

                If sSpeedBoost != 0                        If sSpeedBoost == 100 || sSpeedBoost == 125 || sSpeedBoost == 150                                Set sSpeedBoost to -sSpeedBoost                                Player.ModActorValue Speed sSpeedBoost                        Else                                Player.ModActorValue Speed -100                        EndIf                                                Set sHAPenalty to Player.GetBaseAV2 HeavyArmor * 2                        Player.ModActorValue2 HeavyArmor sHAPenalty                        Set sHAPenalty to 0                        Set sSpeedBoost to 0                        Set sBoost to 0                EndIf


You could dump the != 0 check. Its kinda redundant. Aside from that, Looks good. :D
User avatar
michael danso
 
Posts: 3492
Joined: Wed Jun 13, 2007 9:21 am

Post » Fri Feb 18, 2011 8:32 pm

Great, thanks.
User avatar
Dustin Brown
 
Posts: 3307
Joined: Sun Sep 30, 2007 6:55 am


Return to IV - Oblivion