mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Changed AttackSubType enum "GUNS" to "RANGED"
* to be in line with define_extra.h, the naming is from RE/CE. Minor textual edits to code.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This script re-implements damage calculation of the original game.
|
This script reimplements the combat damage calculation of the original game.
|
||||||
Use it to implement your own damage formula!
|
Use this to implement your own damage formula!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../sfall/define_lite.h"
|
#include "../sfall/define_lite.h"
|
||||||
@@ -34,13 +34,13 @@ procedure start begin
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
/**
|
/*
|
||||||
HOOK_COMBATDAMAGE
|
HOOK_COMBATDAMAGE
|
||||||
|
|
||||||
Runs when:
|
|
||||||
|
|
||||||
Game calculates how much damage each target will get. This includes primary target as well as all extras (explosions and bursts). This happens BEFORE the actual attack animation.
|
Runs when:
|
||||||
AI decides whether it is safe to use area attack (burst, grenades), if he might hit friendlies.
|
1) Game calculates how much damage each target will get. This includes primary target as well as all extras (explosions and bursts). This happens BEFORE the actual attack animation.
|
||||||
|
2) AI decides whether it is safe to use area attack (burst, grenades), if he might hit friendlies.
|
||||||
|
|
||||||
Does not run for misses, or non-combat damage like dynamite explosions.
|
Does not run for misses, or non-combat damage like dynamite explosions.
|
||||||
|
|
||||||
Critter arg0 - The target
|
Critter arg0 - The target
|
||||||
@@ -49,10 +49,10 @@ end
|
|||||||
int arg3 - The amount of damage to the attacker
|
int arg3 - The amount of damage to the attacker
|
||||||
int arg4 - The special effect flags for the target (use bwand DAM_* to check specific flags)
|
int arg4 - The special effect flags for the target (use bwand DAM_* to check specific flags)
|
||||||
int arg5 - The special effect flags for the attacker (use bwand DAM_* to check specific flags)
|
int arg5 - The special effect flags for the attacker (use bwand DAM_* to check specific flags)
|
||||||
int arg6 - The weapon used in the attack
|
Item arg6 - The weapon used in the attack
|
||||||
int arg7 - The bodypart that was struck
|
int arg7 - The bodypart that was struck
|
||||||
int arg8 - Damage Multiplier (this is divided by 2, so a value of 3 does 1.5x damage, and 8 does 4x damage. Usually it's 2; for critical hits, the value is taken from the critical table; with Silent Death perk and the corresponding attack conditions, the value will be doubled)
|
int arg8 - Damage Multiplier (this is divided by 2, so a value of 3 does 1.5x damage, and 8 does 4x damage. Usually it's 2; for critical hits, the value is taken from the critical table; with Silent Death perk and the corresponding attack conditions, the value will be doubled)
|
||||||
int arg9 - Number of bullets actually hit the target (1 for melee attacks)
|
int arg9 - Number of bullets actually hit the target (1 for melee attacks)
|
||||||
int arg10 - The amount of knockback to the target
|
int arg10 - The amount of knockback to the target
|
||||||
int arg11 - Attack Type (see ATKTYPE_* constants)
|
int arg11 - Attack Type (see ATKTYPE_* constants)
|
||||||
mixed arg12 - computed attack data (see C_ATTACK_* for offsets and use get/set_object_data functions to get/set the data)
|
mixed arg12 - computed attack data (see C_ATTACK_* for offsets and use get/set_object_data functions to get/set the data)
|
||||||
@@ -62,7 +62,7 @@ end
|
|||||||
int ret2 - The special effect flags for the target
|
int ret2 - The special effect flags for the target
|
||||||
int ret3 - The special effect flags for the attacker
|
int ret3 - The special effect flags for the attacker
|
||||||
int ret4 - The amount of knockback to the target
|
int ret4 - The amount of knockback to the target
|
||||||
*/
|
*/
|
||||||
procedure combatdamage_handler begin
|
procedure combatdamage_handler begin
|
||||||
variable dmg_type, weapon_perk, dmg_thresh, dmg_resist, weapon_subtype, bonus_ranged, difficulty, i, dmg_mult, dmg_div, damage;
|
variable dmg_type, weapon_perk, dmg_thresh, dmg_resist, weapon_subtype, bonus_ranged, difficulty, i, dmg_mult, dmg_div, damage;
|
||||||
variable target, flags, knockback, amount;
|
variable target, flags, knockback, amount;
|
||||||
@@ -82,7 +82,7 @@ procedure combatdamage_handler begin
|
|||||||
hit_mode := get_sfall_arg;
|
hit_mode := get_sfall_arg;
|
||||||
|
|
||||||
if (ctdSource != item_damage_attacker or weapon != item_damage_weapon) then begin
|
if (ctdSource != item_damage_attacker or weapon != item_damage_weapon) then begin
|
||||||
debug_msg("! ERROR ! compute_damage: Expected attacker and weapon differs!");
|
debug_msg("! ERROR ! compute_damage: Expected attacker or weapon differs!");
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ procedure combatdamage_handler begin
|
|||||||
set_sfall_return(flagsTarget);
|
set_sfall_return(flagsTarget);
|
||||||
set_sfall_return(flagsSource);
|
set_sfall_return(flagsSource);
|
||||||
set_sfall_return(amountKnockback);
|
set_sfall_return(amountKnockback);
|
||||||
|
|
||||||
set_sfall_arg(2, amountTarget);
|
set_sfall_arg(2, amountTarget);
|
||||||
set_sfall_arg(3, amountSource);
|
set_sfall_arg(3, amountSource);
|
||||||
set_sfall_arg(4, flagsTarget);
|
set_sfall_arg(4, flagsTarget);
|
||||||
@@ -211,7 +211,6 @@ procedure combatdamage_handler begin
|
|||||||
set_sfall_arg(10, amountKnockback);
|
set_sfall_arg(10, amountKnockback);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
procedure calc_damage_YAAM(variable weapon, variable rounds, variable armorDT, variable armorDR, variable bonusRangedDamage, variable multiplyDamage, variable difficulty) begin
|
procedure calc_damage_YAAM(variable weapon, variable rounds, variable armorDT, variable armorDR, variable bonusRangedDamage, variable multiplyDamage, variable difficulty) begin
|
||||||
variable accumulatedDamage, ammoDiv, ammoMult, ammoDT, calcDT, _calcDT, calcDR, i, rawDamage, resistedDamage;
|
variable accumulatedDamage, ammoDiv, ammoMult, ammoDT, calcDT, _calcDT, calcDR, i, rawDamage, resistedDamage;
|
||||||
if (rounds <= 0) then begin
|
if (rounds <= 0) then begin
|
||||||
@@ -225,7 +224,7 @@ procedure calc_damage_YAAM(variable weapon, variable rounds, variable armorDT, v
|
|||||||
multiplyDamage *= ammoMult;
|
multiplyDamage *= ammoMult;
|
||||||
|
|
||||||
// Retrieve ammo DT (well, it's really Retrieve ammo DR, but since we're treating ammo DR as ammo DT...)
|
// Retrieve ammo DT (well, it's really Retrieve ammo DR, but since we're treating ammo DR as ammo DT...)
|
||||||
ammoDT := get_ammo_value(weapon, PROTO_AM_DR_MOD);
|
ammoDT := get_ammo_value(weapon, PROTO_AM_DR_MOD);
|
||||||
|
|
||||||
calcDT := armorDT - ammoDT;
|
calcDT := armorDT - ammoDT;
|
||||||
_calcDT := calcDT;
|
_calcDT := calcDT;
|
||||||
@@ -233,8 +232,8 @@ procedure calc_damage_YAAM(variable weapon, variable rounds, variable armorDT, v
|
|||||||
if (calcDT >= 0) then begin
|
if (calcDT >= 0) then begin
|
||||||
_calcDT := 0;
|
_calcDT := 0;
|
||||||
end else begin
|
end else begin
|
||||||
// (note that this should be a negative value)
|
// note that this should be a negative value
|
||||||
_calcDT *= 10;
|
_calcDT *= 10;
|
||||||
calcDT := 0;
|
calcDT := 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -246,7 +245,7 @@ procedure calc_damage_YAAM(variable weapon, variable rounds, variable armorDT, v
|
|||||||
return 0;
|
return 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
display_msg("YAAM: AmmoDT="+ammoDT+", DT="+calcDT+"/"+armorDT+", DR="+calcDR+"/"+armorDR);
|
display_msg("YAAM: AmmoDT=" + ammoDT + ", DT=" + calcDT + "/" + armorDT + ", DR=" + calcDR + "/" + armorDR);
|
||||||
// Start of damage calculation loop
|
// Start of damage calculation loop
|
||||||
for (i := 0; i < rounds; i++) begin
|
for (i := 0; i < rounds; i++) begin
|
||||||
rawDamage = random(item_damage_min, item_damage_max);
|
rawDamage = random(item_damage_min, item_damage_max);
|
||||||
@@ -269,7 +268,7 @@ procedure calc_damage_YAAM(variable weapon, variable rounds, variable armorDT, v
|
|||||||
rawDamage -= resistedDamage;
|
rawDamage -= resistedDamage;
|
||||||
|
|
||||||
if (rawDamage > 0) then begin
|
if (rawDamage > 0) then begin
|
||||||
display_msg("YAAM: Bullet "+i+" dmg="+rawDamage);
|
display_msg("YAAM: Bullet " + i + " dmg=" + rawDamage);
|
||||||
accumulatedDamage += rawDamage;
|
accumulatedDamage += rawDamage;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -278,6 +277,7 @@ end
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
HOOK_ITEMDAMAGE
|
HOOK_ITEMDAMAGE
|
||||||
|
|
||||||
Runs when retrieving the damage rating of the player's used weapon. (Which may be their fists.)
|
Runs when retrieving the damage rating of the player's used weapon. (Which may be their fists.)
|
||||||
|
|
||||||
int arg0 - The default min damage
|
int arg0 - The default min damage
|
||||||
@@ -306,7 +306,7 @@ procedure item_w_subtype(variable weapon, variable hit_mode) begin
|
|||||||
|
|
||||||
if weapon and (hit_mode <= ATKTYPE_RWEP2) then begin
|
if weapon and (hit_mode <= ATKTYPE_RWEP2) then begin
|
||||||
attack_mode := weapon_attack_mode(obj_pid(weapon), hit_mode);
|
attack_mode := weapon_attack_mode(obj_pid(weapon), hit_mode);
|
||||||
|
|
||||||
if (attack_mode >= ATTACK_MODE_SINGLE) then
|
if (attack_mode >= ATTACK_MODE_SINGLE) then
|
||||||
type := WEAPON_TYPE_RANGED;
|
type := WEAPON_TYPE_RANGED;
|
||||||
else if (attack_mode == ATTACK_MODE_THROW) then
|
else if (attack_mode == ATTACK_MODE_THROW) then
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
#define WEAPON_2HAND 0x00000200 // 2Hnd (weapon is two-handed)
|
#define WEAPON_2HAND 0x00000200 // 2Hnd (weapon is two-handed)
|
||||||
#define WEAPON_ENERGY 0x00000400 // Energy Weapon (forces weapon to use Energy Weapons skill) [sfall 4.2/3.8.20]
|
#define WEAPON_ENERGY 0x00000400 // Energy Weapon (forces weapon to use Energy Weapons skill) [sfall 4.2/3.8.20]
|
||||||
|
|
||||||
// The attack types returned by get_attack_type or as fifth argument of HOOK_ITEMDAMAGE
|
// The attack types returned by get_attack_type or as the fifth argument of HOOK_ITEMDAMAGE
|
||||||
#define ATKTYPE_LWEP1 (0)
|
#define ATKTYPE_LWEP1 (0)
|
||||||
#define ATKTYPE_LWEP2 (1)
|
#define ATKTYPE_LWEP2 (1)
|
||||||
#define ATKTYPE_RWEP1 (2)
|
#define ATKTYPE_RWEP1 (2)
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
#define MSGBOX_YESNO (0x10) // use YES/NO buttons instead of DONE
|
#define MSGBOX_YESNO (0x10) // use YES/NO buttons instead of DONE
|
||||||
#define MSGBOX_CLEAN (0x20) // no buttons
|
#define MSGBOX_CLEAN (0x20) // no buttons
|
||||||
|
|
||||||
// Some possible defines for the 4th argument to HOOK_REMOVEINVOBJ
|
// Some possible defines for the fourth argument of HOOK_REMOVEINVENOBJ
|
||||||
#define RMOBJ_ITEM_REMOVED_INVEN 4831349 // removing or destroying an item (obj_remove_from_inven_)
|
#define RMOBJ_ITEM_REMOVED_INVEN 4831349 // removing or destroying an item (obj_remove_from_inven_)
|
||||||
#define RMOBJ_ITEM_REMOVED 4548572 // (op_rm_obj_from_inven_)
|
#define RMOBJ_ITEM_REMOVED 4548572 // (op_rm_obj_from_inven_)
|
||||||
#define RMOBJ_ITEM_REMOVED_MULTI 4563866 // (op_rm_mult_objs_from_inven_)
|
#define RMOBJ_ITEM_REMOVED_MULTI 4563866 // (op_rm_mult_objs_from_inven_)
|
||||||
@@ -507,8 +507,8 @@
|
|||||||
#define CRITICAL_VALUE_STAT_CHECK (2) // This makes a check against a (SPECIAL) stat. Values of 2 (endurance), 5 (agility), and 6 (luck) are used, but other stats will probably work as well. A value of -1 indicates that no check is to be made.
|
#define CRITICAL_VALUE_STAT_CHECK (2) // This makes a check against a (SPECIAL) stat. Values of 2 (endurance), 5 (agility), and 6 (luck) are used, but other stats will probably work as well. A value of -1 indicates that no check is to be made.
|
||||||
#define CRITICAL_VALUE_STAT_MOD (3) // Affects the outcome of the stat check, if one is made. Positive values make it easier to pass the check, and negative ones make it harder.
|
#define CRITICAL_VALUE_STAT_MOD (3) // Affects the outcome of the stat check, if one is made. Positive values make it easier to pass the check, and negative ones make it harder.
|
||||||
#define CRITICAL_VALUE_FAIL_EFFECT (4) // Another bit field, using the same values as EFFECTS. If the stat check is failed, these are applied in addition to the earlier ones.
|
#define CRITICAL_VALUE_FAIL_EFFECT (4) // Another bit field, using the same values as EFFECTS. If the stat check is failed, these are applied in addition to the earlier ones.
|
||||||
#define CRITICAL_VALUE_MSG (5) // The message to show when this critical occurs, taken from combat.msg .
|
#define CRITICAL_VALUE_MSG (5) // The message to show when this critical occurs, taken from combat.msg.
|
||||||
#define CRITICAL_VALUE_FAIL_MSG (6) // Shown instead of Message if the stat check is failed.
|
#define CRITICAL_VALUE_FAIL_MSG (6) // This is shown instead of Message if the stat check fails.
|
||||||
|
|
||||||
|
|
||||||
/* Playback mode defines for the soundplay function */
|
/* Playback mode defines for the soundplay function */
|
||||||
|
|||||||
@@ -273,7 +273,7 @@
|
|||||||
|
|
||||||
#define weapon_attack_mode1(pid) (get_proto_data(pid, PROTO_FLAG_EXT) bwand 0x0000000F)
|
#define weapon_attack_mode1(pid) (get_proto_data(pid, PROTO_FLAG_EXT) bwand 0x0000000F)
|
||||||
#define weapon_attack_mode2(pid) ((get_proto_data(pid, PROTO_FLAG_EXT) bwand 0x000000F0) / 0x10)
|
#define weapon_attack_mode2(pid) ((get_proto_data(pid, PROTO_FLAG_EXT) bwand 0x000000F0) / 0x10)
|
||||||
#define weapon_attack_mode(pid, attackType) (weapon_attack_mode1(pid) if attackType == ATKTYPE_LWEP1 or attackType == ATKTYPE_RWEP1 else weapon_attack_mode2(pid))
|
#define weapon_attack_mode(pid, attackType) (weapon_attack_mode1(pid) if (attackType == ATKTYPE_LWEP1 or attackType == ATKTYPE_RWEP1) else weapon_attack_mode2(pid))
|
||||||
|
|
||||||
|
|
||||||
/* SFALL_FUNCX MACROS */
|
/* SFALL_FUNCX MACROS */
|
||||||
|
|||||||
@@ -206,9 +206,9 @@ fo::AttackSubType GetWeaponType(DWORD weaponFlag) {
|
|||||||
fo::AttackSubType::MELEE,
|
fo::AttackSubType::MELEE,
|
||||||
fo::AttackSubType::MELEE,
|
fo::AttackSubType::MELEE,
|
||||||
fo::AttackSubType::THROWING,
|
fo::AttackSubType::THROWING,
|
||||||
fo::AttackSubType::GUNS,
|
fo::AttackSubType::RANGED,
|
||||||
fo::AttackSubType::GUNS,
|
fo::AttackSubType::RANGED,
|
||||||
fo::AttackSubType::GUNS
|
fo::AttackSubType::RANGED
|
||||||
};
|
};
|
||||||
DWORD type = weaponFlag & 0xF;
|
DWORD type = weaponFlag & 0xF;
|
||||||
return (type < 9) ? weapon_types[type] : fo::AttackSubType::NONE;
|
return (type < 9) ? weapon_types[type] : fo::AttackSubType::NONE;
|
||||||
|
|||||||
@@ -649,7 +649,7 @@ enum AttackSubType : long
|
|||||||
UNARMED = 1,
|
UNARMED = 1,
|
||||||
MELEE = 2,
|
MELEE = 2,
|
||||||
THROWING = 3,
|
THROWING = 3,
|
||||||
GUNS = 4
|
RANGED = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BodyType : long
|
enum BodyType : long
|
||||||
|
|||||||
@@ -603,9 +603,9 @@ struct CritInfo {
|
|||||||
long statMod;
|
long statMod;
|
||||||
// Another bit field, using the same values as EffectFlags. If the stat check is failed, these are applied in addition to the earlier ones.
|
// Another bit field, using the same values as EffectFlags. If the stat check is failed, these are applied in addition to the earlier ones.
|
||||||
long failureEffect;
|
long failureEffect;
|
||||||
// The message to show when this critical occurs, taken from combat.msg .
|
// The message to show when this critical occurs, taken from combat.msg.
|
||||||
long message;
|
long message;
|
||||||
// Shown instead of Message if the stat check is failed.
|
// This is shown instead of Message if the stat check fails.
|
||||||
long failMessage;
|
long failMessage;
|
||||||
};
|
};
|
||||||
long values[7];
|
long values[7];
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ static long item_w_mp_cost_sub(fo::GameObject* source, fo::GameObject* item, lon
|
|||||||
if ((type == fo::AttackSubType::MELEE || type == fo::AttackSubType::UNARMED) && Stats::perk_level(source, fo::Perk::PERK_bonus_hth_attacks)) {
|
if ((type == fo::AttackSubType::MELEE || type == fo::AttackSubType::UNARMED) && Stats::perk_level(source, fo::Perk::PERK_bonus_hth_attacks)) {
|
||||||
cost--;
|
cost--;
|
||||||
}
|
}
|
||||||
if (type == fo::AttackSubType::GUNS && Stats::perk_level(source, fo::Perk::PERK_bonus_rate_of_fire)) {
|
if (type == fo::AttackSubType::RANGED && Stats::perk_level(source, fo::Perk::PERK_bonus_rate_of_fire)) {
|
||||||
cost--;
|
cost--;
|
||||||
}
|
}
|
||||||
if (cost < 1) cost = 1;
|
if (cost < 1) cost = 1;
|
||||||
|
|||||||
@@ -2299,7 +2299,7 @@ fix:
|
|||||||
mov edx, [esi + ammoPid];
|
mov edx, [esi + ammoPid];
|
||||||
test edx, edx;
|
test edx, edx;
|
||||||
js skip;
|
js skip;
|
||||||
mov eax, GUNS; // set GUNS if has ammo pid
|
mov eax, RANGED; // set RANGED if has ammo pid
|
||||||
skip:
|
skip:
|
||||||
retn;
|
retn;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1159,7 +1159,7 @@ static void __declspec(naked) item_w_called_shot_hack() {
|
|||||||
call fo::funcoffs::item_hit_with_; // get pointer to weapon
|
call fo::funcoffs::item_hit_with_; // get pointer to weapon
|
||||||
mov edx, ecx;
|
mov edx, ecx;
|
||||||
call fo::funcoffs::item_w_subtype_;
|
call fo::funcoffs::item_w_subtype_;
|
||||||
cmp eax, THROWING; // is weapon type GUNS or THROWING?
|
cmp eax, THROWING; // is weapon type RANGED or THROWING?
|
||||||
jge checkRange; // yes
|
jge checkRange; // yes
|
||||||
jmp FastShotTraitFix_End; // continue processing called shot attempt
|
jmp FastShotTraitFix_End; // continue processing called shot attempt
|
||||||
checkRange:
|
checkRange:
|
||||||
|
|||||||
Reference in New Issue
Block a user