DLL Questions

dabeastlybeast

Chieftain
Joined
Aug 28, 2013
Messages
35
So I'm looking at making some more in depth changes with my custom civs, and want to know if I'm completely lost here. I'm looking at having units available only when at war, and can't find anything useful in the XML or SQL files, which leads me to the DLL. My questions are:

1) What exactly is under the DLL, the game source code?

2) How do you view the contents of the DLL?
(Please note I have followed this guide http://forums.civfanatics.com/showthread.php?t=479374)

3) Is what I'm planning even theoretically possible? This is really the main reason I'm delving into this, and want to know if it's even worth it.

If anyone has any input, that would be greatly appreciated. Thanks!
 
You would only need Lua for what you're looking: http://modiki.civfanatics.com/index.php/Player.CanTrain_(Civ5_API)

For instance:

Code:
function WarUnits(iPlayer, iUnit)
       local player = Players[iPlayer]
       local civType = player:GetCivilizationType()
       if civType == X and iUnit == X then   
           local playerTeam = player:GetTeam()
           if Teams[playerTeam ]:IsAtWar() then
              return true
           else
              return
           end
        end
  return true
end
GameEvents.PlayerCanTrain.Add(WarUnits)

Or something like that.
 
You would only need Lua for what you're looking: http://modiki.civfanatics.com/index.php/Player.CanTrain_(Civ5_API)

For instance:

Code:
function WarUnits(iPlayer, iUnit)
       local player = Players[iPlayer]
       local civType = player:GetCivilizationType()
       if civType == X and iUnit == X then   
           local playerTeam = player:GetTeam()
           if Teams[playerTeam ]:IsAtWar() then
              return true
           else
              return
           end
        end
  return true
end
GameEvents.PlayerCanTrain.Add(WarUnits)

Or something like that.
Alright thanks! But where was that Lua file? The only Lua files I could find were the map generation scripts. Also, to add a Lua file through Modbuddy, do you just use Import to VFS?
 
This is one that you make yourself. I think there's a guide in the Tutorials section on how to enable it, but for this type of file you don't import to VFS. Instead, under the properties of your mod you go to Content, and in there add your lua file as an InGameAddin.

You might find this code a little more modular:
Code:
function WarUnits(iPlayer, iUnit)
       local player = Players[iPlayer]
       local requiresWar = GameInfo.Units[iUnit].RequiresWar
       if requiresWar then   
           local playerTeam = player:GetTeam()
           if Teams[playerTeam]:IsAtWar() then
              return true
           else
              return
           end
        end
  return true
end
GameEvents.PlayerCanTrain.Add(WarUnits)
But you would need to add in SQL:

Code:
ALTER TABLE Units ADD RequiresWar boolean default 0;

And then you can just add the tags <RequiresWar>true</RequireWar> to your unit.
 
The only Lua files I could find were the map generation scripts.
There are also Lua scripts as part of the UI and within the DLC scenarios (the latter TurnsRemaining files are particularly useful - worth buying the DLC for just for these if you want to learn Lua for Civ5 IMHO)

Also, to add a Lua file through Modbuddy, do you just use Import to VFS?
That depends on the type of Lua file your are adding/replacing - see http://forums.civfanatics.com/showthread.php?t=487846
 
So just to make sure, all I would need would be a Lua file, containing the code mentioned above, a SQL file, adding the column to the units table, and the normal XML files?

Code:
function WarUnits(iPlayer, iUnit)
       local player = Players[iPlayer]
       local requiresWar = GameInfo.Units[iUnit].RequiresWar
       if requiresWar then   
           local playerTeam = player:GetTeam()
           if Teams[playerTeam]:IsAtWar() then
              return true
           else
              return
           end
        end
  return true
end
GameEvents.PlayerCanTrain.Add(WarUnits)

And just checking, since I'm not that familiar with Lua, being a Java guy myself, would anything in the code need to be changed? I recognize that iPlayer and iUnit are arguments for the function WarUnits, but are these also what are being passed in? Like I said, not that familiar with Lua.
 
So just to make sure, all I would need would be a Lua file, containing the code mentioned above, a SQL file, adding the column to the units table, and the normal XML files?

Yes, that should be all.

And just checking, since I'm not that familiar with Lua, being a Java guy myself, would anything in the code need to be changed? I recognize that iPlayer and iUnit are arguments for the function WarUnits, but are these also what are being passed in? Like I said, not that familiar with Lua.

iPlayer and iUnit are already defined in the DLL. I'm not familiar with programming enough to tell you more than this as an inference. But it's all the code you need to achieve your intent.
 
Top Bottom