diff options
author | Dastgir <dastgirp@gmail.com> | 2018-06-05 12:10:05 +0530 |
---|---|---|
committer | Asheraf <acheraf1998@gmail.com> | 2018-06-25 21:21:27 +0100 |
commit | 9a95d3c61f8195c326ed430323074ef8ec23273c (patch) | |
tree | 5a8c81a39bfb437d4d6d18bca44881617d73cda1 /src/map | |
parent | 7c9860b275ee1c1d39bad2ca2551da82bd525267 (diff) | |
download | hercules-9a95d3c61f8195c326ed430323074ef8ec23273c.tar.gz hercules-9a95d3c61f8195c326ed430323074ef8ec23273c.tar.bz2 hercules-9a95d3c61f8195c326ed430323074ef8ec23273c.tar.xz hercules-9a95d3c61f8195c326ed430323074ef8ec23273c.zip |
Implemented Pet Autofeeding
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/battle.c | 1 | ||||
-rw-r--r-- | src/map/battle.h | 1 | ||||
-rw-r--r-- | src/map/clif.c | 30 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/pet.c | 10 | ||||
-rw-r--r-- | src/map/pet.h | 1 |
6 files changed, 36 insertions, 9 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index 6a961afeb..4d320704a 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -7319,6 +7319,7 @@ static const struct battle_data { { "features/rodex", &battle_config.feature_rodex, 1, 0, 1, }, { "features/rodex_use_accountmail", &battle_config.feature_rodex_use_accountmail, 0, 0, 1, }, { "features/enable_homun_autofeed", &battle_config.feature_enable_homun_autofeed, 1, 0, 1, }, + { "features/enable_pet_autofeed", &battle_config.feature_enable_pet_autofeed, 1, 0, 1, }, { "storage_use_item", &battle_config.storage_use_item, 0, 0, 1, }, { "features/enable_attendance_system", &battle_config.feature_enable_attendance_system,1, 0, 1, }, { "features/feature_attendance_endtime",&battle_config.feature_attendance_endtime, 1, 0, 99999999, }, diff --git a/src/map/battle.h b/src/map/battle.h index c325daf0d..f4176f142 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -563,6 +563,7 @@ struct Battle_Config { int feature_rodex_use_accountmail; int feature_enable_homun_autofeed; + int feature_enable_pet_autofeed; int storage_use_item; diff --git a/src/map/clif.c b/src/map/clif.c index aeaf03e43..86b159288 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9093,7 +9093,7 @@ void clif_feel_hate_reset(struct map_session_data *sd) /// value: /// 0 = disabled /// 1 = enabled -void clif_zc_config(struct map_session_data* sd, int type, int flag) +void clif_zc_config(struct map_session_data* sd, enum CZ_CONFIG type, int flag) { int fd; nullpo_retv(sd); @@ -16154,24 +16154,38 @@ void clif_parse_cz_config(int fd, struct map_session_data *sd) __attribute__((no /// 02d8 <type>.L <value>.L /// type: /// 0 = open equip window +/// 2 = pet autofeeding /// 3 = homunculus autofeeding /// value: /// 0 = disabled /// 1 = enabled void clif_parse_cz_config(int fd, struct map_session_data *sd) { - int type = RFIFOL(fd, 2); + enum CZ_CONFIG type = RFIFOL(fd, 2); int flag = RFIFOL(fd, 6); - if (type == CZ_CONFIG_OPEN_EQUIPMENT_WINDOW) { + switch (type) { + case CZ_CONFIG_OPEN_EQUIPMENT_WINDOW: sd->status.show_equip = flag; - } else if (type == CZ_CONFIG_HOMUNCULUS_AUTOFEEDING) { - struct homun_data *hd; - hd = sd->hd; + break; + case CZ_CONFIG_PET_AUTOFEEDING: { + struct pet_data *pd = sd->pd; + nullpo_retv(pd); + if (pd->petDB->autofeed == 0) { + clif->message(fd, "Autofeed is disabled for this pet."); + return; + } + pd->pet.autofeed = flag; + break; + } + case CZ_CONFIG_HOMUNCULUS_AUTOFEEDING: { + struct homun_data *hd = sd->hd; nullpo_retv(hd); hd->homunculus.autofeed = flag; - } else { - ShowWarning("clif_parse_cz_config: Unsupported type has been received (%d).", type); + break; + } + default: + ShowWarning("clif_parse_cz_config: Unsupported type has been received (%u).\n", type); return; } clif->zc_config(sd, type, flag); diff --git a/src/map/clif.h b/src/map/clif.h index 4b625023f..a8a9ddf70 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -834,7 +834,7 @@ struct clif_interface { void (*mission_info) (struct map_session_data *sd, int mob_id, unsigned char progress); void (*feel_hate_reset) (struct map_session_data *sd); void (*partytickack) (struct map_session_data* sd, bool flag); - void (*zc_config) (struct map_session_data *sd, int type, int flag); + void (*zc_config) (struct map_session_data *sd, enum CZ_CONFIG type, int flag); void (*viewequip_ack) (struct map_session_data* sd, struct map_session_data* tsd); void (*equpcheckbox) (struct map_session_data* sd); void (*displayexp) (struct map_session_data *sd, uint64 exp, char type, bool is_quest); diff --git a/src/map/pet.c b/src/map/pet.c index 4bac79dc8..4e3503b05 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -233,6 +233,13 @@ int pet_hungry(int tid, int64 tick, int id, intptr_t data) { return 1; //You lost the pet already, the rest is irrelevant. pd->pet.hungry--; + /* Pet Autofeed */ + if (battle_config.feature_enable_homun_autofeed != 0) { + if (pd->petDB->autofeed == 1 && pd->pet.autofeed == 1 && pd->pet.hungry <= 25) { + pet->food(sd, pd); + } + } + if( pd->pet.hungry < 0 ) { pet_stop_attack(pd); @@ -1359,6 +1366,9 @@ int pet_read_db_sub(struct config_setting_t *it, int n, const char *source) if (libconfig->setting_lookup_int(it, "ChangeTargetRate", &i32)) pet->db[n].change_target_rate = i32; + if ((t = libconfig->setting_get_member(it, "AutoFeed")) && (i32 = libconfig->setting_get_bool(t))) + pet->db[n].autofeed = i32; + if (libconfig->setting_lookup_string(it, "PetScript", &str)) pet->db[n].pet_script = *str ? script->parse(str, source, -pet->db[n].class_, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL; diff --git a/src/map/pet.h b/src/map/pet.h index d341be97c..434b07015 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -50,6 +50,7 @@ struct s_pet_db { int attack_rate; int defence_attack_rate; int change_target_rate; + int autofeed; struct script_code *equip_script; struct script_code *pet_script; }; |