mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-28 15:03:01 +00:00
Merge branch 'coop' of github.com:sm64ex-coop-dev/sm64ex-coop into coop
This commit is contained in:
commit
0412044456
1 changed files with 70 additions and 54 deletions
|
@ -1,5 +1,7 @@
|
||||||
-- 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 collect!\nIdea by Mr.Needlemouse, created by Sunk\n\nModified by Demnyx.
|
||||||
|
-- incompatible: gamemode arena
|
||||||
|
|
||||||
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
|
||||||
|
@ -13,68 +15,65 @@ local screenWidth = 0
|
||||||
|
|
||||||
local psToggle = 1
|
local psToggle = 1
|
||||||
|
|
||||||
|
local fadeTimer = 0
|
||||||
|
|
||||||
|
-- junk --
|
||||||
|
cutscenes = {
|
||||||
|
[ACT_END_PEACH_CUTSCENE] = true,
|
||||||
|
[ACT_CREDITS_CUTSCENE] = true,
|
||||||
|
[ACT_END_WAVING_CUTSCENE] = true,
|
||||||
|
[ACT_INTRO_CUTSCENE] = true,
|
||||||
|
}
|
||||||
|
|
||||||
---@param m MarioState
|
---@param m MarioState
|
||||||
--Increments an independent counter if a star is collected.
|
--Increments an independent counter if a star is collected.
|
||||||
function localStarCounter(m, o, type)
|
function localStarCounter(m, o, type)
|
||||||
if (m.playerIndex == 0) and (type == INTERACT_STAR_OR_KEY) then
|
if (m.playerIndex == 0) and (type == INTERACT_STAR_OR_KEY) then
|
||||||
--This ensures that it increments ONLY if a star is collected.
|
--This ensures that it increments ONLY if a star is collected.
|
||||||
if get_id_from_behavior(o.behavior) ~= id_bhvBowserKey then
|
if get_id_from_behavior(o.behavior) ~= id_bhvBowserKey then
|
||||||
--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
|
||||||
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
|
||||||
|
|
||||||
-- 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 is_game_paused() then multiplier = 0.5 end
|
if djui_hud_is_pause_menu_created() then multiplier = 0.57 end
|
||||||
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()
|
function displayStarCounter()
|
||||||
local m = gMarioStates[0]
|
local m = gMarioStates[0]
|
||||||
if psToggle ~= 1 then return end
|
if psToggle ~= 1 then return end
|
||||||
|
--if cutscenes[m.action] ~= nil then return end
|
||||||
if obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil
|
if obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil
|
||||||
or (m.action == ACT_END_PEACH_CUTSCENE
|
or cutscenes[m.action] ~= nil then
|
||||||
or m.action == ACT_CREDITS_CUTSCENE
|
return
|
||||||
or m.action == ACT_END_WAVING_CUTSCENE) then return 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)
|
||||||
|
|
||||||
--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
|
||||||
prevNumStars = m.numStars
|
prevNumStars = m.numStars
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
a = 255
|
||||||
end
|
end
|
||||||
|
|
||||||
if obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil then
|
|
||||||
if a <= 255 and a > 32 then
|
|
||||||
a = a - 40
|
|
||||||
else
|
|
||||||
a = 0
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if a >= 0 and a < 215 then
|
|
||||||
a = a + 16
|
|
||||||
else
|
|
||||||
a = 255
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local timerValFrames = hud_get_value(HUD_DISPLAY_TIMER)
|
local timerValFrames = hud_get_value(HUD_DISPLAY_TIMER)
|
||||||
local timerX = 0
|
local timerX = 0
|
||||||
local timerY = 0
|
local timerY = 0
|
||||||
|
@ -85,22 +84,22 @@ function displayStarCounter()
|
||||||
timerY = 17
|
timerY = 17
|
||||||
end
|
end
|
||||||
|
|
||||||
--Normal personal star counter
|
--Normal personal star counter (The red one)
|
||||||
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 - 61 - timerX, screenHeight - 208 - timerY, 1)
|
djui_hud_print_text(tostring(StarCounter), screenWidth - 60 - timerX, screenHeight - 208 - timerY, 1)
|
||||||
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 - 77 - timerX, screenHeight - 208 - timerY, 1, 1)
|
djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 208 - timerY, 1, 1)
|
||||||
else
|
else
|
||||||
djui_hud_set_adjusted_color(246, 246, 246, a)
|
djui_hud_set_adjusted_color(246, 246, 246, a)
|
||||||
djui_hud_print_text(tostring("X"), screenWidth - 61 - timerX, screenHeight - 208 - timerY, 1)
|
djui_hud_print_text(tostring("X"), screenWidth - 60 - timerX, screenHeight - 208 - timerY, 1)
|
||||||
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 - 46.8 - timerX, screenHeight - 208 - timerY, 1)
|
djui_hud_print_text(tostring(StarCounter), screenWidth - 46 - timerX, screenHeight - 208 - timerY, 1)
|
||||||
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 - 77 - timerX, screenHeight - 208 - timerY, 1, 1)
|
djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 208 - timerY, 1, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Total star counter
|
--Total star counter (The green one)
|
||||||
if timerValFrames ~= 0 then
|
if timerValFrames ~= 0 then
|
||||||
timerX = 0
|
timerX = 0
|
||||||
timerY = -10
|
timerY = -10
|
||||||
|
@ -115,26 +114,43 @@ function displayStarCounter()
|
||||||
|
|
||||||
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 - 61 - timerX, screenHeight - 190 - timerY, 1)
|
djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 60 - timerX, screenHeight - 190 - timerY, 1)
|
||||||
djui_hud_set_adjusted_color(50, 176, 40, a)
|
djui_hud_set_adjusted_color(50, 176, 40, a)
|
||||||
djui_hud_render_texture(gTextures.star, screenWidth - 77 - 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 - 77 - timerX, screenHeight - 174 - timerY, 0.5)
|
djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76 - timerX, screenHeight - 174 - timerY, 0.5)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
djui_hud_set_adjusted_color(246, 246, 246, a)
|
djui_hud_set_adjusted_color(246, 246, 246, a)
|
||||||
djui_hud_print_text(tostring("X"), screenWidth - 61 - timerX, screenHeight - 190 - timerY, 1)
|
djui_hud_print_text(tostring("X"), screenWidth - 60 - timerX, screenHeight - 190 - timerY, 1)
|
||||||
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 - 46.8 - timerX, screenHeight - 190 - timerY, 1)
|
djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 46 - timerX, screenHeight - 190 - timerY, 1)
|
||||||
djui_hud_set_adjusted_color(50, 176, 40, a)
|
djui_hud_set_adjusted_color(50, 176, 40, a)
|
||||||
djui_hud_render_texture(gTextures.star, screenWidth - 77 - 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 - 77 - timerX, screenHeight - 174 - timerY, 0.5)
|
djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76 - timerX,
|
||||||
|
screenHeight - 174 - timerY, 0.5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--StarCounter = 120
|
|
||||||
|
-- Trying some HUD trickery here..
|
||||||
|
if is_transition_playing() == true then
|
||||||
|
fadeTimer = 5
|
||||||
|
else
|
||||||
|
if fadeTimer >= 1 then
|
||||||
|
fadeTimer = fadeTimer - 1
|
||||||
|
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)
|
function PSToggle(msg)
|
||||||
|
@ -152,4 +168,4 @@ 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('pstoggle', 'On|Off - Displays stars you"ve collected. Default is On.', PSToggle)
|
hook_chat_command('pstarcount', 'On|Off - Displays stars you"ve collected. Default is On.', PSToggle)
|
||||||
|
|
Loading…
Reference in a new issue