Forum

> > CS2D > Scripts > Tile Modifier Details
Forums overviewCS2D overview Scripts overviewLog in to reply

English Tile Modifier Details

4 replies
To the start Previous 1 Next To the start

old Tile Modifier Details

Dousea
User Off Offline

Quote
PARTIALLY SOLVED
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Well, I experimented a map file which used modifiers for about 3 hours. I got something of course.
1
2
3
4
5
6
1 byte = tile with right rotation
2 bytes = tile with down rotation
3 bytes = tile with left rotation
4 bytes = each 10% brightness for tile
64 bytes = tile blend
128 bytes = tile color
The byte of "tile modifier at that map position" must be decreased by the bytes above. Example of usage.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- BYTE tile modifier at that map position

if (modifier > 0) then
	if (modifier >= 128) then
		-- BYTE tile color red
		-- BYTE tile color green
		-- BYTE tile color blue
		-- BYTE tile overlay frame
		modifier = modifier - 128
	end
	
	if (modifier >= 64) then
		-- BYTE frame for tile modification
		modifier = modifier - 64
	end
	
	if (modifier > 0) then
		for rotationindex = 1, 3 do
			if ((modifier - rotationindex) % 4 == 0) then
				rotation = rotationindex
				-- 0 = up, 1 = right, 2 = down, 3 = left
				modifier = modifier - rotationindex
			end
		end
	end
	
	if (modifier >= 4) then
		brightness = modifier / 4 * 10
	end
end
What I don't understand are overlay frame and frame for tile modification which are the ones that I can't figure it out.

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

I don't understand many things below.
CS2D specification map format has written
BYTE tile modifier at that map position
     Depending on the value of that byte there can be additional stuff saved:
     If the bits for the values 64 OR 128 are 1 in that byte:
          If the bits for 64 AND 128 are 1
               STRING - unused -
          Else If the bit for 64 is 1 and the bit for 128 is 0:
               BYTE frame for tile modification
          Else (the bit for 64 is 0 and the bit for 128 is 1):
               BYTE tile color red
               BYTE tile color green
               BYTE tile color blue
               BYTE tile overlay frame

Can someone (especially user DC) explain how tile modifier works in the map file with details? Or should I ignore the tile modifier because "the following stuff is not used in current versions at all but should be implemented for compatibility with future versions"?
edited 2×, last 01.05.15 07:05:12 pm

old Re: Tile Modifier Details

Hajt
User Off Offline

Quote
Yeah I know that this thread was created 559 days ago but my problem is very similar. Well I'm kinda confused because of modifiers. I have no idea how this should looks. Here's the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
if modifiers == 1 then
	modifier = ReadByte(stream)
	if (modifier >= 128) then
		ReadByte(stream)
		ReadByte(stream)
		ReadByte(stream)
		ReadByte(stream)
		modifier = modifier - 128
	end

	if (modifier >= 64) then
		ReadByte(stream)
		modifier = modifier - 64
	end

	if (modifier > 0) then
		for rotationindex = 1, 3 do
			if ((modifier - rotationindex) % 4 == 0) then
				rotation = rotationindex
				-- 0 = up, 1 = right, 2 = down, 3 = left
				modifier = modifier - rotationindex
			end
		end
	end

	if (modifier >= 4) then
		brightness = modifier / 4 * 10
	end
end

old Re: Tile Modifier Details

VADemon
User Off Offline

Quote
+UseMapModifiers:
me has written
<BYTE Tile Index><BYTE Tile Modifier>

If <BYTE Tile Modifier> == 11****** or 10****** or 01****** then
     If 11****** then
          <STRING Unused>
     Elseif 01****** then
          <BYTE frame for tile modification>
     Elseif 10****** then
          <BYTE tile color red>
          <BYTE tile color green>
          <BYTE tile color blue>
          <BYTE tile overlay frame>
     End
End

Checking single bit values is not as simple as comparing "more/less than, equals"
I used to disassemble the byte into bits starting with the most significant bit.

https://ricilake.blogspot.de/2007/10/iterating-bits-in-lua.html
edited 1×, last 11.11.16 12:37:00 am

old Re: Tile Modifier Details

Dousea
User Off Offline

Quote
@user Hajt: Damn, you just recovered a really-really old thread that had no reply. What kind of problem you're facing? If you're confused with the modifiers you can check file cs2d [OR] Get Map Data 2.0 as reference.

@user VADemon: Well, I use "equal/more than" conditions for the bit values and it does its job wonderfully. I do understand that this is not the correct way to check bit values but it's the easiest way to do it.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview