Jump to content
  • Advertisement
Sign in to follow this  
Joakim_ar

DLL driven game

This topic is 4879 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

I am currently developing a turret defence game (think td maps in warcraft 3 and starcraft). After having made one semi-finished version that was clearly too static and hard to create contents for, I'm trying to make an engine that will allow both me and the end user to manipulate the behaviour of pretty much anything in the game easily. In the editor, each object will have a list of events that are scripted. By scripted, I mean that you can chose a function in a DLL, fill in the needed parameters, and it'll call this function whenever the event occurs. For example, a turret might have the event "Shoot". You'd select a dll and a function inside it, and every time this type of turret shoots, it will call this function. Additionally you can specify a number of parameters to tweak the function's behaviour if it supports it. There are some obvious problems with this approach though: 1)  It's not trivial to retreive a list of functions that exists in a dll, and even if I wrote a function to do it, I wouldn't be able to tell what functions that are really supposed to be used as event handlers and which are to be called from other functions in the dll. 2)  I wouldn't be able to figure out what number and kind of arguments it supports. 3)  DLLs contains raw machine code, and may contain viruses or other malware. As my goal is to make the game modable, some saftey around this would be nice, so you know if you are risking your files and privacy by downloading a costum map or not. To bypass 1) and 2) I made it so that you must make an xml document that exposes the functions inside the dll to the editor; an example would be this:
<dll filename="render.dll">

    <description>Graphical rendering routines</description>

    <author>Joakim Ahnfelt-Rønne</author>

    <function name="RenderMap" alias="rendermap">

        <parameter name="Offset.X" variable="num1" value="0.00" />

        <parameter name="Offset.Y" variable="num2" value="0.00" />

    </function>

    <function name="RenderTurret" alias="renderturret" />

</dll>
Most of it should be obvious, but some things are not. the function name is the name that will appear in the editor. The alias is the actual function name stored in the dll. The parameter name is a short description of what the parameter does, the variable is the variable to store the value in (I pass a limited number of floating point numbers and strings in a structure by reference to the functions in the DLL, which all have the same prototype), and the value is the default value. I would like to know if you tried using DLLs for scripting, and how you did it? Any kind of suggestions and comments are welcome too of course. Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!