Archived

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

making a game's engine moddable

This topic is 5620 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

we''re making a game, and it''d be nice if the engine would be able to support mods. what i mean is how to about making a 100% moddable engine. one where a mod is not just some replaced sprites, new levels, etc. but a whole different game! i think those are called TCs (total conversion). one way that i know, which half-life uses, would be to make a mod dll. the engine loads that dll which over-rides all the necessary functions, etc. that makes sense. the only problem is not only this half-life approach moddable, it''s also hackable. they suggest that the whole engine >> possible hack >> mod dll thing is the problem here, but i''m not sure. i mean, is that really what makes it so vulnerable to hacking, or it something else? so my question is, what other methods are there to make a moddable engine with the game as a "default mod"? and moddable meaning that you can write your own code. thanks for all the help. ps. how do they do mods for q3? ---
shurcool
wwdev

Share this post


Link to post
Share on other sites
Well, I know specifially that Jedi Knight II and Return to Castle Wolfenstein (both based of the Q3 engine) have mods created for them. They were made because the companies that made them released the source to the public. It would be pretty hard to make a game moddable short of allowing people to alter code.

Share this post


Link to post
Share on other sites
The problem is with the dll linking approach. The problem is that cheaters/hackers can impose a pass through dll between the engine and the game code. They can then alter messages between the two.

IIRC, Quake 3 uses a virtual machine to run compiled mod code, which makes ''dll hooking'' a bit harder.

Another approach, followed by Tribes 2 , is to write all of the code in script, and write a script engine into your game engine. That even allows people to mod your game with a text editor. (No compiler required!)

Share this post


Link to post
Share on other sites
quote:
Original post by Erunama
Well, I know specifially that Jedi Knight II and Return to Castle Wolfenstein (both based of the Q3 engine) have mods created for them. They were made because the companies that made them released the source to the public. It would be pretty hard to make a game moddable short of allowing people to alter code.


two questions.

first of all, i don't have q3 (i played the demo, but nothing more), so i don't know how it works. i have half-life, so i know all about that. u open the game, go to custom game, select your mod, press activate and you're there. i also know that installing a mod for unreal tournament is a pain. you have to run a separate exe, etc. so how does it work in q3? is it all nice and you do it in the main menu, like in half-life, or?

ok, make that three questions. if i release the source to my game, it'd be possible to make a mod, no problem. but the problem comes when you try installing that mod. do you replace the original game? can you have two mods installed at the same time? etc. i want this all to be handled nicely in main menu. i don't want many executables, etc. i remeber that in serious sam they did exactly that. in the main menu to go to mods, then you could select different mods there (it was a demo, so there was only "default mod", but you get the idea). does any1 know how they did it?

edit: ok, i don't think this is an option because it will make the game very easy-2-hack.

and last question... :D i just noticed it's a question for CheeseGrater. what's a virtual machine (don't bother answering, i'll look at google anyway)?

edit: from what i found out, it looks like some sort of compiled code which is also portable. so it's some sort of specialized script that gets compiled? is it a good approach? if yes, how would one go about doing it?

---
shurcool
wwdev


[edited by - shurcool on July 24, 2002 1:09:04 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by shurcool

first of all, i don't have q3 (i played the demo, but nothing more), so i don't know how it works. i have half-life, so i know all about that. u open the game, go to custom game, select your mod, press activate and you're there. i also know that installing a mod for unreal tournament is a pain. you have to run a separate exe, etc. so how does it work in q3? is it all nice and you do it in the main menu, like in half-life, or?



It looks about the same as HL from the launcher menu.

quote:

ok, make that three questions. if i release the source to my game, it'd be possible to make a mod, no problem. but the problem comes when you try installing that mod. do you replace the original game? can you have two mods installed at the same time? etc. i want this all to be handled nicely in main menu. i don't want many executables, etc. i remeber that in serious sam they did exactly that. in the main menu to go to mods, then you could select different mods there (it was a demo, so there was only "default mod", but you get the idea). does any1 know how they did it?



Just like half-life: Make a sub directory for each mod. When your game runs, look for mod subdirs under your game directory. For each one that you find, you make an entry in the mod list. You would load the mod by loading the dll/scripts/virual machine compiled file/whatever in the selected directory.

quote:


and last question... :D i just noticed it's a question for CheeseGrater. what's a virtual machine (don't bother answering, i'll look at google anyway)?

edit: from what i found out, it looks like some sort of compiled code which is also portable. so it's some sort of specialized script that gets compiled? is it a good approach? if yes, how would one go about doing it?



If you're using a VM, you compile the sourcecode to some intermediate format (usually called bytecode) The bytecode is the '.exe' of your new system.

The VM is basically a computer simulated on your computer. The VM reads bytecode instead of machine code. This is nice, because people can write programs to run on the VM, and they will work on any system that the VM has been ported to. (PCs, Macs, Playstations, whatever)

Virtual machines are how Java achieves platform independance.

It's by no means easy to write a virtual machine based system from scratch. If you're interested in giving it a go, read some books on Theoretical operating systems and Compiler Design.

I'd go with either dll linking or a script engine myself... Virtual Machines are pretty much overkill unless you plan on Mac/Linux/Console versions of your game.

[edited by - cheesegrater on July 24, 2002 1:22:25 PM]

Share this post


Link to post
Share on other sites
yeah... i guess VM is too good for my game.

so i''ll probably go w/ either DLL linking or a script engine then. i''m wondering, just how flexible can a script engine be? depends on how i write it, or is there a limit? what if i were to use one, like Lua or such? is that a good idea? would it be too slow? would it be too hard to make a game in it (my game is a real-time multiplayer 2d game, like Worms by team17)? or a mod?

haha, i know i asked too many questions, but please try to answer some of them! thanks...

---
shurcool
wwdev

Share this post


Link to post
Share on other sites
I''d go with the script approach too. That''s what I plan on doing. I''m going to bundle a toolset, like Neverwinter Nights, although not nearly as complicated or polished. Just enough with some documentation to allow a user to update various game controls and events.

-----------------------------
kevin@mayday-anime.com
http://games.mayday-anime.com

Share this post


Link to post
Share on other sites
I''ll go with the script approach, too. But I want to use flow charts instead of simple text scripts, because flow charts are much easier to understand, more fun to create and even executing these flow charts could be easier...
I guess, scientifically spoken these flow charts are a kind of finite state machines and these were used by Quake for UI and AI.
So this stuff shouldn''t be too bad, what do you think? (I mean I didn''t start coding this yet, so if you think (or better know) that this is complete crap, you could save me a lot of work.... ;-) )

-Philipp

Share this post


Link to post
Share on other sites
I think scripting would be the way to go, that way anyone can modify the game, and they wouldnt need a C/C++ compiler either.

The only problem is that making a stable scripting engine is HARD! I''ve made several attempts at it and failed. I''d recommend that you check out some of the several scripting languages that are out there today: Lua, Python, java-script (spidermonkey at www.mozilla.org), etc.

But if you want to make your own scripting language, there is an on-going series here at GameDev (I like this one the best) and theres a full series of tutorials over at flipcode.

Share this post


Link to post
Share on other sites
Not like nobody''s mentioned it, or like I haven''t pimped it enough so far, but I strongly recommend you take a long look at Lua for your scripting needs. It''s easy to program, easy to extend, and easy to embed in your application.

I started out my adventure game engine scripting with Python; but while Python is built for easy extension and easy embedding, if you''re trying to do both, things get quite tricky. Moreover, the C interface for Lua is extremely simple and quick to master (as long as you''re comfortable working with a stack).

And for your application (modding) functions can be easily overridden, even on a per-instantiation basis. That should make a lot of stuff really easy.



Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
*sign* ok, an update.

after spending about 1.5+ hours reading all the threads which contain the word "Lua" in them (used search), i was totally exhaused and couldn''t do anything... which is why i post this today. anyway, from what i''ve found out, Lua seems to be a good scripting language. it''s possible to compile it (for speed), which is really good.

i did take a look at some Lua vs. Python comparisons, but i''m still not certain which is best for me.

so now i will read all (most of) the threads containing "Python" (because there''s soo many!...) and see what else i can find out about it...

but right now i need answers to these questions:

1. is Lua slow when interpreted? compared to C++ compiled code?

2. is Lua fast (comparable to compiled C/C++) when compiled?

3. how do you execute the compiled .out file (i used LuaC.exe on some .lua file and got the .out file)?

4. could i do the following things w/ it:
- on startup, load all the scrips, and recompile them if necessary (if they''ve changed)
- load all the gamerules scripts and let the user select which one they want in menus (deathmath? capture the flag? make a new script, and you have another gameplay mode)
- same thing for weapons, allowing to make unusual weapons, having access to all the game vars (player positions, etc.)
- run the compiled scripts at a very high speed and recompile them if they''ve changed if necessary (will that take a lot of time?)

5. any tuts or link on how to embed a script in a Visual C++ 6 project (how to interpret on the fly, or run a compiled script, all from this C++ program)? don''t answer this if it''s already in the manual (but tell me that it is! ), which i will sooner or later read.

does that sound like something Lua can do? or is Python better for my purposes?

ok, now off to research Python... *sign*

---
shurcool
wwdev

Share this post


Link to post
Share on other sites
quote:
Original post by shurcool
*sign* ok, an update.

after spending about 1.5+ hours reading all the threads which contain the word "Lua" in them (used search), i was totally exhaused and couldn''t do anything... which is why i post this today. anyway, from what i''ve found out, Lua seems to be a good scripting language. it''s possible to compile it (for speed), which is really good.



Check out http://lua-users.org. The best lua resource out there that I''ve found.

quote:

1. is Lua slow when interpreted? compared to C++ compiled code?



It depends what you''re doing with it. Nothing is going to be much faster than C/C++, but for most regular scripting tasks, it''s fast enough that you won''t notice any difference. I don''t suggest you use it for things like visibility computation, collision detection, etc., where tight optimization is needed.

quote:

2. is Lua fast (comparable to compiled C/C++) when compiled?


See above.

quote:

3. how do you execute the compiled .out file (i used LuaC.exe on some .lua file and got the .out file)?



In C/C++, you''ll probably be using lua_dofile. Or, if you just want to play around, use the standalone lua interpreter (lua.exe) and use lua''s built-in dofile function.

Lua can transparently handle both source and bytecoded files.

quote:

4. could i do the following things w/ it:
- on startup, load all the scrips, and recompile them if necessary (if they''ve changed)


Sure, tho it isn''t necessarily needed. Profile your application and see if you need the extra speed boost from bytecoding.

quote:

- load all the gamerules scripts and let the user select which one they want in menus (deathmath? capture the flag? make a new script, and you have another gameplay mode)


I don''t see why not. You could iterate through each of the lua files found, calling dofile on each one. Each script would set global variables with information about itself, and then you''d aggregate it and display it to the user.

quote:

- same thing for weapons, allowing to make unusual weapons, having access to all the game vars (player positions, etc.)


The number one determining factor of how moddable your game will be is not the scripting language, but the design of your program. If I recall correctly, there was a great article on doing that in Gamasutra awhile ago.

quote:

- run the compiled scripts at a very high speed and recompile them if they''ve changed if necessary (will that take a lot of time?)


In my experience, Lua is fast enough for any scripting task I''ve needed it for. But again, if you want to do highly optimized tasks like collision detection, I suggest you implement them in C/C++ (and then expose them to Lua).

quote:

5. any tuts or link on how to embed a script in a Visual C++ 6 project (how to interpret on the fly, or run a compiled script, all from this C++ program)? don''t answer this if it''s already in the manual (but tell me that it is! ), which i will sooner or later read.


What I did was make a folder called "Lua files", and then make a custom build rule for that folder. However, since Lua can execute source as well as bytecode, I ended up not using it. I''ll just run luac when I''m preparing a release.

quote:

Does that sound like something Lua can do? or is Python better for my purposes?


Python has more complex syntax, which in some cases can give you more power with less programming. Additionally, it has a large user/developer base. It''s definitely worth taking a look at. But before you commit to either one, spend a fair amount of time playing around with them, and (most importantly) embedding each one into a test app.



Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
thank you, Sneftel, that was very helpful!

i guess i''ll 1st try Lua, and then Python.

quote:

It depends what you''re doing with it. Nothing is going to be much faster than C/C++, but for most regular scripting tasks, it''s fast enough that you won''t notice any difference. I don''t suggest you use it for things like visibility computation, collision detection, etc., where tight optimization is needed.



of course, i''m not going to use it for collision detection, but i am for weapons. what i''m planning to do is have a weapon description (rate of fire, type of weapon, ammo in clip, etc.) part of the script read at weapon load time. then, during the game, depending on the weapon type (we should have enough to make almost any kind of weapon), it will call a specific script function when the projectile hits a wall, when the player shoots, reloads (not too sure if i need a script function for that...), or enough time has passed to update the projectile position (because maybe it''s a controllable missile or something - speed and gravity isn''t good enough). of course, depending on the weapon description, you can tell it to use the generic weapon reload function using these reload times, or something. so for a simple handgun, all you''d need is its description. but for a very compilcated weapon (one that shoots projectiles which spawn more projectiles, or some big nuke which spawns a radiation cloud :D :D), you''d need a lot of custom scripted function. that means both beginner scripters and pros can do what they want!

---
shurcool
wwdev

Share this post


Link to post
Share on other sites
quote:
Original post by shurcool
of course, i''m not going to use it for collision detection, but i am for weapons. what i''m planning to do is have a weapon description (rate of fire, type of weapon, ammo in clip, etc.) part of the script read at weapon load time. then, during the game, depending on the weapon type (we should have enough to make almost any kind of weapon), it will call a specific script function when the projectile hits a wall, when the player shoots, reloads (not too sure if i need a script function for that...), or enough time has passed to update the projectile position (because maybe it''s a controllable missile or something - speed and gravity isn''t good enough). of course, depending on the weapon description, you can tell it to use the generic weapon reload function using these reload times, or something. so for a simple handgun, all you''d need is its description. but for a very compilcated weapon (one that shoots projectiles which spawn more projectiles, or some big nuke which spawns a radiation cloud :D :D), you''d need a lot of custom scripted function. that means both beginner scripters and pros can do what they want!


Sounds like a great application for scripting. One thing I would caution, tho: since your scripting won''t have quite as much versatility as the C++ engine it''s built on (an intrinsic disadvantage of embedded languages), you''ll need to make sure your program is robust and extensible enough to handle a very wide range of customization. In particular, put a lot of thought into the graphics system. Having a scriptable particle engine that is fast and efficient, but also extremely customizable, will be a challenging task.



Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
yeah... well, just about everything in this game is a challenge. starting from a totally different approach for creating a destructable/modifyable terrain (my game's a 2d side view shooter, sort of like Worms by team17 but in real-time): using polygons instead of a table describing each pixel (if it's filled it or not). first of all, it's slow, especially since after each modification vertex count usually grows, making the whole thing very slow. i had to learn about bps trees, how to do boolean operations on them, etc. etc. and in the end realized there was a different way, which i ended up using. it's still slow, so i had to work on some vertex reduction algorithm, etc. anything to speed it up. now add to that multiplayer - syncing the land modifications on all players, bullets which might hit some1 when the player shoots, but by the time bullet is traced on the server, land might be different, which renders client-side-prediction useless, causing more trouble. and what about players who connect? you'd have to somehow send them the land modifications to make sure their map's the same. don't forget custom weapons and game-modes, as well as general engine flexibily, power, and speed to allow moddability, which is essential to our game. all these things make me research something completely different, and put up w/ so many difficulties. then had to read millions of articles on networking, consulting in these forums, making some demos, which took me about a month in total. i wish i had a coder on my team who'd be very experienced to help me out (ya, keep dreamin'! ). i do have one, but his skill level is comparable to mine (which isn't bad, i mean we did get lots of stuff done, now we have to put it all together and make it work... well... and fast). oh well, i guess, since this is an "educational" project, so it does what it's supposed to. i spend a lot of time researching each part of this game, thinking how to make it work faster, etc., a lot more than actually working on the game. :-\ now i gotta learn how to use a scripting lang. oh well, i figure by the time we're done (if that ever happens), or even if not (*shudder* all the effort ), i'd be a pro.

ps. i don't know why i typed up all that, but now that i did, i have nothing else to do but to post it...

---
shurcool
wwdev


[edited by - shurcool on July 25, 2002 3:12:29 PM]

Share this post


Link to post
Share on other sites
Why not make your game a mod itself?
HL must work something like that.

----------------
Blaster
Computer game programmer and part time human being
Strategy First - http://www.strategyfirst.com
BlasterSoft - http://www.blastersoft.com

Share this post


Link to post
Share on other sites
quote:
Original post by Blaster
Why not make your game a mod itself?
HL must work something like that.


that's exactly what i'm doing. well, planning to, anyway.

and if you make a mod, with, let's say, just one replaced sprite, it will use the sprite instead of the original one, and use original resources for anything that isn't supplied.

for example, if you want to make such mod, you make a new dir, put some mod descriptor file, and the replaced sprite. you don't need to copy every other one that you didn't change, the engine will use them by default (since they're not supplied) from the dafault mod dir (which is the original game).

---
shurcool
wwdev


[edited by - shurcool on July 25, 2002 3:42:08 PM]

Share this post


Link to post
Share on other sites
Whoa, you guys really got your hands full on that one!

For your project, if you are having problems with speed, I''d go with Lua too. Lua seems faster than python (from what I''ve read) and its also more compact, by several 100''s of kilobytes in fact

Both are very good languages, and fun to mess around with. I just wish that Lua had a big support base like python.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by grasshopa55
I''d go with the script approach too. That''s what I plan on doing. I''m going to bundle a toolset, like Neverwinter Nights, although not nearly as complicated or polished. Just enough with some documentation to allow a user to update various game controls and events.

-----------------------------
kevin@mayday-anime.com
http://games.mayday-anime.com


I wouldn''t call ANYTHING related to Neverwinter Nights "polished", or even "working". That game has to be the worst example of professional game development to date (especially after being so highly anticipated).

Share this post


Link to post
Share on other sites
yoru engine does not sound like it would allow much extensiblity since its a worms clone thus the terrain engine is very specific to be deformable in a certain scenario. i suggest just allow different gaming types (ctf, deathmatch, etc) and weapons. simple stuff. you cant expect to create a full featured modular game like quake3, ut or hl with a very specific engine style.

if you are having trouble with the rest of the game, then its probably a good idea to lower the goals a bit so you do get something done.

also mods should not be created in game, instead a seperate tool should be developed (it will use the same engine) that has debugging and other capabilities. common users wont be modding the game. it sounds like you want to have mods like in ut (ie mutators) which just affect gameplay, not actually recreate the entire game (ie go from first person shooter to 3rd person racing game or sidecroller).

Share this post


Link to post
Share on other sites