ModModder's Guide

I'm going to ask anw to try and remove the case requirement.

ok, i replaced unix pathing with windows pathing ... now it should be case-insensitive :)

moreover, i optimized the code, so now it's 84 lines shorter :D and little bit more commented
 
Yup.

Code:
<PrereqInCity>1</PrereqInCity>
<PrereqBuildingORs>
     <PrereqBuilding>BUILDING_WEAPONSMITH</PrereqBuilding>
</PrereqBuildingORs>

I don't know if PrereqInCity is required if you define a building, but best to put it in anyway.

Note that it requires a building, not a buildingclass, so if there are multiple versions of a building you should include them all.
 
Love the guide so far! :lol: Guessing you got started and realized there was a whole lot of info needed.

Question: In the Art Defines (for base RifE), there are a bunch of references to stuff like Art/Interface/Buttons/Promotions/blah.dds, where the files pointed to don't actually exist in the RifE mod folder. But this stuff all does work in the game. So where are these files actually located? If I just want to reuse an image, I can just link to the same place, but if I want to modify an image, it'd be nice to be able to find them...
 
Its in the PAK file, you need PakBuilder to get all the files out, but its a massive file :)
 
Man, all these wacky file formats...

Another quick question. Is there a way to attach string data to a unit?

What I want to do is, mage casts spell on a bonus, remove bonus from tile, add "Drop Bonus" promotion to caster, and attach a string to the caster that says what type of bonus it is. Then when the mage casts "Drop Bonus", put the bonus back down where he's standing.

I'd rather not have to make a new promotion for each type of bonus, especially because it wouldn't work for any new resources that are added by other modmods, patches, or version changes (though version changes will probably break my modmod anyway). But if that's the only way to do it, then so be it.

Also, caster.plot().GetBonusType(), I'm assuming that returns only visible bonuses? Like, unrevealed copper or Patrian Artifacts or whatever will not be returned?
 
Man, all these wacky file formats...

Another quick question. Is there a way to attach string data to a unit?

What I want to do is, mage casts spell on a bonus, remove bonus from tile, add "Drop Bonus" promotion to caster, and attach a string to the caster that says what type of bonus it is. Then when the mage casts "Drop Bonus", put the bonus back down where he's standing.

I'd rather not have to make a new promotion for each type of bonus, especially because it wouldn't work for any new resources that are added by other modmods, patches, or version changes (though version changes will probably break my modmod anyway). But if that's the only way to do it, then so be it.

Also, caster.plot().GetBonusType(), I'm assuming that returns only visible bonuses? Like, unrevealed copper or Patrian Artifacts or whatever will not be returned?

I'm not sure, but I think that you'd need a promotion for every bonus. A pain really, but I can't think of any other way of doing it.
 
Thanks for the answers, jemon. Here's another python question:

I see a lot of "getInfoTypeForString(whatever)", is there a way to go the opposite direction and get the string that corresponds to the integer?

i.e. I would do something like,
Code:
caster.setHasPromotion(gc.getInfoTypeForString("PROMOTION_CARRYING_" + gc.getStringFromInfoType(caster.plot().getBonusType(-1))), True)

Then, even though I'd have to create a promo for each one, at least the python would be relatively short. Then, the requirements function will check for one of the bonustypes that I entered promos for, and probably won't allow it for animal resources or mana.
 
Thanks for the answers, jemon. Here's another python question:

I see a lot of "getInfoTypeForString(whatever)", is there a way to go the opposite direction and get the string that corresponds to the integer?

i.e. I would do something like,
Code:
caster.setHasPromotion(gc.getInfoTypeForString("PROMOTION_CARRYING_" + gc.getStringFromInfoType(caster.plot().getBonusType(-1))), True)
Then, even though I'd have to create a promo for each one, at least the python would be relatively short. Then, the requirements function will check for one of the bonustypes that I entered promos for, and probably won't allow it for animal resources or mana.
I'm really not sure, but you could always try it out :)
If not, the python would be a lot of copy and pasting anyway :)
 
I'm really not sure, but you could always try it out :)
If not, the python would be a lot of copy and pasting anyway :)

Sort of. Without knowing the function name, it's really just a shot in the dark. I suppose I'll either brute force it or wait until the c++ files are out so I can see the function names.
 
Another quick question. Is there a way to attach string data to a unit?

Use SdToolKitAdvanced from the assets/python/utils folder.

I'd rather not have to make a new promotion for each type of bonus, especially because it wouldn't work for any new resources that are added by other modmods, patches, or version changes (though version changes will probably break my modmod anyway). But if that's the only way to do it, then so be it.

I think it's best to make a new promotion for each bonus. You wont have to worry about how to display what kind of bonus the mage is carrying , it's easy to exclude bonuses and it wouldn't work for any new resources that are added by other modmods, patches, or version changes. It is much better to break upfront than cause unintended consequences.

Also, caster.plot().GetBonusType(), I'm assuming that returns only visible bonuses? Like, unrevealed copper or Patrian Artifacts or whatever will not be returned?

You supply an argument to GetBonusType. If it is a TeamTypes you only get resources visible to that team, if it's -1 you always get the resource, if any.
 
Could you give a short overview of how the leach works?

In particular, is it possible to set one unit to be another ones leach point?
 
Something with my module is causing a CTD while loading. I have been debugging it for the last day and some more but I have no idea what it could be.

The CTD is the standard windows error message and no CIV message so it is of no help.


The CTD first appeared when I included two new units (the last ones in the PPQ_CIV4UnitInfos.xml). But when I remove said units, the CTD still appears so it can't be them.

I honestly am lost as to what could be happening. It worked fine one moment and threw up an error the next.

Here is the module, maybe some of you have an idea what is wrong.


PS. I forgot to say that removing the custom PPQ_CIV4UnitInfos.xml file altogether fixes it. But nothing inside the file it self seemed like it was causing the problem so I ignored it.


Edit: I just dug through the whole thing again I have found the XML causing it.
This:
Code:
If I remove said tag, the game works. If not I get a CTD.

But the code is way old (a week at least). And all that time it worked perfectly.
I mean, how can a peace of code that worked perfectly just a day ago suddenly bug up?


I am an idiot. Took me 24 hours to find that I had missed a >

Problem solved.
 
Could you give a short overview of how the leach works?

In particular, is it possible to set one unit to be another ones leach point?

Leashes currently do NOT allow leashes to other units. That will be added, however, and will be used for Summons (and possibly Commander/Minions, at least for the AI). Aside from the cases where it is forced (again, Summons), it will require python to apply. Not something you can do via a promotion.

As for the rest:

There are only two leash tags, iLeashRange and iLeashChance. Both are only accessible via promotion (if done on the unit it can NEVER be removed, chose not to add that. Can accomplish it with promotions anyway)

iLeashRange is the standard tag. It is used for exact leash ranges; Ex: Mana Guardians. Tag accepts anything from 0 on up (0 imitates Held, but allows attacking!).

iLeashChance is the random tag, used to apply a variable leash range. Ex: Acheron. Currently has an issue with removing them, will be fixed. Leash will chance each turn, anything from 0 to the value listed in the tag.

The two tags cooperate nicely, as the randleash is maintained in a separate variable. When a unit gains it's first leash, the plot it is on becomes it's leash plot. This is generally also it's spawn plot, but does not need to be. If a unit has lost all it's leashes, and gains a new one, the new plot becomes it's leash plot. If it already has a leash, the ranges stack (leash 1 + leash 1 = leash 2).

Leashed units may only move within their leash range, but they may attack up to one tile past that range. If a leashed unit ends up outside it's leash (teleportation, blind, etc) it is able to move back towards it's leash, but nowhere else.
That should be it.

Something with my module is causing a CTD while loading. I have been debugging it for the last day and some more but I have no idea what it could be.

The CTD is the standard windows error message and no CIV message so it is of no help.


The CTD first appeared when I included two new units (the last ones in the PPQ_CIV4UnitInfos.xml). But when I remove said units, the CTD still appears so it can't be them.

I honestly am lost as to what could be happening. It worked fine one moment and threw up an error the next.

Here is the module, maybe some of you have an idea what is wrong.


PS. I forgot to say that removing the custom PPQ_CIV4UnitInfos.xml file altogether fixes it. But nothing inside the file it self seemed like it was causing the problem so I ignored it.


Edit: I just dug through the whole thing again I have found the XML causing it.
This:
If I remove said tag, the game works. If not I get a CTD.

But the code is way old (a week at least). And all that time it worked perfectly.
I mean, how can a peace of code that worked perfectly just a day ago suddenly bug up?


I am an idiot. Took me 24 hours to find that I had missed a >

Problem solved.

:lol: I've done that before.

For instance: Been trying to figure out for a few days now why spawngroups were not spawning for the barbs. The isSpawnGroupValid and createSpawnGroup functions both worked, tested them with python.

Finally got down into the code and stepped through the entire barb creation code, line by line, with the game running so I could see what was stored in each variable.

Noticed that it failed on isValid each time, even though I tested that. So stepped through that function too.

Noticed that it failed on the tech requirements. Suddenly realized that every spawngroup I've defined thus far required the barbs to have a tech. There were no early spawns, so I was seeing no spawns in my tests.

:wallbash::wallbash::wallbash::wallbash:
 
Leashes currently do NOT allow leashes to other units. That will be added, however, and will be used for Summons (and possibly Commander/Minions, at least for the AI). Aside from the cases where it is forced (again, Summons), it will require python to apply. Not something you can do via a promotion.

I was thinking a promotion with a PyPerTurn, setting the leash point to the masters position each turn. Are those variables exposed to python currently?
 
I was thinking a promotion with a PyPerTurn, setting the leash point to the masters position each turn. Are those variables exposed to python currently?

That would work, yeah.

Exposed Leash functions:

  • getLeashX() / setLeashX(int)
  • getLeashY() / setLeashY(int)
  • getLeashRange() / setLeashRange(int) / changeLeashRange(int)
  • getLeashChance() / setLeashChance(int) / changeLeashChance(int)
  • getRandLeash()
    • Randomly generated leash for that turn, dependent on LeashChance. Not allowing this one to be modified, could break things.
  • isLeashed()
    • Set automatically if the other tags are, used to tell the game to run the rest of the leash code.
 
Top Bottom