rogged/src/common.h
NotAShelf 26aa295f82
build: move map & rng logic to their own libraries
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I1802469f3baff4576f61accfb5a197d86a6a6964
2026-04-10 20:07:04 +03:00

118 lines
2.6 KiB
C

#ifndef COMMON_H
#define COMMON_H
#include "settings.h"
#include <stdbool.h>
typedef struct {
int x, y;
} Vec2;
// Tile types
typedef enum { TILE_WALL, TILE_FLOOR, TILE_STAIRS } TileType;
// Status effect types
typedef enum { EFFECT_NONE, EFFECT_POISON, EFFECT_STUN, EFFECT_BLEED, EFFECT_WEAKEN, EFFECT_BURN } StatusEffectType;
// Damage classes
typedef enum { DMG_SLASH, DMG_IMPACT, DMG_PIERCE, DMG_FIRE, DMG_POISON } DamageClass;
// Status effect instance
typedef struct {
StatusEffectType type;
int duration; // turns remaining
int intensity; // damage per tick or stat reduction amount
} StatusEffect;
// Room
typedef struct {
int x, y, w, h;
} Room;
// Map
typedef struct {
TileType tiles[MAP_HEIGHT][MAP_WIDTH];
Room rooms[MAX_ROOMS];
int room_count;
unsigned char visible[MAP_HEIGHT][MAP_WIDTH];
unsigned char remembered[MAP_HEIGHT][MAP_WIDTH];
} Map;
// Dungeon
typedef struct {
int current_floor;
Room rooms[MAX_ROOMS];
int room_count;
} Dungeon;
// Item types
typedef enum { ITEM_POTION, ITEM_WEAPON, ITEM_ARMOR } ItemType;
// Item
typedef struct {
int x, y;
ItemType type;
int power;
int floor;
int picked_up;
DamageClass dmg_class;
int crit_chance;
int crit_multiplier;
int status_chance;
} Item;
// Player
typedef struct {
Vec2 position;
int hp, max_hp;
int attack;
int defense;
int floor;
int step_count;
int speed; // actions per 100 ticks (100 = 1 action per turn)
int cooldown; // countdown to next action (0 = can act)
int dodge; // dodge chance percentage
int block; // flat damage reduction on successful block roll
Item equipped_weapon;
int has_weapon;
Item equipped_armor;
int has_armor;
Item inventory[MAX_INVENTORY];
int inventory_count;
// status effects
StatusEffect effects[MAX_EFFECTS];
int effect_count;
} Player;
// Enemy types
typedef enum { ENEMY_GOBLIN, ENEMY_SKELETON, ENEMY_ORC } EnemyType;
// Enemy
typedef struct {
Vec2 position;
int hp;
int max_hp;
int attack;
int alive;
EnemyType type;
int speed; // actions per 100 ticks
int cooldown; // countdown to next action
int dodge; // dodge chance percentage
int block; // flat damage reduction
int resistance[NUM_DMG_CLASSES];
DamageClass dmg_class;
int status_chance;
int crit_chance; // crit chance percentage (0-100)
int crit_mult; // crit damage multiplier percentage (e.g. 150 = 1.5x)
// vision
int vision_range;
int alert; // 1 = aware of player, searching
int last_known_x; // last position where enemy saw player
int last_known_y;
// status effects
StatusEffect effects[MAX_EFFECTS];
int effect_count;
} Enemy;
#endif // COMMON_H