Scripts / Interactive map

Author
Message
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 15th Aug 2019 19:38
Hi all,
While not building my projects levels I have been helping my daughter level here character/guild in EQ2 and also collecting me 14 years veteran rewards lol yep been playing it that long with all the kids as they grew up
As I play it though it occasionally sparks some ideas the latest being this one so I thought I'd throw it out there see if you guys think its viable.
In Everquest you have a bell or a world port thingy which when you click it brings up a map then you can click on a part/area on that map to travel there.
So bringing up the map part after clicking your preferred travel thing I presume would just be a sprite of the map full screen, here's where the tricky part is I would think, being able to click certain parts of it and the jump to that level.
So what do you think? possible with GG? and any pointers on how I could tackle that part would be cool cheers
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
AMD Radeon 7570 1gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 15th Aug 2019 20:37 Edited at: 15th Aug 2019 20:38
Yes, work out the x,y screen coordinates for a box (i.e. bottom left corner/ top right corner) that fits around the things you want clickable and put them in a named list.
Then on a 'click' search the list to see which thing the mouse coordinates are 'inside' (if any) and use the name to select the level to jump to. (or possibly have the name map to another list containing x,z coordinates to move the player to)
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Aug 2019 23:37 Edited at: 15th Aug 2019 23:42
as amen says, we don't have access to anything other than percentages of the screen for 2D (no sprite click type detection) so you need to convert 3D space to 2D space.
thankfully this is quite simple with a fixed world size (GG is something like 51000x51000 iirc) so you just take your current x and z in the 3D world and divide by the max x & z then multiply by the percentage size of your map in screen space plus any offset if smaller than fullscreen, otherwise just multiply by 100.
i.e. if the point of interest is say; x:10,000 , z:20,000 you get a 2D position of rougly x: 20 , z: 40 or
x: 10k / 51k = 0.2 = 0.2*100 = 20
z: 20k / 51k = 0.4 = 0.4*100 = 40
so with a little wiggle room for the actual clickable area you get something like;
if g_MouseX >= 19 and g_MouseX <= 21 then
if g_MouseY >= 39 and g_MouseY <= 41 then
--mouse is in the correct area
end
end

as i mentioned above, if the map is smaller than fullscreen it's just a couple extra steps
first work out how big the map is on screen (i.e.what percentage of the screen it takes up), this is still easy in GG as sprite sizes are set in percentage so you can simply put the size of the sprite.
now workout the position of the map from the top left of the screen and put that into the calculation above (if the map is placed away from the top left corner)
i.e. if the map is centered on screen or set to bottom right etc the offset on the x & y will be different (again this is simply the placement of the sprite in GG assuming you use the top left of the sprite as the offset, if you change the sprite offset it will need to be calculated by size too - say you have your map centered at 50x50 and it is size of 80x60 your offsets would be x:10 , y:20
(because it is centered you have a gap of 10 either size on the x (or 100-80 = 20 / 2 = 10) and 20 either size on the y (100-60 = 40 / 2 = 20)
so to work out the new area using the 80x60 centered map you do (assuming the same 3D space)
10,000 / 51,000 = 0.2 * 80 = 16 + 10 = 26
20,000 / 51,000 = 0.4 * 60 = 24 + 20 = 44
(it's been a long time since i did any map logic but i'm 95% sure i'm remembering it right)

as you can see, in this example it doesn't make a huge difference because the map is still quite large on screen but smaller maps will make the mouse position % change faster so you will want to take that into consideration when making the area check allowance in the 'if' statements

note that this only works on maps you can see the entirety of at once... scrolling maps are a whole other problem

note2 that you could just skip all this and simply hard code the positions using visual feedback based on reported co-ords of the mouse as you move it over your map on screen but you would need to remember to update those every time you made a change or added something to your map or moved the map on screen etc, with the above method you can easily place some object in your GG level and have it report the 3D location and then you're free to move or relocate your POI as you wish with much easier edits to the script to compensate
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 16th Aug 2019 00:14 Edited at: 16th Aug 2019 00:15
Ok lol I knew this would be a little beyond me but thanks guys, I do however have the bit between my teeth on this one so I'll start with the map and then plug you two for help along the way if that's ok, I recon it'd be a nice thing to have for rpg games works really well in eq2.
p.s couldn't you just place a text name over the area and click that? ( I think that's sorta how it works in eq2) and kind of narrows it down to just the text.
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
AMD Radeon 7570 1gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th Aug 2019 12:15 Edited at: 16th Aug 2019 12:15
All you know when you 'click' is the x,y screen position of the mouse pointer.

Somehow you need to turn that into a name or id that can then be used to trigger different behaviours.

Once you have the sprite displayed on screen, write a small script that simply shows the x,y values on screen and then use that to identify all your trigger point values, e.g. top-left /bottom-right values. Write them all down with an identifying name then put them in a Lua list, something like:



Then you can create a function that returns the name given a specific x,y location:

Been there, done that, got all the T-Shirts!
PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 16th Aug 2019 13:22 Edited at: 16th Aug 2019 16:19
Ok just completed the map the places are actual screenshots of the map then jazzed up with paint .net. reading what you have put now AM cheers m8.
and still has room for expansion at a later date.
I was thinking it is a very similar idea to smallg's old teleport to other maps script (which I usually use for this type of game) although it doesn't use the map clicking it uses a menu




ok now to work on getting the map displayed.

I now have the map displaying but only on the distance check not via a keypress (slowly getting there lol)









and the final look of the map




Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
AMD Radeon 7570 1gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on

Attachments

Login to view attachments
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 16th Aug 2019 18:12
ah you want to change level in GG, sorry i missed that part - ignore my post about converting from 3D to 2D, i was thinking you wanted to port around the same GG map.
for a level selection type map it is simply a case of getting the correct co-ords (by displaying them when you move the mouse on screen) and putting those into the script
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 16th Aug 2019 20:36 Edited at: 16th Aug 2019 20:39


Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 17th Aug 2019 00:58 Edited at: 17th Aug 2019 01:06
@ 3 com wow ...lol confused
@ smallg yes m8 like your multi level script but by mouse click on the map via a world entity or a harbour bell etc can it be done (remember my scripting is limited and I need it in layman's terms)
again this is something I'm playing with as I saw it in eq2 and thought it was a pretty cool way to get around the rpg world, once I have the basics of it I can expand it to new areas.
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
AMD Radeon 7570 1gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 17th Aug 2019 04:43
Quote: "@ 3 com wow ...lol confused"







hth
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Aug 2019 15:55
Here is my take on it using a list as described previously.



The map isn't high enough resolution for me to read the names so I've just added 4 of them to the list and called them level1 - level4 but in reality you would use the actual names in the list.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 17th Aug 2019 17:09 Edited at: 17th Aug 2019 17:11
@ 3com and AM thank you guys they are perfect for me to get it all going really appreciate the help there. Now I better model a port bell or something @ AM yeah good point on the resolution will sort that now.
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
AMD Radeon 7570 1gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Aug 2019 17:20
One suggestion I would make is to have the clickable map items highlight in some way as you mouse over them, a simple rectangular sprite overlaying the trigger squares would work quite well.
Been there, done that, got all the T-Shirts!
PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 17th Aug 2019 20:26 Edited at: 17th Aug 2019 20:56
Just a quick question I have it so now the bell is on a distance check press (e) and freezes the player. Also the map is now full screen which poses the problem lol can't see the co-ordinates is there a way to display them over the map so I can record them on a full screen map and -- them out later?

Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
AMD Radeon 7570 1gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on

Attachments

Login to view attachments
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 17th Aug 2019 21:39



You can find the generated txt file in the Gameguru folder> Files> XY_List.txt
hth
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 18th Aug 2019 04:56
Well, maybe put a developers function into the script where when you press
the letter 'H' for example, the map is hidden, and the coordinates displayed
on screen. Release 'H' and map comes back. Just for tweaking the script...
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 19th Aug 2019 18:07
BTW, I also thought that it would be nice for a function of;
MouseSpotRGB() to return the RGB colors of the mouse coordinates.
How would that be useful?
If you have a unique color on your sprite, and the mouse discovers that color,
you know you are there.

So, looking at 3com's map-- there are the 3 color spots that we seek to trigger
the response, when MouseSpotRGB() finds that color, BAM. Done.

(("But there might be the same color at other parts of the screen")).
Okay, so a simplistic map designed right like you are using would help to
eliminate that. In fact, 256(3rd power) is a LOT of colors to work with!
That assumes you could match color in the same manner as the text color
is chosen...
Nice. Let's get that function-- Please!
Yeah, I know, this is more 1990's Qbasic functions talking..... !
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 19th Aug 2019 19:16
You are assuming the app knows what the colour is at a particular screen location but that information is going to be in the GPU, i.e. the actual colour on screen is going to depend on what shaders are in use plus what all the slider settings are, unless the sprite is set completely opaque in which case the colour *should* be the same as the colour of the image used to create the sprite but even then it is probably only going to work with solid colour fills.

The other problem you would have is that the script is being executed *before* anything is actually drawn to the screen.

Anyhow the script I posted isn't actually that complicated.

Been there, done that, got all the T-Shirts!
PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 20th Aug 2019 00:26 Edited at: 20th Aug 2019 00:28
lol I actually solved this with bluetack I just bluetacked the areas over a full screen map then shrunk the map to record them ….works fine only thing is you now cant see the name so as you suggested m8 maybe make it glow. But then me being me I thought hang on if we can have a sprite over a sprite when the mouse is hovered over the area is it possible to have a sprite pop up with a description of that area? (that would be pretty cool ) e.g Lindunia "this is the main city" bla bla bla
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
AMD Radeon 7570 1gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 20th Aug 2019 00:33
Yes you can do that easily enough. If you use my sprite font library you could even have the text pop up on it's own rather than have to create a lot of separate sprites.
Been there, done that, got all the T-Shirts!
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 20th Aug 2019 00:42
Quote: "I thought hang on if we can have a sprite over a sprite when the mouse is hovered over the area"

In fact does not neccessary do so, just need 2 images, one flat img and the other glow one, then just show one img or other, depending where the mouse is.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 20th Aug 2019 13:48
This is what I was thinking when the mouse hovers over Lindunia for example: This is displayed and then if clicked jump to level, so the sprite that pops up is for information on that particular city or area.

Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
AMD Radeon 7570 1gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-20 07:29:33
Your offset time is: 2024-05-20 07:29:33