Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: HLD_Prophecy on November 20, 2016, 01:55:31 pm

Title: How to get player ship damage and ammo to carry over to the next mission?
Post by: HLD_Prophecy on November 20, 2016, 01:55:31 pm
I'm sure someone knows how to do this.

I have a chain of missions where the player shouldn't be able to repair or resupply. I tried making them all red alert missions but this didn't work. I'm not sure how to copy ship damage and ammo to a campaign persistent variable.
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: Jackho on November 20, 2016, 02:08:28 pm
Have you tried this (http://www.hard-light.net/forums/index.php?topic=74716.0) ?
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: HLD_Prophecy on November 20, 2016, 08:35:11 pm
Have you tried this (http://www.hard-light.net/forums/index.php?topic=74716.0) ?

No, I did not see that, thanks. But I have no idea how to use it. :confused:
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: AdmiralRalwood on November 20, 2016, 09:48:20 pm
I tried making them all red alert missions but this didn't work.
...Why didn't it work?
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: Black Wolf on November 20, 2016, 11:02:51 pm
Not to put words in anyone's mouth, but I'm going to suspect that maybe "red alert carry status", or whatever it's called, wasn't checked in the ship box. It's easy to forget.
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: 0rph3u5 on November 21, 2016, 04:42:10 am
You have the Red Altert option already mentioned here ... however Red Alert has been prone to bugs in relations to mods Red Alert is bugfree, Praise the Coders

However with a little thinking you can emulate the system with events from one mission to another. But that requires a large number of events if you have a wide array of ships/weapons to cover because you will have to set event for every contingency - the recall can actually done with a single event.

What you need are around 12 variables (for ship class, hull value, primary weapon 1, primary weapon 2, primary 1 ammo, primary 2 ammo, secondary weapon 1, secondary weapon 2, secondary weapon 3, secondary 1 ammo, secondary 2 ammo, secondary 3 ammo), each of them has to be campaign persistent so carries over from mission to mission.

You can either code the varibles as numbers (e.g. 0 for Perseus, 1 for Myrmidon, 2 for Loki) or make the variables string-type, see below.

Here is how I would do it (note that a single example, you might have to repeat the event for all weapons and ships avalible, so the more you restrict loadouts the less work you have - another note, how that will work with ships that have a different number of weapons backs and therefor don't input data into the variables - I myself have sidesteped that when implimented that)

1. Save Ship-class:
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/save-stuff-1-shipclass_zpsh0yikznv.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/save-stuff-1-shipclass_zpsh0yikznv.png.html)

2. Save a Primary:
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/save-stuff-2-primary_zps4mxsmtjs.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/save-stuff-2-primary_zps4mxsmtjs.png.html)

3. Save a Secondary:
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/save-stuff-3-secondary_zps4swohce1.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/save-stuff-3-secondary_zps4swohce1.png.html)

4. Save the Hull value:
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/save-stuff-4-hullvalue_zpshpnpw5nn.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/save-stuff-4-hullvalue_zpshpnpw5nn.png.html)

5. Recall:
EDIT: The change-ship-class is wrong, the varible should be the first argument and the second argument the ship that needs to be changed
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/save-stuff-5-recall_zpszdahxmoy.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/save-stuff-5-recall_zpszdahxmoy.png.html)

Note if you do this for more than one ship, you might hit the limit of variables...

EDIT:
ps. I forgot a screen capture of the variables-dialogue, sry...
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: HLD_Prophecy on November 21, 2016, 06:31:33 pm
Not to put words in anyone's mouth, but I'm going to suspect that maybe "red alert carry status", or whatever it's called, wasn't checked in the ship box. It's easy to forget.

No, I didn't even know that was a thing!

Will try now!

Thanks for the help guys! :D
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: HLD_Prophecy on November 21, 2016, 06:40:59 pm
Okay, unfortunately the red alert carry status didn't do anything.

Honestly, Orpheus, that solution you suggested has my brains scrambled so badly that I'm not sure if it's worth all that work. I might just have to lampshade the regenerating health and ammo.
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: Black Wolf on November 21, 2016, 07:27:33 pm
It definitely works, I've used it, retail uses it.

Did you check the box in both the mission before and after the red alert?
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: AdmiralRalwood on November 22, 2016, 06:36:38 am
You have the Red Altert option already mentioned here ... however Red Alert has been prone to bugs in relations to mods
If there are currently any bugs with Red Alert, I'm unaware of them. If a feature is buggy, you're supposed to report the bugs so they get fixed, not tell people not to use the feature in the first place. ;)

(That being said, modern mission design philosophy shies away from Red Alert missions in favour of making a longer mission with a checkpoint system, but that might feel a little daunting for somebody who just wants to FRED something simple.)
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: 0rph3u5 on November 22, 2016, 08:37:10 am
Honestly, Orpheus, that solution you suggested has my brains scrambled so badly that I'm not sure if it's worth all that work. I might just have to lampshade the regenerating health and ammo.

That was not my intention, I am sorry.

To start easy, FRED has a function to introduce "variables", custom data-sets that you can fill with data via events. Variables are almost free-from, so you can use them for a lot of stuff - franken-engineering what Red Alert does, is only a single application.
I explain the basics about them here (http://www.hard-light.net/forums/index.php?topic=92662.msg1831935#msg1831935), here (http://www.hard-light.net/forums/index.php?topic=92662.msg1831946#msg1831946) and here (http://www.hard-light.net/forums/index.php?topic=92662.msg1831951#msg1831951)

My example above might be a bit too detailed but is actually not complicated but busywork (as I just noticed that you can collapse the save-events with some advanced knowledge); what I wanted to show as that you can save those data points in variables, the values of which (aka the data you saved in them) can be transfered from mission to mission if they appear in both missions (same name, same type, "campaign persitent"-flag checked) and then be used.
(I do so regualarly to transfer hull values of capital ships.)

You have the Red Altert option already mentioned here ... however Red Alert has been prone to bugs in relations to mods
If there are currently any bugs with Red Alert, I'm unaware of them. If a feature is buggy, you're supposed to report the bugs so they get fixed, not tell people not to use the feature in the first place. ;)

Doesn't Red Alert break if you use one pilot file across mods anymore? (it used to when it called data that was unavalible)
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: Admiral MS on November 22, 2016, 09:47:14 am
Have you tried this (http://www.hard-light.net/forums/index.php?topic=74716.0) ?

No, I did not see that, thanks. But I have no idea how to use it. :confused:
Well, the script does essentially what 0rph3u5 described and replaces all the variable saving/loading stuff with a simple one-line script call that saves data to a file. I made it originally to get around the back then horribly bugged red-alert which has probably been fixed.
So I guess in your case figuring out how to get red-alert to work properly is what I would do.
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: X3N0-Life-Form on November 22, 2016, 09:56:22 am
Doesn't Red Alert break if you use one pilot file across mods anymore? (it used to when it called data that was unavalible)

My understanding is that these issues were fixed with the new pilot code introduced with 3.7.0.
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: HLD_Prophecy on November 22, 2016, 04:32:36 pm
Honestly, Orpheus, that solution you suggested has my brains scrambled so badly that I'm not sure if it's worth all that work. I might just have to lampshade the regenerating health and ammo.

That was not my intention, I am sorry.

To start easy, FRED has a function to introduce "variables", custom data-sets that you can fill with data via events. Variables are almost free-from, so you can use them for a lot of stuff - franken-engineering what Red Alert does, is only a single application.
I explain the basics about them here (http://www.hard-light.net/forums/index.php?topic=92662.msg1831935#msg1831935), here (http://www.hard-light.net/forums/index.php?topic=92662.msg1831946#msg1831946) and here (http://www.hard-light.net/forums/index.php?topic=92662.msg1831951#msg1831951)

My example above might be a bit too detailed but is actually not complicated but busywork (as I just noticed that you can collapse the save-events with some advanced knowledge); what I wanted to show as that you can save those data points in variables, the values of which (aka the data you saved in them) can be transfered from mission to mission if they appear in both missions (same name, same type, "campaign persitent"-flag checked) and then be used.
(I do so regualarly to transfer hull values of capital ships.)





Okay, this breaks it down a bit, thanks. I'm kind of an amateur FREDer so variables are not something that I'm used to using.

I'll give it a shot. All I need to transfer is health and secondary 1 and 2 ammo, anyway, so I should only need 3 of those.

Sorry for my response at first, I guess it just seemed way over my head at first look and I have a bad habit of giving up too easily. :P

EDIT: And I should have realized before that you put that whole event list together for me. Thanks for doing that work...  :nod:
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: HLD_Prophecy on November 22, 2016, 04:48:21 pm
Okay, I'm trying to get this set up, but I'm not sure how to get the variable into the event in another mission.

Like in the set-subsystem-strength operator in "recall", I don't know how to get Alpha-1-Hull in there. How do I replace the simple number with a campaign-persistent variable?
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: 0rph3u5 on November 23, 2016, 01:36:48 am
You have to first set-up the variable via "Add Variable" in the right-click menu
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/variable-advice1_zps4lenf2ut.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/variable-advice1_zps4lenf2ut.png.html)

Make sure it is set-up to be a "Number"-variable, like this - you may also want to check "campaign persistent" -:
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/variable-advice4_zps4lsxodkc.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/variable-advice4_zps4lsxodkc.png.html)


And then simply use "Replace Variable" where you want it, like this:
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/variable-advice2_zpsoswp5xga.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/variable-advice2_zpsoswp5xga.png.html)

ps. yes, I am shamelessly re-using stuff
Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: HLD_Prophecy on November 23, 2016, 12:24:25 pm
Thanks, I got that now.

I'll get the framework laid out and post here if it works.

Title: Re: How to get player ship damage and ammo to carry over to the next mission?
Post by: HLD_Prophecy on November 24, 2016, 06:33:36 am
Awesome, the system worked!

Thanks a ton, my mod is almost ready for release!  :D