Looping battle system...*Bug
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
-
- Regular
- Posts: 60
- Joined: Tue Mar 21, 2017 11:10 pm
- Contact:
Looping battle system...*Bug
how can i fix the bug where after you finish one round of battle and you continue on the story but when you press Back button it returns to the battle scene it's been looping and looping returning to the battle scene, and even when you save to a certain point and load it it returns to the battle scene too even when your adding some things to the script after it reloads it returns to the battle scene... i wonder what the problem is.?
- SuperbowserX
- Veteran
- Posts: 270
- Joined: Sat Jan 07, 2017 3:09 pm
- Contact:
Re: Looping battle system...*Bug
After the battle, run this line of code. It will prevent Ren'py from rolling back to before this line of code is used.
Code: Select all
$ renpy.block_rollback()
-
- Regular
- Posts: 60
- Joined: Tue Mar 21, 2017 11:10 pm
- Contact:
Re: Looping battle system...*Bug
this is generally the battle system with a few changes 1st part placed on the upper part before label start:SuperbowserX wrote:After the battle, run this line of code. It will prevent Ren'py from rolling back to before this line of code is used.
Code: Select all
$ renpy.block_rollback()
this is where the characters are made thingy.
Code: Select all
# battle framework
init 1 python:
from random import randint
chance = 0
def rand_enemy(chance):
chance = randint(1,3)
return chance
#use calculator and divide left to right
def rand_gen1(chance):
chance = randint(1,4)
return chance
def rand_gen2(chance):
chance = randint(1,2)
return chance
def rand_gen3(chance):
chance = randint(1,100)
image enemy_Sylvie1:
xalign .98
yalign .02
"images/char/katipunero.png"
image enemy_Sylvie2:
xalign .98
yalign .02
"images/enam/spaniards1.png"
image enemy_logo:
xalign .98
yalign .02
"images/enam/loko.png"
image player_Daario:
xalign .02
yalign .02
"images/daario/daario.png"
#Declare characters used by this game.
define e = Character('Enemy', color="#ff0000")
define p_name = Character('Player', color="#c8ffc8")
label fight():
# player/fighter image
if char==0:
show player_Daario
if turn_count == 4:
$turn_count = 0
# player stat's frame @ line 28
$ stats_frame(pname, php, pmaxhp, xalign=0.2, yalign=.7)
#list of available enemies
if which_enemy == 1: # enemies
$ename = "Katipunero"
$emaxhp = 100
if combat_turn == 0:
$ehp=emaxhp
show enemy_Sylvie1
if turn_count ==3:
$e_dam = 30
else:
$e_dam = 15
elif which_enemy == 2:
$ename = "Spaniards 1"
$emaxhp = 100
if combat_turn == 0:
$ehp=emaxhp
show enemy_Sylvie2
if turn_count ==3:
$e_dam = 30
else:
$e_dam = 15
else:
$ename = "Spaniards 2"
$emaxhp = 100
if combat_turn == 0:
$ehp=emaxhp
show enemy_logo
if turn_count == 3:
$e_dam = 30
else:
$e_dam = 15
#Enemy stat's Frame
$ stats_frame(ename, ehp, emaxhp, xalign = .98, yalign = .7)
return
for the 1st battle scene be he would need to accumulate wrong answers for example 3 mistake the battle scene would be trigger as for the points.
$ strike +=1
now if the strike points reached 3
i used (if statements)
if strike ==3:
it would jump to label failed:
Code: Select all
$which_enemy = 1
jump action_a
if action_a == e_defeat:
jump win
else:
jump Giveup
and now for the battle system it would look like this
Code: Select all
label post_battle:
while not click_link:
"Choose your action \n
{a=action_a}Fight!{/a} \n
{a=action_b}Hide.{/a}"
label action_a:
$ click_link = True
jump attack
label action_b:
$ exit_battle_chance = rand_gen2(chance)
if exit_battle_chance==1:
scene black with dissolve
centered "You have successfully escaped!"
if flag == 1:
ab "..."
jump battle3
if flag == 2:
ab "Stop hiding you coward!"
jump chapter3
else:
"You failed to hide and you where foundout, you where forced to battle.."
jump attack
return
label attack:
$ click_link = False
$attack_s=0
jump combat_setup
#---------------------------------------- End of attack type area ----------------------------
#---------------------------------------- Combat Setup Area ------------------------------------------
label combat_setup:
$ combat_turn = 0
$ emaxhp = 100
$ ename = "None"
#$ which_enemy = rand_enemy(chance)
$ php=pmaxhp
$ ehp=emaxhp
$ turn_count = 0
jump combat
return
label combat:
while not click_link:
call fight() from _call_fight
$ combat_turn=1
"[pname]'s options:\n
{a=battle_a}Slash{/a}\n
{a=battle_b}Shoot{/a}\n
{a=battle_c}Defend{/a}\n
{a=battle_d}Run Away{/a}\n"
label battle_c: ###### Defend ###########
$ turn_count +=1
$ def_points = (e_dam/2)
call fight() from _call_fight_1
"[pname] defends.."
hide fight()
call fight() from _call_fight_2
"[ename] attacks."
hide fight ()
$ php -= def_points
if php <= 0:
call fight () from _call_fight_3
extend " [pname] suffers [def_points] damage. \n [pname] HAS BEEN DEFEATED."
jump p_defeat
else:
call fight () from _call_fight_4
extend "[pname] suffers [def_points] damge."
jump combat
return
label battle_d: ########### Hide########
$ turn_count +=1
$ exit_battle_chance = rand_gen1(chance)
if exit_battle_chance==1:
scene black with dissolve
centered "You have successfully escaped!"
if flag ==0:
jump Giveup
if flag == 1:
ab "..."
jump battle3
if flag == 2:
ab "Stop running you coward!"
jump chapter2conc
else:
$ def_points = (e_dam)
return
call fight() from _call_fight_5
"[pname] tried to run away but failed"
hide fight()
call fight() from _call_fight_6
"[ename] attacks."
hide fight()
$ php -= def_points
if php <= 0:
call fight () from _call_fight_7
extend " [pname] suffers [def_points] damage. \n [pname] HAS BEEN DEFEATED."
jump p_defeat
else:
call fight () from _call_fight_8
extend "[pname] suffers [def_points] damge."
jump combat
return
label battle_a: ################ Slash #################
$ turn_count +=1
#randomizes damage
#if hit_chance is equal to 4, player damage becomes 25
#if hit_chance is any number other than 4, player damage becomes 15
$hit_chance = rand_gen1(chance)
if hit_chance == 4:
$p_dam_s = 25
with slashflash
play sound "slashstab.mp3"
else:
$p_dam_s = 15
with flashbulb
play sound "slash.mp3"
call fight () from _call_fight_9
"[pname] attacks."
hide fight ()
$ ehp -= p_dam_s
if ehp <= 0:
$ehp = 0
call fight() from _call_fight_10
extend "[ename] suffers [p_dam_s] damage. \n [ename] Has been Defeated."
hide fight ()
jump e_defeat
else :
call fight() from _call_fight_11
extend " [ename] suffers [p_dam_s] damage."
hide fight()
call fight() from _call_fight_12
"[ename] attacks"
hide fight()
$ php -= e_dam
if e_dam == 15:
with flashbulb
play sound "slash.mp3"
else:
with slashflash
play sound "slashstab.mp3"
if php <=0:
$php = 0
call fight () from _call_fight_13
extend "[pname] suffers [e_dam] damage \n [pname] Has been Defeated. "
jump p_defeat
else:
call fight () from _call_fight_14
extend " [pname] suffers [e_dam] damage."
stop sound
jump combat
return
label battle_b: ############# Shoot #############
$ turn_count +=1
#randomizes damage
#if hit_chance is equal to 4, player damage becomes 20
#if hit_chance is any number other than 4, player damage becomes 40
$hit_chance = rand_gen1(chance)
if hit_chance == 4:
$p_dam_s = 20
with flashbulb
play sound "gunshot.mp3"
else:
$p_dam_s = 40
with slashflash
play sound "gunshot.mp3"
call fight () from _call_fight_15
"[pname] attacks."
hide fight ()
$ ehp -= p_dam_s
if ehp <= 0:
$ehp = 0
call fight() from _call_fight_16
extend "[ename] suffers [p_dam_s] damage. \n [ename] Has been Defeated."
hide fight ()
jump e_defeat
else :
call fight() from _call_fight_17
extend " [ename] suffers [p_dam_s] damage."
hide fight()
call fight() from _call_fight_18
"[ename] attacks"
play sound "slash.mp3"
hide fight()
$ php -= e_dam
if php <=0:
$php = 0
call fight () from _call_fight_19
extend "[pname] suffers [e_dam] damage \n [pname] Has been Defeated. "
jump p_defeat
else:
call fight () from _call_fight_20
extend " [pname] suffers [e_dam] damage."
stop sound
jump combat
return turn_count
label p_defeat:
scene black with dissolve
centered "GAME OVER"
if flag == 0:
return Enter
elif flag ==1:
menu:
"Return to previous check point?"
"Yes":
$flag -=1
return delmonte
"No":
#$Rnpy.full_restart()
return
else:
menu:
"Return to previous check point?]"
"Yes":
$flag -=1
return delmonte
"No":
#$Renpy.full_restart()
return
return
label e_defeat:
scene black with dissolve
centered "YOU WIN"
if flag ==0:
jump win
elif flag ==1:
"After the battle we have succesfully captured the town's gunpowder supply, but Spanish reinforcements quickly came and they where forced to battle again."
jump battle3
else:
jump chapter2conc
sorry for the vague information i dont know to to explain it to you guys so i had a hard time thinking of words to explain and even posting multiple treads with the same problem i dont know if its the rollback and but i think its not and i guessing its how i call the battle system? cause everytime i passed the battle scene an continue on the story the bug occures when you press back when you for exmple missed a sentence and decided to re read it that *back feature and returns you to the 1st or last battle scene that you have already passed.
*Edited
Last edited by mahyuringon on Fri Apr 21, 2017 9:08 pm, edited 1 time in total.
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Looping battle system...*Bug
You should place code inside [ code][ /code] rather than quote tags in order to preserve tabs.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
-
- Regular
- Posts: 60
- Joined: Tue Mar 21, 2017 11:10 pm
- Contact:
Re: Looping battle system...*Bug
didnt know that...trooper6 wrote:You should place code inside [ code][ /code] rather than quote tags in order to preserve tabs.
-
- Regular
- Posts: 60
- Joined: Tue Mar 21, 2017 11:10 pm
- Contact:
Re: Looping battle system...*Bug
Hmm, next time, it would be nice to provide a working demo, so people don't have to waste time setting one up. It's much harder for us to deal with missing screens, methods, variables, images or sound effects.
In any case there's one thing I've derived from your combat system. You use the text hyperlink tag. The problem is that doesn't work like a jump call, it expects to return, and you never actually return. For me this breaks the rollback feature, as soon as I click one of the options I lose the ability to rollback, even though there's nothing in the code suggesting that I shouldn't be able to rollback. I'm willing to wager your problem is related to not returning from the hyperlink properly.
I also have a makeshift combat system. Feel free to check out my project and dig around the code for some ideas.
In any case there's one thing I've derived from your combat system. You use the text hyperlink tag. The problem is that doesn't work like a jump call, it expects to return, and you never actually return. For me this breaks the rollback feature, as soon as I click one of the options I lose the ability to rollback, even though there's nothing in the code suggesting that I shouldn't be able to rollback. I'm willing to wager your problem is related to not returning from the hyperlink properly.
I also have a makeshift combat system. Feel free to check out my project and dig around the code for some ideas.
Phoenix Star - Persistence, perseverance, ambition.
...
Lost Legends
[VN][Fantasy][Open World] Lost Legends
(Bug Thread) Lost Legends
(Direct Download)
Deviant Art: ...
Lost Legends
[VN][Fantasy][Open World] Lost Legends
(Bug Thread) Lost Legends
(Direct Download)
Discord: saltome
Itch: Phoenix Start
Who is online
Users browsing this forum: bonnie_641, Google [Bot]