Adding XP to unit's who are build in a city with Citadel

LoneTraveller

Warlord
Joined
Apr 30, 2008
Messages
283
Location
Montreal, Quebec
Hi,

I'm new to modding in Civ5 and I'm wondering how I could make the 'build_citadel' add experience to units who were build in a city with a citadel near it.

I'm kinda used to Civ4 sdk and would probably be able to do this easily but I have no clue how to do this with the xml in civ5.

Are there C++ files in civ5 ? :confused: while searching these forums I didn't find an 'API' for all the Lua functions either.

What are the limits for modding in Civ5 compared to Civ4 right now ?
 
Short version: No, you can't.

Long version: Nooooooooo, yooooooou caaaaan't.

Very long version: In the XML, you can tie XP for new units to a policy (which is obviously global) or to a specific building in a city. And a building, in turn, could depend on the presence of a nearby resource. But there isn't an easy way in XML to tie it to a nearby Improvement or Feature.

In Lua, you CAN trap the OnUnitCreated event, figure out which city the unit's being created in, and look to see if this Improvement is nearby. This isn't that difficult to do, since this is one of the few Lua functions we know the syntax of, although the map check to see if a Citadel is near the city takes a little work. There's really only one little problem: XP awarded this way can't be used to pick a promotion until the NEXT turn. (Still working on finding a way around that one.) So it's possible in Lua.

Technically, you could also tie it to whether or not the tile is being worked. But the AI would have no idea that this benefit exists, and so wouldn't choose to work the tile. You could of course override this yourself in your own cities, but the AI's cities wouldn't know to do this.

What are the limits for modding in Civ5 compared to Civ4 right now?

The XML modding's not too difficult, and you can do quite a bit with it in terms of general balance tweaks. It's also pretty straightforward (although not FAST) to add new techs, civilizations, resources, units, buildings, eras, and such, with two main exceptions: 3D unit/building models, and adding new sounds (like the voiceovers you hear when researching a new tech or entering a new era). There are also a few things that, while in XML tables, are NOT easy to add new ones of, mainly Yields and font icons. But generally speaking, you can create a large amount of content using only XML, and it won't just be "more of the same" since there are a lot of unused-but-working stubs in the XML schema.

Lua modding of existing functions isn't too tough, either, although to do this you need to duplicate the original before making your changes, which make these sorts of changes the biggest source of conflict between mods. For instance, AssignStartingPlots.lua manages the placement of resources on a new map, so any mod that changes the resource rarities, adds a new resource, etc. (like several of the custom Map types) will be incompatible with each other.
If you want to modify existing UI elements, this sort of thing isn't that difficult to do, although you need to be at least a remotely competent programmer.

Lua modding of NEW functions is basically just yet another programming language; while you've got a huge array of possible things that can be checked and/or changed, the number of triggers is unfortunately limited at the moment. There's not an easy way to key an event to happen when a building is created, for instance, and several of the events we DO have triggers for are UI-related, where the event only fires when the active player (that's you) SEES it happen.
You can do a lot with this sort of Lua. Right now, the most common change seems to be to add new UI windows or pulldowns, with better information for the player. But you can also do plenty of gameplay-related Lua, like add new Wonder effects or some custom unit abilities. (For instance, in my mod, there's a unit combat class that has several units that adjust base power up or down a bit depending on the strength of the opponent. This is pure Lua modification.)

We're still waiting on the full DLL access, which'll open up the possibility of major conversion mods (like Fall From Heaven). Just remember that Civ4 didn't have that at the start, either.
 
you can give city a free building when Citadel found to add XP

The event to trap "when Citadel founded" only applies if the user SEES it being created. AI empires on the other side of the world wouldn't get this. That's why, if you read my longer post, you'd see that the better way to use Lua for this is to work it the other direction: catch when the unit is created, and check for a local Citadel.
 
you mean the SerialEventImprovementCreated only applies Vision of user ?
but the BarbarianCamp use it?

i see your post , but i think your extra XP only can be counted at next turn .
 
you mean the SerialEventImprovementCreated only applies Vision of user ?

Not quite "only". There are some strange circumstances involved, which you'll see with things like the Ancient Ruins. But the event is heavily UI-based, triggering when the active player sees something. In some cases, this means that it might trigger twice. I've had to deal with this a lot for the terraforming logic in my own mod.

i see your post , but i think your extra XP only can be counted at next turn .

Correct. Like it or not, there's not going to be a GOOD solution to this sort of thing. A lot of Lua modding, in the absence of DLL access, is finding something that works well enough to keep you happy. So by using the UnitCreated event, you can give a unit extra XP, but it won't let you use that XP until the following turn. This is almost never going to be a problem in practice.
 
i am not very understand.
you mean the SerialEventImprovementCreated only triggering when the active player sees thing?
and it do not triggering when a Improvement Created?
 
you mean the SerialEventImprovementCreated only triggering when the active player sees thing?
and it do not triggering when a Improvement Created?

Basically, yes.

If the improvement is created by you, in your territory, then it'll trigger when it's created.
If the improvement is created by an opponent, in an area you can't see, then depending on the circumstances and type it might only trigger when it's built, it might only trigger when you first see it, or it might trigger both times.

All of the Serial events are like this. They're designed for UI mods, primarily, so things that the active player can't see aren't handled the same way as things they can.
 
Back
Top Bottom