Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
fix lakitu cam duplication hopefully (sm64pc#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac0-dev authored Apr 3, 2023
1 parent 4328c00 commit 6838390
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mods/lakituCam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,22 @@ end

local bhvPlayerLakitu = hook_behavior(nil, OBJ_LIST_DEFAULT, true, bhv_custom_lakitu_init, bhv_custom_lakitu)

-- search for a Lakitu with our global index
local function search_for_lakitu(index)
local o = obj_get_first_with_behavior_id(bhvPlayerLakitu)
while o ~= nil do
if o.oLakituOwner == index then
return o
end
o = obj_get_next_with_same_behavior_id(o)
end
return nil
end

-- spawn the local player's Lakitu when the area's sync state is valid (every time the player warps areas)
local function update_lakitu()
-- if a Lakitu that we own already exists, don't spawn a new one
if search_for_lakitu(npl.globalIndex) then return end
-- spawn Lakitu with our custom Lakitu behavior and the default Lakitu model; and mark it as a sync object
spawn_sync_object(bhvPlayerLakitu, E_MODEL_LAKITU, 0, 0, 0, function(o)
-- save the global id of the player that owns this Lakitu
Expand Down

0 comments on commit 6838390

Please sign in to comment.