Commit Graph

157 Commits (aed0d4cb3ad7a0740c34a25eb92fab6addef509d)

Author SHA1 Message Date
PeachyPeach d1bb79f4a0
Camera config values for lua (#116)
* Added camera config getters and setters
2022-05-22 18:47:36 -07:00
MysterD f5258f2d41 audio_stream_load_url() cleanup 2022-05-21 21:20:02 -07:00
Lord-Giganticus 499518adde
Add function to load music via https URLs (#100) 2022-05-21 21:17:35 -07:00
MysterD de2300f837 Fix clang/mac compile 2022-05-19 19:42:07 -07:00
Agent X 68d46cdefe
Mouse lock & freeze cam fixes and warp constants (#103) 2022-05-19 17:06:51 -07:00
PeachyPeach 4fbafc2708
Fixed various audio bugs; DynOS can now detect texture duplicates to decrease generated bin files size (#110)
Fixed the following audio bugs:
    Bug: Rom-hacks sequences don't seem to be affected by volume scaling and
         muting
    Fix: Force the BGM sequences to follow the vanilla behavior:
        Volume can't go higher than default volume
        Volume is reduced to 31% when the game is paused
        Audio is stopped when the game is paused outside the Castle levels
    Bug: (Pointed out by Draco) Mario's voice clips are not replaced by the
         player's character's in the following instances: fall to death
         barrier, "here we go" in the ending cutscene, "let's a go"
         after selecting a star, "okey dokey" after starting the game.
    Fix: The first two ones now call
         play_character_sound(m, CHAR_SOUND_...) instead of
         play_sound(SOUND_MARIO_..., pos). The last two ones couldn't be
         fixed the same way for two reasons: First, the corresponding sounds
         were not referenced in the sound table, second, the sound played is
         always cut-off after a few frames (due to how sm64 resets the sound
         banks after loading a level).

Added SOUND_*_LETS_A_GO and SOUND_*_OKEY_DOKEY sounds for each playable
    character as Bass samples.
    Character Bass sounds work the same way as vanilla sounds (i.e. can be
    played with play_character_sound), but they cannot be prematurely stopped
    by sm64 sound banks shenanigans.
    This fixes the cut-off for both the star select and the castle grounds
    entry, plays the sound corresponding to the player's character, and doesn't
    need to extend or edit the sound table.

DynOS can detect texture duplicates when generating a bin or lvl file.
    When a duplicate is detected, the name of the original texture node is
    written instead of the whole PNG data, decreasing significantly the
    resulting file size.
2022-05-19 16:40:45 -07:00
PeachyPeach 27db236b5d
Various bug fixes + Added is_game_paused() and more background music functions to lua (#93)
Bug: DynOS models with animations cannot swap animations if they are
     loaded via lua (smlua_model_util_get_id and
     obj_set_model_extended).
Fix: DynOS_Actor_GetActorGfx takes a graph node instead of a georef,
     and checks for DynosValidActors graph nodes if georef is NULL.

Bug: The game can crash when calling obj_set_model_extended inside a
     HOOK_ON_OBJECT_RENDER hook.
Fix: The crash happens in smlua_model_util_load_with_pool_and_cache_id
     due to pool being NULL. If the game can't allocate an
     AllocOnlyPool object, use DynOS to generate the graph node.

Bug: warp_to_level and similar functions don't trigger HOOK_ON_WARP.
Fix: Call HOOK_ON_WARP hooks in DynOS_Warp_UpdateWarp and
     DynOS_Warp_UpdateExit after level and mario initialization.

Bug: The game sometimes calls HOOK_ON_OBJECT_RENDER hooks for
     unintended objects.
Fix: Initialize hookRender field to 0 when creating an object.

Bug: Actions can't apply gfx offsets to characters that have an anim
     offset (Waluigi, Wario)
Fix: Add m->curAnimOffset to gfx.pos[1] instead of setting it to
     m->pos[1] + m->curAnimOffset, except during the jumbo star
     cutscene.
2022-05-14 14:28:25 -07:00
Agent X 4bc13ef275
djui_hud_get_raw_mouse_x/y, djui_hud_set_mouse_locked (#91) 2022-05-13 19:55:47 -07:00
MysterD 933914d984 Add djui_hud_world_pos_to_screen_pos, and render interpolated rect/texture 2022-05-13 19:54:49 -07:00
MysterD c7cfa1be54 Merge branch 'audio' into unstable 2022-05-08 16:41:05 -07:00
MysterD f2c032c6d8 Specify filetypes in audio folder, add audio_custom_shutdown() 2022-05-08 15:44:04 -07:00
PeachyPeach 94c531272f
More rom-hacks globals to lua; more bug fixes (#84)
New gLevelValues exposed to lua:
        pssSlideStarTime: the time limit in frames for PSS-style levels (default: 630)
        pssSlideStarIndex: the index of the star spawned below the time limit for PSS-style levels (default: 1)
        coinsRequiredForCoinStar: number of coins required to spawn the 7th star of a main course (default: 100)
        wingCapDuration: duration in frames of the wing cap (default: 1800)
        metalCapDuration: duration in frames of the metal cap (default: 600)
        vanishCapDuration: duration in frames of the vanish cap (default: 600)
        wingCapDurationTotwc: duration in frames of the wing cap given to the player at the entrance of TOTWC (default: 1200)
        metalCapDurationCotmc: duration in frames of the metal cap given to the player at the entrance of COTMC (default: 600)
        vanishCapDurationVcutm: duration in frames of the vanish cap given to the player at the entrance of VCUTM (default: 600)
    Fixed a bug preventing the level music from restarting after defeating a Boss.
    Fixed some bugs with 3D coins or any model with the geo_rotate_coin function:
        Disable billboard and cylboard attributes.
        Set the pitch and roll to 0 for the model to rotate properly.
        The model no longer rotates every frame (even when the game is paused), but every time the object is updated.
2022-05-08 12:18:25 -07:00
MysterD 725e26fe83 Make bass sound interface easier to handle 2022-05-08 04:04:14 -07:00
MysterD 034ada738c Re-ran autogen 2022-05-08 00:29:17 -07:00
Beyley Thomas b8553162c2
Add basic Bass audio engine (#58) 2022-05-08 00:25:09 -07:00
PeachyPeach 68e1b72b99
3-digits orange numbers; Fixed red coins and secrets bugs; Correct red coins display during pause (#82)
Modified number_geo to allow it to display orange numbers from 0 to 999.
    Edited red coins/secrets code:
        Added two fields in the Area struct: numRedCoins and numSecrets
        The number of red coins/secrets in every area is computed during level script processing
        Removed the useless global gRedCoinsCollected
    These changes fix the following bugs:
        Wrong sound effect played and incorrect number displayed when there is more than 8 red coins/5 secrets
        Desynced red coins/secrets counter when going from an area to another
        Remotely spawning red coins/secrets stars in other areas without collecting all red coins/secrets
    Pausing the game now shows the correct number of collected red coins / the total number of red coins in the current area.
2022-05-07 19:09:37 -07:00
MysterD cdcbdabb37 Allow Lua to get any vanilla texture 2022-05-07 03:05:25 -07:00
MysterD ad6642a4bd Add support for custom HUD textures and faster texture packs w/o EXTERNAL_DATA 2022-05-06 22:03:12 -07:00
Agent X b972bb1be4
Add surface_terrains.h to constants (#77) 2022-05-02 17:31:55 -07:00
Agent X 6466fbe457
camera_freeze, camera_unfreeze, djui_hud_get_mouse_x, djui_hud_get_mouse_y, set_override_fov, set_override_near, set_override_far (#74) 2022-04-30 17:36:38 -07:00
PeachyPeach 8812fbac8b
HOOK_ALLOW_INTERACT; new HUD functions (#73)
Added new hook: HOOK_ALLOW_INTERACT:
        Called before Mario interacts with an object. Return true to allow the interaction.
        The hook signature is bool function(MarioState, Object, InteractionType)

    Added new HUD constants:
        enum HudDisplayValue:
            HUD_DISPLAY_LIVES
            HUD_DISPLAY_COINS
            HUD_DISPLAY_STARS
            HUD_DISPLAY_WEDGES
            HUD_DISPLAY_KEYS
            HUD_DISPLAY_FLAGS
            HUD_DISPLAY_TIMER
        enum HudDisplayFlags:
            HUD_DISPLAY_FLAGS_NONE
            HUD_DISPLAY_FLAGS_LIVES
            HUD_DISPLAY_FLAGS_COIN_COUNT
            HUD_DISPLAY_FLAGS_STAR_COUNT
            HUD_DISPLAY_FLAGS_CAMERA_AND_POWER
            HUD_DISPLAY_FLAGS_KEYS
            HUD_DISPLAY_FLAGS_UNKNOWN_0020
            HUD_DISPLAY_FLAGS_TIMER
            HUD_DISPLAY_FLAGS_EMPHASIZE_POWER

    Added new HUD functions:
        s32 hud_get_value(enum HudDisplayValue type)
        void hud_set_value(enum HudDisplayValue type, s32 value)
        void hud_render_power_meter(s32 health, f32 x, f32 y, f32 width, f32 height)
2022-04-30 17:33:38 -07:00
Prince Frizzy 2a405b3233
Add two new LUA util functions. (#72) 2022-04-28 20:42:29 -07:00
PeachyPeach 6726a6280a
Changes in level_info; play_transition; dev-only warp command; bug fix for moving sounds played via lua (#69)
Improved level_info.c and added functions to LUA:
        const char *get_level_name_ascii(s16 courseNum, s16 levelNum, s16 areaIndex, s16 charCase):
            Return a level name as an ascii string. If charCase is 1, capitalize all letters.
            If charCase is -1, decapitalize all letters except the first one of each word.
        const u8 *get_level_name_sm64(s16 courseNum, s16 levelNum, s16 areaIndex, s16 charCase):
            Return a level name as an sm64 u8 string.
            If charCase is 1, capitalize all letters.
            If charCase is -1, decapitalize all letters except the first one of each word.
        const char *get_level_name(s16 courseNum, s16 levelNum, s16 areaIndex):
            Shortcut for get_level_name_ascii(courseNum, levelNum, areaIndex, -1).
        const char *get_star_name_ascii(s16 courseNum, s16 starNum, s16 charCase):
            Return a star name as an ascii string.
            If charCase is 1, capitalize all letters.
            If charCase is -1, decapitalize all letters except the first one of each word.
        const u8 *get_star_name_sm64(s16 courseNum, s16 starNum, s16 charCase):
            Return a star name as an sm64 u8 string.
            If charCase is 1, capitalize all letters.
            If charCase is -1, decapitalize all letters except the first one of each word.
        const char *get_star_name(s16 courseNum, s16 starNum):
            Shortcut for get_star_name_ascii(courseNum, starNum, -1).

    Added play_transition function to LUA.
        I chose to copy the function declaration to smlua_misc_utils.h instead of adding area.h
        to the autogen tool, as most structures, variables and functions in area.h aren't meant
        to be used by LUA scripts.

    Added a dev-only warp chat command.
        This command signature is /warp [LEVEL] [AREA] [ACT]. Level can be either a number
            or a shorthand name (bob, wf, ccm...). Area and Act are numbers.
        This command is available only when building the game with DEBUG and DEVELOPMENT.
        This command cannot be used if hosting through Discord.

    Fixed a bug with moving sounds when they are played via a lua script.
        Bug: Moving sounds (including terrain sounds, flying sound, quicksand sound)
            are not played correctly when a lua script play them via a call of
            play_sound or play_sound_with_freq_scale. This is due to how the moving
            sounds are handled internally. They use the f32 pointer provided to the
            play_sound functions to decide if the sound must be kept playing,
            stopped or restarted. Most of the time, the pointer provided is the
            cameraToObject field of Mario's object graph node. Since smlua uses a
            circular buffer for Vec3f conversion, this pointer is lost, and the
            sound engine can't decide what to do with the sound, resulting in a
            weird and incorrect sound effect.
        Fix: play_sound and play_sound_with_freq_scale now calls
            smlua_get_vec3f_for_play_sound before filling the sound request queue,
            to retrieve the correct pointer from the Vec3f provided by smlua.
2022-04-26 13:48:50 -07:00
MysterD 71105833c5 Made specialTripleJump a field of MarioState instead of a global 2022-04-23 00:35:49 -07:00
MysterD 80a5638bd1 Added more detailed lua error logs 2022-04-23 00:15:08 -07:00
MysterD 0d29a29c1b Use binary search for all Lua cobject fields 2022-04-22 18:51:25 -07:00
MysterD 5cfef9abb3 Added gActiveMods global to lua 2022-04-22 18:44:59 -07:00
MysterD 48cff1c5da Split up functions.md into multiple pages 2022-04-22 18:41:42 -07:00
MysterD bc7821a1e9 Added custom mod packets 2022-04-22 00:13:58 -07:00
MysterD ef7dc41560 Added HOOK_ON_DEATH 2022-04-21 18:34:12 -07:00
MysterD c8a0e6da10 Fixed player interactions 2022-04-21 00:48:26 -07:00
MysterD 4b63a16056 Added passes_pvp_interaction_checks() 2022-04-20 18:27:34 -07:00
MysterD 186149b2dd Merge branch 'unstable' of github.com:sm64ex-coop-dev/sm64ex-coop into unstable 2022-04-20 11:22:18 -07:00
MysterD 18d7140954 Add headPos to marioBodyState 2022-04-20 18:21:36 -07:00
PeachyPeach 9e5a45ecdd
Added lua profiler; Added useful object functions; Bug fixes (#65)
Added a basic lua profiler
        If the game is compiled with LUA_PROFILER=1, displays on screen the average execution time per frame of each active lua mod, in microseconds.

    Added object functions
        For some reasons, accessing the object fields obj.o* via lua is rather slow, and can drastically increase execution time of custom behaviors. For basic stuff like setting an object's velocity or moving it, some functions, missing from the original code, have been added:
        s32 obj_is_valid_for_interaction(struct Object *o): returns 1 if an object is valid for interaction, i.e. active, tangible and not interacted.
        s32 obj_check_hitbox_overlap(struct Object *o1, struct Object *o2): returns 1 if two objects hitboxes overlap. Doesn't check tangibility, only hitbox values.
        void obj_set_vel(struct Object *o, f32 vx, f32 vy, f32 vz): sets an object's velocity.
        void obj_move_xyz(struct Object *o, f32 dx, f32 dy, f32 dz): moves an object position by (dx, dy, dz).

    Bug fixes:
        Disable collisions with walls and ceilings after Mario exits a warp pipe to prevent softlocks in narrow places.
        Make the koopa shell exclamation box respawn after some time.
        Quicksand no longer downwarps and instant-kills Mario if he's shocked while being above it.
2022-04-20 11:20:45 -07:00
MysterD 2347ab61c1 Added HOOK_ON_OBJECT_RENDER 2022-04-19 22:36:47 -07:00
MysterD dd6f6c430e Refactor how objects set their models 2022-04-19 18:47:50 -07:00
MysterD 6b67c983ec exposed sequence ids to lua 2022-04-15 21:51:18 -07:00
MysterD fbce5f23c6 Added ability to set a level to skip credits, fixed SM74 bugs 2022-04-15 18:33:10 -07:00
MysterD 9653a19c7d Improve rom hack camera's collisions in tight spaces and focus underwater. Add HOOK_ON_SET_CAMERA_MODE 2022-04-13 00:10:50 -07:00
MysterD 431af75d88 Add a vanilla-like camera for romhacks 2022-04-11 21:04:15 -07:00
MysterD ef4a83dc88 Quick fixes for test 2022-04-10 10:11:13 -07:00
MysterD 2c187bba45 Added default volume support for custom sequences 2022-04-10 09:47:17 -07:00
MysterD 9dc78a0971 Added support for custom music 2022-04-10 09:11:45 -07:00
MysterD 957e03cd81 Added HOOK_GET_STAR_COLLECTION_DIALOG 2022-04-10 02:44:11 -07:00
MysterD 958b04378c Add exit castle warp params to Lua 2022-04-10 02:29:44 -07:00
MysterD 15d6dc3a9c Allow ability to disable vanilla course-specific settings for camera 2022-04-10 01:55:11 -07:00
MysterD 3db42f1700 Allow coop mods to use the backup save slot independently of the normal one 2022-04-10 00:30:47 -07:00
MysterD 653ab58a5d Allow course names/acts to be changed from Lua 2022-04-09 23:28:36 -07:00
MysterD c75e71f24e Unhardcoded all behavior dialogs, allowed replacement of dialogs 2022-04-09 19:50:50 -07:00