Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualVarlun

Posted 16 November 2012 - 09:01 PM

Edit: I'm aware that the bits of code I've posted aren't properly spaced. Something about this word processor didn't like tabbing, so I'll have to go in and put the spaces myself... in other words, if you're seeing this Edit message and the code looks like shit, I'm probably fixing it at this very moment! Thank you for your patience. I know unspaced code is a nightmare to read. Hence why it does it automatically in the programmer.

Edit: I've put in some spacing... and actually, I figured out that it doesn't like spaces at all, so I'm having to use dots to space it. Which is a pain. But, it must be done.

Edit: Ugh, noticed another flaw created by this word processor... apparently, every time the symbol "&" was used, it put some funny stuff after it. I'll clear that out later, but for now, just know that that stuff isn't supposed to be there. I've never seen so many problems with a forum poster.

Hey everyone. I've seen many other posts say it, so I'll go ahead and throw in that this is my first post on these forums as well. So, yay.

Let's get right to it. I'm currently learning Visual Basic, and I feel that I've learned enough to get started on creating my own text-based adventure game. I'll post the entire code that I have so far below for inspection. I'd like to know if I'm on the right track. I'll probably select bits and pieces of the code afterward, and explain what happens, to save you guys the headache. It may or may not seem complex to you- I know I for one am impressed with what I've come up with so far. To think that I started with just a couple If statements.

So far, I've pretty much got about half of the combat system worked out. You can choose what you want to attack with, and it'll do damage, and will move on after the enemy dies, but the enemy doesn't fight back yet. I'll get to that. For now, I'm working on the adventure part of the game... where you can actually move from territory to territory, search for items, etc.

This part is largely unfinished, but the idea will be something like this: When you enter an area, it'll detect what area that is, and it'll detect what stage that area is in, and display a bit of text to describe it appropriately. From there, you'll have three options: move on, search, and inventory. Inventory is just disabled at the moment, I'll put that in a while later from now.

If you choose move on, the game will again detect where you are and what stage the area is in... it'll account for all the appropriate variables... and display an appropriate message of all the exits. It'll also assign the exits to forward/back/left/right options, which will be done by it detecting which area you were in previously (if you were in x room, then your direction is north, and selecting back will take you south / if you were in x room, then your direction is south, and selecting back will take you north).

And if you choose search, it'll look at all the appropriate things again, and display an appropriate message describing things in the area which you could possibly inspect. For example, if you enter an area for the first time, let's say there's a dagger in the corner. It would tell you there's a dagger in the corner. You could then type "inspect dagger" and it'll give you options... such as leave dagger/take dagger. If you leave the dagger, then obviously nothing changes. However, if you take the dagger... these are the sorts of things which will change the stage of an area. So in the future, when you come back to the room, and if you've taken the dagger, it won't tell you there's a dagger there anymore. It would instead, perhaps, mention a dagger-shaped clear spot in some dust, in that same corner, from where you took it. This would obviously create, frankly, a shitload of these "stages" when I get to having multiple items in a room. A bucket, a dagger, a sword, a key, a torch, a lamp, a... whatever. I feel like I'm definitely going to have to find a way to avoid this... perhaps somehow using multiple labels... but I don't know. This is an area I feel I need help in. For now, I'm going to avoid having more than one or two items. Which would, right there, create 4 different stages. x.x

So. In the future, I plan on giving every item a durability. I think I'm going to set it up where, as the durability goes down, the weapon/armor becomes increasingly useless- damage/defense bonuses go away, increasingly. And once/if it reaches 0, the item completely breaks down, either into nothing or just some bits of scrap... probably bits of scrap. And I'm going to make it where you can scavenge materials from things... such as breaking a bucket for bits of wood... and you'll be able to use these in conjunction with tools to repair your gear. So it'll be a constant fight to keep yourself well-geared. The more you fight, the more you have to manage yourself. In other words, no Leeroy Jenkins. Unless you're prepared. I really love the idea of this feature, because it requires you to use caution. If you get in too deep, by the time you get out, your gear may be so heavily damaged that you find yourself unable to enter areas which you previously had no problem with.

I also plan on there being an ability for you to clear out and make use of enemy strongholds. Like, if you completely eliminate the current enemy presence there, then you'll be free to set up camp. Now, in conjunction with this system, I'd like to set it up to where that bit of territory looks at the surrounding territories, and determines a percentage of invasion... and this percentage will be rolled every time you move... no matter where you are in the game. So obviously the percentage would be very low, but the point is, that if you don't manage the territory AROUND your base, then you may find it destroyed and overrun when you return. I'd also like to make it where the enemy can push out and expand, taking over territory. So there'll be a sort of tug-of-war. And yes, I'd love to also have the possibility in there for you to completely eliminate an enemy faction, where you never have to worry about them anymore. Taking out the source would obviously be a huge ordeal, but yeah. The point is the possibility being there.

I currently don't really have any plan to put in allies... I feel like I want to make it a sort of "you're on your own" type of game, where the entire goal is to get something which will get you out of this hellhole and back to civilization. But if I do put friendly factions in there, I'd love to give them bases of their own, coupled with the expansion system seen above... which would obviously eventually lead to constant border fighting between friendly and enemy factions, whether you're there or not. Posted Image

As far as natural creatures, not pertaining to any faction... they'll obviously thrive where no faction has control. I think I'll give uncontrolled areas a certain percentage for spawning creatures... reproduction and all that... and it'll go up over time, to 100%. This would naturally make it harder and harder to fight an enemy as you get closer to its source. I'll probably use the same system for friendly/enemy factions. But what I think I'll do is, if the territory is under control by one faction or another, that percentage will slowly die down, as whatever group goes around and weeds out the source of the problem... until that goes to 0%. So yes, again, the natural creatures could be completely eliminated. I want this game to contain those extreme possibilities. That's what makes a game interesting, no? Nobody really likes a game where everything is scripted. Well, I don't.

So those are ideas for the future. I guess I'll get to explaining what I have now. Here's the code. Oh, and once again, if you want a walkthrough of how this works, scroll down to after the code.

Public Class Form1

...Dim gameMode As String = "adventure"

...'Battle Variables
...Dim enemyHealth As Integer = 0
...Dim battleChoice As String = Nothing
...Dim enemy As String = Nothing
...Dim health As Integer = 1000
...Dim dragon As Boolean = True
...Dim dragonHealth As Integer = 50
...Dim battleChoiceVisited As Boolean = False
...Dim enemyHealthDisplayed As Boolean = False

...'Attack Variables
...Dim attack As Boolean = False
...Dim attackChoice As String = Nothing
...Dim attackChoiceDamage As Integer = 0
...Dim dagger As Boolean = False
...Dim daggerDamage As Integer = 25
...Dim fireball As Boolean = False
...Dim fireballDamage As Integer = 50
...Dim attackDamage As Integer = 0
...Dim attackChoiceVisited As Boolean = False

...'Heal Variables
...Dim heal As Boolean = False
...Dim weakHeal As Boolean = False
...Dim healChoice As String = Nothing
...Dim healChoiceAmount As Integer = 0
...Dim weakHealAmount As Integer = 0
...Dim strongHeal As Boolean = False
...Dim strongHealAmount As Integer = 0
...Dim healAmount As Integer = 0
...Dim healChoiceVisited As Boolean = False

...'Adventure Variables
...Dim adventureChoice As String = Nothing
...Dim worldLocation As String = "rockslide"
...Dim rockslideStage As Integer = 1
...Dim adventureChoiceVisited As Boolean = False
...Dim forestEntranceStage As Integer = 1

...'Search Variables
...Dim searchChoice As String = Nothing
...Dim search As Boolean = False

...'Move On Variables
...Dim moveOnChoice As String = Nothing
...Dim moveOn As Boolean = False

...'Inventory Variables
...Dim inventory As Boolean = False

...Private Sub btnAction_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAction.Click
......Select Case gameMode
.........Case "battle"
............Call Battle()
.........Case "adventure"
............Call Adventure()
......End Select
...End Sub

...Sub Battle()
......If enemyHealthDisplayed = False Then
.........Me.lblEnemyHealth.Text = "Enemy Health: " & enemyHealth
.........enemyHealthDisplayed = True
......End If

......If battleChoice = Nothing Then
.........Call ChooseBattleChoice()
......End If

......If battleChoice = "attack" Then
.........If attackChoice = Nothing Then
............Call ChooseAttackChoice()
.........End If

.........If attackChoice <> Nothing Then
............Call AttackResult()
.........End If

......ElseIf battleChoice = "heal" Then
.........If healChoice = Nothing Then
............Call ChooseHealChoice()
.........End If

.........If healChoice <> Nothing Then
...........Call HealResult()
.........End If
......End If
...End Sub

...Sub ChooseBattleChoice()
......If Me.txtAction.Text = "attack" Then
.........If attack = True Then
............battlechoice = "attack"
.........Else
............Call InvalidEntry()
.........End If

......ElseIf Me.txtAction.Text = "heal" Then
.........If heal = True Then
............battlechoice = "heal"
.........Else
............Call InvalidEntry()
.........End If

......Else
.........If battleChoiceVisited = False Then
............Me.lblPrompt.Text = "A " &amp;amp; enemy &amp;amp; " stands before you! What will you do?"
............battleChoiceVisited = True
.........Else
............Call InvalidEntry()
.........End If
......End If
...End Sub

...Sub ChooseAttackChoice()
If Me.txtAction.Text = "dagger" Then
If dagger = True Then
attackChoice = "dagger"
attackChoiceDamage = daggerDamage
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "fireball" Then
If fireball = True Then
attackChoice = "fireball"
attackChoiceDamage = fireballDamage
Else
Call InvalidEntry()
End If

Else
If battleChoiceVisited = False Then
Me.lblPrompt.Text = "What will you attack with?"
battleChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
...End Sub

...Sub AttackResult()
attackDamage = attackChoiceDamage
enemyHealth = enemyHealth - attackDamage

If enemyHealth > 0 Then
Me.lblEnemyHealth.Text = "Enemy Health: " &amp;amp; enemyHealth
Else
Me.lblEnemyHealth.Text = "Enemy Health: 0"
End If

MessageBox.Show("You deal " &amp;amp; attackDamage &amp;amp; " damage to the " &amp;amp; enemy &amp;amp; " with your " &amp;amp; attackChoice &amp;amp; "!")
battlechoice = Nothing
attackChoice = Nothing
attackDamage = 0
attackChoiceDamage = 0
battleChoiceVisited = False
attackChoiceVisited = False

If enemyHealth <= 0 Then
MessageBox.Show("You killed the " &amp;amp; enemy &amp;amp; "!")
Me.lblEnemyHealth.Text = Nothing
enemyHealthDisplayed = False
gameMode = "adventure"
Call Adventure()
Else
Call Battle()
End If
...End Sub

...Sub ChooseHealChoice()
If Me.txtAction.Text = "small heal" Then
If weakHeal = True Then
healChoice = "small heal"
healChoiceAmount = weakHealAmount
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "large heal" Then
If strongHeal = True Then
healChoice = "large heal"
healChoiceAmount = strongHealAmount
Else
Call InvalidEntry()
End If

Else
If healChoiceVisited = False Then
Me.lblPrompt.Text = "What will you heal with?"
healChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
...End Sub

...Sub HealResult()
healAmount = healChoiceAmount
health = health + healAmount

If health < 1000 Then
Me.lblHealth.Text = "Health: " &amp;amp; health
Else
Me.lblHealth.Text = "Health: 1000"
End If

MessageBox.Show("You restore " &amp;amp; healAmount &amp;amp; " health with your " &amp;amp; healChoice &amp;amp; "!")
battlechoice = Nothing
healChoice = Nothing
healAmount = 0
healChoiceAmount = 0
Call Battle()
...End Sub

...Sub Adventure()
If adventureChoice = Nothing Then
Call ChooseAdventureChoice()
End If

If adventureChoice = "search" Then
If searchChoice = Nothing Then
Call ChooseSearchChoice()
End If

If searchChoice <> Nothing Then
Call SearchResult()
End If

ElseIf adventureChoice = "move on" Then
If moveOnChoice = Nothing Then
Call ChooseMoveOnChoice()
End If

If moveOnChoice <> Nothing Then
Call MoveOnResult()
End If

ElseIf adventureChoice = "inventory" Then
Call Filler()
End If
...End Sub

...Sub ChooseAdventureChoice()
Select Case worldLocation
Case "rockslide"
Select Case rockslideStage
Case 1
If Me.txtAction.Text = "search" Then
If search = True Then
adventureChoice = "search"
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "move on" Then
If moveOn = True Then
adventureChoice = "move on"
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "inventory" Then
If inventory = True Then
adventureChoice = "inventory"
Else
Call InvalidEntry()
End If

Else
If adventureChoiceVisited = False Then
Me.txtAction.Text = "filler"
adventureChoiceVisited = True
Else
Call InvalidEntry()
End If
End If

Case 2
Call Filler()
End Select

Case "forestEntrance"
Select Case forestEntranceStage
Case 1
Call Filler()

Case 2
Call Filler()
End Select
End Select
...End Sub

...Sub ChooseSearchChoice()

...End Sub

...Sub SearchResult()

...End Sub

...Sub ChooseMoveOnChoice()

...End Sub

...Sub MoveOnResult()

...End Sub

...Sub AdventureResult()

...End Sub

...Sub InvalidEntry()
......MessageBox.Show("Invalid entry.")
...End Sub

...Sub GameLoad() Handles MyBase.Load
......Call Adventure()
...End Sub

...Sub Filler()
......MessageBox.Show("Feature not available.")
...End Sub
End Class

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'll explain how battle works. Now, what'll happen is, when it's determined that an enemy has shown up, it'll Call Battle, and that will determine if you've made a Battle Choice yet.

If battleChoice = Nothing Then
...Call ChooseBattleChoice()
End If

Obviously, you haven't, so it'll Call ChooseBattleChoice, and that will determine if you've typed in what you want your Battle Choice to be yet.

If Me.txtAction.Text = "attack" Then
...~~~
ElseIf Me.txtAction.Text = "heal" Then
...~~~
Else
...~~~
End If

And you haven't, so it'll determine if it's run through this bit of code before.

Else
...If battleChoiceVisited = False Then
...... ~~~
...Else
......~~~
...End If
End If

And you haven't, so it'll display the type of enemy that's standing before you, the type of enemy being declared in the very beginning, when it was determined by the game that an enemy was going to show up.

If battleChoiceVisited = False Then
...Me.lblPrompt.Text = "A " &amp;amp; enemy &amp;amp; " stands before you! What will you do?"
...battleChoiceVisited = True
Else
...~~~
End If

And it'll run out through the rest of the code and do nothing else, leaving you an opportunity to type something in and click Action, which is what the button is named. Now, if you type anything in other than what it wants you to, it'll run through all the same code, except when it reaches the above part, battleChoiceVisited will be True.

If battleChoiceVisited = False Then
...~~~
Else
...Call InvalidEntry()
End If

So it'll Call InvalidEntry, which simply pops up a Message Box saying "Invalid entry." and it'll run through the rest of the code, doing nothing. Now, if you type something in properly, it'll notice that, and assign Battle Choice the appropriate thing. For this instance, let's say Attack was chosen. It'll also take note of whether you actually can attack or not at this moment, and if you can't, it'll Call InvalidEntry.

If Me.txtAction.Text = "attack" Then
...If attack = True Then
......battlechoice = "attack"
...Else
......Call InvalidEntry()
...End If
ElseIf Me.txtAction.Text = "heal" Then
...~~~
Else
...~~~
End If

Then, it'll pull out of the sub procedure ChooseBattleChoice, and run on down, taking note of what choice you made.

If battleChoice = "attack" Then
...If attackChoice = Nothing Then
......Call ChooseAttackChoice()
...End If

...If attackChoice <> Nothing Then
......Call AttackResult()
...End If

ElseIf battleChoice = "heal" Then
...~~~
End If

It'll do much the same thing it did before, with deciding if you've made an Attack Choice or not. It'll run through all that same stuff, only for making an Attack Choice, and since you haven't made one, and also haven't typed in what you want it to be...

If Me.txtAction.Text = "dagger" Then
...~~~
ElseIf Me.txtAction.Text = "fireball" Then
...~~~
Else
...If battleChoiceVisited = False Then
......Me.lblPrompt.Text = "What will you attack with?"
......battleChoiceVisited = True
...Else
......Call InvalidEntry()
...End If
End If

It'll ask you what you want to attack with. If you don't type in something proper, it calls InvalidEntry... if you do, it notes that choice, and runs on down the code, assuming you actually CAN use a dagger... or a fireball... this is how I will enable/disable weapons in the game. If they break... if you find them... if you get them stolen... all will change that weapon/ability variable to True/False. Now, once you make your selection..

If attackChoice <> Nothing Then
...Call AttackResult()
End If

And from here it'll run through the AttackResult procedure... which I'm sure you can figure out what that does just by looking at it.

Sub AttackResult()
...attackDamage = attackChoiceDamage
...enemyHealth = enemyHealth - attackDamage

...If enemyHealth > 0 Then
......Me.lblEnemyHealth.Text = "Enemy Health: " &amp;amp; enemyHealth
...Else
......Me.lblEnemyHealth.Text = "Enemy Health: 0"
...End If

...MessageBox.Show("You deal " &amp;amp; attackDamage &amp;amp; " damage to the " &amp;amp; enemy &amp;amp; " with your " &amp;amp; attackChoice &amp;amp; "!")
...battlechoice = Nothing
...attackChoice = Nothing
...attackDamage = 0
...attackChoiceDamage = 0
...battleChoiceVisited = False
...attackChoiceVisited = False

...If enemyHealth <= 0 Then
......MessageBox.Show("You killed the " &amp;amp; enemy &amp;amp; "!")
......Me.lblEnemyHealth.Text = Nothing
......enemyHealthDisplayed = False
......gameMode = "adventure"
......Call Adventure()
...Else
......Call Battle()
...End If
End Sub

No big secrets here, no need for an insanely-detailed explanation. Once you make your choice, after it calculates all the damage and displays the results, it'll clear your choices so that when it runs through the code again, you'll have to make your choices again. And if the enemy dies, it says so, and ends the fight and returns you to adventure mode appropriately.

This does of course quickly lead to redundancy... I hope to find a way to cut that out in the future. This is another area I may need help on. Perhaps I'll put in a "redo previous action" choice, which will check to make sure that it actually can redo the choice. If so, it'll just quickly change the battleChoice and attackChoice (assuming you attack) variables to their appropriate thing, and run through the AttackResult. So, say for example, your poison wears off, it'll still let you know. I'm very big on not having bugs in my programming. If there's a problem, I find a way to fix it.

As it is insanely unfinished, I'm not going to bother with trying to explain the adventure part of it all. I pretty much did so in the very beginning. You can see how all of this is pretty much taking on the same general form. No real surprises in the structure of the code. It checks for things, makes decisions based on the things.

That's pretty much it, I suppose... geeze, I sure did write out a lot, didn't I? Well, I have been looking for a great place to discuss my game, and get advice for how to move forward. This seems like the perfect place. Much better than asking around in the General chat of some game.

I greatly look forward to any responses. Thank you for taking the time to read through all this. Have a nice day! Posted Image

#10Varlun

Posted 16 November 2012 - 09:01 PM

Edit: I'm aware that the bits of code I've posted aren't properly spaced. Something about this word processor didn't like tabbing, so I'll have to go in and put the spaces myself... in other words, if you're seeing this Edit message and the code looks like shit, I'm probably fixing it at this very moment! Thank you for your patience. I know unspaced code is a nightmare to read. Hence why it does it automatically in the programmer.

Edit: I've put in some spacing... and actually, I figured out that it doesn't like spaces at all, so I'm having to use dots to space it. Which is a pain. But, it must be done.

Edit: Ugh, noticed another flaw created by this word processor... apparently, every time the symbol "&" was used, it put some funny stuff after it. I'll clear that out later, but for now, just know that that stuff isn't supposed to be there. I've never seen so many problems with a forum poster.

Hey everyone. I've seen many other posts say it, so I'll go ahead and throw in that this is my first post on these forums as well. So, yay.

Let's get right to it. I'm currently learning Visual Basic, and I feel that I've learned enough to get started on creating my own text-based adventure game. I'll post the entire code that I have so far below for inspection. I'd like to know if I'm on the right track. I'll probably select bits and pieces of the code afterward, and explain what happens, to save you guys the headache. It may or may not seem complex to you- I know I for one am impressed with what I've come up with so far. To think that I started with just a couple If statements.

So far, I've pretty much got about half of the combat system worked out. You can choose what you want to attack with, and it'll do damage, and will move on after the enemy dies, but the enemy doesn't fight back yet. I'll get to that. For now, I'm working on the adventure part of the game... where you can actually move from territory to territory, search for items, etc.

This part is largely unfinished, but the idea will be something like this: When you enter an area, it'll detect what area that is, and it'll detect what stage that area is in, and display a bit of text to describe it appropriately. From there, you'll have three options: move on, search, and inventory. Inventory is just disabled at the moment, I'll put that in a while later from now.

If you choose move on, the game will again detect where you are and what stage the area is in... it'll account for all the appropriate variables... and display an appropriate message of all the exits. It'll also assign the exits to forward/back/left/right options, which will be done by it detecting which area you were in previously (if you were in x room, then your direction is north, and selecting back will take you south / if you were in x room, then your direction is south, and selecting back will take you north).

And if you choose search, it'll look at all the appropriate things again, and display an appropriate message describing things in the area which you could possibly inspect. For example, if you enter an area for the first time, let's say there's a dagger in the corner. It would tell you there's a dagger in the corner. You could then type "inspect dagger" and it'll give you options... such as leave dagger/take dagger. If you leave the dagger, then obviously nothing changes. However, if you take the dagger... these are the sorts of things which will change the stage of an area. So in the future, when you come back to the room, and if you've taken the dagger, it won't tell you there's a dagger there anymore. It would instead, perhaps, mention a dagger-shaped clear spot in some dust, in that same corner, from where you took it. This would obviously create, frankly, a shitload of these "stages" when I get to having multiple items in a room. A bucket, a dagger, a sword, a key, a torch, a lamp, a... whatever. I feel like I'm definitely going to have to find a way to avoid this... perhaps somehow using multiple labels... but I don't know. This is an area I feel I need help in. For now, I'm going to avoid having more than one or two items. Which would, right there, create 4 different stages. x.x

So. In the future, I plan on giving every item a durability. I think I'm going to set it up where, as the durability goes down, the weapon/armor becomes increasingly useless- damage/defense bonuses go away, increasingly. And once/if it reaches 0, the item completely breaks down, either into nothing or just some bits of scrap... probably bits of scrap. And I'm going to make it where you can scavenge materials from things... such as breaking a bucket for bits of wood... and you'll be able to use these in conjunction with tools to repair your gear. So it'll be a constant fight to keep yourself well-geared. The more you fight, the more you have to manage yourself. In other words, no Leeroy Jenkins. Unless you're prepared. I really love the idea of this feature, because it requires you to use caution. If you get in too deep, by the time you get out, your gear may be so heavily damaged that you find yourself unable to enter areas which you previously had no problem with.

I also plan on there being an ability for you to clear out and make use of enemy strongholds. Like, if you completely eliminate the current enemy presence there, then you'll be free to set up camp. Now, in conjunction with this system, I'd like to set it up to where that bit of territory looks at the surrounding territories, and determines a percentage of invasion... and this percentage will be rolled every time you move... no matter where you are in the game. So obviously the percentage would be very low, but the point is, that if you don't manage the territory AROUND your base, then you may find it destroyed and overrun when you return. I'd also like to make it where the enemy can push out and expand, taking over territory. So there'll be a sort of tug-of-war. And yes, I'd love to also have the possibility in there for you to completely eliminate an enemy faction, where you never have to worry about them anymore. Taking out the source would obviously be a huge ordeal, but yeah. The point is the possibility being there.

I currently don't really have any plan to put in allies... I feel like I want to make it a sort of "you're on your own" type of game, where the entire goal is to get something which will get you out of this hellhole and back to civilization. But if I do put friendly factions in there, I'd love to give them bases of their own, coupled with the expansion system seen above... which would obviously eventually lead to constant border fighting between friendly and enemy factions, whether you're there or not. Posted Image

As far as natural creatures, not pertaining to any faction... they'll obviously thrive where no faction has control. I think I'll give uncontrolled areas a certain percentage for spawning creatures... reproduction and all that... and it'll go up over time, to 100%. This would naturally make it harder and harder to fight an enemy as you get closer to its source. I'll probably use the same system for friendly/enemy factions. But what I think I'll do is, if the territory is under control by one faction or another, that percentage will slowly die down, as whatever group goes around and weeds out the source of the problem... until that goes to 0%. So yes, again, the natural creatures could be completely eliminated. I want this game to contain those extreme possibilities. That's what makes a game interesting, no? Nobody really likes a game where everything is scripted. Well, I don't.

So those are ideas for the future. I guess I'll get to explaining what I have now. Here's the code. Oh, and once again, if you want a walkthrough of how this works, scroll down to after the code.

Public Class Form1

...Dim gameMode As String = "adventure"

...'Battle Variables
...Dim enemyHealth As Integer = 0
...Dim battleChoice As String = Nothing
...Dim enemy As String = Nothing
...Dim health As Integer = 1000
...Dim dragon As Boolean = True
...Dim dragonHealth As Integer = 50
...Dim battleChoiceVisited As Boolean = False
...Dim enemyHealthDisplayed As Boolean = False

...'Attack Variables
...Dim attack As Boolean = False
...Dim attackChoice As String = Nothing
...Dim attackChoiceDamage As Integer = 0
...Dim dagger As Boolean = False
...Dim daggerDamage As Integer = 25
...Dim fireball As Boolean = False
...Dim fireballDamage As Integer = 50
...Dim attackDamage As Integer = 0
...Dim attackChoiceVisited As Boolean = False

...'Heal Variables
...Dim heal As Boolean = False
...Dim weakHeal As Boolean = False
...Dim healChoice As String = Nothing
...Dim healChoiceAmount As Integer = 0
...Dim weakHealAmount As Integer = 0
...Dim strongHeal As Boolean = False
...Dim strongHealAmount As Integer = 0
...Dim healAmount As Integer = 0
...Dim healChoiceVisited As Boolean = False

...'Adventure Variables
...Dim adventureChoice As String = Nothing
...Dim worldLocation As String = "rockslide"
...Dim rockslideStage As Integer = 1
...Dim adventureChoiceVisited As Boolean = False
...Dim forestEntranceStage As Integer = 1

...'Search Variables
...Dim searchChoice As String = Nothing
...Dim search As Boolean = False

...'Move On Variables
...Dim moveOnChoice As String = Nothing
...Dim moveOn As Boolean = False

...'Inventory Variables
...Dim inventory As Boolean = False

...Private Sub btnAction_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAction.Click
......Select Case gameMode
.........Case "battle"
............Call Battle()
.........Case "adventure"
............Call Adventure()
......End Select
...End Sub

...Sub Battle()
......If enemyHealthDisplayed = False Then
.........Me.lblEnemyHealth.Text = "Enemy Health: " &amp;amp; enemyHealth
.........enemyHealthDisplayed = True
......End If

......If battleChoice = Nothing Then
.........Call ChooseBattleChoice()
......End If

......If battleChoice = "attack" Then
.........If attackChoice = Nothing Then
............Call ChooseAttackChoice()
.........End If

.........If attackChoice <> Nothing Then
............Call AttackResult()
.........End If

......ElseIf battleChoice = "heal" Then
.........If healChoice = Nothing Then
............Call ChooseHealChoice()
.........End If

.........If healChoice <> Nothing Then
...........Call HealResult()
.........End If
......End If
...End Sub

...Sub ChooseBattleChoice()
......If Me.txtAction.Text = "attack" Then
.........If attack = True Then
............battlechoice = "attack"
.........Else
............Call InvalidEntry()
.........End If

......ElseIf Me.txtAction.Text = "heal" Then
.........If heal = True Then
............battlechoice = "heal"
.........Else
............Call InvalidEntry()
.........End If

......Else
.........If battleChoiceVisited = False Then
............Me.lblPrompt.Text = "A " &amp;amp; enemy &amp;amp; " stands before you! What will you do?"
............battleChoiceVisited = True
.........Else
............Call InvalidEntry()
.........End If
......End If
...End Sub

...Sub ChooseAttackChoice()
If Me.txtAction.Text = "dagger" Then
If dagger = True Then
attackChoice = "dagger"
attackChoiceDamage = daggerDamage
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "fireball" Then
If fireball = True Then
attackChoice = "fireball"
attackChoiceDamage = fireballDamage
Else
Call InvalidEntry()
End If

Else
If battleChoiceVisited = False Then
Me.lblPrompt.Text = "What will you attack with?"
battleChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
...End Sub

...Sub AttackResult()
attackDamage = attackChoiceDamage
enemyHealth = enemyHealth - attackDamage

If enemyHealth > 0 Then
Me.lblEnemyHealth.Text = "Enemy Health: " &amp;amp; enemyHealth
Else
Me.lblEnemyHealth.Text = "Enemy Health: 0"
End If

MessageBox.Show("You deal " &amp;amp; attackDamage &amp;amp; " damage to the " &amp;amp; enemy &amp;amp; " with your " &amp;amp; attackChoice &amp;amp; "!")
battlechoice = Nothing
attackChoice = Nothing
attackDamage = 0
attackChoiceDamage = 0
battleChoiceVisited = False
attackChoiceVisited = False

If enemyHealth <= 0 Then
MessageBox.Show("You killed the " &amp;amp; enemy &amp;amp; "!")
Me.lblEnemyHealth.Text = Nothing
enemyHealthDisplayed = False
gameMode = "adventure"
Call Adventure()
Else
Call Battle()
End If
...End Sub

...Sub ChooseHealChoice()
If Me.txtAction.Text = "small heal" Then
If weakHeal = True Then
healChoice = "small heal"
healChoiceAmount = weakHealAmount
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "large heal" Then
If strongHeal = True Then
healChoice = "large heal"
healChoiceAmount = strongHealAmount
Else
Call InvalidEntry()
End If

Else
If healChoiceVisited = False Then
Me.lblPrompt.Text = "What will you heal with?"
healChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
...End Sub

...Sub HealResult()
healAmount = healChoiceAmount
health = health + healAmount

If health < 1000 Then
Me.lblHealth.Text = "Health: " &amp;amp; health
Else
Me.lblHealth.Text = "Health: 1000"
End If

MessageBox.Show("You restore " &amp;amp; healAmount &amp;amp; " health with your " &amp;amp; healChoice &amp;amp; "!")
battlechoice = Nothing
healChoice = Nothing
healAmount = 0
healChoiceAmount = 0
Call Battle()
...End Sub

...Sub Adventure()
If adventureChoice = Nothing Then
Call ChooseAdventureChoice()
End If

If adventureChoice = "search" Then
If searchChoice = Nothing Then
Call ChooseSearchChoice()
End If

If searchChoice <> Nothing Then
Call SearchResult()
End If

ElseIf adventureChoice = "move on" Then
If moveOnChoice = Nothing Then
Call ChooseMoveOnChoice()
End If

If moveOnChoice <> Nothing Then
Call MoveOnResult()
End If

ElseIf adventureChoice = "inventory" Then
Call Filler()
End If
...End Sub

...Sub ChooseAdventureChoice()
Select Case worldLocation
Case "rockslide"
Select Case rockslideStage
Case 1
If Me.txtAction.Text = "search" Then
If search = True Then
adventureChoice = "search"
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "move on" Then
If moveOn = True Then
adventureChoice = "move on"
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "inventory" Then
If inventory = True Then
adventureChoice = "inventory"
Else
Call InvalidEntry()
End If

Else
If adventureChoiceVisited = False Then
Me.txtAction.Text = "filler"
adventureChoiceVisited = True
Else
Call InvalidEntry()
End If
End If

Case 2
Call Filler()
End Select

Case "forestEntrance"
Select Case forestEntranceStage
Case 1
Call Filler()

Case 2
Call Filler()
End Select
End Select
...End Sub

...Sub ChooseSearchChoice()

...End Sub

...Sub SearchResult()

...End Sub

...Sub ChooseMoveOnChoice()

...End Sub

...Sub MoveOnResult()

...End Sub

...Sub AdventureResult()

...End Sub

...Sub InvalidEntry()
......MessageBox.Show("Invalid entry.")
...End Sub

...Sub GameLoad() Handles MyBase.Load
......Call Adventure()
...End Sub

...Sub Filler()
......MessageBox.Show("Feature not available.")
...End Sub
End Class

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'll explain how battle works. Now, what'll happen is, when it's determined that an enemy has shown up, it'll Call Battle, and that will determine if you've made a Battle Choice yet.

If battleChoice = Nothing Then
...Call ChooseBattleChoice()
End If

Obviously, you haven't, so it'll Call ChooseBattleChoice, and that will determine if you've typed in what you want your Battle Choice to be yet.

If Me.txtAction.Text = "attack" Then
...~~~
ElseIf Me.txtAction.Text = "heal" Then
...~~~
Else
...~~~
End If

And you haven't, so it'll determine if it's run through this bit of code before.

Else
...If battleChoiceVisited = False Then
...... ~~~
...Else
......~~~
...End If
End If

And you haven't, so it'll display the type of enemy that's standing before you, the type of enemy being declared in the very beginning, when it was determined by the game that an enemy was going to show up.

If battleChoiceVisited = False Then
...Me.lblPrompt.Text = "A " &amp;amp; enemy &amp;amp; " stands before you! What will you do?"
...battleChoiceVisited = True
Else
...~~~
End If

And it'll run out through the rest of the code and do nothing else, leaving you an opportunity to type something in and click Action, which is what the button is named. Now, if you type anything in other than what it wants you to, it'll run through all the same code, except when it reaches the above part, battleChoiceVisited will be True.

If battleChoiceVisited = False Then
...~~~
Else
...Call InvalidEntry()
End If

So it'll Call InvalidEntry, which simply pops up a Message Box saying "Invalid entry." and it'll run through the rest of the code, doing nothing. Now, if you type something in properly, it'll notice that, and assign Battle Choice the appropriate thing. For this instance, let's say Attack was chosen. It'll also take note of whether you actually can attack or not at this moment, and if you can't, it'll Call InvalidEntry.

If Me.txtAction.Text = "attack" Then
...If attack = True Then
......battlechoice = "attack"
...Else
......Call InvalidEntry()
...End If
ElseIf Me.txtAction.Text = "heal" Then
...~~~
Else
...~~~
End If

Then, it'll pull out of the sub procedure ChooseBattleChoice, and run on down, taking note of what choice you made.

If battleChoice = "attack" Then
...If attackChoice = Nothing Then
......Call ChooseAttackChoice()
...End If

...If attackChoice <> Nothing Then
......Call AttackResult()
...End If

ElseIf battleChoice = "heal" Then
...~~~
End If

It'll do much the same thing it did before, with deciding if you've made an Attack Choice or not. It'll run through all that same stuff, only for making an Attack Choice, and since you haven't made one, and also haven't typed in what you want it to be...

If Me.txtAction.Text = "dagger" Then
...~~~
ElseIf Me.txtAction.Text = "fireball" Then
...~~~
Else
...If battleChoiceVisited = False Then
......Me.lblPrompt.Text = "What will you attack with?"
......battleChoiceVisited = True
...Else
......Call InvalidEntry()
...End If
End If

It'll ask you what you want to attack with. If you don't type in something proper, it calls InvalidEntry... if you do, it notes that choice, and runs on down the code, assuming you actually CAN use a dagger... or a fireball... this is how I will enable/disable weapons in the game. If they break... if you find them... if you get them stolen... all will change that weapon/ability variable to True/False. Now, once you make your selection..

If attackChoice <> Nothing Then
...Call AttackResult()
End If

And from here it'll run through the AttackResult procedure... which I'm sure you can figure out what that does just by looking at it.

Sub AttackResult()
...attackDamage = attackChoiceDamage
...enemyHealth = enemyHealth - attackDamage

...If enemyHealth > 0 Then
......Me.lblEnemyHealth.Text = "Enemy Health: " &amp;amp; enemyHealth
...Else
......Me.lblEnemyHealth.Text = "Enemy Health: 0"
...End If

...MessageBox.Show("You deal " &amp;amp; attackDamage &amp;amp; " damage to the " &amp;amp; enemy &amp;amp; " with your " &amp;amp; attackChoice &amp;amp; "!")
...battlechoice = Nothing
...attackChoice = Nothing
...attackDamage = 0
...attackChoiceDamage = 0
...battleChoiceVisited = False
...attackChoiceVisited = False

...If enemyHealth <= 0 Then
......MessageBox.Show("You killed the " &amp;amp; enemy &amp;amp; "!")
......Me.lblEnemyHealth.Text = Nothing
......enemyHealthDisplayed = False
......gameMode = "adventure"
......Call Adventure()
...Else
......Call Battle()
...End If
End Sub

No big secrets here, no need for an insanely-detailed explanation. Once you make your choice, after it calculates all the damage and displays the results, it'll clear your choices so that when it runs through the code again, you'll have to make your choices again. And if the enemy dies, it says so, and ends the fight and returns you to adventure mode appropriately.

This does of course quickly lead to redundancy... I hope to find a way to cut that out in the future. This is another area I may need help on. Perhaps I'll put in a "redo previous action" choice, which will check to make sure that it actually can redo the choice. If so, it'll just quickly change the battleChoice and attackChoice (assuming you attack) variables to their appropriate thing, and run through the AttackResult. So, say for example, your poison wears off, it'll still let you know. I'm very big on not having bugs in my programming. If there's a problem, I find a way to fix it.

As it is insanely unfinished, I'm not going to bother with trying to explain the adventure part of it all. I pretty much did so in the very beginning. You can see how all of this is pretty much taking on the same general form. No real surprises in the structure of the code. It checks for things, makes decisions based on the things.

That's pretty much it, I suppose... geeze, I sure did write out a lot, didn't I? Well, I have been looking for a great place to discuss my game, and get advice for how to move forward. This seems like the perfect place. Much better than asking around in the General chat of some game.

I greatly look forward to any responses. Thank you for taking the time to read through all this. Have a nice day! Posted Image

#9Varlun

Posted 16 November 2012 - 08:55 PM

Edit: I'm aware that the bits of code I've posted aren't properly spaced. Something about this word processor didn't like tabbing, so I'll have to go in and put the spaces myself... in other words, if you're seeing this Edit message and the code looks like shit, I'm probably fixing it at this very moment! Thank you for your patience. I know unspaced code is a nightmare to read. Hence why it does it automatically in the programmer.

Edit: I've put in some spacing... and actually, I figured out that it doesn't like spaces at all, so I'm having to use dots to space it. Which is a pain. But, it must be done.

Hey everyone. I've seen many other posts say it, so I'll go ahead and throw in that this is my first post on these forums as well. So, yay.

Let's get right to it. I'm currently learning Visual Basic, and I feel that I've learned enough to get started on creating my own text-based adventure game. I'll post the entire code that I have so far below for inspection. I'd like to know if I'm on the right track. I'll probably select bits and pieces of the code afterward, and explain what happens, to save you guys the headache. It may or may not seem complex to you- I know I for one am impressed with what I've come up with so far. To think that I started with just a couple If statements.

So far, I've pretty much got about half of the combat system worked out. You can choose what you want to attack with, and it'll do damage, and will move on after the enemy dies, but the enemy doesn't fight back yet. I'll get to that. For now, I'm working on the adventure part of the game... where you can actually move from territory to territory, search for items, etc.

This part is largely unfinished, but the idea will be something like this: When you enter an area, it'll detect what area that is, and it'll detect what stage that area is in, and display a bit of text to describe it appropriately. From there, you'll have three options: move on, search, and inventory. Inventory is just disabled at the moment, I'll put that in a while later from now.

If you choose move on, the game will again detect where you are and what stage the area is in... it'll account for all the appropriate variables... and display an appropriate message of all the exits. It'll also assign the exits to forward/back/left/right options, which will be done by it detecting which area you were in previously (if you were in x room, then your direction is north, and selecting back will take you south / if you were in x room, then your direction is south, and selecting back will take you north).

And if you choose search, it'll look at all the appropriate things again, and display an appropriate message describing things in the area which you could possibly inspect. For example, if you enter an area for the first time, let's say there's a dagger in the corner. It would tell you there's a dagger in the corner. You could then type "inspect dagger" and it'll give you options... such as leave dagger/take dagger. If you leave the dagger, then obviously nothing changes. However, if you take the dagger... these are the sorts of things which will change the stage of an area. So in the future, when you come back to the room, and if you've taken the dagger, it won't tell you there's a dagger there anymore. It would instead, perhaps, mention a dagger-shaped clear spot in some dust, in that same corner, from where you took it. This would obviously create, frankly, a shitload of these "stages" when I get to having multiple items in a room. A bucket, a dagger, a sword, a key, a torch, a lamp, a... whatever. I feel like I'm definitely going to have to find a way to avoid this... perhaps somehow using multiple labels... but I don't know. This is an area I feel I need help in. For now, I'm going to avoid having more than one or two items. Which would, right there, create 4 different stages. x.x

So. In the future, I plan on giving every item a durability. I think I'm going to set it up where, as the durability goes down, the weapon/armor becomes increasingly useless- damage/defense bonuses go away, increasingly. And once/if it reaches 0, the item completely breaks down, either into nothing or just some bits of scrap... probably bits of scrap. And I'm going to make it where you can scavenge materials from things... such as breaking a bucket for bits of wood... and you'll be able to use these in conjunction with tools to repair your gear. So it'll be a constant fight to keep yourself well-geared. The more you fight, the more you have to manage yourself. In other words, no Leeroy Jenkins. Unless you're prepared. I really love the idea of this feature, because it requires you to use caution. If you get in too deep, by the time you get out, your gear may be so heavily damaged that you find yourself unable to enter areas which you previously had no problem with.

I also plan on there being an ability for you to clear out and make use of enemy strongholds. Like, if you completely eliminate the current enemy presence there, then you'll be free to set up camp. Now, in conjunction with this system, I'd like to set it up to where that bit of territory looks at the surrounding territories, and determines a percentage of invasion... and this percentage will be rolled every time you move... no matter where you are in the game. So obviously the percentage would be very low, but the point is, that if you don't manage the territory AROUND your base, then you may find it destroyed and overrun when you return. I'd also like to make it where the enemy can push out and expand, taking over territory. So there'll be a sort of tug-of-war. And yes, I'd love to also have the possibility in there for you to completely eliminate an enemy faction, where you never have to worry about them anymore. Taking out the source would obviously be a huge ordeal, but yeah. The point is the possibility being there.

I currently don't really have any plan to put in allies... I feel like I want to make it a sort of "you're on your own" type of game, where the entire goal is to get something which will get you out of this hellhole and back to civilization. But if I do put friendly factions in there, I'd love to give them bases of their own, coupled with the expansion system seen above... which would obviously eventually lead to constant border fighting between friendly and enemy factions, whether you're there or not. Posted Image

As far as natural creatures, not pertaining to any faction... they'll obviously thrive where no faction has control. I think I'll give uncontrolled areas a certain percentage for spawning creatures... reproduction and all that... and it'll go up over time, to 100%. This would naturally make it harder and harder to fight an enemy as you get closer to its source. I'll probably use the same system for friendly/enemy factions. But what I think I'll do is, if the territory is under control by one faction or another, that percentage will slowly die down, as whatever group goes around and weeds out the source of the problem... until that goes to 0%. So yes, again, the natural creatures could be completely eliminated. I want this game to contain those extreme possibilities. That's what makes a game interesting, no? Nobody really likes a game where everything is scripted. Well, I don't.

So those are ideas for the future. I guess I'll get to explaining what I have now. Here's the code. Oh, and once again, if you want a walkthrough of how this works, scroll down to after the code.

Public Class Form1

...Dim gameMode As String = "adventure"

...'Battle Variables
...Dim enemyHealth As Integer = 0
...Dim battleChoice As String = Nothing
...Dim enemy As String = Nothing
...Dim health As Integer = 1000
...Dim dragon As Boolean = True
...Dim dragonHealth As Integer = 50
...Dim battleChoiceVisited As Boolean = False
...Dim enemyHealthDisplayed As Boolean = False

...'Attack Variables
...Dim attack As Boolean = False
...Dim attackChoice As String = Nothing
...Dim attackChoiceDamage As Integer = 0
...Dim dagger As Boolean = False
...Dim daggerDamage As Integer = 25
...Dim fireball As Boolean = False
...Dim fireballDamage As Integer = 50
...Dim attackDamage As Integer = 0
...Dim attackChoiceVisited As Boolean = False

...'Heal Variables
...Dim heal As Boolean = False
...Dim weakHeal As Boolean = False
...Dim healChoice As String = Nothing
...Dim healChoiceAmount As Integer = 0
...Dim weakHealAmount As Integer = 0
...Dim strongHeal As Boolean = False
...Dim strongHealAmount As Integer = 0
...Dim healAmount As Integer = 0
...Dim healChoiceVisited As Boolean = False

...'Adventure Variables
...Dim adventureChoice As String = Nothing
...Dim worldLocation As String = "rockslide"
...Dim rockslideStage As Integer = 1
...Dim adventureChoiceVisited As Boolean = False
...Dim forestEntranceStage As Integer = 1

...'Search Variables
...Dim searchChoice As String = Nothing
...Dim search As Boolean = False

...'Move On Variables
...Dim moveOnChoice As String = Nothing
...Dim moveOn As Boolean = False

...'Inventory Variables
...Dim inventory As Boolean = False

...Private Sub btnAction_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAction.Click
......Select Case gameMode
.........Case "battle"
............Call Battle()
.........Case "adventure"
............Call Adventure()
......End Select
...End Sub

...Sub Battle()
......If enemyHealthDisplayed = False Then
.........Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
.........enemyHealthDisplayed = True
......End If

......If battleChoice = Nothing Then
.........Call ChooseBattleChoice()
......End If

......If battleChoice = "attack" Then
.........If attackChoice = Nothing Then
............Call ChooseAttackChoice()
.........End If

.........If attackChoice <> Nothing Then
............Call AttackResult()
.........End If

......ElseIf battleChoice = "heal" Then
.........If healChoice = Nothing Then
............Call ChooseHealChoice()
.........End If

.........If healChoice <> Nothing Then
...........Call HealResult()
.........End If
......End If
...End Sub

...Sub ChooseBattleChoice()
......If Me.txtAction.Text = "attack" Then
.........If attack = True Then
............battlechoice = "attack"
.........Else
............Call InvalidEntry()
.........End If

......ElseIf Me.txtAction.Text = "heal" Then
.........If heal = True Then
............battlechoice = "heal"
.........Else
............Call InvalidEntry()
.........End If

......Else
.........If battleChoiceVisited = False Then
............Me.lblPrompt.Text = "A " &amp; enemy &amp; " stands before you! What will you do?"
............battleChoiceVisited = True
.........Else
............Call InvalidEntry()
.........End If
......End If
...End Sub

...Sub ChooseAttackChoice()
If Me.txtAction.Text = "dagger" Then
If dagger = True Then
attackChoice = "dagger"
attackChoiceDamage = daggerDamage
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "fireball" Then
If fireball = True Then
attackChoice = "fireball"
attackChoiceDamage = fireballDamage
Else
Call InvalidEntry()
End If

Else
If battleChoiceVisited = False Then
Me.lblPrompt.Text = "What will you attack with?"
battleChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
...End Sub

...Sub AttackResult()
attackDamage = attackChoiceDamage
enemyHealth = enemyHealth - attackDamage

If enemyHealth > 0 Then
Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
Else
Me.lblEnemyHealth.Text = "Enemy Health: 0"
End If

MessageBox.Show("You deal " &amp; attackDamage &amp; " damage to the " &amp; enemy &amp; " with your " &amp; attackChoice &amp; "!")
battlechoice = Nothing
attackChoice = Nothing
attackDamage = 0
attackChoiceDamage = 0
battleChoiceVisited = False
attackChoiceVisited = False

If enemyHealth <= 0 Then
MessageBox.Show("You killed the " &amp; enemy &amp; "!")
Me.lblEnemyHealth.Text = Nothing
enemyHealthDisplayed = False
gameMode = "adventure"
Call Adventure()
Else
Call Battle()
End If
...End Sub

...Sub ChooseHealChoice()
If Me.txtAction.Text = "small heal" Then
If weakHeal = True Then
healChoice = "small heal"
healChoiceAmount = weakHealAmount
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "large heal" Then
If strongHeal = True Then
healChoice = "large heal"
healChoiceAmount = strongHealAmount
Else
Call InvalidEntry()
End If

Else
If healChoiceVisited = False Then
Me.lblPrompt.Text = "What will you heal with?"
healChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
...End Sub

...Sub HealResult()
healAmount = healChoiceAmount
health = health + healAmount

If health < 1000 Then
Me.lblHealth.Text = "Health: " &amp; health
Else
Me.lblHealth.Text = "Health: 1000"
End If

MessageBox.Show("You restore " &amp; healAmount &amp; " health with your " &amp; healChoice &amp; "!")
battlechoice = Nothing
healChoice = Nothing
healAmount = 0
healChoiceAmount = 0
Call Battle()
...End Sub

...Sub Adventure()
If adventureChoice = Nothing Then
Call ChooseAdventureChoice()
End If

If adventureChoice = "search" Then
If searchChoice = Nothing Then
Call ChooseSearchChoice()
End If

If searchChoice <> Nothing Then
Call SearchResult()
End If

ElseIf adventureChoice = "move on" Then
If moveOnChoice = Nothing Then
Call ChooseMoveOnChoice()
End If

If moveOnChoice <> Nothing Then
Call MoveOnResult()
End If

ElseIf adventureChoice = "inventory" Then
Call Filler()
End If
...End Sub

...Sub ChooseAdventureChoice()
Select Case worldLocation
Case "rockslide"
Select Case rockslideStage
Case 1
If Me.txtAction.Text = "search" Then
If search = True Then
adventureChoice = "search"
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "move on" Then
If moveOn = True Then
adventureChoice = "move on"
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "inventory" Then
If inventory = True Then
adventureChoice = "inventory"
Else
Call InvalidEntry()
End If

Else
If adventureChoiceVisited = False Then
Me.txtAction.Text = "filler"
adventureChoiceVisited = True
Else
Call InvalidEntry()
End If
End If

Case 2
Call Filler()
End Select

Case "forestEntrance"
Select Case forestEntranceStage
Case 1
Call Filler()

Case 2
Call Filler()
End Select
End Select
...End Sub

...Sub ChooseSearchChoice()

...End Sub

...Sub SearchResult()

...End Sub

...Sub ChooseMoveOnChoice()

...End Sub

...Sub MoveOnResult()

...End Sub

...Sub AdventureResult()

...End Sub

...Sub InvalidEntry()
......MessageBox.Show("Invalid entry.")
...End Sub

...Sub GameLoad() Handles MyBase.Load
......Call Adventure()
...End Sub

...Sub Filler()
......MessageBox.Show("Feature not available.")
...End Sub
End Class

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'll explain how battle works. Now, what'll happen is, when it's determined that an enemy has shown up, it'll Call Battle, and that will determine if you've made a Battle Choice yet.

If battleChoice = Nothing Then
...Call ChooseBattleChoice()
End If

Obviously, you haven't, so it'll Call ChooseBattleChoice, and that will determine if you've typed in what you want your Battle Choice to be yet.

If Me.txtAction.Text = "attack" Then
...~~~
ElseIf Me.txtAction.Text = "heal" Then
...~~~
Else
...~~~
End If

And you haven't, so it'll determine if it's run through this bit of code before.

Else
...If battleChoiceVisited = False Then
...... ~~~
...Else
......~~~
...End If
End If

And you haven't, so it'll display the type of enemy that's standing before you, the type of enemy being declared in the very beginning, when it was determined by the game that an enemy was going to show up.

If battleChoiceVisited = False Then
...Me.lblPrompt.Text = "A " &amp; enemy &amp; " stands before you! What will you do?"
...battleChoiceVisited = True
Else
...~~~
End If

And it'll run out through the rest of the code and do nothing else, leaving you an opportunity to type something in and click Action, which is what the button is named. Now, if you type anything in other than what it wants you to, it'll run through all the same code, except when it reaches the above part, battleChoiceVisited will be True.

If battleChoiceVisited = False Then
...~~~
Else
...Call InvalidEntry()
End If

So it'll Call InvalidEntry, which simply pops up a Message Box saying "Invalid entry." and it'll run through the rest of the code, doing nothing. Now, if you type something in properly, it'll notice that, and assign Battle Choice the appropriate thing. For this instance, let's say Attack was chosen. It'll also take note of whether you actually can attack or not at this moment, and if you can't, it'll Call InvalidEntry.

If Me.txtAction.Text = "attack" Then
...If attack = True Then
......battlechoice = "attack"
...Else
......Call InvalidEntry()
...End If
ElseIf Me.txtAction.Text = "heal" Then
...~~~
Else
...~~~
End If

Then, it'll pull out of the sub procedure ChooseBattleChoice, and run on down, taking note of what choice you made.

If battleChoice = "attack" Then
...If attackChoice = Nothing Then
......Call ChooseAttackChoice()
...End If

...If attackChoice <> Nothing Then
......Call AttackResult()
...End If

ElseIf battleChoice = "heal" Then
...~~~
End If

It'll do much the same thing it did before, with deciding if you've made an Attack Choice or not. It'll run through all that same stuff, only for making an Attack Choice, and since you haven't made one, and also haven't typed in what you want it to be...

If Me.txtAction.Text = "dagger" Then
...~~~
ElseIf Me.txtAction.Text = "fireball" Then
...~~~
Else
...If battleChoiceVisited = False Then
......Me.lblPrompt.Text = "What will you attack with?"
......battleChoiceVisited = True
...Else
......Call InvalidEntry()
...End If
End If

It'll ask you what you want to attack with. If you don't type in something proper, it calls InvalidEntry... if you do, it notes that choice, and runs on down the code, assuming you actually CAN use a dagger... or a fireball... this is how I will enable/disable weapons in the game. If they break... if you find them... if you get them stolen... all will change that weapon/ability variable to True/False. Now, once you make your selection..

If attackChoice <> Nothing Then
...Call AttackResult()
End If

And from here it'll run through the AttackResult procedure... which I'm sure you can figure out what that does just by looking at it.

Sub AttackResult()
...attackDamage = attackChoiceDamage
...enemyHealth = enemyHealth - attackDamage

...If enemyHealth > 0 Then
......Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
...Else
......Me.lblEnemyHealth.Text = "Enemy Health: 0"
...End If

...MessageBox.Show("You deal " &amp; attackDamage &amp; " damage to the " &amp; enemy &amp; " with your " &amp; attackChoice &amp; "!")
...battlechoice = Nothing
...attackChoice = Nothing
...attackDamage = 0
...attackChoiceDamage = 0
...battleChoiceVisited = False
...attackChoiceVisited = False

...If enemyHealth <= 0 Then
......MessageBox.Show("You killed the " &amp; enemy &amp; "!")
......Me.lblEnemyHealth.Text = Nothing
......enemyHealthDisplayed = False
......gameMode = "adventure"
......Call Adventure()
...Else
......Call Battle()
...End If
End Sub

No big secrets here, no need for an insanely-detailed explanation. Once you make your choice, after it calculates all the damage and displays the results, it'll clear your choices so that when it runs through the code again, you'll have to make your choices again. And if the enemy dies, it says so, and ends the fight and returns you to adventure mode appropriately.

This does of course quickly lead to redundancy... I hope to find a way to cut that out in the future. This is another area I may need help on. Perhaps I'll put in a "redo previous action" choice, which will check to make sure that it actually can redo the choice. If so, it'll just quickly change the battleChoice and attackChoice (assuming you attack) variables to their appropriate thing, and run through the AttackResult. So, say for example, your poison wears off, it'll still let you know. I'm very big on not having bugs in my programming. If there's a problem, I find a way to fix it.

As it is insanely unfinished, I'm not going to bother with trying to explain the adventure part of it all. I pretty much did so in the very beginning. You can see how all of this is pretty much taking on the same general form. No real surprises in the structure of the code. It checks for things, makes decisions based on the things.

That's pretty much it, I suppose... geeze, I sure did write out a lot, didn't I? Well, I have been looking for a great place to discuss my game, and get advice for how to move forward. This seems like the perfect place. Much better than asking around in the General chat of some game.

I greatly look forward to any responses. Thank you for taking the time to read through all this. Have a nice day! Posted Image

#8Varlun

Posted 16 November 2012 - 08:52 PM

Edit: I'm aware that the bits of code I've posted aren't properly spaced. Something about this word processor didn't like tabbing, so I'll have to go in and put the spaces myself... in other words, if you're seeing this Edit message and the code looks like shit, I'm probably fixing it at this very moment! Thank you for your patience. I know unspaced code is a nightmare to read. Hence why it does it automatically in the programmer.

Edit: I've put in some spacing... and actually, I figured out that it doesn't like spaces at all, so I'm having to use dots to space it. Which is a pain. But, it must be done.

Hey everyone. I've seen many other posts say it, so I'll go ahead and throw in that this is my first post on these forums as well. So, yay.

Let's get right to it. I'm currently learning Visual Basic, and I feel that I've learned enough to get started on creating my own text-based adventure game. I'll post the entire code that I have so far below for inspection. I'd like to know if I'm on the right track. I'll probably select bits and pieces of the code afterward, and explain what happens, to save you guys the headache. It may or may not seem complex to you- I know I for one am impressed with what I've come up with so far. To think that I started with just a couple If statements.

So far, I've pretty much got about half of the combat system worked out. You can choose what you want to attack with, and it'll do damage, and will move on after the enemy dies, but the enemy doesn't fight back yet. I'll get to that. For now, I'm working on the adventure part of the game... where you can actually move from territory to territory, search for items, etc.

This part is largely unfinished, but the idea will be something like this: When you enter an area, it'll detect what area that is, and it'll detect what stage that area is in, and display a bit of text to describe it appropriately. From there, you'll have three options: move on, search, and inventory. Inventory is just disabled at the moment, I'll put that in a while later from now.

If you choose move on, the game will again detect where you are and what stage the area is in... it'll account for all the appropriate variables... and display an appropriate message of all the exits. It'll also assign the exits to forward/back/left/right options, which will be done by it detecting which area you were in previously (if you were in x room, then your direction is north, and selecting back will take you south / if you were in x room, then your direction is south, and selecting back will take you north).

And if you choose search, it'll look at all the appropriate things again, and display an appropriate message describing things in the area which you could possibly inspect. For example, if you enter an area for the first time, let's say there's a dagger in the corner. It would tell you there's a dagger in the corner. You could then type "inspect dagger" and it'll give you options... such as leave dagger/take dagger. If you leave the dagger, then obviously nothing changes. However, if you take the dagger... these are the sorts of things which will change the stage of an area. So in the future, when you come back to the room, and if you've taken the dagger, it won't tell you there's a dagger there anymore. It would instead, perhaps, mention a dagger-shaped clear spot in some dust, in that same corner, from where you took it. This would obviously create, frankly, a shitload of these "stages" when I get to having multiple items in a room. A bucket, a dagger, a sword, a key, a torch, a lamp, a... whatever. I feel like I'm definitely going to have to find a way to avoid this... perhaps somehow using multiple labels... but I don't know. This is an area I feel I need help in. For now, I'm going to avoid having more than one or two items. Which would, right there, create 4 different stages. x.x

So. In the future, I plan on giving every item a durability. I think I'm going to set it up where, as the durability goes down, the weapon/armor becomes increasingly useless- damage/defense bonuses go away, increasingly. And once/if it reaches 0, the item completely breaks down, either into nothing or just some bits of scrap... probably bits of scrap. And I'm going to make it where you can scavenge materials from things... such as breaking a bucket for bits of wood... and you'll be able to use these in conjunction with tools to repair your gear. So it'll be a constant fight to keep yourself well-geared. The more you fight, the more you have to manage yourself. In other words, no Leeroy Jenkins. Unless you're prepared. I really love the idea of this feature, because it requires you to use caution. If you get in too deep, by the time you get out, your gear may be so heavily damaged that you find yourself unable to enter areas which you previously had no problem with.

I also plan on there being an ability for you to clear out and make use of enemy strongholds. Like, if you completely eliminate the current enemy presence there, then you'll be free to set up camp. Now, in conjunction with this system, I'd like to set it up to where that bit of territory looks at the surrounding territories, and determines a percentage of invasion... and this percentage will be rolled every time you move... no matter where you are in the game. So obviously the percentage would be very low, but the point is, that if you don't manage the territory AROUND your base, then you may find it destroyed and overrun when you return. I'd also like to make it where the enemy can push out and expand, taking over territory. So there'll be a sort of tug-of-war. And yes, I'd love to also have the possibility in there for you to completely eliminate an enemy faction, where you never have to worry about them anymore. Taking out the source would obviously be a huge ordeal, but yeah. The point is the possibility being there.

I currently don't really have any plan to put in allies... I feel like I want to make it a sort of "you're on your own" type of game, where the entire goal is to get something which will get you out of this hellhole and back to civilization. But if I do put friendly factions in there, I'd love to give them bases of their own, coupled with the expansion system seen above... which would obviously eventually lead to constant border fighting between friendly and enemy factions, whether you're there or not. Posted Image

As far as natural creatures, not pertaining to any faction... they'll obviously thrive where no faction has control. I think I'll give uncontrolled areas a certain percentage for spawning creatures... reproduction and all that... and it'll go up over time, to 100%. This would naturally make it harder and harder to fight an enemy as you get closer to its source. I'll probably use the same system for friendly/enemy factions. But what I think I'll do is, if the territory is under control by one faction or another, that percentage will slowly die down, as whatever group goes around and weeds out the source of the problem... until that goes to 0%. So yes, again, the natural creatures could be completely eliminated. I want this game to contain those extreme possibilities. That's what makes a game interesting, no? Nobody really likes a game where everything is scripted. Well, I don't.

So those are ideas for the future. I guess I'll get to explaining what I have now. Here's the code. Oh, and once again, if you want a walkthrough of how this works, scroll down to after the code.

Public Class Form1

...Dim gameMode As String = "adventure"

...'Battle Variables
...Dim enemyHealth As Integer = 0
...Dim battleChoice As String = Nothing
...Dim enemy As String = Nothing
...Dim health As Integer = 1000
...Dim dragon As Boolean = True
...Dim dragonHealth As Integer = 50
...Dim battleChoiceVisited As Boolean = False
...Dim enemyHealthDisplayed As Boolean = False

...'Attack Variables
...Dim attack As Boolean = False
...Dim attackChoice As String = Nothing
...Dim attackChoiceDamage As Integer = 0
...Dim dagger As Boolean = False
...Dim daggerDamage As Integer = 25
...Dim fireball As Boolean = False
...Dim fireballDamage As Integer = 50
...Dim attackDamage As Integer = 0
...Dim attackChoiceVisited As Boolean = False

...'Heal Variables
...Dim heal As Boolean = False
...Dim weakHeal As Boolean = False
...Dim healChoice As String = Nothing
...Dim healChoiceAmount As Integer = 0
...Dim weakHealAmount As Integer = 0
...Dim strongHeal As Boolean = False
...Dim strongHealAmount As Integer = 0
...Dim healAmount As Integer = 0
...Dim healChoiceVisited As Boolean = False

...'Adventure Variables
...Dim adventureChoice As String = Nothing
...Dim worldLocation As String = "rockslide"
...Dim rockslideStage As Integer = 1
...Dim adventureChoiceVisited As Boolean = False
...Dim forestEntranceStage As Integer = 1

...'Search Variables
...Dim searchChoice As String = Nothing
...Dim search As Boolean = False

...'Move On Variables
...Dim moveOnChoice As String = Nothing
...Dim moveOn As Boolean = False

...'Inventory Variables
...Dim inventory As Boolean = False

...Private Sub btnAction_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAction.Click
......Select Case gameMode
.........Case "battle"
............Call Battle()
.........Case "adventure"
............Call Adventure()
......End Select
...End Sub

...Sub Battle()
......If enemyHealthDisplayed = False Then
.........Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
.........enemyHealthDisplayed = True
......End If

......If battleChoice = Nothing Then
.........Call ChooseBattleChoice()
......End If

......If battleChoice = "attack" Then
.........If attackChoice = Nothing Then
............Call ChooseAttackChoice()
.........End If

......If attackChoice <> Nothing Then
.........Call AttackResult()
......End If

......ElseIf battleChoice = "heal" Then
.........If healChoice = Nothing Then
............Call ChooseHealChoice()
.........End If

.........If healChoice <> Nothing Then
...........Call HealResult()
.........End If
......End If
...End Sub

...Sub ChooseBattleChoice()
......If Me.txtAction.Text = "attack" Then
.........If attack = True Then
............battlechoice = "attack"
.........Else
............Call InvalidEntry()
.........End If

......ElseIf Me.txtAction.Text = "heal" Then
.........If heal = True Then
............battlechoice = "heal"
.........Else
............Call InvalidEntry()
.........End If

......Else
.........If battleChoiceVisited = False Then
............Me.lblPrompt.Text = "A " &amp; enemy &amp; " stands before you! What will you do?"
............battleChoiceVisited = True
.........Else
............Call InvalidEntry()
.........End If
......End If
...End Sub

...Sub ChooseAttackChoice()
If Me.txtAction.Text = "dagger" Then
If dagger = True Then
attackChoice = "dagger"
attackChoiceDamage = daggerDamage
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "fireball" Then
If fireball = True Then
attackChoice = "fireball"
attackChoiceDamage = fireballDamage
Else
Call InvalidEntry()
End If

Else
If battleChoiceVisited = False Then
Me.lblPrompt.Text = "What will you attack with?"
battleChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
...End Sub

...Sub AttackResult()
attackDamage = attackChoiceDamage
enemyHealth = enemyHealth - attackDamage

If enemyHealth > 0 Then
Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
Else
Me.lblEnemyHealth.Text = "Enemy Health: 0"
End If

MessageBox.Show("You deal " &amp; attackDamage &amp; " damage to the " &amp; enemy &amp; " with your " &amp; attackChoice &amp; "!")
battlechoice = Nothing
attackChoice = Nothing
attackDamage = 0
attackChoiceDamage = 0
battleChoiceVisited = False
attackChoiceVisited = False

If enemyHealth <= 0 Then
MessageBox.Show("You killed the " &amp; enemy &amp; "!")
Me.lblEnemyHealth.Text = Nothing
enemyHealthDisplayed = False
gameMode = "adventure"
Call Adventure()
Else
Call Battle()
End If
...End Sub

...Sub ChooseHealChoice()
If Me.txtAction.Text = "small heal" Then
If weakHeal = True Then
healChoice = "small heal"
healChoiceAmount = weakHealAmount
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "large heal" Then
If strongHeal = True Then
healChoice = "large heal"
healChoiceAmount = strongHealAmount
Else
Call InvalidEntry()
End If

Else
If healChoiceVisited = False Then
Me.lblPrompt.Text = "What will you heal with?"
healChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
...End Sub

...Sub HealResult()
healAmount = healChoiceAmount
health = health + healAmount

If health < 1000 Then
Me.lblHealth.Text = "Health: " &amp; health
Else
Me.lblHealth.Text = "Health: 1000"
End If

MessageBox.Show("You restore " &amp; healAmount &amp; " health with your " &amp; healChoice &amp; "!")
battlechoice = Nothing
healChoice = Nothing
healAmount = 0
healChoiceAmount = 0
Call Battle()
...End Sub

...Sub Adventure()
If adventureChoice = Nothing Then
Call ChooseAdventureChoice()
End If

If adventureChoice = "search" Then
If searchChoice = Nothing Then
Call ChooseSearchChoice()
End If

If searchChoice <> Nothing Then
Call SearchResult()
End If

ElseIf adventureChoice = "move on" Then
If moveOnChoice = Nothing Then
Call ChooseMoveOnChoice()
End If

If moveOnChoice <> Nothing Then
Call MoveOnResult()
End If

ElseIf adventureChoice = "inventory" Then
Call Filler()
End If
...End Sub

...Sub ChooseAdventureChoice()
Select Case worldLocation
Case "rockslide"
Select Case rockslideStage
Case 1
If Me.txtAction.Text = "search" Then
If search = True Then
adventureChoice = "search"
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "move on" Then
If moveOn = True Then
adventureChoice = "move on"
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "inventory" Then
If inventory = True Then
adventureChoice = "inventory"
Else
Call InvalidEntry()
End If

Else
If adventureChoiceVisited = False Then
Me.txtAction.Text = "filler"
adventureChoiceVisited = True
Else
Call InvalidEntry()
End If
End If

Case 2
Call Filler()
End Select

Case "forestEntrance"
Select Case forestEntranceStage
Case 1
Call Filler()

Case 2
Call Filler()
End Select
End Select
...End Sub

...Sub ChooseSearchChoice()

...End Sub

...Sub SearchResult()

...End Sub

...Sub ChooseMoveOnChoice()

...End Sub

...Sub MoveOnResult()

...End Sub

...Sub AdventureResult()

...End Sub

...Sub InvalidEntry()
......MessageBox.Show("Invalid entry.")
...End Sub

...Sub GameLoad() Handles MyBase.Load
......Call Adventure()
...End Sub

...Sub Filler()
......MessageBox.Show("Feature not available.")
...End Sub
End Class

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'll explain how battle works. Now, what'll happen is, when it's determined that an enemy has shown up, it'll Call Battle, and that will determine if you've made a Battle Choice yet.

If battleChoice = Nothing Then
...Call ChooseBattleChoice()
End If

Obviously, you haven't, so it'll Call ChooseBattleChoice, and that will determine if you've typed in what you want your Battle Choice to be yet.

If Me.txtAction.Text = "attack" Then
...~~~
ElseIf Me.txtAction.Text = "heal" Then
...~~~
Else
...~~~
End If

And you haven't, so it'll determine if it's run through this bit of code before.

Else
...If battleChoiceVisited = False Then
...... ~~~
...Else
......~~~
...End If
End If

And you haven't, so it'll display the type of enemy that's standing before you, the type of enemy being declared in the very beginning, when it was determined by the game that an enemy was going to show up.

If battleChoiceVisited = False Then
...Me.lblPrompt.Text = "A " &amp; enemy &amp; " stands before you! What will you do?"
...battleChoiceVisited = True
Else
...~~~
End If

And it'll run out through the rest of the code and do nothing else, leaving you an opportunity to type something in and click Action, which is what the button is named. Now, if you type anything in other than what it wants you to, it'll run through all the same code, except when it reaches the above part, battleChoiceVisited will be True.

If battleChoiceVisited = False Then
...~~~
Else
...Call InvalidEntry()
End If

So it'll Call InvalidEntry, which simply pops up a Message Box saying "Invalid entry." and it'll run through the rest of the code, doing nothing. Now, if you type something in properly, it'll notice that, and assign Battle Choice the appropriate thing. For this instance, let's say Attack was chosen. It'll also take note of whether you actually can attack or not at this moment, and if you can't, it'll Call InvalidEntry.

If Me.txtAction.Text = "attack" Then
...If attack = True Then
......battlechoice = "attack"
...Else
......Call InvalidEntry()
...End If
ElseIf Me.txtAction.Text = "heal" Then
...~~~
Else
...~~~
End If

Then, it'll pull out of the sub procedure ChooseBattleChoice, and run on down, taking note of what choice you made.

If battleChoice = "attack" Then
...If attackChoice = Nothing Then
......Call ChooseAttackChoice()
...End If

...If attackChoice <> Nothing Then
......Call AttackResult()
...End If

ElseIf battleChoice = "heal" Then
...~~~
End If

It'll do much the same thing it did before, with deciding if you've made an Attack Choice or not. It'll run through all that same stuff, only for making an Attack Choice, and since you haven't made one, and also haven't typed in what you want it to be...

If Me.txtAction.Text = "dagger" Then
...~~~
ElseIf Me.txtAction.Text = "fireball" Then
...~~~
Else
...If battleChoiceVisited = False Then
......Me.lblPrompt.Text = "What will you attack with?"
......battleChoiceVisited = True
...Else
......Call InvalidEntry()
...End If
End If

It'll ask you what you want to attack with. If you don't type in something proper, it calls InvalidEntry... if you do, it notes that choice, and runs on down the code, assuming you actually CAN use a dagger... or a fireball... this is how I will enable/disable weapons in the game. If they break... if you find them... if you get them stolen... all will change that weapon/ability variable to True/False. Now, once you make your selection..

If attackChoice <> Nothing Then
...Call AttackResult()
End If

And from here it'll run through the AttackResult procedure... which I'm sure you can figure out what that does just by looking at it.

Sub AttackResult()
...attackDamage = attackChoiceDamage
...enemyHealth = enemyHealth - attackDamage

...If enemyHealth > 0 Then
......Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
...Else
......Me.lblEnemyHealth.Text = "Enemy Health: 0"
...End If

...MessageBox.Show("You deal " &amp; attackDamage &amp; " damage to the " &amp; enemy &amp; " with your " &amp; attackChoice &amp; "!")
...battlechoice = Nothing
...attackChoice = Nothing
...attackDamage = 0
...attackChoiceDamage = 0
...battleChoiceVisited = False
...attackChoiceVisited = False

...If enemyHealth <= 0 Then
......MessageBox.Show("You killed the " &amp; enemy &amp; "!")
......Me.lblEnemyHealth.Text = Nothing
......enemyHealthDisplayed = False
......gameMode = "adventure"
......Call Adventure()
...Else
......Call Battle()
...End If
End Sub

No big secrets here, no need for an insanely-detailed explanation. Once you make your choice, after it calculates all the damage and displays the results, it'll clear your choices so that when it runs through the code again, you'll have to make your choices again. And if the enemy dies, it says so, and ends the fight and returns you to adventure mode appropriately.

This does of course quickly lead to redundancy... I hope to find a way to cut that out in the future. This is another area I may need help on. Perhaps I'll put in a "redo previous action" choice, which will check to make sure that it actually can redo the choice. If so, it'll just quickly change the battleChoice and attackChoice (assuming you attack) variables to their appropriate thing, and run through the AttackResult. So, say for example, your poison wears off, it'll still let you know. I'm very big on not having bugs in my programming. If there's a problem, I find a way to fix it.

As it is insanely unfinished, I'm not going to bother with trying to explain the adventure part of it all. I pretty much did so in the very beginning. You can see how all of this is pretty much taking on the same general form. No real surprises in the structure of the code. It checks for things, makes decisions based on the things.

That's pretty much it, I suppose... geeze, I sure did write out a lot, didn't I? Well, I have been looking for a great place to discuss my game, and get advice for how to move forward. This seems like the perfect place. Much better than asking around in the General chat of some game.

I greatly look forward to any responses. Thank you for taking the time to read through all this. Have a nice day! Posted Image

#7Varlun

Posted 16 November 2012 - 08:36 PM

Edit: I'm aware that the bits of code I've posted aren't properly spaced. Something about this word processor didn't like tabbing, so I'll have to go in and put the spaces myself... in other words, if you're seeing this Edit message and the code looks like shit, I'm probably fixing it at this very moment! Thank you for your patience. I know unspaced code is a nightmare to read. Hence why it does it automatically in the programmer.

Hey everyone. I've seen many other posts say it, so I'll go ahead and throw in that this is my first post on these forums as well. So, yay.

Let's get right to it. I'm currently learning Visual Basic, and I feel that I've learned enough to get started on creating my own text-based adventure game. I'll post the entire code that I have so far below for inspection. I'd like to know if I'm on the right track. I'll probably select bits and pieces of the code afterward, and explain what happens, to save you guys the headache. It may or may not seem complex to you- I know I for one am impressed with what I've come up with so far. To think that I started with just a couple If statements.

So far, I've pretty much got about half of the combat system worked out. You can choose what you want to attack with, and it'll do damage, and will move on after the enemy dies, but the enemy doesn't fight back yet. I'll get to that. For now, I'm working on the adventure part of the game... where you can actually move from territory to territory, search for items, etc.

This part is largely unfinished, but the idea will be something like this: When you enter an area, it'll detect what area that is, and it'll detect what stage that area is in, and display a bit of text to describe it appropriately. From there, you'll have three options: move on, search, and inventory. Inventory is just disabled at the moment, I'll put that in a while later from now.

If you choose move on, the game will again detect where you are and what stage the area is in... it'll account for all the appropriate variables... and display an appropriate message of all the exits. It'll also assign the exits to forward/back/left/right options, which will be done by it detecting which area you were in previously (if you were in x room, then your direction is north, and selecting back will take you south / if you were in x room, then your direction is south, and selecting back will take you north).

And if you choose search, it'll look at all the appropriate things again, and display an appropriate message describing things in the area which you could possibly inspect. For example, if you enter an area for the first time, let's say there's a dagger in the corner. It would tell you there's a dagger in the corner. You could then type "inspect dagger" and it'll give you options... such as leave dagger/take dagger. If you leave the dagger, then obviously nothing changes. However, if you take the dagger... these are the sorts of things which will change the stage of an area. So in the future, when you come back to the room, and if you've taken the dagger, it won't tell you there's a dagger there anymore. It would instead, perhaps, mention a dagger-shaped clear spot in some dust, in that same corner, from where you took it. This would obviously create, frankly, a shitload of these "stages" when I get to having multiple items in a room. A bucket, a dagger, a sword, a key, a torch, a lamp, a... whatever. I feel like I'm definitely going to have to find a way to avoid this... perhaps somehow using multiple labels... but I don't know. This is an area I feel I need help in. For now, I'm going to avoid having more than one or two items. Which would, right there, create 4 different stages. x.x

So. In the future, I plan on giving every item a durability. I think I'm going to set it up where, as the durability goes down, the weapon/armor becomes increasingly useless- damage/defense bonuses go away, increasingly. And once/if it reaches 0, the item completely breaks down, either into nothing or just some bits of scrap... probably bits of scrap. And I'm going to make it where you can scavenge materials from things... such as breaking a bucket for bits of wood... and you'll be able to use these in conjunction with tools to repair your gear. So it'll be a constant fight to keep yourself well-geared. The more you fight, the more you have to manage yourself. In other words, no Leeroy Jenkins. Unless you're prepared. I really love the idea of this feature, because it requires you to use caution. If you get in too deep, by the time you get out, your gear may be so heavily damaged that you find yourself unable to enter areas which you previously had no problem with.

I also plan on there being an ability for you to clear out and make use of enemy strongholds. Like, if you completely eliminate the current enemy presence there, then you'll be free to set up camp. Now, in conjunction with this system, I'd like to set it up to where that bit of territory looks at the surrounding territories, and determines a percentage of invasion... and this percentage will be rolled every time you move... no matter where you are in the game. So obviously the percentage would be very low, but the point is, that if you don't manage the territory AROUND your base, then you may find it destroyed and overrun when you return. I'd also like to make it where the enemy can push out and expand, taking over territory. So there'll be a sort of tug-of-war. And yes, I'd love to also have the possibility in there for you to completely eliminate an enemy faction, where you never have to worry about them anymore. Taking out the source would obviously be a huge ordeal, but yeah. The point is the possibility being there.

I currently don't really have any plan to put in allies... I feel like I want to make it a sort of "you're on your own" type of game, where the entire goal is to get something which will get you out of this hellhole and back to civilization. But if I do put friendly factions in there, I'd love to give them bases of their own, coupled with the expansion system seen above... which would obviously eventually lead to constant border fighting between friendly and enemy factions, whether you're there or not. Posted Image

As far as natural creatures, not pertaining to any faction... they'll obviously thrive where no faction has control. I think I'll give uncontrolled areas a certain percentage for spawning creatures... reproduction and all that... and it'll go up over time, to 100%. This would naturally make it harder and harder to fight an enemy as you get closer to its source. I'll probably use the same system for friendly/enemy factions. But what I think I'll do is, if the territory is under control by one faction or another, that percentage will slowly die down, as whatever group goes around and weeds out the source of the problem... until that goes to 0%. So yes, again, the natural creatures could be completely eliminated. I want this game to contain those extreme possibilities. That's what makes a game interesting, no? Nobody really likes a game where everything is scripted. Well, I don't.

So those are ideas for the future. I guess I'll get to explaining what I have now. Here's the code. Oh, and once again, if you want a walkthrough of how this works, scroll down to after the code.

Public Class Form1

Dim gameMode As String = "adventure"

'Battle Variables
Dim enemyHealth As Integer = 0
Dim battleChoice As String = Nothing
Dim enemy As String = Nothing
Dim health As Integer = 1000
Dim dragon As Boolean = True
Dim dragonHealth As Integer = 50
Dim battleChoiceVisited As Boolean = False
Dim enemyHealthDisplayed As Boolean = False


'Attack Variables
Dim attack As Boolean = False
Dim attackChoice As String = Nothing
Dim attackChoiceDamage As Integer = 0
Dim dagger As Boolean = False
Dim daggerDamage As Integer = 25
Dim fireball As Boolean = False
Dim fireballDamage As Integer = 50
Dim attackDamage As Integer = 0
Dim attackChoiceVisited As Boolean = False

'Heal Variables
Dim heal As Boolean = False
Dim weakHeal As Boolean = False
Dim healChoice As String = Nothing
Dim healChoiceAmount As Integer = 0
Dim weakHealAmount As Integer = 0
Dim strongHeal As Boolean = False
Dim strongHealAmount As Integer = 0
Dim healAmount As Integer = 0
Dim healChoiceVisited As Boolean = False


'Adventure Variables
Dim adventureChoice As String = Nothing
Dim worldLocation As String = "rockslide"
Dim rockslideStage As Integer = 1
Dim adventureChoiceVisited As Boolean = False
Dim forestEntranceStage As Integer = 1

'Search Variables
Dim searchChoice As String = Nothing
Dim search As Boolean = False


'Move On Variables
Dim moveOnChoice As String = Nothing
Dim moveOn As Boolean = False

'Inventory Variables
Dim inventory As Boolean = False


Private Sub btnAction_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAction.Click
Select Case gameMode
Case "battle"
Call Battle()
Case "adventure"
Call Adventure()
End Select
End Sub

Sub Battle()
If enemyHealthDisplayed = False Then
Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
enemyHealthDisplayed = True
End If


If battleChoice = Nothing Then
Call ChooseBattleChoice()
End If

If battleChoice = "attack" Then
If attackChoice = Nothing Then
Call ChooseAttackChoice()
End If


If attackChoice <> Nothing Then
Call AttackResult()
End If

ElseIf battleChoice = "heal" Then
If healChoice = Nothing Then
Call ChooseHealChoice()
End If


If healChoice <> Nothing Then
Call HealResult()
End If
End If
End Sub

Sub ChooseBattleChoice()
If Me.txtAction.Text = "attack" Then
If attack = True Then
battlechoice = "attack"
Else
Call InvalidEntry()
End If


ElseIf Me.txtAction.Text = "heal" Then
If heal = True Then
battlechoice = "heal"
Else
Call InvalidEntry()
End If

Else
If battleChoiceVisited = False Then
Me.lblPrompt.Text = "A " &amp; enemy &amp; " stands before you! What will you do?"
battleChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
End Sub


Sub ChooseAttackChoice()
If Me.txtAction.Text = "dagger" Then
If dagger = True Then
attackChoice = "dagger"
attackChoiceDamage = daggerDamage
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "fireball" Then
If fireball = True Then
attackChoice = "fireball"
attackChoiceDamage = fireballDamage
Else
Call InvalidEntry()
End If


Else
If battleChoiceVisited = False Then
Me.lblPrompt.Text = "What will you attack with?"
battleChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
End Sub

Sub AttackResult()
attackDamage = attackChoiceDamage
enemyHealth = enemyHealth - attackDamage


If enemyHealth > 0 Then
Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
Else
Me.lblEnemyHealth.Text = "Enemy Health: 0"
End If

MessageBox.Show("You deal " &amp; attackDamage &amp; " damage to the " &amp; enemy &amp; " with your " &amp; attackChoice &amp; "!")
battlechoice = Nothing
attackChoice = Nothing
attackDamage = 0
attackChoiceDamage = 0
battleChoiceVisited = False
attackChoiceVisited = False


If enemyHealth <= 0 Then
MessageBox.Show("You killed the " &amp; enemy &amp; "!")
Me.lblEnemyHealth.Text = Nothing
enemyHealthDisplayed = False
gameMode = "adventure"
Call Adventure()
Else
Call Battle()
End If
End Sub

Sub ChooseHealChoice()
If Me.txtAction.Text = "small heal" Then
If weakHeal = True Then
healChoice = "small heal"
healChoiceAmount = weakHealAmount
Else
Call InvalidEntry()
End If


ElseIf Me.txtAction.Text = "large heal" Then
If strongHeal = True Then
healChoice = "large heal"
healChoiceAmount = strongHealAmount
Else
Call InvalidEntry()
End If

Else
If healChoiceVisited = False Then
Me.lblPrompt.Text = "What will you heal with?"
healChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
End Sub


Sub HealResult()
healAmount = healChoiceAmount
health = health + healAmount

If health < 1000 Then
Me.lblHealth.Text = "Health: " &amp; health
Else
Me.lblHealth.Text = "Health: 1000"
End If


MessageBox.Show("You restore " &amp; healAmount &amp; " health with your " &amp; healChoice &amp; "!")
battlechoice = Nothing
healChoice = Nothing
healAmount = 0
healChoiceAmount = 0
Call Battle()
End Sub


Sub Adventure()
If adventureChoice = Nothing Then
Call ChooseAdventureChoice()
End If

If adventureChoice = "search" Then
If searchChoice = Nothing Then
Call ChooseSearchChoice()
End If


If searchChoice <> Nothing Then
Call SearchResult()
End If

ElseIf adventureChoice = "move on" Then
If moveOnChoice = Nothing Then
Call ChooseMoveOnChoice()
End If


If moveOnChoice <> Nothing Then
Call MoveOnResult()
End If

ElseIf adventureChoice = "inventory" Then
Call Filler()
End If
End Sub


Sub ChooseAdventureChoice()
Select Case worldLocation
Case "rockslide"
Select Case rockslideStage
Case 1
If Me.txtAction.Text = "search" Then
If search = True Then
adventureChoice = "search"
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "move on" Then
If moveOn = True Then
adventureChoice = "move on"
Else
Call InvalidEntry()
End If


ElseIf Me.txtAction.Text = "inventory" Then
If inventory = True Then
adventureChoice = "inventory"
Else
Call InvalidEntry()
End If

Else
If adventureChoiceVisited = False Then
Me.txtAction.Text = "filler"
adventureChoiceVisited = True
Else
Call InvalidEntry()
End If
End If


Case 2
Call Filler()
End Select

Case "forestEntrance"
Select Case forestEntranceStage
Case 1
Call Filler()

Case 2
Call Filler()
End Select
End Select
End Sub


Sub ChooseSearchChoice()

End Sub


Sub SearchResult()

End Sub


Sub ChooseMoveOnChoice()

End Sub


Sub MoveOnResult()

End Sub


Sub AdventureResult()

End Sub


Sub InvalidEntry()
MessageBox.Show("Invalid entry.")
End Sub

Sub GameLoad() Handles MyBase.Load
Call Adventure()
End Sub


Sub Filler()
MessageBox.Show("Feature not available.")
End Sub
End Class

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'll explain how battle works. Now, what'll happen is, when it's determined that an enemy has shown up, it'll Call Battle, and that will determine if you've made a Battle Choice yet.

If battleChoice = Nothing Then
Call ChooseBattleChoice()
End If

Obviously, you haven't, so it'll Call ChooseBattleChoice, and that will determine if you've typed in what you want your Battle Choice to be yet.

If Me.txtAction.Text = "attack" Then
~~~
ElseIf Me.txtAction.Text = "heal" Then
~~~
Else
~~~
End If

And you haven't, so it'll determine if it's run through this bit of code before.

Else
If battleChoiceVisited = False Then
~~~
Else
~~~
End If
End If

And you haven't, so it'll display the type of enemy that's standing before you, the type of enemy being declared in the very beginning, when it was determined by the game that an enemy was going to show up.

If battleChoiceVisited = False Then
Me.lblPrompt.Text = "A " &amp; enemy &amp; " stands before you! What will you do?"
battleChoiceVisited = True
Else
~~~
End If

And it'll run out through the rest of the code and do nothing else, leaving you an opportunity to type something in and click Action, which is what the button is named. Now, if you type anything in other than what it wants you to, it'll run through all the same code, except when it reaches the above part, battleChoiceVisited will be True.

If battleChoiceVisited = False Then
~~~
Else
Call InvalidEntry()
End If

So it'll Call InvalidEntry, which simply pops up a Message Box saying "Invalid entry." and it'll run through the rest of the code, doing nothing. Now, if you type something in properly, it'll notice that, and assign Battle Choice the appropriate thing. For this instance, let's say Attack was chosen. It'll also take note of whether you actually can attack or not at this moment, and if you can't, it'll Call InvalidEntry.

If Me.txtAction.Text = "attack" Then
If attack = True Then
battlechoice = "attack"
Else
Call InvalidEntry()
End If
ElseIf Me.txtAction.Text = "heal" Then
~~~
Else
~~~
End If

Then, it'll pull out of the sub procedure ChooseBattleChoice, and run on down, taking note of what choice you made.


If battleChoice = "attack" Then
If attackChoice = Nothing Then
Call ChooseAttackChoice()
End If


If attackChoice <> Nothing Then
Call AttackResult()
End If

ElseIf battleChoice = "heal" Then
~~~

End If

It'll do much the same thing it did before, with deciding if you've made an Attack Choice or not. It'll run through all that same stuff, only for making an Attack Choice, and since you haven't made one, and also haven't typed in what you want it to be...

If Me.txtAction.Text = "dagger" Then
~~~
ElseIf Me.txtAction.Text = "fireball" Then
~~~
Else
If battleChoiceVisited = False Then
Me.lblPrompt.Text = "What will you attack with?"
battleChoiceVisited = True
Else
Call InvalidEntry()
End If
End If

It'll ask you what you want to attack with. If you don't type in something proper, it calls InvalidEntry... if you do, it notes that choice, and runs on down the code, assuming you actually CAN use a dagger... or a fireball... this is how I will enable/disable weapons in the game. If they break... if you find them... if you get them stolen... all will change that weapon/ability variable to True/False. Now, once you make your selection..

If attackChoice <> Nothing Then
Call AttackResult()
End If

And from here it'll run through the AttackResult procedure... which I'm sure you can figure out what that does just by looking at it.

Sub AttackResult()
attackDamage = attackChoiceDamage
enemyHealth = enemyHealth - attackDamage


If enemyHealth > 0 Then
Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
Else
Me.lblEnemyHealth.Text = "Enemy Health: 0"
End If

MessageBox.Show("You deal " &amp; attackDamage &amp; " damage to the " &amp; enemy &amp; " with your " &amp; attackChoice &amp; "!")
battlechoice = Nothing
attackChoice = Nothing
attackDamage = 0
attackChoiceDamage = 0
battleChoiceVisited = False
attackChoiceVisited = False


If enemyHealth <= 0 Then
MessageBox.Show("You killed the " &amp; enemy &amp; "!")
Me.lblEnemyHealth.Text = Nothing
enemyHealthDisplayed = False
gameMode = "adventure"
Call Adventure()
Else
Call Battle()
End If
End Sub

No big secrets here, no need for an insanely-detailed explanation. Once you make your choice, after it calculates all the damage and displays the results, it'll clear your choices so that when it runs through the code again, you'll have to make your choices again. And if the enemy dies, it says so, and ends the fight and returns you to adventure mode appropriately.

This does of course quickly lead to redundancy... I hope to find a way to cut that out in the future. This is another area I may need help on. Perhaps I'll put in a "redo previous action" choice, which will check to make sure that it actually can redo the choice. If so, it'll just quickly change the battleChoice and attackChoice (assuming you attack) variables to their appropriate thing, and run through the AttackResult. So, say for example, your poison wears off, it'll still let you know. I'm very big on not having bugs in my programming. If there's a problem, I find a way to fix it.

As it is insanely unfinished, I'm not going to bother with trying to explain the adventure part of it all. I pretty much did so in the very beginning. You can see how all of this is pretty much taking on the same general form. No real surprises in the structure of the code. It checks for things, makes decisions based on the things.

That's pretty much it, I suppose... geeze, I sure did write out a lot, didn't I? Well, I have been looking for a great place to discuss my game, and get advice for how to move forward. This seems like the perfect place. Much better than asking around in the General chat of some game.

I greatly look forward to any responses. Thank you for taking the time to read through all this. Have a nice day! Posted Image

#6Varlun

Posted 16 November 2012 - 08:15 PM

Edit: I'm aware that the bits of code I've posted aren't properly spaced. Something about this word processor didn't like tabbing, so I'll have to go in and put the spaces myself... in other words, if you're seeing this Edit message and the code looks like shit, I'm probably fixing it at this very moment! Thank you for your patience. I know unspaced code is a nightmare to read. Hence why it does it automatically in the programmer.

Hey everyone. I've seen many other posts say it, so I'll go ahead and throw in that this is my first post on these forums as well. So, yay.

Let's get right to it. I'm currently learning Visual Basic, and I feel that I've learned enough to get started on creating my own text-based adventure game. I'll post the entire code that I have so far below for inspection. I'd like to know if I'm on the right track. I'll probably select bits and pieces of the code afterward, and explain what happens, to save you guys the headache. It may or may not seem complex to you- I know I for one am impressed with what I've come up with so far. To think that I started with just a couple If statements.

So far, I've pretty much got about half of the combat system worked out. You can choose what you want to attack with, and it'll do damage, and will move on after the enemy dies, but the enemy doesn't fight back yet. I'll get to that. For now, I'm working on the adventure part of the game... where you can actually move from territory to territory, search for items, etc.

This part is largely unfinished, but the idea will be something like this: When you enter an area, it'll detect what area that is, and it'll detect what stage that area is in, and display a bit of text to describe it appropriately. From there, you'll have three options: move on, search, and inventory. Inventory is just disabled at the moment, I'll put that in a while later from now.

If you choose move on, the game will again detect where you are and what stage the area is in... it'll account for all the appropriate variables... and display an appropriate message of all the exits. It'll also assign the exits to forward/back/left/right options, which will be done by it detecting which area you were in previously (if you were in x room, then your direction is north, and selecting back will take you south / if you were in x room, then your direction is south, and selecting back will take you north).

And if you choose search, it'll look at all the appropriate things again, and display an appropriate message describing things in the area which you could possibly inspect. For example, if you enter an area for the first time, let's say there's a dagger in the corner. It would tell you there's a dagger in the corner. You could then type "inspect dagger" and it'll give you options... such as leave dagger/take dagger. If you leave the dagger, then obviously nothing changes. However, if you take the dagger... these are the sorts of things which will change the stage of an area. So in the future, when you come back to the room, and if you've taken the dagger, it won't tell you there's a dagger there anymore. It would instead, perhaps, mention a dagger-shaped clear spot in some dust, in that same corner, from where you took it. This would obviously create, frankly, a shitload of these "stages" when I get to having multiple items in a room. A bucket, a dagger, a sword, a key, a torch, a lamp, a... whatever. I feel like I'm definitely going to have to find a way to avoid this... perhaps somehow using multiple labels... but I don't know. This is an area I feel I need help in. For now, I'm going to avoid having more than one or two items. Which would, right there, create 4 different stages. x.x

So. In the future, I plan on giving every item a durability. I think I'm going to set it up where, as the durability goes down, the weapon/armor becomes increasingly useless- damage/defense bonuses go away, increasingly. And once/if it reaches 0, the item completely breaks down, either into nothing or just some bits of scrap... probably bits of scrap. And I'm going to make it where you can scavenge materials from things... such as breaking a bucket for bits of wood... and you'll be able to use these in conjunction with tools to repair your gear. So it'll be a constant fight to keep yourself well-geared. The more you fight, the more you have to manage yourself. In other words, no Leeroy Jenkins. Unless you're prepared. I really love the idea of this feature, because it requires you to use caution. If you get in too deep, by the time you get out, your gear may be so heavily damaged that you find yourself unable to enter areas which you previously had no problem with.

I also plan on there being an ability for you to clear out and make use of enemy strongholds. Like, if you completely eliminate the current enemy presence there, then you'll be free to set up camp. Now, in conjunction with this system, I'd like to set it up to where that bit of territory looks at the surrounding territories, and determines a percentage of invasion... and this percentage will be rolled every time you move... no matter where you are in the game. So obviously the percentage would be very low, but the point is, that if you don't manage the territory AROUND your base, then you may find it destroyed and overrun when you return. I'd also like to make it where the enemy can push out and expand, taking over territory. So there'll be a sort of tug-of-war. And yes, I'd love to also have the possibility in there for you to completely eliminate an enemy faction, where you never have to worry about them anymore. Taking out the source would obviously be a huge ordeal, but yeah. The point is the possibility being there.

I currently don't really have any plan to put in allies... I feel like I want to make it a sort of "you're on your own" type of game, where the entire goal is to get something which will get you out of this hellhole and back to civilization. But if I do put friendly factions in there, I'd love to give them bases of their own, coupled with the expansion system seen above... which would obviously eventually lead to constant border fighting between friendly and enemy factions, whether you're there or not. :D

As far as natural creatures, not pertaining to any faction... they'll obviously thrive where no faction has control. I think I'll give uncontrolled areas a certain percentage for spawning creatures... reproduction and all that... and it'll go up over time, to 100%. This would naturally make it harder and harder to fight an enemy as you get closer to its source. I'll probably use the same system for friendly/enemy factions. But what I think I'll do is, if the territory is under control by one faction or another, that percentage will slowly die down, as whatever group goes around and weeds out the source of the problem... until that goes to 0%. So yes, again, the natural creatures could be completely eliminated. I want this game to contain those extreme possibilities. That's what makes a game interesting, no? Nobody really likes a game where everything is scripted. Well, I don't.

So those are ideas for the future. I guess I'll get to explaining what I have now. Here's the code. Oh, and once again, if you want a walkthrough of how this works, scroll down to after the code.

Public Class Form1


Dim gameMode As String = "adventure"

'Battle Variables
Dim enemyHealth As Integer = 0
Dim battleChoice As String = Nothing
Dim enemy As String = Nothing
Dim health As Integer = 1000
Dim dragon As Boolean = True
Dim dragonHealth As Integer = 50
Dim battleChoiceVisited As Boolean = False
Dim enemyHealthDisplayed As Boolean = False


'Attack Variables
Dim attack As Boolean = False
Dim attackChoice As String = Nothing
Dim attackChoiceDamage As Integer = 0
Dim dagger As Boolean = False
Dim daggerDamage As Integer = 25
Dim fireball As Boolean = False
Dim fireballDamage As Integer = 50
Dim attackDamage As Integer = 0
Dim attackChoiceVisited As Boolean = False

'Heal Variables
Dim heal As Boolean = False
Dim weakHeal As Boolean = False
Dim healChoice As String = Nothing
Dim healChoiceAmount As Integer = 0
Dim weakHealAmount As Integer = 0
Dim strongHeal As Boolean = False
Dim strongHealAmount As Integer = 0
Dim healAmount As Integer = 0
Dim healChoiceVisited As Boolean = False


'Adventure Variables
Dim adventureChoice As String = Nothing
Dim worldLocation As String = "rockslide"
Dim rockslideStage As Integer = 1
Dim adventureChoiceVisited As Boolean = False
Dim forestEntranceStage As Integer = 1

'Search Variables
Dim searchChoice As String = Nothing
Dim search As Boolean = False


'Move On Variables
Dim moveOnChoice As String = Nothing
Dim moveOn As Boolean = False

'Inventory Variables
Dim inventory As Boolean = False


Private Sub btnAction_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAction.Click
Select Case gameMode
Case "battle"
Call Battle()
Case "adventure"
Call Adventure()
End Select
End Sub

Sub Battle()
If enemyHealthDisplayed = False Then
Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
enemyHealthDisplayed = True
End If


If battleChoice = Nothing Then
Call ChooseBattleChoice()
End If

If battleChoice = "attack" Then
If attackChoice = Nothing Then
Call ChooseAttackChoice()
End If


If attackChoice <> Nothing Then
Call AttackResult()
End If

ElseIf battleChoice = "heal" Then
If healChoice = Nothing Then
Call ChooseHealChoice()
End If


If healChoice <> Nothing Then
Call HealResult()
End If
End If
End Sub

Sub ChooseBattleChoice()
If Me.txtAction.Text = "attack" Then
If attack = True Then
battlechoice = "attack"
Else
Call InvalidEntry()
End If


ElseIf Me.txtAction.Text = "heal" Then
If heal = True Then
battlechoice = "heal"
Else
Call InvalidEntry()
End If

Else
If battleChoiceVisited = False Then
Me.lblPrompt.Text = "A " &amp; enemy &amp; " stands before you! What will you do?"
battleChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
End Sub


Sub ChooseAttackChoice()
If Me.txtAction.Text = "dagger" Then
If dagger = True Then
attackChoice = "dagger"
attackChoiceDamage = daggerDamage
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "fireball" Then
If fireball = True Then
attackChoice = "fireball"
attackChoiceDamage = fireballDamage
Else
Call InvalidEntry()
End If


Else
If battleChoiceVisited = False Then
Me.lblPrompt.Text = "What will you attack with?"
battleChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
End Sub

Sub AttackResult()
attackDamage = attackChoiceDamage
enemyHealth = enemyHealth - attackDamage


If enemyHealth > 0 Then
Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
Else
Me.lblEnemyHealth.Text = "Enemy Health: 0"
End If

MessageBox.Show("You deal " &amp; attackDamage &amp; " damage to the " &amp; enemy &amp; " with your " &amp; attackChoice &amp; "!")
battlechoice = Nothing
attackChoice = Nothing
attackDamage = 0
attackChoiceDamage = 0
battleChoiceVisited = False
attackChoiceVisited = False


If enemyHealth <= 0 Then
MessageBox.Show("You killed the " &amp; enemy &amp; "!")
Me.lblEnemyHealth.Text = Nothing
enemyHealthDisplayed = False
gameMode = "adventure"
Call Adventure()
Else
Call Battle()
End If
End Sub

Sub ChooseHealChoice()
If Me.txtAction.Text = "small heal" Then
If weakHeal = True Then
healChoice = "small heal"
healChoiceAmount = weakHealAmount
Else
Call InvalidEntry()
End If


ElseIf Me.txtAction.Text = "large heal" Then
If strongHeal = True Then
healChoice = "large heal"
healChoiceAmount = strongHealAmount
Else
Call InvalidEntry()
End If

Else
If healChoiceVisited = False Then
Me.lblPrompt.Text = "What will you heal with?"
healChoiceVisited = True
Else
Call InvalidEntry()
End If
End If
End Sub


Sub HealResult()
healAmount = healChoiceAmount
health = health + healAmount

If health < 1000 Then
Me.lblHealth.Text = "Health: " &amp; health
Else
Me.lblHealth.Text = "Health: 1000"
End If


MessageBox.Show("You restore " &amp; healAmount &amp; " health with your " &amp; healChoice &amp; "!")
battlechoice = Nothing
healChoice = Nothing
healAmount = 0
healChoiceAmount = 0
Call Battle()
End Sub


Sub Adventure()
If adventureChoice = Nothing Then
Call ChooseAdventureChoice()
End If

If adventureChoice = "search" Then
If searchChoice = Nothing Then
Call ChooseSearchChoice()
End If


If searchChoice <> Nothing Then
Call SearchResult()
End If

ElseIf adventureChoice = "move on" Then
If moveOnChoice = Nothing Then
Call ChooseMoveOnChoice()
End If


If moveOnChoice <> Nothing Then
Call MoveOnResult()
End If

ElseIf adventureChoice = "inventory" Then
Call Filler()
End If
End Sub


Sub ChooseAdventureChoice()
Select Case worldLocation
Case "rockslide"
Select Case rockslideStage
Case 1
If Me.txtAction.Text = "search" Then
If search = True Then
adventureChoice = "search"
Else
Call InvalidEntry()
End If

ElseIf Me.txtAction.Text = "move on" Then
If moveOn = True Then
adventureChoice = "move on"
Else
Call InvalidEntry()
End If


ElseIf Me.txtAction.Text = "inventory" Then
If inventory = True Then
adventureChoice = "inventory"
Else
Call InvalidEntry()
End If

Else
If adventureChoiceVisited = False Then
Me.txtAction.Text = "filler"
adventureChoiceVisited = True
Else
Call InvalidEntry()
End If
End If


Case 2
Call Filler()
End Select

Case "forestEntrance"
Select Case forestEntranceStage
Case 1
Call Filler()

Case 2
Call Filler()
End Select
End Select
End Sub


Sub ChooseSearchChoice()

End Sub


Sub SearchResult()

End Sub


Sub ChooseMoveOnChoice()

End Sub


Sub MoveOnResult()

End Sub


Sub AdventureResult()

End Sub


Sub InvalidEntry()
MessageBox.Show("Invalid entry.")
End Sub

Sub GameLoad() Handles MyBase.Load
Call Adventure()
End Sub


Sub Filler()
MessageBox.Show("Feature not available.")
End Sub
End Class

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'll explain how battle works. Now, what'll happen is, when it's determined that an enemy has shown up, it'll Call Battle, and that will determine if you've made a Battle Choice yet.

If battleChoice = Nothing Then
Call ChooseBattleChoice()
End If

Obviously, you haven't, so it'll Call ChooseBattleChoice, and that will determine if you've typed in what you want your Battle Choice to be yet.

If Me.txtAction.Text = "attack" Then
~~~
ElseIf Me.txtAction.Text = "heal" Then
~~~
Else
~~~
End If

And you haven't, so it'll determine if it's run through this bit of code before.

Else
If battleChoiceVisited = False Then
~~~
Else
~~~
End If
End If

And you haven't, so it'll display the type of enemy that's standing before you, the type of enemy being declared in the very beginning, when it was determined by the game that an enemy was going to show up.

If battleChoiceVisited = False Then
Me.lblPrompt.Text = "A " &amp; enemy &amp; " stands before you! What will you do?"
battleChoiceVisited = True
Else
~~~
End If

And it'll run out through the rest of the code and do nothing else, leaving you an opportunity to type something in and click Action, which is what the button is named. Now, if you type anything in other than what it wants you to, it'll run through all the same code, except when it reaches the above part, battleChoiceVisited will be True.

If battleChoiceVisited = False Then
~~~
Else
Call InvalidEntry()
End If

So it'll Call InvalidEntry, which simply pops up a Message Box saying "Invalid entry." and it'll run through the rest of the code, doing nothing. Now, if you type something in properly, it'll notice that, and assign Battle Choice the appropriate thing. For this instance, let's say Attack was chosen. It'll also take note of whether you actually can attack or not at this moment, and if you can't, it'll Call InvalidEntry.

If Me.txtAction.Text = "attack" Then
If attack = True Then
battlechoice = "attack"
Else
Call InvalidEntry()
End If
ElseIf Me.txtAction.Text = "heal" Then
~~~
Else
~~~
End If

Then, it'll pull out of the sub procedure ChooseBattleChoice, and run on down, taking note of what choice you made.


If battleChoice = "attack" Then
If attackChoice = Nothing Then
Call ChooseAttackChoice()
End If


If attackChoice <> Nothing Then
Call AttackResult()
End If

ElseIf battleChoice = "heal" Then
~~~

End If

It'll do much the same thing it did before, with deciding if you've made an Attack Choice or not. It'll run through all that same stuff, only for making an Attack Choice, and since you haven't made one, and also haven't typed in what you want it to be...

If Me.txtAction.Text = "dagger" Then
~~~
ElseIf Me.txtAction.Text = "fireball" Then
~~~
Else
If battleChoiceVisited = False Then
Me.lblPrompt.Text = "What will you attack with?"
battleChoiceVisited = True
Else
Call InvalidEntry()
End If
End If

It'll ask you what you want to attack with. If you don't type in something proper, it calls InvalidEntry... if you do, it notes that choice, and runs on down the code, assuming you actually CAN use a dagger... or a fireball... this is how I will enable/disable weapons in the game. If they break... if you find them... if you get them stolen... all will change that weapon/ability variable to True/False. Now, once you make your selection..

If attackChoice <> Nothing Then
Call AttackResult()
End If

And from here it'll run through the AttackResult procedure... which I'm sure you can figure out what that does just by looking at it.

Sub AttackResult()
attackDamage = attackChoiceDamage
enemyHealth = enemyHealth - attackDamage


If enemyHealth > 0 Then
Me.lblEnemyHealth.Text = "Enemy Health: " &amp; enemyHealth
Else
Me.lblEnemyHealth.Text = "Enemy Health: 0"
End If

MessageBox.Show("You deal " &amp; attackDamage &amp; " damage to the " &amp; enemy &amp; " with your " &amp; attackChoice &amp; "!")
battlechoice = Nothing
attackChoice = Nothing
attackDamage = 0
attackChoiceDamage = 0
battleChoiceVisited = False
attackChoiceVisited = False


If enemyHealth <= 0 Then
MessageBox.Show("You killed the " &amp; enemy &amp; "!")
Me.lblEnemyHealth.Text = Nothing
enemyHealthDisplayed = False
gameMode = "adventure"
Call Adventure()
Else
Call Battle()
End If
End Sub

No big secrets here, no need for an insanely-detailed explanation. Once you make your choice, after it calculates all the damage and displays the results, it'll clear your choices so that when it runs through the code again, you'll have to make your choices again. And if the enemy dies, it says so, and ends the fight and returns you to adventure mode appropriately.

This does of course quickly lead to redundancy... I hope to find a way to cut that out in the future. This is another area I may need help on. Perhaps I'll put in a "redo previous action" choice, which will check to make sure that it actually can redo the choice. If so, it'll just quickly change the battleChoice and attackChoice (assuming you attack) variables to their appropriate thing, and run through the AttackResult. So, say for example, your poison wears off, it'll still let you know. I'm very big on not having bugs in my programming. If there's a problem, I find a way to fix it.

As it is insanely unfinished, I'm not going to bother with trying to explain the adventure part of it all. I pretty much did so in the very beginning. You can see how all of this is pretty much taking on the same general form. No real surprises in the structure of the code. It checks for things, makes decisions based on the things.

That's pretty much it, I suppose... geeze, I sure did write out a lot, didn't I? Well, I have been looking for a great place to discuss my game, and get advice for how to move forward. This seems like the perfect place. Much better than asking around in the General chat of some game.

I greatly look forward to any responses. Thank you for taking the time to read through all this. Have a nice day! :D

PARTNERS