void __thiscall A0_Battle_Stack_MakeShot_sub_43F620(_BattleStack_ *this, int Enemy)
{
int v2; // ebx@1
_BattleStack_ *this_v3; // esi@1
int v4; // eax@2
int *v5; // edi@3
int v6; // eax@7
_Hero_ *Hero_v7; // ecx@8
_BattleStack_ *Enemy_v8; // edi@8
int CreatureType_v9; // eax@11
int v10; // ecx@14
int v11; // ebx@14
int v12; // edi@16
int v13; // ecx@16
int v14; // eax@19
signed int v15; // edi@24
int v16; // eax@26
int v17; // ecx@28
char v18; // al@30
char *v19; // eax@31
_BattleStack_ *Stack_v20; // edi@31
int v21; // ebx@31
int v22; // ebx@37
int v23; // eax@37
_BattleStack_ *v24; // ecx@44
int v25; // eax@46
char *v26; // eax@49
int v27; // ebx@56
int v28; // eax@56
int v29; // eax@58
char *v30; // eax@61
int v31; // esi@66
int v32; // ebx@68
int v33; // ecx@70
int v34; // ebx@70
int v35; // edi@72
int v36; // ecx@72
int v37; // eax@75
int v38; // eax@82
int v39; // ecx@84
char v40; // al@86
int v41; // ebx@87
_BattleStack_ *v42; // edi@87
char *v43; // eax@89
int v44; // eax@91
unsigned __int8 v45; // sf@96
unsigned __int8 v46; // of@96
int v47; // eax@100
char *v48; // eax@103
int v49; // [sp+Ch] [bp-20h]@37
int v50; // [sp+10h] [bp-1Ch]@37
int v51; // [sp+14h] [bp-18h]@31
int v52; // [sp+18h] [bp-14h]@3
int v53; // [sp+1Ch] [bp-10h]@3
int v54; // [sp+20h] [bp-Ch]@24
_BattleStack_ *v55; // [sp+24h] [bp-8h]@24
_BattleStack_ *v56; // [sp+28h] [bp-4h]@24
this_v3 = this;
v2 = 0;
this->CurrAttack_Is_Lucky_dword70 = 0;
if ( A0_BattleMgr_dword_699420->hero[A0_Battle_Stack_Get_Controller_sub_43FE60(this)] )
{
v4 = this_v3->Luck_dword4EC;
if ( v4 > 0 )
{
v53 = this_v3->Luck_dword4EC;
v52 = 3;
v5 = &v52;
if ( v4 <= 3 )
v5 = &v53;
if ( A0_Rand_Int_sub_50C7C0(1, 24) <= *v5 )
{
this_v3->CurrAttack_Is_Lucky_dword70 = 1;
if ( !A0_Battle_ShouldNotRenderBattle_sub_46A080((int)A0_BattleMgr_dword_699420) )
{
A0_StartAndPlaySample_Parallel_sub_59A890("goodluck.82m", -1, 3);
v6 = (int)A0_Get_CreatureName_by_Type_adn_Count_sub_43FE20(
this_v3->CreatureType_dword34,
this_v3->Count_dword4C);
sprintf((int)A0_TempText_unk_697428, *(char **)(*((_DWORD *)off_6A5DC4 + 8) + 184), v6);
A0_Battle_MessageToLog_sub_4729D0(A0_BattleMgr_dword_699420->dlg, A0_TempText_unk_697428, 1, 0);
A0_Battle_Play_Std_BattleAnimation_sub_4963C0(A0_BattleMgr_dword_699420, 18, this_v3, 100, 0);
}
}
}
}
Enemy_v8 = (_BattleStack_ *)Enemy;
A0_Battle_Stack_DrawShot_Bullet_sub_43EFE0(this_v3, (_BattleStack_ *)Enemy);
Hero_v7 = A0_BattleMgr_dword_699420->hero[this_v3->Owner_dwordF4];
if ( !Hero_v7 || !A0_Hero_Check_Has_Artifact_Weared_sub_4D9460(Hero_v7, 5) )// Повода с боеприпасами
--this_v3->Creature_29dword74.Ammo_dword64;
CreatureType_v9 = this_v3->CreatureType_dword34;
if ( CreatureType_v9 == 45 ) // Магог
{
v52 = off_687FA8[716];
if ( v52 != -1 )
{
if ( !A0_Battle_ShouldNotRenderBattle_sub_46A080((int)A0_BattleMgr_dword_699420) )
{
A0_StartAndPlaySample_Parallel_sub_59A890((char *)off_687FA8[715], -1, 3);
v11 = A0_Load_Def_sub_55C9C0(A0_BattleAnims_off_641E18[3 * v52]);
Enemy = (int)((char *)A0_BattleMgr_dword_699420 + 112 * Enemy_v8->GexNum_dword38);
v10 = *(_WORD *)(Enemy + 452);
if ( Enemy_v8->Creature_29dword74.Flags_dword10 & 1 )
v10 += (Enemy_v8->Orientation_dword44 != 0 ? 0x2C : 0) - 22;
v53 = v10 - *(_DWORD *)(v11 + 48) / 2;
v13 = *(_WORD *)(Enemy + 454) - Enemy_v8->CreatureImageHeight_dword16C / 2 - *(_DWORD *)(v11 + 52) / 2;
v12 = 0;
Enemy = v13;
while ( 1 )
{
v14 = *(_DWORD *)(v11 + 40) > 0 && **(_DWORD **)(v11 + 44) ? ***(_DWORD ***)(v11 + 28) : 0;
if ( v12 >= v14 )
break;
A0_Battle_Draw_sub_493FC0((int)A0_BattleMgr_dword_699420, 0, 0, 0, 50, 1, 1);
A0_Battle_DrawOrSetBorders_TranparentDef_sub_494F30(
(int)A0_BattleMgr_dword_699420,
v11,
v12,
v53,
Enemy,
0,
0);
A0_FlipBattle_sub_493300((int)A0_BattleMgr_dword_699420);
++v12;
}
A0_Battle_Draw_sub_493FC0((int)A0_BattleMgr_dword_699420, 1, 0, 0, 0, 1, 0);
(*(void (__thiscall **)(int))(*(_DWORD *)v11 + 4))(v11);
v2 = 0;
}
}
A0_Battle_Clear_Stacks_Redraw_Needs_sub_5A69C0(A0_BattleMgr_dword_699420);
v15 = 0;
v53 = v2;
v55 = (_BattleStack_ *)v2;
v56 = (_BattleStack_ *)v2;
BYTE3(Enemy) = 0;
v54 = 0;
do
{
if ( v15 == 6 )
v16 = this_v3->Attacked_Or_MoveTarget_Gex_Num_dword1C;
else
v16 = sub_524370(this_v3->Attacked_Or_MoveTarget_Gex_Num_dword1C, v15);
v17 = (int)&A0_BattleMgr_dword_699420->hex[v16];
if ( v16 >= 0 )
{
if ( v16 < 187 )
{
v18 = A0_BattleMgr_dword_699420->hex[v16].bstack_side;
if ( v18 >= 0 )
{
v51 = *(_BYTE *)(v17 + 25);
v21 = v18;
Stack_v20 = A0_Battle_get_StackByGex_sub_4E7230(v17);
v19 = &A0_BattleMgr_dword_699420->field_53D4[20 * v21 + 168] + v51;
if ( !*v19 )
{
*v19 = 1;
if ( v56 )
{
if ( v56->CreatureType_dword34 != Stack_v20->CreatureType_dword34 )
BYTE3(Enemy) = 1;
}
else
{
v56 = Stack_v20;
}
v51 = 0;
if ( Stack_v20 )
{
v23 = A0_Battle_Stack_CalcDamage_sub_442E80((int)this_v3, 0);
v22 = A0_Battle_Stack_CalcDamageModifs_sub_443C60(
this_v3,
Stack_v20,
v23,
1,
0,
this_v3->GexesWay_Length_dword490,
&v51);
v50 = v22;
v49 = A0_Battle_Stack_MakeDamage_sub_443DB0(Stack_v20, v22);
this_v3->CurrAttack_Is_Lucky_dword70 = 0;
}
else
{
v22 = v50;
}
v55 = (_BattleStack_ *)((char *)v55 + v22);
v53 += v49;
}
v15 = v54;
}
}
}
++v15;
v54 = v15;
}
while ( v15 < 7 );
if ( (signed int)v55 > 0 )
{
if ( BYTE3(Enemy) )
v24 = 0;
else
v24 = v56;
v25 = this_v3->CreatureType_dword34;
if ( v25 < 0 || v25 > 150 )
{
v26 = A0_Empty_dword_691260;
}
else
{
if ( this_v3->Count_dword4C == 1 )
v26 = (*Main_MonsersTable_off_6747B0)[v25].NameSingle_dword14;
else
v26 = (*Main_MonsersTable_off_6747B0)[v25].NameMulti_dword18;
}
A0_Battle_Attacking_Log_Message_sub_469670(
(int)A0_BattleMgr_dword_699420,
(char)v26,
this_v3->Count_dword4C,
(int)v55,
v24,
v53);
A0_Battle_DrawAction_Play_sub_468570(A0_BattleMgr_dword_699420, v52, 1);
}
}
else
{
if ( CreatureType_v9 == 64 || CreatureType_v9 == 65 )// Лич, могущественный лич
{
v32 = off_687FA8[2586];
if ( v32 != -1 )
{
if ( !A0_Battle_ShouldNotRenderBattle_sub_46A080((int)A0_BattleMgr_dword_699420) )
{
A0_StartAndPlaySample_Parallel_sub_59A890((char *)off_687FA8[2585], -1, 3);
v34 = A0_Load_Def_sub_55C9C0(A0_BattleAnims_off_641E18[3 * v32]);
Enemy = (int)((char *)A0_BattleMgr_dword_699420 + 112 * Enemy_v8->GexNum_dword38);
v33 = *(_WORD *)(Enemy + 452);
if ( Enemy_v8->Creature_29dword74.Flags_dword10 & 1 )
v33 += (Enemy_v8->Orientation_dword44 != 0 ? 0x2C : 0) - 22;
v49 = v33 - *(_DWORD *)(v34 + 48) / 2;
v36 = *(_WORD *)(Enemy + 454) - Enemy_v8->CreatureImageHeight_dword16C / 2 - *(_DWORD *)(v34 + 52) / 2;
v35 = 0;
Enemy = v36;
while ( 1 )
{
v37 = *(_DWORD *)(v34 + 40) > 0 && **(_DWORD **)(v34 + 44) ? ***(_DWORD ***)(v34 + 28) : 0;
if ( v35 >= v37 )
break;
A0_Battle_Draw_sub_493FC0((int)A0_BattleMgr_dword_699420, 0, 0, 0, 100, 1, 1);
A0_Battle_DrawOrSetBorders_TranparentDef_sub_494F30(
(int)A0_BattleMgr_dword_699420,
v34,
v35,
v49,
Enemy,
0,
0);
A0_FlipBattle_sub_493300((int)A0_BattleMgr_dword_699420);
++v35;
}
A0_Battle_Draw_sub_493FC0((int)A0_BattleMgr_dword_699420, 1, 0, 0, 0, 1, 0);
(*(void (__thiscall **)(int))(*(_DWORD *)v34 + 4))(v34);
}
}
A0_Battle_Clear_Stacks_Redraw_Needs_sub_5A69C0(A0_BattleMgr_dword_699420);
v53 = 0;
v54 = 0;
v55 = 0;
BYTE3(Enemy) = 0;
v56 = 0;
do
{
if ( v56 == (_BattleStack_ *)6 )
v38 = this_v3->Attacked_Or_MoveTarget_Gex_Num_dword1C;
else
v38 = sub_524370(this_v3->Attacked_Or_MoveTarget_Gex_Num_dword1C, v56);
v39 = (int)&A0_BattleMgr_dword_699420->hex[v38];
if ( v38 >= 0 )
{
if ( v38 < 187 )
{
v40 = A0_BattleMgr_dword_699420->hex[v38].bstack_side;
if ( v40 >= 0 )
{
v49 = *(_BYTE *)(v39 + 25);
v41 = v40;
v42 = A0_Battle_get_StackByGex_sub_4E7230(v39);
if ( v56 == (_BattleStack_ *)6 || (v42->Creature_29dword74.Flags_dword10 >> 4) & 1 )
{
v43 = &A0_BattleMgr_dword_699420->field_53D4[20 * v41 + 168] + v49;
if ( !*v43 )
{
*v43 = 1;
v49 = 0;
if ( v42 )
{
v44 = A0_Battle_Stack_CalcDamage_sub_442E80((int)this_v3, 0);
v50 = A0_Battle_Stack_CalcDamageModifs_sub_443C60(
this_v3,
v42,
v44,
1,
0,
this_v3->GexesWay_Length_dword490,
&v49);
v51 = A0_Battle_Stack_MakeDamage_sub_443DB0(v42, v50);
this_v3->CurrAttack_Is_Lucky_dword70 = 0;
}
v54 += v50;
v53 += v51;
if ( v55 )
{
if ( v55->CreatureType_dword34 != v42->CreatureType_dword34 )
BYTE3(Enemy) = 1;
}
else
{
v55 = v42;
}
}
}
}
}
}
v46 = __SETO__(&v56->CurrDrawAct_IsShooter_byte1, 7);
v45 = (signed int)((char *)v56 - 6) < 0;
v56 = (_BattleStack_ *)((char *)v56 + 1);
}
while ( v45 ^ v46 );
if ( v54 > 0 )
{
if ( BYTE3(Enemy) )
v55 = 0;
v47 = this_v3->CreatureType_dword34;
if ( v47 < 0 || v47 > 150 )
{
v48 = A0_Empty_dword_691260;
}
else
{
if ( this_v3->Count_dword4C == 1 )
v48 = (*Main_MonsersTable_off_6747B0)[v47].NameSingle_dword14;
else
v48 = (*Main_MonsersTable_off_6747B0)[v47].NameMulti_dword18;
}
A0_Battle_Attacking_Log_Message_sub_469670(
(int)A0_BattleMgr_dword_699420,
(char)v48,
this_v3->Count_dword4C,
v54,
v55,
v53);
A0_Battle_DrawAction_Play_sub_468570(A0_BattleMgr_dword_699420, -1, 1);
}
}
else
{
Enemy = 0;
if ( Enemy_v8 )
{
v28 = A0_Battle_Stack_CalcDamage_sub_442E80((int)this_v3, 0);
v27 = A0_Battle_Stack_CalcDamageModifs_sub_443C60(
this_v3,
Enemy_v8,
v28,
1,
0,
this_v3->GexesWay_Length_dword490,
&Enemy);
Enemy = A0_Battle_Stack_MakeDamage_sub_443DB0(Enemy_v8, v27);
this_v3->CurrAttack_Is_Lucky_dword70 = 0;
}
else
{
v27 = Enemy;
}
A0_Battle_DrawAction_Play_sub_468570(A0_BattleMgr_dword_699420, -1, 0);
v29 = this_v3->CreatureType_dword34;
if ( v29 < 0 || v29 > 150 )
{
v30 = A0_Empty_dword_691260;
}
else
{
if ( this_v3->Count_dword4C == 1 )
v30 = (*Main_MonsersTable_off_6747B0)[v29].NameSingle_dword14;
else
v30 = (*Main_MonsersTable_off_6747B0)[v29].NameMulti_dword18;
}
A0_Battle_Attacking_Log_Message_sub_469670(
(int)A0_BattleMgr_dword_699420,
(char)v30,
this_v3->Count_dword4C,
v27,
Enemy_v8,
Enemy);
if ( !A0_Battle_ShouldNotRenderBattle_sub_46A080((int)A0_BattleMgr_dword_699420) )
{
if ( !A0_Battle_ShouldNotRenderBattle_sub_46A080((int)A0_BattleMgr_dword_699420) )
{
v31 = (int)this_v3->Shot_Sound_dword17C;
if ( v31 )
A0_Wait_Sample_sub_59A1C0((void *)A0_SoundMgr_dword_699414, *(_DWORD *)(v31 + 28), -1);
}
}
}
}
}