Skip to content

Commit

Permalink
Add udmf support to doors keys portals treasures
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiskster committed Sep 8, 2024
1 parent 1bb6504 commit 9c362c0
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 20 deletions.
43 changes: 32 additions & 11 deletions src/Lua/Gimmicks/doors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ states[S_PTSR_DOOR_UNLOCKED] = {
}

mobjinfo[MT_PTSR_DOOR] = {
--$Category Spice Runners
--$Name Door
--$Sprite PDORA0
--$Arg0 "Enter/Exit Type"
--$Arg0Type 11
--$Arg0Enum { 0="Enter"; 1="Exit";}
--$Arg1 "Door/Key ID"

doomednum = 2111,

radius = 20*FU,
Expand Down Expand Up @@ -63,16 +71,16 @@ local function getPlayers(mo)
return players
end

local function assignDoors(mo, type, angle)
local function assignDoors(mo, type, id)
if not (mo and mo.valid) then return end

local oppositeType = type == "enter" and "exit" or "enter"

PTSR.doors[type][angle] = mo
mo.assignedType = angle
PTSR.doors[type][id] = mo
mo.assignedType = id

if PTSR.doors[oppositeType][angle] then
local mo2 = PTSR.doors[oppositeType][angle]
if PTSR.doors[oppositeType][id] then
local mo2 = PTSR.doors[oppositeType][id]

if mo2 and mo.valid then
mo.opposite_door = mo2
Expand All @@ -81,7 +89,7 @@ local function assignDoors(mo, type, angle)
end

if type == "enter"
and PTSR.keys[angle] then
and PTSR.keys[id] then
mo.state = S_PTSR_DOOR_LOCKED
-- LOCK IT GET THE KEY BITCH
end
Expand All @@ -103,11 +111,24 @@ addHook("MobjSpawn", function(mo)
end, MT_PTSR_DOOR)

addHook("MapThingSpawn", function(mo, thing)
local type = thing.extrainfo == 0 and "enter" or "exit"
local oppositeType = thing.extrainfo == 0 and "exit" or "enter"

assignDoors(mo, type, thing.angle)
assignDoors(PTSR.doors[oppositeType][thing.angle], oppositeType, thing.angle)
local type
local oppositeType
local id = 0

if not udmf then
type = thing.extrainfo == 0 and "enter" or "exit"
oppositeType = thing.extrainfo == 0 and "exit" or "enter"
id = thing.angle
else
type = thing.args[0] == 0 and "enter" or "exit"
oppositeType = thing.args[0] == 0 and "exit" or "enter"
id = thing.args[1]
end

if type and oppositeType then
assignDoors(mo, type, id)
assignDoors(PTSR.doors[oppositeType][id], oppositeType, id)
end
end, MT_PTSR_DOOR)

addHook("MobjThinker", function(mo)
Expand Down
22 changes: 17 additions & 5 deletions src/Lua/Gimmicks/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ local keyNotCaughtFlags = MF_SPECIAL
local keyCaughtFlags = MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY

mobjinfo[MT_PTSR_KEY] = {
--$Category Spice Runners
--$Name Key
--$Sprite PKEYA0
--$Arg0 "Door/Key ID"
doomednum = 2112,
spawnstate = S_PTSR_KEY,

Expand Down Expand Up @@ -124,10 +128,18 @@ addHook("PostThinkFrame", do
end)

addHook("MapThingSpawn", function(mo, thing)
PTSR.keys[thing.angle] = mo
mo.assignedType = thing.angle

if not PTSR.doors["enter"][thing.angle] then return end
local id = 0

if not udmf then
id = thing.angle
else
id = thing.args[0]
end

PTSR.keys[id] = mo
mo.assignedType = id

if not PTSR.doors["enter"][id] then return end

PTSR.doors["enter"][thing.angle].state = S_PTSR_DOOR_LOCKED
PTSR.doors["enter"][id].state = S_PTSR_DOOR_LOCKED
end, MT_PTSR_KEY)
2 changes: 1 addition & 1 deletion src/Lua/Gimmicks/pizzaportal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ freeslot("MT_PIZZAPORTAL", "S_PIZZAPORTAL", "SPR_P3PT", "sfx_lapin", "sfx_lapout

mobjinfo[MT_PIZZAPORTAL] = {
--$Name "Pizza Portal"
--$Sprite SPR_P3PT
--$Sprite P3PTA0
--$Category "Spice Runners"
doomednum = 1417,
spawnstate = S_PIZZAPORTAL,
Expand Down
11 changes: 8 additions & 3 deletions src/Lua/Gimmicks/treasures.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
freeslot("MT_PTSR_TREASURE", "S_PTSR_TREASURE", "S_PTSR_TREASURE_EFFECT")

local TREASURE_SCORE_AWARD = 10000

states[freeslot "S_PTSR_TREASURE"] = {
states[S_PTSR_TREASURE] = {
sprite = freeslot "SPR_STRE",
frame = A,
tics = -1
}

states[freeslot "S_PTSR_TREASURE_EFFECT"] = {
states[S_PTSR_TREASURE_EFFECT] = {
sprite = freeslot "SPR_TEFF",
frame = FF_ANIMATE|A,
tics = -1,
var1 = C,
var2 = 1
}

mobjinfo[freeslot "MT_PTSR_TREASURE"] = {
mobjinfo[MT_PTSR_TREASURE] = {
--$Category Spice Runners
--$Name Treasure
--$Sprite STREA0
doomednum = 2113,
radius = 16*FU,
height = 16*FU,
Expand Down

0 comments on commit 9c362c0

Please sign in to comment.