I am making a battle system and am trying to figure out how to make enable the player character and the enemy to be able to defend from the upcoming attack so here is what i need to figure out:
1. How to subtract the defence value from the attack value.
2. How to make the defence "Stay" up until the defending characters next move.
Here is the code:
Thank you for your help.
Defending in my battle system...
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.
-
- Newbie
- Posts: 11
- Joined: Mon May 31, 2021 12:09 pm
- Contact:
Re: Defending in my battle system...
You can make a variable to store enemy's defense.frytkosz-555 wrote: ↑Sun Jun 13, 2021 8:22 am ...1. How to subtract the defence value from the attack value.
2. How to make the defence "Stay" up until the defending characters next move. ...
Try
Code: Select all
default enemy_defense = 0
label battle:
while (enemy_hp >0) and (hero_hp > 0):
menu:
"Attack":
$ dmg = renpy.random.randint(2.5)
$ enemy_hp -= max(0, dmg - enemy_defense)
# if enemy_defense is greater than hero's dmg
# then enemy_hp will be reduced by 0
# (make the same for all attacks)
$ enemy_defense = 0 # defense is working for 1 move only
if enemy_hp > 0:
$ randaction = renpy.random.choice(["attack", "defend"]):
if randaction == "defend":
$ enemy_defense = 4
-
- Newbie
- Posts: 11
- Joined: Mon May 31, 2021 12:09 pm
- Contact:
Re: Defending in my battle system...
So I implemented some of the stuff from the post above, now the enemy can defend themselves but when the value of defence exceeds the value of the MC's attack then the enemy heals themselves by the value of the difference betweent he two and I don't want them to do that, how can I fix that?
Re: Defending in my battle system...
Code: Select all
$ enemy_hp -= max(0, dmg - enemy_defense)
-
- Newbie
- Posts: 11
- Joined: Mon May 31, 2021 12:09 pm
- Contact:
Re: Defending in my battle system...
Thanks Alex I applied that and now it works perfectly.
Who is online
Users browsing this forum: Ocelot