How can I add RPG combat to my game?
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: 38
- Joined: Sat Apr 21, 2018 3:46 am
- Contact:
How can I add RPG combat to my game?
My game is designed to be a standard VN in terms of gameplay but I would there to be a quick turn based RPG battle as part of an joke scene. I heard that Ren'py can make turn based RPG combat so I'm wondering what to do.
Last edited by NadOtavlas on Tue Sep 08, 2020 12:33 am, edited 1 time in total.
-
- Newbie
- Posts: 3
- Joined: Mon Sep 07, 2020 3:03 pm
- Contact:
Re: How can I add RPG combat to my game?
I made a simple test to see how it work work. This is what I wrote in the script:
And this is what I had for the screen:
This put the player's health bar on the top left and the opponent's health bar on the top right. You can obviously change the numbers to whatever you want, but that's what I did.
Code: Select all
label start:
$currenthp = 50
$maxhp = 50
$currenthpe = 50
$maxhpe = 50
show screen battle
label battle:
menu:
"Attack":
jump attack
"Defend":
jump defend
label attack:
"You attack!"
"You deal 10 damage!"
$currenthpe -= 10
if currenthpe <= 0:
"You win!"
jump end
"Enemy attacks!"
"You take 5 damage!"
$currenthp -= 5
if currenthp <= 0:
"You lose!"
jump end
jump battle
label defend:
"You defend!"
"Enemy attacks!"
"You take 3 damage!"
$currenthp -= 3
if currenthp <= 0:
"You lose!"
jump end
jump battle
label end:
And this is what I had for the screen:
Code: Select all
screen battle:
text "Player" xalign 0.0 yalign 0.0
text "HP: [currenthp]/[maxhp]" xalign 0.0 yalign 0.05
bar value currenthp range maxhp xalign 0.0 yalign 0.1 xmaximum 200
text "Enemy" xalign 1.0 yalign 0.0
text "HP: [currenthpe]/[maxhpe]" xalign 1.0 yalign 0.05
bar value currenthpe range maxhpe xalign 1.0 yalign 0.1 xmaximum 200
This put the player's health bar on the top left and the opponent's health bar on the top right. You can obviously change the numbers to whatever you want, but that's what I did.
-
- Regular
- Posts: 38
- Joined: Sat Apr 21, 2018 3:46 am
- Contact:
Re: How can I add RPG combat to my game?
Ok so some errors have been happening. The engine is telling me that the enemyhp value is not define when I try to attack. This is the code:StarWarriorSora wrote: ↑Mon Sep 07, 2020 3:09 pm I made a simple test to see how it work work. This is what I wrote in the script:
Code: Select all
label start: $currenthp = 50 $maxhp = 50 $currenthpe = 50 $maxhpe = 50 show screen battle label battle: menu: "Attack": jump attack "Defend": jump defend label attack: "You attack!" "You deal 10 damage!" $currenthpe -= 10 if currenthpe <= 0: "You win!" jump end "Enemy attacks!" "You take 5 damage!" $currenthp -= 5 if currenthp <= 0: "You lose!" jump end jump battle label defend: "You defend!" "Enemy attacks!" "You take 3 damage!" $currenthp -= 3 if currenthp <= 0: "You lose!" jump end jump battle label end:
And this is what I had for the screen:
Code: Select all
screen battle: text "Player" xalign 0.0 yalign 0.0 text "HP: [currenthp]/[maxhp]" xalign 0.0 yalign 0.05 bar value currenthp range maxhp xalign 0.0 yalign 0.1 xmaximum 200 text "Enemy" xalign 1.0 yalign 0.0 text "HP: [currenthpe]/[maxhpe]" xalign 1.0 yalign 0.05 bar value currenthpe range maxhpe xalign 1.0 yalign 0.1 xmaximum 200
This put the player's health bar on the top left and the opponent's health bar on the top right. You can obviously change the numbers to whatever you want, but that's what I did.
label rpgbattle1:
play music "track16.mp3"
with fade
"A Dragonlord draws near! Command?"
menu:
"Attack":
$currenthpe -= 35
jump attack
"Spell":
jump spelllist
"Run":
jump run
"Item":
jump item
label attack:
"[povname] attacks!"
"The Dragonlord's Hit Points have been reduced by 35."
jump enemy1turn
-
- Miko-Class Veteran
- Posts: 793
- Joined: Fri Feb 09, 2018 12:05 am
- Location: Canada
- Contact:
Re: How can I add RPG combat to my game?
this might help you out more
viewtopic.php?f=51&t=37710#p408490
the reason why you getting errors is because you didn't defined the variables
default enemyhp = 50
default currenthp = 50
default maxhp = 50
default maxhpe = 50
viewtopic.php?f=51&t=37710#p408490
the reason why you getting errors is because you didn't defined the variables
default enemyhp = 50
default currenthp = 50
default maxhp = 50
default maxhpe = 50
-
- Regular
- Posts: 38
- Joined: Sat Apr 21, 2018 3:46 am
- Contact:
Re: How can I add RPG combat to my game?
So I'm trying to have a magic system but magic can't seem to kill the enemy. Here's my code:
label hurt:
if maxmp <= 1:
"Thy MP is too low."
jump spelllist
else:
"[povname] chanted the spell of HURT."
"The Dragonlord's Hit Points have been reduced by 40."
if enemyhp1 <= 0:
jump boss1defeat
else:
jump enemy1turn
label hurt:
if maxmp <= 1:
"Thy MP is too low."
jump spelllist
else:
"[povname] chanted the spell of HURT."
"The Dragonlord's Hit Points have been reduced by 40."
if enemyhp1 <= 0:
jump boss1defeat
else:
jump enemy1turn
Who is online
Users browsing this forum: No registered users