Simple Python Things

Edit:
I mean it fails when a unit is upgraded, not promoted.
The promotion remains on the upgraded unit, but not the effects.

It works just fine on my system. The SDK for stock BTS indeed has the function needed to receive the one point jump in strength.:

Code:
void CvUnit::setBaseCombatStr(int iCombat)
{
	m_iBaseCombat = iCombat;
}
 
I have no doubt that setBaseCombatStr will increase the base Strength of a unit from say 4 to 5.

What you don't understand is that when a Warrior with this promotion upgrades to an Axeman, the Axeman retains the promotion, but does not benefit from the Strength boost.

The codes are only for when the unit earns the promotion for the first time, but there are no codes upon upgrading.
 
I have no doubt that setBaseCombatStr will increase the base Strength of a unit from say 4 to 5.

What you don't understand is that when a Warrior with this promotion upgrades to an Axeman, the Axeman retains the promotion, but does not benefit from the Strength boost.

The codes are only for when the unit earns the promotion for the first time, but there are no codes upon upgrading.

Ah. The promotion works, but when upgrading a unit, the promotion effects do not carryover. Now I understand what you are saying. I'm not sure what python function can be used to deal with that unique situation (i.e. on Upgrade). Do you have an idea?
 
The only function activated upon unit upgrade is OnUnitCreated.
But whatever you code there only affects the unit before upgrade.
Thus, it cannot work via pure python.
 
incorrect

The answer is simple, onUnitCreated check if the unit has the promotion (as the converted unit will do, I've checked the DLL, by the time onUnitCreated is called, the unit is completely converted), and if they do then apply the promotions effects
 
onUnitCreated is activated by other stuff though.
How do you limit it to just upon upgrade :D
 
You mean... come out of my C++ cave?! :eek:

Well, I've not dived into python for a while, but I see no reason why it shouldn't work.

evidence

onUnitCreated() called at the end of the DLL constructor, by this time all promotions have been transferred, including our promotion X here

CyUnit::isHasPromotion (PromotionType ePromotion) is a thing

Can you elaborate why this wouldn't work, as I am going to be leaving in 10 mins, and won't back till friday (away from computer)?
 
onUnitCreated is activated by other stuff though.
How do you limit it to just upon upgrade :D

Well, that's me eating my words. I should know by now, you don't challenge the master of civ 4 python :p

Still, there has got to be a way of doing it... something that distinguishes a unit.

But, while I remember... if a unit has been created, and it has the promotion, surely it must need the effects, regardless of the origin. Therefore my solution should still hold right? So what if somebody gifted it to you, the unit still has the promotion and so should have the effects!
 
It can work if and only if this is the only source of item which will modify base strength.
When you merge with other mod components which have similar stuff, it gets chaotic.

And I won't activate onUnitCreated just for a tiny promotion.
 
It can work if and only if this is the only source of item which will modify base strength.
When you merge with other mod components which have similar stuff, it gets chaotic.

And I won't activate onUnitCreated just for a tiny promotion.

This is how I dealt with the issue in OGI:

1. I limited the promotion to only Melee and Archery units.
2. The promotions were named Elite Melee and Elite Archer.
3. Both promotions require combat II.
4. The strength promotion is combined with one first strike.
5. On upgrade, only the first strike capability transfers from the old unit to the new. Thus, an expert warrior, is not necessarily going to be an expert Axeman. Only the quickness (first strike) is transferred.

This is how it works now, but I plan on developing an SDK fix so that the strength promotion carries over.
 
Hi THE J!,
compliment for your work, amazing!
I don't know if you are considering further development, but I've have an idea for you:
-create object that unit can pick up or drop down in any moment (not only when they are killed), have you alredy done such a thing?
thank you for your great work, and your time :)
 
Is the "Spawn a civ" modcomp compatible with Revolutions ans Barbarian Civs? I'd like to add aliens to AND2 and this seems to be just the right way to do so.
Did anyone try these?
 
Is the "Spawn a civ" modcomp compatible with Revolutions ans Barbarian Civs? I'd like to add aliens to AND2 and this seems to be just the right way to do so.
Did anyone try these?
As far as I have tried the answer is yes it works with both. What it does is allow "timed" spawning events to happen, eg you can set "the huns" to come from nowhere ie edge of scenario map and invade the settled lands.
 
Thx. I just wanted wanted to know if it has some variables or whatever thatis the same as in Rev./Barb.Civ?
Now I only need to know ho to make a civ non-spawnable for Rev./Barb.Civ and game start.
 
I was just wondering, in the Roman Conquerors victory they have to destroy the Carthagians and Celts. But is this available only for the Romans or if any civ kills the Carthagians and Celts they win?
 
Could anyone help me with a small thing?
When I right this python part in the CvEventManager.py under the City [argslist] or something like that it gives me this error:
Civ4ScreenShot0004.JPG


Here is the python part:
Code:
 pUnit = gc.getInfoTypeForString("UNIT_SETTLER")
   if pUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_PLAGUE")):
                              city.setHasRealBuilding(iPlague, True)

I have no idea how to give an attribute to the integer. If anyone knows and tells me I will be indebted to that person.
 
Could anyone help me with a small thing?
When I right this python part in the CvEventManager.py under the City [argslist] or something like that it gives me this error:
View attachment 571238

Here is the python part:
Code:
 pUnit = gc.getInfoTypeForString("UNIT_SETTLER")
   if pUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_PLAGUE")):
                              city.setHasRealBuilding(iPlague, True)

I have no idea how to give an attribute to the integer. If anyone knows and tells me I will be indebted to that person.

getinfotypeforstring does always give you an integer (a number) and pUnit needs to be a unit instance. Btw: I think onCityBuilt has no Unit instance, so you cannot test the settler for promotions. See here:

PHP:
def onCityBuilt(self, argsList)
        city = argsList[0]

you can only alter or test the city instance.

versus

PHP:
    def onUnitKilled(self, argsList):
        'Unit Killed'
        unit, iAttacker = argsList

here you receive a unit instance and the attacker's player id to work with
 
Top Bottom