/********************************************************************* * date : 2007.11.16 * file : ani.cpp * author : mhh * description : */ #define _ani_cpp_ #include "stdafx.h" #include "char.h" #include "item.h" #include "ani.h" #include "dev_log.h" const char* FN_race_name(int race) { #define FN_NAME(race) case race: return #race switch (race) { FN_NAME(MAIN_RACE_WARRIOR_M); FN_NAME(MAIN_RACE_ASSASSIN_W); FN_NAME(MAIN_RACE_SURA_M); FN_NAME(MAIN_RACE_SHAMAN_W); FN_NAME(MAIN_RACE_WARRIOR_W); FN_NAME(MAIN_RACE_ASSASSIN_M); FN_NAME(MAIN_RACE_SURA_W); FN_NAME(MAIN_RACE_SHAMAN_M); FN_NAME(MAIN_RACE_MAX_NUM); } return "UNKNOWN"; #undef FN_NAME } const char* FN_weapon_type(int weapon) { #define FN_NAME(weapon) case weapon: return #weapon switch (weapon) { FN_NAME(WEAPON_SWORD); FN_NAME(WEAPON_DAGGER); FN_NAME(WEAPON_BOW); FN_NAME(WEAPON_TWO_HANDED); FN_NAME(WEAPON_BELL); FN_NAME(WEAPON_FAN); FN_NAME(WEAPON_ARROW); FN_NAME(WEAPON_MOUNT_SPEAR); FN_NAME(WEAPON_NUM_TYPES); } return "UNKNOWN"; #undef FN_NAME } class ANI { protected: // [Á¾Á·][ÀϹÝ0Å»°Í1][¹«±â][ÄÞº¸] DWORD m_speed[MAIN_RACE_MAX_NUM][2][WEAPON_NUM_TYPES][9]; public: ANI(); public: bool load(); bool load_one_race(int race, const char *dir_name); DWORD load_one_weapon(const char *dir_name, int weapon, BYTE combo, bool horse); DWORD attack_speed(int race, int weapon, BYTE combo = 0, bool horse = false); void print_attack_speed(); }; static class ANI s_ANI; DWORD FN_attack_speed_from_file(const char *file) { FILE * fp = fopen(file, "r"); if (NULL == fp) return 0; int speed = 1000; const char *key = "DirectInputTime"; const char *delim = " \t\r\n"; const char *field, *value; char buf[1024]; while (fgets(buf, 1024, fp)) { field = strtok(buf, delim); value = strtok(NULL, delim); if (field && value) { if (0 == strcasecmp(field, key)) { float f_speed = strtof(value, NULL); speed = (int) (f_speed * 1000.0); break; } } } fclose(fp); return speed; } ANI::ANI() { // set default value for (int race = 0; race < MAIN_RACE_MAX_NUM; ++race) { for (int weapon = 0; weapon < WEAPON_NUM_TYPES; ++weapon) { for (BYTE combo = 0; combo <= 8; ++combo) { m_speed[race][0][weapon][combo] = 1000; m_speed[race][1][weapon][combo] = 1000; } } } } bool ANI::load() { const char* dir_name[MAIN_RACE_MAX_NUM] = { "data/pc/warrior", // ¹«»ç(³²) "data/pc/assassin", // ÀÚ°´(¿©) "data/pc/sura", // ¼ö¶ó(³²) "data/pc/shaman", // ¹«´ç(¿©) "data/pc2/warrior", // ¹«»ç(¿©) "data/pc2/assassin", // ÀÚ°´(³²) "data/pc2/sura", // ¼ö¶ó(¿©) "data/pc2/shaman" // ¹«´ç(³²) }; for (int race = 0; race GetWear(WEAR_WEAPON); if (NULL == item) return speed; if (ITEM_WEAPON != item->GetType()) return speed; int race = ch->GetRaceNum(); int weapon = item->GetSubType(); /* dev_log(LOG_DEB0, "%s : (race,weapon) = (%s,%s) POINT_ATT_SPEED = %d", ch->GetName(), FN_race_name(race), FN_weapon_type(weapon), ch->GetPoint(POINT_ATT_SPEED)); */ /* ÅõÇÚµðµå ¼ÒµåÀÇ °æ¿ì »ï¿¬Âü°ø°Ý°ú ½Â¸¶½Ã */ /* ¿À·ù°¡ ¸¹¾Æ ÇÑ¼Õ°Ë ¼Óµµ·Î »ý°¢ÇÏÀÚ */ if (weapon == WEAPON_TWO_HANDED) weapon = WEAPON_SWORD; return s_ANI.attack_speed(race, weapon); } DWORD ani_combo_speed(LPCHARACTER ch, BYTE combo) { LPITEM item = ch->GetWear(WEAR_WEAPON); if (NULL == item || combo > 8) return 1000; return s_ANI.attack_speed(ch->GetRaceNum(), item->GetSubType(), combo, ch->IsRiding()); } void ani_print_attack_speed() { s_ANI.print_attack_speed(); } #if 0 int main(int argc, char **argv) { ani_init(); ani_print_attack_speed(); exit(0); } #endif