Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (555)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Implementing modding for games  (Read 976 times)
0 Members and 1 Guest are viewing this topic.
Offline Quarry
« Posted 2013-03-14 16:18:40 »

I'm planning on making moddable games but I don't want to share the full source code, what are my options with Java?
Offline actual

JGO Coder


Medals: 23



« Reply #1 - Posted 2013-03-14 16:55:07 »

That is a pretty broad question. I think your options with Java are similar to most other languages.

You can provide a tool (like a level editor, etc) that allows people to make modifications, although that can be a fairly complex task to develop in and of itself.

Another option is to take a data driven approach. For instance, use external configuration files rather than hard coding values. If you want to take this to the extreme, then you can use the Properties Pattern (Steve Yegge has a pretty good description of it). You essentially store everything in hash maps rather than fields.

So you don't have a Ship class any more. Everything is a bag of properties. This can give a lot of freedom to specify all sorts of behavior outside of your code.

The down sides of the approach are that the performance may not be as great, it can get unwieldy to program (lots of getValue("hitPoints"), and you can't take advantage of the static type checking that Java gives you.  If your property is maxHealth and you call it maxhealth, you won't know until run time.

Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #2 - Posted 2013-03-14 16:55:51 »

A scripting language like Lua?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Agro
« Reply #3 - Posted 2013-03-14 17:09:21 »

Or, you can even just use Java. Java's ability to load other JARs in a Java program allow it to be a capable modding platform. You can just use a ClassLoader, and load a class that has all the mod functions.

Offline Quarry
« Reply #4 - Posted 2013-03-14 18:12:43 »

Or, you can even just use Java. Java's ability to load other JARs in a Java program allow it to be a capable modding platform. You can just use a ClassLoader, and load a class that has all the mod functions.

Can I get any game specific examples on this?
Offline Agro
« Reply #5 - Posted 2013-03-14 18:52:35 »

Bukkit's whole plugin system is based on it. Check out CraftBukkit, I've made an IRC client with plugins that was based off of its plugin system. Its pretty neat.

Offline Geemili

Senior Member


Medals: 9
Projects: 1
Exp: 2 years


No Games Finished


« Reply #6 - Posted 2013-03-14 19:22:55 »

I don't know it is the best library to use, but JSPF is a pretty simple.
Offline deepthought
« Reply #7 - Posted 2013-03-14 19:39:52 »

if you have an entity base class you can just use reflection to load subclasses.
This is basically what i am doing for captain failure.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
abstract class entity
{
public void init(String/object[]/whatever args);
public void act/(float delta_time);// thinker function
}

//spawning code
public entity spawn(String classname,String/object[]/whatever args)
{
entity e = (entity)Class.forName(classname).newInstance();
e.init(args);
// add e to main entities list
}


now all you have to do is implement init() and act(). the args parameter for init can be an array of string, an array of objects, a table of key/value pairs, or any other object suitable for storing parameters such as position, rotation, or entity specific values.
The reason I use init() instead of a constructor is so you don't have to use reflection to get a constructor object, which would be slower.

then, in your map editor, allow the user to type in class names to determine entity type

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline Quarry
« Reply #8 - Posted 2013-03-14 21:13:00 »

Thanks for all the replies, I have two more questions though;

1) Can I do this;

Foo.java
1  
2  
3  
4  
5  
6  
class Foo {
int a;

int getValue() {
    return a;
}


Boo.java
1  
2  
3  
4  
5  
6  
class Boo {
int a;

int getValue() {
    return a;
}


1  
Boo obj = (Boo)new Foo();


2) Is there a way to keep my code unobfuscated but still safely commercially release it?
Offline deepthought
« Reply #9 - Posted 2013-03-14 21:33:46 »

no. you can only convert a subclass to a superclass that way.

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline actual

JGO Coder


Medals: 23



« Reply #10 - Posted 2013-03-14 21:40:15 »

A couple of questions:

1. Who do you envision as modding your game? Other programmers? People into your game who can't program?
2. How much of your game do you wish to be moddable? Different art assets? Different behavior?

This will help you decide what kinds of tools to use. If you want non-programmers modding your game, you are going to have to either provide tools or give them access to something they can understand.

And why are you hung up on keeping your source code secret? Is it to prevent cheating?
Offline Quarry
« Reply #11 - Posted 2013-03-14 21:54:44 »

1. Other programmers
2. Enough to add new content, let people add new items or actors to the game
3. I'm not sure, I'm afraid that the code might be stolen or used to create another game
Offline deepthought
« Reply #12 - Posted 2013-03-14 22:03:52 »

you could distribute your engine code if that's agreeable, and people won't be able to steal your game specific stuff.

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline StumpyStrust
« Reply #13 - Posted 2013-03-14 22:53:16 »

Best games for mods basically have a folder where there are .xml type of files that they will use to load in any mods. Most of the loading and what not is done via config files that point to where the resources are and what the changes are. Look at skyrim for a modern approach or Arcanum for a very hacky but quick way.

In Arcanum, almost the whole game is loaded via .mes files which are text files. You can change and/or add things to the game. Fate also has a similar system which works very well. It also depends on the type of game. For fps, you could have some rules files that can be change and maybe a level editor. For a rpg you could load items/skills/all sorts of stuff through various files instead of hard coding things. This will let people play with them without having to recompile things.

As far as code getting stolen, unless it is super super super good no one will want to steal your code. In all honesty, I do not get the whole, "can't use my code" thing. Unless it is for security reasons, there is really no reason not to be liberal with your code. I know that many games do not just give the code away due to copyright issues but if you ask them how they do things, many will tell you or point you in the right direction. Even if someone uses your code, what is wrong with that? I would consider it a compliment.

Online HeroesGraveDev

JGO Kernel


Medals: 246
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #14 - Posted 2013-03-15 04:09:07 »

Technically modding IS editing the source code.

If you aren't dealing with the source, it's called scripting.

Just put the source out there. It saves you a lot of time (by not having to deal with modding compatibility), and if someone really wanted to steal your game, they would have no trouble getting the source anyway.

The kind of people you are trying to stop are the kind who can't be stopped. You just end up ruining it for those who want to be honest and just make some mods.

Also, the chances of making a game people actually WANT to make mods for is quite low. No point wasting time on something that nobody will ever use.

Finally, there is absolutely no way you can account for everything in scripting. No way. That's why modders want to hack into the source and get the power they need.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (38 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (24 views)
2014-08-16 06:20:21

Tekkerue (34 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (48 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!