mirror of https://github.com/bgiraudr/Adoranda.git
Types are now working + bugfix event on area
This commit is contained in:
parent
42bf216c8c
commit
dfbdb84327
|
@ -2,6 +2,7 @@
|
|||
"name":"Charge",
|
||||
"id":2,
|
||||
"categorie":"PHYSICAL",
|
||||
"type":"Modérateur",
|
||||
"pp":25,
|
||||
"atk":15,
|
||||
"precision":100
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name":"Cheat",
|
||||
"id":3,
|
||||
"categorie":"PHYSICAL",
|
||||
"type":"Administrateur",
|
||||
"pp":25,
|
||||
"atk":45,
|
||||
"precision":100
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name":"Soin",
|
||||
"id":1,
|
||||
"categorie":"STATUT",
|
||||
"type":"Rédacteur",
|
||||
"pp":100,
|
||||
"boost_atk":15,
|
||||
"boost_hp":15,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name":"Test capacité",
|
||||
"id":0,
|
||||
"categorie":"SPECIAL",
|
||||
"type":"Labélisateur",
|
||||
"pp":5,
|
||||
"atk":20,
|
||||
"precision":100
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name":"Test capacité2",
|
||||
"id":4,
|
||||
"categorie":"PHYSICAL",
|
||||
"type":"Rédacteur",
|
||||
"pp":5,
|
||||
"atk":20,
|
||||
"precision":100
|
||||
|
|
|
@ -191,8 +191,10 @@ def parseZone(layer):
|
|||
zone += fxconv.u32(origin[1])
|
||||
zone += fxconv.u32(to[0])
|
||||
zone += fxconv.u32(to[1])
|
||||
zone += fxconv.string(i["properties"][0]["value"]) #event
|
||||
print(i["properties"][0]["value"])
|
||||
|
||||
event = bytes(i["properties"][0]["value"], "utf-8")
|
||||
event += bytes(128 - len(event))
|
||||
zone += event #event
|
||||
|
||||
monsters = bytes()
|
||||
zone += fxconv.u32(int(i["properties"][1]["value"]) if i["properties"][1]["value"] != "" else -1) #level
|
||||
|
@ -229,6 +231,7 @@ def convert_capa(input, output, params, target):
|
|||
id_categorie = ["STATUT", "PHYSICAL", "SPECIAL"]
|
||||
|
||||
move += fxconv.string(data["name"])
|
||||
move += fxconv.string(data["type"])
|
||||
move += fxconv.u32(data["id"])
|
||||
move += fxconv.u32(id_categorie.index(categorie))
|
||||
move += fxconv.u32(data["pp"])
|
||||
|
@ -261,6 +264,7 @@ def convert_monster(input, output, params, target):
|
|||
stats = fxconv.Structure()
|
||||
|
||||
if len(data["stats"]) != 6: raise Exception(f"convert_monster : Les statistiques de {data['name']} sont mauvaises")
|
||||
stats+=fxconv.string(data["type"])
|
||||
stats+=fxconv.u32(data["stats"]["atk"])
|
||||
stats+=fxconv.u32(data["stats"]["def"])
|
||||
stats+=fxconv.u32(data["stats"]["pv"])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.8" tiledversion="1.8.4" orientation="orthogonal" renderorder="right-down" width="100" height="38" tilewidth="16" tileheight="16" infinite="0" nextlayerid="14" nextobjectid="65">
|
||||
<map version="1.8" tiledversion="1.8.4" orientation="orthogonal" renderorder="right-down" width="100" height="38" tilewidth="16" tileheight="16" infinite="0" nextlayerid="14" nextobjectid="66">
|
||||
<editorsettings>
|
||||
<export target="testCarte.json" format="json"/>
|
||||
</editorsettings>
|
||||
|
@ -216,16 +216,16 @@
|
|||
<objectgroup id="13" name="zone">
|
||||
<object id="57" x="400" y="464" width="32" height="48">
|
||||
<properties>
|
||||
<property name="event" value=""/>
|
||||
<property name="event" value="xp:1"/>
|
||||
<property name="level" type="int" value="30"/>
|
||||
<property name="monsters" value="1"/>
|
||||
<property name="monsters" value="1;2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="58" x="256" y="464" width="112" height="32">
|
||||
<properties>
|
||||
<property name="event" value="xp:30"/>
|
||||
<property name="level" value=""/>
|
||||
<property name="monsters" value=""/>
|
||||
<property name="level" value="5"/>
|
||||
<property name="monsters" value="2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="64" x="304" y="560" width="112" height="32">
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name":"test",
|
||||
"sprite":"test",
|
||||
"id":1,
|
||||
"type":"Labélisateur",
|
||||
"stats":{
|
||||
"atk":10,
|
||||
"def":10,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name":"Citron",
|
||||
"sprite":"test2",
|
||||
"id":2,
|
||||
"type":"Modérateur",
|
||||
"stats":{
|
||||
"atk":80,
|
||||
"def":5,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
struct Move {
|
||||
char *name;
|
||||
char *type;
|
||||
int id;
|
||||
int categorie;
|
||||
int init_pp;
|
||||
|
@ -28,7 +29,10 @@ enum status {
|
|||
HEAL,
|
||||
ATK,
|
||||
DEF,
|
||||
MULTIPLE
|
||||
MULTIPLE,
|
||||
SUPER_EFFECTIVE,
|
||||
LESS_EFFECTIVE,
|
||||
NOT_EFFECTIVE
|
||||
};
|
||||
|
||||
enum categorie {
|
||||
|
@ -48,4 +52,5 @@ struct Move *get_move_id_pointer(int id);
|
|||
float crit(struct Stats *attacker);
|
||||
int is_crit();
|
||||
int is_miss(struct Move *move);
|
||||
int self_effect(struct Stats *stats, struct Move *move);
|
||||
int self_effect(struct Stats *stats, struct Move *move);
|
||||
float stab(char *type, char *move);
|
|
@ -18,6 +18,7 @@ enum action {
|
|||
DIR_UP,
|
||||
DIR_RIGHT,
|
||||
ACTION_SHIFT,
|
||||
ACTION_MENU,
|
||||
ACTION_ALPHA,
|
||||
ACTION_OPTN,
|
||||
ACTION_F1,
|
||||
|
|
|
@ -11,7 +11,7 @@ struct Teleporter {
|
|||
struct Zone {
|
||||
int start_x, start_y;
|
||||
int end_x, end_y;
|
||||
char *event;
|
||||
char event[128];
|
||||
int level;
|
||||
int nbMonsters;
|
||||
short *monsters;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "capacite.h"
|
||||
#include "game.h"
|
||||
#include <gint/display.h>
|
||||
#include "type.h"
|
||||
|
||||
struct Monster {
|
||||
char *name;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "capacite.h"
|
||||
#include "inventory.h"
|
||||
#include "define.h"
|
||||
#include "type.h"
|
||||
|
||||
struct Player {
|
||||
/*current position of the player on the map - Tile*/
|
||||
|
@ -17,6 +18,7 @@ struct Player {
|
|||
struct Stats stats;
|
||||
struct Move *moves[NB_PLAYER_MOVES];
|
||||
struct Inventory inventory;
|
||||
struct Type type;
|
||||
/*player mid - offset pixels*/
|
||||
int x_mid, y_mid;
|
||||
/*the direction the player facing to*/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
struct Stats {
|
||||
char* type;
|
||||
int atk;
|
||||
int def;
|
||||
int pv;
|
||||
|
|
26
src/battle.c
26
src/battle.c
|
@ -8,6 +8,7 @@
|
|||
#include "capacite.h"
|
||||
#include "player.h"
|
||||
#include "monster.h"
|
||||
#include "talkable.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
extern bopti_image_t img_dialogue;
|
||||
|
@ -92,6 +93,15 @@ void check_move_status(int status, struct Player *player, struct Monster *monste
|
|||
case MULTIPLE:
|
||||
draw_status(name, "améliore ses statistiques !");
|
||||
break;
|
||||
case SUPER_EFFECTIVE:
|
||||
draw_status(name, "utilise une attaque super efficace !");
|
||||
break;
|
||||
case LESS_EFFECTIVE:
|
||||
draw_status(name, "utilise une attaque peu efficace");
|
||||
break;
|
||||
case NOT_EFFECTIVE:
|
||||
draw_status(name, "utilise une attaque non efficace...");
|
||||
break;
|
||||
}
|
||||
|
||||
dupdate();
|
||||
|
@ -105,8 +115,7 @@ void finish_battle(int status, struct Game *game, struct Monster *monster) {
|
|||
//gain d'xp
|
||||
int xp = ceil((monster->stats->xp*monster->stats->level*1.5)/7);
|
||||
|
||||
dimage(42,DHEIGHT-75,&img_dialogue);
|
||||
dprint(50,DHEIGHT-47, C_BLACK, "Vous remportez %d points d'experience", xp);
|
||||
format_text(50, DHEIGHT-47, C_BLACK, "Vous remportez %d points d'experience", xp);
|
||||
dupdate();
|
||||
wait_for_input(KEY_SHIFT);
|
||||
|
||||
|
@ -114,8 +123,7 @@ void finish_battle(int status, struct Game *game, struct Monster *monster) {
|
|||
|
||||
} else if(status == LOSE) {
|
||||
draw_battle(game->player, monster);
|
||||
dimage(42,DHEIGHT-75,&img_dialogue);
|
||||
dprint(50,DHEIGHT-47,C_BLACK,"%s a eu raison de vous !", monster->name);
|
||||
format_text(50, DHEIGHT-47, C_BLACK, "%s a eu raison de vous !", monster->name);
|
||||
dupdate();
|
||||
wait_for_input(KEY_SHIFT);
|
||||
game->player->stats.pv = 0;
|
||||
|
@ -188,6 +196,7 @@ void draw_battle(struct Player *player, struct Monster *monster) {
|
|||
|
||||
dprint(333,124,C_BLACK,"%d",player->stats.level);
|
||||
dprint(246,124,C_BLACK,"%d/%d", player->stats.pv, player->stats.max_pv);
|
||||
dtext(340,115,C_BLUE, player->stats.type);
|
||||
|
||||
int posHPmonster = (float)monster->stats->pv / monster->stats->max_pv * WIDTH_HP;
|
||||
dprint(2,8,C_BLACK,"%s",monster->name);
|
||||
|
@ -202,20 +211,19 @@ void draw_battle(struct Player *player, struct Monster *monster) {
|
|||
drect(48,23,48+posHPmonster,27,mcolor);
|
||||
dprint(90,9,C_BLACK,"%d",monster->stats->level);
|
||||
dprint(127,11,C_BLACK,"%d/%d", monster->stats->pv, monster->stats->max_pv);
|
||||
dtext(92,0,C_BLUE, monster->stats->type);
|
||||
|
||||
dimage(265,10,monster->sprite);
|
||||
}
|
||||
|
||||
void draw_executed_move(struct Move *move, struct Monster *monster, int is_monster) {
|
||||
dimage(42,DHEIGHT-75,&img_dialogue);
|
||||
if(is_monster) {
|
||||
dprint(50,DHEIGHT-47, C_BLACK, "%s lance %s !", monster->name, move->name);
|
||||
format_text(50, DHEIGHT-47, C_BLACK, "%s lance %s !", monster->name, move->name);
|
||||
} else {
|
||||
dprint(50,DHEIGHT-47, C_BLACK, "Vous lancez %s !", move->name);
|
||||
format_text(50, DHEIGHT-47, C_BLACK, "Vous lancez %s !", move->name);
|
||||
}
|
||||
}
|
||||
|
||||
void draw_status(char *name, char *message) {
|
||||
dimage(42,DHEIGHT-75,&img_dialogue);
|
||||
dprint(50,DHEIGHT-47, C_BLACK, "%s %s", name, message);
|
||||
format_text(50, DHEIGHT-47, C_BLACK, "%s %s", name, message);
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "capacite.h"
|
||||
#include "util.h"
|
||||
#include "type.h"
|
||||
|
||||
extern struct Capacities capacities;
|
||||
|
||||
|
@ -31,6 +32,7 @@ struct Move *get_move_id_pointer(int id) {
|
|||
struct Move *copy_move(struct Move move) {
|
||||
struct Move *copyMove = malloc(sizeof(struct Move));
|
||||
copyMove->name = move.name;
|
||||
copyMove->type = move.type;
|
||||
copyMove->init_pp = move.init_pp;
|
||||
copyMove->id = move.id;
|
||||
copyMove->categorie = move.categorie;
|
||||
|
@ -67,6 +69,7 @@ void draw_move(int x, int y, int x2, int y2, struct Move *move) {
|
|||
dprint(x+15, y2-17, C_BLACK, "ATK : %d", move->atk);
|
||||
dprint(x+70, y2-17, C_BLACK, "PRE : %d", move->precision);
|
||||
}
|
||||
dtext(x+50, y+15, C_BLUE, move->type);
|
||||
}
|
||||
|
||||
void draw_classic_move(int x, int y, struct Move *move) {
|
||||
|
@ -81,13 +84,19 @@ int execute_move(struct Stats *player_stats, struct Stats *monster_stats, struct
|
|||
return MISS;
|
||||
}
|
||||
|
||||
float typeEffect;
|
||||
if(ismonster) {
|
||||
player_stats->pv-=calc_damage(monster_stats, player_stats, move);
|
||||
typeEffect = getTypeEffect(getTypeFromName(move->type), getTypeFromName(player_stats->type));
|
||||
} else {
|
||||
move->pp--;
|
||||
monster_stats->pv-=calc_damage(player_stats, monster_stats, move);
|
||||
typeEffect = getTypeEffect(getTypeFromName(move->type), getTypeFromName(monster_stats->type));
|
||||
}
|
||||
|
||||
if(typeEffect == 2) return SUPER_EFFECTIVE;
|
||||
if(typeEffect == 0.5) return LESS_EFFECTIVE;
|
||||
if(typeEffect == 0) return NOT_EFFECTIVE;
|
||||
if(is_crit()) return CRIT;
|
||||
} else {
|
||||
if(ismonster) {
|
||||
|
@ -102,11 +111,27 @@ int execute_move(struct Stats *player_stats, struct Stats *monster_stats, struct
|
|||
}
|
||||
|
||||
int calc_damage(struct Stats *attacker, struct Stats *target, struct Move *move) {
|
||||
if(move->categorie == PHYSICAL)
|
||||
return floor((floor(((2*attacker->level / 5 + 2) * attacker->atk * move->atk / target->def) / 50) + 2)*crit(attacker));
|
||||
if(move->categorie == SPECIAL)
|
||||
return floor((floor(((2*attacker->level / 5 + 2) * attacker->spe_atk * move->atk / target->spe_def) / 50) + 2)*crit(attacker));
|
||||
return 0;
|
||||
int atk =1, def = 1;
|
||||
if(move->categorie == PHYSICAL) {
|
||||
atk = attacker->atk;
|
||||
def = target->def;
|
||||
} else if(move->categorie == SPECIAL) {
|
||||
atk = attacker->spe_atk;
|
||||
def = target->spe_def;
|
||||
}
|
||||
|
||||
if(getTypeEffect(getTypeFromName(move->type), getTypeFromName(target->type)) == 0) return 0;
|
||||
return floor((floor(((2*attacker->level / 5 + 2) * atk *
|
||||
move->atk
|
||||
*getTypeEffect(getTypeFromName(move->type), getTypeFromName(target->type))
|
||||
*stab(attacker->type, move->type)
|
||||
/ def)
|
||||
/ 50) + 2)*crit(attacker));
|
||||
}
|
||||
|
||||
float stab(char *type, char *move) {
|
||||
if(!strcmp(type, move)) return 1.5f;
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
int is_crit() {
|
||||
|
|
|
@ -135,7 +135,7 @@ void engine_action(struct Game *game, int action) {
|
|||
}
|
||||
if(action == ACTION_F2) {
|
||||
//add_item_to_inventory(game, &game->player->inventory, get_item_id(1));
|
||||
srand(game->player->pos.x * game->player->pos.y);
|
||||
// srand(game->player->pos.x * game->player->pos.y);
|
||||
drawTypeEffects(getTypeFromId(rand_range(1,5)));
|
||||
}
|
||||
if(action == ACTION_OPTN) {
|
||||
|
|
33
src/game.c
33
src/game.c
|
@ -23,23 +23,22 @@ int get_inputs(void) {
|
|||
int opt = GETKEY_DEFAULT & GETKEY_REP_ARROWS;
|
||||
int timeout = 1;
|
||||
|
||||
while(1) {
|
||||
key_event_t ev = getkey_opt(opt, &timeout);
|
||||
if(ev.type == KEYEV_NONE) return -1;
|
||||
int key = ev.key;
|
||||
if(key == KEY_MENU) return ACTION_MENU;
|
||||
|
||||
key_event_t ev = getkey_opt(opt, &timeout);
|
||||
if(ev.type == KEYEV_NONE) return -1;
|
||||
int key = ev.key;
|
||||
/*direction*/
|
||||
if(key == KEY_DOWN) return DIR_DOWN;
|
||||
if(key == KEY_RIGHT) return DIR_RIGHT;
|
||||
if(key == KEY_UP) return DIR_UP;
|
||||
if(key == KEY_LEFT) return DIR_LEFT;
|
||||
|
||||
/*direction*/
|
||||
if(key == KEY_DOWN) return DIR_DOWN;
|
||||
if(key == KEY_RIGHT) return DIR_RIGHT;
|
||||
if(key == KEY_UP) return DIR_UP;
|
||||
if(key == KEY_LEFT) return DIR_LEFT;
|
||||
|
||||
/*action key*/
|
||||
if(key == KEY_SHIFT) return ACTION_SHIFT;
|
||||
if(key == KEY_ALPHA) return ACTION_ALPHA;
|
||||
if(key == KEY_OPTN) return ACTION_OPTN;
|
||||
if(key == KEY_F1) return ACTION_F1;
|
||||
if(key == KEY_F2) return ACTION_F2;
|
||||
}
|
||||
/*action key*/
|
||||
if(key == KEY_SHIFT) return ACTION_SHIFT;
|
||||
if(key == KEY_ALPHA) return ACTION_ALPHA;
|
||||
if(key == KEY_OPTN) return ACTION_OPTN;
|
||||
if(key == KEY_F1) return ACTION_F1;
|
||||
if(key == KEY_F2) return ACTION_F2;
|
||||
return -1;
|
||||
}
|
||||
|
|
17
src/main.c
17
src/main.c
|
@ -42,19 +42,24 @@ int main(void) {
|
|||
dupdate_set_hook(GINT_CALL(take_capture));
|
||||
|
||||
/*Main loop*/
|
||||
while(!keydown(KEY_MENU)) {
|
||||
while(1) {
|
||||
while(!tick) sleep();
|
||||
tick = 0;
|
||||
|
||||
engine_draw(&game);
|
||||
dupdate();
|
||||
|
||||
int action = get_inputs();
|
||||
if(action >= 0 && action <= 3)
|
||||
engine_move(&game, action);
|
||||
else if(action >= 4) {
|
||||
engine_action(&game, action);
|
||||
int action = 0;
|
||||
while(action != -1) {
|
||||
action = get_inputs();
|
||||
if(action == ACTION_MENU) break;
|
||||
if(action >= DIR_DOWN && action <= DIR_RIGHT)
|
||||
engine_move(&game, action);
|
||||
else if(action >= ACTION_SHIFT) {
|
||||
engine_action(&game, action);
|
||||
}
|
||||
}
|
||||
if(action == ACTION_MENU) break;
|
||||
engine_tick(&game, ENGINE_TICK);
|
||||
}
|
||||
|
||||
|
|
12
src/map.c
12
src/map.c
|
@ -13,6 +13,16 @@ struct Map *maps[] = {
|
|||
&map_2,
|
||||
};
|
||||
|
||||
struct Zone default_zone = {
|
||||
.start_x = 0,
|
||||
.start_y = 0,
|
||||
.end_x = 0,
|
||||
.end_y = 0,
|
||||
.event = "",
|
||||
.level = -1,
|
||||
.nbMonsters = 0
|
||||
};
|
||||
|
||||
/*check if a tile is walkable*/
|
||||
int map_walkable(struct Map const *map, int x, int y) {
|
||||
int tile = map->info_map[x + map->w * y];
|
||||
|
@ -84,5 +94,5 @@ struct Zone get_zone(struct Player *player, struct Map *map) {
|
|||
struct Zone zone = map->zones[i];
|
||||
if(zone.start_x <= posx && zone.start_y <= posy && zone.end_x >= posx && zone.end_y >= posy) return zone;
|
||||
}
|
||||
return map->zones[0];
|
||||
return default_zone;
|
||||
}
|
|
@ -28,7 +28,8 @@ struct Player init_player(void) {
|
|||
|
||||
struct Stats stats = {
|
||||
.level = 1,
|
||||
.xp = 0
|
||||
.xp = 0,
|
||||
.type = "Rédacteur"
|
||||
};
|
||||
|
||||
struct Inventory inventory = {
|
||||
|
|
|
@ -15,6 +15,7 @@ void draw_stats(struct Stats stats) {
|
|||
dprint(300,120,C_BLACK,"ATKS : %d",stats.spe_atk);
|
||||
dprint(300,140,C_BLACK,"DEFS : %d",stats.spe_def);
|
||||
dprint(300,160,C_BLACK,"LVLUP : %d",(int)(pow(stats.level+1, 3.03))-stats.xp);
|
||||
dprint(300, 180, C_BLUE, stats.type);
|
||||
}
|
||||
|
||||
void set_stats_level_from(const struct Stats *from, struct Stats *to) {
|
||||
|
|
Loading…
Reference in New Issue