Skip to content

Commit

Permalink
Add a special game rule for Tails & MetalSonic players
Browse files Browse the repository at this point in the history
Players who use these skins and are playing as Innocent have to get 50 rings to make a shot (instead of 100 like everyone else)
  • Loading branch information
LeonardoTheMutant committed Oct 4, 2024
1 parent 7647cbd commit 17156b4
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 56 deletions.
98 changes: 50 additions & 48 deletions SRC/LUA/CCMD.LUA
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ local tech_info = {
"\27Website:\nleonardothemutant.github.io/SRB2-Murder-Mystery\16\n"
}

local function helpCMD(p, page)
--MMHELP console command
COM_AddCommand("mmhelp", function(p, page)
if (gametype != GT_MURDERMYSTERY)
CONS_Printf(p, "The game must be Murder Mystery to access this command")
return
Expand Down Expand Up @@ -62,9 +63,10 @@ local function helpCMD(p, page)

--enable the UI
p.mmhelp.active = true
end
end, COM_LOCAL)

local function MMlang(p, l) --player, lang
--MMLANG console command
COM_AddCommand("mmlang", function(p, l) --player, lang
if (gametype != GT_MURDERMYSTERY)
CONS_Printf(p, "The game must be Murder Mystery to access this command")
return
Expand Down Expand Up @@ -121,10 +123,7 @@ local function MMlang(p, l) --player, lang
else CONS_Printf(p, "\x85Failed to save\x80 Language preferences to \x81/luafiles/client/MM.DAT\x80. Does your folder lack read+write privileges?") end
else CONS_Printf(p, "'\x82"..l.."\x80' language is not present/loaded into the game\nPlease ask your game Administrator to add the required MM language file or contact our SRB2 MM_DEV Team for help.") end
end
end

COM_AddCommand("mmhelp", helpCMD, COM_LOCAL)
COM_AddCommand("mmlang", MMlang, COM_LOCAL)
end, COM_LOCAL)

--
-- MMHELP UI
Expand All @@ -147,56 +146,59 @@ end
--I was unable to lock player controls here because clients would desynchronise each time they press something
--Enjoy what you already have
addHook("PlayerThink", function(p)
if not (p.mmhelp and p.mmhelp.active) or (not MM.text[consoleplayer.mmlang]["MMHELP"]) or (gametype != GT_MURDERMYSTERY) return end
if (gametype != GT_MURDERMYSTERY) return end
--MMHELP UI controls
if (p.mmhelp and p.mmhelp.active) and (MM.text[consoleplayer.mmlang]["MMHELP"])

--p.powers[pw_nocontrol] = 1 --this completely destroys the game for clients
--p.powers[pw_nocontrol] = 1 --this completely destroys the game for clients

p.buffer = {}

if (p.mmhelp.page <= #MM.text[consoleplayer.mmlang]["MMHELP"])
V_InsertToBuffer(p, MM_GetText(consoleplayer.mmlang, "MMHELP", p.mmhelp.page))
end

if (p.mmhelp.page == (#MM.text[consoleplayer.mmlang]["MMHELP"] + 1)) --last page is always a technical info page
V_InsertToBuffer(p, tech_info)
end

if (p.cmd.buttons & BT_ATTACK) --FIRE, leave HELP
p.pflags = $|PF_ATTACKDOWN --this does not help
p.mmhelp.active = false
return --this also doesn't
end
p.buffer = {}

if (p.cmd.buttons & BT_JUMP) --JUMP, up
if (not (p.lastbuttons & BT_JUMP))
p.mmhelp.pos = $ - 1
if (p.mmhelp.pos < 1) p.mmhelp.pos = 1 end
if (p.mmhelp.page <= #MM.text[consoleplayer.mmlang]["MMHELP"])
V_InsertToBuffer(p, MM_GetText(consoleplayer.mmlang, "MMHELP", p.mmhelp.page))
end
end

if (p.cmd.buttons & BT_SPIN) --SPIN, down
if (not (p.lastbuttons & BT_SPIN))
p.mmhelp.pos = $ + 1
--hit the end of the page
if (p.mmhelp.pos + scrnRows > (#p.buffer + 1)) then p.mmhelp.pos = $ - 1 end
if (p.mmhelp.page == (#MM.text[consoleplayer.mmlang]["MMHELP"] + 1)) --last page is always a technical info page
V_InsertToBuffer(p, tech_info)
end
end

if (p.cmd.buttons & BT_WEAPONNEXT) --Next weapon, right
if (not (p.lastbuttons & BT_WEAPONNEXT))
p.mmhelp.page = $ + 1
p.mmhelp.pos = 1
if (p.mmhelp.page >= (#MM.text[consoleplayer.mmlang]["MMHELP"] + 1)) p.mmhelp.page = (#MM.text[consoleplayer.mmlang]["MMHELP"] + 1) end
if (p.cmd.buttons & BT_ATTACK) --FIRE, leave HELP
p.pflags = $|PF_ATTACKDOWN --this does not help
p.mmhelp.active = false
return --this also doesn't
end
end

if (p.cmd.buttons & BT_WEAPONPREV) --Prev weapon, left
if (not (p.lastbuttons & BT_WEAPONPREV))
p.mmhelp.page = $ - 1
p.mmhelp.pos = 1
if (p.mmhelp.page <= 1) p.mmhelp.page = 1 end
end
end
if (p.cmd.buttons & BT_JUMP) --JUMP, up
if (not (p.lastbuttons & BT_JUMP))
p.mmhelp.pos = $ - 1
if (p.mmhelp.pos < 1) p.mmhelp.pos = 1 end
end
end

if (p.cmd.buttons & BT_SPIN) --SPIN, down
if (not (p.lastbuttons & BT_SPIN))
p.mmhelp.pos = $ + 1
--hit the end of the page
if (p.mmhelp.pos + scrnRows > (#p.buffer + 1)) then p.mmhelp.pos = $ - 1 end
end
end

if (p.cmd.buttons & BT_WEAPONNEXT) --Next weapon, right
if (not (p.lastbuttons & BT_WEAPONNEXT))
p.mmhelp.page = $ + 1
p.mmhelp.pos = 1
if (p.mmhelp.page >= (#MM.text[consoleplayer.mmlang]["MMHELP"] + 1)) p.mmhelp.page = (#MM.text[consoleplayer.mmlang]["MMHELP"] + 1) end
end
end

if (p.cmd.buttons & BT_WEAPONPREV) --Prev weapon, left
if (not (p.lastbuttons & BT_WEAPONPREV))
p.mmhelp.page = $ - 1
p.mmhelp.pos = 1
if (p.mmhelp.page <= 1) p.mmhelp.page = 1 end
end
end
end
end)

--renderer, frontend
Expand Down
12 changes: 9 additions & 3 deletions SRC/LUA/HUD.LUA
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,9 @@ hud.add(function(v, p)
--Selector
v.draw((MM.hud.game.pos.ringWep.x + 6 + p.currentweapon*20), (MM.hud.game.pos.ringWep.y - 2 - (del >> 1)), MM.graphics["CURWEAP"], V_SNAPTOBOTTOM|V_PERPLAYER|v.localTransFlag())
end
elseif (p.role == ROLE_INNOCENT) and (p.rings > 99) and (CV_FindVar("mm_wepinno").value)

--Innocent weapon logic
elseif (p.role == ROLE_INNOCENT) and ((((consoleplayer.skin == 1) or (consoleplayer.skin == 5)) and (p.rings > 49)) or (((consoleplayer.skin != 1) and (consoleplayer.skin != 5)) and (p.rings > 99))) and (CV_FindVar("mm_wepinno").value)
--Knife-only
if (MM_WeaponConfigFlags(ROLE_INNOCENT, WEPCFG_DISABLERED))
v.draw((MM.hud.game.pos.ringWepOnly.x + 8), (MM.hud.game.pos.ringWep.y), MM.graphics[MM.weapons[-2][1]], V_SNAPTOBOTTOM) --Knife icon
Expand All @@ -414,8 +416,12 @@ hud.add(function(v, p)
end

--Ammo counter
v.drawString((MM.hud.game.pos.ringWepOnly.x + 24), (MM.hud.game.pos.ringWep.y + 8), (p.rings / 100), V_SNAPTOBOTTOM|v.localTransFlag(), "thin-right")

if (consoleplayer.skin == 1) or (consoleplayer.skin == 5) --Player is Tails or MetalSonic
v.drawString((MM.hud.game.pos.ringWepOnly.x + 24), (MM.hud.game.pos.ringWep.y + 8), (p.rings / 50), V_SNAPTOBOTTOM|v.localTransFlag(), "thin-right")
else
v.drawString((MM.hud.game.pos.ringWepOnly.x + 24), (MM.hud.game.pos.ringWep.y + 8), (p.rings / 100), V_SNAPTOBOTTOM|v.localTransFlag(), "thin-right")
end

--Selector
v.draw((MM.hud.game.pos.ringWepOnly.x + 6), (MM.hud.game.pos.ringWep.y - 2 - (del >> 1)), MM.graphics["CURWEAP"], V_SNAPTOBOTTOM|v.localTransFlag())
end
Expand Down
12 changes: 8 additions & 4 deletions SRC/LUA/WEAPONS.LUA
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ addHook("PlayerThink", function(p) --this whole hook is a port of P_DoFiring() f

if (p.cmd.buttons & BT_FIRENORMAL) or ((p.currentweapon == 0) and MM_WeaponConfigFlags(p.role, WEPCFG_DISABLERED))
-- KNIFE --
if (((p.role != ROLE_INNOCENT) and (p.rings > 0)) or ((p.role == ROLE_INNOCENT) and (p.rings > 99)))
if ((p.role != ROLE_INNOCENT) and (p.rings > 0)) or ((p.role == ROLE_INNOCENT) and ((((p.skin == 1) or (p.skin == 5)) and (p.rings > 49)) or (((p.skin != 1) and (p.skin != 5)) and (p.rings > 99))))
P_SetWeaponDelay(p, MM.weapons[-2][4])
mo = P_SpawnPlayerMissile(p.mo, MM.weapons[-2][2], MM.weapons[-2][3])
if (p.role == ROLE_INNOCENT) then P_GivePlayerRings(p, -100) --Weapon shot/use costs 100 rings for Innocents
if (p.role == ROLE_INNOCENT) --Weapon shot/use costs 100 rings for Innocents
if ((p.skin == 1) or (p.skin == 5)) then P_GivePlayerRings(p, -50) --Player is Tails, take 50 rings instead
else P_GivePlayerRings(p, -100) end
else P_GivePlayerRings(p, -1) end

if (not p.sneak) S_StartSound(p.mo, sfx_wepfir) end --yeah, stealth included
Expand Down Expand Up @@ -195,10 +197,12 @@ addHook("PlayerThink", function(p) --this whole hook is a port of P_DoFiring() f
p.powers[pw_infinityring] = $ - 1
else
-- RED RING --
if (((p.role != ROLE_INNOCENT) and (p.rings > 0)) or ((p.role == ROLE_INNOCENT) and (p.rings > 99)))
if ((p.role != ROLE_INNOCENT) and (p.rings > 0)) or ((p.role == ROLE_INNOCENT) and (((p.skin == 1) or (p.skin == 5) and (p.rings > 49)) or ((consoleplayer.skin != 1) and (p.rings > 99))))
P_SetWeaponDelay(p, MM.weapons[-1][4])
mo = P_SpawnPlayerMissile(p.mo, MM.weapons[-1][2], MM.weapons[-1][3])
if (p.role == ROLE_INNOCENT) then P_GivePlayerRings(p, -100) --Weapon shot/use costs 100 rings for Innocents
if (p.role == ROLE_INNOCENT) --Weapon shot/use costs 100 rings for Innocents
if ((p.skin == 1) or (p.skin == 5)) then P_GivePlayerRings(p, -50) --Player is Tails or MetalSonic, take 50 rings instead
else P_GivePlayerRings(p, -100) end
else P_GivePlayerRings(p, -1) end
end
end
Expand Down
1 change: 0 additions & 1 deletion TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
- Include the "Minimal System Requirements" with the add-on
- Replace the vanilla F1 menu graphics with the MM manual
- Make (several) release trailer(s)
- Make Sonic & Tails as well as Fang & Amy skins differ from each other (not complicated differences to implement)
- Change the extended map names from MAPK# to MAPM# ("K" stands for Killer, "M" - Murder/Mystery)
- Fix Footmarks spawn code on FOFs, find a way to get the precise FOF boundaries, unless STJr does it first

0 comments on commit 17156b4

Please sign in to comment.