- Код: Выделить всё
void __thiscall AI_get_value_of_buying_creatures(
void *this,
TTown *town,
eCreatures creatureType,
int *arg8,
int creaturesNum,
float *a6)
{
float v6; // [esp+0h] [ebp-5Ch]
int j; // [esp+Ch] [ebp-50h]
int i; // [esp+10h] [ebp-4Ch]
THero *defenderHero; // [esp+14h] [ebp-48h]
int num2HexAttackUnits; // [esp+18h] [ebp-44h]
char v11[4]; // [esp+1Ch] [ebp-40h] BYREF
char v12[4]; // [esp+20h] [ebp-3Ch] BYREF
float v13; // [esp+24h] [ebp-38h]
char v14[4]; // [esp+28h] [ebp-34h] BYREF
float a4; // [esp+2Ch] [ebp-30h] BYREF
int effective_cost; // [esp+30h] [ebp-2Ch]
float a3; // [esp+34h] [ebp-28h] BYREF
int cost[7]; // [esp+38h] [ebp-24h] BYREF
float a8; // [esp+54h] [ebp-8h] BYREF
int value; // [esp+58h] [ebp-4h]
num2HexAttackUnits = 0;
getCreatureCost(creatureType, cost);
effective_cost = AI_get_effective_cost(cost) * creaturesNum;
value = ((*&akCreatureTypeTraits[creatureType].ai_value * creaturesNum) * *&o_ActivePlayer->gap4[8]);
if ( town->defenderHeroId != -1 )
{
defenderHero = &gpGame->hero[town->defenderHeroId];
value = (value * 1.1);
if ( creatureType / 6 == defenderHero->class_id )
value = (value * 1.1);
if ( (akCreatureTypeTraits[creatureType].abilities & 8) != 0 )
{
for ( i = 0; i < 5; ++i )
{
if ( defenderHero->armyGroup.id[i] != -1
&& (akCreatureTypeTraits[defenderHero->armyGroup.id[i]].abilities & 8) != 0 )
{
++num2HexAttackUnits;
}
}
value = (value * (1.18 - num2HexAttackUnits * 0.06));
}
value = (value * (*&gpGame->player[town->owner].gap3[24] + 0.66));
}
if ( (akCreatureTypeTraits[creatureType].abilities & 8) != 0 )
{
for ( j = 0; j < 5; ++j )
{
if ( town->garrison.id[j] != -1 && (akCreatureTypeTraits[town->garrison.id[j]].abilities & 8) != 0 )
++num2HexAttackUnits;
}
value = (value * (1.18 - num2HexAttackUnits * 0.06));
}
sub_44B9BD(town, 0, &a3, &a4, v14, v12, v11, &a8);
v13 = a8 + 0.96;
value = (value * (v13 * v13 * v13));
v6 = value;
value = (sub_44CD10(cost) * v6);
*arg8 = value;
*a6 = *arg8 / effective_cost;
}