Jelajahi Sumber

* Some updates for range check. (bugreport:3339)
- Monsters shouldn't use skills if the target is within its attack range but is out of the skill range.
- Monsters' skill range is no longer 9 by default.
- Range for players' attacks and skills should always check for a circular area.
- The range of Magnetic Earth is 2.

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

Inkfish 16 tahun lalu
induk
melakukan
b1445ca0ae
8 mengubah file dengan 25 tambahan dan 7 penghapusan
  1. 5 0
      Changelog-Trunk.txt
  2. 2 2
      conf/battle/monster.conf
  3. 2 0
      db/Changelog.txt
  4. 1 1
      db/skill_db.txt
  5. 9 0
      src/map/battle.c
  6. 1 1
      src/map/clif.c
  7. 4 2
      src/map/mob.c
  8. 1 1
      src/map/skill.c

+ 5 - 0
Changelog-Trunk.txt

@@ -3,6 +3,11 @@ 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.
 
+09/07/11
+	* Some updates for range check. (bugreport:3339) [Inkfish]
+	- Monsters shouldn't use skills if the target is within its attack range but is out of the skill range.
+	- Monsters' skill range is no longer 9 by default. 
+	- Range for players' attacks and skills should always have a circular check.
 09/07/07
 	* Skills with multiple hits should do 1 damage per hit to plants. [Inkfish]
 09/07/04

+ 2 - 2
conf/battle/monster.conf

@@ -59,8 +59,8 @@ monster_max_aspd: 199
 //        the same skill, instead, only to that particular entry (eg: Mob has heal
 //        on six lines in the mob_skill_db, only the entry that is actually used
 //        will receive the delay). This will make monsters harder, especially MvPs.
-// 0x400: By default mobs have a range of 9 for all skills. Set this to enforce
-//        the normal skill range rules on them.
+// 0x400: Set this to make mobs have a range of 9 for all skills. Otherwise, they 
+//        will obey the normal skill range rules.
 // Example: 0x140 -> Chase players through warps + use skills in random order.
 monster_ai: 0
 

+ 2 - 0
db/Changelog.txt

@@ -34,6 +34,8 @@
 	2385 Recuvative_Armor		Should trigger HP/SP return with magical kills as well.
 
 =======================
+2009/07/11
+	* The range of Magnetic Earth should be 2. (bugreport:3339) [Inkfish]
 2009/07/02
 	* Fixed a bug in Ifrit's drops (bugreport:3319) [Playtester]
 2009/06/29

+ 1 - 1
db/skill_db.txt

@@ -330,7 +330,7 @@
 285,2,6,2,3,0x1,0,5,1,yes,0,0,0,magic,0,		SA_VOLCANO,Volcano
 286,2,6,2,1,0x1,0,5,1,yes,0,0,0,magic,0,		SA_DELUGE,Deluge
 287,2,6,2,4,0x1,0,5,1,yes,0,0,0,magic,0,		SA_VIOLENTGALE,Whirlwind
-288,3,6,2,0,0x1,0,5,1,yes,0,0,0,magic,0,		SA_LANDPROTECTOR,Magnetic Earth
+288,2,6,2,0,0x1,0,5,1,yes,0,0,0,magic,0,		SA_LANDPROTECTOR,Magnetic Earth
 289,9,6,1,0,0x1,0:0:0:0:0:-1,5,1,yes,0,0xE00,0,magic,0,	SA_DISPELL,Dispell
 290,0,6,4,0,0x1,0,10,1,yes,0,0,0,magic,0,	SA_ABRACADABRA,Hocus-pocus
 291,9,6,1,0,0x1,0,1,1,yes,0,0x2,0,magic,0,	SA_MONOCELL,Monocell

+ 9 - 0
src/map/battle.c

@@ -3430,6 +3430,15 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range
 	if( src->m != bl->m )
 		return false;
 
+#ifndef CIRCULAR_AREA
+	if( src->type == BL_PC )
+	{ // Range for players' attacks and skills should always have a circular check. [Inkfish]
+		int dx = src->x - bl->x, dy = src->y - bl->y;
+		if( !check_distance(dx*dx + dy*dy, 0, range*range+(dx&&dy?1:0)) )
+			return false;
+	}
+	else
+#endif
 	if( !check_distance_bl(src, bl, range) )
 		return false;
 

+ 1 - 1
src/map/clif.c

@@ -9516,7 +9516,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
 	{
 		if( skilllv != sd->skillitemlv )
 			skilllv = sd->skillitemlv;
-		if( !(skill_get_inf(skillnum)&INF_SELF_SKILL) )
+		if( !(tmp&INF_SELF_SKILL) )
 			pc_delinvincibletimer(sd); // Target skills thru items cancel invincibility. [Inkfish]
 		unit_skilluse_id(&sd->bl, target_id, skillnum, skilllv);
 		return;

+ 4 - 2
src/map/mob.c

@@ -3004,7 +3004,8 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
 			}
 			md->skillidx = i;
 			map_freeblock_lock();
-			if (!unit_skilluse_pos2(&md->bl, x, y, ms[i].skill_id, ms[i].skill_lv, ms[i].casttime, ms[i].cancel))
+			if( !battle_check_range(&md->bl,bl,skill_get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) ||
+				!unit_skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) )
 			{
 				map_freeblock_unlock();
 				continue;
@@ -3040,7 +3041,8 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
 			if (!bl) continue;
 			md->skillidx = i;
 			map_freeblock_lock();
-			if (!unit_skilluse_id2(&md->bl, bl->id, ms[i].skill_id, ms[i].skill_lv, ms[i].casttime, ms[i].cancel))
+			if( !battle_check_range(&md->bl,bl,skill_get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) ||
+				!unit_skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) )
 			{
 				map_freeblock_unlock();
 				continue;

+ 1 - 1
src/map/skill.c

@@ -218,7 +218,7 @@ int skill_get_casttype (int id)
 int skill_get_range2 (struct block_list *bl, int id, int lv)
 {
 	int range;
-	if( bl->type == BL_MOB && !(battle_config.mob_ai&0x400) )
+	if( bl->type == BL_MOB && battle_config.mob_ai&0x400 )
 		return 9; //Mobs have a range of 9 regardless of skill used.
 
 	range = skill_get_range(id, lv);