mirror of https://github.com/bgiraudr/Adoranda.git
Add self buff with move
This commit is contained in:
parent
df3e9ab714
commit
a875d3d359
|
@ -48,6 +48,7 @@ set(SOURCES
|
|||
|
||||
set(ASSETS_cg
|
||||
assets-cg/tileset.png
|
||||
assets-cg/categories.png
|
||||
assets-cg/dialogue.png
|
||||
assets-cg/capacite.png
|
||||
assets-cg/battle_ui.png
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name":"Charge",
|
||||
"id":2,
|
||||
"categorie":"PHYSICAL",
|
||||
"pp":25,
|
||||
"atk":15,
|
||||
"precision":100
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name":"Cheat",
|
||||
"id":3,
|
||||
"categorie":"PHYSICAL",
|
||||
"pp":25,
|
||||
"atk":45,
|
||||
"precision":100
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"name":"Deuxième",
|
||||
"id":1,
|
||||
"pp":100,
|
||||
"atk":11,
|
||||
"precision":50
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name":"Soin",
|
||||
"id":1,
|
||||
"categorie":"STATUT",
|
||||
"pp":100,
|
||||
"boost_atk":15,
|
||||
"boost_hp":15,
|
||||
"boost_def":15
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"name":"Test capacité",
|
||||
"id":0,
|
||||
"categorie":"PHYSICAL",
|
||||
"pp":5,
|
||||
"atk":20,
|
||||
"precision":50
|
||||
"precision":80
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 267 B |
|
@ -207,10 +207,20 @@ def convert_capa(input, output, params, target):
|
|||
try:
|
||||
move += fxconv.string(data["name"])
|
||||
move += fxconv.u32(data["id"])
|
||||
move += fxconv.u32(1 if data["categorie"]=="PHYSICAL" else 0)
|
||||
move += fxconv.u32(data["pp"])
|
||||
move += fxconv.u32(data["pp"])
|
||||
move += fxconv.u32(data["atk"])
|
||||
move += fxconv.u32(data["precision"])
|
||||
|
||||
categorie = data["categorie"]
|
||||
if categorie=="PHYSICAL":
|
||||
move += fxconv.u32(data["atk"])
|
||||
move += fxconv.u32(data["precision"])
|
||||
move += fxconv.u32(0) + fxconv.u32(0) + fxconv.u32(0)
|
||||
elif categorie=="STATUT":
|
||||
move += fxconv.u32(0) + fxconv.u32(100)
|
||||
move += fxconv.u32(data["boost_atk"])
|
||||
move += fxconv.u32(data["boost_def"])
|
||||
move += fxconv.u32(data["boost_hp"])
|
||||
except KeyError:
|
||||
raise Exception(f"convert_capa() : La capacité {data['name']} est mal configurée")
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@ capacite.png:
|
|||
name: img_capacite
|
||||
profile: p4
|
||||
|
||||
categories.png:
|
||||
type: bopti-image
|
||||
name: img_categories
|
||||
profile: p4
|
||||
|
||||
battle_ui.png:
|
||||
type: bopti-image
|
||||
name: img_battle
|
||||
|
|
|
@ -13,6 +13,6 @@ int battle(struct Player *player, struct Monster *monster);
|
|||
int select_move(struct Player *player, struct Monster *monster, int prec_selected);
|
||||
void draw_battle(struct Player *player, struct Monster *monster);
|
||||
void draw_executed_move(struct Move *move, struct Monster *monster, int is_monster);
|
||||
void draw_status(char *message);
|
||||
void draw_status(char *name, char *message);
|
||||
void finish_battle(int status, struct Game *game, struct Monster *monster);
|
||||
void check_move_status(int status, struct Player *player, struct Monster *monster);
|
||||
void check_move_status(int status, struct Player *player, struct Monster *monster, int is_monster);
|
|
@ -4,10 +4,16 @@
|
|||
struct Move {
|
||||
char *name;
|
||||
int id;
|
||||
int categorie;
|
||||
int init_pp;
|
||||
int pp;
|
||||
int atk;
|
||||
int precision;
|
||||
|
||||
//self effect (%)
|
||||
int boost_atk;
|
||||
int boost_def;
|
||||
int boost_hp;
|
||||
};
|
||||
|
||||
struct Capacities {
|
||||
|
@ -19,6 +25,15 @@ enum status {
|
|||
MISS,
|
||||
SUCCESS,
|
||||
CRIT,
|
||||
HEAL,
|
||||
ATK,
|
||||
DEF,
|
||||
MULTIPLE
|
||||
};
|
||||
|
||||
enum categorie {
|
||||
STATUT,
|
||||
PHYSICAL,
|
||||
};
|
||||
|
||||
struct Move default_move();
|
||||
|
@ -28,9 +43,8 @@ void draw_classic_move(int x, int y, struct Move *move);
|
|||
int execute_move(struct Stats *player_stats, struct Stats *monster_stats, struct Move *move, int ismonster);
|
||||
int calc_damage(struct Stats *attacker, struct Stats *target, struct Move *move);
|
||||
struct Move *copy_move(struct Move move);
|
||||
|
||||
struct Move *get_move_id_pointer(int id);
|
||||
|
||||
float crit(struct Stats *attacker);
|
||||
int is_crit();
|
||||
int is_miss(struct Move *move);
|
||||
int is_miss(struct Move *move);
|
||||
int self_effect(struct Stats *stats, struct Move *move);
|
|
@ -6,7 +6,7 @@
|
|||
#include <gint/display.h>
|
||||
|
||||
struct Monster {
|
||||
const char *name;
|
||||
char *name;
|
||||
bopti_image_t *sprite;
|
||||
int nbMoves;
|
||||
struct Stats *stats;
|
||||
|
|
50
src/battle.c
50
src/battle.c
|
@ -39,7 +39,7 @@ int battle(struct Player *player, struct Monster *monster) {
|
|||
dupdate();
|
||||
wait_for_input(KEY_SHIFT);
|
||||
status = execute_move(&player->stats, monster->stats, player->moves[selection], 0);
|
||||
check_move_status(status, player, monster);
|
||||
check_move_status(status, player, monster, 0);
|
||||
|
||||
draw_battle(player, monster);
|
||||
|
||||
|
@ -55,7 +55,7 @@ int battle(struct Player *player, struct Monster *monster) {
|
|||
dupdate();
|
||||
wait_for_input(KEY_SHIFT);
|
||||
status = execute_move(&player->stats, monster->stats, monster_move, 1);
|
||||
check_move_status(status, player, monster);
|
||||
check_move_status(status, player, monster, 1);
|
||||
|
||||
if(player->stats.pv <= 0) {
|
||||
return LOSE;
|
||||
|
@ -68,17 +68,32 @@ int battle(struct Player *player, struct Monster *monster) {
|
|||
return LOSE;
|
||||
}
|
||||
|
||||
void check_move_status(int status, struct Player *player, struct Monster *monster) {
|
||||
if(status == CRIT) {
|
||||
void check_move_status(int status, struct Player *player, struct Monster *monster, int is_monster) {
|
||||
char *name = is_monster ? monster->name : "Player";
|
||||
if(status != SUCCESS) {
|
||||
draw_battle(player, monster);
|
||||
draw_status("Coup critique !");
|
||||
dupdate();
|
||||
wait_for_input(KEY_SHIFT);
|
||||
}
|
||||
|
||||
if(status == MISS) {
|
||||
draw_battle(player, monster);
|
||||
draw_status("Mais cela échoue !");
|
||||
switch(status){
|
||||
case CRIT:
|
||||
draw_status(name, "réalise un coup critique !");
|
||||
break;
|
||||
case MISS:
|
||||
draw_status(name, "rate son attaque !");
|
||||
break;
|
||||
case HEAL:
|
||||
draw_status(name, "regagne des PVs !");
|
||||
break;
|
||||
case ATK:
|
||||
draw_status(name, "améliore son attaque !");
|
||||
break;
|
||||
case DEF:
|
||||
draw_status(name, "améliore sa défense !");
|
||||
break;
|
||||
case MULTIPLE:
|
||||
draw_status(name, "améliore ses statistiques !");
|
||||
break;
|
||||
}
|
||||
|
||||
dupdate();
|
||||
wait_for_input(KEY_SHIFT);
|
||||
}
|
||||
|
@ -107,7 +122,6 @@ void finish_battle(int status, struct Game *game, struct Monster *monster) {
|
|||
wait_for_input(KEY_SHIFT);
|
||||
}
|
||||
game->player->stats.level = calc_level;
|
||||
set_stats_level_from(&game->player->base_stats, &game->player->stats);
|
||||
|
||||
} else if(status == LOSE) {
|
||||
draw_battle(game->player, monster);
|
||||
|
@ -118,6 +132,8 @@ void finish_battle(int status, struct Game *game, struct Monster *monster) {
|
|||
game->player->stats.pv = 0;
|
||||
}
|
||||
|
||||
//On retire les changements de status en revenant à la base
|
||||
set_stats_level_from(&game->player->base_stats, &game->player->stats);
|
||||
free_monster(monster);
|
||||
}
|
||||
|
||||
|
@ -143,6 +159,12 @@ int select_move(struct Player *player, struct Monster *monster, int prec_selecte
|
|||
dtext(58 + (selection * 130), DHEIGHT-15 , C_RED, "[X]");
|
||||
dupdate();
|
||||
|
||||
if(keydown(KEY_OPTN)) {
|
||||
draw_stats(player->stats);
|
||||
dupdate();
|
||||
wait_for_input(KEY_OPTN);
|
||||
}
|
||||
|
||||
if(keydown(KEY_SHIFT)) {
|
||||
if(buffer) buffer = 0;
|
||||
else if(player->moves[selection]->pp > 0) break;
|
||||
|
@ -204,7 +226,7 @@ void draw_executed_move(struct Move *move, struct Monster *monster, int is_monst
|
|||
}
|
||||
}
|
||||
|
||||
void draw_status(char *message) {
|
||||
void draw_status(char *name, char *message) {
|
||||
dimage(42,DHEIGHT-75,&img_dialogue);
|
||||
dprint(50,DHEIGHT-47, C_BLACK, "%s", message);
|
||||
dprint(50,DHEIGHT-47, C_BLACK, "%s %s", name, message);
|
||||
}
|
|
@ -33,25 +33,40 @@ struct Move *copy_move(struct Move move) {
|
|||
copyMove->name = move.name;
|
||||
copyMove->init_pp = move.init_pp;
|
||||
copyMove->id = move.id;
|
||||
copyMove->categorie = move.categorie;
|
||||
|
||||
copyMove->pp = move.pp;
|
||||
copyMove->atk = move.atk;
|
||||
copyMove->precision = move.precision;
|
||||
copyMove->boost_atk = move.boost_atk;
|
||||
copyMove->boost_def = move.boost_def;
|
||||
copyMove->boost_hp = move.boost_hp;
|
||||
|
||||
return copyMove;
|
||||
}
|
||||
|
||||
void draw_move(int x, int y, int x2, int y2, struct Move *move) {
|
||||
extern bopti_image_t img_capacite;
|
||||
extern bopti_image_t img_categories;
|
||||
|
||||
const int font_size = 8;
|
||||
dimage(x, y, &img_capacite);
|
||||
dsubimage(x+96, y+7, &img_categories, 20*move->categorie, 0, 20, 10, DIMAGE_NONE);
|
||||
|
||||
int color = move->pp > 0 ? C_BLACK : C_RED;
|
||||
dprint(x+15, y+5, color, "PP : %d", move->pp);
|
||||
dprint(x+15, y2-17, C_BLACK, "ATK : %d", move->atk);
|
||||
dprint(x+70, y2-17, C_BLACK, "PRE : %d", move->precision);
|
||||
dprint((int)((x+x2)/2)-(int)(strlen(move->name)/2*font_size),
|
||||
(int)((y+y2)/2)-font_size/2,
|
||||
C_BLACK, "%s", move->name);
|
||||
|
||||
if(move->categorie == PHYSICAL) {
|
||||
dprint(x+15, y2-17, C_BLACK, "ATK : %d", move->atk);
|
||||
dprint(x+70, y2-17, C_BLACK, "PRE : %d", move->precision);
|
||||
} else {
|
||||
if(move->boost_atk > 0) dprint(x+10, y2-17, C_BLACK, "A+%d%%", move->boost_atk);
|
||||
if(move->boost_hp > 0) dprint(x+47, y2-17, C_BLACK, "H+%d%%", move->boost_hp);
|
||||
if(move->boost_def > 0) dprint(x+85, y2-17, C_BLACK, "D+%d%%", move->boost_def);
|
||||
}
|
||||
}
|
||||
|
||||
void draw_classic_move(int x, int y, struct Move *move) {
|
||||
|
@ -60,24 +75,34 @@ void draw_classic_move(int x, int y, struct Move *move) {
|
|||
|
||||
int execute_move(struct Stats *player_stats, struct Stats *monster_stats, struct Move *move, int ismonster) {
|
||||
srand(rtc_ticks());
|
||||
if(is_miss(move)) {
|
||||
move->pp--;
|
||||
return MISS;
|
||||
}
|
||||
if(move->categorie == PHYSICAL) {
|
||||
if(is_miss(move)) {
|
||||
move->pp--;
|
||||
return MISS;
|
||||
}
|
||||
|
||||
if(ismonster) {
|
||||
player_stats->pv-=calc_damage(monster_stats, player_stats, move);
|
||||
if(ismonster) {
|
||||
player_stats->pv-=calc_damage(monster_stats, player_stats, move);
|
||||
} else {
|
||||
move->pp--;
|
||||
monster_stats->pv-=calc_damage(player_stats, monster_stats, move);
|
||||
}
|
||||
|
||||
if(is_crit()) return CRIT;
|
||||
} else {
|
||||
move->pp--;
|
||||
monster_stats->pv-=calc_damage(player_stats, monster_stats, move);
|
||||
if(ismonster) {
|
||||
return self_effect(monster_stats, move);
|
||||
} else {
|
||||
move->pp--;
|
||||
return self_effect(player_stats, move);
|
||||
}
|
||||
return HEAL;
|
||||
}
|
||||
|
||||
if(is_crit()) return CRIT;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int calc_damage(struct Stats *attacker, struct Stats *target, struct Move *move) {
|
||||
return (floor(((2*attacker->level / 5 + 2) * attacker->atk * move->atk / target->def) / 50) + 2)*crit(attacker);
|
||||
return floor((floor(((2*attacker->level / 5 + 2) * attacker->atk * move->atk / target->def) / 50) + 2)*crit(attacker));
|
||||
}
|
||||
|
||||
int is_crit() {
|
||||
|
@ -97,4 +122,17 @@ float crit(struct Stats *attacker) {
|
|||
/*1 if miss, else 0*/
|
||||
int is_miss(struct Move *move) {
|
||||
return rand_range(0, 101) > move->precision;
|
||||
}
|
||||
|
||||
int self_effect(struct Stats *stats, struct Move *move) {
|
||||
stats->pv += stats->max_pv * move->boost_hp/100;
|
||||
stats->atk *= (float)(100+move->boost_atk)/100;
|
||||
stats->def *= (float)(100+move->boost_def)/100;
|
||||
|
||||
if(stats->pv > stats->max_pv) stats->pv = stats->max_pv;
|
||||
|
||||
if((move->boost_hp > 0 && move->boost_atk > 0) ||
|
||||
(move->boost_hp > 0 && move->boost_def > 0) ||
|
||||
(move->boost_atk > 0 && move->boost_def > 0)) return MULTIPLE;
|
||||
return move->boost_hp > 0 ? HEAL : move->boost_atk > 0 ? ATK : DEF;
|
||||
}
|
|
@ -44,10 +44,10 @@ struct Move *monster_select(struct Player *player, struct Monster *monster) {
|
|||
for(int i = 0; i < monster->nbMoves; i++) {
|
||||
struct Move *move = get_move_id_pointer(monster->moves[i]);
|
||||
int damage = calc_damage(monster->stats, &player->stats, move);
|
||||
if(damage >= player->stats.pv) {
|
||||
stoMove = move;
|
||||
if(move->precision > 80) return move;
|
||||
}
|
||||
// if(damage >= player->stats.pv) {
|
||||
// stoMove = move;
|
||||
// if(move->precision > 80) return move;
|
||||
// }
|
||||
if(damage > stoDamage) {
|
||||
stoMove = move;
|
||||
stoDamage = damage;
|
||||
|
|
|
@ -36,7 +36,7 @@ struct Player init_player(void) {
|
|||
.anim.dir = DIR_DOWN
|
||||
};
|
||||
player.idle = !anim_player_idle(&player.anim, 1);
|
||||
player.moves[0] = copy_move(default_move());
|
||||
player.moves[0] = copy_move(get_move_id(1));
|
||||
|
||||
set_stats_level_from(&player.base_stats, &player.stats);
|
||||
return player;
|
||||
|
|
Loading…
Reference in New Issue