Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: kenjeh on December 24, 2008, 11:11:36 pm

Title: Idea/Request: Exclude Weapon From Rearm
Post by: kenjeh on December 24, 2008, 11:11:36 pm
Basically, a weapon with this flag cannot be rearmed while in a mission.

This would be useful for large warheads or beams mounted on fighters for the sake of balance. It wouldn't make sense for a fighter to continuously fire off an insanely powerful weapon while calling the support ship every 30 seconds because they ran out of ammunition. This would also be useful for missions where you only have one shot at something, and have to make it count.

Would a weapon flag like this be possible?
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: Nuke on December 25, 2008, 12:40:52 am
old idea, never implemented, it shouold be
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: karajorma on December 25, 2008, 02:03:28 am
Possible.

Although to be honest I'd rather screw myself over by trying to implement FREDder set limited quanities on the support ship rather than saying that weapons on certain ship can't be rearmed. :)

Remind me after 3.6.10 comes out and I'll look into this.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: Nuke on December 25, 2008, 08:40:10 am
mainly it would be usefull for special external stores. maelstrom is a good example where you can strap a gargantuan meson torpedo to your hull on bank 3, and still get your nuke banks 1&2, missile turret, and gatling-howitzers reloaded by a support ship. with ballistics the flag is even more useful since you may want to allow the rearm of primarys, but not certain secondaries.

on the other hand a system where you can set a support ship's inventory, a list of ordinance kept aboard the support ship. so say you have gatling guns and missiles in the ship, but no extra warheads. so you can fire the warheads you have, but aren't allowed any more. take it a step further and you can specify quantities of weapons available on board the ship. so you can put 10 warheads on board, and bombers can reload them until their gone. something like this could do the same job, and better.

but the former solution seems like it would be an order of magnitude less difficult to implement. adding a flag and then a conditional in the rearm code. the latter option would require changes to fred as well, and more complex additions to the rearm code.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: portej05 on December 25, 2008, 08:55:10 am
I've had a quick look at this (I'm still familiarising myself with the code base, but it doesn't look too difficult)
If you could provide a list of names of the weapons or a list of some info that can be correlated with a unique entry in the Weapon_info entries, it could be done something like this:
(and yes, I know this is sloppy - very sloppy)

At line 12990 in ship.cpp (revision 5020) is:
Code: [Select]
for (i = 0; i < swp->num_secondary_banks; i++ )
{

After that line, insert:
Code: [Select]
int curr_weapon_secondary_rearm = swp->secondary_bank_weapons[i];
char* curr_weapon_secondary_name = Weapon_info[ curr_weapon_secondary_rearm ];
bool ignore_current_weapon_secondary = false;
for ( int j = 0; j < num_weapons_on_name_list_to_ignore; j++ )
{
     if ( strcmp( curr_weapon_secondary_name, weapon_name_to_ignore[j] ) == 0 )
       ignore_current_weapon_secondary = true;
}
if ( ignore_current_weapon_secondary )
   continue; // move onto the next secondary weapon to rearm
Replace j if a conflict occurs - I haven't checked


I don't know how to get the list of weapons to ignore into the game, so I'm not going to actually implement this (that's for someone who knows what they're doing, and has a few hours free to test it)

Enjoy!
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: Shade on December 25, 2008, 08:56:55 am
I endorse this idea. Being able to limit the amount/types of weapons available for rearming would be very handy indeed.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: portej05 on December 25, 2008, 09:01:58 am
Not sure how to limit the resources - I didn't look that far ahead! If there's already a support ship structure, it wouldn't be too difficult, otherwise, might be a lot more difficult!
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: chief1983 on December 25, 2008, 11:05:27 am
So are you guys thinking this should be a weapon flag or a flag on a particular ship or weapon type in a given mission?
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: Shade on December 25, 2008, 11:46:36 am
Neither - Kara's take on it does it all and more. But if a stopgap measure is needed to do some of it quickly, then I'd say it should be an extra  checkbox for each weapon in FRED's team loadout editor which you could tick to disallow the weapon in question from being refilled by support ships.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: Trivial Psychic on December 25, 2008, 01:30:31 pm
How about a sexp to set the availability of individual weapons on a per-mission basis?  It could also include a field for a numeric value which indicates whether the amount of said weapon given should be considered the maximum available in the mission, or on a per-support-ship basis.  That means that you could independently limit the number of weapons and the number of support ships.

set-weapon-rearm
-<name of weapon>
-<weapon quantity available>
-<0=limit on entire mission, 1=limit per support ship>
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: karajorma on December 25, 2008, 05:40:53 pm
The ability to limit the number of weapons on a support ship is actually an essential part of my weapon loadout changes. It's no good being able to limit the number of missiles or bullets available to the player if they can simply call in a support ship to rearm them.

A stopgap method however is problematic. If I say "You can't rearm Bank 2" then what stops the player from simply using the loadout screen to move the weapon to Bank 1? What happens if the player decides to swap the big bomb for something else instead? Sure we can have "No Rearm" as a weapons flag but then that does mean that the support ship can never rearm that weapon at any time in the campaign.

That said I do want to add something player side too rather than just on the support ship side. It does no good to horde your most powerful missiles if the AI ships can call in support and then use them all up. :D So I probably will be building something onto the support ship code and something onto the ship code so that both of them can be used to create this feature. The challenge is therefore to design a stopgap which works as part of the overall feature I'd like to add.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: portej05 on December 26, 2008, 12:32:45 am
I suppose that's the trick.
My hack can (I think!) prevent a given missile being reloaded if a list of the missile names can be found, but it would be for the entire mission, and I don't know how to get that list into the game.

I think I can see where you're wanting to go - there's no point having a support ship if your wingmen are going to use all the missiles anyway (leaving you with none). What about a per ship re-arm limit? This means that the ship itself can keep track of its loadout, and there aren't huge changes to be made to either the support code or the ship code. Just (somehow) load the number of missiles that can be reloaded in each bank (in the ship structure), and then around the same area (ship.cpp(12990)?) just decrement that counter for the missile bank to be rearmed until it hits 0. Informing the user of what is going on might be a bit of a bigger task however (another HUD gauge?)

Just throwing ideas out!
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: Solatar on December 26, 2008, 03:29:38 pm
Perhaps make the table side of it so that if you set a weapon's rearm time to -1 it wouldn't rearm? So if the support ship sees a positive time, it does its normal thing; if it sees -1 it ignores the bank completely.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: karajorma on December 26, 2008, 06:14:49 pm
portej05, if you want to take a look at the code make sure you check out my branch of the code as the team loadout changes are already in there and anything I'd be doing would have to fit with them.

The problem with a per-ship limit is that there is no easy way to recover from the player changing his weapon type in the loadout. Suppose the player starts with a bank of Helios Torpedoes and a rearm limit of 1. What then happens if the player then changes to Hornets? Giving them 1 hornet would seem rather silly.

Yeah you can have a limit for every weapon but that's a hell of a lot more data to carry about, and a lot more work to make the editor for.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: Kie99 on December 27, 2008, 04:17:30 am
Sure we can have "No Rearm" as a weapons flag but then that does mean that the support ship can never rearm that weapon at any time in the campaign.

So make two, like with Cyclops and Cyclops #Short
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: karajorma on December 27, 2008, 04:32:11 am
Which basically means wasting a table space for each weapon you want to do this to.

Not exactly the most robust solution really.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: portej05 on December 27, 2008, 09:08:40 am
I've been thinking about how to implement an algorithm for this, and I've come up with a number of ideas (this may or may not be flame bait - sorry K!)
This is kind of train of thought, but any feedback would be great

Have a per fighter reload coefficient (i.e. if you start with 100 missiles, you can reload up to 200 missiles with a coefficient)
-Advantages are that you don't have to worry about the weapon type at all - all weapons are affected
Have a per bank reload coefficient/number (for each ship?)
-Advantage is that you can precisely control how many missiles a player can have during a mission, disadvantage is that it's a lot of work for the mod creator
Have a flag that says that a particular secondary type cannot be reloaded
-Advantage is that it's dead simple to implement. Not at all flexible (although, a flag or some event could be added that could change that - more work though and someone has got to figure out how to do the flag)
Have a per weapon inventory
-Lots of work!, but very powerful if it is a per weapon per ship type arrangement
Some combination of all of the above?

Any other ideas?

I've had a look through the Karajorma repository - I'm not exactly sure what I'm looking for in terms of changes. There are changes in weapons.cpp and missionweaponchoice.cpp but I'm not exactly sure what they do yet.

I think I'm looking at the codebase from the wrong end - it might have been a bad idea to try and jump in and code a feature rather than fix a bug - however bugs usually require more knowledge of how it works than to implement a feature!
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: karajorma on December 27, 2008, 05:53:13 pm
This is rather old and I've changed a few things since I wrote it but it does explain what the feature was meant to do.

http://www.hard-light.net/wiki/index.php/Improved_Team_Loadout

In order to use feature for weapons though you either have to disallow support ships or live with the fact that they'll ignore the number of weapons you had left. That's something I plan to change sooner or later.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: Nuke on December 28, 2008, 01:03:19 am
The ability to limit the number of weapons on a support ship is actually an essential part of my weapon loadout changes. It's no good being able to limit the number of missiles or bullets available to the player if they can simply call in a support ship to rearm them.

A stopgap method however is problematic. If I say "You can't rearm Bank 2" then what stops the player from simply using the loadout screen to move the weapon to Bank 1? What happens if the player decides to swap the big bomb for something else instead? Sure we can have "No Rearm" as a weapons flag but then that does mean that the support ship can never rearm that weapon at any time in the campaign.

That said I do want to add something player side too rather than just on the support ship side. It does no good to horde your most powerful missiles if the AI ships can call in support and then use them all up. :D So I probably will be building something onto the support ship code and something onto the ship code so that both of them can be used to create this feature. The challenge is therefore to design a stopgap which works as part of the overall feature I'd like to add.

i was originally thinking of adding something at the weapon level. so if i load a wtfhugeassnuke, and the weapon entry for wtfhugeassnuke has a "no rearm" flag then if you call the support ship, and have that weapon, then it wont be reloaded. of course the idea of control over what the support ship carries can be used to accomplish the same thing. really just need something to make external weapons non-reloadable.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: kenjeh on December 28, 2008, 02:14:27 am
i was originally thinking of adding something at the weapon level. so if i load a wtfhugeassnuke, and the weapon entry for wtfhugeassnuke has a "no rearm" flag then if you call the support ship, and have that weapon, then it wont be reloaded.

Pretty much what I was thinking.
Title: Re: Idea/Request: Exclude Weapon From Rearm
Post by: Nuke on December 28, 2008, 03:07:29 am
but having 3 levels, by the bank, by the weapon, or by the fred defined inventory. that would make it alot more versatile.