summaryrefslogtreecommitdiff
path: root/src/map/homunculus.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/homunculus.c')
-rw-r--r--src/map/homunculus.c149
1 files changed, 98 insertions, 51 deletions
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index a708c0a28..6df272243 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -37,6 +37,7 @@
#include "map/party.h"
#include "map/pc.h"
#include "map/pet.h"
+#include "map/quest.h"
#include "map/script.h"
#include "map/skill.h"
#include "map/status.h"
@@ -58,19 +59,21 @@
#include <stdlib.h>
#include <string.h>
-struct homunculus_interface homunculus_s;
-struct homun_dbs homundbs;
+static struct homunculus_interface homunculus_s;
+static struct homun_dbs homundbs;
struct homunculus_interface *homun;
//Returns the viewdata for homunculus
-struct view_data* homunculus_get_viewdata(int class_) {
+static struct view_data *homunculus_get_viewdata(int class_)
+{
Assert_retr(NULL, homdb_checkid(class_));
return &homun->dbs->viewdb[class_-HM_CLASS_BASE];
}
-enum homun_type homunculus_class2type(int class_) {
+static enum homun_type homunculus_class2type(int class_)
+{
switch(class_) {
// Normal Homunculus
case HOMID_LIF:
@@ -104,7 +107,8 @@ enum homun_type homunculus_class2type(int class_) {
}
}
-void homunculus_addspiritball(struct homun_data *hd, int max) {
+static void homunculus_addspiritball(struct homun_data *hd, int max)
+{
nullpo_retv(hd);
if (max > MAX_SKILL_LEVEL)
@@ -121,7 +125,8 @@ void homunculus_addspiritball(struct homun_data *hd, int max) {
clif->spiritball(&hd->bl);
}
-void homunculus_delspiritball(struct homun_data *hd, int count, int type) {
+static void homunculus_delspiritball(struct homun_data *hd, int count, int type)
+{
nullpo_retv(hd);
if (hd->homunculus.spiritball <= 0) {
@@ -140,11 +145,13 @@ void homunculus_delspiritball(struct homun_data *hd, int count, int type) {
clif->spiritball(&hd->bl);
}
-void homunculus_damaged(struct homun_data *hd) {
+static void homunculus_damaged(struct homun_data *hd)
+{
clif->hominfo(hd->master,hd,0);
}
-int homunculus_dead(struct homun_data *hd) {
+static int homunculus_dead(struct homun_data *hd)
+{
//There's no intimacy penalties on death (from Tharis)
struct map_session_data *sd;
@@ -165,7 +172,8 @@ int homunculus_dead(struct homun_data *hd) {
}
//Vaporize a character's homun. If flag, HP needs to be 80% or above.
-int homunculus_vaporize(struct map_session_data *sd, enum homun_state flag) {
+static int homunculus_vaporize(struct map_session_data *sd, enum homun_state flag)
+{
struct homun_data *hd;
nullpo_ret(sd);
@@ -193,7 +201,8 @@ int homunculus_vaporize(struct map_session_data *sd, enum homun_state flag) {
//delete a homunculus, completely "killing it".
//Emote is the emotion the master should use, send negative to disable.
-int homunculus_delete(struct homun_data *hd, int emote) {
+static int homunculus_delete(struct homun_data *hd, int emote)
+{
struct map_session_data *sd;
nullpo_ret(hd);
sd = hd->master;
@@ -212,7 +221,8 @@ int homunculus_delete(struct homun_data *hd, int emote) {
return unit->remove_map(&hd->bl,CLR_OUTSIGHT, ALC_MARK);
}
-int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) {
+static int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve)
+{
int i, id = 0;
int j, f = 1;
int c = 0;
@@ -269,7 +279,8 @@ int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) {
return 0;
}
-int homunculus_checkskill(struct homun_data *hd,uint16 skill_id) {
+static int homunculus_checkskill(struct homun_data *hd, uint16 skill_id)
+{
int i = skill_id - HM_SKILLBASE;
if(!hd)
return 0;
@@ -281,7 +292,8 @@ int homunculus_checkskill(struct homun_data *hd,uint16 skill_id) {
return 0;
}
-int homunculus_skill_tree_get_max(int id, int b_class) {
+static int homunculus_skill_tree_get_max(int id, int b_class)
+{
int i, skill_id;
b_class -= HM_CLASS_BASE;
Assert_ret(b_class >= 0 && b_class < MAX_HOMUNCULUS_CLASS);
@@ -291,7 +303,8 @@ int homunculus_skill_tree_get_max(int id, int b_class) {
return skill->get_max(id);
}
-void homunculus_skillup(struct homun_data *hd,uint16 skill_id) {
+static void homunculus_skillup(struct homun_data *hd, uint16 skill_id)
+{
int i = 0 ;
nullpo_retv(hd);
@@ -317,7 +330,8 @@ void homunculus_skillup(struct homun_data *hd,uint16 skill_id) {
}
}
-bool homunculus_levelup(struct homun_data *hd) {
+static bool homunculus_levelup(struct homun_data *hd)
+{
struct s_homunculus *hom;
struct h_stats *min, *max;
int growth_str, growth_agi, growth_vit, growth_int, growth_dex, growth_luk ;
@@ -393,10 +407,12 @@ bool homunculus_levelup(struct homun_data *hd) {
growth_int/10.0, growth_dex/10.0, growth_luk/10.0);
clif_disp_onlyself(hd->master, output);
}
+ quest->questinfo_refresh(hd->master);
return true;
}
-int homunculus_change_class(struct homun_data *hd, short class_) {
+static int homunculus_change_class(struct homun_data *hd, short class_)
+{
int i = homun->db_search(class_,HOMUNCULUS_CLASS);
nullpo_retr(0, hd);
if (i == INDEX_NOT_FOUND)
@@ -405,10 +421,12 @@ int homunculus_change_class(struct homun_data *hd, short class_) {
hd->homunculus.class_ = class_;
status->set_viewdata(&hd->bl, class_);
homun->calc_skilltree(hd, 1);
+ quest->questinfo_refresh(hd->master);
return 1;
}
-bool homunculus_evolve(struct homun_data *hd) {
+static bool homunculus_evolve(struct homun_data *hd)
+{
struct s_homunculus *hom;
struct h_stats *max, *min;
struct map_session_data *sd;
@@ -456,11 +474,12 @@ bool homunculus_evolve(struct homun_data *hd) {
if (!(battle_config.hom_setting&0x2))
skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately
-
+ quest->questinfo_refresh(sd);
return true;
}
-bool homunculus_mutate(struct homun_data *hd, int homun_id) {
+static bool homunculus_mutate(struct homun_data *hd, int homun_id)
+{
struct s_homunculus *hom;
struct map_session_data *sd;
int prev_class = 0;
@@ -506,7 +525,8 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) {
return true;
}
-int homunculus_gainexp(struct homun_data *hd,unsigned int exp) {
+static int homunculus_gainexp(struct homun_data *hd, unsigned int exp)
+{
enum homun_type htype;
nullpo_ret(hd);
@@ -550,7 +570,8 @@ int homunculus_gainexp(struct homun_data *hd,unsigned int exp) {
}
// Return the new value
-unsigned int homunculus_add_intimacy(struct homun_data *hd, unsigned int value) {
+static unsigned int homunculus_add_intimacy(struct homun_data *hd, unsigned int value)
+{
nullpo_ret(hd);
if (battle_config.homunculus_friendly_rate != 100)
value = (value * battle_config.homunculus_friendly_rate) / 100;
@@ -563,7 +584,8 @@ unsigned int homunculus_add_intimacy(struct homun_data *hd, unsigned int value)
}
// Return 0 if decrease fails or intimacy became 0 else the new value
-unsigned int homunculus_consume_intimacy(struct homun_data *hd, unsigned int value) {
+static unsigned int homunculus_consume_intimacy(struct homun_data *hd, unsigned int value)
+{
nullpo_ret(hd);
if (hd->homunculus.intimacy >= value)
hd->homunculus.intimacy -= value;
@@ -573,12 +595,14 @@ unsigned int homunculus_consume_intimacy(struct homun_data *hd, unsigned int val
return hd->homunculus.intimacy;
}
-void homunculus_healed (struct homun_data *hd) {
+static void homunculus_healed(struct homun_data *hd)
+{
nullpo_retv(hd);
clif->hominfo(hd->master,hd,0);
}
-void homunculus_save(struct homun_data *hd) {
+static void homunculus_save(struct homun_data *hd)
+{
// copy data that must be saved in homunculus struct ( hp / sp )
struct map_session_data *sd = NULL;
//Do not check for max_hp/max_sp caps as current could be higher to max due
@@ -592,7 +616,8 @@ void homunculus_save(struct homun_data *hd) {
intif->homunculus_requestsave(sd->status.account_id, &hd->homunculus);
}
-unsigned char homunculus_menu(struct map_session_data *sd,unsigned char menu_num) {
+static unsigned char homunculus_menu(struct map_session_data *sd, unsigned char menu_num)
+{
nullpo_ret(sd);
if (sd->hd == NULL)
return 1;
@@ -613,7 +638,8 @@ unsigned char homunculus_menu(struct map_session_data *sd,unsigned char menu_num
return 0;
}
-bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd) {
+static bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd)
+{
int i, foodID, emotion;
nullpo_retr(false, hd);
@@ -661,7 +687,8 @@ bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd) {
return true;
}
-int homunculus_hunger_timer(int tid, int64 tick, int id, intptr_t data) {
+static int homunculus_hunger_timer(int tid, int64 tick, int id, intptr_t data)
+{
struct map_session_data *sd;
struct homun_data *hd;
@@ -702,7 +729,8 @@ int homunculus_hunger_timer(int tid, int64 tick, int id, intptr_t data) {
return 0;
}
-void homunculus_hunger_timer_delete(struct homun_data *hd) {
+static void homunculus_hunger_timer_delete(struct homun_data *hd)
+{
nullpo_retv(hd);
if(hd->hungry_timer != INVALID_TIMER) {
timer->delete(hd->hungry_timer,homun->hunger_timer);
@@ -710,7 +738,7 @@ void homunculus_hunger_timer_delete(struct homun_data *hd) {
}
}
-int homunculus_change_name(struct map_session_data *sd, const char *name)
+static int homunculus_change_name(struct map_session_data *sd, const char *name)
{
int i;
struct homun_data *hd;
@@ -731,7 +759,7 @@ int homunculus_change_name(struct map_session_data *sd, const char *name)
return intif_rename_hom(sd, name);
}
-bool homunculus_change_name_ack(struct map_session_data *sd, const char *name, int flag)
+static bool homunculus_change_name_ack(struct map_session_data *sd, const char *name, int flag)
{
struct homun_data *hd;
char *newname = NULL;
@@ -757,7 +785,8 @@ bool homunculus_change_name_ack(struct map_session_data *sd, const char *name, i
return true;
}
-int homunculus_db_search(int key,int type) {
+static int homunculus_db_search(int key, int type)
+{
int i;
for(i=0;i<MAX_HOMUNCULUS_CLASS;i++) {
@@ -791,7 +820,7 @@ int homunculus_db_search(int key,int type) {
* @param hom The homunculus source data.
* @retval false in case of errors.
*/
-bool homunculus_create(struct map_session_data *sd, const struct s_homunculus *hom)
+static bool homunculus_create(struct map_session_data *sd, const struct s_homunculus *hom)
{
struct homun_data *hd;
int i = 0;
@@ -841,14 +870,16 @@ bool homunculus_create(struct map_session_data *sd, const struct s_homunculus *h
return true;
}
-void homunculus_init_timers(struct homun_data * hd) {
+static void homunculus_init_timers(struct homun_data *hd)
+{
nullpo_retv(hd);
if (hd->hungry_timer == INVALID_TIMER)
hd->hungry_timer = timer->add(timer->gettick()+hd->homunculusDB->hungryDelay,homun->hunger_timer,hd->master->bl.id,0);
hd->regen.state.block = 0; //Restore HP/SP block.
}
-bool homunculus_call(struct map_session_data *sd) {
+static bool homunculus_call(struct map_session_data *sd)
+{
struct homun_data *hd;
nullpo_retr(false, sd);
@@ -886,7 +917,7 @@ bool homunculus_call(struct map_session_data *sd) {
}
// Receive homunculus data from char server
-bool homunculus_recv_data(int account_id, const struct s_homunculus *sh, int flag)
+static bool homunculus_recv_data(int account_id, const struct s_homunculus *sh, int flag)
{
struct map_session_data *sd;
struct homun_data *hd;
@@ -945,7 +976,8 @@ bool homunculus_recv_data(int account_id, const struct s_homunculus *sh, int fla
}
// Ask homunculus creation to char server
-bool homunculus_creation_request(struct map_session_data *sd, int class_) {
+static bool homunculus_creation_request(struct map_session_data *sd, int class_)
+{
struct s_homunculus hom;
struct h_stats *base;
int i;
@@ -981,7 +1013,8 @@ bool homunculus_creation_request(struct map_session_data *sd, int class_) {
return true;
}
-bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short x, short y) {
+static bool homunculus_ressurect(struct map_session_data *sd, unsigned char per, short x, short y)
+{
struct homun_data* hd;
nullpo_retr(false,sd);
@@ -1014,7 +1047,8 @@ bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short
return true;
}
-void homunculus_revive(struct homun_data *hd, unsigned int hp, unsigned int sp) {
+static void homunculus_revive(struct homun_data *hd, unsigned int hp, unsigned int sp)
+{
struct map_session_data *sd;
nullpo_retv(hd);
@@ -1028,7 +1062,8 @@ void homunculus_revive(struct homun_data *hd, unsigned int hp, unsigned int sp)
clif->homskillinfoblock(sd);
}
//Resets a homunc stats back to zero (but doesn't touches hunger or intimacy)
-void homunculus_stat_reset(struct homun_data *hd) {
+static void homunculus_stat_reset(struct homun_data *hd)
+{
struct s_homunculus_db *db;
struct s_homunculus *hom;
struct h_stats *base;
@@ -1052,7 +1087,8 @@ void homunculus_stat_reset(struct homun_data *hd) {
hd->homunculus.skillpts = 0;
}
-bool homunculus_shuffle(struct homun_data *hd) {
+static bool homunculus_shuffle(struct homun_data *hd)
+{
struct map_session_data *sd;
int lv, skillpts;
unsigned int exp;
@@ -1101,7 +1137,8 @@ bool homunculus_shuffle(struct homun_data *hd) {
return true;
}
-bool homunculus_read_db_sub(char* str[], int columns, int current) {
+static bool homunculus_read_db_sub(char *str[], int columns, int current)
+{
int classid;
struct s_homunculus_db *db;
@@ -1212,7 +1249,8 @@ bool homunculus_read_db_sub(char* str[], int columns, int current) {
return true;
}
-void homunculus_read_db(void) {
+static void homunculus_read_db(void)
+{
int i;
const char *filename[]={DBPATH"homunculus_db.txt","homunculus_db2.txt"};
memset(homun->dbs->db, 0, sizeof(homun->dbs->db));
@@ -1232,7 +1270,8 @@ void homunculus_read_db(void) {
}
// <hom class>,<skill id>,<max level>[,<job level>],<req id1>,<req lv1>,<req id2>,<req lv2>,<req id3>,<req lv3>,<req id4>,<req lv4>,<req id5>,<req lv5>,<intimacy lv req>
-bool homunculus_read_skill_db_sub(char* split[], int columns, int current) {
+static bool homunculus_read_skill_db_sub(char *split[], int columns, int current)
+{
int k, classid;
int j;
int minJobLevelPresent = 0;
@@ -1272,7 +1311,8 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) {
return true;
}
-int8 homunculus_get_intimacy_grade(struct homun_data *hd) {
+static int8 homunculus_get_intimacy_grade(struct homun_data *hd)
+{
unsigned int val;
nullpo_ret(hd);
val = hd->homunculus.intimacy / 100;
@@ -1292,12 +1332,14 @@ int8 homunculus_get_intimacy_grade(struct homun_data *hd) {
return 0;
}
-void homunculus_skill_db_read(void) {
+static void homunculus_skill_db_read(void)
+{
memset(homun->dbs->skill_tree, 0, sizeof(homun->dbs->skill_tree));
sv->readdb(map->db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub);
}
-void homunculus_exp_db_read(void) {
+static void homunculus_exp_db_read(void)
+{
char line[1024];
int i, j=0;
char *filename[]={
@@ -1331,16 +1373,19 @@ void homunculus_exp_db_read(void) {
}
}
-void homunculus_reload(void) {
+static void homunculus_reload(void)
+{
homun->read_db();
homun->exp_db_read();
}
-void homunculus_skill_reload(void) {
+static void homunculus_skill_reload(void)
+{
homun->skill_db_read();
}
-void do_init_homunculus(bool minimal) {
+static void do_init_homunculus(bool minimal)
+{
int class_;
if (minimal)
@@ -1358,11 +1403,13 @@ void do_init_homunculus(bool minimal) {
homun->dbs->viewdb[class_].class = HM_CLASS_BASE + class_;
}
-void do_final_homunculus(void) {
+static void do_final_homunculus(void)
+{
}
-void homunculus_defaults(void) {
+void homunculus_defaults(void)
+{
homun = &homunculus_s;
homun->dbs = &homundbs;