Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: TrashMan on February 23, 2008, 08:19:27 am

Title: custom HP for missiles/torpedos?
Post by: TrashMan on February 23, 2008, 08:19:27 am
Will that be in 3.6.10? :blah:
Title: Re: custom HP for missiles/torpedos?
Post by: Snail on February 23, 2008, 08:38:26 am
I was wondering the same thing meeself.
Title: Re: custom HP for missiles/torpedos?
Post by: Colonol Dekker on February 23, 2008, 08:53:09 am
Would be awesome for subspace cruise missiles, or skipper (wing commander fanbois rejoice) missiles!
Title: Re: custom HP for missiles/torpedos?
Post by: Snail on February 23, 2008, 09:07:40 am
Well there are already local Local SSM.
Title: Re: custom HP for missiles/torpedos?
Post by: Colonol Dekker on February 23, 2008, 09:14:44 am
I know that :D anyone played project sylpheed? It has missiles the length of battleships lol
Title: Re: custom HP for missiles/torpedos?
Post by: karajorma on February 23, 2008, 10:32:15 am
Will that be in 3.6.10? :blah:

No.

And ten out of ten for moving from simply asking for a feature respectfully to asking why it won't be in 3.6.10 as if it's some sort of failing from the SCP to have not included it the second you thought of it.


EDIT : Actually since you're a coder why don't you do it? Here's your starting point.

weapon_create() contains this little snippet of code

   if (wip->wi_flags & WIF_BOMB){
      objp->hull_strength = 50.0f;
   } else {
      objp->hull_strength = 0.0f;
   }

There you go. Add the table function and test heavily in both multiplayer and single player until you've proved beyond a reasonable doubt that you haven't introduced any bugs.
Title: Re: custom HP for missiles/torpedos?
Post by: blowfish on February 23, 2008, 11:33:35 am
It would be cool if we could also have shields for bombs, but maybe I'm asking for too much.

EDIT: I just looked at the code, and adding custom HP to a bomb wouldn't be too hard ( I'm not even going to look at sheilds ).  Would it look something like this?:

weapon.h
Code: [Select]
typedef struct weapon_info {
...
float max_hull_strength;
...
}

weapon.cpp
Code: [Select]
void init_weapon_entry(int weap_info_index) {
...
wip->max_hull_strength = 0.0f
...
}

int parse_weapon(int subtype, bool replace) {
...
if(optional_string("$Hitpoints:"))
{
stuff_float(&wip->max_hull_strength);
if (wip->hitpoints < 0.0f)
{
Warning(LOCATION, "Max hull strength on %s '%s' cannot be less than 0.  Defaulting to 0.\n", info_type_name, wip->name, wip->max_hull_strength);
wip->max_hull_strength = 0.0f;
}
}
...
}

int weapon_create( vec3d * pos, matrix * porient, int weapon_type, int parent_objnum, int group_id, int is_locked, int is_spawned) {
...
if (wip->wi_flags & WIF_BOMB){
if (wip->max_hull_strength <= 0.0f) {
objp->hull_strength = 50.0f;
} else {
objp->hull_strength = wip->max_hull_strength;
}
} else {
objp->hull_strength = 0.0f;
}
...
}

Forgive me if this is incomplete/buggy/flat out wrong, I am really a n00b programmer who is used to working with high-level, object-oriented APIs in GUI based apps (in Objective-C or Java), and I am not set to test this.
Title: Re: custom HP for missiles/torpedos?
Post by: karajorma on February 23, 2008, 12:54:22 pm
Seems about right. I'd assumed that would be all there was to it when I noticed the code I posted above and clipped it to my things to do list. I'd probably have replaced this if

Code: [Select]
if (wip->max_hull_strength <= 0.0f)
with an assertion since in the usual running of the game there's no way that value should be negative due to the way the parse code was written and if something else is changing the value I'd rather know about it than silently fix it.
Title: Re: custom HP for missiles/torpedos?
Post by: blowfish on February 23, 2008, 12:59:40 pm
Does that mean we will get custom HP for bombs sometime in the near future? ;)
Title: Re: custom HP for missiles/torpedos?
Post by: karajorma on February 23, 2008, 01:08:16 pm
If people want to test it, sure. I see no reason not to.
Title: Re: custom HP for missiles/torpedos?
Post by: JGZinv on February 23, 2008, 01:58:22 pm
Baxslash and myself had come up with the concept a few months ago
for a few different variants of the SSM, in some cases including shields.

However we just decided to use a "ship" (as a missile/bomb) with tweaked
attributes and scripted events. 

But this will probably make it easier now.  :)
Title: Re: custom HP for missiles/torpedos?
Post by: TrashMan on February 23, 2008, 02:25:56 pm
If people want to test it, sure. I see no reason not to.


YAaaaay!!
but honestly, it's not like this is a new idea. I recall seeing this idea thrown about for years.

Hooray for the SCP team! They bring us much goodies! :D :D :D :D
Title: Re: custom HP for missiles/torpedos?
Post by: karajorma on February 23, 2008, 03:16:57 pm
I know it's not a new idea. The fact I've had it on my todo list for ages proves that. But the simple fact is that unless you have reason to believe someone was working on it acting like it should be in 3.6.10 is a quick way to piss off the coders.
Title: Re: custom HP for missiles/torpedos?
Post by: WMCoolmon on February 23, 2008, 04:04:12 pm
Especially given that you claim to be working on some kind of 50-page project based on the SCP to prove that you understand the code and that you deserve a degree, but then you have people explain the code to you because you don't want to actually learn how to code.

It's kind of hard to feel sympathetic for someone who's openly professed to taking advantage of the people who actually do the work for the degree, so that they can try to BS their professors and devalue the degree that they're getting.
Title: Re: custom HP for missiles/torpedos?
Post by: Mobius on February 23, 2008, 04:06:17 pm
I thought the plural of "torpedo" was "torpedoes".
Title: Re: custom HP for missiles/torpedos?
Post by: TrashMan on February 23, 2008, 04:27:42 pm
Especially given that you claim to be working on some kind of 50-page project based on the SCP to prove that you understand the code and that you deserve a degree, but then you have people explain the code to you because you don't want to actually learn how to code.

It's kind of hard to feel sympathetic for someone who's openly professed to taking advantage of the people who actually do the work for the degree, so that they can try to BS their professors and devalue the degree that they're getting.

Actually, I decided to make a engine instead of modifying an existing one. It's crap, but it works and I'm happy. And I'm not trying to get a degree for programing..computer sciences ecompases much more than just coding.
Title: Re: custom HP for missiles/torpedos?
Post by: Woolie Wool on February 23, 2008, 04:36:11 pm
Wouldn't bombs need more sophisticated collision detection anyway? Right now the coordinate of (0,0,0) within the bomb model must be within the radius of a primary weapons shot for the bomb to blow up, right?
Title: Re: custom HP for missiles/torpedos?
Post by: Polpolion on February 23, 2008, 07:12:24 pm
What about dampening for missiles? Is that even remotely possible?
Title: Re: custom HP for missiles/torpedos?
Post by: Snail on February 24, 2008, 04:46:02 am
What about dampening for missiles? Is that even remotely possible?

Next thing we know we have bombs with turrets. :p
Title: Re: custom HP for missiles/torpedos?
Post by: Mobius on February 24, 2008, 04:48:27 am
The Venom cruise missile has a turret :P

One second... what if we use a normal model(with shields) as bomb? Is it going to keep the shields? There are a few screenshots of Erynies torpedoes and other interesting stuff somewhere.
Title: Re: custom HP for missiles/torpedos?
Post by: Snail on February 24, 2008, 04:53:06 am
The Venom cruise missile has a turret :P

One second... what if we use a normal model(with shields) as bomb? Is it going to keep the shields? There are a few screenshots of Erynies torpedoes and other interesting stuff somewhere.


Wasn't that takashi?
Title: Re: custom HP for missiles/torpedos?
Post by: Mobius on February 24, 2008, 04:54:55 am
Did the torpedo keep the shields?
Title: Re: custom HP for missiles/torpedos?
Post by: Colonol Dekker on February 24, 2008, 05:40:59 am
Kamikaze flag ftw!
Title: Re: custom HP for missiles/torpedos?
Post by: Snail on February 24, 2008, 09:56:23 am
Did the torpedo keep the shields?

No. It might even have made it easier to hit.


On the topic of adding features, how hard could it really be to add another legal flag to the Subsystem flags field which automatically destroys the ship when the subsystem is destroyed (without having to have SEXPs)?
Title: Re: custom HP for missiles/torpedos?
Post by: Mobius on February 24, 2008, 02:07:31 pm
SEXPs work fine. And what if you don't want a ship to blow up after the destruction of a certain subsystem?
Title: Re: custom HP for missiles/torpedos?
Post by: karajorma on February 24, 2008, 02:12:49 pm
On the topic of adding features, how hard could it really be to add another legal flag to the Subsystem flags field which automatically destroys the ship when the subsystem is destroyed (without having to have SEXPs)?

Harder than telling the FREDder to not be so ****ing lazy and just use a SEXP.
Title: Re: custom HP for missiles/torpedos?
Post by: WMCoolmon on February 24, 2008, 02:37:22 pm
Actually, that seems kind of useful if you wanted to consistently make a 'cockpit' subsystem for fighters that would blow the thing up (kill the pilot, fry the electronics, reactor goes critical). Could add some variety to things.
Title: Re: custom HP for missiles/torpedos?
Post by: FUBAR-BDHR on February 24, 2008, 03:32:10 pm
The feature that I always though would be nice is a way to tell if a player shot down a bomb and be able to assign a point score to the bombs.  Also tracking bomb kills in player stats would be nice.  Kind of a way to reward a player for playing good defense. 
Title: Re: custom HP for missiles/torpedos?
Post by: Mobius on February 24, 2008, 04:54:32 pm
It would be useful in a StarLancer MOD.
Title: Re: custom HP for missiles/torpedos?
Post by: Koth on February 24, 2008, 11:42:13 pm
Slightly related question: Is there a limit on how many flags a ship or a weapon can have?
Title: Re: custom HP for missiles/torpedos?
Post by: blowfish on February 25, 2008, 12:05:47 am
Slightly related question: Is there a limit on how many flags a ship or a weapon can have?

From what I saw in the code, there is none, though eventually you will run out of memory (that's not likely to happen any time soon though).
Title: Re: custom HP for missiles/torpedos?
Post by: karajorma on February 25, 2008, 02:41:43 am
Slightly related question: Is there a limit on how many flags a ship or a weapon can have?

Practically, once we hit 32 flags we have to add a new section (Which is why each ship in the mission file have a Flags() and a Flags2() section). Apart from that I can't think of one.
Title: Re: custom HP for missiles/torpedos?
Post by: Polpolion on February 25, 2008, 09:43:05 pm
What about dampening for missiles? Is that even remotely possible?

:(
Title: Re: custom HP for missiles/torpedos?
Post by: blowfish on February 28, 2008, 07:25:28 pm
What about dampening for missiles? Is that even remotely possible?

Actually there is a roation dampening number that is automatically set to 0 but could become a weapons.tbl option the same way custom hitpoints could.  Not sure about speed though.

EDIT: Speed can be dampened too.

Does anyone know the significance of this like of code from weapon.cpp:

Code: [Select]
objp->shield_quadrant[0] = wip->damage;
Title: Re: custom HP for missiles/torpedos?
Post by: blowfish on February 28, 2008, 07:27:19 pm
EDIT: Double post.  Whoops! :nervous:
Title: Re: custom HP for missiles/torpedos?
Post by: Polpolion on February 28, 2008, 07:59:35 pm
With my 4 weeks of c++ classes, I am going to conjecture that the line applies the weapons damage to whatever shield quadrant objp might be pointing to, assuming it is a pointer at all, and completely disregarding whatever "wip" is.


Damn. The hardest part of trying to learn how to code the SCP is figuring out what the hell all those variables/pointers/abbreviated prefixes/classes/whatever are. BTW, any tips on learning that, aside from just sitting down and reading the entire code?

EDIT: Nevermind, I should probably just learn how to program first. :p
Title: Re: custom HP for missiles/torpedos?
Post by: Turey on February 28, 2008, 08:16:13 pm
objp stands for object pointer, wip stands for weapon info pointer (pointer to weapon_info struct)
Title: Re: custom HP for missiles/torpedos?
Post by: karajorma on February 29, 2008, 06:25:35 am
Does anyone know the significance of this like of code from weapon.cpp:

Code: [Select]
objp->shield_quadrant[0] = wip->damage;

My guess would be that it's some kind of error which has been hidden by the fact that weapons can't have shields. The current version was added by Phreak but is merely a change from this

Code: [Select]
objp->shields[0] = wip->damage;
I can't think why a weapon's damage would be stored in the shield array. You should get that info out of Weapons_info when you need it.
Title: Re: custom HP for missiles/torpedos?
Post by: Mongoose on February 29, 2008, 08:03:23 am
Damn. The hardest part of trying to learn how to code the SCP is figuring out what the hell all those variables/pointers/abbreviated prefixes/classes/whatever are. BTW, any tips on learning that, aside from just sitting down and reading the entire code?
That's kind of the conundrum I was faced with when I started playing around with downloading/compiling the source.  I've taken a few C/++-related classes, so I feel like I probably have enough technical knowledge to make at least a tiny contribution to the project...but after looking at that mass of files and directories, I realized that, even were I to pick what seemed like a relatively minor bug in Mantis and try to start working on it, I'd have no idea at all where to go.  I suspect that the only way to get anywhere is to just grit your teeth and start hopping between files.
Title: Re: custom HP for missiles/torpedos?
Post by: karajorma on February 29, 2008, 01:20:58 pm
You can pick up a good amount of how the game works from just looking at the structs in object.h, ship.h and weapon.h

Many of the variables ending in p are a pointer to to an object in one of the arrays from those files. sip = Ship_info pointer, wip = Weapon_info pointer etc. Your IDE probably has a way to leap to the definition of any variable easily, use it.
Title: Re: custom HP for missiles/torpedos?
Post by: Snail on March 01, 2008, 05:11:52 am
Harder than telling the FREDder to not be so ****ing lazy and just use a SEXP.

What if I have 50 ships with the same thing? :nervous:




/me whimpers and runs away from the Master of Some/Destroyer of Souls/Banned
Title: Re: custom HP for missiles/torpedos?
Post by: karajorma on March 01, 2008, 12:30:15 pm
Use a repeating when-argument and simply list all 50 ships.

It's still easier than adding that feature. :)
Title: Re: custom HP for missiles/torpedos?
Post by: Snail on March 01, 2008, 03:47:32 pm
*shoots self*

I can't believe I didn't think of that... :rolleyes:
Title: Re: custom HP for missiles/torpedos?
Post by: Getter Robo G on March 14, 2008, 04:01:04 pm
Bow before the God Karajorma mortal ...  :lol:

(I didn't think of it either!) *runs* and pours salt behind him so Snail can't chase him down.

Snail calls in SSM support... ("Aw F***!) KABOOM! *Dies*


Random note: I made one of Trashman's turrets into a ship once, IDK why...
Title: Re: custom HP for missiles/torpedos?
Post by: TrashMan on March 14, 2008, 04:20:11 pm
I bow before no one!

And GRG, the answer is oblivious*: my turrets are so awesome you just can't get enough of them!


*pun intentional