English How to add altitude to maps?

23 replies
Goto Page
To the start Previous 1 2 Next To the start
01.02.15 02:07:09 pm
Up
Pagyra
User
Offline Off
IMG:http://1.bp.blogspot.com/-d2jIdngficg/UCKdvKQI2RI/AAAAAAAAAA4/WTE9ujIRS9w/s1600/Depth%2BExample.png

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

IMG:http://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
01.02.15 02:29:32 pm
Up
Rainoth
Moderator
Offline Off
So what's your point? Also, how is this related to scripts?
01.02.15 02:38:15 pm
Up
Pagyra
User
Offline Off
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
01.02.15 04:09:28 pm
Up
Alistaire
User
Offline Off
"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.
IMG:http://i.imgur.com/5zhwOTP.png
01.02.15 08:53:19 pm
Up
Pagyra
User
Offline Off
in other word you dont know how do it.
02.02.15 07:08:40 am
Up
MikuAuahDark
User
Offline Off
You can use 2D array(for x,y in tile) and store the altitude value at there.
file cs2d LuaJIT for Dedicated Server (9) JIT POWER! | Know your Lua errors! | don't use PM for scripting help!
02.02.15 08:44:42 am
Up
Pagyra
User
Offline Off
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.
02.02.15 11:46:16 am
Up
Ortimh
User
Offline Off
Code:
1
2
3
4
5
6
altitudetiles = {{[[X, Y, HEIGHT]]}}
playerheight = {}

for id = 1, 32 do
     playerheight[id] = 0
end

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
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
I'm awesome ... and I really cookies
02.02.15 11:46:43 am
Up
MikuAuahDark
User
Offline Off
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).
file cs2d LuaJIT for Dedicated Server (9) JIT POWER! | Know your Lua errors! | don't use PM for scripting help!
02.02.15 12:20:02 pm
Up
Pagyra
User
Offline Off
@user Ortimh:
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.
02.02.15 12:34:54 pm
Up
Ortimh
User
Offline Off
Is it FPS down lag or internet connection lag?
I'm awesome ... and I really cookies
02.02.15 12:37:44 pm
Up
Pagyra
User
Offline Off
in internet connection lag and in situation when player moving from tile to tile - then player sometimes causes "fall" damage.
03.02.15 12:50:36 pm
Up
Nekomata
User
Offline Off
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
14.04.15 01:07:38 pm
Up
Pagyra
User
Offline Off
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:http://s017.radikal.ru/i423/1504/0e/ac6799391d2b.png

So on seamless background it look like this:
IMG:http://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
14.04.15 05:16:50 pm
Up
Captione
User
Offline Off
God user Pagyra! Your idea is brilliant! CS2D is lacking perception of depth. You should suggest your idea to DC.
14.04.15 05:22:46 pm
Up
Fraizeraust
Moderator
Offline Off
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).
14.04.15 05:27:04 pm
Up
Infinite Rain
Reviewer
Offline Off
user DC is too lazy to implement this anyway. Don't get your hopes high.
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
14.04.15 05:29:10 pm
Up
Captione
User
Offline Off
@user Fraizeraust: If user DC agreed to this, mapmakers will be making maps with more options from CQB battles to large-scale landscape battlefields.
@user Infinite Rain: Then I could wait for Stranded 3. After that, ill just wait for DC to implement this nice feature.
05.05.15 04:02:25 pm
Up
Pagyra
User
Offline Off
Anyway, I think it would be extremely unusual for CS2D.
05.05.15 04:12:10 pm
Up
Fraizeraust
Moderator
Offline Off
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