Difference between revisions of "RPG Guide"

One thing I noticed on the Wanted Page was a topic on Game Mechanics, the user Primetime requesting how to do fundamental RPG things, like turn-based combat similar to Final Fantasy, and how to calculate damage, etc.

This is a stub because I don't want to be the only one writing this. Let's add formulas that others can use as a basis for their RPG. I'm in the process of making an RPG with friends from school, so I'm willing to share what mathematic and game knowledge in this stub.

Overview of an RPG

RPG or Role-Playing Game is where you as the player takes the role of a character inside of a fictional story, determining how they level up, what dialog actions they take, and how you move the story along.

A classic RPG, such as Final Fantasy, has monsters on one of the battle screen, and the party on the other side. Ever since FFII, Square had implemented ATB combat, Action-Time-Based. This was how quickly characters would act depended on their Speed. In FFIV, the bar was invisible, but in FFVI, the bar was visible. When this bar filled up, the character would flash, and a menu would appear. Then the player could input the commands.

RPGs have all types of attacks, usually divided into physical and magical, so just as common they have similar character stats like Physical Attack and Defense, and Magic Attack and Defense.

The Character Class in an RPG

Creating a class for the character is recommended, because you can hold all of the character's stats inside of the class. Also, you can have private subroutines to determine how HP and other stats are calculated based off of items and attributes.

```Class Hero
Dim Strength as Integer
Dim Intellect as Integer
Dim Agility as Integer
Dim HitPoints as Integer
Dim Attack as Integer```

Some other possible attributes are listed Here.

Here we can see the basic attributes of a hero. How strong he is, how smart he is, how fast he is, how much he can take, and how much he can dish out. It is possible to code an RPG with just these elements, but we're forgetting about other factors that take place inside of an RPG, such as:

1. Dodging
2. Critcals
3. Magic Attack and Defense

But we can attack this later.

Turn-Based Action

Since the RPG I'm coding is a one-man-against-all, I'm only going to code for one character. This routine can be duplicated for multiple characters, and you can queue whose turn it is.

```Private Sub Encounter(ByVal Hero.Agility, ByVal Monster.Agility)
Dim Roll as New Random
If Hero.Agility + Roll.Next(-6,7) > Monster.Agility
Call PartyTurn
Else
Call EnemyTurn
End If
End Sub

Private Sub EnemyTurn()
Finished = False
'Execute the AI or just have the monster do a basic attack
'After the monster attack is complete, set a boolean Finished to true
If Finished = True
Call PartyTurn
EndIf
End Sub

Private Sub PartyTurn()
Finished = False
Case "Fight"
Damage = Hero.Attack - Monster.Defense
If Roll.Next(1,101) &lt; Monster.DodgeChance
LabelDamage.Text = &quot;Miss&quot;
Damage = 0
Else
LabelDamage.Text = Damage
Monster.HitPoints = Monster.HitPoints - Damage
EndIf
Case "Spell"
'going to end that there for now
Case "Defend"
Hero.Defense = Hero.Defense * 1.5
Case "Item"