| Mirage Source http://miragesource.net/forums/ |
|
| Equip Bonus System http://miragesource.net/forums/viewtopic.php?f=201&t=3181 |
Page 1 of 1 |
| Author: | Anthony [ Wed Dec 19, 2007 12:46 am ] |
| Post subject: | Equip Bonus System |
So I have been working on this equipment bonus thing for a couple hours and have it all figured out so it's working nicely however I think it is sort of messy. I am not sure. I was hoping to get somebodys advice on if there would be a faster way to do any of the things I am or not. As it is I have 6 Functions that are each like this: Code: Function GetPlayerWeaponBonus(ByVal Index As Long) Dim WeaponSlot As Long StrengthBonus = 0 EnduranceBonus = 0 DexterityBonus = 0 WisdomBonus = 0 AgilityBonus = 0 If GetPlayerWeaponSlot(Index) > 0 Then WeaponSlot = GetPlayerWeaponSlot(Index) If Item(GetPlayerInvItemNum(Index, WeaponSlot)).BonusType = 0 Then StrengthBonus = Item(GetPlayerInvItemNum(Index, WeaponSlot)).Bonus End If If Item(GetPlayerInvItemNum(Index, WeaponSlot)).BonusType = 1 Then EnduranceBonus = Item(GetPlayerInvItemNum(Index, WeaponSlot)).Bonus End If If Item(GetPlayerInvItemNum(Index, WeaponSlot)).BonusType = 2 Then DexterityBonus = Item(GetPlayerInvItemNum(Index, WeaponSlot)).Bonus End If If Item(GetPlayerInvItemNum(Index, WeaponSlot)).BonusType = 3 Then WisdomBonus = Item(GetPlayerInvItemNum(Index, WeaponSlot)).Bonus End If If Item(GetPlayerInvItemNum(Index, WeaponSlot)).BonusType = 4 Then AgilityBonus = Item(GetPlayerInvItemNum(Index, WeaponSlot)).Bonus End If End If End Function 6 of those, one for each item type. Then I have this: Code: Function GetPlayerBonus(Index) Call GetPlayerWeaponBonus(Index) Call GetPlayerArmorBonus(Index) Call GetPlayerSheildBonus(Index) Call GetPlayerHelmBonus(Index) Call GetPlayerNecklaceBonus(Index) Call GetPlayerRingBonus(Index) Call SendStats(Index) End Function So thats called whenever an item is equipped or unequipped and when you first join the game. Then obviously I have 5 declares like StrengthBonus, EnduranceBonus, etc. Those are sent in the SendStats sub so I can have my visual stats update like 8 + (1). So this seems slow, any faster ways? xD thanks! |
|
| Author: | Rezeyu [ Wed Dec 19, 2007 1:04 am ] |
| Post subject: | Re: Equip Bonus System |
Why are they functions if they aren't returning their own value? =/ GetPlayerWeaponBonus doesn't return a variable named GetPlayerWeaponBonus, so why isn't it just a sub? |
|
| Author: | Anthony [ Wed Dec 19, 2007 2:03 am ] |
| Post subject: | Re: Equip Bonus System |
Because I didn't know the difference... |
|
| Author: | Lea [ Wed Dec 19, 2007 4:38 am ] |
| Post subject: | Re: Equip Bonus System |
Also, if you reset the bonus to 0 in each function, the previous bonus is reset. You never want to assume a function does something for you. Have the function return the value, and set it yourself. Instead of allowing only one type of bonus per level, create a structure (UDT) called Bonuses and include a bonus for each type. |
|
| Author: | James [ Wed Dec 19, 2007 9:42 am ] |
| Post subject: | Re: Equip Bonus System |
Just curious, but say you implemented a bonus system, but wanted negatives, could you do that in the editor? ItemStrBonus = txtStrBonus.Text where the text is -1? Would that save correctly and work in the code if you had the players stats set to Str + ItemBonus, etc? |
|
| Author: | Rezeyu [ Wed Dec 19, 2007 4:56 pm ] |
| Post subject: | Re: Equip Bonus System |
Why would negatives not work? |
|
| Author: | Lea [ Wed Dec 19, 2007 6:12 pm ] |
| Post subject: | Re: Equip Bonus System |
Magnus, you're all like, "zomg math" yet you forget one of the most elementary rules of algebra? SPOILER: (click to show)
|
|
| Author: | Leighland [ Sat Dec 29, 2007 6:25 am ] |
| Post subject: | Re: Equip Bonus System |
That's pretty close to what I did for my bonus system. Mines a bit sloppier though I think. This is what it looks like :p Code: Function GetPlayerBonusSTR(ByVal Index As Long) As Byte ' get players extra strength from items Dim ArmorSlot As Byte, HelmSlot As Byte, WeaponSlot As Byte, ShieldSlot As Byte GetPlayerBonusSTR = 0 ' Check for subscript out of range If IsPlaying(Index) = False Or Index <= 0 Or Index > MAX_PLAYERS Then Exit Function End If ArmorSlot = GetPlayerArmorSlot(Index) HelmSlot = GetPlayerHelmetSlot(Index) WeaponSlot = GetPlayerWeaponSlot(Index) ShieldSlot = GetPlayerShieldSlot(Index) If ArmorSlot > 0 Then GetPlayerBonusSTR = GetPlayerBonusSTR + (Item(ArmorSlot).StrBon) If HelmSlot > 0 Then GetPlayerBonusSTR = GetPlayerBonusSTR + (Item(HelmSlot).StrBon) If WeaponSlot > 0 Then GetPlayerBonusSTR = GetPlayerBonusSTR + (Item(WeaponSlot).StrBon) If ShieldSlot > 0 Then GetPlayerBonusSTR = GetPlayerBonusSTR + (Item(ShieldSlot).StrBon) If GetPlayerBonusSTR < 0 Then GetPlayerBonusSTR = 0 ' Gotta check, never know :p End Function My item/inventory code was changed so the code isn't what it would be for a vanilla mse but you get the point. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|