Jump to content
  • 0

Need help with cell_mobnopass old diff


Bartender

Question


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  6
  • Reputation:   0
  • Joined:  09/13/16
  • Last Seen:  

Hi,

Could someone help me to convert this old diff to make it compatible with last git please? When I try to do it mob have glitch when they walk on cell.

Index: db/const.txt
===================================================================
--- db/const.txt	(revision 14075)
+++ db/const.txt	(working copy)
@@ -232,6 +232,7 @@
 cell_landprotector	5
 cell_novending	6
 cell_nochat	7
+cell_nomobpass	8
 
 //cell_gettype	0
 cell_chkwall	1
Index: src/map/battle.c
===================================================================
--- src/map/battle.c	(revision 14075)
+++ src/map/battle.c	(working copy)
@@ -3428,7 +3428,7 @@
  *------------------------------------------*/
 bool battle_check_range(struct block_list *src, struct block_list *bl, int range)
 {
-	int d;
+	int d, CHK_Type;
 	nullpo_retr(false, src);
 	nullpo_retr(false, bl);
 
@@ -3453,7 +3453,12 @@
 	if( d > AREA_SIZE )
 		return false; // Avoid targetting objects beyond your range of sight.
 
-	return path_search_long(NULL,src->m,src->x,src->y,bl->x,bl->y,CELL_CHKWALL);
+	if (src->type == BL_MOB)
+		CHK_Type = CELL_CHKMOBWALL;
+	else
+		CHK_Type = CELL_CHKWALL;
+
+	return path_search_long(NULL,src->m,src->x,src->y,bl->x,bl->y,CHK_Type);
 }
 
 static const struct _battle_data {
Index: src/map/map.c
===================================================================
--- src/map/map.c	(revision 14075)
+++ src/map/map.c	(working copy)
@@ -1247,7 +1247,7 @@
  *------------------------------------------*/
 int map_search_freecell(struct block_list *src, int m, short *x,short *y, int rx, int ry, int flag)
 {
-	int tries, spawn=0;
+	int tries, CHK_Type, spawn=0;
 	int bx, by;
 	int rx2 = 2*rx+1;
 	int ry2 = 2*ry+1;
@@ -1258,6 +1258,11 @@
 		return 0;
 	}
 
+	if ((src && src->type == BL_MOB) || !src) //Assume null source = mob... probably not a good idea
+		CHK_Type = CELL_CHKMOBPASS;
+	else
+		CHK_Type = CELL_CHKREACH;
+
 	if (flag&1) {
 		bx = *x;
 		by = *y;
@@ -1270,7 +1275,7 @@
 		//No range? Return the target cell then....
 		*x = bx;
 		*y = by;
-		return map_getcell(m,*x,*y,CELL_CHKREACH);
+		return map_getcell(m,*x,*y,CHK_Type);
 	}
 	
 	if (rx >= 0 && ry >= 0) {
@@ -1288,7 +1293,7 @@
 		if (*x == bx && *y == by)
 			continue; //Avoid picking the same target tile.
 		
-		if (map_getcell(m,*x,*y,CELL_CHKREACH))
+		if (map_getcell(m,*x,*y,CHK_Type))
 		{
 			if(flag&2 && !unit_can_reach_pos(src, *x, *y, 1))
 				continue;
@@ -2328,6 +2333,8 @@
 		case CELL_GETTYPE:
 			return map_cell2gat(cell);
 
+		case CELL_CHKMOBWALL:
+			if (cell.nomobpass && !cell.shootable) return 1;
 		// base gat type checks
 		case CELL_CHKWALL:
 			return (!cell.walkable && !cell.shootable);
@@ -2352,6 +2359,9 @@
 			return (cell.nochat);
 
 		// special checks
+		case CELL_CHKMOBPASS:
+
+			if (cell.nomobpass == 1) return 0;
 		case CELL_CHKPASS:
 #ifdef CELL_NOSTACK
 			if (cell.cell_bl >= battle_config.cell_stack_limit) return 0;
@@ -2359,6 +2369,8 @@
 		case CELL_CHKREACH:
 			return (cell.walkable);
 
+		case CELL_CHKMOBNOPASS:
+			if (cell.nomobpass == 1) return 1;
 		case CELL_CHKNOPASS:
 #ifdef CELL_NOSTACK
 			if (cell.cell_bl >= battle_config.cell_stack_limit) return 1;
@@ -2402,6 +2414,7 @@
 		case CELL_LANDPROTECTOR: map[m].cell[j].landprotector = flag; break;
 		case CELL_NOVENDING:     map[m].cell[j].novending = flag;     break;
 		case CELL_NOCHAT:        map[m].cell[j].nochat = flag;        break;
+		case CELL_NOMOBPASS:     map[m].cell[j].nomobpass = flag;     break;
 		default:
 			ShowWarning("map_setcell: invalid cell type '%d'\n", (int)cell);
 			break;
Index: src/map/map.h
===================================================================
--- src/map/map.h	(revision 14075)
+++ src/map/map.h	(working copy)
@@ -349,6 +349,7 @@
 	CELL_LANDPROTECTOR,
 	CELL_NOVENDING,
 	CELL_NOCHAT,
+	CELL_NOMOBPASS,
 } cell_t;
 
 // used by map_getcell()
@@ -370,6 +371,9 @@
 	CELL_CHKLANDPROTECTOR,
 	CELL_CHKNOVENDING,
 	CELL_CHKNOCHAT,
+	CELL_CHKMOBPASS,	// Passable by monsters, Check CELL_NOMOB then work as CELL_CHKPASS [Orcao]
+	CELL_CHKMOBNOPASS,	// Used like the other No checks... seems redundant
+	CELL_CHKMOBWALL,	// Mob version of CHKWALL... 
 } cell_chk;
 
 struct mapcell
@@ -386,7 +390,8 @@
 		basilica : 1,
 		landprotector : 1,
 		novending : 1,
-		nochat : 1;
+		nochat : 1,
+		nomobpass : 1;
 
 #ifdef CELL_NOSTACK
 	unsigned char cell_bl; //Holds amount of bls in this cell.
Index: src/map/mob.c
===================================================================
--- src/map/mob.c	(revision 14075)
+++ src/map/mob.c	(working copy)
@@ -382,7 +382,7 @@
 		map_search_freecell(bl, m, &x, &y, 1, 1, 0);
 
 	// if none found, pick random position on map
-	if (x <= 0 || y <= 0 || map_getcell(m,x,y,CELL_CHKNOREACH))
+	if (x <= 0 || y <= 0 || map_getcell(m,x,y,CELL_CHKMOBNOPASS))
 		map_search_freecell(NULL, m, &x, &y, -1, -1, 1);
 	
 	data.x = x;
@@ -477,7 +477,7 @@
 			x = rand()%(x1-x0+1)+x0;
 			y = rand()%(y1-y0+1)+y0;
 			j++;
-		} while( map_getcell(m,x,y,CELL_CHKNOPASS) && j < max );
+		} while( map_getcell(m,x,y,CELL_CHKMOBNOPASS) && j < max );
 
 		if( j == max )
 		{// attempt to find an available cell failed
@@ -1230,7 +1230,7 @@
 		x+=md->bl.x;
 		y+=md->bl.y;
 
-		if((map_getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit_walktoxy(&md->bl,x,y,1)){
+		if((map_getcell(md->bl.m,x,y,CELL_CHKMOBPASS)) && unit_walktoxy(&md->bl,x,y,1)){
 			break;
 		}
 	}
Index: src/map/pc.c
===================================================================
--- src/map/pc.c	(revision 14075)
+++ src/map/pc.c	(working copy)
@@ -4032,10 +4032,15 @@
  *------------------------------------------*/
 int pc_randomwarp(struct map_session_data *sd, int type)
 {
-	int x,y,i=0;
+	int x,y,CHK_Type,i=0;
 	int m;
 
 	nullpo_retr(0, sd);
 
 	m=sd->bl.m;
 
+	if (sd->bl.type == BL_MOB)
+		CHK_Type = CELL_CHKMOBNOPASS;
+	else
+		CHK_Type = CELL_CHKNOPASS;
+
@@ -4045,7 +4050,7 @@
 	do{
 		x=rand()%(map[m].xs-2)+1;
 		y=rand()%(map[m].ys-2)+1;
-	}while(map_getcell(m,x,y,CELL_CHKNOPASS) && (i++)<1000 );
+	}while(map_getcell(m,x,y,CHK_Type) && (i++)<1000 );
 
 	if (i < 1000)
 		return pc_setpos(sd,map[sd->bl.m].index,x,y,type);
Index: src/map/unit.c
===================================================================
--- src/map/unit.c	(revision 14075)
+++ src/map/unit.c	(working copy)
@@ -55,15 +55,20 @@
 
 int unit_walktoxy_sub(struct block_list *bl)
 {
-	int i;
+	int i, CHK_Type;
 	struct walkpath_data wpd;
 	struct unit_data *ud = NULL;
 
 	nullpo_retr(1, bl);
 	ud = unit_bl2ud(bl);
 	if(ud == NULL) return 0;
+	
+	if (bl->type == BL_MOB)
+		CHK_Type = CELL_CHKMOBNOPASS;
+	else
+		CHK_Type = CELL_CHKNOPASS;
 
-	if( !path_search(&wpd,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CELL_CHKNOPASS) )
+	if( !path_search(&wpd,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CHK_Type) )
 		return 0;
 
 	memcpy(&ud->walkpath,&wpd,sizeof(wpd));
@@ -565,6 +570,7 @@
 //it respects the no warp flags, so it is safe to call this without doing nowarpto/nowarp checks.
 int unit_warp(struct block_list *bl,short m,short x,short y,int type)
 {
+	int CHK_Type;
 	struct unit_data *ud;
 	nullpo_retr(0, bl);
 	ud = unit_bl2ud(bl);
@@ -585,10 +591,13 @@
 				return 1;
 			if (m != bl->m && map[m].flag.nobranch && battle_config.mob_warp&4)
 				return 1;
+			CHK_Type = CELL_CHKMOBNOPASS;
 			break;
 		case BL_PC:
 			if (map[bl->m].flag.noteleport)
 				return 1;
+		default:
+			CHK_Type = CELL_CHKNOREACH;
 			break;
 	}
 	
@@ -599,7 +608,7 @@
 			return 2;
 			
 		}
-	} else if (map_getcell(m,x,y,CELL_CHKNOREACH))
+	} else if (map_getcell(m,x,y,CHK_Type))
 	{	//Invalid target cell
 		ShowWarning("unit_warp: Specified non-walkable target cell: %d (%s) at [%d,%d]\n", m, map[m].name, x,y);
 		
@@ -1342,4 +1351,5 @@
  *------------------------------------------*/
 bool unit_can_reach_pos(struct block_list *bl,int x,int y, int easy)
 {
+	int CHK_Type;
 	nullpo_retr(false, bl);
@@ -1350,2 +1360,7 @@
-	return path_search(NULL,bl->m,bl->x,bl->y,x,y,easy,CELL_CHKNOREACH);
+	if (bl->type == BL_MOB)
+		CHK_Type = CELL_CHKMOBNOPASS;
+	else
+		CHK_Type = CELL_CHKNOREACH;
+
+	return path_search(NULL,bl->m,bl->x,bl->y,x,y,easy,CHK_Type);
 }
@@ -1355,7 +1370,7 @@
  *------------------------------------------*/
 bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y)
 {
-	int i;
+	int i, CHK_Type;
 	short dx,dy;
 	nullpo_retr(false, bl);
 	nullpo_retr(false, tbl);
@@ -1375,9 +1390,16 @@
 	dx=(dx>0)?1:((dx<0)?-1:0);
 	dy=(dy>0)?1:((dy<0)?-1:0);
 	
-	if (map_getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOPASS))
+	if(bl->type != BL_MOB){
+		CHK_Type = CELL_CHKNOPASS;
+	}
+	else{
+		CHK_Type = CELL_CHKMOBNOPASS;
+	}
+
+	if (map_getcell(tbl->m,tbl->x-dx,tbl->y-dy,CHK_Type))
 	{	//Look for a suitable cell to place in.
-		for(i=0;i<9 && map_getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOPASS);i++);
+		for(i=0;i<9 && map_getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CHK_Type);i++);
 		if (i==9) return false; //No valid cells.
 		dx = dirx[i];
 		dy = diry[i];
@@ -1385,7 +1407,7 @@
 
 	if (x) *x = tbl->x-dx;
 	if (y) *y = tbl->y-dy;
-	return path_search(NULL,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH);
+	return path_search(NULL,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CHK_Type);
 }
 /*==========================================
  * Calculates position of Pet/Mercenary/Homunculus

cell_mobnopassv01_workingdiff.diff

Edited by Bartender
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...