CIV4UnitInfos question

Houman

TR Team Leader
Joined
Jan 24, 2002
Messages
1,083
Code:
<UnitClassAttackMod>
	<UnitClassType>UNITCLASS_WAR_ELEPHANT</UnitClassType>
	<iUnitClassMod>40</iUnitClassMod>
</UnitClassAttackMod>
<UnitClassAttackMod>
	<UnitClassType>UNITCOMBAT_MELEE</UnitClassType>
	<iUnitClassMod>50</iUnitClassMod>
</UnitClassAttackMod>

Would that mean, if my unit attack an War_Elephant, it would make 90% damage (50% because WE is counting as meele + 40% because it is a war elephant?)

Thanks
Houman
 
Another question:

I would like to give my WAR ELEPHANT trapling bonus. It means when it attacks a stack of Army, it can damage the units it is attacking in full and the two other units in the stack only in half-strength.

How would you do that please?

Thanks
Houman
 
Houman said:
Code:
<UnitClassAttackMod>
	<UnitClassType>UNITCLASS_WAR_ELEPHANT</UnitClassType>
	<iUnitClassMod>40</iUnitClassMod>
</UnitClassAttackMod>
<UnitClassAttackMod>
	<UnitClassType>UNITCOMBAT_MELEE</UnitClassType>
	<iUnitClassMod>50</iUnitClassMod>
</UnitClassAttackMod>

Would that mean, if my unit attack an War_Elephant, it would make 90% damage (50% because WE is counting as meele + 40% because it is a war elephant?)

Thanks
Houman

No, it means this units get a 40% strength boost against elephants. The second function won't work because you are trying to use a UnitCombat in a place where it is expecting a UnitClass.
 
For the second question - you can do this with collateral damage, limit it to only 2 extra units and set the damage to 50%, I think it should be something like this:
Code:
<iCollateralDamage>50</iCollateralDamage>
<iCollateralDamageLimit>50</iCollateralDamageLimit>
<iCollateralDamageMaxUnits>2</iCollateralDamageMaxUnits>
So other than maxunits, the other two values are in percentages. I'm not sure if the collateraldamagelimit suppose to indicate how much health is left or taken. That is, if it's left then in order to be able to kill with collateral damage you want this value at zero, i.e. there's no limit to how much damage you can cause overall. Or it's the other way around, I'm sure someone knows this better.
 
Thank you very much for the comments.

1) It would be very important to know what iCollateralDamageLimit means exactly.

2) I have to understand the difference between
UnitClassAttackMod
UnitClassDefenseMod
UnitCombatMod

And how do they stack together...e.g. does UnitClassAttackMod and UnitCombatMod stack together? WHat is the meaning of each?

Any idea for both questions?


Thanks
Houman
 
Houman said:
2) I have to understand the difference between
UnitClassAttackMod
UnitClassDefenseMod
UnitCombatMod

And how do they stack together...e.g. does UnitClassAttackMod and UnitCombatMod stack together? WHat is the meaning of each?
UnitClassAttackMod and UnitClassDefenseMod modify how your unit performs when attacking or defending against a particular class of units, and class refers to pretty much the actual units, e.g. grenadiers get attack bonus of 50% against riflemen.

UnitCombatMod modifies how your unit performs when both attacking and defending against a particular combat type of units, and combat type refers to unit classifications, i.e. Melee, Archer (ranged not the unit), Armor, Mounted, etc.

And as Lord Olleus said, they do stack, but always based off the base value.
 
@Rabbit, White

I see. So the idea is:

Code:
<UnitClassAttackMods>
        <UnitClassAttackMod>
	       <UnitClassType>UNITCLASS_WAR_ELEPHANT</UnitClassType>
	       <iUnitClassMod>40</iUnitClassMod>
        </UnitClassAttackMod>
</UnitClassAttackMods>
<UnitCombatMods>
	<UnitCombatMod>
		<UnitCombatType>UNITCOMBAT_MOUNTED</UnitCombatType>
		<iUnitCombatMod>50</iUnitCombatMod>
	</UnitCombatMod>
</UnitCombatMods>

Now my Unit is able according to the above values, to fight (attack and defend) all the mounted units (e.g. Elephants and Knights). However against Elephants the Unit will fight even better for another 40%, but only if attacking it. Not if defending.

Summary:
Unit attacks or defends Knights = 50% of base
Unit attacks War Elephants = 50% of base + 40% of base
Unit defends War Elephants = only 50% of base

Is this correct?

Thank you,
Houman

P.S. I am still looking for the meaning of iCollateralDamageLimit. If anyone has a clue, please enlighten me. ;)
 
Houman said:
P.S. I am still looking for the meaning of iCollateralDamageLimit. If anyone has a clue, please enlighten me. ;)
Just a guess, but perhaps either the maximum amount of damage it can do in one attack (ie it can only do up to x% damage/turn) or the max amount of damage it can do period (it can't hurt them past x% damage).

EDIT: it appears that it is the latter.
 
hey, is it possible to get the UnitClassType over the GlobalContext only with the Unit-Description ?
like gc.getUnitTypeByDescription(string description)

I didn't find anything like that in the API , but maybe somebody already created such a function? :hmm:
 
You could go through every UnitType by hand and check each one's description, but why do you want to? You can easily get the unittype (or unitclass type) number from the <Type> info.
 
talchas said:
Just a guess, but perhaps either the maximum amount of damage it can do in one attack (ie it can only do up to x% damage/turn) or the max amount of damage it can do period (it can't hurt them past x% damage).

EDIT: it appears that it is the latter.


Are you sure? Have you tested it? ;)

Cheers
Houman
 
talchas said:
You could go through every UnitType by hand and check each one's description, but why do you want to? You can easily get the unittype (or unitclass type) number from the <Type> info.
yes .. hmm..
I want to display a unit with addUnitGraphicGFC( ) from a list ( of unit-descriptions).
This is working a bit with this method - params :


Code:
self.screen.addUnitGraphicGFC( "InterfaceUnitModel", 
                       gc.getUnitInfo(self.unitList.index(
                                  self.screenValues["unitDescription"])
                                  ).getUnitClassType(), 
                       self.xcentre - self.WIDTH/6, 
                       self.ycentre - 250, 
                       self.WIDTH/3, 
                       200, 
                       WidgetTypes.WIDGET_UNIT_MODEL,
                       gc.getUnitInfo(self.unitList.index(
                                  self.screenValues["unitDescription"])
                                  ).getUnitClassType(), 
                       -1,  -20, 30, 1, False )

the unitList contains all unit-descriptions and was built up this way :
Code:
self.unitList = []
        for i in range(gc.getNumUnitInfos()):
            self.unitList.append(gc.getUnitInfo(i).getDescription())

screenValues is a directory, and screenValues["unitDescription"] contains a valid unitDescription, which I can change during runtime.

but when testing to display several units over this way, only the first 6 units are being displayed correctly. Then I get the normal worker graphic for the 7th unit (fast worker) . From this point the unit graphics are shifted to their ID's (or descriptions) somehow .. :hmm:

Edit
I debugged this issue with ingame messages. I'm really displaying unit # 74 (Jet) in method addUnitGraphicGFC(...) but get the graphic for modern armor ! :confused: :sad:
 
Houman said:
@Rabbit, White

I see. So the idea is:

Code:
<UnitClassAttackMods>
        <UnitClassAttackMod>
	       <UnitClassType>UNITCLASS_WAR_ELEPHANT</UnitClassType>
	       <iUnitClassMod>40</iUnitClassMod>
        </UnitClassAttackMod>
</UnitClassAttackMods>
<UnitCombatMods>
	<UnitCombatMod>
		<UnitCombatType>UNITCOMBAT_MOUNTED</UnitCombatType>
		<iUnitCombatMod>50</iUnitCombatMod>
	</UnitCombatMod>
</UnitCombatMods>

Now my Unit is able according to the above values, to fight (attack and defend) all the mounted units (e.g. Elephants and Knights). However against Elephants the Unit will fight even better for another 40%, but only if attacking it. Not if defending.

Summary:
Unit attacks or defends Knights = 50% of base
Unit attacks War Elephants = 50% of base + 40% of base
Unit defends War Elephants = only 50% of base

Is this correct?

Thank you,
Houman

P.S. I am still looking for the meaning of iCollateralDamageLimit. If anyone has a clue, please enlighten me. ;)

You can test all this by use the alt key to get odds tooltips on perspective match ups. Just go into the game, spawn the units you want and check the odds.
 
Belizan said:
try
Code:
gc.getUnitInfo(self.unitList.index(
                                  self.screenValues["unitDescription"])
                                  ).[B]getUnitType[/B]()

CvUnitInfo Object has no attribute 'getUnitType' :(
Because of this I took .getUnitClassType()
 
Vadus said:
CvUnitInfo Object has no attribute 'getUnitType' :(
Because of this I took .getUnitClassType()
That's the one he meant.

What's this code for by the way?

Oh, and we're going slightly off topic here :mischief:
 
The Great Apple said:
That's the one he meant.

What's this code for by the way?

Oh, and we're going slightly off topic here :mischief:

But, when I say, that we found out, that the UnitInfos Class has no getUnitType( ) method were back on topic :D

with my code I want to display the units on a panel, like in the civliopedia. And with a drop down box (containing all unit descriptions) I can change this unitgraphic.
But I didn't find a sample code for this in the CvPediaUnit.py. The CvMainInterface.py ( there is a unit graphic in the left bottom corner of the city screen) uses
Code:
screen.addUnitGraphicGFC( "InterfaceUnitModel", 
                      CyInterface().getHeadSelectedUnit().getUnitType() ... )
but I want to get a unit from a self defined variable (so by description or id )

So I tried a bit on my own and have now this problem, that I only can use the getUnitClassType() from gc.getUnitInfo( ) .. but maybe I need a CyUnit instance .. only this class has the needed getUnitType( ) method
 
Back
Top Bottom