ModModder's Guide

I tried to give a unit the propability to aquire Channeling 2 with Techdiscoveries.
Is it possible or not and when, then how?
the 'unready' promotion has something to do with this i think, also if i remember right the amurite tower mage gets more channeling with higher techs, propabably looking at those units/promos can help you
 
I tried to give a unit the propability to aquire Channeling 2 with Techdiscoveries.
Is it possible or not and when, then how?

It is possible, there are several ways in fact.

I'd create two new promotions:
First one, let's call it "Potential Channeling", is autoaquired whenever you want a unit to have the chance of getting Channeling II. Give it whatever chance you want to apply Channeling II. It has a duration of 1 and degrades to the second promotion, "Failed Channeler" which serves only to block the first one. I'd hide both the new promotions from the player, to reduce clutter, and make a note on the unit that it can gain Channeling II but nothing is certain.​


If you're prepared to wait a while you could use the python on promotion gained Valkrionn is adding, you'd only need one promotion but also some python.
 
how would you make a unit be created when say a city is destroyed

also how do you apply a random race promotion when a unit is created
 
I tried to give a unit the propability to aquire Channeling 2 with Techdiscoveries.
Is it possible or not and when, then how?

Odalrick answered this one pretty well, I think. The way I'd do it at least. :p

For future reference: Far easier to understand what someone is doing when they post the code as well.

Also... Dear god, I'm actually on this side of the Modmodder thread now. :lol: I used to be the one asking the questions and getting Xienwolf to answer. :crazyeye:

how would you make a unit be created when say a city is destroyed

also how do you apply a random race promotion when a unit is created

Function in onCityDestroyed. It's already used for the Vessel of D'tesh, for example.

In order to created a random racial, you need to list the promotions you want to choose from and run a rand past it. Check the Refugee function in CustomFunctions, it selects a random race from a limited selection.
 
Okay, another question for anyone that cares to answer...

Is there any way to give a bonus to ranged defense? There doesn't seem to be an iAirCombatDefense stat, or anything else appropriate... If there's no way to do it in XML, is there a way to do it with python? Like a pyPreCombat function (and a way to figure out if it's a ranged attack or a regular attack)? Or some other trick?

I'm thinking about how to implement a Deflect Arrows spell. It could either grant a promotion to the stack, or it could just activate itself when attacked by range (using up the caster's spell casting for the turn after). Worst comes to worst, just giving a flat +50% or so vs. Archery could work, I guess.
 
i was making an unit for the amurites that would spawn like a grigori adventurer but i wanted it to require kote I've got everything else sorted i think i just needed that
 
well ... if you are looking only for if-condition, then the code is sth like this
Spoiler :
Code:
import CvEventInterface
from CvPythonExtensions import *

gc = CyGlobalContext()
pPlayer = gc.getPlayer(iPlayer) ## gc.getPlayer(gc.getGame().getActivePlayer())
eTeam = gc.getTeam(pPlayer.getTeam())
if (eTeam.isHasTech(CvEventInterface.getEventManager().Techs["Knowledge of the Ether"])):
     ##code
i somehow put that together looking into CustomFunctions.py, so this might not be the best solution :D
 
Another question (won't you be glad when the c++ code is published and I'll only have to ask half as often!):

The revelation spell checks for invisible units by looking for promos (PROMOTION_HIDDEN, PROMOTION_INVISIBLE), etc... But it looks like in addition to those promos, there's also an Invisible tag on units, frex: <Invisible>INVISIBLE_ANIMAL</Invisible>. That doesn't seem to be handled with promos, so when I copied the code for revelation, it doesn't detect that that spider is supposed to be included as an invisible/hidden unit (this may have something to do with the caster being a ranger UU, or it may not).

Is there a getHasInvisibility(INVISIBILITY_TYPE) or similar function? More generally, I don't suppose there's any reference that simply has the name and function prototypes of all the available python functions so I can stop asking?
 
i was making an unit for the amurites that would spawn like a grigori adventurer but i wanted it to require kote I've got everything else sorted i think i just needed that

Ah, anw already answered it but it's just a simple if hasTech check before the rest of the code.

Another question (won't you be glad when the c++ code is published and I'll only have to ask half as often!):

The revelation spell checks for invisible units by looking for promos (PROMOTION_HIDDEN, PROMOTION_INVISIBLE), etc... But it looks like in addition to those promos, there's also an Invisible tag on units, frex: <Invisible>INVISIBLE_ANIMAL</Invisible>. That doesn't seem to be handled with promos, so when I copied the code for revelation, it doesn't detect that that spider is supposed to be included as an invisible/hidden unit (this may have something to do with the caster being a ranger UU, or it may not).

Is there a getHasInvisibility(INVISIBILITY_TYPE) or similar function? More generally, I don't suppose there's any reference that simply has the name and function prototypes of all the available python functions so I can stop asking?

There is a
Code:
 int CyUnit::getInvisibleType(int i)	//InvisibleTypes
function. You would have to loop through invisible types, which is located in BasicInfos, and check if the unit has that type.

Or, if you want just a specific invisibility to be revealed, you can compare it the same way you would to check if a unit has a promotion. Just an

Code:
if pUnit.getInvisibleType(gc.getInfoTypeForString"INVISIBLE_ANIMAL"):
 
Which files I have to change to create a new INVISIBLE type like INVISIBLE_ANIMEL, INVISIBLE_LAND...?
I've tried to add it only in CIV4InvisibleInfo.xml in Assets/XML/Basicinfos but it doesen't work:(
seems that there are more files.

And is there a way to force units (with a promotion) to go on streets or similar improvements?
 
Which files I have to change to create a new INVISIBLE type like INVISIBLE_ANIMEL, INVISIBLE_LAND...?
Ive tried to add it only in CIV4InvisibleInfo.xml in Assets/XML/Basicinfos but it doesent work:( seems that there are more files.

I think its in the DLL, so you'd need to mess with the source code. :(
 
still two questions:p


1. can I combine

<PrereqInCity>
and <PrereqImprovement>

with an OR so that the unit can be in a City or a (for example) fort to gain the promo?

I want to equip fort Commanders with copper iron and mithril weapons but they can't move in citys :rolleyes:


2. is there an opposite of <PromotionPrereq1> so that the unit mustn't have the promo to get an other?
 
still two questions:p


1. can I combine

<PrereqInCity>
and <PrereqImprovement>

with an OR so that the unit can be in a City or a (for example) fort to gain the promo?

I want to equip fort Commanders with copper iron and mithril weapons but they can't move in citys :rolleyes:


2. is there an opposite of <PromotionPrereq1> so that the unit mustn't have the promo to get an other?

  1. Unfortunately, no. However, improvements may have the bActAsCity tag (check citadels) which may work for you.
  2. Yes, but not on the promo itself. PromotionExcludes on the promo you want to block the new one.
 
There is a
Code:
 int CyUnit::getInvisibleType(int i)	//InvisibleTypes
function. You would have to loop through invisible types, which is located in BasicInfos, and check if the unit has that type.

One point of confusion... it takes an int and returns an int. I tried passing -1 as the argument, thinking it might be like some other functions and return any invisible type on a -1, but that caused an exception. So if it must take an invisible type, what does the int returned mean? Is it just a pseudo bool? (edit: or maybe passing INVISIBLE_ALL will return any invisible type? I can't tell for sure if INVISIBLE_ALL means "any" invisible type, or is true for any unit that is invisible to everything.)

(EDIT): Oh wait, it's worse. It seems like the function throws a C++ exception if the unit has no invisibility (regardless of input?)... Which makes it kind of rough for finding out whether or not a unit is invisible... Any help?
 
for i in xrange(pUnit.getNumInvisibleTypes()):
if (pUnit.getInvisibleType(i) > 0):
do stuff

Unfortunately setInvisibleType is not available in python, so you can't set it as not being invisible. Nor is setSeeInvisibleType so you can't make your unit able to see it either, unless you give it a promotion which allow it.




Contrary to what lemonjelly said invisible types are not defined in the DLL. No idea why it didn't work for you to add your own Imma93, it should.
 
Top Bottom