quote:Original post by Dreddnafious Maelstrom
Allow me to suggest a few things.
1) Write your character class as an object with all of your listed statistics as properties.
You mean like this??
Public Type Character Name As String Sex As String Race As String Class As String Strength As Long Endurance As Long Agility As Long Power As Long ''Controls the effectiveness of spells Intelligence As Long ''Controls the number of spell points MaxHP As Long ''Maximum Hit points CurHP As Long ''Current HP MaxSP As Long ''Maximum Spell points CurSP As Long ''Current SP Level As Long ''Current level Experience As Long ''Current experience ExpToNextLvl As Long ''Experience to next level Gold As LongEnd TypePublic Hero As Character
quote:
It will be a lot easier to keep track of it all, trust me,
but I will stick to your linear method for now.
No need, I have a fair grasp of classes, like I showed above. If you thought of that because I had all those seperate variables, that was just some pseudocode I wrote up to get me started. Here''s the real code that I have in the game now...
If Random(50) < x Then ''Miss- no damage Damage = 0 Enemy(CurrentType).CurHP = Enemy(CurrentType).CurHP ElseIf Random(50) >= x And Random(50) < n Then ''Normal hit If Hero.Strength > Enemy(CurrentType).Endurance Then Damage = Hero.Strength + 5 + Random(Hero.Level) Enemy(CurrentType).CurHP = Enemy(CurrentType).CurHP - Damage ElseIf Hero.Strength < Enemy(CurrentType).Endurance Then Damage = Hero.Strength - 5 + Random(Hero.Level) Enemy(CurrentType).CurHP = Enemy(CurrentType).CurHP - Damage End If ElseIf Random(50) >= n Then ''Lucky hit- double damage If Hero.Strength > Enemy(CurrentType).Endurance Then Damage = 2 * (Hero.Strength + 5 + Random(Hero.Level)) Enemy(CurrentType).CurHP = Enemy(CurrentType).CurHP - Damage ElseIf Hero.Strength < Enemy(CurrentType).Endurance Then Damage = 2 * (Hero.Strength - 5 + Random(Hero.Level)) Enemy(CurrentType).CurHP = Enemy(CurrentType).CurHP - Damage End If End If
quote:
2) Try not to do as much math on the fly. I''m assuming that like any good RPG there will be alot of combat involved. If your going to call this function alot, which you will, you should resolve as much upfront as possible.
It''s not a real-time game, if that''s what you''re wondering. I don''t know nearly enough yet to do real-time. My game is played through forms I created in Visual Basic, and combat is turn-based. I don''t think your statement above would be as much of an issue, would it?
That aside, I don''t really understand- should I seperate the calculations somehow? That doesn''t seem to make sense to me, since I''m only doing them in one place: the Combat form. Could you explain yourself some more?
quote:
How will you handle armor, how will you change it?
See if any of this looks good:
Const CHAINMAIL_VALUE = 30
Private Function NewAC As Long
NewAC = Agility + EquippedArmorValue
End Function
Private Function ToHit AS Long
ToHit = CharacterStrength + Int(Rnd * 100) + 1
End Function
When your character changes armor then
EquippedArmorValue = CHAINMAIL_VALUE
CurrentAC = NewAC
When your character actually attacks:
If ToHit >= MonsterArmorClass Then
ResolveDamage
Else
You Missed
End If
Kind of tough really to read because i haven''t coded without objects since i''ve learned to do them but definitely don''t recalculate anything in your to hit swing that you can calculate once and carry with you. Invent an ArmorClass that will carry each creatures chance to avoid damage with it, so you don''t have to recalculate it. Also think about your code and your game, you don''t want write a line of code for each incidence in your program, you really just want to write the rules they will use and then toss a bunch of data at your rules. And finally, for the third time(i think) pre-calculate everything you can. VB math functions are really slow. Maybe you could Pre-generate a whole bunch of random numbers when your app loads and then iterate through an array to get your to hit seed. (make any sense?)
I''m not doing anything with armor yet. I''m trying to get the basic game running first, and to tell the truth, I''m not sure yet exactly which way it''s going to go. All I have (more or less) fully functioning yet are the Character Creation and Combat forms.
However, please do keep up with the helpful advice!
quote:
Best of Luck!
Thanks!!
Grant Palin