Author Topic: Campaign persistent variables  (Read 3133 times)

0 Members and 1 Guest are viewing this topic.

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Campaign persistent variables
Here's a question for the coders responsible for Campaign Persistent Variables.

I have three ships: Enterprise, Falcon, and Tardis. I want to track how many of them are destroyed over the span of two missions. At the end of these two missions, I want to have a number, 0-3 inclusive, that tells me how many of them are dead.

I decide I'm going to use a CPV to achieve this. I'll call it @destroyedCount.

I add the following events to Mission 1:
If the Enterprise explodes, add 1 to @destroyedCount
If the Falcon explodes, add 1 to @destroyedCount
If the Tardis explodes, add 1 to @destroyedCount

Then I add the same events to Mission 2. If a ship blew up in Mission 1 it doesn't appear in Mission 2, so we don't need to worry about its destruction being counted twice.

In mission 3, I check the value of @destroyedCount to branch the mission into one of four states. I don't bother to handle values below 0 and above 3.

Have I implemented this correctly?

 

Offline Luis Dias

  • 211
Re: Campaign persistent variables
Obviously from those three, only the Enterprise is going to be destroyed, so that probably should be hardcoded.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Campaign persistent variables
Here's a bonus round that rather spoils the game -

Spoiler:
I lose the Enterprise during Mission 1. Later in the mission, I fail, and I'm kicked to a failure debrief screen. I hit 'replay mission'. I lose the Enterprise again, but I beat the mission and proceed in the campaign. What is the value of @destroyedCount going into Mission 2?

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Campaign persistent variables
I think I know what you're getting at.. and I think I've run into that same problem.

Spoiler:
@destroyedCount  becomes 2, in that case right? (Because CVs are apparently saved when the debrief starts, regardless of anything else.) When it should be 1.

I got around it by using a temporary variable and then storing a PPV upon mission success and Alt-J pressed, iirc.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Campaign persistent variables
I think I'd actually qualify this behavior as a straight-up bug.

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Campaign persistent variables
And I would agree. CVs should take success into account, which it can get from the campaign file.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: Campaign persistent variables
CPVs are only supposed to be recorded when the mission succeeds and you advance in the campaign.  If you restart the mission, they are supposed to revert back to their old values as if the mission had never been played.

(I think the way this is implemented is that they are recorded when the debriefing starts, but if you select "retry the mission again later" they are rolled back.  The same happens with other player stats such as scoring and medals.)

CPVs have worked this way ever since they were implemented, lo these many years ago.  If they are acting differently in 3.7+ builds, there is probably a bug in the new pilot code.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Campaign persistent variables
They don't seem to be rolling back correctly after a failure debrief. This bug could be part of the new pilot code, as it dates back to the BP2 Tenebra release.

 

Offline niffiwan

  • 211
  • Eluder Class
Re: Campaign persistent variables
Urgh.  Another bug in the pilot code :(
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline Axem

  • 211
Re: Campaign persistent variables
Okay, I just wasn't sure if it was intended behavior or not. I guess it really is a bug then!

I confirmed the problem is not present in 3.6.18 and only appears with 3.7.0

I have Mantised the bug and have linked to a campaign with easy steps to reproduce.

http://scp.indiegames.us/mantis/view.php?id=3051

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Campaign persistent variables
That's definitely a bug. Only player persistant variables should survive something like that without rolling back.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]