2018-04-12 11:18:19 +00:00
|
|
|
#ifndef OPENMW_RECORDHELPER_HPP
|
|
|
|
#define OPENMW_RECORDHELPER_HPP
|
|
|
|
|
[General] Implement RecordDynamic packet, part 1
Spell, potion, enchantment, creature, NPC, armor, book, clothing, miscellaneous and weapon record data can now be sent in a RecordDynamic packet. Additionally, the packets include data related to associated magical effects (for spells, potions and enchantments), data related to default inventory contents (for creatures and NPCs) and data related to body parts affected (for armor and clothing).
The server now has associated script functions for setting most of the details of the above, with the main exception being individual creature and NPC stats.
Records can either be created entirely from scratch or can use an existing record (set via the baseId variable) as a starting point for their values. In the latter case, only the values that are specifically set override the starting values. Creature and NPC records also have an inventoryBaseId that can be used on top of the baseId to base their inventories on another existing record.
The client's RecordHelper class has been heavily expanded to allow for the above mentioned functionality.
When players create spells, potions and enchantments as part of regular gameplay, they send RecordDynamic packets that provide the server with the complete details of the records that should be created. When they create enchantments, they also provide the server with armor, book, clothing and weapon records corresponding to the items they've enchanted.
This functionality added by this packet was originally supposed to be exclusive to the rewrite, but I've gone ahead and tried to provide it for the pre-rewrite in a way that can mostly be reused for the rewrite.
2018-07-30 07:56:26 +00:00
|
|
|
#include <components/openmw-mp/Base/BaseWorldstate.hpp>
|
|
|
|
|
2018-04-12 11:18:19 +00:00
|
|
|
#include <components/esm/loadcrea.hpp>
|
|
|
|
#include <components/esm/loadnpc.hpp>
|
|
|
|
|
|
|
|
namespace RecordHelper
|
|
|
|
{
|
[General] Implement RecordDynamic packet, part 1
Spell, potion, enchantment, creature, NPC, armor, book, clothing, miscellaneous and weapon record data can now be sent in a RecordDynamic packet. Additionally, the packets include data related to associated magical effects (for spells, potions and enchantments), data related to default inventory contents (for creatures and NPCs) and data related to body parts affected (for armor and clothing).
The server now has associated script functions for setting most of the details of the above, with the main exception being individual creature and NPC stats.
Records can either be created entirely from scratch or can use an existing record (set via the baseId variable) as a starting point for their values. In the latter case, only the values that are specifically set override the starting values. Creature and NPC records also have an inventoryBaseId that can be used on top of the baseId to base their inventories on another existing record.
The client's RecordHelper class has been heavily expanded to allow for the above mentioned functionality.
When players create spells, potions and enchantments as part of regular gameplay, they send RecordDynamic packets that provide the server with the complete details of the records that should be created. When they create enchantments, they also provide the server with armor, book, clothing and weapon records corresponding to the items they've enchanted.
This functionality added by this packet was originally supposed to be exclusive to the rewrite, but I've gone ahead and tried to provide it for the pre-rewrite in a way that can mostly be reused for the rewrite.
2018-07-30 07:56:26 +00:00
|
|
|
void overrideCreatureRecord(const mwmp::CreatureRecord& record);
|
|
|
|
void overrideNpcRecord(const mwmp::NpcRecord& record);
|
|
|
|
|
|
|
|
void overrideEnchantmentRecord(const mwmp::EnchantmentRecord& record);
|
|
|
|
void overridePotionRecord(const mwmp::PotionRecord& record);
|
|
|
|
void overrideSpellRecord(const mwmp::SpellRecord& record);
|
|
|
|
|
|
|
|
void overrideArmorRecord(const mwmp::ArmorRecord& record);
|
|
|
|
void overrideBookRecord(const mwmp::BookRecord& record);
|
|
|
|
void overrideClothingRecord(const mwmp::ClothingRecord& record);
|
|
|
|
void overrideMiscellaneousRecord(const mwmp::MiscellaneousRecord& record);
|
|
|
|
void overrideWeaponRecord(const mwmp::WeaponRecord& record);
|
2018-04-12 11:18:19 +00:00
|
|
|
|
2019-07-27 00:45:50 +00:00
|
|
|
void overrideContainerRecord(const mwmp::ContainerRecord& record);
|
|
|
|
void overrideDoorRecord(const mwmp::DoorRecord& record);
|
|
|
|
|
2019-08-01 06:48:57 +00:00
|
|
|
void overrideActivatorRecord(const mwmp::ActivatorRecord& record);
|
|
|
|
void overrideStaticRecord(const mwmp::StaticRecord& record);
|
|
|
|
|
2019-08-03 03:19:22 +00:00
|
|
|
void overrideIngredientRecord(const mwmp::IngredientRecord& record);
|
2019-08-04 14:53:18 +00:00
|
|
|
void overrideApparatusRecord(const mwmp::ApparatusRecord& record);
|
|
|
|
void overrideLockpickRecord(const mwmp::LockpickRecord& record);
|
|
|
|
void overrideProbeRecord(const mwmp::ProbeRecord& record);
|
|
|
|
void overrideRepairRecord(const mwmp::RepairRecord& record);
|
2019-08-14 18:10:53 +00:00
|
|
|
void overrideLightRecord(const mwmp::LightRecord& record);
|
2019-09-28 10:12:48 +00:00
|
|
|
void overrideCellRecord(const mwmp::CellRecord& record);
|
2019-08-03 03:19:22 +00:00
|
|
|
|
2019-10-15 05:47:54 +00:00
|
|
|
template<class RecordType>
|
2019-10-16 10:14:32 +00:00
|
|
|
void overrideRecord(const RecordType &record)
|
2019-10-15 05:47:54 +00:00
|
|
|
{
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
2019-10-16 10:14:32 +00:00
|
|
|
world->getModifiableStore().overrideRecord(record);
|
2019-10-15 05:47:54 +00:00
|
|
|
}
|
|
|
|
|
2019-10-15 04:21:48 +00:00
|
|
|
template<class RecordType>
|
2019-10-16 10:14:32 +00:00
|
|
|
const RecordType *createRecord(const RecordType &record)
|
2019-10-15 04:21:48 +00:00
|
|
|
{
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
2019-10-16 10:14:32 +00:00
|
|
|
return world->createRecord(record);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class RecordType>
|
|
|
|
bool doesRecordIdExist(const std::string& id)
|
|
|
|
{
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
return world->getStore().get<RecordType>().search(id);
|
2019-10-15 04:21:48 +00:00
|
|
|
}
|
2018-04-12 11:18:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif //OPENMW_RECORDHELPER_HPP
|