mt-mods / spacecannon

2 stars 4 forks source link

Aim a space cannon #12

Open Klaranth opened 3 years ago

Klaranth commented 3 years ago

On the #ideas repo (https://github.com/pandorabox-io/in-game/issues/74), the following question came around:

Can space cannons be aimed? And if so, how?

dennisjenkins75 commented 3 years ago

Aiming could be done when told to fire via digilines. If using the manual interface, then the "target x,y,z" could be entered into the formspec.

Need to consider what to do if the target coord is behind the cannon. Would the cannon destroy itself, or just refuse to fire? I propose that an "aimed" cannon cannot fire at an angle greater than 45 degrees from a tangent to its firing surface. Maybe 75 degrees at the most. if the angle were greater than this, it should simply refuse to fire.

BuckarooBanzay commented 3 years ago

This mod here https://github.com/mt-mods/cannons remembers the aiming when you first shoot it, not a bad idea but i may not be always what you want.

Aiming could be done when told to fire via digilines. If using the manual interface, then the "target x,y,z" could be entered into the formspec.

How about horizontal and vertical degrees? Configurable over digilines of course. This might be a little math heavy though :thinking:

S-S-X commented 3 years ago

I propose that an "aimed" cannon cannot fire at an angle greater than 45 degrees from a tangent to its firing surface. Maybe 75 degrees at the most.

Agree with this but I would limit it even more to actually require good cannon position too. I would propose 45 degrees at most but preferably smaller angles that do not allow covering areas completely but still allow useful aiming over larger distances. That would be something like 10 - 30 degrees.

This might be a little math heavy though

But then, math like that is not really heavy... compared to almost anything like single call to ItemStack()

kiedtl commented 1 year ago

I've been thinking about this for a while. I really don't like the idea of just giving cannons the capability for even limited aiming, since that eliminates an important constraint that affects how ships are built and limits their power. Currently if you want to be able to hit any target from a large ship, you have to add a bunch of cannons along the sides and such; adding a targeting capability without significant tradeoffs would make it optimal to have far fewer cannons and make it too easy to build a powerful ship IMO.

Targeting could be alright if some tradeoffs were added though, I suppose. Here are some (rough) ideas I had:

S-S-X commented 1 year ago

Add a "targeting calibration system" node

Sound good but instead of straightforward allow/disallow targeting it could just kind of increase accuracy. What I'm thinking would be defined time / degree to acquire new target and random deviation that decreases based on how many calibration nodes you have. Target acquisition system that is not instant but takes time depending on angle difference would probably already work fine without extra nodes but calibration nodes would possibly make it bit more interesting.

Add upgrade slots, with "targeting system" craftitems that can be placed in there. Each craftitem could give 11 degrees of targeting, for 44 degrees in total with all slots filled

Sounds like good alternative to first system and cheaper on server resources. Other stuff from my previous comments would apply and could create situation where player has to select between speed and accuracy (2 different upgrades).

Maybe targeting the cannon has no upfront costs, but is unreliable somehow.

Would my proposals on previous points work well enough here? (variable time for target acquisition, variable accuracy, variables possibly based on upgrades or calibration nodes)

kiedtl commented 1 year ago

Sound good but instead of straightforward allow/disallow targeting it could just kind of increase accuracy. What I'm thinking would be defined time / degree to acquire new target and random deviation that decreases based on how many calibration nodes you have.

That would certainly be more interesting than a simple switch.

Sounds like good alternative to first system and cheaper on server resources. Other stuff from my previous comments would apply and could create situation where player has to select between speed and accuracy (2 different upgrades).

What if both were combined? Targeting system nodes that provide a small (10 deg) base targeting feature (when all 4 of them are present), but each has upgrade slots to increase the targeting or accuracy.

The downside is that it's far more complicated.

The reason I like the first idea, having to place actual nodes near the cannon, is the effect it has on shipbuilding design since one will need to plan for 8 extra nodes (targeting nodes + cables), and prevents one from stuffing fully-upgraded cannons on tiny ships. Upgrade slots just seem too overpowered to me.

S-S-X commented 1 year ago

The downside is that it's far more complicated.

There's also other downside which is what I mean by saving server resources: nodes around cannon need actual area search and reading multiple nodes from world which is way slower than reading data about upgrades which is already there when firing cannon (basically same storage where energy storage is). Multiple nodes can work but good to be careful and plan well to not make one cannon eat up 4 cannons worth of server resources.

Other than that I'd agree with multi node things being a lot more interesting but also bit harder to get right. For quick and easy solution without having to think much about implementation details: just upgrades. For not so easy but possibly better (depends on many things) solution: calibration nodes and possibly upgrades too.

Adding upgrades on top of calibration node thing wont really be big thing, actual code needed for upgrades would still be very simple especially when comparing with code needed for calibration nodes.

kiedtl commented 1 year ago

If using the manual interface, then the "target x,y,z" could be entered into the formspec.

I wonder if there's an easier way to do this. Some kind of UI overlay/mode which allows using Minetest's regular face-and-point action to fire? Would be much easier than entering manual coordinates, and make it viable to use in an actual battle.

S-S-X commented 1 year ago

I wonder if there's an easier way to do this. Some kind of UI overlay/mode which allows using Minetest's regular face-and-point action to fire? Would be much easier than entering manual coordinates, and make it viable to use in an actual battle.

You could create controller entity, attach player to it, read direction they're trying to look at and create HUD reticle that follows direction with aiming delay. Or you could move reticle with WASD. Aiming wouldn't be simply easy point and pull the trigger but would require some training and that's the point, simple point and click without any challenge / skill requirement wouldn't be as fun.

Not exactly what I meant but not too far from what kind of manual control I was thinking about: https://threejs.org/examples/?q=ball#misc_controls_trackball

Maybe have actual visible model for some kind of gunners chair that player would right click to sit on and gain manual control of cannon, you could even allow wiring it to multiple cannons if you like (maybe by just giving some controller id through cannon config formspec or some kind of punch to connect interface).