• Log in or sign up for an account here: https://www.sythe.org/login

[Source] Text-Based RPG Battle System

Blupig

BEEF TOILET

$5 USD Donor
Joined
Nov 23, 2006
Sythe Gold
1,609
Messages
7,145
Age
33
Location
Canada
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
[SOURCE] Text-Based RPG Battle Engine

About:
I was really into making my own RPG at some point, so I made a battle system then never got around to finishing the rest. So, here it is. Massive credits to Terrankiller for his RandomInt function.
What this does is player 1 clicks their turn button. A random number is picked between 1 and 10, and the opponent suffers that damage. Then, the opponent's button has to be clicked, then they do damage between 1 and 10 to the player. The first one to reach 0 HP loses.


WHAT YOU NEED
-Label (4)
1: name = playerhp
2: name = opphp
3: name = dmgplayer
4: name = dmgopp
-Command Button (2)
1: name = oppgo, enabled = false
2: name = playergo
-Timer (1)
1: name = tmrDmg

This is Terrankiller's RandomInt function. It randomly picks a number between Low and High. Add it into a module:
Code:
'RandomInt Function by Terrankiller, http://www.terrankiller.com/
Public Function RandomInt(ByVal Low As Long, ByVal High As Long) As Long

   Randomize: RandomInt = Int((High - Low + 1) * Rnd) + Low
  
End Function

Now make a normal form and add this into it's code:
Code:
Option Explicit
Dim oppdmg As Integer
Dim plrdmg As Integer

Private Sub Form_Load()

playerhp.Caption = 20
opphp.Caption = 20

End Sub

Private Sub oppgo_Click()

playerhp.Caption = playerhp.Caption - oppdmg
oppgo.Enabled = False
playergo.Enabled = True
dmgopp.Caption = oppdmg
If playerhp.Caption <= 0 Then
playerhp.Caption = "0"
MsgBox "You died.", vbCritical, ":("
Unload Me
End If

End Sub

Private Sub playergo_Click()

dmgplayer.Caption = plrdmg
opphp.Caption = opphp.Caption - plrdmg
playergo.Enabled = False
oppgo.Enabled = True
If opphp.Caption <= 0 Then
opphp.Caption = "0"
MsgBox "You won!", vbExclamation, ":)"
Unload Me
End If

End Sub

Private Sub tmrDmg_Timer()

oppdmg = RandomInt(1, 10)
plrdmg = RandomInt(1, 10)

End Sub
 
Runescape Gamblingrunescape gambling
Back
Top