How to make a point selection tool (like artillery remote)?
Posted: Sun Jul 15, 2018 6:57 pm
by beiju
I'm trying to make a tool that the player can hold in their cursor and click to select a single point, like the artillery remote. My first attempt was to use a capsule of type artillery-remote, but that seems hard-coded to have artillery behavior. All the capsule types seem to have some undesired hardcoded behavior. I settled on using the use-on-self type with an action that has infinite range and does 0 damage on yourself. The undesired behavior here is that the item gets used up, so in my event handler I have to give the player another one -- but, it doesn't get used up until after the event handler so what I actually have to do is set a flag so that the on_tick handler (which I use anyway) can give it back on the next tick.
Obviously, that's a mess. Is there a better way to do this? Note that I don't want to allow the user to select an area, so selection-tool is not helpful unless I missed a way to tell it to only select a point. Also, being able to use it in the zoomed-out map view, like the artillery-remote, would be ideal but isn't required.
Re: How to make a point selection tool (like artillery remote)?
Posted: Sun Jul 15, 2018 9:58 pm
by Klonan
I would recommend the selection tool
If you make the selection box invisible, people won't be inclined to select an area,
And even if they do select and area, you can always just use the center of that area or something
maybe we could be some way to select from the map view, not sure
It also has the added benefit that 'shift + click' can have different functionality
Re: How to make a point selection tool (like artillery remote)?
Posted: Mon Jul 16, 2018 1:07 pm
by eradicator
Klonan wrote:I would recommend the selection tool
If you make the selection box invisible, people won't be inclined to select an area,
And even if they do select and area, you can always just use the center of that area or something
You have to make extra sprites to also hide the selection boxes around everything in the selected area for that to work, because there is no selection_mode = 'none' (Consider this a request ;). Here's the comment in my code from when i tried that last week:
Apart from that it's probably the cleanest implementation you can get. Remaining side effect would be that that event is raised on mouse_up instead of mouse_down like everything else. Where right_bottom would be the coordinates of the cursor on mouse_up.
An easier implementation would be to add an invisible (or visible if you want a targeting marker) place_result entity with (collision_mask={},flags={'placeable-off-grid'}) to your item and use on_put_item, which is also raised if the player uses it outside of building_reach. Side effects: The entity-preview is dynamicallay tinted green/yellow/red depending on building_reach.
Re: How to make a point selection tool (like artillery remote)?
Posted: Mon Jul 16, 2018 1:16 pm
by Klonan
eradicator wrote:
Klonan wrote:I would recommend the selection tool
If you make the selection box invisible, people won't be inclined to select an area,
And even if they do select and area, you can always just use the center of that area or something
You have to make extra sprites to also hide the selection boxes around everything in the selected area for that to work, because there is no selection_mode = 'none' (Consider this a request . Here's the comment in my code from when i tried that last week:
Apart from that it's probably the cleanest implementation you can get. Remaining side effect would be that that event is raised on mouse_up instead of mouse_down like everything else. Where right_bottom would be the coordinates of the cursor on mouse_up.
An easier implementation would be to add an invisible (or visible if you want a targeting marker) place_result entity with (collision_mask={},flags={'placeable-off-grid'}) to your item and use on_put_item, which is also raised if the player uses it outside of building_reach. Side effects: The entity-preview is dynamicallay tinted green/yellow/red depending on building_reach.
in 0.17 we have force conditions you can set on the flag, so you can hide it with two incompatible conditions:
Haven't used MIRV yet. Does it have a target marker ala command-and-conquer? And if yes how do you handle the tinting of the entity preview? (Can we perhaps get a prototype flag/property to disable the tinting?)