An OpenMW mod that lets you play the whole Elder Scrolls III: Morrowind as a top-down isometric game — with full online co-op or MMO modes.
C++
MMO: a quest script's enable or disable reaches the player whose script it was; one-offs stay dead
Alan Saundersf5409e301d09
diff --git a/isowind/server/CoreScripts/scripts/custom/isowindMmo.lua b/isowind/server/CoreScripts/scripts/custom/isowindMmo.luaindex c7e5d73..2609f1f 100644--- a/isowind/server/CoreScripts/scripts/custom/isowindMmo.lua+++ b/isowind/server/CoreScripts/scripts/custom/isowindMmo.lua@@ -10,7 +10,8 @@-- * Enemies and NPCs come back after they die, players there or not, after a time from how-- tough they were (WoW-like tiers, from their health): trash 1.5 minutes, normal 5, elite 15, bosses 20, divided by-- the host's respawn speed. Ones from the game's files are reset on each client ("isowind respawn", a console--- command packet the game handles itself); leveled-list ones are spawned again where they first appeared.+-- command packet the game handles itself); leveled-list ones are spawned again where they first appeared. Someone a+-- quest script brought into the world (Tarhiel falling from the sky) is a one-off and stays dead.if not IsowindHost.IsMmo() thenreturn@@ -327,8 +328,11 @@ local function onObjectState(eventStatus, pid, cellDescription, objects)endcell.data.isowindStates[uniqueIndex] = recordend- -- The party's others who are on see it now (the player's own game already made the change)- for _, recipient in ipairs(otherOnlinePids(pid, names)) do+ -- The player and the party's others who are on see it now (the player's own game waits for the server to make+ -- the change, mwmp::hooks::requestScriptObjectState)+ local recipients = otherOnlinePids(pid, names)+ table.insert(recipients, pid)+ for _, recipient in ipairs(recipients) dotes3mp.ClearObjectList()tes3mp.SetObjectListPid(recipient)tes3mp.SetObjectListCell(cellDescription)@@ -564,6 +568,21 @@ local function onObjectSpawn(eventStatus, pid, cellDescription, objects)endend+-- Someone a quest script brought into the world (enabled) for a player, like Tarhiel falling from the sky near Seyda+-- Neen: a one-off, so their death stays and they don't come back to fall again+local function isQuestAppearance(cell, uniqueIndex)+ local record = cell.data.isowindStates ~= nil and cell.data.isowindStates[uniqueIndex] or nil+ if record == nil then+ return false+ end+ for _, state in pairs(record.players) do+ if state == true then+ return true+ end+ end+ return false+end+local function onActorDeath(eventStatus, pid, cellDescription, actors)local cell = LoadedCells[cellDescription]if cell == nil then@@ -576,7 +595,8 @@ local function onActorDeath(eventStatus, pid, cellDescription, actors)local _, mpNum = splitIndex(uniqueIndex)local isSummon = objectData ~= nil and objectData.summon ~= nillocal spawnPoints = cell.data.isowindSpawnPoints or {}- if not isSummon and (mpNum == 0 or spawnPoints[uniqueIndex] ~= nil) then+ if not isSummon and not isQuestAppearance(cell, uniqueIndex) and+ (mpNum == 0 or spawnPoints[uniqueIndex] ~= nil) thenlocal minutes = respawnMinutes(actor.refId or (objectData and objectData.refId), objectData)respawns[cellDescription] = respawns[cellDescription] or {}respawns[cellDescription][uniqueIndex] = now + math.floor(minutes * 60 / IsowindHost.respawnSpeed)diff --git a/isowind/server/tests/mmotest.lua b/isowind/server/tests/mmotest.luaindex 02dd3a3..b879b39 100644--- a/isowind/server/tests/mmotest.lua+++ b/isowind/server/tests/mmotest.lua@@ -136,7 +136,9 @@ local function runTests()check("quest disable skips the shared save", status.validDefaultHandler == false)check("quest disable kept for the player", cell.data.isowindStates["4444-0"].players.alpha == false)check("quest disable not shared", cell.data.objectData["4444-0"] == nil or cell.data.objectData["4444-0"].state == nil)- check("quest disable not sent to others", lastSent("SendObjectState") == nil)+ local stateSent = lastSent("SendObjectState")+ check("quest disable sent back to the player only", stateSent ~= nil and stateSent.args[1] == false and+ #sent == 1)-- The player's hands enabling or disabling things (none do) and the console stay as they werereceive({ objects = {}, origin = enumerations.packetOrigin.CLIENT_CONSOLE })@@ -166,6 +168,13 @@ local function runTests()local due = WorldInstance.data.isowindRespawns[CELL]["999-0"]check("mudcrab due in about 90 seconds", due ~= nil and math.abs(due - os.time() - 90) <= 2)+ -- Someone a quest script brought in (Tarhiel falling near Seyda Neen) stays dead+ cell.data.isowindStates["994-0"] = { refId = "agronian guy", players = { alpha = true } }+ cell.data.objectData["994-0"] = { refId = "agronian guy", stats = { healthBase = 5 } }+ customEventHooks.triggerHandlers("OnActorDeath", customEventHooks.makeEventStatus(true, true),+ { pid, CELL, { ["994-0"] = { refId = "agronian guy", killer = {} } } })+ check("quest appearance does not come back", WorldInstance.data.isowindRespawns[CELL]["994-0"] == nil)+cell.data.objectData["998-0"] = { refId = "dagoth gares", stats = { healthBase = 300 } }cell.data.objectData["997-0"] = { refId = "ordinator", stats = { healthBase = 250 } }customEventHooks.triggerHandlers("OnActorDeath", customEventHooks.makeEventStatus(true, true),diff --git a/isowind/server/tests/partytest.lua b/isowind/server/tests/partytest.luaindex 51ddd0b..033e1e1 100644--- a/isowind/server/tests/partytest.lua+++ b/isowind/server/tests/partytest.lua@@ -132,7 +132,9 @@ local function runTests()check("quest disable kept for both members", record.players.alpha == false and record.players.beta == false)local toBeta = sentTo("SendObjectState", 1)check("Beta's game told now", toBeta ~= nil and toBeta.objects[1] ~= nil and toBeta.objects[1].state == false)- check("Alpha's game not told (it did it)", sentTo("SendObjectState", 0) == nil)+ local toAlpha = sentTo("SendObjectState", 0)+ check("Alpha's game told too (it waits for the server)", toAlpha ~= nil and toAlpha.objects[1] ~= nil and+ toAlpha.objects[1].state == false)-- Kill credit for the allybeta.data.kills = nil