Tic Tac 2 Posted March 31, 2014 Author Share Posted March 31, 2014 I wanted to change my combat formula to be the exact same as Runescape 2s combat formula. It gives me RTE 9 subscript out of range though. Any idea what i might be doing wrong? Any feedback is appreciated. Thank you very much.Edit: This error happens when i hit somebody. Both with and without weapon equipped.![](http://i.snag.gy/gCxbh.jpg) Link to comment Share on other sites More sharing options...
Matt Posted March 31, 2014 Share Posted March 31, 2014 RTE 9 means exactly what it says. A value is outside of its range. ~~When the error happens, hover over each value and see which one is causing the RTE.~~I know what could be causing the error. If the player doesn't have a weapon, the WeaponNum is 0 which is outside the range of the Item types (1 to MAX_ITEMS) Link to comment Share on other sites More sharing options...
Stein Posted March 31, 2014 Share Posted March 31, 2014 That is exactly what is causing the error here. Could you paste that piece of code into a code tag so we can correct it? Link to comment Share on other sites More sharing options...
Tic Tac 2 Posted March 31, 2014 Author Share Posted March 31, 2014 > RTE 9 means exactly what it says. A value is outside of its range. ~~When the error happens, hover over each value and see which one is causing the RTE.~~> > > > I know what could be causing the error. If the player doesn't have a weapon, the WeaponNum is 0 which is outside the range of the Item types (1 to MAX_ITEMS)This happens both when i have a weapon on and not.> That is exactly what is causing the error here. Could you paste that piece of code into a code tag so we can correct it?Sure :P```Function GetPlayerDamage(ByVal index As Long) As Long Dim WeaponNum As Long ' Check for subscript out of range If IsPlaying(index) = False Or index < 1 Or index > Player_HighIndex Then Exit Function If GetPlayerEquipment(index, Equipment.Weapon) > 0 Then If Not GetPlayerEquipmentDur(index, GetPlayerEquipment(index, Equipment.Weapon)) = 0 Or Item(GetPlayerEquipment(index, Equipment.Weapon)).Indestructable = 1 Then WeaponNum = GetPlayerEquipment(index, Equipment.Weapon) GetPlayerDamage = 1 'Max = 5 + STRLVL * (STRBONUS + 64) / 64 '* Item(WeaponNum).Data2 Exit Function End If End If GetPlayerDamage = 5 + (GetPlayerStat(index, Strength) * (Item(WeaponNum).Data2 + 64) / 64)End Function```The last line before End Function is the highlighted one. Link to comment Share on other sites More sharing options...
Matt Posted March 31, 2014 Share Posted March 31, 2014 The returning statement is dependant on the WeaponNum being bigger than 0\. Change it to this.```Function GetPlayerDamage(ByVal index As Long) As Long Dim WeaponNum As Long ' Check for subscript out of range If IsPlaying(index) = False Or index < 1 Or index > Player_HighIndex Then Exit Function If GetPlayerEquipment(index, Equipment.Weapon) > 0 Then If Not GetPlayerEquipmentDur(index, GetPlayerEquipment(index, Equipment.Weapon)) = 0 Or Item(GetPlayerEquipment(index, Equipment.Weapon)).Indestructable = 1 Then WeaponNum = GetPlayerEquipment(index, Equipment.Weapon) GetPlayerDamage = 5 + (GetPlayerStat(index, Strength) * (Item(WeaponNum).Data2 + 64) / 64) ' GetPlayerDamage = 1 No idea why this is here. 'Max = 5 + STRLVL * (STRBONUS + 64) / 64 '* Item(WeaponNum).Data2 Exit Function End If End If GetPlayerDamage = 5 + (GetPlayerStat(index, Strength) / 64)End Function``` Link to comment Share on other sites More sharing options...
Tic Tac 2 Posted March 31, 2014 Author Share Posted March 31, 2014 > The returning statement is dependant on the WeaponNum being bigger than 0\. Change it to this.> > ```> > Function GetPlayerDamage(ByVal index As Long) As Long> Dim WeaponNum As Long> > ' Check for subscript out of range> If IsPlaying(index) = False Or index < 1 Or index > Player_HighIndex Then Exit Function> > If GetPlayerEquipment(index, Equipment.Weapon) > 0 Then> If Not GetPlayerEquipmentDur(index, GetPlayerEquipment(index, Equipment.Weapon)) = 0 Or Item(GetPlayerEquipment(index, Equipment.Weapon)).Indestructable = 1 Then> WeaponNum = GetPlayerEquipment(index, Equipment.Weapon)> GetPlayerDamage = 5 + (GetPlayerStat(index, Strength) * (Item(WeaponNum).Data2 + 64) / 64)> ' GetPlayerDamage = 1 No idea why this is here.> 'Max = 5 + STRLVL * (STRBONUS + 64) / 64> '* Item(WeaponNum).Data2> Exit Function> End If> End If> > GetPlayerDamage = 5 + (GetPlayerStat(index, Strength) / 64)> End Function> > ```Item.WeaponNum.Datais that the Vital number set on the weapon in the equipment editor? If not, what is the code to make it set to multiply by weapon vital? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now