Home   Help Search Login Register  

Author Topic: Passing info (variables, arrays) from mission to next one in campaign  (Read 4046 times)

0 Members and 1 Guest are viewing this topic.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Is it possible to store data (variables, arrays) in a campaign mission and use it in next mission? In official resistance campaign weapons/magazines were stored. How that was made?

Offline i0n0s

  • Moderator
  • *****
Using saveVar, saveStatus

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Thank you. :)

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
I've got a whole script suite for this stuff (moving people/vehicles/etc persistently from mission to mission) that I made for ArmA and that, AFAIK, works in Arma 2 as well. Let me know if you'd like to borrow it ;) It's harder than you think, actually...

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Hey thanks, that would be great and time saving, if you could borrow that. I planning to add at least few things that would transfer between missions. Burned vehicles from earlier battles, maybe some cars and also weapon cargo or something.

Offline fleepee

  • Members
  • *
  • Enter the Matrix!
I'm interested too in that feature!!
 :good:
where can it be found?

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
 :dry:

I promised too much too soon, it seems. Due to some changes in how Arma 2 treats "undefined variables", the scripts as they are right now throw up errors (they still work, more or less, but it's ugly). Secondly, the way Arma 2 treats initializations fucks things up - in ArmA, if you used "call" on a script in the init.sqf, it'd run BEFORE the briefing loaded. In Arma 2, call no longer does that. In short, there's a lot of weirdness. On the other hand, Arma 2 might have changed how saveVar works as well, hopefully improved it, so I might not need my workarounds any longer. I'd need to experiment with that. Naturally experimenting with campaign saving and loading is terribly time-consuming, so it might take a while. Sigh.  >:(

Sorry, I'll get back to you though if I can get it to work. For now, I suggest you simply use saveVar to save a variable that checks alive/dead on your units, and then use it as their "condition of presence" when placing them - that ought to work (mind though that saveVar saves backwards as well, meaning that if you revert to an earlier spot in the campaign where the unit SHOULD be alive, it'll be dead if the variable was ever updated with saveVar  ::) You need to use separate variables between missions to circumvent that).

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Sure, no hurry. :) I will try that saveVar at somepoint when I have made more progress in other parts (in that campaign). If I find something usefull of this issue, I will post examples here.

Offline fleepee

  • Members
  • *
  • Enter the Matrix!

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Sorry, I almost forgot to write my findings here. But I am now using the saveVar like this:

In my campaign, I copy player gear and damage in every mission ending script with:
Code: [Select]
PlCo = [weapons leader player,magazines leader player,damage leader player];
saveVar "PlCo";
Then in the next mission init.sqf, I use this data with:
Code: [Select]
if (!isnil("PlCo")) then {
removeallweapons player;
_we = PlCo select 0;
_ma = PlCo select 1;
_da = PlCo select 2;
        {player addmagazine _x;} foreach _ma;
{player addweapon _x;} foreach _we;
player setDamage _da;
while {!(canStand player)} do {_da = _da - 0.05;player setdamage _da;};
};

So the PlCo is created in 1st mission, then always overwrited in next missions. To make sure, there is no errors if reverting or something deletes the variable, I have isNil-check for the variable in init.sqf before trying to copy data from it.

Edit:
« Last Edit: 09 Jul 2011, 13:52:59 by SaOk »

Offline Zipper5

  • BIS Team
  • ****
Two things about that otherwise-fine script, SaOk:

1) You should always add magazines before adding a weapon as then the player won't have to reload his weapon. An engine issue since OFP.
2) Instead of that damage check at the end, you can try just using:
Code: [Select]
player setHit ["legs",0];:)

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Good to know :). I have wondered why the actors reload their weapons in cutscenes where I have also the weapons added before magazines. I am going to fix that, thx.

A slightly similar question, is it possible to pass variables and other data into a mission outro in a single player mission as opposed to just another mission in a campaign?

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
I believe it work in the same way. But instead of getting the info from variable in init.sqf. You just get that in some outro-script.