Skip to content

Commit

Permalink
Backport changes for v2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Alienmario committed Jan 21, 2024
1 parent 084576c commit 520102d
Show file tree
Hide file tree
Showing 9 changed files with 1,126 additions and 237 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vscode/*
*.code-workspace
plugins/*
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
# ModelChooser
A better model chooser for Sourcemod

Tested on HL2DM and Black Mesa, potentially works on other games as well.
A better model chooser for Sourcemod.

## Installation
- Move the config file from corresponding configs folder to your Sourcemod's configs folder
- Move `model_chooser_2020.smx` to your Sourcemod's plugins folder
#### Features
- Third-person model browser
- Custom per-model sounds and animations
- Persistence via cookies
- Extensive configuration
- Admin only and locked models
- Fully automatic downloads
- Scripting API

#### Supported games
- HL2:DM
- Black Mesa

Older build for SM versions lower than 11 is provided but not maintained - `model_chooser_2020_preSM11.smx`
> If you need other games without the custom gamedata requirement, try the **v1 legacy version**.
## Installation
1. Download latest version from the releases page
2. Unpack it in your sourcemod folder
3. Done!

#### Requirements
- DHooks (Included in Sourcemod 11+)
#### Dependencies
- (Compile+Gamedata) **Alienmario/[StudioHdr](https://github.com/Alienmario/StudioHdr/)**
- (Compile+Gamedata) **Alienmario/[smartdm-redux](https://github.com/Alienmario/smartdm-redux)**
- (Compile) **bcserv/[smlib](https://github.com/bcserv/smlib/tree/transitional_syntax)**
- (Compile+Runtime) **DHooks detours** - Included in Sourcemod 11+

#### Compile requirements
- SMLib
## Usage
Type !models to enter. Press moveleft or moveright to browse. Press use or jump to exit.
#### Usage
Type !models to enter. Press movement keys to browse. Press use or jump to exit.

#### Config
- `modelchooser_immunity` (0/1) Whether players have damage immunity / are unable to fire when selecting models
- `modelchooser_autoreload` (0/1) Whether to reload model list on mapchanges

#### Admin commands
- `sm_unlockmodel` Unlock a locked model by name for a player
Expand Down
67 changes: 53 additions & 14 deletions configs-bms/player_models.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,39 @@
{
"Models"
{
//"Example"
//{
// "path" "models/example.mdl"
// "sounds" "Combine"
// "enabled" "1"
// "defaultprio" "100"
// "adminflags" "c"
// "locked" "1"
// "downloads"
// {
// "path" "models/example.ext"
// "path" "models/another.ext"
// }
//}
"Example"
{
"enabled" "0"
"path" "models/example.mdl"
"sounds" "Example"
"hurtsoundHP" "45"
"hudcolor" "10 65 85"
"defaultprio" "100"
"adminflags" "c"
"locked" "0"
"anims"
{
"idle" "ACT_HL2MP_IDLE"
"idle_crouch" "ACT_HL2MP_IDLE_CROUCH"
"walk" "ACT_HL2MP_WALK"
"walk_crouch" "ACT_HL2MP_WALK_CROUCH"
"run" "ACT_HL2MP_RUN"
"jump" "jump"
"noclip"
{
"anim" "ACT_GMOD_NOCLIP_LAYER"
"rate" "2.0"
}
}
"downloads"
{
// Note: Downloads are handled automatically! Only add additional files you need.
"path" "models/example.ext"
"path" "models/another.ext"
}
}

// ----------------------------------------------------------------------------------------

"Hev"
{
Expand Down Expand Up @@ -69,5 +88,25 @@
}
"Sounds"
{
"Example"
{
"View"
{
// "path" "dir/example.wav"
// "path" "dir/example2.wav"
}
"Select"
{
}
"Hurt"
{
}
"Death"
{
}
"Jump"
{
}
}
}
}
68 changes: 54 additions & 14 deletions configs-hl2dm/player_models.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,39 @@
{
"Models"
{
//"Example"
//{
// "path" "models/example.mdl"
// "sounds" "Combine"
// "enabled" "1"
// "defaultprio" "100"
// "adminflags" "c"
// "locked" "1"
// "downloads"
// {
// "path" "models/example.ext"
// "path" "models/another.ext"
// }
//}
"Example"
{
"enabled" "0"
"path" "models/example.mdl"
"sounds" "Example"
"hurtsoundHP" "45"
"hudcolor" "10 65 85"
"defaultprio" "100"
"adminflags" "c"
"locked" "0"
"anims"
{
"idle" "ACT_HL2MP_IDLE"
"idle_crouch" "ACT_HL2MP_IDLE_CROUCH"
"walk" "ACT_HL2MP_WALK"
"walk_crouch" "ACT_HL2MP_WALK_CROUCH"
"run" "ACT_HL2MP_RUN"
"jump" "jump"
"noclip"
{
"anim" "ACT_GMOD_NOCLIP_LAYER"
"rate" "2.0"
}
}
"downloads"
{
// Note: Downloads are handled automatically! Only add additional files you need.
"path" "models/example.ext"
"path" "models/another.ext"
}
}

// ----------------------------------------------------------------------------------------

"Soldier"
{
Expand Down Expand Up @@ -169,6 +188,27 @@
}
"Sounds"
{
"Example"
{
"View"
{
// "path" "dir/example.wav"
// "path" "dir/example2.wav"
}
"Select"
{
}
"Hurt"
{
}
"Death"
{
}
"Jump"
{
}

This comment has been minimized.

Copy link
@belgvr

belgvr Sep 1, 2024

I'd suggest adding a "Taunt" section for when killing an enemy, like NPCs do on single player, they kinda celebrate...

Thanks for your effort in this game!

}

"Male"
{
"Hurt"
Expand Down
110 changes: 110 additions & 0 deletions gamedata/modelchooser.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
"Games"
{
"#default"
{
"Functions"
{
"CBaseEntity::SetModel_" // crashy name (><)
{
"offset" "CBaseEntity::SetModel"
"hooktype" "entity"
"return" "void"
"this" "entity"
"arguments"
{
"model"
{
"type" "charptr"
}
}
}
"CBasePlayer::DeathSound"
{
"offset" "CBasePlayer::DeathSound"
"hooktype" "entity"
"return" "void"
"this" "entity"
"arguments"
{
"info"
{
"type" "objectptr"
"flags" "byref"
}
}
}
"CBasePlayer::SetAnimation"
{
"offset" "CBasePlayer::SetAnimation"
"hooktype" "entity"
"return" "void"
"this" "entity"
"arguments"
{
"playerAnim"
{
"type" "int"
}
}
}
}
}
"hl2mp"
{
"Offsets"
{
"CBaseEntity::SetModel" // CBaseEntity::SetModel(char const*)
{
"windows" "24"
"linux" "25"
}
"CBasePlayer::DeathSound" // CBasePlayer::DeathSound(CTakeDamageInfo const&)
{
"windows" "362"
"linux" "363"
}
"CBasePlayer::SetAnimation" // CBasePlayer::SetAnimation(PLAYER_ANIM)
{
"windows" "365"
"linux" "366"
}
}
"Signatures"
{
"CBaseAnimating::ResetSequence" // CBaseAnimating::ResetSequence(int nSequence)
{
"windows" "\x55\x8B\xEC\xA1\x2A\x2A\x2A\x2A\x53\x56\x57\x83\x78\x30\x00"
"linux" "@_ZN14CBaseAnimating13ResetSequenceEi"
}
}
}
"bms"
{
"Offsets"
{
"CBaseEntity::SetModel" // CBaseEntity::SetModel(char const*)
{
"windows" "26"
"linux" "27"
}
"CBasePlayer::DeathSound" // CBasePlayer::DeathSound(CTakeDamageInfo const&)
{
"windows" "382"
"linux" "383"
}
"CBasePlayer::SetAnimation" // CBasePlayer::SetAnimation(PLAYER_ANIM)
{
"windows" "385"
"linux" "386"
}
}
"Signatures"
{
"CBaseAnimating::ResetSequence" // CBaseAnimating::ResetSequence(int nSequence)
{
"windows" "\x55\x8B\xEC\xA1\x2A\x2A\x2A\x2A\x53\x56\x8B\xD9\xB9\x2A\x2A\x2A\x2A\x57\xFF\x50\x2C\x8B\x7D\x08"
"linux" "@_ZN14CBaseAnimating13ResetSequenceEi"
}
}
}
}
Binary file removed plugins/model_chooser_2020.smx
Binary file not shown.
Binary file removed plugins/model_chooser_2020_preSM11.smx
Binary file not shown.
5 changes: 4 additions & 1 deletion scripting/include/model_chooser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public void __pl_model_chooser_SetNTVOptional()
MarkNativeAsOptional("ModelChooser_UnlockModel");
MarkNativeAsOptional("ModelChooser_LockModel");
MarkNativeAsOptional("ModelChooser_SelectModel");
MarkNativeAsOptional("ModelChooser_IsClientChoosing");
}
#endif

Expand All @@ -37,4 +38,6 @@ native bool ModelChooser_UnlockModel(int client, char[] modelName, bool select =

native bool ModelChooser_LockModel(int client, char[] modelName);

native bool ModelChooser_SelectModel(int client, char[] modelName);
native bool ModelChooser_SelectModel(int client, char[] modelName);

native bool ModelChooser_IsClientChoosing(int client);
Loading

0 comments on commit 520102d

Please sign in to comment.