Home   Help Search Login Register  

Author Topic: loadStatus/saveStatus and campaigns  (Read 3983 times)

0 Members and 1 Guest are viewing this topic.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
loadStatus/saveStatus and campaigns
« on: 10 Jul 2007, 11:13:47 »
Hello all!  :D

Now, I understand questions pertaining to "loadStatus and weaponpools" and such are advanced, why I'm writing here. Also I generally feel confident I can answer most questions on my own only through consulting the COMREF and hands-on testing, but this thing has me seriously stumped. And frustrated. Here's the basic layout:

I'm modding Tacrod's excellent ADCS 0.1 BETA system (I believe you can find it in the User Missions section in the official forums), which is basically a dynamic campaign system that randomly assigns a mission type and then randomly generates the location/enemy/friendly forces etc. Bareboned, but very nicely done.

Anyway, I've wanted to add some more persistant elements to this, and I have some larger plans in the pipeline as well, but the first things I wanted to do was just change it so that instead of, as in the default scripts, getting a full squad spawned on me at the beginning of every mission, I'd have a persistent squad that gains experience and to which I can assign weapons and roles and so on. Alright, weaponpool up and working no problem, but the persistance is an issue.

Basically I use init.sqs and exit.sqs. I haven't the scripts with me right now, but the basic layout is as follows: Each soldier in the squad is named U1->U8, the player being u0. In the init.sqs of every mission in the campaign, I simply loadStatus every member, and then run a short snippet removing all the units who are dead :
Code: [Select]
? {!alive _x : deleteVehicle _x} forEach [array of u0-u8 here]And in the exit.sqs I first deleteStatus everyone
Code: [Select]
{deleteStatus _x}foreach [array of status string-names here] and then saveStatus them again.

Now, I found some problems with the deleteStatus command : essentially it didn't seem to work as I wanted it to, so I removed it, and the mission played well for a while : people killed didn't turn up in the next mission, ammo and weapons were stored. And then it just randomly stopped working. Some of my units returned for no reason, sometimes all of them returned, sometimes their custom experience levels stopped working, their ranks didn't transfer over...blargh. Basically all the signs of "the load/saveStatus commands aren't functioning".

Once I get home I can post you the mission and you can see it for yourself, but the very heart of my question is simple:

loadStatus = loads saved status, which includes health levels, rank, skill level, name, weapon loadout + possible other things (confirmed)
saveStatus = saves all of the above into "string name", accessible with loadStatus.
deleteStatus = removes the "string name" and the saved status from the objects.sav or wherever, WITHOUT for that automatically removing any already loaded statuses!

So, essentially, all I should need to have a unit carrying over from mission to mission would be:

Code: [Select]
init.sqs

unit1 loadStatus "unit1"
?!alive unit1 : deleteVehicle unit1

exit.sqs

deleteStatus "unit1"; unit1 saveStatus "unit1"

The above is essentially my code. Why doesn't it work, always? It works sometimes, sometimes it doesn't. It works for one or two missions, then stops. ARGH!  >:( It's driving me nuts, quite frankly.

Thanks anyway!

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

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: loadStatus/saveStatus and campaigns
« Reply #1 on: 10 Jul 2007, 11:30:42 »
Why you delete the status of a unit just before saving it? And, you are deleting dead units, but you are still saving their status at exit.sqs, right? IMO you should not delete these dead units if you want to save their status later.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: loadStatus/saveStatus and campaigns
« Reply #2 on: 10 Jul 2007, 11:37:07 »
cud try 2 save em nd den delete em ???

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: loadStatus/saveStatus and campaigns
« Reply #3 on: 10 Jul 2007, 12:30:27 »
@Mandoble

I delete the old status..uhm...mostly because I've seen other people do it.  :blink: Although if I comment out the deletion of the old status, it still works, but still doesn't work (consistently). Also, I've noticed that if you cancel a mission and revert to a previous one in the campaign, the saved statuses of all the units remain (i.e., they will have the weapons & such given to them in a LATER mission at an EARLIER state). Which is basically a really weird thing, overall  :dunno:

@LCD

Saving them and then deleting them would not seem to make much sense to me since, well, what's there to load in the next mission then? Unless you mean loading them and then deleting them, which I've also tried, and which generally doesn't yield good results (I theorize that if you delete the statuses in the init.sqs right after having loaded them, it retroactively deletes the already loaded statuses and thus give you a full group with default equipment. Argh!).

There might be something in my fast editing of the missions though (I edit them directly in their campaign folder). Although I always delete the save files generated in the Wolfrug/Saved/campaigns/ADCS Mercs folder (to start from the beginning), it still doesn't always seem to get all edits I've made. If I try to ctrl-X, ctrl-V the files away, Windows sometimes randomly complains they're in use (even though I'm not even in the campaign screen at the time).

Sighety sigh. ArmA, eh?

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

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: loadStatus/saveStatus and campaigns
« Reply #4 on: 10 Jul 2007, 12:45:56 »
Not sure what would be the behaviour of saving or deleting statuses of deleted units  :scratch:

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: loadStatus/saveStatus and campaigns
« Reply #5 on: 11 Jul 2007, 00:05:23 »
Addons required edited!

Alright, after another couple of fruitless hours of testing I'm entirely stumped. No matter what I do, I simply can't get even the most basic of functions to work with this any more. Basically, it doesn't work. The code is the exact same as when it worked, the -exact- same...but it simply isn't functioning anymore. :confused:

I actually added a secondary system to check for dead/alive-ness, but that didn't seem to work either. This involved using saveVar to save a variable which could be true or false, and needed to be true to even -spawn- the units in the first place (condition of presence : uxalive, x being a number from 1-8). Basically in the exit.sqs of every run-through it checks if each unit is alive or not, and if not, makes the attached variable false. Which -should- work, even if the save/loadStatus doesn't.

Except, well, it don't. The same load/saveStatuses are still in place, although I've commented out the deleteStatus. But it doesn't even save their weapons anymore, not even the players. It saves nothing at all, it simply doesn't work. I am entirely stumped. Please, if anyone could make sure that YES in fact this does not work and NO it's not just the ghost in my machine doing this, then that alone could be of aid. Attached is the campaign - all it needs is to be unRARed and then placed in your campaigns folder (it's not a pbo, for ease of editing and checking stuff out).

Basically what you'll need to do is simply start the first mission, kill one of your men/change your loadout, and then see if any of these carry on to the next mission. In my experience, they do not. For no reason whatsoever. Maybe I've gone blind. Except for the first mission (which has some saveVars and addWeaponPools), the init/exit.sqs are identical for each mission.

Oh, and, argh....this is a bummer. But you'll also need:

Skaven's RACS Mercs V3 (http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=f6ae07e13a2d3c99999ad7649938c9a6;act=ST;f=70;t=65148)

NIM Dynamic Weather
(http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=7fed3d0f0dc69265c495be4385566a7b;act=ST;f=70;t=57830 )

EDIT:http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=e54833065dd0b0af8a6a0b54f2ac5e89;act=ST;f=70;t=65124)

(sorry about forgetting that one -> it was late when I posted this >_<)

Hopefully I haven't added any more addons there by accident, sigh.

And, since I understand not everyone wants to download these by themselves, here are the pertinent init.sqs and exit.sqs:

Code: [Select]
;init.sqs

Player loadStatus "u0"
u1 loadStatus "u1"
u2 loadStatus "u2"
u3 loadStatus "u3"
u4 loadStatus "u4"
u5 loadStatus "u5"
u6 loadStatus "u6"
u7 loadStatus "u7"
u8 loadStatus "u8"

{ if (!alive _x) then { deletevehicle _x }; _x setdammage 0 } foreach [u0, u1, u2, u3, u4, u5, u6, u7, u8];

[] exec "Core\StartADCS.sqs"
titletext ["Please wait","BLACK OUT",0.1]
exit

Code: [Select]
;exit.sqs
{_xp = (rating _x / 10000); _x setskill (skill _x + _xp)} foreach units group player
{ if (!alive _x) then { deletevehicle _x }; _x setdammage 0 } foreach [u0, u1, u2, u3, u4, u5, u6, u7, u8];
?!alive u1 : u1alive = false
?!alive u2 : u2alive = false
?!alive u3 : u3alive = false
?!alive u4 : u4alive = false
?!alive u5 : u5alive = false
?!alive u6 : u6alive = false
?!alive u7 : u7alive = false
?!alive u8 : u8alive = false

;{deleteStatus _x}foreach ["u0", "u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8"]
~0.1
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"

exit

The code with the _xp in the exit.sqs is just there to add "experience" to your soldiers (based on their individual rating, i.e. how many peeps they've killed). Also there's some random ADCS-related code, and some commented lines. And yes, I know that right now it's got a lot of superfluos stuff in it, but argh. It doesn't seem to matter how much I edit or move around or whatever...it's stopped working.  :dunno:

Aaahh, well. Hope someone can figure something out.

Thanks!

Wolfrug out.

Edit : removed now-unnecessary mission file!
« Last Edit: 14 Jul 2007, 13:29:12 by Wolfrug »
"When 900 years YOU reach, look as good you will not!"

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: loadStatus/saveStatus and campaigns
« Reply #6 on: 11 Jul 2007, 22:21:07 »
 :blink:

Uhm. Okay. Now it works again. I removed a couple of commented texts and changed the position of another thing. And now...it works. What the heckers?  :o

I think it was the whole saveVar "u1alive" thing that did it ultimately though : that seems to work. Of course, you still can't revert in the campaign (since the variable will invariably be the same throughout, apparently?), but maybe that can be worked around somehow. For now, at least, this thingamajog seems to be working again.

 :goodnight:

Time for sleep.

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

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: loadStatus/saveStatus and campaigns
« Reply #7 on: 12 Jul 2007, 15:24:45 »
How about a quick post of the working solution?

:yes: Share and Enjoy! :yes:
urp!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: loadStatus/saveStatus and campaigns
« Reply #8 on: 12 Jul 2007, 17:32:02 »
same, fairly unedited init.sqs:

Code: [Select]
Player loadStatus "u0"
u1 loadStatus "u1"
u2 loadStatus "u2"
u3 loadStatus "u3"
u4 loadStatus "u4"
u5 loadStatus "u5"
u6 loadStatus "u6"
u7 loadStatus "u7"
u8 loadStatus "u8"

{ if (!alive _x) then { deletevehicle _x }; _x setdammage 0 } foreach [u0, u1, u2, u3, u4, u5, u6, u7, u8];

[] exec "Core\StartADCS.sqs"
titletext ["Please wait","BLACK OUT",0.1]
exit

slightly changed exit.sqs:

Code: [Select]
{_xp = (rating _x / 10000); _x setskill (skill _x + _xp)} foreach units group player

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"

exit

The first mission's init sequence has a list like the above which goes through each "u#alive" and sets them to true, as per so:

Code: [Select]
u1alive = true; saveVar "u1alive"
u2alive = true; saveVar "u2alive"
u3alive = true; saveVar "u3alive"
u4alive = true; saveVar "u4alive"
u5alive = true; saveVar "u5alive"
u6alive = true; saveVar "u6alive"
u7alive = true; saveVar "u7alive"
u8alive = true; saveVar "u8alive"

Each unit from U1-U8 have, after the first mission, as their editor-given "Condition of Presence" their asigned "uxalive". So that if they're dead (=false) then they won't show up at all (idea courtesy of an OFPEC forums search & nominesine's helpful post about his Blue Skies campaign).

So, this works. Probably the whole "deletevehicle" thing in the init.sqs isn't really necessary since they shouldn't show up -anyway-, but yees...

The only strange this is, it DID work first with just the save/loadstatus and deletevehicle. :( Meh, ah well...lots of global variables, yay! And you still can't revert in any way, won't save statuses like that. Argh.

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

Offline Arkon

  • Members
  • *
Re: loadStatus/saveStatus and campaigns
« Reply #9 on: 13 Jul 2007, 13:35:23 »

Hi,

On the same subject of transfering stuff between missions in a campaign. Does anyone know if
it is possible to transfer a vehicle to the next mission?

Arkon

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: loadStatus/saveStatus and campaigns
« Reply #10 on: 13 Jul 2007, 15:04:00 »
It is. Check out this campaign: http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=9134ddffa2d111ec4b3cc93570eb6803;act=ST;f=67;t=65025 (Resistance Sniper II). It lets you store, I believe, up to 10 stolen vehicles between missions.

Unfortunately (ish) it seems to pretty far rely on "brute force" scripting : at the end of the missions the missionmaker checks what vehicles are within a certain radius of the player, and then depending on the type assigns a variable to it, which is then repeated at the start of the next mission and the vehicle is created. It seems a bit cumbersome to me, to be honest. I think it might have something to do with stopping the player from i.e. shooting down an AH-1 or something and keeping that around, and/or to avoid the problem with reverting to previous missions and still retaining your vehicles and so forth (problem I'm having). Haven't looked into it far enough.

Hm hm...I'mma gonna script something up theorethically about this, methinks...interesting stuff.  :scratch:

Wolfrug out.


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

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
"When 900 years YOU reach, look as good you will not!"