Archived

This topic is now archived and is closed to further replies.

s_cloudx

How to implement a mod engine?

Recommended Posts

s_cloudx    162
I''ve always been interested in the idea of moding a game. But I''m still confused in most aspect in making a game modeable. So, my question is: How do they implement Modding in games like Half-life and Quake? I understand that Quake''s source code is hidden from the mod developer but yet, it is still reprogrammable. Can anyone please enlighten me?

Share this post


Link to post
Share on other sites
botman    122
You create an API to your engine functions and create a game DLL that makes use of that API.

You publish the API (as header files) and game DLL source code as an SDK and people create a MOD from the modified game DLL source code.

botman

Share this post


Link to post
Share on other sites
s_cloudx    162
Okay, from what I understand:
1) make the game engine (the sounds, physics, graphics, etc.) a dll
2) release the engine''s header to allow the mod dev to use the functions in the engine.
3) make an exe that calls the mod''s dll
4) the mod''s dll calls the engine

Is this how it works? I''m only speculating. BTW, I''m interested in a C-oriented engine.

Share this post


Link to post
Share on other sites
Fidelio_    122
quote:
Original post by s_cloudx
Okay, from what I understand:
1) make the game engine (the sounds, physics, graphics, etc.) a dll
2) release the engine''s header to allow the mod dev to use the functions in the engine.
3) make an exe that calls the mod''s dll
4) the mod''s dll calls the engine

Is this how it works? I''m only speculating. BTW, I''m interested in a C-oriented engine.


No, in Quake and Half-Life the .exe is the graphics engine, and it loads the game logic as a dll. This means you can create your own game by just writing a new dll, using the defined entry functions.

Share this post


Link to post
Share on other sites
chris_graham    122
Scripting is the other approach: again, a limited API is exported, but its exported to a scripting language like python or lua, and then the scripts from that language have hooks into whatever game functionality you exported. Scripts are hooked into the game at various events, such as a entity getting shot, or spawned. This has the advantage of making it very easy to code for the game (you don''t even need to compile), but won''t be as fast. It also has the advantage that you can easily create a console if you think of the console as a dynamically created script.

Share this post


Link to post
Share on other sites
s_cloudx    162
thanks for the advice. So, this is how I think it works, now:

1) make the game engine (graphics, sounds, physics,etc ) an .exe
2) release the engine''s header to allow the mod dev to use the functions in the engine.
3) make the game logic (the AI, weapons, etc.) a .dll
4) The exe calls the mod''s game .dll

Share this post


Link to post
Share on other sites
dMDI    122
You should be careful not to expose all your engine functions to the modder, otherwise a malicious programmer could take advantage of it.

Share this post


Link to post
Share on other sites
s_cloudx    162
Thanks for the warning, dMDI.

Since I'm using C, I can't declare my functions as private. But I have the idea that if I don't declare the function in my engine's header, it could be "hidden" from the mod (unless he is a very stubborn hacker and change the dll to insert his malicious codes. So, let's just add CRC-checks.). Is there any other way to make a function private in C?

[edited by - s_cloudx on October 3, 2002 9:03:45 AM]

Share this post


Link to post
Share on other sites
thona    100
Lets turn around: is there any reason to use C? For something as complex as an engine?


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post


Link to post
Share on other sites
Max_Payne    757
"Since I''m using C, I can''t declare my functions as private. But I have the idea that if I don''t declare the function in my engine''s header, it could be "hidden" from the mod (unless he is a very stubborn hacker and change the dll to insert his malicious codes. So, let''s just add CRC-checks.). Is there any other way to make a function private in C?"

Private is just a C++ keyword, it doesnt change squat to the actual function code, you could call private functions from anywhere if you wanted to. If you design an engine with a gameplay dll, you should only put the necessary functions in header files, nothing superficial, thats all.

Share this post


Link to post
Share on other sites
s_cloudx    162
Oops. I was thinking as a visual basic programmer again. I used privates inside modules. Anyways, back to the topic, What else can I do to make my engine mod eable?

[edited by - s_cloudx on October 5, 2002 4:22:46 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
You should learn C++ and get a LOT of experience with. From what you''re saying you don''t know it much. Nobody goes from 0 to modding.

Share this post


Link to post
Share on other sites
s_cloudx    162
I been using C since I was a kid. Maybe, that's why I'm a little biased on C, althrough I do have some experience with C++.

There are lots of things I don't know and mod is one of them. It is one of the tough subjects of game programming, imho. But I do know how to program games and database. As a matter of fact, I have an easter egg on my database program that "slows down productivity "... *wink* *wink*

Besides, Quake did it in C. BTW, a question that occurred to me this afternoon, how did Quake redirect the game logic from on mod to another? I'm guessing pointers did the trick. Or am I wrong?

[edited by - s_cloudx on October 6, 2002 9:45:46 AM]

[edited by - s_cloudx on October 7, 2002 9:41:59 AM]

Share this post


Link to post
Share on other sites