OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: SaOk on 03 Apr 2011, 22:49:51
-
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?
-
Using saveVar, saveStatus
-
Thank you. :)
-
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.
-
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.
-
I'm interested too in that feature!!
:good:
where can it be found?
-
: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.
-
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.
-
:good:
-
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:
PlCo = [weapons leader player,magazines leader player,damage leader player];
saveVar "PlCo";
Then in the next mission init.sqf, I use this data with:
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: I changed the order for weapons and magazines, following Zipper5´s nice find.
-
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:
player setHit ["legs",0];:)
-
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?
-
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.