Просмотр исходного кода

- Cleaned up the "show_steal_in_party" setting so it only takes effect when the item was successfully stolen (there was no point in telling you the item couldn't be stolen due to being overweight)
- Cleaned up the pc_steal_item implementation (again). It now uses a more random, simple approach in each steal attempt.
- Changed the way the skill_steal_max_tries work. Now it actually MEANS the max number of steal tries, use 0 to disable (unlimited tries).
- Changed the default of skill_steal_max_tries to 0 as there's no proof anywhere that there should be such a limit.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9057 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 18 лет назад
Родитель
Сommit
14fd5f1b63
6 измененных файлов с 64 добавлено и 67 удалено
  1. 8 0
      Changelog-Trunk.txt
  2. 5 0
      conf-tmpl/Changelog.txt
  3. 3 3
      conf-tmpl/battle/skill.conf
  4. 3 5
      src/map/battle.c
  5. 1 2
      src/map/battle.h
  6. 44 57
      src/map/pc.c

+ 8 - 0
Changelog-Trunk.txt

@@ -3,6 +3,14 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2006/10/24
+	* Cleaned up the "show_steal_in_party" setting so it only takes effect when
+	  the item was successfully stolen (there was no point in telling you the
+	  item couldn't be stolen due to being overweight) [Skotlex]
+	* Cleaned up the pc_steal_item implementation (again). It now uses a more
+	  random, simple approach in each steal attempt. [Skotlex]
+	* Changed the way the skill_steal_max_tries work. Now it actually MEANS the
+	  max number of steal tries, use 0 to disable (unlimited tries). [Skotlex]
 2006/10/23
 	* Added a bunch of important indexes when dealing with the log tables.
 	  Added upgrade_svn9050.sql which adds these indexes as well. [Skotlex]

+ 5 - 0
conf-tmpl/Changelog.txt

@@ -1,5 +1,10 @@
 Date	Added
 
+2006/10/24
+	* Changed the way the skill_steal_max_tries work. Now it actually MEANS the
+	  max number of steal tries, use 0 to disable (unlimited tries). [Skotlex]
+	* Changed the default of skill_steal_max_tries to 0 as there's no proof
+	  anywhere that there should be such a limit. [Skotlex]
 2006/10/20
 	* Added config setting "summon_flora_setting" (skill.conf), with it you can
 	  decide now two things: a. Whether or not players can harm your floras

+ 3 - 3
conf-tmpl/battle/skill.conf

@@ -212,9 +212,9 @@ backstab_bow_penalty: yes
 skill_steal_type: yes
 
 // How many times you could try to steal from a mob.
-// Note: It helps to avoid stealing exploit on monstewrs with few rare items
-// 0..254 = number of tries +1
-skill_steal_max_tries: 15
+// Note: It helps to avoid stealing exploit on monsters with few rare items
+// Use 0 to disable (max allowed value is 255)
+skill_steal_max_tries: 0
 
 // Can Rogues plagiarize advanced job skills           
 // 0 = no restriction

+ 3 - 5
src/map/battle.c

@@ -3705,8 +3705,7 @@ static const struct battle_data_short {
 	{ "pk_min_level",                      &battle_config.pk_min_level}, // [celest]
 	{ "skill_steal_type",                  &battle_config.skill_steal_type}, // [celest]
 	{ "skill_steal_rate",                  &battle_config.skill_steal_rate}, // [celest]
-	{ "skill_steal_max_tries",			&battle_config.skill_steal_max_tries}, // [Lupus]
-//	{ "night_darkness_level",              &battle_config.night_darkness_level}, // [celest]
+	{ "skill_steal_max_tries",             &battle_config.skill_steal_max_tries}, // [Lupus]
 	{ "motd_type",                         &battle_config.motd_type}, // [celest]
 	{ "finding_ore_rate",                  &battle_config.finding_ore_rate}, // [celest]
 	{ "exp_calc_type",                     &battle_config.exp_calc_type}, // [celest]
@@ -4138,8 +4137,7 @@ void battle_set_defaults() {
 	battle_config.pk_min_level = 55;
 	battle_config.skill_steal_type = 1;
 	battle_config.skill_steal_rate = 100;
-	battle_config.skill_steal_max_tries = 15; //=16 tries
-//	battle_config.night_darkness_level = 9;
+	battle_config.skill_steal_max_tries = 0; //Default: unlimited tries.
 	battle_config.motd_type = 0;
 	battle_config.finding_ore_rate = 100;
 	battle_config.castrate_dex_scale = 150;
@@ -4392,7 +4390,7 @@ void battle_validate_conf() {
 	if (battle_config.sg_miracle_skill_duration_max < 2000)
 		battle_config.sg_miracle_skill_duration_max = 2000;
 
-	if (battle_config.skill_steal_max_tries > UCHAR_MAX)
+	if (battle_config.skill_steal_max_tries >= UCHAR_MAX)
 		battle_config.skill_steal_max_tries = UCHAR_MAX;	
 
 #ifdef CELL_NOSTACK

+ 1 - 2
src/map/battle.h

@@ -355,8 +355,7 @@ extern struct Battle_Config {
 	unsigned short pk_min_level; // [celest]
 	unsigned short skill_steal_type; // [celest]
 	unsigned short skill_steal_rate; // [celest]
-	unsigned short skill_steal_max_tries; //max steal skill tries on a mob. if=256, then w/o limit [Lupus]
-//	unsigned short night_darkness_level; // [celest]
+	unsigned short skill_steal_max_tries; //max steal skill tries on a mob. if 0 or 256, then w/o limit [Lupus]
 	unsigned short motd_type; // [celest]
 	unsigned short finding_ore_rate; // orn
 	unsigned short exp_calc_type;

+ 44 - 57
src/map/pc.c

@@ -3154,23 +3154,14 @@ int pc_show_steal(struct block_list *bl,va_list ap)
 	struct item_data *item=NULL;
 	char output[100];
 
-	nullpo_retr(0, bl);
-	nullpo_retr(0, ap);
-	nullpo_retr(0, sd=va_arg(ap,struct map_session_data *));
-
+	sd=va_arg(ap,struct map_session_data *);
 	itemid=va_arg(ap,int);
-	type=va_arg(ap,int);
 
-	if(!type){
-		if((item=itemdb_exists(itemid))==NULL)
-			sprintf(output,"%s stole an Unknown Item.",sd->status.name);
-		else
-			sprintf(output,"%s stole %s.",sd->status.name,item->jname);
-		clif_displaymessage( ((struct map_session_data *)bl)->fd, output);
-	}else{
-		sprintf(output,"%s has not stolen the item because of being overweight.",sd->status.name);
-		clif_displaymessage( ((struct map_session_data *)bl)->fd, output);
-	}
+	if((item=itemdb_exists(itemid))==NULL)
+		sprintf(output,"%s stole an Unknown Item.",sd->status.name);
+	else
+		sprintf(output,"%s stole %s.",sd->status.name,item->jname);
+	clif_displaymessage( ((struct map_session_data *)bl)->fd, output);
 
 	return 0;
 }
@@ -3181,8 +3172,7 @@ int pc_show_steal(struct block_list *bl,va_list ap)
 //** pc.c:
 int pc_steal_item(struct map_session_data *sd,struct block_list *bl, int lv)
 {
-	static int i = 0;
-	int old_i,rate,itemid,flag;
+	int i,rate,itemid,flag;
 	struct status_data *sd_status, *md_status;
 	struct mob_data *md;
 	struct item tmp_item;
@@ -3194,47 +3184,40 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, int lv)
 	md_status= status_get_status_data(bl);
 	md = (TBL_MOB *)bl;
 
-	if(md->state.steal_flag>=battle_config.skill_steal_max_tries ||
+	if(md->state.steal_flag == UCHAR_MAX || //already stolen from
 		md_status->mode&MD_BOSS || md->master_id ||
 		(md->class_>=1324 && md->class_<1364) || // prevent stealing from treasure boxes [Valaris]
 		map[md->bl.m].flag.nomobloot ||        // check noloot map flag [Lorky]
 		md->sc.opt1 //status change check
   	)
 		return 0;
-	
+						
+	if(battle_config.skill_steal_max_tries &&
+		md->state.steal_flag++ >= battle_config.skill_steal_max_tries)
+	{	//Reached limit of steal attempts.
+		md->state.steal_flag = UCHAR_MAX;
+		return 0;
+	}
+
 	rate = battle_config.skill_steal_type
 		? (sd_status->dex - md_status->dex)/2 + lv*6 + 10
-		: sd_status->dex - md_status->dex + lv*3 + 10;
+		: (sd_status->dex - md_status->dex)   + lv*3 + 10;
 
 	rate += sd->add_steal_rate; //Better make the steal_Rate addition affect % rather than an absolute on top of the total drop rate. [Skotlex]
 		
 	if (rate < 1)
 		return 0;
 
-	md->state.steal_flag++; //increase steal tries number
-
 	//preliminar statistical data hints at this behaviour:
 	//each steal attempt: try to steal against ONE mob drop, and no more.
-	//We use a static index to prevent giving priority to any of the slots.
-	old_i = i;
-	do {
-		i++;
-		if (i == MAX_MOB_DROP-1 && lv <= 5)
-			continue; //Cannot steal "last slot" (card slot)
-		if (i == MAX_MOB_DROP)
-			i = 0;
-	} while (md->db->dropitem[i].p <= 0 && old_i != i);
-
-	if(old_i == i) {
-		md->state.steal_flag = UCHAR_MAX; //Tag for speed up in case you reinsist
-		return 0; //Mob has nothing stealable!
-	}
+	if (lv > 5) //Include last slot (card slot)
+		i = rand()%MAX_MOB_DROP;
+	else	//Do not include card slot
+		i = rand()%(MAX_MOB_DROP-1);
 
 	if(rand() % 10000 >= md->db->dropitem[i].p*rate/100)
 		return 0;
 	
-	md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more
-	
 	malloc_set(&tmp_item,0,sizeof(tmp_item));
 	itemid = md->db->dropitem[i].nameid;
 	tmp_item.nameid = itemid;
@@ -3242,27 +3225,31 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, int lv)
 	tmp_item.identify = itemdb_isidentified(itemid);
 	flag = pc_additem(sd,&tmp_item,1);
 
-	if(battle_config.show_steal_in_same_party)
-		party_foreachsamemap(pc_show_steal,sd,AREA_SIZE,sd,tmp_item.nameid,flag?1:0);
-	if(flag)
+	//TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise?
+	md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more
+
+	if(flag) { //Failed to steal due to overweight
 		clif_additem(sd,0,0,flag);
-	else
-	{	//Only invoke logs if item was successfully added (otherwise logs lie about actual item transaction)
-		//Logs items, Stolen from mobs [Lupus]
-		if(log_config.enable_logs&0x80) {
-			log_pick_mob(md, "M", itemid, -1, NULL);
-			log_pick_pc(sd, "P", itemid, 1, NULL);
-		}
+		return 0;
+	}
+	
+	if(battle_config.show_steal_in_same_party)
+		party_foreachsamemap(pc_show_steal,sd,AREA_SIZE,sd,tmp_item.nameid);
+
+	//Logs items, Stolen from mobs [Lupus]
+	if(log_config.enable_logs&0x80) {
+		log_pick_mob(md, "M", itemid, -1, NULL);
+		log_pick_pc(sd, "P", itemid, 1, NULL);
+	}
 		
-		//A Rare Steal Global Announce by Lupus
-		if(md->db->dropitem[i].p<=battle_config.rare_drop_announce) {
-			struct item_data *i_data;
-			char message[128];
-			i_data = itemdb_search(itemid);
-			sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, i_data->jname, (float)md->db->dropitem[i].p/100);
-			//MSG: "'%s' stole %s's %s (chance: %%%0.02f)"
-			intif_GMmessage(message,strlen(message)+1,0);
-		}
+	//A Rare Steal Global Announce by Lupus
+	if(md->db->dropitem[i].p<=battle_config.rare_drop_announce) {
+		struct item_data *i_data;
+		char message[128];
+		i_data = itemdb_search(itemid);
+		sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, i_data->jname, (float)md->db->dropitem[i].p/100);
+		//MSG: "'%s' stole %s's %s (chance: %%%0.02f)"
+		intif_GMmessage(message,strlen(message)+1,0);
 	}
 	return 1;
 }