1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-02-01 06:57:25 +00:00
UltimateTrainingModpack/source/training/directional_influence.hpp

39 lines
1.3 KiB
C++
Raw Normal View History

#include "common.hpp"
2019-10-30 07:25:25 +00:00
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
namespace DirectionalInfluence {
float get_float(u64 module_accessor, int var, bool& replace) {
if (var == FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_X ||
var == FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_Y) {
if (is_training_mode() && is_operation_cpu(module_accessor) &&
is_in_hitstun(module_accessor)) {
2019-10-26 21:09:18 +00:00
if (menu.DI_STATE != NONE) {
2019-10-30 07:25:25 +00:00
float angle = (menu.DI_STATE - 1) * M_PI / 4.0;
// Either 0 (right) or PI (left)
if (menu.DI_STATE == DI_RANDOM_IN_AWAY) {
angle = app::sv_math::rand(hash40("fighter"), 2) * M_PI;
}
2019-10-30 07:25:25 +00:00
// If facing left, reverse angle
if (PostureModule::lr(module_accessor) != -1.0) angle -= M_PI;
if (var == FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_X) {
replace = true;
2019-10-30 07:25:25 +00:00
return cos(angle);
}
2019-10-30 07:25:25 +00:00
if (var == FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_Y) {
replace = true;
2019-10-30 07:25:25 +00:00
return sin(angle);
}
}
}
}
replace = false;
return 0;
}
}