Qazek Posted December 14, 2013 Author Share Posted December 14, 2013 It's only requirement ifs code optimalization.Before:```Select Case Item(itemnum).Type```Paste:``` ' stat requirements For i = 1 To Stats.Stat_Count - 1 If GetPlayerRawStat(index, i) < Item(itemnum).Stat_Req(i) Then PlayerMsg index, "You do not meet the stat requirements to equip this item.", BrightRed Exit Sub End If Next ' level requirement If GetPlayerLevel(index) < Item(itemnum).LevelReq Then PlayerMsg index, "You do not meet the level requirement to equip this item.", BrightRed Exit Sub End If ' class requirement If Item(itemnum).ClassReq > 0 Then If Not GetPlayerClass(index) = Item(itemnum).ClassReq Then PlayerMsg index, "You do not meet the class requirement to equip this item.", BrightRed Exit Sub End If End If ' access requirement If Not GetPlayerAccess(index) >= Item(itemnum).AccessReq Then PlayerMsg index, "You do not meet the access requirement to equip this item.", BrightRed Exit Sub End If```And now remove requirement ifs from ITEM_TYPE_WEAPON, ITEM_TYPE_ARMOR etc.For example for ITEM_TYPE_ARMOR:``` Case ITEM_TYPE_ARMOR If GetPlayerEquipment(index, Armor) > 0 Then tempItem = GetPlayerEquipment(index, Armor) End If SetPlayerEquipment index, itemnum, Armor PlayerMsg index, "You equip " & CheckGrammar(Item(itemnum).Name), BrightGreen TakeInvItem index, itemnum, 0 If tempItem > 0 Then GiveInvItem index, tempItem, 0 ' give back the stored item tempItem = 0 End If Call SendWornEquipment(index) Call SendMapEquipment(index) ' send vitals Call SendVital(index, Vitals.HP) Call SendVital(index, Vitals.MP) ' send vitals to party if in one If TempPlayer(index).inParty > 0 Then SendPartyVitals TempPlayer(index).inParty, index ' send the sound SendPlayerSound index, GetPlayerX(index), GetPlayerY(index), SoundEntity.seItem, itemnum```;) Link to comment Share on other sites More sharing options...
Richy420Rich Posted December 15, 2013 Share Posted December 15, 2013 Wow lol. I never even thought of that when I was optimising, nice catch and thanks. 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