Best practices (noob question) - multiple .dll or squeezing everything in one? Created 11 months ago2023-11-28 17:51:08 UTC by jonnymartini jonnymartini

Created 11 months ago2023-11-28 17:51:08 UTC by jonnymartini jonnymartini

Posted 11 months ago2023-11-28 17:51:08 UTC Post #348102
Hey folks,

I'm building a challenge mod as a part of Half-Life's 25th Anniversary.
I have previous experience with C# .Net (school experience, 15 years ago), but I am new to C++, so I might not have all the right reflexes.

In a nutshell. I'm building a mod with different scenarios:
  • Crowbar only (with a few map iterations to remove the impossibility of making it happen - i.e. removing the mines in c2a4c and c2a4e and removing the explosive crates in c2a4g).
  • 9mm only (with iterations at c1a1 to make the doors open without having to break the glass)
  • 1hp mode (with iteration to c1a0d to remove the HEV suit, easy since .rmf is included in SDK)
  • Adding Hardcore skill (4th skill - realistic damage to player/monsters + slow when injured).
  • Realistic mode (counter-strike mechanism for weapons (1 side, 1 main, 1 melee, 1 explosive, with G to drop/change) + hardcore skill)
  • Permadeath mode (no save allowed, exit when dead, default skills + hardcore)
So far, I've programmed the crowbar & 9mm mechanism, and it works (created a new FallThinkProp and FallInitProp entity and removed Materialize() from them to create real pickable and prop unpickable weapons and avoid sound (weapon drop) looping issues.)

But now, it works for the entire game, no matter the skill I select.

If I want to incorporate everything under the same mod, what would be the best practice? How would I achieve that? Should I just create different .dlls and point the right ones depending on the mod selected with the in-game menu?

Open for collaboration as well :)
Posted 11 months ago2023-11-30 11:24:00 UTC Post #348121
Maybe use a cvar that selects the game rules.
Posted 11 months ago2023-11-30 13:40:17 UTC Post #348124
Hello!
You should definitely look into CGameRules and the code around it.

The class: https://github.com/SamVanheer/halflife-updated/blob/master/dlls/gamerules.h#L61
HL deathmatch gamemode: https://github.com/SamVanheer/halflife-updated/blob/master/dlls/gamerules.h#L260
Gamemode factory: https://github.com/SamVanheer/halflife-updated/blob/master/dlls/gamerules.cpp#L371

You can basically select your different scenarios in InstallGameRules (assuming they'd be implemented as gamerules) instead of mangling with different DLLs. The latter could be pretty messy.
Admer456 Admer456If it ain't broken, don't fox it!
Posted 11 months ago2023-11-30 14:49:31 UTC Post #348125
I see I can modify (i.e.) the weapon behavior per "Game mode".
As an example, the crossbow arrow explode on hit MP vs. regular hit in SP

Code: https://github.com/SamVanheer/halflife-updated/blob/fae5e0180a3caaba53b0c2ae7ad2f1218367817e/dlls/crossbow.cpp#L96

For weapon behavior for specific modes, I was thinking about adding the same pattern for each weapons.
For pickup restriction (i.e. crowbar-only mode), I guess I can do the same thing, instead of creating new entities.

Tweaking those isn't that much of a problem.
But I'm a bit lost at adding gamerules associated to this.

Should I copy the code of singleplay_gamerules.cpp and create a new crowbar_gamerules, glock_gamerules, lowhealth_gamerules.cpp files and tweak it accordingly. (Then point in different files with/ IsCrowbarmode, IsGlockmode/, etc.)

If so, how do I add those mode to the UI afterward.
A bit like the new 25th anniversary. You have your skills (1,2,3) and you can select regular or uplink with those skills.
You must be logged in to post a response.