Author Topic: Help! Something is screwing with my variables  (Read 684 times)

0 Members and 1 Guest are viewing this topic.

Help! Something is screwing with my variables
Ok people I really tried everything that came to my mind but now I'm stuck.

I have a mission that later becomes part of a campaign file. The loadout depends on the variables from other missions. I can use the team-loadout-window in FRED to tell that the amount of a weapon shall be set from the corresponding variable. After that, I save and exit.

If I reopen the file via FRED some of these weapons are unchecked or now have a certain amount instead of being set from a variable.

If I open the mission with Notepad++, the line shows the following:

Quote
+Weaponry Pool: (
   "Bullseye"   @Loadout_Bullseye
   "Haymaker"   @Loadout_Haymaker
   "Rossmore"   @Loadout_Rossmore
   "Ripper"   @Loadout_Ripper
   "Rosebud"   @Loadout_Rosebud
   "Ambassador"   @Loadout_Ambassador
   "Vendetta"   @Loadout_Vendetta
   "Needle"   @Loadout_Needle
   "Sling"   @Loadout_Sling
   "Sling MK 2"   @Loadout_SlingMK2
   "Tomahawk"   @Loadout_Tomahawk
   "Labrys"   @Loadout_Labrys
   "Trident"   @Loadout_Trident
   "Pilum"   @Loadout_Pilum
   "Hurricane"   @Loadout_Hurricane
   "Typhoon"   @Loadout_Typhoon
   "Bullseye"   11
   "Haymaker"   12
   "Rossmore"   1
   "Needle"   480
   "Sling"   1020
   "Tomahawk"   220
   "Pilum"   60

So see, some of them are double. If I delete the ones with the numbers and just have the ones with the variables, everything seems ok (no doubles). But back in FRED some are again set to "don't use variables", some remain with variables.
I used 3.8 and the latest nightly, the problem remains the same.

Or is this just because there is no campaign file behind it where it can check for the corresponding variables (AKA which weapon was chosen before)? Will this problem go away once a campaign file is created?

Strangely, this only happens with the weapon-variables. The ship-variables all stay as "Set amount from variable"...

Quote
$Ship Choices: (
   "MLF Foxhound"   @Loadout_Foxhound
   "MMF Tornjak"   @Loadout_Tornjak
   "MMF Bulldog"   @Loadout_Bulldog
   "MMF Husky"   @Loadout_Husky
   "MMF Pitbull"   @Loadout_Pitbull
   "MHF Mastiff"   @Loadout_Mastiff
   "MHF Bandog"   @Loadout_Bandog
   "MVHF Wolfhound"   @Loadout_Wolfhound
   "MB Tiger"   @Loadout_Tiger
   "MB Lion"   @Loadout_Lion
)

Any ideas WHY this is happening and what I can do? Or will this not become an issue once the campaign file is created?

The variables are all set to "campaign-persistant", by the way. This strange behaviour also leads to the fact that when I start the mission, I'm told "Player has no weapons", the weapon loadout screen stays empty.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Help! Something is screwing with my variables
To be fair, the weapon stuff hasn't been tested anywhere near as much as the ship stuff was (You might be the first person to use it this way since I wrote the code over 10 years ago). Can you test to see if you get the same behaviour with retail data (or the media VPs) and if you do, post the mission. I'll look at it as a matter of priority this weekend if you can. This definitely isn't related to the campaign file as FRED doesn't care about that at all.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 
Re: Help! Something is screwing with my variables
By retail data you mean creating variables with the retail weapons? Then I would try to rebuild the mission with the standard weapons and models and post it.
« Last Edit: March 08, 2018, 08:49:56 am by bomb3rman »

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Help! Something is screwing with my variables
Yeah. That way I can run it via the debugger and see what's going on.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 
Re: Help! Something is screwing with my variables
There you go. Didn't use all FS2 weapons, but enough to show the problem. Again, the ships are all shown correctly. And again, some weapons are unchecked and in the file they appear with the variable and again with the numbers... I hope this helps. If you need more, just ask.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Help! Something is screwing with my variables
Okay I see what's causing the problem in FRED. If you edit the mission in notepad does it work correctly in FS2? I'm just wondering if I have to fix FRED or FRED and FS2.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 
Re: Help! Something is screwing with my variables
When I see that it wasn't working in fred I took notepad to delete the ones with the numbers. But when I went back into Fred the problem remains. So I think It's both.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Help! Something is screwing with my variables
I know the numbers come back, that's because FRED will alter the mission as soon as you open the loadout editor. So of course when you save it, the error is also saved. What I'm asking is if the fixed version works flawlessly in FS2. Without taking a good look at the code, there is no way to know for certain apart from testing it. I suspect it will since FS2 doesn't save the mission, only load it. And it does it using different code, which isn't required to work out the number of weapons on board the default fighters.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

  
Re: Help! Something is screwing with my variables
Hey, sorry for not replying earlier. Work ;)

If I fix the mission via Notepad and hit "save" and just start FS2, all variables appear correctly.

If I fix the mission via Notepad and hit "save" and start FRED, some are unchecked again. If I recheck them in the loadout editor and enable "set amount from variable" and hit "save", the numbers can be seen via Notepad again. So the problem appears to be FRED, not FS2 I guess.

So I hope this helps and clarifies it.

There's a second thing that I found out while setting the default number of the variables to 500: My wingmen seem to take the guns and weapons from "my pool", too. Even if I locked their ships and weapons via the initial status editor. (I thought this would "block" their weapon banks) Is there a way to prevent this (except from making the number of a specified weapon exactly the way that the amount of the wingmen is filled and the "leftover" is the stuff I can use).

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Help! Something is screwing with my variables
Okay, I finally got a chance to test this with a debug build and it's fairly easy to see what's happening. When I coded this feature I always imagined that the user would have a certain set of default weapons that were always available and upgrades that would be dependent on variables. Your missions seem to have gone the route of having all the weapons available via variables. This is causing a problem because the ships in the default wings all have weapons on board and these need to go into the loadout tallys.

In mission 1 of your campaign are all the weapons still dynamic? Are there no default weapons which are always available for the campaign?

There are some ways that the code can be fixed in order to deal with the problem if not, but that would definitely be the easiest solution.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 
Re: Help! Something is screwing with my variables
Basically it's not mission 1 of the campaign but somewhen later. But in the first mission when the variables are used, the player has 1 (very light) ship and 1 primary and 2 different secondaries available. Ever other weapon/ship will come available with dynamic variables (aka after they were bought).

The buy-event allows the ship/weapon/missile and modifies the variable.

I could change that by simply allowing all ships/primaries/secondaries in the first mission where all of this starts and just change the buy-event so that it only modifies the variable when one of them is bought. Would that help?

If I get this correctly, then the primaries and secondaries the other ships and wings have on board would go into the "extra available" window and be chosen by them. Or am I getting something wrong?

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Help! Something is screwing with my variables
Not quite. There is no need to allow all ships/primaries/secondaries or change the buy events.

Basically think of the system as being like an old arcade shoot-em-up. You have your default primary and secondary weapon and everything else is a power up (which is available via a variable). The problem is that you've also used variables for the default weapons. The ships in the mission you gave me are armed with Subachs, Prom R, Hornets and Harpoons (just go into ships editor -> Weapons). So the game is assuming that those are the defaults that are always available. But you also have a variable for the number of Subachs, etc. And FRED basically ignores variables when it tries to arm wings with default weapons. If you run a debug build you'll actually get a warning on loading that mission ("Subach HL-7 is used in wings of team 0 but was not in the loadout. Fixing now"). That's what's causing the problem.

If you remove the variables for Subachs, Prom R, Hornets and Harpoons the problem goes away, so the trick is simply to make sure that the "1 primary and 2 different secondaries" you mentioned are the ONLY weapons that are on any wingmen in Alpha, Beta or Gamma in your mission. If I look at the original post I can see that you have a lot of different kinds of weapons on the ships of those wings.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 
Re: Help! Something is screwing with my variables
Ok I get it.

But here's the problem: I would like to have the other ships different weapons than the player at some point. Think of the wingmen as other mercenaries who take care of their weapons for themselves.

So my idea would be to "allow" all weapons by default and just set the amount of "extra available" exactly as high as they are needed for the wingmen. Since the player can't switch the weapons of the wingmen, I guess the extra available ones go into their slots. So what remains are only the weapons that the player has bought (loaded via amount the variable is set to). Or won't this work?

Another option could be to change the weapons of the wingmen via sexp directly after the mission has started.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Help! Something is screwing with my variables
I'm not certain that would work, but if it does, tell me.

If not, simply add that number of weapons in the preceding mission. That way they'd be doled out to the wingmen immediately in the briefing and since the ships are locked, the player wouldn't be able to grab them for themselves.

If I get the chance, I'd like to see if I could improve the way the game gives out weapons so that kind of nonsense isn't necessary, but it will be a while before I have the time to deal with something like that.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 
Re: Help! Something is screwing with my variables
Quote
If not, simply add that number of weapons in the preceding mission. That way they'd be doled out to the wingmen immediately in the briefing and since the ships are locked, the player wouldn't be able to grab them for themselves.

That's a very good idea! I'll test both ways and see if they bring the same results. So I guess I'll go with allowing all weapons from the beginning and just modifying the variables.

Thanks!