Modding in another Barb faction in Dll

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
I have an "Animal" player in my mod that is just another major player added during game setup. I've already modded dll to make them work differently than normal players, using various new GameEvents and Civilizations table tags.

However, for various reasons I'm thinking it might be easier in the long run to add them as a hard-coded playerID in the dll, analogous to Barbarians, with isBarbarian() modded to return true. Can someone tell me if this is a reasonable idea? Or am I crazy?

If reasonable, some follow up questions:
  • Can someone point me to the source for the 34 major civs dll mod? (I found the dll at Gedemon's GitHub site, but couldn't find source files.)
  • Should I cut MAX_MINOR_CIVS and MAX_CIV_PLAYERS down by one each and add ANIMAL_PLAYER as player 62?
  • Or better to increase MAX_PLAYERS by one and add ANIMAL_PLAYER as player 64?
  • Any useful suggestions/comments from other dll modders before I go down this rabbit hole?


Pasted from CvDLLUtilDefines.h for reference:
Code:
// do not change this or have MAX_PLAYERS exceed it - this will require the engine to be rebuilt
#define REALLY_MAX_PLAYERS (80)
#define REALLY_MAX_TEAMS (80)

#define MAX_CIV_PLAYERS										(63)
#define MAX_CIV_TEAMS										(MAX_CIV_PLAYERS)

#define MAX_MAJOR_CIVS										(22)
#define MAX_MINOR_CIVS										(MAX_CIV_PLAYERS - MAX_MAJOR_CIVS)

#define MAX_PLAYERS											(MAX_CIV_PLAYERS + 1)
#define MAX_TEAMS											(MAX_PLAYERS)
#define BARBARIAN_PLAYER									((PlayerTypes)MAX_CIV_PLAYERS)
#define BARBARIAN_TEAM										((TeamTypes)MAX_CIV_TEAMS)
#define OBSERVER_TEAM											((TeamTypes)(MAX_MAJOR_CIVS-1))		//This only works because observer mode is multiplayer/debug only
 
I'd also love the knowhow on how to add custom Barbs. I really want to add some Bushrangers with Unique names (to go hand in hand with Australia).
 
Well, that was easier than I thought it would be. I basically replicated the way the dll adds the barbarian player into the game, with ANIMAL_PLAYER = 62 and MAX_CIV_PLAYERS and MAX_MINOR_CIVS reduced by 1. I modded isBarbarian() to return true for both ANIMAL_PLAYER and BARBARIAN_PLAYER. This takes care of many issues like no contact with other players, not popping goodies, starting at war with all non-barb players, no notifications for war/peace change (which I can set on the Lua side), staying alive with no cities, and so on. There's no spawning logic in dll for this player, but that's OK because I'm doing all that on the Lua side.

It's working in autoplay now with no issues so far.

Now I need to go back into the dll and mod animal behavior to be different than barbs. (The Lion King seems hell-bent on taking a city in my current autoplay.)

I'll try to get my source code up on GitHub this weekend if anyone wants it.
 
If reasonable, some follow up questions:
  • Can someone point me to the source for the 34 major civs dll mod? (I found the dll at Gedemon's GitHub site, but couldn't find source)
 
Thanks Gedemon. I'm still learning how to navigate around GitHub. I found and subsequently forgot where to go to compare files. And then I forked your project into my new repository by accident, though it was something I wanted to do anyway. I hope the FAQ is correct that it's hard to break anything.
 
I've done something similar with Shadowspawn for my Wheel of Time mod. The relevant files on my WoTMod repository are primarily WoTShadowSpawn.h and WoTShadowspawn.cpp. (Open the repository web page, press the 'T' key and then type in the file name.) I basically took the barbs as a template and worked from there. (I hard coded Shadowspawn to be the player id == barb id - 1, I'm aware this may collide with a city state in some world configurations, which I will deal with eventually.)

And basically, yes, IsShadowSpawn() I've defined on units, players, and teams and run through the source code for instances of IsBarbarian() and added corresponding calls to IsShadowSpawn().

The shadowspawn are also set up explicitly in the InitPlayers() function of CvGame (like barbs/minors/majors are done separately by default).

My code is not very elegant and probably non-optimal, I'm a fan of learning by doing about Firaxis' design patterns, which has meant a lot of hit and miss. (And with no one else working on this code but me for now, that hasn't been too much of a problem.) Anyway, hopefully helpful.
 
Back
Top Bottom