The code below is designated as a quest script and attached to a start game enabled quest. The function is to classify weapons, assign and execute appropriate kickback and muzzle rise when fired.
After a death and reset, the quest variable remain frozen at their last values and the effect loop is not executed.
What am I missing?
SCN xCalKickScriptshort ammocountshort xCalKickLoopshort KickLoopCountershort Kickskillshort IsSmallGunfloat fRisefloat fAnglefloat Kickback float Kickfloat RiseAmtref rAmmoType ref rCurrentGunBEGIN Gamemode;############################################################# KickBack Assignment IF (IsSmallGun==41) || (rCurrentGun==0) IF ( rCurrentGun != player.getequippedobject 5 ) set rCurrentGun to player.getequippedobject 5 set rAmmoType to getweaponammo rCurrentGun set IsSmallGun to Player.getweaponskill rCurrentGun IF player.isweaponinlist xCalKickAutoL set Kickback to 1.25 Set xCalKickLoop to 2 ElseIF player.isweaponinlist xCalKickAutoH set Kickback to 2 Set xCalKickLoop to 2 ElseIF player.isweaponinlist xCalKickAutoSMG set Kickback to .75 Set xCalKickLoop to 2 ElseIF player.isweaponinlist xCalKickSemiS set Kickback to 2 Set xCalKickLoop to 4 ElseIF player.isweaponinlist xCalKickSemiM set Kickback to 3 Set xCalKickLoop to 4 ElseIF player.isweaponinlist xCalKickSemiL set Kickback to 4 Set xCalKickLoop to 4 ElseIF player.isweaponinlist xCalKickCannon set Kickback to 5 Set xCalKickLoop to 4 ElseIF (getisautomatic rCurrentGun) ;Automatic designation IF (GetWeaponType ==3) || (GetWeaponType == 4) listaddform xCalKickAutoSMG rCurrentGun set Kickback to .75 Set xCalKickLoop to 2 ElseIF (rAmmoType == CALIBRxAmmoRifle762x51) listaddform xCalKickAutoH rCurrentGun set Kickback to 2 Set xCalKickLoop to 2 ElseIF (rAmmoType != CALIBRxAmmoRifle762x51) listaddform xCalKickAutoL rCurrentGun set Kickback to 1.25 Set xCalKickLoop to 2 EndIF ElseIF getdamage rCurrentGun < 30 ;Semi designation listaddform xCalKickSemiS rCurrentGun set Kickback to 2 Set xCalKickLoop to 4 ElseIF getdamage rCurrentGun < 60 listaddform xCalKickSemiM rCurrentGun set Kickback to 3 Set xCalKickLoop to 4 ElseIF getdamage rCurrentGun < 90 listaddform xCalKickSemiL rCurrentGun set Kickback to 4 Set xCalKickLoop to 4 ElseIF getdamage rCurrentGun > 89 listaddform xCalKickCannon rCurrentGun set Kickback to 5 Set xCalKickLoop to 4 EndIF Set Kickskill to player.GetAV SmallGuns Set Kick to (Kickback*(100/(kickskill+100))) ; full skill reduces kick 50% EndIF ; New Weapon Equiped loop;############################################################# KickBack Effect Loop IF ( AmmoCount > player.getitemcount rAmmoType ) ; weapon has been fired Set KickLoopCounter to 1 Label 1 IF KickLoopCounter <= xCalKickLoop set fAngle to player.getangle x - (Kick/ xCalKickLoop) IF ( fAngle>=-89 && fAngle<=89 ) player.setangle x fAngle EndIF IF iscontrolpressed 6 == 0 Set RiseAmt to ((Kick/xCalKickLoop)/2) Else Set RiseAmt to (Kick/xCalKickLoop) EndIF set fRise to ((getrandompercent - 50)/100)*RiseAmt set fAngle to player.getangle z - fRise player.setangle z fAngle set KickloopCounter to (KickloopCounter + 1) GoTo 1 EndIF EndIF set AmmoCount to player.getitemcount rAmmoTypeEndIFEND