-
Notifications
You must be signed in to change notification settings - Fork 2
/
loose-cap.lua
44 lines (37 loc) · 1.69 KB
/
loose-cap.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
-- name: Loose cap
-- description: Your cap is not sautered onto your skull correctly anymore.\n\nSpecial thanks to Agent X for the name, mod by eros71.
local localMario = gMarioStates[0];
function mario_on_set_action()
if (localMario.action == ACT_START_CROUCHING and localMario.flags & MARIO_CAP_IN_HAND) then --aways exectutes when the player crouches, no idea why
cutscene_put_cap_on(localMario)
end
if (
localMario.action == ACT_RELEASING_BOWSER or
localMario.action == ACT_SOFT_BONK or
localMario.action == ACT_DEATH_ON_BACK or
localMario.action == ACT_THROWN_BACKWARD or
localMario.action == ACT_FALL_AFTER_STAR_GRAB or
localMario.action == ACT_DISAPPEARED or
localMario.action == ACT_FREEFALL
and localMario.flags & ~MARIO_CAP_IN_HAND
) then
mario_blow_off_cap(localMario, 5);
play_character_sound(localMario, CHAR_SOUND_WHOA);
end
end
-- Retrieve cap command.
function on_retrieve_command()
if (localMario.flags & ~MARIO_CAP_ON_HEAD) then --if the retrieve command is executed and mario is not wearing a cap
--obj_mark_for_deletion(cap) --TODO: Delete the cap from the level once it's given back to the player. How do I actually mark the cap?
mario_retrieve_cap(localMario)
cutscene_put_cap_on(localMario)
return true
elseif (localMario.flags & MARIO_CAP_ON_HEAD) then -- if Mario is wearing his cap
djui_chat_message_create('You already have your cap on.')
return true
end
return false
end
-- hooks --
hook_event(HOOK_ON_SET_MARIO_ACTION, mario_on_set_action)
hook_chat_command('retrieve', "- Gives you your cap back.", on_retrieve_command)