Browse Source

ENTITY REWRITE: added bullet params

asiekierka 7 years ago
parent
commit
66389f4bed

+ 22
- 11
client/CraftrGameScreen.java View File

@@ -155,13 +155,28 @@ public class CraftrGameScreen extends CraftrScreen
155 155
 		{
156 156
 			for(int ix=0;ix<c.FULLGRID_W;ix++)
157 157
 			{
158
-			    t = blocks[ix+(iy*c.FULLGRID_W)];
159
-			    if(t != null)
160
-			    {
161
-				    c.DrawChar(ix<<4,iy<<4,(byte)t.getDrawnChar(),(byte)t.getDrawnColor());
162
-				    if(t.isBullet()) c.DrawChar(ix<<4,iy<<4,(byte)248,(byte)15);
158
+				t = blocks[ix+(iy*c.FULLGRID_W)];
159
+				if(t != null)
160
+				{
161
+					c.DrawChar(ix<<4,iy<<4,(byte)t.getDrawnChar(),(byte)t.getDrawnColor());
162
+					if(t.isBullet())
163
+						switch(t.getBullet())
164
+						{
165
+							case 1:
166
+							case 2:
167
+							case 3:
168
+							case 4:
169
+								c.DrawChar(ix<<4,iy<<4,(byte)248,(byte)15);
170
+								break;
171
+							case 5:
172
+								c.DrawChar(ix<<4,iy<<4,(byte)153,(byte)6);
173
+								break;
174
+							case 6:
175
+								c.DrawChar(ix<<4,iy<<4,(byte)227,(byte)0x0B);
176
+								break;
177
+						}
163 178
 				}else{
164
-				    c.DrawChar(ix<<4,iy<<4,(byte)177,(byte)0x08);
179
+					c.DrawChar(ix<<4,iy<<4,(byte)177,(byte)0x08);
165 180
 				}
166 181
 			}
167 182
 		}
@@ -314,7 +329,7 @@ public class CraftrGameScreen extends CraftrScreen
314 329
 		if(drawType == 2) bsmt=3;
315 330
 		else if(isArrow() && barselMode == 1) bsmt=4;
316 331
 		else if(drawType == 17) bsmt=5;
317
-		else if(drawType >= 21 && drawType <= 23) bsmt=0;
332
+		else if(drawType >= 21 && drawType <= 22) bsmt=0;
318 333
 		if((drawType == 3 || drawType ==20)&& (gdrawChr()<24 || gdrawChr()>=28)) sdrawChr(25);
319 334
 		else if(drawType == 15 && !(gdrawChr()==30 || gdrawChr()==31 || gdrawChr()==16 || gdrawChr()==17)) sdrawChr(31);
320 335
 		else if(drawType==4) sdrawChr(206);
@@ -329,10 +344,6 @@ public class CraftrGameScreen extends CraftrScreen
329 344
 			sdrawCol(0x06);
330 345
 			sdrawChr(153);
331 346
 		} else if (drawType == 22)
332
-		{
333
-			sdrawCol(0x0D);
334
-			sdrawChr(5);
335
-		} else if (drawType == 23)
336 347
 		{
337 348
 			sdrawCol(0x0B);
338 349
 			sdrawChr(227);

+ 15
- 7
common/CraftrBlock.java View File

@@ -6,9 +6,9 @@ public class CraftrBlock
6 6
 {
7 7
 	public int x = 0;
8 8
 	public int y = 0;
9
-	private byte[] block = new byte[7];
10
-	public static final int maxType = 23;
11
-	public static final int invalidTypes = 3;
9
+	private byte[] block = new byte[8];
10
+	public static final int maxType = 22;
11
+	public static final int invalidTypes = 2;
12 12
 	public static Random rand = new Random();
13 13
 
14 14
 	public CraftrBlock()
@@ -102,6 +102,16 @@ public class CraftrBlock
102 102
 		block[6]=t;
103 103
 	}
104 104
 
105
+	public int getBulletParam()
106
+	{
107
+		return 0xFF&(int)block[7];
108
+	}
109
+
110
+	public void setBulletParam(byte t)
111
+	{
112
+		block[7] = t;
113
+	}
114
+
105 115
 	public int getType()
106 116
 	{
107 117
 		return 0xFF&(int)block[0];
@@ -185,7 +195,7 @@ public class CraftrBlock
185 195
 
186 196
 	public static int getBDSize()
187 197
 	{
188
-		return 7;
198
+		return 8;
189 199
 	}
190 200
 
191 201
 	public byte[] getBlockData()
@@ -195,7 +205,7 @@ public class CraftrBlock
195 205
 
196 206
 	public static boolean isPlaceable(int t)
197 207
 	{
198
-		return !(t == 16 || t==18 || t==22);
208
+		return !(t == 16 || t==18);
199 209
 	}
200 210
 
201 211
 	public boolean isPlaceable()
@@ -252,8 +262,6 @@ public class CraftrBlock
252 262
 			case 21:
253 263
 				return "Bear";
254 264
 			case 22:
255
-				return "Ruffian";
256
-			case 23:
257 265
 				return "Tiger";
258 266
 			case -1:
259 267
 				return "Pushium";

+ 23
- 6
common/CraftrChunk.java View File

@@ -12,6 +12,7 @@ public class CraftrChunk {
12 12
 	public byte[] colp;
13 13
 	public byte[] chr2;
14 14
 	public byte[] col2;
15
+	public byte[] bullpar;
15 16
 	public byte[] mapinfo;
16 17
 
17 18
 	public int w;
@@ -37,6 +38,7 @@ public class CraftrChunk {
37 38
 		col2 = new byte[64*64];
38 39
 		chrp = new byte[64*64];
39 40
 		colp = new byte[64*64];
41
+		bullpar = new byte[64*64];
40 42
 		mapinfo = new byte[4096];
41 43
 		w = 64;
42 44
 		h = 64;
@@ -51,17 +53,21 @@ public class CraftrChunk {
51 53
 	{
52 54
 		// i love arraycopy, and all its mysteries!
53 55
 		// boom de yada, boom de yada...
56
+		int ver = rawdata[0];
57
+		int dec = 0;
54 58
 		System.arraycopy(rawdata,1+hdrsize,type,0,4096);
55 59
 		System.arraycopy(rawdata,1+hdrsize+4096,param,0,8192);
56 60
 		System.arraycopy(rawdata,1+hdrsize+(4096*3),chr,0,8192);
57 61
 		System.arraycopy(rawdata,1+hdrsize+(4096*5),col,0,8192);
58 62
  		System.arraycopy(rawdata,1+hdrsize+(4096*7),chrp,0,4096);
59 63
  		System.arraycopy(rawdata,1+hdrsize+(4096*8),colp,0,4096);
64
+ 		if(ver == 5) System.arraycopy(rawdata,1+hdrsize+(4096*9),bullpar,0,4096);
65
+		else dec = 4096;
60 66
 		byte[] tmp = new byte[2];
61 67
 		System.arraycopy(rawdata,4,tmp,0,2);
62 68
 		mapinfo_len = CraftrConvert.arrShort(tmp);
63 69
 		mapinfo_type = rawdata[3];
64
-		if(mapinfo_len > 0 && mapinfo_type > 0) System.arraycopy(rawdata,1+hdrsize+(4096*9),mapinfo,0,mapinfo_len);
70
+		if(mapinfo_len > 0 && mapinfo_type > 0) System.arraycopy(rawdata,1+hdrsize+(4096*10)-dec,mapinfo,0,mapinfo_len);
65 71
 		spawnX = rawdata[1];
66 72
 		spawnY = rawdata[2];
67 73
 		fixDisplay();
@@ -74,15 +80,16 @@ public class CraftrChunk {
74 80
 
75 81
 	public byte[] saveByte()
76 82
 	{
77
-		byte[] out = new byte[(4096*10)+1+hdrsize];
83
+		byte[] out = new byte[(4096*11)+1+hdrsize];
78 84
 		System.arraycopy(type,0,out,1+hdrsize,4096);
79 85
 		System.arraycopy(param,0,out,4096+1+hdrsize,8192);
80 86
 		System.arraycopy(chr,0,out,(4096*3)+1+hdrsize,8192);
81 87
 		System.arraycopy(col,0,out,(4096*5)+1+hdrsize,8192);
82 88
  		System.arraycopy(chrp,0,out,(4096*7)+1+hdrsize,4096);
83 89
  		System.arraycopy(colp,0,out,(4096*8)+1+hdrsize,4096);
84
-		System.arraycopy(mapinfo,0,out,(4096*9)+1+hdrsize,4096);
85
-		out[0] = 4; // version
90
+ 		System.arraycopy(bullpar,0,out,(4096*9)+1+hdrsize,4096);
91
+		System.arraycopy(mapinfo,0,out,(4096*10)+1+hdrsize,4096);
92
+		out[0] = 5; // version
86 93
 		out[1] = (byte)spawnX;
87 94
 		out[2] = (byte)spawnY;
88 95
 		out[3] = (byte)mapinfo_type;
@@ -141,7 +148,7 @@ public class CraftrChunk {
141 148
 	}
142 149
 	public byte[] getBlock(int x, int y)
143 150
 	{
144
-		byte[] data = new byte[7];
151
+		byte[] data = new byte[8];
145 152
 		int p = x+(y<<6);
146 153
 		data[0] = type[p];
147 154
 		data[1] = param[p];
@@ -150,6 +157,7 @@ public class CraftrChunk {
150 157
 		data[4] = chrp[p];
151 158
 		data[5] = colp[p];
152 159
 		data[6] = getBullet(x,y);
160
+		data[7] = bullpar[p];
153 161
 		return data;
154 162
 	}
155 163
 	public byte getBlockType(int x, int y)
@@ -185,10 +193,19 @@ public class CraftrChunk {
185 193
 	public byte getBullet(int x, int y)
186 194
 	{
187 195
 		return param[4096+x+(y<<6)];
188
-	}	
196
+	}
197
+	public byte getBulletParam(int x, int y)
198
+	{
199
+		return bullpar[x+(y<<6)];
200
+	}		
189 201
 	public void placeBullet(int x, int y, byte aType)
202
+	{
203
+		placeBullet(x,y,aType,(byte)0);
204
+	}	
205
+	public void placeBullet(int x, int y, byte aType, byte aPar)
190 206
 	{
191 207
 		param[4096+x+(y<<6)]=aType;
208
+		bullpar[x+(y<<6)]=aPar;
192 209
 	}
193 210
 	public void place(int x, int y, byte aType, byte aChr, byte aCol, byte aPar)
194 211
 	{

+ 17
- 12
common/CraftrMap.java View File

@@ -237,9 +237,9 @@ public class CraftrMap
237 237
 			int hdrsize = CraftrChunk.hdrsize;
238 238
 			switch(buf[0])
239 239
 			{
240
-				case 3:
241
-					out = new byte[1+(4096*10)+hdrsize];
242
-					while(i<(1+(4096*8)+hdrsize) && i>-1) i += gin.read(out,i,(1+(4096*8)+hdrsize)-i);
240
+				case 4:
241
+					out = new byte[1+(4096*11)+hdrsize];
242
+					while(i<(1+(4096*10)+hdrsize) && i>-1) i += gin.read(out,i,out.length-i);
243 243
 					gin.close();
244 244
 					for(int ri=0;ri<4096;ri++)
245 245
 					{
@@ -248,13 +248,13 @@ public class CraftrMap
248 248
 							out[1+ri+hdrsize+4096]=(byte)1;
249 249
 							physics.addBlockToCheck(new CraftrBlockPos(x*64+(ri&63),y*64+(ri>>6)));
250 250
 						}
251
-						else if(physics.isReloaded(out[1+ri+hdrsize]))
251
+						else if(physics.isReloaded(out[1+ri+hdrsize]) || out[1+ri+(4096*9)+hdrsize] != 0)
252 252
 							physics.addBlockToCheck(new CraftrBlockPos(x*64+(ri&63),y*64+(ri>>6)));
253 253
 					}
254 254
 					return out;
255
-				case 4:
256
-					out = new byte[1+(4096*10)+hdrsize];
257
-					while(i<(1+(4096*10)+hdrsize) && i>-1) i += gin.read(out,i,out.length-i);
255
+				case 5:
256
+					out = new byte[1+(4096*11)+hdrsize];
257
+					while(i<(1+(4096*11)+hdrsize) && i>-1) i += gin.read(out,i,out.length-i);
258 258
 					gin.close();
259 259
 					for(int ri=0;ri<4096;ri++)
260 260
 					{
@@ -263,9 +263,8 @@ public class CraftrMap
263 263
 							out[1+ri+hdrsize+4096]=(byte)1;
264 264
 							physics.addBlockToCheck(new CraftrBlockPos(x*64+(ri&63),y*64+(ri>>6)));
265 265
 						}
266
-						else if(physics.isReloaded(out[1+ri+hdrsize]))
266
+						else if(physics.isReloaded(out[1+ri+hdrsize]) || out[1+ri+(4096*9)+hdrsize] != 0)
267 267
 							physics.addBlockToCheck(new CraftrBlockPos(x*64+(ri&63),y*64+(ri>>6)));
268
-
269 268
 					}
270 269
 					return out;
271 270
 				default:
@@ -403,14 +402,17 @@ public class CraftrMap
403 402
  			if(!multiplayer) System.exit(1);
404 403
 		}
405 404
 	}
406
-
407 405
  	public void setBullet(int x, int y, byte aType)
406
+	{
407
+		setBullet(x,y,aType,(byte)0);
408
+	}
409
+ 	public void setBullet(int x, int y, byte aType, byte aPar)
408 410
  	{
409 411
  		try
410 412
  		{ 
411 413
  			int px = x&63;
412 414
  			int py = y&63;
413
- 			grabChunk((x>>6),(y>>6)).placeBullet(px,py,aType);
415
+ 			grabChunk((x>>6),(y>>6)).placeBullet(px,py,aType, aPar);
414 416
  		}
415 417
 		catch(Exception e)
416 418
 		{
@@ -419,7 +421,10 @@ public class CraftrMap
419 421
  			if(!multiplayer) System.exit(1);
420 422
 		}
421 423
 	}
422
-
424
+	public void setBulletNet(int x, int y, byte aType, byte aPar)
425
+	{
426
+		setBulletNet(x,y,aType);
427
+	}
423 428
 	public void setBulletNet(int x, int y, byte aType)
424 429
 	{
425 430
 		try

+ 5
- 1
common/CraftrPhysics.java View File

@@ -198,7 +198,7 @@ public class CraftrPhysics
198 198
 			}
199 199
 		}
200 200
 		// Bullet code
201
-		if(changeBullets && blockData[6]!=0)
201
+		if(changeBullets && blockData[6]>0 && blockData[6]<=4)
202 202
 		{
203 203
 			boolean bshot = false;
204 204
 			for(int i=0;i<256;i++)
@@ -249,6 +249,10 @@ public class CraftrPhysics
249 249
 			blockO.setBullet((byte)0);
250 250
 			addBlockToSet(blockO);
251 251
 			addBlockToCheck(new CraftrBlockPos(blockO.x,blockO.y));
252
+		}
253
+		else if(!changeBullets && blockData[6]==5)
254
+		{
255
+
252 256
 		}
253 257
 		else if(!changeBullets && blockData[6]!=0)
254 258
 		{

+ 1
- 1
common/CraftrVersion.java View File

@@ -7,7 +7,7 @@ public class CraftrVersion
7 7
 	private static final int majorVer = 2;
8 8
 	private static final int minorVer = 0;
9 9
 	private static final int patchVer = 0;
10
-	private static final String addon = "-b0-git";
10
+	private static final String addon = "-beta1";
11 11
 	//private static final String addon = "";
12 12
 	public CraftrVersion()
13 13
 	{

+ 1
- 1
config.txt View File

@@ -4,5 +4,5 @@ tp-for-all=1
4 4
 port=25566
5 5
 private-mode=0
6 6
 name=[0.2] BETATESTING
7
-spawn-x=0
7
+spawn-x=1
8 8
 spawn-y=3

Loading…
Cancel
Save