瀏覽代碼

- Added an alternate path searching method for non-stacking mode.
- Allowed pc_setpos to place players on top of cells that are stacked in CELL_NOSTACK mode.
- Fixed a missing break that was making Heal, Resurrection and some others become attack skills x.x'
- Fixed a logic bug in the mob-walk code that was making them get stuck and not move (triggered quite often when the cell no stack mod is enabled)


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

skotlex 19 年之前
父節點
當前提交
3804e1684f
共有 4 個文件被更改,包括 37 次插入11 次删除
  1. 8 0
      Changelog-Trunk.txt
  2. 24 11
      src/map/mob.c
  3. 4 0
      src/map/pc.c
  4. 1 0
      src/map/skill.c

+ 8 - 0
Changelog-Trunk.txt

@@ -4,6 +4,14 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.  EVERYTHING ELSE
 GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
 
+2006/02/18
+	* Fixed a missing break that was making Heal, Resurrection and some others
+	  become attack skills [Skotlex]
+	* Some CELL_NOSTACK Mod updates: [Skotlex]
+	- Made the free-cell lookup more extensive.
+	- Allowed pc_setpos to place players on top of cells that are stacked 
+	- Fixed a logic bug in the mob-walk code that was making them get stuck and
+	  not move (triggered quite often when the cell no stack mod is enabled)
 2006/02/17
 	* Cleaned up irc.c, may it compile now on Windows? [Skotlex]
 	* Updated the VC project files by Joshuaali. [Skotlex]

+ 24 - 11
src/map/mob.c

@@ -509,7 +509,6 @@ static int mob_walktoxy_sub(struct mob_data *md);
  */
 static int mob_walk(struct mob_data *md,unsigned int tick,int data)
 {
-	int moveblock;
 	int i;
 	static int dirx[8]={0,-1,-1,-1,0,1,1,1};
 	static int diry[8]={1,1,0,-1,-1,-1,0,1};
@@ -550,8 +549,6 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data)
 			return 0;
 		}
 
-		moveblock = ( x/BLOCK_SIZE != (x+dx)/BLOCK_SIZE || y/BLOCK_SIZE != (y+dy)/BLOCK_SIZE);
-
 		md->state.state=MS_WALK;
 		map_foreachinmovearea(clif_moboutsight,md->bl.m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,md);
 
@@ -787,7 +784,7 @@ int mob_changestate(struct mob_data *md,int state,int type)
 	case MS_WALK:
 		if((i=calc_next_walk_step(md))>0){
 			i = i>>2;
-			md->timer=add_timer(gettick()+i,mob_timer,md->bl.id,0);
+			md->timer=add_timer(gettick()+i,mob_timer,md->bl.id, md->walkpath.path_pos);
 		}
 		else
 			md->state.state=MS_IDLE;
@@ -890,20 +887,13 @@ static int mob_timer(int tid,unsigned int tick,int id,int data)
 static int mob_walktoxy_sub(struct mob_data *md)
 {
 	struct walkpath_data wpd;
-	int x,y;
-	static int dirx[8]={0,-1,-1,-1,0,1,1,1};
-	static int diry[8]={1,1,0,-1,-1,-1,0,1};
-
 	nullpo_retr(0, md);
-
 	memset(&wpd, 0, sizeof(wpd));
 
 	if(path_search(&wpd,md->bl.m,md->bl.x,md->bl.y,md->to_x,md->to_y,md->state.walk_easy))
 		return 1;
 	if (wpd.path[0] >= 8)
 		return 1;	
-	x = md->bl.x+dirx[wpd.path[0]];
-	y = md->bl.y+diry[wpd.path[0]];
 
 	memcpy(&md->walkpath,&wpd,sizeof(wpd));
 
@@ -1753,6 +1743,28 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
 				else if (dx > 0) dx--;
 				if (dy < 0) dy++;
 				else if (dy > 0) dy--;
+#ifdef CELL_NOSTACK
+				while (mob_walktoxy(md, md->bl.x + dx, md->bl.y + dy, 0))
+				{	//Attempt to chase to nearby blocks
+					do {
+						if (i < 5) {
+							dx = tbl->x - md->bl.x + rand()%3 - 1;
+							dy = tbl->y - md->bl.y + rand()%3 - 1;
+						} else { //Try some more...
+							dx = tbl->x - md->bl.x + rand()%5 - 2;
+							dy = tbl->y - md->bl.y + rand()%5 - 2;
+						}
+						i++;
+					} while (i < 15 && map_getcell(md->bl.m,  md->bl.x+dx, md->bl.y+dy, CELL_CHKSTACK));
+					if (i >= 15) {
+						//On stacked mode, it is much more likely that you just can't reach the target. So unlock it
+						mob_unlocktarget(md, tick);
+						//Make it give up for 1 second to avoid unnecessary server load in case the target is already mobbed to death.
+						mob_changestate(md,MS_DELAY,1000);
+						return 0;
+					}
+				}
+#else
 				while (i < 5 && mob_walktoxy(md, md->bl.x + dx, md->bl.y + dy, 0))
 				{	//Attempt to chase to nearby blocks
 					dx = tbl->x - md->bl.x + rand()%3 - 1;
@@ -1766,6 +1778,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
 					if (dy < 0) dy = 2;
 					else if (dy > 0) dy = -2;
 				}
+#endif
 				md->next_walktime = tick + 500;
 				mob_walktoxy (md, md->bl.x+dx, md->bl.y+dy, 0);
 				return 0;

+ 4 - 0
src/map/pc.c

@@ -3316,7 +3316,11 @@ int pc_setpos(struct map_session_data *sd,unsigned short mapindex,int x,int y,in
 	if(x <0 || x >= map[m].xs || y <0 || y >= map[m].ys)
 		x=y=0;
 	if((x==0 && y==0) ||
+#ifndef CELL_NOSTACK
 		(map_getcell(m,x,y,CELL_CHKNOPASS) && !map_getcell(m, x, y, CELL_CHKICEWALL))
+#else
+		(map_getcell(m,x,y,CELL_CHKNOPASS) && !map_getcell(m, x, y, CELL_CHKICEWALL) && !map_getcell(m, x, y, CELL_CHKSTACK))
+#endif
 	){ //We allow placing players on top of an ICEWALL tile to prevent force-warping players when an ice wall is placed 
 		//at spawn points from warps and the like. [Skotlex]
 		if(x||y) {

+ 1 - 0
src/map/skill.c

@@ -3079,6 +3079,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
 				}
 				return skill_castend_damage_id (src, bl, skillid, skilllv, tick, flag);
 			}
+			break;
 		case NPC_SMOKING: //Since it is a self skill, this one ends here rather than in damage_id. [Skotlex]
 			return skill_castend_damage_id (src, bl, skillid, skilllv, tick, flag);
 		case CR_GRANDCROSS: