summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-08-22 15:14:07 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-08-22 15:14:07 +0000
commitdb0184a272d0fbb1b09d4eba6527181b85890357 (patch)
tree663efd0c6f42df68ddce6b7639f9153ea60db78d
parent4c930b82911ecd24dfef47c7021fe7f6cfa1a3b1 (diff)
downloadhercules-db0184a272d0fbb1b09d4eba6527181b85890357.tar.gz
hercules-db0184a272d0fbb1b09d4eba6527181b85890357.tar.bz2
hercules-db0184a272d0fbb1b09d4eba6527181b85890357.tar.xz
hercules-db0184a272d0fbb1b09d4eba6527181b85890357.zip
- Mercenary Database Reading.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13109 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--db/mercenary_skill_db.txt30
-rw-r--r--src/map/mercenary.c165
-rw-r--r--src/map/mercenary.h19
3 files changed, 184 insertions, 30 deletions
diff --git a/db/mercenary_skill_db.txt b/db/mercenary_skill_db.txt
index 509047651..f72c94a71 100644
--- a/db/mercenary_skill_db.txt
+++ b/db/mercenary_skill_db.txt
@@ -1,143 +1,113 @@
//MercenryID,SkillID,SkillLevel
-
// Archer Mercenaries Level 1-10.
// MER_ARCHER01
6017,8207,2 //MA_DOUBLE
6017,8233,1 //MER_AUTOBERSERK
-
// MER_ARCHER02
6018,8208,2 //MA_SHOWER
6018,8224,1 //MER_SIGHT
-
// MER_ARCHER03
6019,8214,1 //MA_CHARGEARROW
6019,8223,1 //MER_QUICKEN
-
// MER_ARCHER04
6020,8237,1 //MER_ESTIMATION
6020,8222,1 //MER_MAGNIFICAT
6020,8227,1 //MER_TENDER
-
// MER_ARCHER05
6021,8207,5 //MA_DOUBLE
6021,8232,1 //MER_PROVOKE
6021,8213,1 //MA_REMOVETRAP
-
// MER_ARCHER06
6022,8207,7 //MA_DOUBLE
6022,8209,3 //MA_LANDMINE
6022,8234,1 //MER_DECAGI
-
// MER_ARCHER07
6023,8208,10 //MA_SHOWER
6023,8230,1 //MER_MENTALCURE
6023,8212,2 //MA_FREEZINGTRAP
-
// MER_ARCHER08
6024,8223,2 //MER_QUICKEN
6024,8232,3 //MER_PROVOKE
6024,8211,3 //MA_SANDMAN
-
// MER_ARCHER09
6025,8207,10 //MA_DOUBLE
6025,8214,1 //MA_CHARGEARROW
6025,8210,5 //MA_LANDMINE
-
// MER_ARCHER10
6026,8214,1 //MA_CHARGEARROW
6026,8215,5 //MA_SHARPSHOOTING
6026,8223,5 //MER_QUICKEN
6026,8233,1 //MER_AUTOBERSERK
-
// Lancer Mercenaries Level 1-10.
// MER_LANCER01
6027,8216,1 //ML_PIERCE
6027,8226,1 //MER_REGAIN
-
// MER_LANCER02
6028,8217,2 //ML_BRANDISH
6028,8236,1 //MER_LEXDIVINA
-
// MER_LANCER03
6029,8216,2 //ML_PIERCE
6029,8221,1 //ML_DEVOTION
6029,8229,1 //MER_RECUPERATE
-
// MER_LANCER04
6030,8219,1 //ML_DEFENDER
6030,8225,4 //MER_CRASH
-
// MER_LANCER05
6031,8216,5 //ML_PIERCE
6031,8220,3 //ML_AUTOGUARD
-
// MER_LANCER06
6032,8223,2 //MER_QUICKEN
6032,8217,5 //ML_BRANDISH
-
// MER_LANCER07
6033,8221,1 //ML_DEVOTION
6033,8233,1 //MER_AUTOBERSERK
-
// MER_LANCER08
6034,8235,1 //MER_SCAPEGOAT
6034,8216,10 //ML_PIERCE
6034,8232,5 //MER_PROVOKE
-
// MER_LANCER09
6035,8217,10 //ML_BRANDISH
6035,8220,7 //ML_AUTOGUARD
6035,8219,3 //ML_DEFENDER
-
// MER_LANCER10
6036,8223,5 //MER_QUICKEN
6036,8220,10 //ML_AUTOGUARD
6036,8221,3 //ML_DEVOTION
6036,8218,5 //ML_SPIRALPIERCE
-
// Swordman Mercenaries Level 1-10.
// MER_SWORDMAN01
6037,8201,1 //MS_BASH
6037,8234,1 //MER_DECAGI
-
// MER_SWORDMAN02
6038,8232,5 //MER_PROVOKE
6038,8202,3 //MS_MAGNUM
-
// MER_SWORDMAN03
6039,8223,1 //MER_QUICKEN
6039,8228,1 //MER_BENEDICTION
-
// MER_SWORDMAN04
6040,8225,1 //MER_CRASH
6040,8202,5 //MS_MAGNUM
-
// MER_SWORDMAN05
6041,8201,5 //MS_BASH
6041,8225,4 //MER_CRASH
6041,8228,1 //MER_BENEDICTION
-
// MER_SWORDMAN06
6042,8223,5 //MER_QUICKEN
6042,8237,1 //MER_ESTIMATION
6042,8234,3 //MER_DECAGI
-
// MER_SWORDMAN07
6043,8201,10 //MS_BASH
6043,8233,1 //MER_AUTOBERSERK
6043,8235,1 //MER_SCAPEGOAT
-
// MER_SWORDMAN08
6044,8223,10 //MER_QUICKEN
6044,8203,5 //MS_BOWLINGABASH
6044,8231,1 //MER_COMPRESS
6044,8204,4 //MS_PARRYING
-
// MER_SWORDMAN09
6045,8203,8 //MS_BOWLINGABASH
6045,8225,3 //MER_CRASH
6045,8205,5 //MS_REFLECTSHIELD
-
// MER_SWORDMAN10
6046,8223,10 //MER_QUICKEN
6046,8203,10 //MS_BOWLINGABASH
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index c56c36cdb..da58da7ee 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -41,6 +41,8 @@
//Better equiprobability than rand()% [orn]
#define rand(a, b) (a+(int) ((float)(b-a+1)*rand()/(RAND_MAX+1.0)))
+struct s_mercenary_db mercenary_db[MAX_MERCENARY_CLASS]; // Mercenary Database
+
struct s_homunculus_db homunculus_db[MAX_HOMUNCULUS_CLASS]; //[orn]
struct skill_tree_entry hskill_tree[MAX_HOMUNCULUS_CLASS][MAX_SKILL_TREE];
@@ -879,6 +881,165 @@ int merc_hom_shuffle(struct homun_data *hd)
return 1;
}
+int read_mercenarydb(void)
+{
+ FILE *fp;
+ char line[1024], *p;
+ char *str[26];
+ int i, j = 0, k = 0, ele;
+ struct s_mercenary_db *db;
+ struct status_data *status;
+
+ sprintf(line, "%s/%s", db_path, "mercenary_db.txt");
+ memset(mercenary_db,0,sizeof(mercenary_db));
+
+ fp = fopen(line, "r");
+ if( !fp )
+ {
+ ShowError("read_mercenarydb : can't read mercenary_db.txt\n");
+ return -1;
+ }
+
+ while( fgets(line, sizeof(line), fp) && j < MAX_MERCENARY_CLASS )
+ {
+ k++;
+ if( line[0] == '/' && line[1] == '/' )
+ continue;
+
+ i = 0;
+ p = strtok(line, ",");
+ while( p != NULL && i < 26 )
+ {
+ str[i++] = p;
+ p = strtok(NULL, ",");
+ }
+ if( i < 26 )
+ {
+ ShowError("read_mercenarydb : Incorrect number of columns at mercenary_db.txt line %d.\n", k);
+ continue;
+ }
+
+ db = &mercenary_db[j];
+ db->class_ = atoi(str[0]);
+ strncpy(db->sprite, str[1], NAME_LENGTH);
+ strncpy(db->name, str[2], NAME_LENGTH);
+ db->lv = atoi(str[3]);
+
+ status = &db->status;
+ status->max_hp = atoi(str[4]);
+ status->max_sp = atoi(str[5]);
+ status->rhw.range = atoi(str[6]);
+ status->rhw.atk = atoi(str[7]);
+ status->rhw.atk2 = atoi(str[8]);
+ status->def = atoi(str[9]);
+ status->mdef = atoi(str[10]);
+ status->str = atoi(str[11]);
+ status->agi = atoi(str[12]);
+ status->vit = atoi(str[13]);
+ status->int_ = atoi(str[14]);
+ status->dex = atoi(str[15]);
+ status->luk = atoi(str[16]);
+ db->range2 = atoi(str[17]);
+ db->range3 = atoi(str[18]);
+ status->size = atoi(str[19]);
+ status->race = atoi(str[20]);
+
+ ele = atoi(str[21]);
+ status->def_ele = ele%10;
+ status->ele_lv = ele/20;
+ if( status->def_ele >= ELE_MAX )
+ {
+ ShowWarning("Mercenary %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1);
+ status->def_ele = ELE_NEUTRAL;
+ }
+ if( status->ele_lv < 1 || status->ele_lv > 4 )
+ {
+ ShowWarning("Mercenary %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv);
+ status->ele_lv = 1;
+ }
+
+ status->speed = atoi(str[22]);
+ status->adelay = atoi(str[23]);
+ status->amotion = atoi(str[24]);
+ status->dmotion = atoi(str[25]);
+
+ j++;
+ }
+
+ fclose(fp);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' mercenaries in '"CL_WHITE"db/mercenary_db.txt"CL_RESET"'.\n",j);
+
+ return 0;
+}
+
+int read_mercenary_skilldb(void)
+{
+ FILE *fp;
+ char line[1024], *p;
+ char *str[3];
+ struct s_mercenary_db *db;
+ int i, j = 0, k = 0, class_;
+ int skillid, skilllv;
+
+ sprintf(line, "%s/%s", db_path, "mercenary_skill_db.txt");
+ fp = fopen(line, "r");
+ if( !fp )
+ {
+ ShowError("read_mercenary_skilldb : can't read mercenary_skill_db.txt\n");
+ return -1;
+ }
+
+ while( fgets(line, sizeof(line), fp) )
+ {
+ k++;
+ if( line[0] == '/' && line[1] == '/' )
+ continue;
+
+ i = 0;
+ p = strtok(line, ",");
+ while( p != NULL && i < 3 )
+ {
+ str[i++] = p;
+ p = strtok(NULL, ",");
+ }
+ if( i < 3 )
+ {
+ ShowError("read_mercenary_skilldb : Incorrect number of columns at mercenary_skill_db.txt line %d.\n", k);
+ continue;
+ }
+
+ class_ = atoi(str[0]);
+ ARR_FIND(0, MAX_MERCENARY_CLASS, i, class_ == mercenary_db[i].class_);
+ if( i == MAX_MERCENARY_CLASS )
+ {
+ ShowError("read_mercenary_skilldb : Class not found in mercenary_db for skill entry, line %d.\n", k);
+ continue;
+ }
+
+ db = &mercenary_db[i];
+ skillid = atoi(str[1]);
+ skilllv = atoi(str[2]);
+
+ ARR_FIND(0, MAX_MERCENARY_SKILL, i, db->skill[i].id == 0 || db->skill[i].id == skillid);
+ if( i == MAX_MERCENARY_SKILL )
+ {
+ ShowError("read_mercenary_skilldb : No more free skill slots for Class %d, line %d.\n", class_, k);
+ continue;
+ }
+ if( db->skill[i].id == skillid )
+ ShowError("read_mercenary_skilldb : Duplicate Skill for Class %d, line %d. Overwriting...\n", class_, k);
+
+ db->skill[i].id = skillid;
+ db->skill[i].lv = skilllv;
+ j++;
+ }
+
+ fclose(fp);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"db/mercenary_skill_db.txt"CL_RESET"'.\n",j);
+ return 0;
+}
+
+
int read_homunculusdb(void)
{
FILE *fp;
@@ -1155,6 +1316,10 @@ int do_init_merc(void)
read_homunculusdb();
read_homunculus_expdb();
read_homunculus_skilldb();
+
+ read_mercenarydb();
+ read_mercenary_skilldb();
+
// Add homunc timer function to timer func list [Toms]
add_timer_func_list(merc_hom_hungry, "merc_hom_hungry");
diff --git a/src/map/mercenary.h b/src/map/mercenary.h
index 88692b4d1..726fae4e4 100644
--- a/src/map/mercenary.h
+++ b/src/map/mercenary.h
@@ -7,6 +7,25 @@
#include "status.h" // struct status_data, struct status_change
#include "unit.h" // struct unit_data
+// Mercenary DB Structures
+// ===================================
+
+struct s_mercenary_db {
+ int class_;
+ char sprite[NAME_LENGTH], name[NAME_LENGTH];
+ unsigned short lv;
+ short range2, range3;
+ struct status_data status;
+ struct {
+ unsigned short id, lv;
+ } skill[MAX_MERCENARY_SKILL];
+};
+
+extern struct s_mercenary_db mercenary_db[MAX_MERCENARY_CLASS];
+
+// Homunculus DB Structures
+// ===================================
+
struct h_stats {
unsigned int HP, SP;
unsigned short str, agi, vit, int_, dex, luk;