浏览代码

Added conf option for homunculus idle no share (#4548)

* Added conf option to make characters stop receiving exp/drop from homunculi when they are idle
Daegaladh 5 年之前
父节点
当前提交
921b3e2c3e
共有 6 个文件被更改,包括 24 次插入10 次删除
  1. 9 0
      conf/battle/homunc.conf
  2. 1 0
      src/map/battle.cpp
  3. 1 0
      src/map/battle.hpp
  4. 6 4
      src/map/mob.cpp
  5. 5 5
      src/map/party.cpp
  6. 2 1
      src/map/pc.hpp

+ 9 - 0
conf/battle/homunc.conf

@@ -61,3 +61,12 @@ homunculus_S_growth_level: 99
 // Send auto-feed notice even if OFF (Note 1) 
 // Official: yes
 homunculus_autofeed_always: yes
+
+// Is getting exp/item from the homunculus disabled when you're idle?
+// Set to no, or the amount of seconds (NOT milliseconds) that need to pass before considering
+// a character idle.
+// Characters in a chat/vending are always considered idle.
+// A character's idle status is reset upon item use/skill use/attack (auto attack counts too)/movement.
+// You will only receive items if 'homunculus_autoloot' is activated,
+// otherwise they will be dropped on the ground as usual.
+hom_idle_no_share: no

+ 1 - 0
src/map/battle.cpp

@@ -8553,6 +8553,7 @@ static const struct _battle_data {
 	{ "mob_nopc_move_rate",                 &battle_config.mob_nopc_move_rate,              100,    0,    100,              },
 	{ "boss_nopc_idleskill_rate",           &battle_config.boss_nopc_idleskill_rate,        100,    0,    100,              },
 	{ "boss_nopc_move_rate",                &battle_config.boss_nopc_move_rate,             100,    0,    100,              },
+	{ "hom_idle_no_share",                  &battle_config.hom_idle_no_share,               0,      0,      INT_MAX,        },
 
 #include "../custom/battle_config_init.inc"
 };

+ 1 - 0
src/map/battle.hpp

@@ -663,6 +663,7 @@ struct Battle_Config
 	int mob_nopc_move_rate;
 	int boss_nopc_idleskill_rate;
 	int boss_nopc_move_rate;
+	int hom_idle_no_share;
 
 #include "../custom/battle_config_struct.inc"
 };

+ 6 - 4
src/map/mob.cpp

@@ -2187,7 +2187,7 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
 	test_autoloot = sd 
 		&& (drop_rate <= sd->state.autoloot || pc_isautolooting(sd, ditem->item_data.nameid))
 		&& (battle_config.idle_no_autoloot == 0 || DIFF_TICK(last_tick, sd->idletime) < battle_config.idle_no_autoloot)
-		&& (battle_config.homunculus_autoloot?1:!flag);
+		&& (battle_config.homunculus_autoloot?(battle_config.hom_idle_no_share == 0 || !pc_isidle_hom(sd)):!flag);
 #ifdef AUTOLOOT_DISTANCE
 		test_autoloot = test_autoloot && sd->bl.m == md->bl.m
 		&& check_distance_blxy(&sd->bl, dlist->x, dlist->y, AUTOLOOT_DISTANCE);
@@ -2654,7 +2654,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 								job_exp = (unsigned int)cap_value(apply_rate(job_exp, rate), 1, UINT_MAX);
 						}
 #endif
-						pc_gainexp(tmpsd[i], &md->bl, base_exp, job_exp, 0);
+						if (!(homkillonly && battle_config.hom_idle_no_share && pc_isidle_hom(tmpsd[i])))
+							pc_gainexp(tmpsd[i], &md->bl, base_exp, job_exp, 0);
 					}
 				}
 				if(zeny) // zeny from mobs [Valaris]
@@ -2665,8 +2666,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 				pc_damage_log_clear(tmpsd[i],md->bl.id);
 		}
 
-		for( i = 0; i < pnum; i++ ) //Party share.
-			party_exp_share(pt[i].p, &md->bl, pt[i].base_exp,pt[i].job_exp,pt[i].zeny);
+		if (!(homkillonly && battle_config.hom_idle_no_share && pc_isidle_hom(map_charid2sd(md->dmglog[0].id))))
+			for( i = 0; i < pnum; i++ ) //Party share.
+				party_exp_share(pt[i].p, &md->bl, pt[i].base_exp,pt[i].job_exp,pt[i].zeny);
 
 	} //End EXP giving.
 

+ 5 - 5
src/map/party.cpp

@@ -1089,7 +1089,7 @@ void party_exp_share(struct party_data* p, struct block_list* src, unsigned int
 
 	// count the number of players eligible for exp sharing
 	for (i = c = 0; i < MAX_PARTY; i++) {
-		if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle(sd[c])) )
+		if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle_party(sd[c])) )
 			continue;
 		c++;
 	}
@@ -1151,7 +1151,7 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i
 				if (i >= MAX_PARTY)
 					i = 0;	// reset counter to 1st person in party so it'll stop when it reaches "itemc"
 
-				if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) || (battle_config.idle_no_share && pc_isidle(psd)) )
+				if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) || (battle_config.idle_no_share && pc_isidle_party(psd)) )
 					continue;
 
 				if (pc_additem(psd,item,item->amount,LOG_TYPE_PICKDROP_PLAYER))
@@ -1168,7 +1168,7 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i
 
 			//Collect pick candidates
 			for (i = 0; i < MAX_PARTY; i++) {
-				if( (psd[count] = p->data[i].sd) == NULL || psd[count]->bl.m != sd->bl.m || pc_isdead(psd[count]) || (battle_config.idle_no_share && pc_isidle(psd[count])) )
+				if( (psd[count] = p->data[i].sd) == NULL || psd[count]->bl.m != sd->bl.m || pc_isdead(psd[count]) || (battle_config.idle_no_share && pc_isidle_party(psd[count])) )
 					continue;
 
 				count++;
@@ -1222,7 +1222,7 @@ int party_sub_count(struct block_list *bl, va_list ap)
 	if (sd->state.autotrade)
 		return 0;
 
-	if (battle_config.idle_no_share && pc_isidle(sd))
+	if (battle_config.idle_no_share && pc_isidle_party(sd))
 		return 0;
 
 	return 1;
@@ -1263,7 +1263,7 @@ int party_sub_count_banding(struct block_list *bl, va_list ap)
 	if (sd->state.autotrade)
 		return 0;
 
-	if (battle_config.idle_no_share && pc_isidle(sd))
+	if (battle_config.idle_no_share && pc_isidle_party(sd))
 		return 0;
 
 	if ((sd->class_&MAPID_THIRDMASK) != MAPID_ROYAL_GUARD)

+ 2 - 1
src/map/pc.hpp

@@ -894,7 +894,8 @@ extern struct s_job_info job_info[CLASS_COUNT];
 #define pc_setsit(sd)         { pc_stop_walking((sd), 1|4); pc_stop_attack((sd)); (sd)->state.dead_sit = (sd)->vd.dead_sit = 2; }
 #define pc_isdead(sd)         ( (sd)->state.dead_sit == 1 )
 #define pc_issit(sd)          ( (sd)->vd.dead_sit == 2 )
-#define pc_isidle(sd)         ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share )
+#define pc_isidle_party(sd)   ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share )
+#define pc_isidle_hom(sd)     ( (sd)->hd && ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.hom_idle_no_share ) )
 #define pc_istrading(sd)      ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->state.trading )
 #define pc_cant_act(sd)       ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->chatID || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend )