mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Corrected combat_attack_gcsd code in the previous commit
Added DAM_PRESERVE_FLAGS to attack_complex for keeping result flags. Fixed OverrideMusicDir=2 not working (#295)
This commit is contained in:
+1
-1
@@ -133,7 +133,7 @@ AllowSoundForFloats=0
|
||||
;This does not effect the play_sfall_sound and stop_sfall_sound script functions
|
||||
AllowDShowSound=0
|
||||
|
||||
;Set to 1 to override the music path used by default (i.e. data\sound\music\) if not present in the cfg
|
||||
;Set to 1 to override the default music path with data\sound\music\ if music_path is not present in the cfg
|
||||
;Set to 2 to overwrite all occurances of the music path
|
||||
OverrideMusicDir=1
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#ifndef DEFINE_EXTRA_H
|
||||
#define DEFINE_EXTRA_H
|
||||
|
||||
/* Combat Flags */
|
||||
#define DAM_PRESERVE_FLAGS 0x80000000 // keep the existing result flags when setting new flags in attack_complex (for sfall)
|
||||
|
||||
#define BODY_HIT_HEAD (0)
|
||||
#define BODY_HIT_LEFT_ARM (1)
|
||||
#define BODY_HIT_RIGHT_ARM (2)
|
||||
|
||||
+34
-33
@@ -117,50 +117,51 @@ enum CritterFlags : long
|
||||
NoKnockBack = 0x4000, // Can't be knocked back
|
||||
};
|
||||
|
||||
enum DamageFlag : long
|
||||
enum DamageFlag : unsigned long
|
||||
{
|
||||
DAM_KNOCKED_OUT = 0x1,
|
||||
DAM_KNOCKED_DOWN = 0x2,
|
||||
DAM_CRIP_LEG_LEFT = 0x4,
|
||||
DAM_CRIP_LEG_RIGHT = 0x8,
|
||||
DAM_CRIP_ARM_LEFT = 0x10,
|
||||
DAM_CRIP_ARM_RIGHT = 0x20,
|
||||
DAM_BLIND = 0x40,
|
||||
DAM_DEAD = 0x80,
|
||||
DAM_HIT = 0x100,
|
||||
DAM_CRITICAL = 0x200,
|
||||
DAM_ON_FIRE = 0x400,
|
||||
DAM_BYPASS = 0x800,
|
||||
DAM_EXPLODE = 0x1000,
|
||||
DAM_DESTROY = 0x2000,
|
||||
DAM_DROP = 0x4000,
|
||||
DAM_LOSE_TURN = 0x8000,
|
||||
DAM_HIT_SELF = 0x10000,
|
||||
DAM_LOSE_AMMO = 0x20000,
|
||||
DAM_DUD = 0x40000,
|
||||
DAM_HURT_SELF = 0x80000,
|
||||
DAM_RANDOM_HIT = 0x100000,
|
||||
DAM_CRIP_RANDOM = 0x200000,
|
||||
DAM_BACKWASH = 0x400000,
|
||||
DAM_KNOCKED_OUT = 0x1,
|
||||
DAM_KNOCKED_DOWN = 0x2,
|
||||
DAM_CRIP_LEG_LEFT = 0x4,
|
||||
DAM_CRIP_LEG_RIGHT = 0x8,
|
||||
DAM_CRIP_ARM_LEFT = 0x10,
|
||||
DAM_CRIP_ARM_RIGHT = 0x20,
|
||||
DAM_BLIND = 0x40,
|
||||
DAM_DEAD = 0x80,
|
||||
DAM_HIT = 0x100,
|
||||
DAM_CRITICAL = 0x200,
|
||||
DAM_ON_FIRE = 0x400,
|
||||
DAM_BYPASS = 0x800,
|
||||
DAM_EXPLODE = 0x1000,
|
||||
DAM_DESTROY = 0x2000,
|
||||
DAM_DROP = 0x4000,
|
||||
DAM_LOSE_TURN = 0x8000,
|
||||
DAM_HIT_SELF = 0x10000,
|
||||
DAM_LOSE_AMMO = 0x20000,
|
||||
DAM_DUD = 0x40000,
|
||||
DAM_HURT_SELF = 0x80000,
|
||||
DAM_RANDOM_HIT = 0x100000,
|
||||
DAM_CRIP_RANDOM = 0x200000,
|
||||
DAM_BACKWASH = 0x400000,
|
||||
DAM_PERFORM_REVERSE = 0x800000,
|
||||
DAM_PRESERVE_FLAGS = 0x80000000 // sfall, used for attack_complex
|
||||
};
|
||||
|
||||
enum DamageType
|
||||
{
|
||||
DMG_normal = 0,
|
||||
DMG_laser = 1,
|
||||
DMG_fire = 2,
|
||||
DMG_plasma = 3,
|
||||
DMG_electrical = 4,
|
||||
DMG_emp = 5,
|
||||
DMG_explosion = 6,
|
||||
DMG_normal = 0,
|
||||
DMG_laser = 1,
|
||||
DMG_fire = 2,
|
||||
DMG_plasma = 3,
|
||||
DMG_electrical = 4,
|
||||
DMG_emp = 5,
|
||||
DMG_explosion = 6,
|
||||
DMG_BYPASS_ARMOR = 256,
|
||||
DMG_NOANIMATE = 512,
|
||||
DMG_NOANIMATE = 512,
|
||||
};
|
||||
|
||||
enum Gender
|
||||
{
|
||||
GENDER_MALE = 0,
|
||||
GENDER_MALE = 0,
|
||||
GENDER_FEMALE = 1,
|
||||
};
|
||||
|
||||
|
||||
@@ -2030,12 +2030,22 @@ skip:
|
||||
static void __stdcall combat_attack_gcsd() {
|
||||
if (fo::var::gcsd->changeFlags & 2) { // only for AttackComplexFix
|
||||
long flags = fo::var::gcsd->flagsSource;
|
||||
flags |= fo::var::main_ctd.attackerFlags & (fo::DamageFlag::DAM_HIT | fo::DamageFlag::DAM_DEAD); // don't unset DAM_HIT and DAM_DEAD flags
|
||||
if (flags & fo::DamageFlag::DAM_PRESERVE_FLAGS) {
|
||||
flags &= ~fo::DamageFlag::DAM_PRESERVE_FLAGS;
|
||||
flags |= fo::var::main_ctd.attackerFlags;
|
||||
} else {
|
||||
flags |= fo::var::main_ctd.attackerFlags & (fo::DamageFlag::DAM_HIT | fo::DamageFlag::DAM_DEAD); // don't unset DAM_HIT and DAM_DEAD flags
|
||||
}
|
||||
fo::var::main_ctd.attackerFlags = flags;
|
||||
}
|
||||
if (fo::var::gcsd->changeFlags & 1) {
|
||||
long flags = fo::var::gcsd->flagsTarget;
|
||||
flags |= fo::var::main_ctd.targetFlags & fo::DamageFlag::DAM_DEAD; // don't unset DAM_DEAD flag
|
||||
if (flags & fo::DamageFlag::DAM_PRESERVE_FLAGS) {
|
||||
flags &= ~fo::DamageFlag::DAM_PRESERVE_FLAGS;
|
||||
flags |= fo::var::main_ctd.targetFlags;
|
||||
} else {
|
||||
flags |= fo::var::main_ctd.targetFlags & fo::DamageFlag::DAM_DEAD; // don't unset DAM_DEAD flag (fix death animation)
|
||||
}
|
||||
fo::var::main_ctd.targetFlags = flags;
|
||||
}
|
||||
|
||||
@@ -2045,17 +2055,17 @@ static void __stdcall combat_attack_gcsd() {
|
||||
if (fo::var::main_ctd.targetDamage < fo::var::gcsd->minDamage) {
|
||||
fo::var::main_ctd.targetDamage = fo::var::gcsd->minDamage;
|
||||
}
|
||||
// check the hit points and set the DAM_DEAD flag
|
||||
if (damage != fo::var::main_ctd.targetDamage) {
|
||||
if (damage < fo::var::main_ctd.targetDamage) { // check the hit points and set the DAM_DEAD flag
|
||||
fo::func::check_for_death(fo::var::main_ctd.target, fo::var::main_ctd.targetDamage, &fo::var::main_ctd.targetFlags);
|
||||
}
|
||||
|
||||
if (fo::var::main_ctd.targetDamage > fo::var::gcsd->maxDamage) {
|
||||
fo::var::main_ctd.targetDamage = fo::var::gcsd->maxDamage;
|
||||
if (fo::var::main_ctd.target->Type() == fo::ObjType::OBJ_TYPE_CRITTER) {
|
||||
long cHP = fo::var::main_ctd.target->critter.health;
|
||||
if (cHP > fo::var::gcsd->maxDamage && cHP <= damage) {
|
||||
fo::var::main_ctd.targetFlags &= ~fo::DamageFlag::DAM_DEAD; // unset
|
||||
}
|
||||
}
|
||||
if (damage > fo::var::main_ctd.targetDamage && fo::var::main_ctd.target->Type() == fo::ObjType::OBJ_TYPE_CRITTER) {
|
||||
long cHP = fo::var::main_ctd.target->critter.health;
|
||||
if (cHP > fo::var::gcsd->maxDamage && cHP <= damage) {
|
||||
fo::var::main_ctd.targetFlags &= ~fo::DamageFlag::DAM_DEAD; // unset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,12 +439,14 @@ static void ObjCanSeeShootThroughPatch() {
|
||||
}
|
||||
}
|
||||
|
||||
static const char* musicOverridePath = "data\\sound\\music\\";
|
||||
static void OverrideMusicDirPatch() {
|
||||
static const char* musicOverridePath = "data\\sound\\music\\";
|
||||
|
||||
if (long overrideMode = GetConfigInt("Sound", "OverrideMusicDir", 0)) {
|
||||
SafeWriteBatch<DWORD>((DWORD)musicOverridePath, {0x4449C2, 0x4449DB});
|
||||
SafeWriteBatch<DWORD>((DWORD)musicOverridePath, {0x4449C2, 0x4449DB}); // set paths if not present in the cfg
|
||||
if (overrideMode == 2) {
|
||||
SafeWriteBatch<DWORD>((DWORD)musicOverridePath, {0x518E78, 0x518E7C});
|
||||
SafeWrite16(0x44FCF3, 0x40EB); // jmp 0x44FD35 (skip paths initialization)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user