Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Dragon on August 30, 2010, 01:38:36 pm

Title: A couple of simple feature requests
Post by: Dragon on August 30, 2010, 01:38:36 pm
I've recently had a few simple feature ideas:
1. Gun recoil:
This might have already been proposed somewhere, basically a table setting which would let a weapon to substract a value from firing ship's velocity every time it's fired. It would be mainly usefull for high power ballistic weapons.
2. Piercing on "overkill":
An addition to normal piercing effects which would allow piercing to occur when a single weapon hit is going to take the target down, regardless of it's HP left. So, if you have a cannon which will take fighter from 100% to 0 in one shot, then it'd have a piercing effect, despite hitting a fighter which is at 100%, not at 10.
3. Shot casings counter:
Currently, if you have a ballistic shotgun primary, ammo counter will display number of pellets left, which is irrational. A launcher flag could be used to make counter display number of shots left, which would be more intuitive.
4. Hiding FS2 main campaign:
From time to time, somebody makes a mod which is still dependant on FS, but so different that FS2 main campaign will not work with it. Unfortunately, there's nothing preventing people from running the main campaign (it's selected by default) and reporting the problems as "bugs" later. So, I think that mods could use a way to hide FS2 main campaign without causing crashes. There's a hack that allows doing that, but it can cause problems when switching mods.
Title: Re: A couple of simple feature requests
Post by: chief1983 on August 30, 2010, 01:46:13 pm
Gun recoil in that sense also only works for a shot fired directly ahead.  What happens if you 'whack' a capital ship though?  Maybe something like that could do it.
Title: Re: A couple of simple feature requests
Post by: Dragon on August 30, 2010, 03:11:13 pm
On the other hand, caps ussualy have enough mass for recoil to be barely noticable.
Fighters, in general, fire their heavy weapons forwards, so substracting speed should work just fine.
Title: Re: A couple of simple feature requests
Post by: Nuke on August 30, 2010, 03:16:01 pm
#1. he means the recoil effect on the ship in which the gun is mounted. kinda like how the a-10 slows down when its firing because the gau-8 recoil counteracts the thrust from one of the engines, resulting in less net thrust. i kinda like the idea, it would give nukemod ships another way to escape a lead spray. impact inertia can already be delt with by tweaking a weapon's mass. i wouldnt do it by just subtracting from the ships forward speed, since guns can be set to converge or fire in different directions, id do a vector sum of all the recoil forces from each weapon, and use that to recoil more realistically. i would also impart angular momentum as well (vector sum of the cross product of the force vector and the firing point irt the center of mass :D ). recoil could be derived from the weapon mass as impact inertia is, of course some control would allow for a cooler yet unrealistic effect (maybe a scaler).

#2. pretty straight forward, different special effects for fatal blows, if i read it properly.

#3 i dont get what you want, but asking for launcher flags is a good way to make the coders hate you.

#4 has been delt with in the past (tbp, btrl), iirc all you need to do to make a tc is replace the interface graphics, which can be done with interface templates, then you could run the whole mod from a different directory without the core fs2 files, you could also use tbls instead of tbms which would effectively override the core fs files. so theres no need to hide the main campaign.
Title: Re: A couple of simple feature requests
Post by: chief1983 on August 30, 2010, 03:22:49 pm
Yeah Nuke, I understood that.  But I'm not sure how subtracting velocity from a ship makes any sense when the shot is fired to port or starboard, or even aft.
Title: Re: A couple of simple feature requests
Post by: Nuke on August 30, 2010, 03:25:47 pm
the math for that is trivial. the force is the inverse of the firing normal, times the magnitude of the force. vector sum up all the recoil forces from all points that have fired for the frame. add the resultant vector to the velocity of the ship and it will represent your linear recoil. you could also like i said in my previous post do angular recoil effects, except you have to dot the force vector with its position in relation to the ships center of mass. sum those up for all fired points each frame and the resultant vector is the angular velocity. if you want convert it to a matrix and multiply with the ships moi. convert back to euler and apply to ships angular velocity.
Title: Re: A couple of simple feature requests
Post by: chief1983 on August 30, 2010, 03:28:47 pm
Yeah the math is, but can that be done in Freespace trivially?
Title: Re: A couple of simple feature requests
Post by: The E on August 30, 2010, 03:29:54 pm
3. Shot casings counter:
Currently, if you have a ballistic shotgun primary, ammo counter will display number of pellets left, which is irrational. A launcher flag could be used to make counter display number of shots left, which would be more intuitive.

This would be something I very much want. Actual number of shots is more useful than number of rounds remaining.
Title: Re: A couple of simple feature requests
Post by: FUBAR-BDHR on August 30, 2010, 03:30:37 pm
And what about glide?  Should you be able to exceed max velocity if you flip around backwards and fire?  Lots of potential issues here.
Title: Re: A couple of simple feature requests
Post by: Nuke on August 30, 2010, 03:35:54 pm
probibly not, there are reasons the cap is there other than gameplay. you dont want the player to build up insane velocity because you will get floating point errors (bad for collision detection, also can be shakey).

Yeah the math is, but can that be done in Freespace trivially?

yea, if you respect the caps and run it at the right point in the physics code. physics code breaks down when you disregard the caps.
Title: Re: A couple of simple feature requests
Post by: Dragon on August 30, 2010, 03:37:47 pm
Of course, speed change induced by recoil should be limited to what ship can normally do.
If you flip backwards and fire in glide, you either won't change the speed (if using default glide, which is unrealistic anyway), or accelerate (in reverse) to maximum normal glide speed.
Yeah Nuke, I understood that.  But I'm not sure how subtracting velocity from a ship makes any sense when the shot is fired to port or starboard, or even aft.
It wouldn't, but as I said, I didn't intended it to use on ships which can fire to the sides, because they wouldn't feel the recoil in most cases.
If somebody made a weird fighter with side firing primaries, then it could be a problem, but I think that this isn't a good idea due to difficulty in aiming.
Or you could simply change slide speed in case of side mounted weapons.
Title: Re: A couple of simple feature requests
Post by: Nuke on August 30, 2010, 03:42:37 pm
It wouldn't, but as I said, I didn't intended it to use on ships which can fire to the sides, because they wouldn't feel the recoil in most cases.
If somebody made a weird fighter with side firing primaries, then it could be a problem, but I think that this isn't a good idea due to difficulty in aiming.
Or you could simply change slide speed in case of side mounted weapons.

what if somone else does (i always thought of doing an ac130 analog)? i mean if you can make the ship recoil backwards, its using the same math, doing it the simple way is just using a vector that disreguards the source of the forces, and assuming what they are. its just as easy for the computer to calculate what they are. you could still have control of how much recoil with a scaler.
Title: Re: A couple of simple feature requests
Post by: chief1983 on August 30, 2010, 03:45:05 pm
And actually, shooting behind you is exactly how you go faster.  Didn't you drive the tank in San Andreas?
Title: Re: A couple of simple feature requests
Post by: Nuke on August 30, 2010, 03:48:36 pm
well my point is if its to be made a feature it should work with other existing features. i dont like it when they dont play well together :D
Title: Re: A couple of simple feature requests
Post by: Dragon on August 30, 2010, 04:08:14 pm
And actually, shooting behind you is exactly how you go faster.  Didn't you drive the tank in San Andreas?
It would make you go faster, but not over maximum reverse speed.
And when to think about it, recoil working in all directions could be really usefull, a dummy weapon firing backwards and with a large recoil could be used as some kind of disposable afterburner (like Wasp Booster in WCP, though it wouldn't work exactly that way, accelerating the ship instead of speeding it up for a period of time).
Title: Re: A couple of simple feature requests
Post by: Trivial Psychic on August 30, 2010, 04:48:41 pm
And actually, shooting behind you is exactly how you go faster.  Didn't you drive the tank in San Andreas?
Did you ever fly it?  ;7
Title: Re: A couple of simple feature requests
Post by: chief1983 on August 30, 2010, 04:51:11 pm
Sounds familiar.  Might have done that once.  At least in MTA:SA I know I have.
Title: Re: A couple of simple feature requests
Post by: Trivial Psychic on August 30, 2010, 04:53:46 pm
Actually, it was Vice City I was recalling.  You could in fact fly higher than you could in any aircraft available and reach a weird invisible patch of land in the sky I called Purgatory, because it was very difficult to get out once you were there.
Title: Re: A couple of simple feature requests
Post by: Scourge of Ages on August 30, 2010, 04:58:42 pm
For numbers 1 and 3, I have an idea involving spawns, which naturally wouldn't work if primary weapons can't have spawns, or if you can't define multiple spawn angles for different types of children.

1) Have the shot fired detonate with no effect immediately or as soon as possible after firing. The primary child spawns exactly forward and continues on and does it's thing, but a second child spawns exactly backward, hitting the firing ship. The secondary round has no effects at all, and does no damage, but has a very high velocity and mass.
3) The shot you fire is actually a single projectile, but immediately after firing it detonates and spawns your desired pellets in the correct cone. You get the shotgun effect you want, and it only costs one ammo.
Title: Re: A couple of simple feature requests
Post by: Dragon on August 30, 2010, 05:04:29 pm
Guns may not be able to spawn and if they were, 1 would still be very difficult (you can't define multiple spawn angles, it's possible to fake with 4 submunitions) and 3 would be a hack I don't want to use for such minor thing.
Title: Re: A couple of simple feature requests
Post by: Nuke on August 30, 2010, 05:21:33 pm
i dont consider it a problem that shotgun weapons count each sub-shot, i usually just have the analog ammo gauge on so i can see how fast ammo is being depleted. its far more useful than the numeric indicator.
Title: Re: A couple of simple feature requests
Post by: Solatar on August 30, 2010, 05:25:21 pm
That all depends on how much ammo you are carrying.  If you can carry a few hundred shots and on up, visual representation is great.  If you've got a special weapon that carries 20 'shells', then a visual representation will be a bit harder to read (do I have 4 or 5 left?).

I don't know what the nature of the weapon the original poster had in mind, however.
Title: Re: A couple of simple feature requests
Post by: Dragon on August 30, 2010, 05:26:47 pm
Somewhere between, but in fact, it'd just be more realistic for all shotguns to count shells instead of pellets.
Title: Re: A couple of simple feature requests
Post by: Nuke on August 30, 2010, 07:20:00 pm
also you must note that weapons in one bank, say you have 4, and you fire one salvo, it will use 4 rounds. just be sure thats not whats causing the issue. if thats whhats causeing the extra ammo usage, thats kinda ok. but if its counting individual pellets, then i think its a sanity issue to just count that as 1 shot.
Title: Re: A couple of simple feature requests
Post by: Wanderer on September 01, 2010, 12:10:14 pm
Via vectors its simple to force recoil from any direction to an object as a change in velocity vector. Imbalanced recoil would be trickier but doable (MOI) as it would (like it realistically does) generate torque and rotation..

As for casings.. I take the 'shot' option only expends as many 'shells' as described in the 'shots' value?
Title: Re: A couple of simple feature requests
Post by: Dragon on September 01, 2010, 03:47:17 pm
Yes, it'd have to always round up to still count half of the shot as 1, but other than that, it'd just be ammo count divided by $Shots: value.
Title: Re: A couple of simple feature requests
Post by: Nuke on September 01, 2010, 08:47:33 pm
Via vectors its simple to force recoil from any direction to an object as a change in velocity vector. Imbalanced recoil would be trickier but doable (MOI) as it would (like it realistically does) generate torque and rotation.

its math i had to figure out for my atmospheric flight model. i was going to do summation of forces from multiple sections of the airframe, of course i never got around to implementing the other stuff it would require, so i never did it. i did however do a test with a drag vector to see if the aircraft would turn itself into the wind, it worked for the most part, but i hadnt got to control surfaces yet and it was completely uncontrolable.

F =  force vector, P = point where force is applied in relation to the ship's center of mass, T = net torque, V = (change in) angular velocity, n =  number of forces, M = inverse! moi matrix
T = ((F1 X P1) + (F2 X P2) + (F3 X P3) + .... (Fn X Pn))

not sure if this is the right order but you do something like
V = T * M

then you just add V to the angular velocity of the ship, the physics code should apply caps for you to prevent the game from screwing up.
Title: Re: A couple of simple feature requests
Post by: Dragon on September 03, 2010, 05:58:28 pm
It seems that the mathematics behind this aren't too complicated.
How difficult would be to make it work?