Remove joke star from PSC (#438)
This commit is contained in:
parent
dda8f6d0c3
commit
ddde827f85
|
@ -1,28 +1,29 @@
|
||||||
-- name: Personal Star Counter EX+
|
-- name: Personal Star Counter EX+
|
||||||
-- description: See how many stars you collect!\nIdea by Mr.Needlemouse, created by Sunk\n\nModified by Demnyx.
|
-- description: See how many stars you've collected!\n\nCredits:\n\\#097419\\Mr.Needlemouse\\#FFFFFF\\ - Concept\nSunk\\#dcdcdc\\ - Creator\n\\#269A91\\Demnyx\\#dcdcdc\\ - Assistance\n\\#f296af\\PeachyPeach\\#dcdcdc\\ - Global functions
|
||||||
-- incompatible: gamemode arena
|
-- incompatible: gamemode arena
|
||||||
|
|
||||||
|
for i = 0, (MAX_PLAYERS - 1) do
|
||||||
|
gPlayerSyncTable[i].psc = 0
|
||||||
|
end
|
||||||
|
|
||||||
if mod_storage_load("StarCounter") == nil then
|
if mod_storage_load("StarCounter") == nil then
|
||||||
mod_storage_save("StarCounter", "0")
|
mod_storage_save("StarCounter", "0")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local starCheater = false
|
||||||
local TotalStarCounter = tonumber(mod_storage_load("StarCounter"))
|
local TotalStarCounter = tonumber(mod_storage_load("StarCounter"))
|
||||||
local StarCounter = 0
|
local StarCounter = 0
|
||||||
local prevNumStars = 0
|
local prevNumStars = 0
|
||||||
|
|
||||||
local screenHeight = 0
|
local screenHeight = 0
|
||||||
local screenWidth = 0
|
local screenWidth = 0
|
||||||
|
local pscToggle = 1
|
||||||
local psToggle = 1
|
local introTimer = 0
|
||||||
|
|
||||||
local fadeTimer = 0
|
|
||||||
|
|
||||||
-- junk --
|
-- junk --
|
||||||
cutscenes = {
|
cutscenes = {
|
||||||
[ACT_END_PEACH_CUTSCENE] = true,
|
[ACT_END_PEACH_CUTSCENE] = true,
|
||||||
[ACT_CREDITS_CUTSCENE] = true,
|
[ACT_CREDITS_CUTSCENE] = true,
|
||||||
[ACT_END_WAVING_CUTSCENE] = true,
|
[ACT_END_WAVING_CUTSCENE] = true,
|
||||||
[ACT_INTRO_CUTSCENE] = true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
---@param m MarioState
|
---@param m MarioState
|
||||||
|
@ -34,31 +35,45 @@ function localStarCounter(m, o, type)
|
||||||
--The hook happens after the star count increments, so this allows the independent counter to increment ONLY when YELLOW star is collected.
|
--The hook happens after the star count increments, so this allows the independent counter to increment ONLY when YELLOW star is collected.
|
||||||
if m.numStars ~= prevNumStars then
|
if m.numStars ~= prevNumStars then
|
||||||
StarCounter = StarCounter + 1
|
StarCounter = StarCounter + 1
|
||||||
|
gPlayerSyncTable[0].psc = StarCounter
|
||||||
|
if starCheater == false then --Only if not cheating
|
||||||
TotalStarCounter = TotalStarCounter + 1
|
TotalStarCounter = TotalStarCounter + 1
|
||||||
mod_storage_save("StarCounter", tostring(TotalStarCounter))
|
mod_storage_save("StarCounter", tostring(TotalStarCounter))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hud alpha stuff from Agent X
|
-- Hud alpha stuff from Agent X
|
||||||
function djui_hud_set_adjusted_color(r, g, b, a)
|
function djui_hud_set_adjusted_color(r, g, b, a)
|
||||||
local multiplier = 1
|
local multiplier = 1
|
||||||
if djui_hud_is_pause_menu_created() then multiplier = 0.57 end
|
if djui_hud_is_pause_menu_created() then multiplier = 0.57 end --Star Display compatibility
|
||||||
djui_hud_set_color(r * multiplier, g * multiplier, b * multiplier, a)
|
djui_hud_set_color(r * multiplier, g * multiplier, b * multiplier, a)
|
||||||
end
|
end
|
||||||
|
|
||||||
function displayStarCounter()
|
local function displayStarCounter()
|
||||||
local m = gMarioStates[0]
|
local m = gMarioStates[0]
|
||||||
if psToggle ~= 1 then return end
|
if pscToggle == 0 then return end
|
||||||
--if cutscenes[m.action] ~= nil then return end
|
if obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil then
|
||||||
if obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil
|
|
||||||
or cutscenes[m.action] ~= nil then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Make HUD appear when the real one does during the intro
|
||||||
|
if m.action == ACT_INTRO_CUTSCENE then
|
||||||
|
if introTimer ~= 1195 then
|
||||||
|
introTimer = introTimer + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
djui_hud_set_resolution(RESOLUTION_N64)
|
djui_hud_set_resolution(RESOLUTION_N64)
|
||||||
djui_hud_set_font(FONT_HUD)
|
djui_hud_set_font(FONT_HUD)
|
||||||
|
--Draw over credits fades
|
||||||
|
if cutscenes[m.action] ~= true then
|
||||||
|
djui_hud_set_render_behind_hud(true)
|
||||||
|
else
|
||||||
|
djui_hud_set_render_behind_hud(false)
|
||||||
|
end
|
||||||
|
|
||||||
--I don't want to put this in a seperate function, there's not enough code for it to be worth it.
|
--I don't want to put this in a seperate function, there's not enough code for it to be worth it.
|
||||||
if m.playerIndex == 0 then
|
if m.playerIndex == 0 then
|
||||||
|
@ -70,9 +85,7 @@ function displayStarCounter()
|
||||||
screenHeight = djui_hud_get_screen_height()
|
screenHeight = djui_hud_get_screen_height()
|
||||||
screenWidth = djui_hud_get_screen_width()
|
screenWidth = djui_hud_get_screen_width()
|
||||||
|
|
||||||
if a == nil then
|
if a == nil then a = 255 end
|
||||||
a = 255
|
|
||||||
end
|
|
||||||
|
|
||||||
local timerValFrames = hud_get_value(HUD_DISPLAY_TIMER)
|
local timerValFrames = hud_get_value(HUD_DISPLAY_TIMER)
|
||||||
local timerX = 0
|
local timerX = 0
|
||||||
|
@ -84,7 +97,45 @@ function displayStarCounter()
|
||||||
timerY = 17
|
timerY = 17
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Normal vanilla star counter (The fake real one)
|
||||||
|
--Yes Im hiding the hardcoded one because alignment is a pain lmao
|
||||||
|
if cutscenes[m.action] ~= true then
|
||||||
|
if introTimer >= 1195
|
||||||
|
or m.action ~= ACT_INTRO_CUTSCENE then
|
||||||
|
if m.numStars >= 100 then
|
||||||
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
|
djui_hud_print_text(tostring(m.numStars), screenWidth - 60, screenHeight - 225, 1)
|
||||||
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
|
djui_hud_render_texture(gTextures.star, screenWidth - 76, screenHeight - 225, 1, 1.)
|
||||||
|
else
|
||||||
|
djui_hud_set_adjusted_color(246, 246, 246, a)
|
||||||
|
djui_hud_print_text("X", screenWidth - 60, screenHeight - 225, 1)
|
||||||
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
|
djui_hud_print_text(tostring(m.numStars), screenWidth - 46, screenHeight - 225, 1)
|
||||||
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
|
djui_hud_render_texture(gTextures.star, screenWidth - 76, screenHeight - 225, 1, 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--Normal personal star counter (The red one)
|
--Normal personal star counter (The red one)
|
||||||
|
if cutscenes[m.action] == true then
|
||||||
|
if StarCounter >= 100 then
|
||||||
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
|
djui_hud_print_text(tostring(StarCounter), screenWidth%2 + 38, screenHeight - 235, 1)
|
||||||
|
djui_hud_set_adjusted_color(232, 17, 35, a)
|
||||||
|
djui_hud_render_texture(gTextures.star, screenWidth%2 + 22, screenHeight - 235, 1, 1)
|
||||||
|
else
|
||||||
|
djui_hud_set_adjusted_color(246, 246, 246, a)
|
||||||
|
djui_hud_print_text(tostring("X"), screenWidth%2 + 38, screenHeight - 235, 1)
|
||||||
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
|
djui_hud_print_text(tostring(StarCounter), screenWidth%2 + 54, screenHeight - 235, 1)
|
||||||
|
djui_hud_set_adjusted_color(232, 17, 35, a)
|
||||||
|
djui_hud_render_texture(gTextures.star, screenWidth%2 + 22, screenHeight - 235, 1, 1)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if introTimer >= 1195
|
||||||
|
or m.action ~= ACT_INTRO_CUTSCENE then
|
||||||
if StarCounter >= 100 then
|
if StarCounter >= 100 then
|
||||||
djui_hud_set_adjusted_color(255, 255, 255, a)
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
djui_hud_print_text(tostring(StarCounter), screenWidth - 60 - timerX, screenHeight - 208 - timerY, 1)
|
djui_hud_print_text(tostring(StarCounter), screenWidth - 60 - timerX, screenHeight - 208 - timerY, 1)
|
||||||
|
@ -98,7 +149,8 @@ function displayStarCounter()
|
||||||
djui_hud_set_adjusted_color(232, 17, 35, a)
|
djui_hud_set_adjusted_color(232, 17, 35, a)
|
||||||
djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 208 - timerY, 1, 1)
|
djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 208 - timerY, 1, 1)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
--Total star counter (The green one)
|
--Total star counter (The green one)
|
||||||
if timerValFrames ~= 0 then
|
if timerValFrames ~= 0 then
|
||||||
timerX = 0
|
timerX = 0
|
||||||
|
@ -112,6 +164,31 @@ function displayStarCounter()
|
||||||
milestone_counter = milestone_counter + 1
|
milestone_counter = milestone_counter + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if cutscenes[m.action] == true then
|
||||||
|
if perceived_total_counter >= 100 then
|
||||||
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
|
djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 60, screenHeight - 235, 1)
|
||||||
|
djui_hud_set_adjusted_color(50, 176, 40, a)
|
||||||
|
djui_hud_render_texture(gTextures.star, screenWidth - 76, screenHeight - 235, 1, 1)
|
||||||
|
if milestone_counter ~= 0 then
|
||||||
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
|
djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76, screenHeight - 235, 0.5)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
djui_hud_set_adjusted_color(246, 246, 246, a)
|
||||||
|
djui_hud_print_text(tostring("X"), screenWidth - 60, screenHeight - 235, 1)
|
||||||
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
|
djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 46, screenHeight - 235, 1)
|
||||||
|
djui_hud_set_adjusted_color(50, 176, 40, a)
|
||||||
|
djui_hud_render_texture(gTextures.star, screenWidth - 76, screenHeight - 235, 1, 1)
|
||||||
|
if milestone_counter ~= 0 then
|
||||||
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
|
djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76, screenHeight - 235, 0.5)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if introTimer >= 1195
|
||||||
|
or m.action ~= ACT_INTRO_CUTSCENE then
|
||||||
if perceived_total_counter >= 100 then
|
if perceived_total_counter >= 100 then
|
||||||
djui_hud_set_adjusted_color(255, 255, 255, a)
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 60 - timerX, screenHeight - 190 - timerY, 1)
|
djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 60 - timerX, screenHeight - 190 - timerY, 1)
|
||||||
|
@ -130,35 +207,47 @@ function displayStarCounter()
|
||||||
djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 190 - timerY, 1, 1)
|
djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 190 - timerY, 1, 1)
|
||||||
if milestone_counter ~= 0 then
|
if milestone_counter ~= 0 then
|
||||||
djui_hud_set_adjusted_color(255, 255, 255, a)
|
djui_hud_set_adjusted_color(255, 255, 255, a)
|
||||||
djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76 - timerX,
|
djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76 - timerX, screenHeight - 174 - timerY, 0.5)
|
||||||
screenHeight - 174 - timerY, 0.5)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Trying some HUD trickery here..
|
|
||||||
if is_transition_playing() == true then
|
|
||||||
fadeTimer = 5
|
|
||||||
else
|
|
||||||
if fadeTimer >= 1 then
|
|
||||||
fadeTimer = fadeTimer - 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if fadeTimer > 0
|
|
||||||
or is_game_paused() == true then
|
|
||||||
djui_hud_set_render_behind_hud(true)
|
|
||||||
else
|
|
||||||
djui_hud_set_render_behind_hud(false)
|
|
||||||
end
|
|
||||||
--StarCounter = 120 (Debug thingie)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function PSToggle(msg)
|
--Turn server cheats off, silly!
|
||||||
|
--Will be updated immediately when individual cheats get flags.
|
||||||
|
function cheaterStar()
|
||||||
|
if starCheater == true then return end
|
||||||
|
if gServerSettings.enableCheats ~= 0 then
|
||||||
|
djui_popup_create("This server has cheats enabled.\n\\#31AF28\\Total Star Count\\#FFFFFF\\ will not change.", 2)
|
||||||
|
play_sound_button_change_blocked()
|
||||||
|
starCheater = true
|
||||||
|
else
|
||||||
|
starCheater = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--See how many stars everyone gets!
|
||||||
|
function updatePSC(m)
|
||||||
|
gPlayerSyncTable[0].psc = StarCounter
|
||||||
|
end
|
||||||
|
|
||||||
|
--No star text icon yet, also the text gets removed after the second color change?
|
||||||
|
function update()
|
||||||
|
for i = 0, (MAX_PLAYERS - 1) do
|
||||||
|
gPlayerSyncTable[i].psc = gPlayerSyncTable[i].psc
|
||||||
|
network_player_set_description(gNetworkPlayers[i], "\\#FF0000\\".."Stars"..--[[ "\\#FFFFFF\\".. ]]": " ..tostring(gPlayerSyncTable[i].psc), 255, 255, 255, 255)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function pscToggle(msg)
|
||||||
if msg == string.lower("On") or msg == "1" then
|
if msg == string.lower("On") or msg == "1" then
|
||||||
psToggle = 1
|
pscToggle = 1
|
||||||
|
hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_STAR_COUNT)
|
||||||
return true
|
return true
|
||||||
elseif msg == string.lower("Off") or msg == "0" then
|
elseif msg == string.lower("Off") or msg == "0" then
|
||||||
psToggle = 0
|
pscToggle = 0
|
||||||
|
hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) | HUD_DISPLAY_FLAG_STAR_COUNT)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -168,8 +257,13 @@ end
|
||||||
---------
|
---------
|
||||||
hook_event(HOOK_ON_INTERACT, localStarCounter)
|
hook_event(HOOK_ON_INTERACT, localStarCounter)
|
||||||
hook_event(HOOK_ON_HUD_RENDER, displayStarCounter)
|
hook_event(HOOK_ON_HUD_RENDER, displayStarCounter)
|
||||||
hook_chat_command('pstarcount', 'On|Off - Displays stars you"ve collected. Default is On.', PSToggle)
|
hook_event(HOOK_ON_LEVEL_INIT, cheaterStar)
|
||||||
|
hook_event(HOOK_UPDATE, update)
|
||||||
|
hook_event(HOOK_UPDATE, updatePSC)
|
||||||
|
hook_chat_command('psc', "On|Off - Displays stars you've collected. Default is On.", pscToggle)
|
||||||
|
|
||||||
|
--Global functions for everyone to use!
|
||||||
|
--Thank you, PeachyPeach!
|
||||||
_G.PersonalStarCounter = {
|
_G.PersonalStarCounter = {
|
||||||
get_star_counter = function ()
|
get_star_counter = function ()
|
||||||
return StarCounter
|
return StarCounter
|
||||||
|
@ -180,6 +274,6 @@ _G.PersonalStarCounter = {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hide_star_counters = function (hide)
|
hide_star_counters = function (hide)
|
||||||
if hide then psToggle = 0 else psToggle = 1 end
|
if hide then pscToggle = 0 else pscToggle = 1 end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
Loading…
Reference in New Issue