Last active
October 22, 2020 03:11
-
-
Save celediel/efcb97c0bc607975d38265a832699c11 to your computer and use it in GitHub Desktop.
Diverse Khajiit MWSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
["adanja"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadFemale_01", hair = "T_B_Kc_HairFemale_04", shoes = "common_shoes_02"}, | |
["dahnara"] = {race = "T_Els_Ohmes-raht", head = "T_B_Kor_HeadFemale_01", hair = "T_B_Kor_HairFemale_09"}, | |
["s'renji"] = {race = "T_Els_Cathay-raht", head = "T_B_Kcr_HeadMale_04", hair = "T_B_Kcr_HairMale_01"}, | |
["shivani"] = {race = "T_Els_Suthay", head = "T_B_Ks_HeadFemale_01", hair = "T_B_Ks_HairFemale_03", shoes = "common_shoes_04"}, | |
["thengil"] = {race = "T_Els_Ohmes", head = "T_B_Ko_HeadMale_03", hair = "T_B_Ko_HairMale_10", shoes = "common_shoes_04"}, | |
["ahdahni"] = {race = "T_Els_Suthay", head = "T_B_Ks_HeadFemale_04", hair = "T_B_Ks_HairFemale_02", shoes = "common_shoes_03"}, | |
["j'jazha"] = {race = "T_Els_Ohmes-raht", head = "T_B_Kor_HeadMale_03", hair = "T_B_Kor_HairMale_04", shoes = "common_shoes_01"}, | |
["j'dato"] = {race = "T_Els_Cathay-raht", head = "T_B_Kcr_HeadMale_02", hair = "T_B_Kcr_HairMale_02"}, | |
["dro'zah"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadMale_01", hair = "T_B_Kc_HairMale_03"}, | |
["chirranirr"] = {race = "T_Els_Suthay", head = "T_B_Ks_HeadFemale_01", hair = "T_B_Ks_HairFemale_04", shoes = "common_shoes_04"}, | |
["wadarkhu"] = {race = "T_Els_Cathay-raht", head = "T_B_Kcr_HeadMale_02", hair = "T_B_Kcr_HairMale_04"}, | |
["ra'zhid"] = {race = "T_Els_Suthay", head = "T_B_Ks_HeadMale_04", hair = "T_B_Ks_HairMale_05"}, | |
["idhassi"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadFemale_01", hair = "T_B_Kc_HairFemale_04"}, | |
["ma'khar"] = {race = "T_Els_Cathay-raht", head = "T_B_Kcr_HeadMale_03", hair = "T_B_Kcr_HairMale_01"}, | |
["joshur"] = {race = "T_Els_Ohmes-raht", head = "T_B_Kor_HeadMale_01", hair = "T_B_Kor_HairMale_03"}, | |
["dahleena"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadFemale_02", hair = "T_B_Kc_HairFemale_04"}, | |
["dro'zaymar"] = {race = "T_Els_Suthay", head = "T_B_Ks_HeadMale_03", hair = "T_B_Ks_HairMale_04"}, | |
["khazura"] = {race = "T_Els_Suthay", head = "T_B_Ks_HeadFemale_01", hair = "T_B_Ks_HairFemale_04"}, | |
["arabhi"] = {race = "T_Els_Suthay", head = "T_B_Ks_HeadFemale_01", hair = "T_B_Ks_HairFemale_03", shoes = "common_shoes_01"}, | |
["j'kara"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadMale_02", hair = "T_B_Kc_HairMale_03"}, | |
["affri"] = {race = "T_Els_Cathay-raht", head = "T_B_Kcr_HeadFemale_02", hair = "T_B_Kcr_HairFemale_04"}, | |
-- conflicts with More Dunmer, disable if loaded | |
["ra'kothre"] = {race = "T_Els_Cathay-raht", head = "T_B_Kcr_HeadMale_02", hair = "T_B_Kcr_HairMale_04"}, | |
["baissa"] = {race = "T_Els_Ohmes", head = "T_B_Ko_HeadFemale_02", hair = "T_B_Ko_HairFemale_23", shoes = "common_shoes_05"}, | |
["j'rasha"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadMale_03", hair = "T_B_Kc_HairMale_03", shoes = "common_shoes_04"}, | |
["abanji"] = {race = "T_Els_Cathay-raht", head = "T_B_Kcr_HeadFemale_02", hair = "T_B_Kcr_HairFemale_03"}, | |
["dro'qanar"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadMale_03", hair = "T_B_Kc_HairMale_02", shoes = "common_shoes_04"}, | |
["tsiya"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadFemale_02", hair = "T_B_Kc_HairFemale_03", shoes = "common_shoes_03"}, | |
["j'zamha"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadMale_01", hair = "T_B_Kc_HairMale_01"}, | |
["ahdni"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadFemale_03", hair = "T_B_Kc_HairFemale_03", shoes = "common_shoes_01"}, | |
["aravi"] = {race = "T_Els_Ohmes-raht", head = "T_B_Kor_HeadFemale_05", hair = "T_B_Kor_HairFemale_07", shoes = "common_shoes_01"}, | |
["shaba"] = {race = "T_Els_Suthay", head = "T_B_Ks_HeadFemale_02", hair = "T_B_Ks_HairFemale_02", shoes = "common_shoes_02"}, | |
["ahndahra"] = {race = "T_Els_Cathay-raht", head = "T_B_Kcr_HeadFemale_02", hair = "T_B_Kcr_HairFemale_04"}, | |
["bahdrashi"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadFemale_04", hair = "T_B_Kc_HairFemale_04"}, | |
["ma'zahn"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadMale_01", hair = "T_B_Kc_HairMale_04"}, | |
["ra'sava"] = {race = "T_Els_Cathay-raht", head = "T_B_Kcr_HeadMale_01", hair = "T_B_Kcr_HairMale_03"}, | |
["tsajadhi"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadFemale_03", hair = "T_B_Kc_HairFemale_01"}, | |
["ri'darsha"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadMale_02", hair = "T_B_Kc_HairMale_02"}, | |
["tsani"] = {race = "T_Els_Cathay", head = "T_B_Kc_HeadFemale_02", hair = "T_B_Kc_HairFemale_02"}, | |
["kisimba"] = {race = "T_Els_Cathay-raht", head = "T_B_Kcr_HeadFemale_01", hair = "T_B_Kcr_HairFemale_03"} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local data = require("celediel.Diverse Khajiit.data") | |
local modName = "Diverse Khajiit" | |
local configName = modName:gsub("%s", "") | |
local modInfo = "" | |
local codeAuthor = "Celediel" | |
local version = "1.0.0" | |
local tamrielData = "Tamriel_Data.esm" | |
local defaultConfig = {randomizeShoes = false, removeShoes = false, debug = true} | |
local config = mwse.loadConfig(configName, defaultConfig) | |
-- send nonsense to the logs | |
local function log(...) if config.debug then mwse.log("[%s] %s", modName, string.format(...)) end end | |
local khajiit_races = {} | |
-- funky but it works | |
local function addShoes(khajiit, shoes) | |
if khajiit.race == khajiit_races["T_Els_Cathay-raht"] or not khajiit.data then return end | |
if shoes and (not khajiit.data.DiverseKhajiit or not khajiit.data.DiverseKhajiit.addedShoes) then | |
log("Adding shoes %s to %s", shoes, khajiit) | |
khajiit.data.DiverseKhajiit = khajiit.data.DiverseKhajiit or {} | |
tes3.addItem({reference = khajiit, item = shoes, count = 1, playSound = false}) | |
khajiit.mobile:equip({item = shoes}) | |
khajiit.data.DiverseKhajiit.addedShoes = shoes | |
end | |
end | |
local function removeShoes(khajiit) | |
if not config.removeShoes then return end | |
log("Removing shoes %s from %s", khajiit.data.DiverseKhajiit.addedShoes, khajiit) | |
-- khajiit.mobile:unequip({item = khajiit.data.DiverseKhajiit.addedShoes}) | |
khajiit.mobile:unequip({armorSlot = tes3.armorSlot.boots}) | |
tes3.removeItem({reference = khajiit, item = khajiit.data.DiverseKhajiit.addedShoes}) | |
khajiit.data.DiverseKhajiit.addedShoes = nil | |
end | |
local function updateKhajiit() | |
for id, info in pairs(data) do | |
local npc = tes3.getObject(id) | |
if npc then | |
-- don't know why getObject doesn't work for races | |
-- local race = tes3.getObject(info.race) | |
local race = khajiit_races[info.race] | |
local head = tes3.getObject(info.head) | |
local hair = tes3.getObject(info.hair) | |
-- todo: better random shoes | |
if config.randomizeShoes then info.shoes = "common_shoes_0" .. math.random(1, 7) end | |
log("Updating %s from id:%s to: race:%s head:%s hair:%s%s", npc, id, race, head, hair, info.shoes and " shoes:" .. info.shoes or "") | |
npc.race = race | |
npc.head = head | |
npc.hair = hair | |
--[[ | |
if npc.inventory and info.shoes then | |
tes3.addItem({reference = npc, item = info.shoes, count = 1, playSound = false}) -- ! doesn't fucking work | |
-- ? wat do ? | |
log("Inventory of %s:", npc.name) | |
for k,v in pairs(npc.inventory) do | |
log("%s:%s", k, v) | |
end | |
end | |
--]] | |
end | |
end | |
end | |
local eventFunctions = {} | |
-- eventFunctions.onLoaded = function(e) updateKhajiit() end | |
-- there's probably a better way to do all of this | |
eventFunctions.onMobileActivated = function(e) | |
local obj = e.reference.baseObject and e.reference.baseObject or | |
(e.reference.object.baseObject and e.reference.object.baseObject or e.reference.object) | |
-- don't worry about mobiles not in our data | |
if not data[obj.id] then return end | |
local shoes = data[obj.id].shoes | |
if shoes then addShoes(e.reference, shoes) end | |
end | |
-- shitty "fix" for khajiit still wearing shoes after this mod is disabled if the game has been saved | |
-- they'll still be wearing shoes if the game is saved without the mobile being deactivated | |
-- also causes issues with save data, bad time so don't even do it | |
-- eventFunctions.onMobileDeactivated = function(e) | |
-- if not e.reference then return end | |
-- if e.reference.data.DiverseKhajiit and e.reference.data.DiverseKhajiit.addedShoes then removeShoes(e.reference) end | |
-- end | |
local function onInitialized() | |
for race in tes3.iterate(tes3.dataHandler.nonDynamicData.races) do | |
-- this is stupid and I hate it | |
if race.id:lower():match("t_els_") then khajiit_races[race.id] = race end | |
end | |
-- log("Loaded Khajiit races:%s", json.encode(khajiit_races, {indent = true})) | |
-- if lua had continue statements I wouldn't have to do this shit | |
if tes3.isModActive("More Dunmers.esp") then data["ra'kothre"] = nil end | |
log("Loaded diverse data:%s", json.encode(data, {indent = true})) | |
-- check if our esp is active | |
if not tes3.isModActive(tamrielData) then | |
local msg = string.format("%s must be activated for %s to work!", tamrielData, modName) | |
mwse.log("[%s] %s", modName, msg) | |
tes3.messageBox(msg) | |
return | |
end | |
-- now that that's out of the way | |
updateKhajiit() | |
for name, func in pairs(eventFunctions) do | |
log("Registering functions for event: %s", name) | |
event.register(name:gsub("^on(%u)", string.lower), func) | |
end | |
mwse.log("[%s] Initialized", modName) | |
end | |
-- MCM | |
local function doConfigMenu() | |
local template = mwse.mcm.createTemplate(modName) | |
template:saveOnClose(modName, config) | |
local page = template:createSideBarPage({ | |
label = "Sidebar Page???", | |
description = string.format("%s v%s Lua code by %s\n\n%s", modName, version, codeAuthor, modInfo) | |
}) | |
local category = page:createCategory(modName) | |
category:createYesNoButton({ | |
label = "Randomize shoes", | |
description = "Pick random shoes for shoe-wearing khajiit instead of the shoes from data.lua", | |
variable = mwse.mcm.createTableVariable({id = "randomizeShoes", table = config}) | |
}) | |
category:createYesNoButton({ | |
label = "Remove shoes on mobileDeactivated", | |
description = "If you want to remove this mod, and don't want khajiit to still have shoes", | |
variable = mwse.mcm.createTableVariable({id = "removeShoes", table = config}) | |
}) | |
category:createYesNoButton({ | |
label = "Debug logging", | |
description = "Enable this if you want a bunch of nonsense in your MWSE.log", | |
variable = mwse.mcm.createTableVariable({id = "debug", table = config}) | |
}) | |
return template | |
end | |
event.register("initialized", onInitialized) | |
event.register("modConfigReady", function() mwse.mcm.register(doConfigMenu()) end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment