diff options
author | Haru <haru@dotalux.com> | 2017-12-08 17:38:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-08 17:38:21 +0100 |
commit | 85b71be7fd1134de6b45f9510006b84dc39975ac (patch) | |
tree | 274df4073757d0cbf04701af7c2ac4e7b3afc827 /src/map | |
parent | 52abec06442607fca319a8309d26674871b25b53 (diff) | |
parent | 952855644c1deaf2dc7d7880bcd14126e2d5f6bd (diff) | |
download | hercules-85b71be7fd1134de6b45f9510006b84dc39975ac.tar.gz hercules-85b71be7fd1134de6b45f9510006b84dc39975ac.tar.bz2 hercules-85b71be7fd1134de6b45f9510006b84dc39975ac.tar.xz hercules-85b71be7fd1134de6b45f9510006b84dc39975ac.zip |
Merge pull request #1898 from Asheraf/homunaf
implement homunculus autofeeding for 2017 clients
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/battle.c | 1 | ||||
-rw-r--r-- | src/map/battle.h | 2 | ||||
-rw-r--r-- | src/map/clif.c | 38 | ||||
-rw-r--r-- | src/map/clif.h | 14 | ||||
-rw-r--r-- | src/map/homunculus.c | 7 | ||||
-rw-r--r-- | src/map/packets.h | 2 |
6 files changed, 47 insertions, 17 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index 8983e93c9..70ebc4a08 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -7308,6 +7308,7 @@ static const struct battle_data { { "boarding_halter_speed", &battle_config.boarding_halter_speed, 25, 0, 100, }, { "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, }, }; #ifndef STATS_OPT_OUT /** diff --git a/src/map/battle.h b/src/map/battle.h index 3ab3e2ddd..429249dca 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -560,6 +560,8 @@ struct Battle_Config { int feature_rodex; int feature_rodex_use_accountmail; + + int feature_enable_homun_autofeed; }; /* criteria for battle_config.idletime_critera */ diff --git a/src/map/clif.c b/src/map/clif.c index 95a2d8f5d..5f7cf3b5d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9043,14 +9043,15 @@ void clif_feel_hate_reset(struct map_session_data *sd) clif->starskill(sd, "", 0, 0, 30); } -/// Equip window (un)tick ack (ZC_CONFIG). +/// Send configurations (ZC_CONFIG). /// 02d9 <type>.L <value>.L /// type: /// 0 = open equip window +/// 3 = homunculus autofeeding /// value: /// 0 = disabled /// 1 = enabled -void clif_equiptickack(struct map_session_data* sd, int flag) +void clif_zc_config(struct map_session_data* sd, int type, int flag) { int fd; nullpo_retv(sd); @@ -9058,7 +9059,7 @@ void clif_equiptickack(struct map_session_data* sd, int flag) WFIFOHEAD(fd, packet_len(0x2d9)); WFIFOW(fd, 0) = 0x2d9; - WFIFOL(fd, 2) = 0; + WFIFOL(fd, 2) = type; WFIFOL(fd, 6) = flag; WFIFOSET(fd, packet_len(0x2d9)); } @@ -15942,19 +15943,32 @@ void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) { clif->msgtable(sd, MSG_EQUIP_NOT_PUBLIC); } -void clif_parse_EquipTick(int fd, struct map_session_data* sd) __attribute__((nonnull (2))); -/// Request to change equip window tick (CZ_CONFIG). +void clif_parse_cz_config(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); +/// Receive configurations (CZ_CONFIG). /// 02d8 <type>.L <value>.L /// type: /// 0 = open equip window +/// 3 = homunculus autofeeding /// value: /// 0 = disabled /// 1 = enabled -void clif_parse_EquipTick(int fd, struct map_session_data* sd) -{ - bool flag = (RFIFOL(fd,6) != 0) ? true : false; - sd->status.show_equip = flag; - clif->equiptickack(sd, flag); +void clif_parse_cz_config(int fd, struct map_session_data *sd) +{ + int type = RFIFOL(fd, 2); + int flag = RFIFOL(fd, 6); + + if (type == CZ_CONFIG_OPEN_EQUIPMENT_WINDOW) { + sd->status.show_equip = flag; + } else if (type == CZ_CONFIG_HOMUNCULUS_AUTOFEEDING) { + struct homun_data *hd; + hd = sd->hd; + nullpo_retv(hd); + hd->homunculus.autofeed = flag; + } else { + ShowWarning("clif_parse_cz_config: Unsupported type has been received (%d).", type); + return; + } + clif->zc_config(sd, type, flag); } void clif_parse_PartyTick(int fd, struct map_session_data* sd) __attribute__((nonnull (2))); @@ -20344,7 +20358,7 @@ void clif_defaults(void) { clif->mission_info = clif_mission_info; clif->feel_hate_reset = clif_feel_hate_reset; clif->partytickack = clif_partytickack; - clif->equiptickack = clif_equiptickack; + clif->zc_config = clif_zc_config; clif->viewequip_ack = clif_viewequip_ack; clif->equpcheckbox = clif_equpcheckbox; clif->displayexp = clif_displayexp; @@ -20869,7 +20883,7 @@ void clif_defaults(void) { clif->pAdopt_request = clif_parse_Adopt_request; clif->pAdopt_reply = clif_parse_Adopt_reply; clif->pViewPlayerEquip = clif_parse_ViewPlayerEquip; - clif->pEquipTick = clif_parse_EquipTick; + clif->p_cz_config = clif_parse_cz_config; clif->pquestStateAck = clif_parse_questStateAck; clif->pmercenary_action = clif_parse_mercenary_action; clif->pBattleChat = clif_parse_BattleChat; diff --git a/src/map/clif.h b/src/map/clif.h index 112db3dec..e348bbb08 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -563,7 +563,15 @@ enum clif_unittype { CLUT_MERCNARY = 0x9, CLUT_ELEMENTAL = 0xa, }; - +/** +* Receive configuration types +**/ +enum CZ_CONFIG { + CZ_CONFIG_OPEN_EQUIPMENT_WINDOW = 0, + // Unknown = 1, + CZ_CONFIG_PET_AUTOFEEDING = 2, + CZ_CONFIG_HOMUNCULUS_AUTOFEEDING = 3, +}; /** * Structures **/ @@ -781,7 +789,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 (*equiptickack) (struct map_session_data* sd, int flag); + void (*zc_config) (struct map_session_data *sd, int 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); @@ -1302,7 +1310,7 @@ struct clif_interface { void (*pAdopt_request) (int fd, struct map_session_data *sd); void (*pAdopt_reply) (int fd, struct map_session_data *sd); void (*pViewPlayerEquip) (int fd, struct map_session_data* sd); - void (*pEquipTick) (int fd, struct map_session_data* sd); + void (*p_cz_config) (int fd, struct map_session_data *sd); void (*pquestStateAck) (int fd, struct map_session_data * sd); void (*pmercenary_action) (int fd, struct map_session_data* sd); void (*pBattleChat) (int fd, struct map_session_data* sd); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index ddaf3443a..9f5756885 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -683,7 +683,12 @@ int homunculus_hunger_timer(int tid, int64 tick, int id, intptr_t data) { } else if(hd->homunculus.hunger == 75) { clif->emotion(&hd->bl, E_OK); } - + if (battle_config.feature_enable_homun_autofeed != 0) { + if (hd->homunculus.autofeed) { + if (hd->homunculus.hunger < 30) + homun->feed(sd, hd); + } + } if(hd->homunculus.hunger < 0) { hd->homunculus.hunger = 0; // Delete the homunculus if intimacy <= 100 diff --git a/src/map/packets.h b/src/map/packets.h index 3fcf1648a..b95ae65cf 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -1151,7 +1151,7 @@ packet(0x96e,-1,clif->ackmergeitems); packet(0x02d5,2); packet(0x02d6,6,clif->pViewPlayerEquip,2); packet(0x02d7,-1); - packet(0x02d8,10,clif->pEquipTick,6); + packet(0x02d8,10,clif->p_cz_config,6); packet(0x02d9,10); packet(0x02da,3); packet(0x02db,-1,clif->pBattleChat,2,4); |