/* * This file is part of RuneOptimizer. * * RuneOptimizer is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) * any later version. * * RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * RuneOptimizer. If not, see . */ /** * @file runeoptimizer.h * * Declarations of the functions and data types used across the application. * * This file declares all the functions and data types used from anywhere in the * program. */ #pragma once #include /** * Application version. * * Metadata, only used in the help and version commands. */ #define VERSION "0.1-RC1" /** * Application author. * * Metadata, only used in the help command. */ #define AUTHOR "IƱigo Valentin" /** * Application author email. * * Metadata, only used in the help command. */ #define MAIL "i@inigovalentin.com" /** * Boolean value TRUE. * * Mocked boolean for consistence across functions. */ #define TRUE 1 /** * Boolean value FALSE. * * Mocked boolean for consistence across functions. */ #define FALSE 0 /** * Energy Set. * * Set ID of Energy runes, as given by Com2Us. */ #define ENERGY 1 /** * Guard Set. * * Set ID of Guard runes, as given by Com2Us. */ #define GUARD 2 /** * Swift Set. * * Set ID of Swift runes, as given by Com2Us. */ #define SWIFT 3 /** * Blade Set. * * Set ID of Blade runes, as given by Com2Us. */ #define BLADE 4 /** * Rage Set. * * Set ID of Rage runes, as given by Com2Us. */ #define RAGE 5 /** * Focus Set. * * Set ID of Focus runes, as given by Com2Us. */ #define FOCUS 6 /** * Endure Set. * * Set ID of Endure runes, as given by Com2Us. */ #define ENDURE 7 /** * Fatal Set. * * Set ID of Fatal runes, as given by Com2Us. */ #define FATAL 8 /** * Despair Set. * * Set ID of Despair runes, as given by Com2Us. */ #define DESPAIR 10 /** * Vampire Set. * * Set ID of Vampire runes, as given by Com2Us. */ #define VAMPIRE 11 /** * Violent Set. * * Set ID of Violent runes, as given by Com2Us. */ #define VIOLENT 13 /** * Nemesis Set. * * Set ID of Nemesis runes, as given by Com2Us. */ #define NEMESIS 14 /** * Will Set. * * Set ID of Will runes, as given by Com2Us. */ #define WILL 15 /** * Shield Set. * * Set ID of Shield runes, as given by Com2Us. */ #define SHIELD 16 /** * Revenge Set. * * Set ID of Revenge runes, as given by Com2Us. */ #define REVENGE 17 /** * Destroy Set. * * Set ID of Destroy runes, as given by Com2Us. */ #define DESTROY 18 /** * Fight Set. * * Set ID of Fight runes, as given by Com2Us. */ #define FIGHT 19 /** * Determination Set. * * Set ID of Determination runes, as given by Com2Us. */ #define DETERMINATION 20 /** * Enhance Set. * * Set ID of Enhance runes, as given by Com2Us. */ #define ENHANCE 21 /** * Accuracy Set. * * Set ID of Accuracy runes, as given by Com2Us. */ #define ACCURACY 22 /** * Tolerance Set. * * Set ID of Tolerance runes, as given by Com2Us. */ #define TOLERANCE 23 /** * HP rune stat. * * Rune stat ID for HP in runes, as given by Com2Us. */ #define HP_FLAT 1 /** * HP% rune stat. * * Rune stat ID for HP% in runes, as given by Com2Us. */ #define HP_PERCENT 2 /** * ATK rune stat. * * Rune stat ID for ATK in runes, as given by Com2Us. */ #define ATK_FLAT 3 /** * ATK% rune stat. * * Rune stat ID for ATK% in runes, as given by Com2Us. */ #define ATK_PERCENT 4 /** * DEF rune stat. * * Rune stat ID for DEF in runes, as given by Com2Us. */ #define DEF_FLAT 5 /** * DEF% rune stat. * * Rune stat ID for DEF% in runes, as given by Com2Us. */ #define DEF_PERCENT 6 /** * SPD rune stat. * * Rune stat ID for SPD in runes, as given by Com2Us. */ #define SPD 8 /** * CRR rune stat. * * Rune stat ID for CRR in runes, as given by Com2Us. */ #define CRR 9 /** * CRD rune stat. * * Rune stat ID for CRD in runes, as given by Com2Us. */ #define CRD 10 /** * RES rune stat. * * Rune stat ID for RES in runes, as given by Com2Us. */ #define RES 11 /** * ACC rune stat. * * Rune stat ID for ACC in runes, as given by Com2Us. */ #define ACC 12 /** * Maximum length of Unit IDs. * * It can never be higher thahn this. */ #define UNIT_ID_LEN 14 /** * Maximum length of Unit name. * * It can never be higher thahn this. */ #define UNIT_NAME_LEN 128 /** * Maximum length of Rune IDs. * * It can never be higher thahn this. */ #define RUNE_ID_LEN 14 /** * Maximum length of Teams IDs. * * It can never be higher thahn this. */ #define TEAM_ID_LEN 4 /** * Length for the database file path. * * Totally arbitrary. * @todo This may be worriesome. */ #define DB_PATH_LEN 512 /** * Rune slots. * * Number of rune slots. In-game, and in many parts of this program, slots are * used with a 1-index. */ #define RUNE_SLOTS 6 /** * CRR Cap. * * Critical rate does nothing over 100%, so for more realistic calcultations, * it's better to have it capped. */ #define CRR_CAP 100.0f /** * RES Cap. * * Resistance does nothing over 100%, so for more realistic calcultations, it's * better to have it capped. */ #define RES_CAP 100.0f /** * ACC Cap. * * In the game, accurary is effectively capped at 85%, so for more realistic * calcultations, it's better to have it capped. */ #define ACC_CAP 85.0f /** * Number of stats defined in the game. * * It's not actually 13, because 0 and 7 are never used in game, but is a good * value for counters and loops. */ #define DIFFERENT_STATS 13 /** * Number of rune sets defined in the game. * * It's not actually 25, because 0, 9 and 12 are never used in game, but is a * good value for counters and loops. */ #define DIFFERENT_SETS 25 /** * Number of rune sets defined in the game. * * It's not actually 26, because a lot of them are never used in game, but is a * good value for counters and loops. */ #define DIFFERENT_QUALITIES 16 /** * Rune max stars. * * Watch out, a rune can't have 0 stars, so in loos, better start at 1. */ #define RUNE_MAX_STARS 6 /** * Structure representing a unit. * * Represents an entity from the table 'unit', but is doesn't have that mucha * data, just the mambers needed for optimization and some other thigs. For a * more complete representation of the table, {@link DB_Unit} can be used. */ typedef struct Unit { /** * Unit ID. * * The ID as given by Com2Us. */ unsigned char id[UNIT_ID_LEN]; /** * The Unit name. * * The name as given by Com2Us, except for Homunculus. For them, the user * given by the naem will be used. */ unsigned char name[UNIT_NAME_LEN]; /** * The unit base HP. * * The Unit HP, at it's current level, without counting runes, artifacts, * towers... */ unsigned int base_hp; /** * The unit base ATK. * * The Unit ATK, at it's current level, without counting runes, artifacts, * towers... */ unsigned short base_atk; /** * The unit base DEF. * * The Unit DEF, at it's current level, without counting runes, artifacts, * towers... */ unsigned short base_def; /** * The unit base SPD. * * The Unit SPD, at it's current level, without counting runes, artifacts, * towers... */ unsigned short base_spd; /** * The unit base CRR. * * The Unit CRR, at it's current level, without counting runes, artifacts, * towers... */ unsigned short base_crr; /** * The unit base CRD. * * The Unit CRD, at it's current level, without counting runes, artifacts, * towers... */ unsigned short base_crd; /** * The unit base RES. * * The Unit RES, at it's current level, without counting runes, artifacts, * towers... */ unsigned short base_res; /** * The unit base ACC. * * The Unit ACC, at it's current level, without counting runes, artifacts, * towers... */ unsigned short base_acc; /** * The unit base EHP. * * The Unit EHP, at it's current level, without counting runes, artifacts, * towers... See {@link calculate_ehp} for more details bout EHP. */ unsigned int base_ehp; /** * The unit base DMG. * * The Unit DMG, at it's current level, without counting runes, artifacts, * towers...See {@link calculate_ehp} for more details bout EHP. */ unsigned short base_dmg; /** * The unit base HP. * * The Unit HP, at it's current level, counting equiped runes, but not * artifacts or towers. */ unsigned int current_hp; /** * The unit base ATK. * * The Unit ATK, at it's current level, counting equiped runes, but not * artifacts or towers. */ unsigned short current_atk; /** * The unit base DEF. * * The Unit DEF, at it's current level, counting equiped runes, but not * artifacts or towers. */ unsigned short current_def; /** * The unit base SPD. * * The Unit SPD, at it's current level, counting equiped runes, but not * artifacts or towers. */ unsigned short current_spd; /** * The unit base CRR. * * The Unit CRR, at it's current level, counting equiped runes, but not * artifacts or towers. */ unsigned short current_crr; /** * The unit base CRD. * * The Unit CRD, at it's current level, counting equiped runes, but not * artifacts or towers. */ unsigned short current_crd; /** * The unit base RES. * * The Unit RES, at it's current level, counting equiped runes, but not * artifacts or towers. */ unsigned short current_res; /** * The unit base ACC. * * The Unit ACC, at it's current level, counting equiped runes, but not * artifacts or towers. */ unsigned short current_acc; /** * The unit base EHP. * * The Unit EHP, at it's current level, counting equiped runes, but not * artifacts or towers.See {@link calculate_ehp} for more details bout EHP. */ unsigned int current_ehp; /** * The unit base DMG. * * The Unit DMG, at it's current level, counting equiped runes, but not * artifacts or towers. See {@link calculate_ehp} for more details bout EHP. */ unsigned short current_dmg; } Unit; /** * Number of runes for a given list of runes. * * It just holds numbers of rune sets. See {@link optimize_count_runes_for_sets} * for a use case. */ typedef struct Rune_Set_Count { /** * Energy count. * * Number of Energy runes. */ unsigned short energy; /** * Guard count. * * Number of Guard runes. */ unsigned short guard; /** * Swift count. * * Number of Swift runes. */ unsigned short swift; /** * Blade count. * * Number of Blade runes. */ unsigned short blade; /** * Rage count. * * Number of Rage runes. */ unsigned short rage; /** * Focus count. * * Number of Focus runes. */ unsigned short focus; /** * Endure count. * * Number of Endure runes. */ unsigned short endure; /** * Fatal count. * * Number of Fatal runes. */ unsigned short fatal; /** * Despair count. * * Number of Despair runes. */ unsigned short despair; /** * Vampire count. * * Number of Vampire runes. */ unsigned short vampire; /** * Violent count. * * Number of Violent runes. */ unsigned short violent; /** * Nemesis count. * * Number of Nemesis runes. */ unsigned short nemesis; /** * Will count. * * Number of Will runes. */ unsigned short will; /** * Shield count. * * Number of Shield runes. */ unsigned short shield; /** * Revenge count. * * Number of Revenge runes. */ unsigned short revenge; /** * Destroy count. * * Number of Destroy runes. */ unsigned short destroy; /** * Fight count. * * Number of Fight runes. */ unsigned short fight; /** * Determination count. * * Number of Determination runes. */ unsigned short determination; /** * Enhance count. * * Number of Enhance runes. */ unsigned short enhance; /** * Accuracy count. * * Number of Accuracy runes. */ unsigned short accuracy; /** * Tolerance count. * * Number of Tolerance runes. */ unsigned short tolerance; } Rune_Set_Count; /** * Names for run stats. * * Indexed by Com2Us ID. Watch out for indexes 0 and 7, they are undefined in * the game. */ extern const char STAT_NAMES[DIFFERENT_STATS][9]; /** * Names for rune sets. * * Indexed by Com2Us ID.Watch out for indexes 0, 9 and 12, they are undefined in * the game. */ extern const char SET_NAMES[DIFFERENT_SETS][9]; /** * Names for rune qualities. * * Indexed by Com2Us ID. 1-5 are qualities for normal runes, 11-15 for ancient * runes. All the others are not defined in the game, */ extern const char QUALITY_NAMES[DIFFERENT_QUALITIES][9]; /** * Names for rune stats, in a printable format. * * They hold a 4 digit stat, padded to the right, with a percent sign on the * right for the stats that are percentual. All padded to the right with a * single space, for a total length of 10 characters. * * Indexed by Com2Us ID. Watch out for indexes 0 and 7, they are undefined in * the game. */ extern const char STAT_NAMES_PRINTABLE[DIFFERENT_STATS][12]; /** * Names for rune sets. * * Thy don't indicate if it's for a flat or a percentile stat. * * Indexed by Com2Us ID.Watch out for indexes 0, 9 and 12, they are undefined in * the game. */ extern const char STAT_NAMES_UNSIGNED[DIFFERENT_STATS][4]; /** * Max roll values for each stat. * * Used for efficiency calculations. Indexed by * - Stat id (indexes 0 and 7 undefined in game). * - Rune stars (1-6, dont use index 0). * * @todo For ancient runes, the initial rolls are higher. */ extern const int STAT_ROLL_MAX[DIFFERENT_STATS][RUNE_MAX_STARS + 1]; /** * Global database connection. * * Used across the app. Opened in {@link db_open}. */ extern sqlite3 *db; /** * Path to the database. * * When possible, use be an absolute path. */ extern char db_location[DB_PATH_LEN]; /** * Calculates effective HP. * * EHP is a complex stat, depending on HP and DEF. In short, the formula is * ((( def * 3.5) + 1140) * hp) / 1000 . * * @param[in] hp HP stat. * @param[in] def DEF stat. * @return Calculated EHP. */ extern unsigned int calculate_ehp(unsigned int hp, unsigned short def); /** * Calculates damage. * * DMG is a complex stat, depending on ATK, CRR and CRD. In short, the formula * is * (atk * ((100 - crr) / 100)) + (atk * (crr / 100) * ((100 + crd) / 100)) . * * @param[in] atk ATK stat. * @param[in] crr CRR stat. * @param[in] crd CRD stat. * @return Calculated DMG. */ extern unsigned short calculate_dmg( unsigned short atk, unsigned short crr, unsigned short crd ); /** * Starts the program. * * Reads command line parameters and runs the appropiate command. * * @param argc Number of arguments passed to the program. * @param argv Arguments passed to the program. * @return SUCCESS on success, other on error. Most errors are listed in * ../error/error.h */ int main(int argc, char *argv[]);