Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum class weapon_type_t: uint8_t
- {
- bow = 4,
- gun = 5,
- staff = 7,
- };
- enum class action_type_t: uint8_t
- {
- physical_attack = 2,
- magical_attack = 3,
- healing_spell = 4,
- };
- struct actiondef_t
- {
- [ 0x0] uint16_t us_id;
- [ 0x4] int16_t is_power;
- [ 0x9a] int8_t aic_9a[];
- [ 0xa0] uint8_t uc_element;
- [ 0xa1] action_type_t action_type;
- [ 0xa7] uint8_t auc_a7[];
- [ 0xac]
- };
- struct gamecell_t
- {
- [ 0x4] uint8_t uc_atk_p50_count;
- [ 0x5] uint8_t uc_atk_m50_count;
- [ 0x6] uint8_t uc_def_p50_count;
- [ 0x7] uint8_t uc_def_m50_count;
- [ 0xb] uint8_t uc_enemy_p50_count;
- [ 0xc] uint8_t uc_enemy_t3_count;
- [ 0x20]
- };
- struct gameunit_t
- {
- [0x2ac] int16_t ais_2ac[];
- [0x400] bool b_damage_resistant;
- [0x4a4] uint16_t aus_learned_action_id[];
- [0x564] int8_t aic_learned_action_level[];
- [0x5c4] int32_t i_stat_hp;
- [0x5c8] int32_t i_stat_sp;
- [0x5cc] int32_t i_stat_hpmax;
- [0x5d0] int32_t i_stat_spmax;
- [0x5d4] int32_t i_stat_atk;
- [0x5d8] int32_t i_stat_def;
- [0x5dc] int32_t i_stat_int;
- [0x5e0] int32_t i_stat_spd;
- [0x5e4] int32_t i_stat_hit;
- [0x5e8] int32_t i_stat_res;
- [0x64e] uint8_t ic_weapon_mastery_staff;
- [0x660] int16_t is_660;
- [0x664] int32_t i_classindex;
- [0x670] uint16_t us_670;
- [0x676] int8_t aic_element_resistance[];
- [0x681] int8_t ic_681;
- [0x689] weapon_type_t equip_weapon_type;
- [0x69f] bool b_magic_resistant;
- };
- struct actioninfo_t
- {
- [0x22e] uint16_t us_22e;
- [0x26e] weapon_type_t weapon_type;
- [0x284] gameunit_t* gameunit;
- [0x3ee] uint16_t us_location;
- [0x401] bool b_is_enemy;
- };
- [0x532bf0] uint16_t g_action_power_factor[] = {
- [ 0] = 90,
- [ 1] = 100,
- [ 2] = 103,
- [ 3] = 106,
- [ 4] = 109,
- [ 5] = 112,
- [ 6] = 115,
- [ 7] = 118,
- [ 8] = 121,
- [ 9] = 124,
- [ 10] = 127,
- [ 11] = 130,
- [ 12] = 133,
- [ 13] = 136,
- [ 14] = 139,
- [ 15] = 142,
- [ 16] = 145,
- [ 17] = 148,
- [ 18] = 151,
- [ 19] = 154,
- [ 20] = 157,
- [ 21] = 160,
- [ 22] = 162,
- [ 23] = 164,
- [ 24] = 166,
- [ 25] = 168,
- [ 26] = 170,
- [ 27] = 172,
- [ 28] = 174,
- [ 29] = 176,
- [ 30] = 178,
- [ 31] = 180,
- [ 32] = 182,
- [ 33] = 184,
- [ 34] = 186,
- [ 35] = 188,
- [ 36] = 190,
- [ 37] = 192,
- [ 38] = 194,
- [ 39] = 196,
- [ 40] = 198,
- [ 41] = 200,
- [ 42] = 202,
- [ 43] = 204,
- [ 44] = 206,
- [ 45] = 208,
- [ 46] = 210,
- [ 47] = 212,
- [ 48] = 214,
- [ 49] = 216,
- [ 50] = 218,
- [ 51] = 220,
- [ 52] = 222,
- [ 53] = 224,
- [ 54] = 226,
- [ 55] = 228,
- [ 56] = 230,
- [ 57] = 232,
- [ 58] = 234,
- [ 59] = 236,
- [ 60] = 238,
- [ 61] = 240,
- [ 62] = 242,
- [ 63] = 244,
- [ 64] = 246,
- [ 65] = 248,
- [ 66] = 250,
- [ 67] = 252,
- [ 68] = 254,
- [ 69] = 256,
- [ 70] = 258,
- [ 71] = 260,
- [ 72] = 262,
- [ 73] = 264,
- [ 74] = 266,
- [ 75] = 268,
- [ 76] = 270,
- [ 77] = 272,
- [ 78] = 274,
- [ 79] = 276,
- [ 80] = 278,
- [ 81] = 280,
- [ 82] = 282,
- [ 83] = 284,
- [ 84] = 286,
- [ 85] = 288,
- [ 86] = 290,
- [ 87] = 292,
- [ 88] = 294,
- [ 89] = 296,
- [ 90] = 298,
- [ 91] = 300,
- [ 92] = 305,
- [ 93] = 310,
- [ 94] = 315,
- [ 95] = 320,
- [ 96] = 325,
- [ 97] = 330,
- [ 98] = 340,
- [ 99] = 350,
- [100] = 400,
- };
- [0x66402c] actiondef_t* g_actionlist_ptr;
- [0x664030] int32_t g_actionlist_length;
- [0x6640b0] gamecell_t g_gamefield[];
- [0x65db3a] uint8_t g_uc_65db3a;
- [0x6d4ac0] uint8_t g_auc_6d4ac0[];
- [0x6e57a8] uint8_t g_uc_6e57a8;
- bool f_444e10( uint8_t arg_1, uint8_t arg_2 )
- {
- if( g_uc_65db3a != 5 )
- {
- return false;
- }
- if( g_uc_6e57a8 == 0 )
- {
- return false;
- }
- if( arg_2 != 0 && arg_2 != 1 )
- {
- return false;
- }
- for( int i = 0; i < 5; ++i )
- {
- if( g_auc_6d4ac0[arg_2*5 + i] == arg_1 )
- {
- return true;
- }
- }
- return false;
- }
- int saturated_curve( int64_t x )
- {
- if( x <= 500 )
- {
- return x;
- }
- else if( x <= 1000 )
- {
- return ( x - 500 ) / 2 + 500;
- }
- else
- {
- return ( x - 1000 ) / 5 + 750;
- }
- }
- void f_46fdc0( int32_t arg_1, void* arg_2,
- actioninfo_t* source_info, actioninfo_t* target_info )
- {
- gameunit_t* gameunit_source = source_info->gameunit;
- gameunit_t* gameunit_target = target_info->gameunit;
- uint32_t u_combo_counter = uint16_t( arg_2[0x170] );
- int32_t i_combo_bonus;
- if( source_info->b_is_enemy )
- {
- i_combo_bonus = u_combo_counter * 15;
- }
- else
- {
- i_combo_bonus = u_combo_counter * 10;
- }
- int32_t i_ebp_52 = ( gameunit_target->is_660 - gameunit_source->is_660 ) * 2;
- if( i_ebp_52 < 0 )
- {
- i_ebp_52 = 0;
- }
- else if( i_ebp_52 > 90 )
- {
- i_ebp_52 = 90;
- }
- actiondef_t* actiondef;
- for( int i = 0; i < g_actionlist_length; ++i )
- {
- if( g_actionlist_ptr[i].us_id == uint16_t( arg_2[0x158] ) )
- {
- actiondef = &g_actionlist_ptr[i];
- goto cycle_break_fe89;
- }
- }
- actiondef = 0;
- cycle_break_fe89:
- int32_t i_action_level;
- for( int i = 0; i < gameunit_source->ic_681; ++i )
- {
- if( gameunit_source->aus_learned_action_id[i] == uint16_t( arg_2[0x158] ) )
- {
- i_action_level = gameunit_source->aic_learned_action_level[i];
- goto cycle_break_feb9;
- }
- }
- i_action_level = 0;
- cycle_break_feb9:
- uint32_t u_action_power_factor = g_action_power_factor[i_action_level];
- int64_t il_defense_bonus = 0;
- int64_t il_attack_bonus = 0;
- if( u_combo_counter > 0 )
- {
- il_attack_bonus = i_combo_bonus;
- il_defense_bonus = -i_combo_bonus;
- }
- int32_t i_source_location = source_info->us_location;
- int32_t i_target_location = target_info->us_location;
- il_attack_bonus += g_gamefield[i_source_location]->uc_atk_p50_count * 50 -
- g_gamefield[i_source_location]->uc_atk_m50_count * 50;
- il_defense_bonus += g_gamefield[i_target_location]->uc_def_p50_count * 50 -
- g_gamefield[i_target_location]->uc_def_m50_count * 50;
- if( source_info->b_is_enemy )
- {
- int32_t t3_boost =
- g_gamefield[i_source_location]->uc_enemy_t3_count * 300 - 100;
- if( t3_boost < 0 )
- {
- t3_boost = 0;
- }
- int64_t p50_boost =
- g_gamefield[i_source_location]->uc_enemy_p50_count * 50;
- il_attack_bonus += p50_boost + t3_boost;
- }
- if( target_info->b_is_enemy )
- {
- int32_t t3_boost =
- g_gamefield[i_target_location]->uc_enemy_t3_count * 300 - 100;
- if( t3_boost < 0 )
- {
- t3_boost = 0;
- }
- int64_t p50_boost =
- g_gamefield[i_target_location]->uc_enemy_p50_count * 50;
- il_defense_bonus += p50_boost + t3_boost;
- }
- if( gameunit_target->i_classindex / 10 == 106 )
- {
- int32_t hit_value = gameunit_source->i_stat_hit * random_range( 70, 100 );
- int32_t spd_value = gameunit_target->i_stat_spd * random_range( 0, 30 );
- if( spd_value > hit_value )
- {
- arg_2[arg_1*4+0x4] = 0;
- uint16_t( arg_2[arg_1*2+0x114] ) = 0;
- return;
- }
- }
- for( int edi_index = 0; edi_index < 5; ++edi_index )
- {
- uint32_t u_ebp_44c = actiondef->auc_a7[edi_index];
- switch( u_ebp_44c )
- {
- case 1:
- {
- il_attack_bonus += actiondef->aic_9a[edi_index] * 10;
- break;
- }
- case 2:
- {
- il_defense_bonus = actiondef->aic_9a[edi_index] * 10;
- break;
- }
- case 11:
- case 12:
- case 13:
- case 14:
- {
- uint32_t u_index = u_ebp_44c - 11;
- uint16_t us_mask = 1 << ( u_index + 6 );
- if( ( gameunit_target->us_670 & us_mask == 0 &&
- i_ebp_52 <= random_range( 0, 99 ) ) ||
- actiondef->aic_9a[edi_index] >= 0 )
- {
- int8_t( arg_2[0x17d + arg_1*16 + u_index + 7] ) =
- actiondef->aic_9a[edi_index];
- }
- break;
- }
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- {
- uint32_t u_index = u_ebp_44c - 21;
- uint16_t us_mask = 1 << u_index;
- if( gameunit_target->us_670 & us_mask != 0 )
- {
- break;
- }
- int32_t i_diff_660 =
- ( gameunit_target->is_660 - gameunit_source->is_660 ) / 2;
- if( i_diff_660 < 0 )
- {
- i_diff_660 = 0;
- }
- int32_t i_ebp_48c =
- random_range( 0, i_action_level + actiondef->aic_9a[edi_index] ) -
- random_range( 0, i_diff_660 + gameunit_target->ais_2ac[u_index] );
- if( i_ebp_48c > 100 )
- {
- i_ebp_48c = 100;
- }
- else if( i_ebp_48c <= 0 )
- {
- break;
- }
- int8_t( arg_2[0x17d + arg_1*16 + u_index] ) = i_ebp_48c;
- break;
- }
- case 101:
- {
- memset( arg_2 + 0x17d + arg_1*16, 0x88, 5 );
- break;
- }
- case 102:
- {
- al = actiondef->aic_9a[edi_index];
- int8_t( arg_2[0x37c] ) = actiondef->aic_9a[edi_index];
- break;
- }
- case 104:
- {
- int16_t( arg_2[0x178] ) = actiondef->aic_9a[edi_index];
- break;
- }
- }
- }
- int64_t il_attack_power;
- int32_t i_defense_power;
- switch( actiondef->action_type )
- {
- case action_type_t::physical_attack:
- {
- uint16_t( arg_2[arg_1*2+0x114] ) = 1;
- int32_t i_660_value = gameunit_source->is_660 + 100;
- if( i_660_value <= 25 )
- {
- i_660_value = 25;
- }
- else
- {
- i_660_value = saturated_curve( i_660_value );
- }
- int64_t il_effective_stat_bonus =
- actiondef->is_power * i_660_value / 100;
- switch( source_info->weapon_type )
- {
- case weapon_type_t::bow:
- {
- int64_t il_effective_stat =
- gameunit_source->i_stat_hit + gameunit_source->i_stat_atk +
- il_effective_stat_bonus * 2;
- il_attack_power =
- il_effective_stat * random_range( 90, 110 ) / 40;
- i_defense_power =
- gameunit_target->i_stat_def * random_range( 45, 60 ) / 20;
- break;
- }
- case weapon_type_t::gun:
- {
- int64_t il_effective_stat =
- gameunit_source->i_stat_hit + il_effective_stat_bonus;
- il_attack_power =
- il_effective_stat * random_range( 90, 110 ) / 27;
- i_defense_power =
- gameunit_target->i_stat_def * random_range( 45, 60 ) / 27;
- break;
- }
- default:
- {
- int64_t il_effective_stat =
- gameunit_source->i_stat_atk + il_effective_stat_bonus;
- il_attack_power =
- il_effective_stat * random_range( 90, 110 ) / 20;
- i_defense_power =
- gameunit_target->i_stat_def * random_range( 45, 60 ) / 20;
- break;
- }
- }
- break;
- }
- case action_type_t::magical_attack:
- {
- int32_t i_660_value = gameunit_source->is_660 + 100;
- if( i_660_value <= 25 )
- {
- i_660_value = 25;
- }
- else
- {
- i_660_value = saturated_curve( i_660_value );
- }
- int64_t il_effective_stat_bonus =
- actiondef->is_power * i_660_value / 100;
- int64_t il_effective_stat =
- gameunit_source->i_stat_int + il_effective_stat_bonus;
- il_attack_power =
- il_effective_stat * random_range( 90, 110 ) / 30;
- i_defense_power =
- gameunit_target->i_stat_res * random_range( 45, 60 ) / 30;
- if( gameunit_target->b_magic_resistant )
- {
- il_attack_power /= 2;
- }
- if( gameunit_source->equip_weapon_type == weapon_type_t::staff )
- {
- int32_t i_wml_bonus = gameunit_source->ic_weapon_mastery_staff * 3;
- if( i_wml_bonus > 100 )
- {
- i_wml_bonus = 100;
- }
- il_attack_bonus += i_wml_bonus;
- }
- break;
- }
- case action_type_t::healing_spell:
- {
- int16_t( arg_2[arg_1*2+0x114] ) = 1;
- int32_t i_amount = gameunit_source->i_stat_int + 100;
- if( i_amount <= 25 )
- {
- i_amount = 25;
- }
- else
- {
- i_amount = saturated_curve( i_amount );
- }
- int64_t il_base_heal_amount =
- i_amount * actiondef->is_power / 100;
- if( gameunit_source->equip_weapon_type == weapon_type_t::staff )
- {
- int32_t i_wml_bonus = gameunit_source->ic_weapon_mastery_staff * 3;
- if( i_wml_bonus > 100 )
- {
- i_wml_bonus = 100;
- }
- il_attack_bonus += edx:eax;
- }
- if( il_attack_bonus > 2000 )
- {
- il_attack_bonus = 2000;
- }
- else if( il_attack_bonus < -100 )
- {
- il_attack_bonus = -100;
- }
- int64_t il_damage_value =
- ( il_attack_bonus + 100 ) * il_base_heal_amount / -100;
- int32_t( arg_2[arg_1*4+0x4] ) = il_damage_value;
- return;
- }
- default:
- {
- int16_t( arg_2[arg_1*2+0x114] ) = 1;
- arg_2[arg_1*4+0x4] = 0;
- return;
- }
- }
- if( il_attack_bonus > 2000 )
- {
- il_attack_bonus = 2000;
- }
- else if( il_attack_bonus <= -100 )
- {
- il_attack_bonus = -100;
- }
- if( il_defense_bonus > 2000 )
- {
- il_defense_bonus = 2000;
- }
- else if( il_defense_bonus <= -100 )
- {
- il_defense_bonus = -100;
- }
- int64_t il_defense_value =
- ( il_defense_bonus + 100 ) * i_defense_power / 1000;
- int64_t il_attack_value =
- ( il_attack_bonus + 100 ) * i_attack_power / 1000;
- int64_t il_damage_value = il_attack_value - il_defense_value;
- if( target_info->b_damage_resistant )
- {
- il_damage_value /= 2;
- }
- il_damage_value = il_damage_value * u_action_power_factor / 100;
- if( actiondef->uc_element >= 1 && actiondef->uc_element <= 3 )
- {
- int32_t i_factor =
- 100 - gameunit_target->aic_element_resistance[actiondef->uc_element];
- if( i_factor < 10 )
- {
- i_factor = 10;
- }
- else if( i_factor > 200 )
- {
- i_factor = 200;
- }
- il_damage_value = il_damage_value * i_factor / 100;
- }
- int32_t i_damage = il_damage_value;
- if( i_damage < 0 )
- {
- i_damage = 0;
- u_action_power_factor = 0;
- }
- if( target_info->us_22e == 3200 ||
- f_444e10( 2, target_info->b_is_enemy ) != 0 )
- {
- i_damage = 0;
- u_action_power_factor = 0;
- }
- int32_t( arg_2[arg_1*4+0x4] ) = i_damage;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement