ID:117386
 
So, given that RetroQuest has some "actiony" elements (I wouldn't truly call it an action game, as it relies on hit/miss chance rather than hit detection and tiles instead of pixel movement) I've been trying to figure out ways to make it easier to click on the occasionally small or spindly icons as they're moving around the screen.

mouse_opacity 2 was something I tried at the start, but when things got crowded with characters that protrude out of the tile that just made things worse. Then I tried various schemes of passing clicks to a tile onto the character standing in it or else the most recent character who'd left it within a tick. Worked pretty well... didn't always work in the way I expected, and that's the sort of thing that only escalates when there are numerous people who aren't the developer playing... it also didn't work for situations where the mob's icon straddles multiple tiles but it's only in one. (Giant spiders have legs that poke out into other icons, and characters with large weapons have their weapons sticking out.)

I expect that the occasional difficulty in targeting the right mob is only going to get worse when I add smaller, faster moving enemies like bats and smaller spiders. And I'm trying to add some more interest to fishing by adding a random chance that you'll spot a large or special fish that's actually visibly swimming in the water and you have to click on it within x amount of time. I don't want to make the fish huge, but I do want to make it more a matter of speed than precision.

It was when I was working with inventory management using some of the items with icons that are still sized for 16x16 that I noticed that even if mouse opacity is set to 2, the icon's actual size is used, not the tile it occupies. Seems obvious in retrospect. It's exactly what I would have expected for a large icon, but I never made the connection with small icons.

So that gave me how to do the fish... make it occupy a smaller square icon and give it mouse_opacity 2. Easier fish can have a larger bounding box.

In doing that, I realized a solution for critters where mouse_opacity 2 isn't appropriate. Completely transparent pixels (alpha 0) don't seem to be opaque to mouse clicks, but any level of opacity... even an invisible-for-all-practical-purposes 1... are clickable at mouse_opacity 1. So anything that I want to be easier to click, I can just draw a "bounding box" around, or an aura a few pixels wide. Draw it in a solid color, swap it to a light color with alpha 1.

Boom: clickable aura that is undetectable to the eye but not to the mouse. This could eliminate what has been a frustrating element in an otherwise really slick combat system.
What you could to is set mouse_opacity to 0 for all map entities and have turfs catch the clicks. Give all map entities a hitbox like you would for pixel movement.

When someone clicks a turf, cycle through each atom in the turf's contents. For each atom which collides with the click, return the one with the highest layer.
That wouldn't really work here.

Imagine a demon the size of a normal one tile character but a wing spread that protrudes three or four pixels past the boundary of the tile to the left and right. If I'm checking the contents of turfs, then I have two choices: only count the middle turf, in which case people will be clicking on the wings and wondering why it's not registering... or give the demon a "three turf hitbox", in which case the demon might very well be blocking targets that are on either side. I'd be better off making the demon icon irregularly sized (cut off just at the edges of the wings, so only a few pixels wider than the tile) and making that mouse_opacity 2.

I don't really see a downside to the way I'm doing it, which lets me basically set as much or as little open space on an icon to be mouse-opaque but eye-transparent.

Edit: I just realized you probably mean define the hit box in terms of pixel size rather than clicks; I've got a splitting headache so my reading comprehension's not great. But why bother? The way I'm doing it I can just -draw- the hitbox and it can be any shape.
Guess you're right about that.

Being able to have image overlays not inherit the mouse_opacity of their source objects would make for a good feature request.