Skip to content

Commit

Permalink
Updated damage
Browse files Browse the repository at this point in the history
  • Loading branch information
twist84 committed Dec 8, 2024
1 parent 3992881 commit a619934
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 78 deletions.
2 changes: 1 addition & 1 deletion game/source/motor/motor_system_biped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void __cdecl biped_falling_damage(long biped_index)
{
SET_BIT(biped->biped.flags, 5, true);
s_damage_data damage_data{};
damage_data.material_type = c_global_material_type();
damage_data.global_material_type = c_global_material_type();
damage_data_new(&damage_data, falling_damage.distance_damage.index);
SET_BIT(damage_data.flags, 2, true);
damage_data.damage_reporting_info.type = _damage_reporting_type_falling_damage;
Expand Down
10 changes: 8 additions & 2 deletions game/source/objects/damage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ real __cdecl compute_total_damage(s_damage_data* damage_data, void* damage_effec
{
real result = INVOKE(0x00B4FB10, compute_total_damage, damage_data, damage_effect_definition, damage_definition, object_index, a5);

if (cheat.deathless_player && TEST_BIT(_object_mask_biped, object_get_type(object_index)))
{
if (object_index == player_mapping_get_unit_by_output_user(0))
result = 0.0f;
}

if (cheat.jetpack && TEST_BIT(_object_mask_biped, object_get_type(object_index)))
{
if (damage_data->damage_reporting_info.type == _damage_reporting_type_generic_collision_damage)
Expand Down Expand Up @@ -110,7 +116,7 @@ void __cdecl object_cause_damage(s_damage_data* damage_data, long object_index,
generate_event(_event_warning, "damaging '%s' 0x%08lx with '%s'",
tag_name_strip_path(tag_get_name(object->definition_index)),
object_index,
tag_name_strip_path(tag_get_name(damage_data->damage_effect_definition_index)));
tag_name_strip_path(tag_get_name(damage_data->definition_index)));
}
}

Expand Down Expand Up @@ -176,7 +182,7 @@ void render_debug_object_damage()

csnzappendf(string, sizeof(string), " %s %0.3f|n",
damage_section.name.get_string(),
real(1.0f - real(real(object_damage_section->__unknown2) / 255.0f)));
real(1.0f - real(real(object_damage_section->current_damage) / 255.0f)));
}
}
}
Expand Down
120 changes: 45 additions & 75 deletions game/source/objects/damage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct s_damage_globals
{
struct s_damage_acceleration
{
real_point3d point;
real_point3d epicenter;
real_vector3d acceleration;
long object_index;
short node_index;
Expand All @@ -25,83 +25,60 @@ struct s_damage_globals
};
static_assert(sizeof(s_damage_globals) == 0x810);

struct s_projectile_material_response_definition;
struct c_aoe_damage_batchifier;
struct s_damage_data
{
long damage_effect_definition_index;
long definition_index;
dword_flags flags;
s_damage_owner damage_owner;

long __unknown14;
long __unknown18;

long damage_unique_identifier;
long collision_damage_object_index;
long damage_creating_object_index;
dword melee_damage_unique_identifier;
s_location location;

byte __data22[2];

real_point3d origin;
real_point3d center;
real_vector3d attacker_direction;

real_vector3d __vector48;

real damage_amount_scale;
real_point3d epicenter;
real_vector3d direction;
real_vector3d aoe_force_direction;
real scale;
real shake_scale;
real damage_amount;
real damage_aoe_size;

real __unknown64;
real __unknown68;
bool __unknown6C;
bool __unknown6D;
byte __data6E[0x2];
real_vector3d __vector70;
long __unknown7C;

real vitality;
c_global_material_type material_type;

short __unknown86;
byte __data88[0x4];

real multiplier;
real area_of_effect_distance;
real area_of_effect_intensity;
real area_of_effect_unknown68;
bool area_of_effect_spike;
bool area_of_effect_emp;
real_vector3d area_of_effect_forward;
long area_of_effect_spike_object;
real material_effect_scale;
c_global_material_type global_material_type;
short shot_id;
s_projectile_material_response_definition const* material_response;
s_damage_reporting_info damage_reporting_info;
c_aoe_damage_batchifier* aoe_damage_batchifier;
long damage_material_index; // model_definition->materials[damage_material_index]
c_aoe_damage_batchifier* optional_batchifier;
long secret_melee_material_index;
};
static_assert(sizeof(s_damage_data) == 0x98);

struct s_model_material;
struct s_model_damage_info;
struct s_damage_response_data
{
byte __data0[0x4];

// some struct that either starts with `s_damage_response_data` or has it as the first member variable
void* __unknown4;

s_model_material const* model_material;
s_model_damage_info const* damage_info;
short body_part;

byte __dataA[0x6];

long region_index;
long node_index;

real __unknown14;
real __unknown18;

real total_damage;
real available_damage;
real shield_damage;

real __unknown20;

real section_damage;
real body_damage;

// passed to `object_damage_constraints_old`
word_flags __unknown28; // destroyed_constraints?
word_flags __unknown2A; // loosened_constraints?

dword_flags flags;
word destroyed_constraints;
word loosened_constraints;
word_flags being_damaged_flags;
long special_death_type;

bool __unknown34;
byte __data35[0x3]; // padding?
bool supress_damage_effects;
};
static_assert(sizeof(s_damage_response_data) == 0x38);

Expand All @@ -113,34 +90,29 @@ struct s_damage_aftermath_result_data
s_damage_owner damage_owner;
real_vector3d direction;
bool epicenter_valid;

byte __data25[0x3]; // padding?

real_vector3d epicenter_direction_vector;
real_vector3d epicenter;
real shake;
real shake_scale;
long body_part;
short node_index;

byte __data42[0x2];

real body_damage;
real shield_damage;

real __unknown4C;

real area_of_effect_distance;
long ping_type;
long special_death_type;
};
static_assert(sizeof(s_damage_aftermath_result_data) == 0x58);

struct object_damage_section
{
short __unknown0;
short __unknown2;
byte __data4[0x8];
word_flags response_flags;
byte current_damage;
byte timed_response_damage_info;
word timed_response_index : 4;
word timed_response_timer : 12;
short damage_section_recharge_ticks;
};
static_assert(sizeof(object_damage_section) == 0xC);
static_assert(sizeof(object_damage_section) == 0x8);

extern bool debug_damage_radius;
extern bool debug_damage_this_event;
Expand All @@ -149,8 +121,6 @@ extern bool debug_player_damage;
extern bool debug_damage;
extern long global_debug_damage_object_index;

struct s_model_damage_info;

extern real __cdecl compute_total_damage(s_damage_data* damage_data, void* damage_effect_definition, void const* damage_definition, long object_index, bool* a5);
extern void __cdecl damage_acceleration_apply(s_damage_globals::s_damage_acceleration const* damage_acceleration);
extern void __cdecl damage_acceleration_queue_begin();
Expand Down

0 comments on commit a619934

Please sign in to comment.