CharmedBaryon / CommonLibSSE-NG

This is a reverse engineered library for Skyrim Special Edition and Skyrim VR.
MIT License
142 stars 32 forks source link

TESForm::CreateDuplicateForm and TESForm::Copy dont do what the supposed to #78

Open CustomPhase opened 1 year ago

CustomPhase commented 1 year ago

TESForm::CreateDuplicateForm creates a new empty form, instead of a duplicate. TESForm::Copy doesnt copy anything. We have to manually copy every field because of this, i.e.


RE::TESForm* weaponCopy = nullptr;
weaponCopy = ref.GetBaseObject()->CreateDuplicateForm(true, (void*)weaponCopy);
auto source = ref.GetBaseObject()->As<RE::TESObjectWEAP>();
auto target = weaponCopy->As<RE::TESObjectWEAP>();
//target->Copy(source); Does nothing. We have to copy things manually
target->weaponData = source->weaponData;
target->criticalData = source->criticalData;
target->criticalData.damage = 0;
target->criticalData.prcntMult = 0;
target->fullName = std::string("FUCKED ").append(source->fullName);
target->textureName = source->textureName;
target->boundData = source->boundData;
target->model = source->model;
target->attackSound = source->attackSound;
target->equipSlot = source->equipSlot;
target->equipSound = source->equipSound;
target->unequipSound = source->unequipSound;
target->firstPersonModelObject = source->firstPersonModelObject;
target->data = source->data;
target->fileOffset = source->fileOffset;
target->formFlags = source->formFlags;
target->impactDataSet = source->impactDataSet;
target->icon = source->icon;
target->keywords = source->keywords;
target->attackFailSound = source->attackFailSound;
target->pickupSound = source->pickupSound;
target->textures = source->textures;
target->addons = source->addons;
target->numAddons = source->numAddons;