Need help with DLL modding

PawelS

Ancient Druid
Joined
Dec 11, 2003
Messages
2,811
Location
Poland
So I managed to create a DLL mod using Dale's guide, but I have no idea how to make it actually do something. For example, I want to change the way the number of VPs to win is calculated, so I need to replace the original Game.getVPToWin function with my own version. How do I do it?
 
Sure, you'd then override that in your own derived Game class. Something like

public override int getVPToWin()
{
return base.getVPToWin() * 2;
}

as a silly example of doubling the base game VP counts.
 
Thank you for a quick response, but I still have a problem: how do I make the game use my derived class instead of the base Game class? (sorry if I'm overlooking something obvious)
 
Ah, I thought that was in the modding guide. So the key is to have your own GameFactory, and also an entry point. The entry point should derive from ModEntryPointAdapter and set your GameFactory, which then does the rest. You need a class like this:

public class IncredibleModEntryPoint : ModEntryPointAdapter
{
public override void Initialize(ModSettings modSettings)
{
base.Initialize(modSettings);
modSettings.Factory = new IncredibleModGameFactory();
}
}


and then the GameFactory like

public class IncredibleModGameFactory : GameFactory
{
public override Game CreateGame(ModSettings pModSettings)
{
return new IncredibleModGame(pModSettings);
}
}

Your GameFactory should be used to make the game use any classes you override, such as Game, Character, etc. You can even do custom UI by instantiating your own ClientUI, etc.
 
Now I get it and my mod works, thanks again :)

(The entry point is in the guide, but it uses the standard GameFactory.)
 
I was't aware of these guides, I only used the one from the sticky thread here.
 
Yeah. That damn Dale. So lazy. His site is so out of date too.

Someone should complain to him and force him to update his site. ;)
 
Top Bottom