Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
-
Nero
- Veteran
- Posts: 242
- Joined: Tue Aug 09, 2016 2:59 pm
-
Contact:
#1
Post
by Nero » Wed Oct 26, 2016 9:33 pm
Hey there mighty programmers!
I need help on how to add critical/miss chance on my attacks in battle loop engine. I haven't found any topic that could help me so I decided to make one.
For example I have random value damage skill with 100% hit chance. Now how do I add to my code lets say 20% miss and critical chance every time I use this skill?
Here are defined values of character and skill:
Code: Select all
$ party_list =[{"name":"Angel",
"max_hp":10000,
"current_hp":10000,
"min_missile_damage":25,
"max_missile_damage":50,
"imga2":"angel_picture", "def_imga2":"defeated_angel",
"laser_gun_max_damage":100,
"laser_gun_min_damage":80,
"id":str(renpy.random.randint(0,1000)*renpy.random.randint(0,1000))}]
Here is the skill that "Angel" character is using:
Code: Select all
menu:
"MISSILE LAUNCHER" if angel_missile_ammo >= 1:
$ angel_missile_ammo -= 1
$ player_damage = renpy.random.randint( current_player["min_missile_damage"], current_player["max_missile_damage"] )
$ enemies_list[res]["current_hp"] -= player_damage
"Firing the missile! {i}(Enemy took damage of - [player_damage]HP){/i}"
$ renpy.block_rollback()
Last edited by
Nero on Thu Oct 27, 2016 7:14 am, edited 1 time in total.
-
csky
- Regular
- Posts: 93
- Joined: Sun Sep 14, 2014 3:46 pm
- Completed: Perceptions of the Dead, Embers of Magic
- Projects: Various Commissioned Artwork
-
Contact:
#2
Post
by csky » Wed Oct 26, 2016 11:18 pm
This might work....? I'm not sure... give it a test.
You will need to add in the line for however much critical damage a crit does.
Code: Select all
menu:
"MISSILE LAUNCHER" if angel_missile_ammo >= 1:
$ angel_missile_ammo -= 1
$ player_damage = renpy.random.randint( current_player["min_missile_damage"], current_player["max_missile_damage"] )
$ enemies_list[res]["current_hp"] -= player_damage
$ hitchance = renpy.random.randint(0, 100)
if hitchance < 20:
"Firing the missile! The missile missed! {i}(Enemy took 0 damage){/i}"
elif hitchance > 79:
#$ code for the missile taking critical damage from enemy
"Firing the missile! The missile made a critical hit...etc"
else:
$ enemies_list[res]["current_hp"] -= player_damage
"Firing the missile! {i}(Enemy took damage of - [player_damage]HP){/i}"
$ renpy.block_rollback()
-
Nero
- Veteran
- Posts: 242
- Joined: Tue Aug 09, 2016 2:59 pm
-
Contact:
#3
Post
by Nero » Thu Oct 27, 2016 6:42 am
Yeah that's perfect thanks a lot!
Users browsing this forum: Google [Bot], mold.FF