diff --git a/scripts/commandHandler.lua b/scripts/commandHandler.lua index 8f4fcad43a..68bc9c6295 100644 --- a/scripts/commandHandler.lua +++ b/scripts/commandHandler.lua @@ -1213,6 +1213,16 @@ function commandHandler.StoreRecord(pid, cmd) storedTable[inputSetting] = inputValue end + -- Remove any stored settings that are mutually exclusive with the one we've added + if config.mutuallyExclusiveRecordSettings[inputType] ~= nil and + tableHelper.containsValue(config.mutuallyExclusiveRecordSettings[inputType], inputSetting) then + for _, excludedSetting in pairs(config.mutuallyExclusiveRecordSettings[inputType]) do + if excludedSetting ~= inputSetting then + storedTable[excludedSetting] = nil + end + end + end + local message = "Storing " .. inputType .. " " .. inputSetting .. " with value " .. inputValue .. "\n" Players[pid]:Message(message) else @@ -1377,6 +1387,7 @@ function commandHandler.CreateRecord(pid, cmd) elseif inputType == "creature" then packetBuilder.AddCreatureRecord(id, savedTable) elseif inputType == "door" then packetBuilder.AddDoorRecord(id, savedTable) elseif inputType == "enchantment" then packetBuilder.AddEnchantmentRecord(id, savedTable) + elseif inputType == "gamesetting" then packetBuilder.AddGameSettingRecord(id, savedTable) elseif inputType == "ingredient" then packetBuilder.AddIngredientRecord(id, savedTable) elseif inputType == "light" then packetBuilder.AddLightRecord(id, savedTable) elseif inputType == "lockpick" then packetBuilder.AddLockpickRecord(id, savedTable) @@ -1392,7 +1403,7 @@ function commandHandler.CreateRecord(pid, cmd) tes3mp.SendRecordDynamic(pid, true, false) - if not tableHelper.containsValue({"spell", "cell", "script"}, inputType) then + if not tableHelper.containsValue(config.unplaceableRecordTypes, inputType) then if inputType ~= "enchantment" then if inputType == "creature" or inputType == "npc" then message = message .. "You can spawn an instance of it using /spawnat " diff --git a/scripts/config.lua b/scripts/config.lua index 9a381438b5..3e91e22fda 100644 --- a/scripts/config.lua +++ b/scripts/config.lua @@ -301,9 +301,10 @@ config.generatedRecordIdPrefix = "$custom" -- players, with the correct order ensuring that enchantments are loaded before items that might be -- using those enchantments or ensuring that NPCs are loaded after the items they might have in their -- inventories -config.recordStoreLoadOrder = { "script", "spell", "potion", "enchantment", "bodypart", "armor", - "clothing", "book", "weapon", "ingredient", "apparatus", "lockpick", "probe", "repair", "light", - "miscellaneous", "creature", "npc", "container", "door", "activator", "static", "cell", "sound" } +config.recordStoreLoadOrder = { "gamesetting", "script", "spell", "potion", "enchantment", "bodypart", + "armor", "clothing", "book", "weapon", "ingredient", "apparatus", "lockpick", "probe", "repair", + "light", "miscellaneous", "creature", "npc", "container", "door", "activator", "static", "cell", + "sound" } -- The types of records that can be enchanted and therefore have links to enchantment records config.enchantableRecordTypes = { "armor", "book", "clothing", "weapon" } @@ -313,6 +314,10 @@ config.enchantableRecordTypes = { "armor", "book", "clothing", "weapon" } config.carriableRecordTypes = { "spell", "potion", "armor", "book", "clothing", "weapon", "ingredient", "apparatus", "lockpick", "probe", "repair", "light", "miscellaneous" } +-- The types of records that cannot be placed in the world and should not display a message +-- about how to place them +config.unplaceableRecordTypes = { "spell", "cell", "script", "gamesetting" } + -- The settings which are accepted as input for different record types when using /storerecord config.validRecordSettings = { activator = { "baseId", "id", "name", "model", "script" }, @@ -332,6 +337,7 @@ config.validRecordSettings = { "aiFight", "aiFlee", "aiAlarm", "aiServices", "flags" }, door = { "baseId", "id", "name", "model", "openSound", "closeSound", "script" }, enchantment = { "baseId", "id", "subtype", "cost", "charge", "flags", "effects" }, + gamesetting = { "baseId", "id", "intVar", "floatVar", "stringVar" }, ingredient = { "baseId", "id", "name", "model", "icon", "script", "weight", "value" }, light = { "baseId", "id", "name", "model", "icon", "sound", "script", "weight", "value", "time", "radius", "color", "flags" }, @@ -366,6 +372,7 @@ config.requiredRecordSettings = { creature = { "name", "model" }, door = { "name", "model" }, enchantment = {}, + gamesetting = { "id" }, ingredient = { "name", "model" }, light = { "model" }, lockpick = { "name", "model" }, @@ -381,11 +388,17 @@ config.requiredRecordSettings = { sound = { "sound" } } +-- The record type settings that are mutually exclusive with each other and remove each other when one of +-- them is set +config.mutuallyExclusiveRecordSettings = { + gamesetting = { "intVar", "floatVar", "stringVar" } +} + -- The record type settings whose input should be converted to numerical values when using /storerecord config.numericalRecordSettings = { "subtype", "charge", "cost", "value", "weight", "quality", "uses", "time", "radius", "health", "armorRating", "speed", "reach", "scale", "part", "bloodType", "level", "magicka", "fatigue", "soulValue", "aiFight", "aiFlee", "aiAlarm", "aiServices", "autoCalc", "gender", - "flags", "enchantmentCharge" } + "flags", "enchantmentCharge", "intVar", "floatVar" } -- The record type settings whose input should be converted to booleans when using /storerecord config.booleanRecordSettings = { "scrollState", "keyState", "vampireState" } diff --git a/scripts/enumerations.lua b/scripts/enumerations.lua index 454536cb33..3ed2f6d0b3 100644 --- a/scripts/enumerations.lua +++ b/scripts/enumerations.lua @@ -18,12 +18,12 @@ enumerations.miscellaneous = { MARK_LOCATION = 0, SELECTED_SPELL = 1 } enumerations.objectCategories = { PLAYER = 0, ACTOR = 1, PLACED_OBJECT = 2 } enumerations.packetOrigin = { CLIENT_GAMEPLAY = 0, CLIENT_CONSOLE = 1, CLIENT_DIALOGUE = 2, CLIENT_SCRIPT_LOCAL = 3, CLIENT_SCRIPT_GLOBAL = 4, SERVER_SCRIPT = 5 } -enumerations.recordType = { ACTIVATOR = 0, APPARATUS = 1, ARMOR = 2, BODYPART = 3, BOOK = 4, CELL = 5, - CLOTHING = 6, CONTAINER = 7, CREATURE = 8, DOOR = 9, ENCHANTMENT = 10, INGREDIENT = 11, LIGHT = 12, - LOCKPICK = 13, MISCELLANEOUS = 14, NPC = 15, POTION = 16, PROBE = 17, REPAIR = 18, SCRIPT = 19, - SPELL = 20, STATIC = 21, WEAPON = 22, SOUND = 23 } +enumerations.recordType = { ACTIVATOR = 0, APPARATUS = 1, ARMOR = 2, BODYPART = 3, BOOK = 4, CELL = 5, CLOTHING = 6, + CONTAINER = 7, CREATURE = 8, DOOR = 9, ENCHANTMENT = 10, GAMESETTING = 11, INGREDIENT = 12, LIGHT = 13, + LOCKPICK = 14, MISCELLANEOUS = 15, NPC = 16, POTION = 17, PROBE = 18, REPAIR = 19, SCRIPT = 20, SOUND = 21, + SPELL = 22, STATIC = 23, WEAPON = 24 } enumerations.resurrect = { REGULAR = 0, IMPERIAL_SHRINE = 1, TRIBUNAL_TEMPLE = 2 } enumerations.spellbook = { SET = 0, ADD = 1, REMOVE = 2 } -enumerations.variableType = { SHORT = 0, LONG = 1, FLOAT = 2 } +enumerations.variableType = { SHORT = 0, LONG = 1, FLOAT = 2, INT = 3, STRING = 4 } return enumerations diff --git a/scripts/packetBuilder.lua b/scripts/packetBuilder.lua index 8b3dde50eb..04b0566b75 100644 --- a/scripts/packetBuilder.lua +++ b/scripts/packetBuilder.lua @@ -289,6 +289,8 @@ packetBuilder.AddRecordByType = function(id, record, storeType) packetBuilder.AddDoorRecord(id, record) elseif storeType == "enchantment" then packetBuilder.AddEnchantmentRecord(id, record) + elseif storeType == "gamesetting" then + packetBuilder.AddGameSettingRecord(id, record) elseif storeType == "ingredient" then packetBuilder.AddIngredientRecord(id, record) elseif storeType == "light" then @@ -520,6 +522,18 @@ packetBuilder.AddEnchantmentRecord = function(id, record) tes3mp.AddRecord() end +packetBuilder.AddGameSettingRecord = function(id, record) + + tes3mp.SetRecordId(id) + if record.baseId ~= nil then tes3mp.SetRecordBaseId(record.baseId) end + + if record.intVar ~= nil then tes3mp.SetRecordIntegerVariable(record.intVar) + elseif record.floatVar ~= nil then tes3mp.SetRecordFloatVariable(record.floatVar) + elseif record.stringVar ~= nil then tes3mp.SetRecordStringVariable(tostring(record.stringVar)) end + + tes3mp.AddRecord() +end + packetBuilder.AddIngredientRecord = function(id, record) tes3mp.SetRecordId(id)