RPG Game Help
Author |
Message |
Planet_Fall

|
Posted: Wed Dec 25, 2013 3:20 pm Post subject: RPG Game Help |
|
|
What is it you are trying to achieve?
To get back to the dungeon menu after the fight with the Thief.
What is the problem you are having?
After you win the battle with the thief, it clears the screen and shows the EXP and GOLD you earned and just freezes there.
Describe what you have tried to solve this problem
I tried making an exit and made the battle a procedure, but after the battle it just won't jump back.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
RPG Test
% Variables
var HP_P, ATK_P, DEF_P, SPD_P, EXP_P, LV, place, GOLD : int := 0
var HP_E, ATK_E, DEF_E, SPD_E, HP_C, HP_D, DAMAGE_E : int := 0
var name, class_P, choice, name_E : string
var Mission_Accepted_Den, Mission_Accepted_Den_Completed : boolean := false
% Procedures
procedure player_stats
HP_P := Rand.Int (50, 100)
ATK_P := Rand.Int (10, 50)
DEF_P := Rand.Int (10, 50)
SPD_P := Rand.Int (10, 50)
%Max is 250
end player_stats
procedure enemy_stats
HP_E := Rand.Int (50, 100)
ATK_E := Rand.Int (10, 50)
DEF_E := Rand.Int (10, 50)
SPD_E := Rand.Int (10, 50)
%Max is 250
end enemy_stats
procedure show_stats
put "Name: ", name : 7
put "Class: Lv.", LV, " ", class_P : 7
put "ATK: ", ATK_P, " ", "DEF: ", DEF_P, " ", "SPD: ", SPD_P
put "EXP : ", EXP_P
end show_stats
procedure show_stats_Battle
put "Name: ", name : 7
put "Class: Lv.", LV, " ", class_P : 7
put "HP: ", HP_C, "/", HP_P
put "ATK: ", ATK_P, " ", "DEF: ", DEF_P, " ", "SPD: ", SPD_P
put "EXP : ", EXP_P
end show_stats_Battle
procedure show_stats_E
put "Name: ", name_E : 7
put "HP: ", HP_E
put "ATK: ", ATK_E, " ", "DEF: ", DEF_E, " ", "SPD: ", SPD_E
end show_stats_E
procedure INN
put "You decide that a quick rest would do wonders, so you " ..
put "enter the nearby INN."
put " Your current HP is ", HP_C, "/", HP_P
put "Do you wish to rest here? (y/n): " ..
loop
get choice
if choice = "y" then
if HP_C = HP_P then
put "You don't need to rest."
delay (1000)
exit
elsif HP_C not= HP_P then
put "You have ", GOLD, " GOLD"
if GOLD >= 5 then
put "Do you wish to recover you HP? (It'll cost you 5 GOLD) (y/n): " ..
loop
get choice
if choice = "y" then
GOLD - = 5
HP_D := 0
put "You rested up a bit."
exit
elsif choice = "n" then
exit
else
put "Please enter a valid entry."
end if
end loop
end if
exit
end if
elsif choice = "n" then
exit
end if
end loop
end INN
procedure battle_normal
%Battle
enemy_stats
loop
cls
HP_C := HP_P - HP_D
show_stats_Battle
put ""
show_stats_E
put ""
put ""
loop
put "What will you do? (ATTACK/DEFEND/RUN): " ..
get choice
if choice = "ATTACK" then
DAMAGE_E := (ATK_P * 10) div 8
HP_E - = DAMAGE_E
HP_D := (ATK_E * 10) div 8
exit
end if
end loop
if HP_E <= 0 then
cls
put "YOU HAVE WON THE FIGHT!"
delay (500)
var gold_earned : int := Rand.Int (10, 50)
GOLD + = gold_earned
put "YOU HAVE EARNED ", gold_earned, " GOLD"
delay (500)
var exp_earned : int := Rand.Int (50, 150)
put "YOU HAVE EARNED ", exp_earned, " EXP"
EXP_P + = exp_earned
delay (1000)
exit
end if
end loop
end battle_normal
% Part One ~Intro~
put "You walk into the guild and walk up to the nearest bartender. \"Hello\" you say to the man. He looks over at you and nods. You feel out of place here but you know that " ..
put "this is a nessasary place to be if you want to be stronger. \"I would like to sign up as a adventurer.\" You tell the bartender, he put's a peice of paper in front of " ..
put "you, \" Fill this out... oh and make sure you spell it EXACTLY like it says. \" he then grumbes somthing."
put ""
put "You read the peice of paper."
put ""
% Name Entry
put "What is your name? (First Name ONLY): " ..
get name
player_stats
% Class Entry
put ""
put "What Class are you? (FIGHTER or DEFENDER): " ..
loop
get class_P
if class_P = "FIGHTER" then
ATK_P + = 1
if ATK_P >= 50 then
ATK_P := 50
end if
exit
elsif class_P = "DEFENDER" then
DEF_P + = 1
if DEF_P >= 50 then
DEF_P := 50
end if
exit
else
put "Please enter a valid entry."
end if
end loop
LV + = 1
cls
% Part Two ~Den of Theives~
loop
cls
HP_C := HP_P - HP_D
show_stats
put "Where do you want to go? (Enter Number): "
put ""
put "1. ADVENTURERS GUILD "
put "2. INN "
if Mission_Accepted_Den = true and Mission_Accepted_Den_Completed = false then
put "3. DEN OF THEIVES"
end if
loop
get place
if place = 1 then
cls
% DEN OF THEIVES MISSION
put "You go into the ADVENTURERS GUILD to see if you could find a easy job to start with."
put "After much thought you think that the DEN OF THEIVES is your best bet."
put "Do you accept the mission? (y/n): " ..
loop
get choice
if choice = "y" then
Mission_Accepted_Den := true
exit
elsif choice = "n" then
exit
else
put "Please enter a vaild entry."
end if
end loop
% END OF DEN OF THEIVES
exit
elsif place = 2 then
cls
INN
exit
elsif place = 3 and Mission_Accepted_Den = true and Mission_Accepted_Den_Completed = false then
var FLOOR1, FLOOR2, FLOOR3 : boolean := false
loop
cls
put "You enter the DEN OF THEIVES and look around aimlessly, the den is held in a mystical space."
put ""
put "Where do you go? (Enter Number): "
put "1. First Floor"
if FLOOR2 = true then
put "2. Secound Floor"
elsif FLOOR3 = true then
put "3. Boss Floor"
end if
get place
if place = 1 then
put "You go up to the first floor."
delay (500)
put " You encounter a THIEF!"
name_E := "THIEF"
battle_normal
exit
elsif place = 2 and FLOOR2 = true then
elsif place = 3 and FLOOR3 = true then
else
put "Please enter a vaild entry."
end if
exit
end loop
end if
end loop
end loop
|
Please specify what version of Turing you are using
Turing 4.1.1 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Raknarg

|
Posted: Wed Dec 25, 2013 5:01 pm Post subject: RE:RPG Game Help |
|
|
Just figured out what happens.
It goes through and exits the fight sequence. it puts the YOU WON stuff, then it jumps to line 171, where you choose to go to an inn, adventurers guild or the theifves' den. However, because of how it is written, it doesn't show that part again. Try it. Once you get to the part where it freezes, press 1. |
|
|
|
|
 |
evildaddy911
|
Posted: Wed Dec 25, 2013 8:19 pm Post subject: RE:RPG Game Help |
|
|
if something like this is happening, try using the trace execution tool. go into preferences\editor window and check the "show debugger menu" box. hit ok, click the debugger dropdown menu at the top and "show debugger controls" check trace execution, shrink the window so you can see the whole run window and then try running the program
That should help show whats going wrong, and from there, you should easily be able to fix it (all you have to do is add one small command) |
|
|
|
|
 |
evildaddy911
|
Posted: Wed Dec 25, 2013 8:21 pm Post subject: RE:RPG Game Help |
|
|
if something like this is happening, try using the trace execution tool. go into preferences\editor window and check the "show debugger menu" box. hit ok, click the debugger dropdown menu at the top and "show debugger controls" check trace execution, shrink the window so you can see the whole run window and then try running the program
That should help show whats going wrong, and from there, you should easily be able to fix it (all you have to do is add one small command) |
|
|
|
|
 |
Raknarg

|
Posted: Wed Dec 25, 2013 9:43 pm Post subject: RE:RPG Game Help |
|
|
That is true.
Did you try following your code to see what it does? |
|
|
|
|
 |
Planet_Fall

|
Posted: Wed Dec 25, 2013 10:44 pm Post subject: Re: RPG Game Help |
|
|
Thanks! I tried following my code to see what was happening and I figured out what the problem was.
loop
get place
if place = 1 then
cls
% DEN OF THEIVES MISSION
put "You go into the ADVENTURERS GUILD to see if you could find a easy job to start with."
put "After much thought you think that the DEN OF THEIVES is your best bet."
put "Do you accept the mission? (y/n): " ..
loop
get choice
if choice = "y" then
Mission_Accepted_Den := true
exit
elsif choice = "n" then
exit
else
put "Please enter a vaild entry."
end if
end loop
% END OF DEN OF THEIVES
exit
elsif place = 2 then
cls
INN
exit
elsif place = 3 and Mission_Accepted_Den = true and Mission_Accepted_Den_Completed = false then
var FLOOR1, FLOOR2, FLOOR3 : boolean := false
loop
cls
put "You enter the DEN OF THEIVES and look around aimlessly, the den is held in a mystical space."
put ""
put "Where do you go? (Enter Number): "
put "1. First Floor"
if FLOOR2 = true then
put "2. Secound Floor"
elsif FLOOR3 = true then
put "3. Boss Floor"
end if
get place
if place = 1 then
put "You go up to the first floor."
delay (500)
put " You encounter a THIEF!"
name_E := "THIEF"
battle_normal
exit
elsif place = 2 and FLOOR2 = true then
elsif place = 3 and FLOOR3 = true then
else
put "Please enter a vaild entry."
end if
exit
end loop
end if
exit <---- It was this line right here
end loop
end loop
It turns out I forgot a 'exit' command so when the battle ended it couldn't loop back to the start. |
|
|
|
|
 |
Raknarg

|
Posted: Wed Dec 25, 2013 10:53 pm Post subject: RE:RPG Game Help |
|
|
Good work. |
|
|
|
|
 |
|
|