Skip to content

Commit

Permalink
Small Refactor for thing_stats.c (dkfans#3514)
Browse files Browse the repository at this point in the history
and cosmetic changes in config_rules.c
  • Loading branch information
walt253 authored Nov 15, 2024
1 parent c24ccb4 commit 8c2ed4b
Show file tree
Hide file tree
Showing 6 changed files with 445 additions and 470 deletions.
341 changes: 172 additions & 169 deletions src/config_rules.c

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/creature_states_combt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3481,9 +3481,8 @@ long project_creature_attack_target_damage(const struct Thing *firing, const str
shot_model = inst_inf->func_params[0];
}
long damage = project_creature_shot_damage(firing, shot_model);
// Adjust the damage with target creature defense
struct CreatureControl* cctrl = creature_control_get_from_thing(firing);
long dexterity = compute_creature_max_dexterity(crstat->dexterity, cctrl->explevel);
// Adjust the damage with target creature defense.
long dexterity = calculate_correct_creature_dexterity(firing);
damage = project_damage_of_melee_shot(dexterity, damage, target);
return damage;
}
Expand Down
12 changes: 6 additions & 6 deletions src/thing_creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -3003,7 +3003,7 @@ long calculate_melee_damage(struct Thing *creatng, short damage_percent)
{
const struct CreatureControl* cctrl = creature_control_get_from_thing(creatng);
const struct CreatureStats* crstat = creature_stats_get_from_thing(creatng);
long strength = compute_creature_max_strength(crstat->strength, cctrl->explevel);
long strength = calculate_correct_creature_strength(creatng);
long damage = compute_creature_attack_melee_damage(strength, crstat->luck, cctrl->explevel, creatng);
if (damage_percent != 0)
{
Expand All @@ -3021,7 +3021,7 @@ long project_melee_damage(const struct Thing *creatng)
{
const struct CreatureControl* cctrl = creature_control_get_from_thing(creatng);
const struct CreatureStats* crstat = creature_stats_get_from_thing(creatng);
long strength = compute_creature_max_strength(crstat->strength, cctrl->explevel);
long strength = calculate_correct_creature_strength(creatng);
return project_creature_attack_melee_damage(strength, 0, crstat->luck, cctrl->explevel, creatng);
}

Expand Down Expand Up @@ -3052,12 +3052,12 @@ long project_creature_shot_damage(const struct Thing *thing, ThingModel shot_mod
long damage;
if ((shotst->model_flags & ShMF_StrengthBased) != 0 )
{
// Project melee damage
long strength = compute_creature_max_strength(crstat->strength, cctrl->explevel);
// Project melee damage.
long strength = calculate_correct_creature_strength(thing);
damage = project_creature_attack_melee_damage(strength, shotst->damage, crstat->luck, cctrl->explevel, thing);
} else
{
// Project shot damage
// Project shot damage.
damage = project_creature_attack_spell_damage(shotst->damage, crstat->luck, cctrl->explevel, thing);
}
return damage;
Expand Down Expand Up @@ -3158,7 +3158,7 @@ void thing_fire_shot(struct Thing *firing, struct Thing *target, ThingModel shot
}
}

dexterity = compute_creature_max_dexterity(crstat->dexterity, cctrl->explevel);
dexterity = calculate_correct_creature_dexterity(firing);
max_dexterity = crstat->dexterity + ((crstat->dexterity * cctrl->explevel * game.conf.crtr_conf.exp.dexterity_increase_on_exp) / 100);

pos1.x.val += distance_with_angle_to_coord_x((cctrl->shot_shift_x + (cctrl->shot_shift_x * game.conf.crtr_conf.exp.size_increase_on_exp * cctrl->explevel) / 100), firing->move_angle_xy + LbFPMath_PI / 2);
Expand Down
9 changes: 2 additions & 7 deletions src/thing_shots.c
Original file line number Diff line number Diff line change
Expand Up @@ -968,10 +968,7 @@ long get_damage_of_melee_shot(struct Thing *shotng, const struct Thing *target,
{
if (NeverBlock)
return shotng->shot.damage;

const struct CreatureStats* tgcrstat = creature_stats_get_from_thing(target);
const struct CreatureControl* tgcctrl = creature_control_get_from_thing(target);
long crdefense = compute_creature_max_defense(tgcrstat->defense, tgcctrl->explevel);
long crdefense = calculate_correct_creature_defense(target);
long hitchance = ((long)shotng->shot.dexterity - crdefense) / 2;
if (hitchance < -96)
{
Expand All @@ -990,9 +987,7 @@ long get_damage_of_melee_shot(struct Thing *shotng, const struct Thing *target,

long project_damage_of_melee_shot(long shot_dexterity, long shot_damage, const struct Thing *target)
{
const struct CreatureStats* tgcrstat = creature_stats_get_from_thing(target);
const struct CreatureControl* tgcctrl = creature_control_get_from_thing(target);
long crdefense = compute_creature_max_defense(tgcrstat->defense, tgcctrl->explevel);
long crdefense = calculate_correct_creature_defense(target);
long hitchance = (shot_dexterity - crdefense) / 2;
if (hitchance < -96) {
hitchance = -96;
Expand Down
Loading

0 comments on commit 8c2ed4b

Please sign in to comment.