none
Text RPG RRS feed

  • Question

  • TextWindow.Title = "Overworld Slayer"
    skeleton()
    
    Sub HP
      dmg1 = Math.GetRandomNumber(20) + 5
      SNHP = 25
      PLAYERHP = 100
    endsub
    
    Sub skeletondeath
       if (SNHP = 0 or SNHP < 0) Then
        win()
      endif
    EndSub
    
    Sub skeleton
    HP()
    skeletondeath()
    TextWindow.WriteLine("A skeleton appears!!!")
    TextWindow.WriteLine(" ")
    TextWindow.WriteLine("1. Use your sword")
    TextWindow.WriteLine("2. Use a smoke bomb")
    TextWindow.WriteLine("3. Run Away")
    TextWindow.WriteLine("4. Use a HP Potion")
    TextWindow.WriteLine(" ")
    encounter1 = TextWindow.ReadNumber()
    move()
    EndSub
    
    Sub move
    HP()
    If encounter1 = 1 Then
      TextWindow.Clear()
      TextWindow.WriteLine("You use your sword and deal " + dmg1 + " damage")
      SNHP = SNHP - dmg1
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      skeleton()
    elseIf encounter1 = 2 Then
      TextWindow.Hide()
    elseIf encounter1 = 3 Then
      TextWindow.Hide()
    elseIf encounter1 = 4 Then
      TextWindow.Clear()
      PLAYERHP = PLAYERHP + 10
      TextWindow.WriteLine("You gain 10 HP")
      TextWindow.WriteLine(" ")
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      skeleton()
    endif
    EndSub
    
    sub win
      TextWindow.Clear()
      TextWindow.WriteLine("You gain 10 exp and 5 gold")
      TextWindow.PauseWithoutMessage()
      TextWindow.Hide()
    EndSub    


    So when the skeleton's hp becomes zero it doesn't go to the win screen where...

    You gain 10 exp and 5 gold

    I can't figure out how to fix it.

    And do I make it so you can only 1 2 3 or 4 works (also to make it so [enter] doesn't do anything) and if you press some other number like 41515 it doesn't do anything.

     

    TextWindow.WriteLine("A skeleton appears!!!")
    TextWindow.WriteLine(" ")
    TextWindow.WriteLine("1. Use your sword")
    TextWindow.WriteLine("2. Use a smoke bomb")
    TextWindow.WriteLine("3. Run Away")
    TextWindow.WriteLine("4. Use a HP Potion")
    TextWindow.WriteLine(" ")
    encounter1 = TextWindow.ReadNumber()




    • Edited by Dinomite07 Friday, September 5, 2014 5:25 PM
    Friday, September 5, 2014 5:02 PM

Answers

  • The number in the parameter (the data in the parenthesis) is randomly selected by the computer. Using the line below as an example.

    Math.GetRandomNumber(16) + 9
    The number in the parameter is 16 so the computer will randomly select numbers from 1 to 16. In other words, 16 is the greatest possible number for the computer to select. It has sixteen numbers to choose from. It selects only one number starting from 1 2 3 4 . . . all the way to 16. No higher. After the computer selects a number (16 being the limit), it will add 9 to it. So the lowest possible outcome is 1 + 9 (sum of 10) and the highest being 16 + 9 (sum of 25). Again it could also be 2 + 9 or 3+9 or 12+9. Thus, the possible outcomes range from 10 to 25.


    • Edited by Ezra94 Sunday, September 7, 2014 3:49 AM Reword
    • Marked as answer by Dinomite07 Sunday, September 7, 2014 4:39 AM
    Sunday, September 7, 2014 3:47 AM

All replies

  • Hello Dinimite,

    I tested your program, after the choices 2 en 3 the textwindow closes and the program ends.

    Choices 1 and 4 give the message about wins or damages after which the menu reappears.

    But .... due to the call of HP()  SNHP and PLAYERHP are reset to their starting values.

    You can check this by changing the "a skeloton appears " line into 

    TextWindow.WriteLine("A skeleton appears!!!  "+SNHP+"  "+playerhp) which shows that SNHP is always 25 and PLAYERHP always 100.

    Addition: Do you know that you can use :  if SNHP <= 0  Then . as a combined test.


    Jan [ WhTurner ] The Netherlands


    • Edited by WhTurner33Editor Friday, September 5, 2014 5:44 PM addition
    • Proposed as answer by Ezra94 Sunday, September 7, 2014 5:21 PM
    Friday, September 5, 2014 5:35 PM
    Answerer
  • TextWindow.Title = "Overworld Slayer"
    intro()
    playervariables()  
    skeletonvariables()

    Sub enter
        TextWindow.WriteLine(" ")
        TextWindow.WriteLine("Press [Enter]")
    EndSub
     
    Sub playervariables
        dmg1 = Math.GetRandomNumber(20) + 5
        PLAYERHP = 100
        HPPot = 3
        smokeb = 3
        exp = 0
        gold = 0
    EndSub
     
    Sub skeletonvariables
       SNHP = 25
       if (SNHP <= 0) Then
        win()
      endif
    EndSub
     
    Sub wrongoption
      TextWindow.Clear()
      TextWindow.WriteLine("You can only select 1 2 3 or 4")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
    EndSub
     
    Sub intro
      TextWindow.WriteLine("You are a lone slayer in the depths of Hell.")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      TextWindow.WriteLine("You have made it your life's duty to slay all the monsters")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      TextWindow.WriteLine("and cleansing Hell of its evil...")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
    location()
    endsub

    Sub location
      TextWindow.WriteLine("Select an option below")
      TextWindow.WriteLine(" ")
      TextWindow.WriteLine("1. Walk North")
      TextWindow.WriteLine("2. Walk East")
      TextWindow.WriteLine("3. Walk West")
      TextWindow.WriteLine("4. Walk South")
      TextWindow.WriteLine(" ")
      loc = TextWindow.ReadNumber()
      If loc = 1 Then
        TextWindow.Clear()
        skeleton()
       elseIf loc = 2 Then
        TextWindow.Clear()
        skeleton()
       elseIf loc = 3 Then
        TextWindow.Clear()
        skeleton()
       elseIf loc = 4 Then
        TextWindow.Clear()
        skeleton()
      Else
        wrongoption()
        location()
      EndIf
    EndSub

    Sub skeleton
    TextWindow.WriteLine("A skeleton appears")
    TextWindow.WriteLine(" ")
    TextWindow.WriteLine("Player HP: " + PLAYERHP)
    TextWindow.WriteLine("Skeleton HP: " + SNHP)
    TextWindow.WriteLine(" ")
    TextWindow.WriteLine("1. Use your sword")
    TextWindow.WriteLine("2. Use a HP Potion: x" + HPPot)
    TextWindow.WriteLine("3. Use a smoke bomb: x" + smokeb)
    TextWindow.WriteLine("4. Run Away")
    TextWindow.WriteLine(" ")
    encounter1 = TextWindow.ReadNumber()
    move1()
    EndSub

    Sub move1
      If encounter1 = 1 Then  
      TextWindow.Clear()
      TextWindow.WriteLine("You use your sword and deal " + dmg1 + " damage")
      SNHP = SNHP - dmg1
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      skeleton()
    elseIf encounter1 = 2 Then
      TextWindow.Clear()
      TextWindow.WriteLine("You gain 10 HP")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      PLAYERHP = PLAYERHP + 10
      HPPot = HPPot - 1
      skeleton()
    elseIf encounter1 = 3 Then
      TextWindow.Clear()
      smokeb = smokeb - 1
      location()
    elseIf encounter1 = 4 Then
      TextWindow.Hide()
    Else
      wrongoption()
      skeleton()
    endif
    EndSub

    sub win
      TextWindow.Clear()
      TextWindow.WriteLine("You gain 10 exp and 5 gold")
      enter()
      TextWindow.PauseWithoutMessage()
      gold = gold + 5
      exp = exp + 10
      TextWindow.Hide()
    EndSub     

    So how would I make the sword do damage to the skeleton. For the HP Pots to appear and when you have no more HP Pots the option disappears or it has no effect. Same for the smoke bombs.




    • Edited by Dinomite07 Saturday, September 6, 2014 12:30 AM
    Friday, September 5, 2014 10:05 PM
  • Hello Dinomite07,

    I basically renamed some of your subroutines, rearrange some code, and included hp for player and hp/damage for skeleton enemies. To make coding your text-based RPG easier, I inputed "LF = Text.GetCharacter (10)" in your code, which creates spacing between your lines. 

    LF = Text.GetCharacter(10)
    
    TextWindow.Title = "OVERWORLD SLAYER"
    
    PLAYERHP = 100 'Intial value of player's HP 
    
    intro() 
    
    Sub intro
      line[1] = "You are a lone slayer in the depths of Hell."
      line[2] = "You have made it your life's duty to slay all the monsters"
      line[3] = "and cleansing Hell of its evil..."
      
      For i = 1 To Array.GetItemCount(line)  
        TextWindow.Writeline(line[i]) 
        enter()
        TextWindow.PauseWithoutMessage()
        TextWindow.Clear()
      EndFor 
      selectLocation()
    EndSub 
    
    Sub selectLocation
      SNHP = 25 'Skeleton's HP
      
      TextWindow.WriteLine("Select an option below" + LF)
      TextWindow.WriteLine("1. Walk North")
      TextWindow.WriteLine("2. Walk East")
      TextWindow.WriteLine("3. Walk West")
      TextWindow.WriteLine("4. Walk South" + LF)
      
      loc = TextWindow.ReadNumber()
      
      If loc = 1 Then
        TextWindow.Clear()
        fight()
      elseIf loc = 2 Then
        TextWindow.Clear()
        fight()
      elseIf loc = 3 Then
        TextWindow.Clear()
        fight()
      elseIf loc = 4 Then
        TextWindow.Clear()
        fight()
      Else
        wrongOption()
        selectLocation()
      EndIf
    EndSub 
    
    Sub move
      If encounter1 = 1 Then
        TextWindow.Clear()
        TextWindow.WriteLine("You use your sword and deal " + dmg1 + " damage!")
        SNHP = SNHP - dmg1
        If (SNHP <= 0) Then
          TextWindow.Clear()
          win()
        EndIf 
        enter()
        TextWindow.PauseWithoutMessage()
        TextWindow.Clear()
        fight()
      elseIf encounter1 = 2 Then
        Program.End()
      elseIf encounter1 = 3 Then
        Program.End()
      elseIf encounter1 = 4 Then
        TextWindow.Clear()
        PLAYERHP = PLAYERHP + 10
        TextWindow.WriteLine("You gain 10 HP!")
        enter()
        TextWindow.PauseWithoutMessage()
        TextWindow.Clear()
        fight()
      Else
        wrongoption()
        fight()
      endif
    EndSub
    
    Sub fight 
      TextWindow.WriteLine("A skeleton appeared!!!" + LF)
      skeleton()
      player()
      TextWindow.WriteLine("1. Use your sword")
      TextWindow.WriteLine("2. Use a smoke bomb")
      TextWindow.WriteLine("3. Run Away")
      TextWindow.WriteLine("4. Use a HP Potion" + LF)
      encounter1 = TextWindow.ReadNumber()
      move()
    EndSub
    
    Sub player 
      dmg1 = Math.GetRandomNumber(20) + 5
      TextWindow.WriteLine("PLAYER1")
      TextWindow.WriteLine("HP: " + PLAYERHP + "/100" + LF)
    EndSub
    
    Sub skeleton 
      TextWindow.WriteLine("SKELETON")
      TextWindow.WriteLine("HP: " + SNHP + "/25"+LF)'Display Health Here
    EndSub 
    
    sub win
      TextWindow.WriteLine("You defeated a skeleton!")
      TextWindow.WriteLine("You gain 10 exp and 5 gold")
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      selectLocation()
    EndSub   
    
    Sub enter
      TextWindow.WriteLine(LF)
      TextWindow.WriteLine("PRESS ENTER")
    EndSub
    
    Sub wrongOption
      TextWindow.Clear()
      TextWindow.WriteLine("You can only select 1 2 3 or 4")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
    EndSub


    • Edited by Ezra94 Saturday, September 6, 2014 12:38 AM Reword
    Saturday, September 6, 2014 12:36 AM
  • LF = Text.GetCharacter(10)

    TextWindow.Title = "OVERWORLD SLAYER"

    PLAYERHP = 100 'Intial value of player's HP
    gold = 0
    exp = 0

    intro()

    Sub intro
      line[1] = "You are a lone slayer in the depths of Hell."
      line[2] = "You have made it your life's duty to slay all the monsters"
      line[3] = "and cleansing Hell of its evil..."
     
      For i = 1 To Array.GetItemCount(line)  
        TextWindow.Writeline(line[i])
        enter()
        TextWindow.PauseWithoutMessage()
        TextWindow.Clear()
      EndFor
      selectLocation()
    EndSub

    Sub selectLocation
      SNHP = 25 'Skeleton's HP
      TextWindow.WriteLine("Experience Points: " + exp)
      TextWindow.WriteLine("Gold: " + gold)
      TextWindow.WriteLine(" ")
      TextWindow.WriteLine("Select an option below" + LF)
      TextWindow.WriteLine("1. Walk North")
      TextWindow.WriteLine("2. Walk East")
      TextWindow.WriteLine("3. Walk West")
      TextWindow.WriteLine("4. Walk South" + LF)
     
      loc = TextWindow.ReadNumber()
     
      If loc = 1 Then
        TextWindow.Clear()
        fight()
      elseIf loc = 2 Then
        TextWindow.Clear()
        fight()
      elseIf loc = 3 Then
        TextWindow.Clear()
        fight()
      elseIf loc = 4 Then
        TextWindow.Clear()
        fight()
      Else
        wrongOption()
        selectLocation()
      EndIf
    EndSub

    Sub skeletonattack
      TextWindow.WriteLine("The Skeleton strikes and deals " + sdmg + " damge!")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      PLAYERHP = PLAYERHP - sdmg
      if (PLAYERHP <= 0) Then
          TextWindow.Clear()
          gameover()
      EndIf
      fight()
    EndSub

    Sub move
      If encounter1 = 1 Then
        TextWindow.Clear()
        TextWindow.WriteLine("You use your sword and deal " + dmg1 + " damage!")
        enter()
        TextWindow.PauseWithoutMessage()
        TextWindow.Clear()
        SNHP = SNHP - dmg1
        If (SNHP <= 0) Then
          TextWindow.Clear()
          win()
        EndIf
        skeletonattack()
      elseIf encounter1 = 2 Then
        TextWindow.Clear()
        selectLocation()
      elseIf encounter1 = 3 Then
        Program.End()
      elseIf encounter1 = 4 Then
        TextWindow.Clear()
        PLAYERHP = PLAYERHP + 10
        TextWindow.WriteLine("You gain 10 HP!")
        enter()
        TextWindow.PauseWithoutMessage()
        TextWindow.Clear()
        skeletonattack()
      elseIf encounter1 = 5 Then
        TextWindow.Clear()
        skeletonattack()
      Else
        wrongoption()
        fight()
      endif
    EndSub

    Sub fight
      TextWindow.WriteLine("A skeleton appeared!!!" + LF)
      skeleton()
      player()
      TextWindow.WriteLine("1. Use your sword")
      TextWindow.WriteLine("2. Use a smoke bomb")
      TextWindow.WriteLine("3. Run Away")
      TextWindow.WriteLine("4. Use a HP Potion" + LF)
      TextWindow.WriteLine("5. Do Nothing")
      'used for testing
      encounter1 = TextWindow.ReadNumber()
      move()
    EndSub

    Sub player
      '10 - 25 dmg
      dmg1 = Math.GetRandomNumber(20) + 5
      TextWindow.WriteLine("PLAYER1")
      TextWindow.WriteLine("HP: " + PLAYERHP + "/100" + LF)
    EndSub

    Sub skeleton
      '5- 10 dmg
      sdmg = Math.GetRandomNumber(10) + 5
      TextWindow.WriteLine("SKELETON")
      TextWindow.WriteLine("HP: " + SNHP + "/25"+LF)'Display Health Here
    EndSub

    sub win
      TextWindow.WriteLine("You defeated a skeleton!")
      TextWindow.WriteLine("You gain 10 exp and 5 gold")
      gold = gold + 5
      exp = exp + 10
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      selectLocation()
    EndSub   

    Sub enter
      TextWindow.WriteLine(LF)
      TextWindow.WriteLine("PRESS ENTER")
    EndSub

    Sub wrongOption
      TextWindow.Clear()
      TextWindow.WriteLine("You can only select 1 2 3 or 4")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
    EndSub

    Sub gameover
      TextWindow.Clear()
      TextWindow.WriteLine("You have been defeated!!!")
      enter()
      TextWindow.PauseWithoutMessage()
      Program.End()
    EndSub

    How would I remove the gap?


    btw trying to make the skeleton appear randomly

    so im going to use math.getrandomnumber(2)+8 which gives random numbers from 1 - 10 and if it lands on a 2 or 8, when i go north east west or south i encounter a skeleton

    i can't think of a way to do it

    • Edited by Dinomite07 Saturday, September 6, 2014 1:29 AM
    Saturday, September 6, 2014 1:19 AM
  • Your problem is here: 

    Sub fight 
      TextWindow.WriteLine("A skeleton appeared!!!" + LF)
      skeleton()
      player()
      TextWindow.WriteLine("1. Use your sword")
      TextWindow.WriteLine("2. Use a smoke bomb")
      TextWindow.WriteLine("3. Run Away")
      TextWindow.WriteLine("4. Use a HP Potion" + LF)
      TextWindow.WriteLine("5. Do Nothing")
      'used for testing
      encounter1 = TextWindow.ReadNumber()
      move()
    EndSub
    

    Remove the " LF " at . . 

    TextWindow.WriteLine("4. Use a HP Potion" + LF)

    and place " LF " at the end of 

      TextWindow.WriteLine("5. Do Nothing")


    Saturday, September 6, 2014 1:31 AM
  • If you are going to create an extensive text based RPG then I recommend looking at an article by Nonki Takahashi. He breaks down and explains the basic structure of a text base game.

    Here's the link to the article:

    http://blogs.msdn.com/b/smallbasic/archive/2014/07/21/small-basic-game-programming-text-adventure.aspx

    Saturday, September 6, 2014 1:38 AM
  • added this for 20% of encountering a skeleton and 80% chance of walking around

    i cant figure out what is wrong (i assume its the if statements in sub randecounter)

    Sub randencounter
         rande = Math.GetRandomNumber(2) + 8
         If rande = 1 or 3 or 4 or 5 or 6 or 7 or 9 or 10 Then 
           selectLocation()
         EndIf
         If rande = 2 Or 8 Then
           fight()
         EndIf 
    EndSub
       
    Sub selectLocation
      SNHP = 25 'Skeleton's HP
      TextWindow.WriteLine("Experience Points: " + exp)
      TextWindow.WriteLine("Gold: " + gold)
      TextWindow.WriteLine(" ")
      TextWindow.WriteLine("Coordinates: " + xxx + "," + yyy)
      TextWindow.WriteLine(" ")
      TextWindow.WriteLine("Select an option below" + LF)
      TextWindow.WriteLine("1. Walk North")
      TextWindow.WriteLine("2. Walk East")
      TextWindow.WriteLine("3. Walk West")
      TextWindow.WriteLine("4. Walk South" + LF)
      loc = TextWindow.ReadNumber()
      
      If loc = 1 Then
        TextWindow.Clear()
        yyy = yyy + 1 
        randencounter()
        elseIf loc = 2 Then
        TextWindow.Clear()
        xxx = xxx + 1
        randencounter()
       elseIf loc = 3 Then
        TextWindow.Clear()
        xxx = xxx - 1
        randencounter()
        elseIf loc = 4 Then
        TextWindow.Clear()
        yyy = yyy - 1
        randencounter()
      Else
        wrongOption()
        selectLocation()
      EndIf
    EndSub 

    full code

    LF = Text.GetCharacter(10)

    TextWindow.Title = "Overworld Slayer"

    PLAYERHP = 100 'Intial value of player's HP
    gold = 0
    exp = 0
    xxx = 0
    yyy = 0

    intro()

    Sub intro
      TextWindow.WriteLine("You are alone with an oath to slay all the monsters in the pit of Hell!!!")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      selectLocation()
    EndSub

    Sub randencounter
         rande = Math.GetRandomNumber(2) + 8
         If rande = (1 or 3 or 4 or 5 or 6 or 7 or 9 or 10) Then
           selectLocation()
         elseif rande = (2 Or 8) Then
           fight()
         EndIf
    EndSub
       
    Sub selectLocation
      SNHP = 25 'Skeleton's HP
      TextWindow.WriteLine("Experience Points: " + exp)
      TextWindow.WriteLine("Gold: " + gold)
      TextWindow.WriteLine(" ")
      TextWindow.WriteLine("Coordinates: " + xxx + "," + yyy)
      TextWindow.WriteLine(" ")
      TextWindow.WriteLine("Select an option below" + LF)
      TextWindow.WriteLine("1. Walk North")
      TextWindow.WriteLine("2. Walk East")
      TextWindow.WriteLine("3. Walk West")
      TextWindow.WriteLine("4. Walk South" + LF)
      loc = TextWindow.ReadNumber()
     
      If loc = 1 Then
        TextWindow.Clear()
        yyy = yyy + 1
        randencounter()
        elseIf loc = 2 Then
        TextWindow.Clear()
        xxx = xxx + 1
        randencounter()
       elseIf loc = 3 Then
        TextWindow.Clear()
        xxx = xxx - 1
        randencounter()
        elseIf loc = 4 Then
        TextWindow.Clear()
        yyy = yyy - 1
        randencounter()
      Else
        wrongOption()
        selectLocation()
      EndIf
    EndSub

    Sub skeletonattack
      TextWindow.WriteLine("The Skeleton strikes and deals " + sdmg + " damge!")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      PLAYERHP = PLAYERHP - sdmg
      if (PLAYERHP <= 0) Then
          TextWindow.Clear()
          gameover()
      EndIf
      fight()
    EndSub

    Sub move
      If encounter1 = 1 Then
        TextWindow.Clear()
        TextWindow.WriteLine("You use your sword and deal " + dmg1 + " damage!")
        enter()
        TextWindow.PauseWithoutMessage()
        TextWindow.Clear()
        SNHP = SNHP - dmg1
        If (SNHP <= 0) Then
          TextWindow.Clear()
          win()
        EndIf
        skeletonattack()
      elseIf encounter1 = 2 Then
        TextWindow.Clear()
        selectLocation()
      elseIf encounter1 = 3 Then
        Program.End()
      elseIf encounter1 = 4 Then
        TextWindow.Clear()
        PLAYERHP = PLAYERHP + 10
        TextWindow.WriteLine("You gain 10 HP!")
        enter()
        TextWindow.PauseWithoutMessage()
        TextWindow.Clear()
        skeletonattack()
      elseIf encounter1 = 5 Then
        TextWindow.Clear()
        skeletonattack()
      Else
        wrongoption()
        fight()
      endif
    EndSub

    Sub fight
      TextWindow.WriteLine("A skeleton appeared!!!" + LF)
      skeleton()
      player()
      TextWindow.WriteLine("1. Use your sword")
      TextWindow.WriteLine("2. Use a smoke bomb")
      TextWindow.WriteLine("3. Run Away")
      TextWindow.WriteLine("4. Use a HP Potion")
      TextWindow.WriteLine("5. Do Nothing" + LF)
      'used for testing
      encounter1 = TextWindow.ReadNumber()
      move()
    EndSub

    Sub player
      '10 - 25 dmg
      dmg1 = Math.GetRandomNumber(20) + 5
      TextWindow.WriteLine("PLAYER1")
      TextWindow.WriteLine("HP: " + PLAYERHP + "/100" + LF)
    EndSub

    Sub skeleton
      '5- 10 dmg
      sdmg = Math.GetRandomNumber(10) + 5
      TextWindow.WriteLine("SKELETON")
      TextWindow.WriteLine("HP: " + SNHP + "/25"+LF)'Display Health Here
    EndSub

    sub win
      TextWindow.WriteLine("You defeated a skeleton!")
      TextWindow.WriteLine("You gain 10 exp and 5 gold")
      gold = gold + 5
      exp = exp + 10
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      selectLocation()
    EndSub   

    Sub enter
      TextWindow.WriteLine(LF)
      TextWindow.WriteLine("PRESS ENTER")
    EndSub

    Sub wrongOption
      TextWindow.Clear()
      TextWindow.WriteLine("You can only select the options listed!")
      enter()
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
    EndSub

    Sub gameover
      TextWindow.Clear()
      TextWindow.WriteLine("You have been defeated!!!")
      enter()
      TextWindow.PauseWithoutMessage()
      Program.End()
    EndSub


    • Edited by Dinomite07 Saturday, September 6, 2014 5:21 AM
    Saturday, September 6, 2014 2:29 AM
  • The first problem I see with the randecounter subroutine is syntax:  

    If rande = 1 or 3 or 4 or 5 or 6 or 7 or 9 or 10 Then

    Instead it should be . . . . .

    If (rand = 1 Or rand = 3 Or rand = 4 ) Then . . .

    Secondly . . .

    rande = Math.GetRandomNumber(2) + 8

    The line above results in only 9 or 10. Random number would be either 1 or 2 then add 8. 

    Here is one way you could fix this . . .

    Sub randecounter 
      rande = Math.GetRandomNumber(10)
      TextWindow.WriteLine(rande) 
      If (rande = 2 Or rande = 8) Then 
        fight() 
      Else 
        selectLocation() 
      EndIf 
    EndSub 
    The wording and intent of your code remains the same for the most part. 


    • Edited by Ezra94 Saturday, September 6, 2014 5:59 AM Reword
    Saturday, September 6, 2014 5:55 AM
  • Hello Dinomite,

    Except for the "rande" error mentioned by Ezra, also the following Math.GetRandomNuber statements do not match with the comments :

    Sub player 
      '10 - 25 dmg
      dmg1 = Math.GetRandomNumber(20) + 5

    Sub skeleton
      '5- 10 dmg
      sdmg = Math.GetRandomNumber(10) + 5

    The first (dmg1) gives numbers from  6 to 25 inclusive,

    the second (sdmg) numbers from 11 to 15 inclusive.

    Maybe that is what you want, and are only the comments wrong, but you should look of this is what you want!


    Jan [ WhTurner ] The Netherlands

    Saturday, September 6, 2014 1:57 PM
    Answerer
  • so how would i make it do

    10 - 25

    and

    5 - 10

    I assume i cant add a save option (data will be still there)

    other then that i finished my game(only monster is a skeleton and no bosses or quests) :(

    i want to make it to you can save

    Sound.Play(Program.Directory + "Theme.mp3")

    i cant hear any sound

    • Edited by Dinomite07 Saturday, September 6, 2014 11:52 PM
    Saturday, September 6, 2014 8:47 PM
  • Here is one way. . .

    For dmg1 the least possible number in the parameter of Math.GetRandomNumber() is 1, which is 10, when added with 9. The greatest possible number is 16, which is 25, when added with 9. The same logic can be applied to sdmg. 

    dmg1 = Math.GetRandomNumber(16) + 9
    
    sdmg = Math.GetRandomNumber(6) + 4

    Sunday, September 7, 2014 12:29 AM
  • I'm not familiar with Program.Directory() and Sound.Play() yet. If you are new to programming then I recommend sticking to the basics if statements, variables, etc. Continue making programs and practicing. However, if you want to start experimenting with those methods here are some resources until more help comes. Maybe you could create about new post for creating files and playing audio files since this post is starting to get full. Hope this helps. 

    Program Directory for sound audios and creating files . .

    http://social.technet.microsoft.com/wiki/contents/articles/16371.small-basic-curriculum-lesson-2-4-sound-program-and-text-objects.aspx

    http://social.technet.microsoft.com/wiki/contents/articles/25576.small-basic-file.aspx

    Saving . . . .

    http://social.msdn.microsoft.com/Forums/en-US/64ad5524-fb90-4dd7-96dc-ebbd9bad37b9/how-to-create-a-saving-dirvectory?forum=smallbasic

    http://social.msdn.microsoft.com/Forums/en-US/4f131104-8a73-4eb9-9e6d-d0fe8a7b2b3c/game-saves-in-small-basic?forum=smallbasic


    • Edited by Ezra94 Sunday, September 7, 2014 12:48 AM Reword
    Sunday, September 7, 2014 12:45 AM
  • math.getrandomnumber(16) + 9

    Numbers 10 - 25 are generated

    so how does it work?


    as in how does a 16 and a 9 get numbers 10 - 24
    • Edited by Dinomite07 Sunday, September 7, 2014 1:30 AM
    Sunday, September 7, 2014 1:14 AM
  • The number in the parameter (the data in the parenthesis) is randomly selected by the computer. Using the line below as an example.

    Math.GetRandomNumber(16) + 9
    The number in the parameter is 16 so the computer will randomly select numbers from 1 to 16. In other words, 16 is the greatest possible number for the computer to select. It has sixteen numbers to choose from. It selects only one number starting from 1 2 3 4 . . . all the way to 16. No higher. After the computer selects a number (16 being the limit), it will add 9 to it. So the lowest possible outcome is 1 + 9 (sum of 10) and the highest being 16 + 9 (sum of 25). Again it could also be 2 + 9 or 3+9 or 12+9. Thus, the possible outcomes range from 10 to 25.


    • Edited by Ezra94 Sunday, September 7, 2014 3:49 AM Reword
    • Marked as answer by Dinomite07 Sunday, September 7, 2014 4:39 AM
    Sunday, September 7, 2014 3:47 AM