diff options
author | shennetsind <ind@henn.et> | 2013-10-24 06:45:48 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-10-24 07:03:30 -0200 |
commit | e08c05a0f73d6e6ea4fe64a9b91291bc0a002251 (patch) | |
tree | efe8ae89989a63c008db2cf244c9ea1eb93b3711 /src | |
parent | 8b07c677e351056b0d23fbc3726f80829ae4d253 (diff) | |
download | hercules-e08c05a0f73d6e6ea4fe64a9b91291bc0a002251.tar.gz hercules-e08c05a0f73d6e6ea4fe64a9b91291bc0a002251.tar.bz2 hercules-e08c05a0f73d6e6ea4fe64a9b91291bc0a002251.tar.xz hercules-e08c05a0f73d6e6ea4fe64a9b91291bc0a002251.zip |
Added idletime options
There have been requests for the extension of the feature, I was reluctant given more options would cause features relying on the feature to be easier to counter (less accurate), with the modification of the feature to employ options the feature is now configurable at the server owners discretion.
Special Thanks to Haruna
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.c | 3 | ||||
-rw-r--r-- | src/map/battle.c | 1 | ||||
-rw-r--r-- | src/map/battle.h | 16 | ||||
-rw-r--r-- | src/map/clif.c | 46 | ||||
-rw-r--r-- | src/map/unit.c | 2 |
5 files changed, 62 insertions, 6 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 19128083d..27fbb7218 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -9664,6 +9664,9 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message sprintf(atcmd_msg, "%s", message); } + if( battle_config.idletime_criteria & BCIDLE_ATCOMMAND ) + sd->idletime = last_tick; + //Clearing these to be used once more. memset(command, '\0', sizeof(command)); memset(params, '\0', sizeof(params)); diff --git a/src/map/battle.c b/src/map/battle.c index 0406500b7..050f3f26e 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6470,6 +6470,7 @@ static const struct _battle_data { { "guild_notice_changemap", &battle_config.guild_notice_changemap, 2, 0, 2, }, { "feature.banking", &battle_config.feature_banking, 1, 0, 1, }, { "feature.auction", &battle_config.feature_auction, 0, 0, 2, }, + { "idletime_criteria", &battle_config.idletime_criteria, 0x25, 1, INT_MAX, }, { "mon_trans_disable_in_gvg", &battle_config.mon_trans_disable_in_gvg, 0, 0, 1, }, }; diff --git a/src/map/battle.h b/src/map/battle.h index 1aa07b2be..a2212a647 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -454,7 +454,7 @@ struct Battle_Config { int max_walk_path; int item_enabled_npc; int packet_obfuscation; - + int idletime_criteria; int gm_ignore_warpable_area; int client_accept_chatdori; // [Ai4rei/Mirei] @@ -467,6 +467,20 @@ struct Battle_Config { int mon_trans_disable_in_gvg; } battle_config; +/* criteria for battle_config.idletime_critera */ +enum e_battle_config_idletime { + BCIDLE_WALK = 0x001, + BCIDLE_USESKILLTOID = 0x002, + BCIDLE_USESKILLTOPOS = 0x004, + BCIDLE_USEITEM = 0x008, + BCIDLE_ATTACK = 0x010, + BCIDLE_CHAT = 0x020, + BCIDLE_SIT = 0x040, + BCIDLE_EMOTION = 0x080, + BCIDLE_DROPITEM = 0x100, + BCIDLE_ATCOMMAND = 0x200, +}; + // Dammage delayed info struct delay_damage { int src_id; diff --git a/src/map/clif.c b/src/map/clif.c index 7aacd8e90..9c740d607 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9917,6 +9917,9 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) } } + if( battle_config.idletime_criteria & BCIDLE_CHAT ) + sd->idletime = last_tick; + if( sd->gcbind ) { clif->chsys_send(sd->gcbind,sd,message); return; @@ -10077,6 +10080,9 @@ void clif_parse_Emotion(int fd, struct map_session_data *sd) return; } sd->emotionlasttime = time(NULL); + + if( battle_config.idletime_criteria & BCIDLE_EMOTION ) + sd->idletime = last_tick; if(battle_config.client_reshuffle_dice && emoticon>=E_DICE1 && emoticon<=E_DICE6) {// re-roll dice emoticon = rnd()%6+E_DICE1; @@ -10151,7 +10157,8 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, } pc->delinvincibletimer(sd); - sd->idletime = last_tick; + if( battle_config.idletime_criteria & BCIDLE_ATTACK ) + sd->idletime = last_tick; unit->attack(&sd->bl, target_id, action_type != 0); break; case 0x02: // sitdown @@ -10175,6 +10182,9 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, )) //No sitting during these states either. break; + if( battle_config.idletime_criteria & BCIDLE_SIT ) + sd->idletime = last_tick; + pc_setsit(sd); skill->sit(sd,1); clif->sitting(&sd->bl); @@ -10185,6 +10195,10 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, clif->standing(&sd->bl); return; } + + if( battle_config.idletime_criteria & BCIDLE_SIT ) + sd->idletime = last_tick; + pc->setstand(sd); skill->sit(sd,0); clif->standing(&sd->bl); @@ -10376,6 +10390,9 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } + if( battle_config.idletime_criteria & BCIDLE_CHAT ) + sd->idletime = last_tick; + // Chat logging type 'W' / Whisper logs->chat(LOG_CHAT_WHISPER, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, message); @@ -10594,6 +10611,9 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd) if (!pc->dropitem(sd, item_index, item_amount)) break; + if( battle_config.idletime_criteria & BCIDLE_DROPITEM ) + sd->idletime = last_tick; + return; } @@ -10619,7 +10639,8 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd) return; //Whether the item is used or not is irrelevant, the char ain't idle. [Skotlex] - sd->idletime = last_tick; + if( battle_config.idletime_criteria & BCIDLE_USEITEM ) + sd->idletime = last_tick; n = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0])-2; if(n <0 || n >= MAX_INVENTORY) @@ -10664,6 +10685,9 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd) return; } + if( battle_config.idletime_criteria & BCIDLE_USEITEM ) + sd->idletime = last_tick; + //Client doesn't send the position for ammo. if(sd->inventory_data[index]->type == IT_AMMO) pc->equipitem(sd,index,EQP_AMMO); @@ -10781,6 +10805,9 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd) index = RFIFOW(fd,2)-2; + if( battle_config.idletime_criteria & BCIDLE_USEITEM ) + sd->idletime = last_tick; + pc->unequipitem(sd,index,1); } @@ -11330,7 +11357,8 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) } // Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex] - sd->idletime = last_tick; + if( battle_config.idletime_criteria & BCIDLE_USESKILLTOID ) + sd->idletime = last_tick; if( sd->npc_id || sd->state.workinprogress&1 ){ #ifdef RENEWAL @@ -11430,7 +11458,8 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski #endif //Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex] - sd->idletime = last_tick; + if( battle_config.idletime_criteria & BCIDLE_USESKILLTOPOS ) + sd->idletime = last_tick; if( skill->not_ok(skill_id, sd) ) return; @@ -12185,6 +12214,9 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } + if( battle_config.idletime_criteria & BCIDLE_CHAT ) + sd->idletime = last_tick; + party->send_message(sd, text, textlen); } @@ -13140,6 +13172,9 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd) sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } + if( battle_config.idletime_criteria & BCIDLE_CHAT ) + sd->idletime = last_tick; + if( sd->bg_id ) bg->send_message(sd, text, textlen); else @@ -16077,6 +16112,9 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd) sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } + if( battle_config.idletime_criteria & BCIDLE_CHAT ) + sd->idletime = last_tick; + bg->send_message(sd, text, textlen); } diff --git a/src/map/unit.c b/src/map/unit.c index a7aca10b9..a9cbd605e 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1915,7 +1915,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) } if(ud->state.attack_continue) { - if( src->type == BL_PC ) + if( src->type == BL_PC && battle_config.idletime_criteria & BCIDLE_ATTACK ) ((TBL_PC*)src)->idletime = last_tick; ud->attacktimer = timer->add(ud->attackabletime,unit->attack_timer,src->id,0); } |