Forum

> > CS2D > Scripts > How to add altitude to maps?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to add altitude to maps?

23 replies
Page
To the start Previous 1 2 Next To the start

old How to add altitude to maps?

Pagyra
User Off Offline

Quote
IMG:https://1.bp.blogspot.com/-d2jIdngficg/UCKdvKQI2RI/AAAAAAAAAA4/WTE9ujIRS9w/s1600/Depth%2BExample.png

IMG:https://2.bp.blogspot.com/--_qjaFoX_8Y/UCK2gPOhS6I/AAAAAAAAABM/qNXWJWLGNBM/s320/Depth%2BExample%2B2.png

IMG:https://s020.radikal.ru/i715/1502/cf/bbdf42b8d8de.jpg


How to add altitude to maps?
like topological maps, if i add z coordinate
edited 1×, last 01.02.15 03:07:38 pm

old Re: How to add altitude to maps?

Pagyra
User Off Offline

Quote
hmm .. I ask for help in form of a piece of lua code to implement of this feature in my code.
because my version of this code is not ready and too far from final result and non-optimized.
It is inconvenient and cumbersome at my mind ... so I'd like to see someone else's view of solution to this problem - so probably if there is a better way then i can use it or i can do "hybrid"
edited 1×, last 01.02.15 03:12:40 pm

old Re: How to add altitude to maps?

Alistaire
User Off Offline

Quote
"How to add altitude to maps" is not a useful question. Be more specific in what you want exactly.

What kind of maps are we talking about anyways, what is your current code, etcetera.

old Re: How to add altitude to maps?

Pagyra
User Off Offline

Quote
Thank you good and adequate man)
At the moment I'm doing it in this way (it's the only solution that came to my mind ... but I think there is some other method) ... but anyway there is one problem - with a large number of players(more than 9 at my old computer) it causes some lags or glitches.

At the this moment I try to solve this problem by combining two types of solutions. Other one solution is adding additionaly check by tile types (as 1 tile = 1 height, 2 tile = 2 height, ... and so on). This reduces lags and glitches on tile, but there are still some problems at moment when player moving between tiles.... so problems is not completely solved.

old Re: How to add altitude to maps?

Dousea
User Off Offline

Quote
1
2
3
4
5
6
altitudetiles = {{[[X, Y, HEIGHT]]}}
playerheight = {}

for id = 1, 32 do
	playerheight[id] = 0
end
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
addhook("always", "alwayshook")
addhook("movetile", "movetilehook")

function alwayshook()
	for none, id in pairs(player(0, "tableliving")) do
		for none, tilevalue in pairs(altitudetiles) do
			if (player(id, "tilex") == tilevalue[1] and player(id, "tiley") == tilevalue[2]) then
				if (tilevalue[3] > playerheight[id]) then
					parse("setpos " .. id .. " " .. player(id, "x") .. " " .. player(id, "y"))
				end
			end
		end
	end
end

function movetilehook(id, tilex, tiley)
	for none, tilevalue in pairs(altitudetiles) do
		if (tilex == tilevalue[1] and tiley == tilevalue[2]) then
			if (tilevalue[3] < playerheight[id]) then
				playerheight[id] = tilevalue[3]
				
				if (tilevalue[3] <= -5) then
					parse("sethealth " .. id .. " " .. player(id, "health") - math.abs(tilevalue[3]) / 5))
				end
			end
		end
	end
end
Not sure about the setpos part. Also you can change the formula for the hurting part.

EDIT: Follow user MikuAuahDark's suggestion.
edited 1×, last 02.02.15 12:05:41 pm

old Re: How to add altitude to maps?

MikuAuahDark
User Off Offline

Quote
I think there should be nothing wrong. Maybe try with cs2d lua hook movetile and set the altitude value at there(for player)

If you want to read the value without editing the array, you can use 24-bit bitmap and read the altitude value at the image(just make sure that map("xsize")+1=image_size_x and map("ysize")+1=image_size_y)(i can provide more about this).

old Re: How to add altitude to maps?

Pagyra
User Off Offline

Quote
@user Dousea:
Thanks for this code) as i say earlier im already write it in thats way and use it, but it lags if there are more then 17 player or if its latency more then 143 ms(at my comp)
and i dont know how this code can be optimized for more performance.

@user MikuAuahDark:
Ohh... it is cool - plz if you can describe this version for me
so i think it can be solution for this problem.

old Re: How to add altitude to maps?

Pagyra
User Off Offline

Quote
in internet connection lag and in situation when player moving from tile to tile - then player sometimes causes "fall" damage.

old Re: How to add altitude to maps?

Nekomata
User Off Offline

Quote
You can create an illusion for it by using the tiles.
For example if he moves from the lighter tile (tile id 69) to the darker tile (tile id 96) it does "fall damage"

Idk the lua for it. But I think programmatically it would be capturing the last 5-10 tiles in arrays and checking the last 2.

Edit: To make the fall thing, I think it'd be best to create a little animation sequence for it by moving his coordinates slightly here and there and taking a bit off his hp if it's from a small fall using the idea you said of giving constants to tiles as how "high" they'd be.
If it's a walk from the tile with the height of 5 to the tile of 1 then it'd take off 50hp. If he walked from tile with the height of 1 to another tile with the height of 1 then it'd make no difference.
edited 1×, last 03.02.15 05:37:52 pm

old Re: How to add altitude to maps?

Pagyra
User Off Offline

Quote
I continue to think about adding altitude to maps and work on script and grapthics to create more quality illusion of different heights of tiles.
For example with using a black-and-white tileset and gradient transparency like this:
IMG:https://s017.radikal.ru/i423/1504/0e/ac6799391d2b.png

So on seamless background it look like this:
IMG:https://s019.radikal.ru/i607/1504/8d/b8af6d6ef875.png


Our eye perceives a light tone as closer and darker as more distant - so at expense of darker tiles are seen as more deep and expense of lighter tiles as more height.

Express and you ideas and opinions about it - so maybe it will be helpful.
I think this is a good idea to simulate landscape/relief for big maps, which are used for example in Tibia and in my mods).
edited 1×, last 14.04.15 01:18:46 pm

old Re: How to add altitude to maps?

GeoB99
Moderator Off Offline

Quote
Totally agreed with user Captione. Some of your ideas are pretty amazing, may DC will accept such things like this, so CS2D will be something a bit impressive (in my opinion).

old Re: How to add altitude to maps?

GeoB99
Moderator Off Offline

Quote
Did you searched this on Gamebanana the first wall image?
Because I searched a spray which it looks very similar like this. By the way, I agree too it looks like is not so usual for CS2D especially the first image.
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview