gruppe-adler / grad-persistence

Save/Load mission progress in server's profileNamespace
26 stars 13 forks source link

[question] Not saving an object but obj is still loaded #44

Open Oldru opened 3 years ago

Oldru commented 3 years ago

I know that you can blacklist objects via class name and variable names, but is there any way to have an object not saved but still loaded on the next load?

EX: a vic that has some walls attached to it via attachTo and I don't want the walls saved so they will attach properly when loading a save once the vic has been moved.

nomisum commented 3 years ago

is this always the same attachment? if so use a CBA class init eventhandler so it runs when the vehicle spawns and reattaches stuff.

if only for specific vehicles of that type you can store a variable on the vehicle to check before.

in short: this can be handled without persistence i presume.

Oldru commented 3 years ago

it's more I don't want certain objects to save, however, if I blacklist them then they won't load at all.

as an example, if I blacklist the cargo net box class name, if I attach a box to a truck and save the mission. then load the mission the box won't load at all and won't even appear in the mission as if it never existed. I did some testing before I posted this question.

McDiod commented 3 years ago

I'm not sure I understand the question correctly. grad-persistence can obviously only load what it has previously saved.

Attached objects are not supported, so an object that was attached to something before saving, will be loaded at the last position, but unattached.

What you can do is:

  1. place the vehicle in 3den and give it a variable name (e.g. "oldru_veh1")
  2. place your wall attachment in 3den and paste this into the wall's init box:
[this] call grad_persistence_fnc_blacklistObjects;
[this, oldru_veh1] call BIS_fnc_attachToRelative;

grad-persistence will then use the editor placed vehicle instead of spawning a new one when loading. The attached walls will not be saved, but will be attached to the vehicle before grad-persistence loads the vehicle's position.

In theory this should work. If it doesn't, your walls were probably not attached before grad-persistence loaded the mission. In that case, use missionWaitCondition, e.g.:

missionWaitCondition = "(missionNamespace getVariable ['CBA_missionTime',0]) > 10";
nomisum commented 3 years ago

Would it be possible to support attached Objects or is this not a good idea due to mods using attachTo to simulate cargo inside (e.g. ACE)?

McDiod commented 3 years ago

Should be possible by nesting the attached objects in the parent object's save data, so

  1. check each object for attachment - only save it if it is not attached to anything, so no duplicates are created
  2. when saving an object, check for attachedObjects and arrayIntersect with ace_cargo_loaded
  3. save attached objects including all their data under a key in the parent object's data hash - flag ace_cargo objects

When loading, re-attach normal objects manually and ace_cargo objects with ace_cargo_fnc_loadItem.


However I'm sure there are other mods or user created scenarios that would need to be accounted for, so I'm hesitant to implement this.

Oldru commented 3 years ago

I got the chance to test what you suggested and it still makes the wall/box just disappear on mission load

I also have a video to show what I mean this time. https://youtu.be/oByOy6dZCxY