Home   Help Search Login Register  

Author Topic: saveStatus / loadStatus problem in Campaign  (Read 1914 times)

0 Members and 1 Guest are viewing this topic.

Offline gambla

  • Members
  • *
saveStatus / loadStatus problem in Campaign
« on: 16 Sep 2008, 14:27:13 »
Hi to all,

i'm working on my campaign that saves the health-status of the player (like PMC first fight) for each mission. It's working fine that a dead ai-unit of my team is deleted and doesn't appear in the next mission. But in this mission the unit-numbers are mixed up ? E.g. : unit #2 dies, next mission unit #3 is changed to #2 and #4 is now #3 ? I'v investigated this now for 2 days but can't find the problem. Does somebody has any idea ? thanks !

My init and exit-sqs looks like:



exit.sqs  e.g. mission1

x = Allen_sf1 saveStatus "sf1_01";
x = Walter_sf2 saveStatus "sf2_01";
x = Benjamin_sf3 saveStatus "sf3_01";
x = Bill_sf4 saveStatus "sf4_01";

exit

_________________________________________

init.sqs  e.g. mission2

PMCHQ=[West,"HQ"];

Allen_sf1 loadStatus "sf1_01"; Allen_sf1 setdammage 0;
Walter_sf2 loadStatus "sf2_01";
Benjamin_sf3 loadStatus "sf3_01";
Bill_sf4 loadStatus "sf4_01";

;call format [{[NVARecon12%1] join grpnull}, VTE_NVARecon]

{ if (!alive _x) then { deletevehicle _x }; _x setdammage 0 } foreach [Walter_sf2,Benjamin_sf3,Bill_sf4];






Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: saveStatus / loadStatus problem in Campaign
« Reply #1 on: 16 Sep 2008, 14:37:12 »
The correct group ID numbers are probably not getting assigned, since you are killing and deleting the dead people before they can be registered. Try waiting a little bit before getting rid of them (you might find it helpful if the player doesn't start the mission by looking at them, so he won't see them disappear):
Code: (init.sqs, campaign mission 2 (untested)) [Select]
PMCHQ=[West,"HQ"];

Allen_sf1 loadStatus "sf1_01"; Allen_sf1 setdammage 0;

~ 0.5;

Walter_sf2 loadStatus "sf2_01";
Benjamin_sf3 loadStatus "sf3_01";
Bill_sf4 loadStatus "sf4_01";

;call format [{[NVARecon12%1] join grpnull}, VTE_NVARecon]

{ if (!alive _x) then { deletevehicle _x }; _x setdammage 0 } foreach [Walter_sf2,Benjamin_sf3,Bill_sf4];

(incidentally, select a block of code and click on the # button to mark it as code, as I have above).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline gambla

  • Members
  • *
Re: saveStatus / loadStatus problem in Campaign
« Reply #2 on: 16 Sep 2008, 14:44:07 »
Thank you Spooner,

is this "~ 0.5;"  a time delay ?

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: saveStatus / loadStatus problem in Campaign
« Reply #3 on: 16 Sep 2008, 15:03:16 »
If I remember correctly I tried this in a campaign of my own (never released), and I did something like this:

First I saved the status of each group member like you have at the end of the mission. This assures that their weapons, names and damage levels are saved. After that, what I did was I saved a variable for each unit using saveVar, and then simply used that variable to determine whether they'd show up at all or not! I.e., I put it in their Condition of Presence field. So as so:

Code: (exit.sqf) [Select]
//Code run before mission ends

U0_var = Player saveStatus "u0"
U1_Var = u1 saveStatus "u1"
U2_Var = u2 saveStatus "u2"
U3_Var = u3 saveStatus "u3"
U4_var = u4 saveStatus "u4"
U5_var = u5 saveStatus "u5"
U6_var = u6 saveStatus "u6"
U7_var = u7 saveStatus "u7"
U8_var = u8 saveStatus "u8"

?!alive u1 : u1alive = false; saveVar "u1alive"
?!alive u2 : u2alive = false; saveVar "u2alive"
?!alive u3 : u3alive = false; saveVar "u3alive"
?!alive u4 : u4alive = false; saveVar "u4alive"
?!alive u5 : u5alive = false; saveVar "u5alive"
?!alive u6 : u6alive = false; saveVar "u6alive"
?!alive u7 : u7alive = false; saveVar "u7alive"
?!alive u8 : u8alive = false; saveVar "u8alive"

(You could also just make the !alive etc. more simple by adding an eventhandler or somesuch to each unit and saving their status that way)

Then, in the init.sqf, I'd load their statuses normally, but each unit (in the editor) would have a Condition of Presence which determines whether they showed up in the first place or not -> i.e., Condition of Presence: u7alive

Naturally the u1alive etc. need to be defined as =true in the first mission.

NOTA BENE: The persistent campaign system in ArmA is not very intuitive, and can be broken quite easily by the player. For instance if the player at one point decides he wants to return to an earlier mission using revert, that mission will now be using all the vars saved in later campaign missions! Meaning, for instance, that your soldiers will be equipped and dead/alive as was apparent when the player last stopped playing. The only way I can see to overcome this is for each mission to have their own saved variables and loading them as that.

Second NOTA BENE: Using Spooner's solution might fix things, but it might also break them: the 0.5 second wait might cause the dead soldiers to show up in the briefing screen, alive and breathing and capable of being equipped, only to disappear (with all their ammo and such) once the mission starts. Just a caveat lector. :)

Good luck!

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

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: saveStatus / loadStatus problem in Campaign
« Reply #4 on: 16 Sep 2008, 15:11:58 »
Yes, ~0.5 is a delay of half a second in SQS (incidentally, if you are just learning, I'd advise learning SQF rather than SQS, because SQS is obsolete; it still works in the game, but it is a "blunt tool").

I'm sure what Wolfrug says is right; by having that delay they will end up in the briefing, even if they are going to die. Perhaps try it with the delay immediately before the forEach line in your script. The issue is that the game doesn't apply the group IDs right away, so it might be that deleting them too early is what is causing the problem, rather than "killing" them. Afraid I haven't done any campaign work, so I can't really test or make further suggestions. Just some ideas that might get you somewhere.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline gambla

  • Members
  • *
Re: saveStatus / loadStatus problem in Campaign
« Reply #5 on: 16 Sep 2008, 16:25:01 »
Hi,
i did another change regarding the grouping, they are now grouped on mission start in every mission. So the unit-numbers are set correct now.  :)
But the status works only from mission 1 to 2. Unit2 dies in mission1, is not in mission2 but back again in mission3 ?  :(



EDIT  17.09.08:

It's working fine now. I've added the time delay in every init.sqs and unified the name of each unit's status-save-file to e.g. "sf2_01" in every mission's init.sqs and exit.sqs.

Thank you so much. :)

regards,
gam

« Last Edit: 17 Sep 2008, 05:55:55 by gambla »