mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Code edits in EngineUtils.cpp
Added comments to some defines in Enums.h.
This commit is contained in:
@@ -56,31 +56,28 @@ Queue* QueueFind(GameObject* object, long type) {
|
|||||||
|
|
||||||
long AnimCodeByWeapon(GameObject* weapon) {
|
long AnimCodeByWeapon(GameObject* weapon) {
|
||||||
if (weapon != nullptr) {
|
if (weapon != nullptr) {
|
||||||
Proto* proto = GetProto(weapon->protoId);
|
Proto* proto = nullptr;
|
||||||
if (proto != nullptr && proto->item.type == item_type_weapon) {
|
if (GetProto(weapon->protoId, proto) && proto->item.type == item_type_weapon) {
|
||||||
return proto->item.weapon.animationCode;
|
return proto->item.weapon.animationCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Proto* GetProto(long pid) {
|
bool GetProto(long pid, Proto* outProto) {
|
||||||
Proto* protoPtr;
|
return (fo::func::proto_ptr(pid, &outProto) != -1);
|
||||||
if (fo::func::proto_ptr(pid, &protoPtr) != -1) {
|
|
||||||
return protoPtr;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CritterCopyProto(long pid, long* &proto_dst) {
|
bool CritterCopyProto(long pid, long* &proto_dst) {
|
||||||
fo::Proto* protoPtr;
|
fo::Proto* proto = nullptr;
|
||||||
if (fo::func::proto_ptr(pid, &protoPtr) == -1) {
|
bool result = GetProto(pid, proto);
|
||||||
|
if (result) {
|
||||||
|
proto_dst = reinterpret_cast<long*>(new int32_t[104]);
|
||||||
|
std::memcpy(proto_dst, proto, 416);
|
||||||
|
} else {
|
||||||
proto_dst = nullptr;
|
proto_dst = nullptr;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
proto_dst = reinterpret_cast<long*>(new long[104]);
|
return result;
|
||||||
memcpy(proto_dst, protoPtr, 416);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkillGetTags(long* result, long num) {
|
void SkillGetTags(long* result, long num) {
|
||||||
@@ -165,21 +162,21 @@ long __fastcall IsRadInfluence() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IsNpcFlag(fo::GameObject* npc, long flag) {
|
bool IsNpcFlag(fo::GameObject* npc, long flag) {
|
||||||
Proto* protoPtr;
|
Proto* proto = nullptr;;
|
||||||
if (fo::func::proto_ptr(npc->protoId, &protoPtr) != -1) {
|
if (GetProto(npc->protoId, proto)) {
|
||||||
return (protoPtr->critter.critterFlags & (1 << flag)) != 0;
|
return (proto->critter.critterFlags & (1 << flag)) != 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToggleNpcFlag(fo::GameObject* npc, long flag, bool set) {
|
void ToggleNpcFlag(fo::GameObject* npc, long flag, bool set) {
|
||||||
Proto* protoPtr;
|
Proto* proto = nullptr;;
|
||||||
if (fo::func::proto_ptr(npc->protoId, &protoPtr) != -1) {
|
if (GetProto(npc->protoId, proto)) {
|
||||||
long bit = (1 << flag);
|
long bit = (1 << flag);
|
||||||
if (set) {
|
if (set) {
|
||||||
protoPtr->critter.critterFlags |= bit;
|
proto->critter.critterFlags |= bit;
|
||||||
} else {
|
} else {
|
||||||
protoPtr->critter.critterFlags &= ~bit;
|
proto->critter.critterFlags &= ~bit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,15 @@ Queue* QueueFind(GameObject* object, long type);
|
|||||||
// returns weapon animation code
|
// returns weapon animation code
|
||||||
long AnimCodeByWeapon(GameObject* weapon);
|
long AnimCodeByWeapon(GameObject* weapon);
|
||||||
|
|
||||||
// returns pointer to prototype by PID, or nullptr on failure
|
// returns False if the prototype does not exist, or pointer to prototype by PID in the outProto argument
|
||||||
Proto* GetProto(long pid);
|
bool GetProto(long pid, Proto* outProto);
|
||||||
|
|
||||||
|
// returns pointer to prototype by PID, or nullptr on get failure
|
||||||
|
// NOTE: not an efficient construction
|
||||||
|
__forceinline Proto* GetProto(long pid) {
|
||||||
|
Proto* proto = nullptr;;
|
||||||
|
return GetProto(pid, proto) ? proto : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool CritterCopyProto(long pid, long* &proto_dst);
|
bool CritterCopyProto(long pid, long* &proto_dst);
|
||||||
|
|
||||||
|
|||||||
+24
-15
@@ -515,10 +515,10 @@ enum Stat : long
|
|||||||
STAT_rad_resist = 31,
|
STAT_rad_resist = 31,
|
||||||
STAT_poison_resist = 32,
|
STAT_poison_resist = 32,
|
||||||
// poison_resist MUST be the last derived stat
|
// poison_resist MUST be the last derived stat
|
||||||
// nonderived stats
|
// non-derived stats
|
||||||
STAT_age = 33,
|
STAT_age = 33,
|
||||||
STAT_gender = 34,
|
STAT_gender = 34,
|
||||||
// gender MUST be the last nonderived stat
|
// gender MUST be the last non-derived stat
|
||||||
STAT_current_hp = 35,
|
STAT_current_hp = 35,
|
||||||
STAT_current_poison = 36,
|
STAT_current_poison = 36,
|
||||||
STAT_current_rad = 37,
|
STAT_current_rad = 37,
|
||||||
@@ -738,6 +738,14 @@ enum RollResult
|
|||||||
ROLL_CRITICAL_SUCCESS = 0x3,
|
ROLL_CRITICAL_SUCCESS = 0x3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum CombatStateFlag : long
|
||||||
|
{
|
||||||
|
InCombat = 1,
|
||||||
|
EnemyOutOfRange = 2,
|
||||||
|
IsFleeing = 4,
|
||||||
|
ReTarget = 8 // sfall flag
|
||||||
|
};
|
||||||
|
|
||||||
namespace Fields {
|
namespace Fields {
|
||||||
enum CommonObj : long
|
enum CommonObj : long
|
||||||
{
|
{
|
||||||
@@ -805,13 +813,14 @@ namespace WinFlags {
|
|||||||
namespace AIpref {
|
namespace AIpref {
|
||||||
enum distance : long
|
enum distance : long
|
||||||
{
|
{
|
||||||
stay_close = 0,
|
stay_close = 0, // the attacker will stay at a distance no more than 5 hexes from the player (defined in ai_move_steps_closer, cai_perform_distance_prefs)
|
||||||
charge = 1,
|
charge = 1, // AI will always try to get close to its target before or after attack
|
||||||
snipe = 2,
|
snipe = 2, // when the distance between the attacker and the target decreases, the attacker will try to move away from the target to a distance of up to 10 hexes
|
||||||
on_your_own = 3,
|
on_your_own = 3, // no special behavior defined for this
|
||||||
stay = 4
|
stay = 4 // the attacker will, if possible, stay at the hex where the combat started (defined in ai_move_steps_closer, ai_move_away)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// presets for party members
|
||||||
enum disposition : long
|
enum disposition : long
|
||||||
{
|
{
|
||||||
none = -1,
|
none = -1,
|
||||||
@@ -824,11 +833,11 @@ namespace AIpref {
|
|||||||
|
|
||||||
enum class attack_who : long
|
enum class attack_who : long
|
||||||
{
|
{
|
||||||
whomever_attacking_me = 0,
|
whomever_attacking_me = 0, // attack the target that the player is attacking (only for party members)
|
||||||
strongest = 1,
|
strongest = 1, // attack stronger targets (will switch to stronger ones in combat)
|
||||||
weakest = 2,
|
weakest = 2, // attack weaker targets
|
||||||
whomever = 3,
|
whomever = 3, // anyone
|
||||||
closest = 4,
|
closest = 4, // only attack near targets
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class run_away_mode : long
|
enum class run_away_mode : long
|
||||||
@@ -850,13 +859,13 @@ namespace AIpref {
|
|||||||
ranged_over_melee = 3,
|
ranged_over_melee = 3,
|
||||||
ranged = 4,
|
ranged = 4,
|
||||||
unarmed = 5,
|
unarmed = 5,
|
||||||
unarmed_over_thrown = 6, // not available in party member control panel
|
unarmed_over_thrown = 6, // not available for party member in control panel
|
||||||
random = 7 // not available in party member control panel
|
random = 7 // not available for party member in control panel
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class area_attack_mode : long
|
enum class area_attack_mode : long
|
||||||
{
|
{
|
||||||
no_pref = -1, // special logic for NPC (not available in party member control panel)
|
no_pref = -1, // special logic for NPC (not available for party member in control panel)
|
||||||
always = 0,
|
always = 0,
|
||||||
sometimes = 1, // use random value from cap.secondary_freq
|
sometimes = 1, // use random value from cap.secondary_freq
|
||||||
be_sure = 2, // 85% hit chance
|
be_sure = 2, // 85% hit chance
|
||||||
|
|||||||
Reference in New Issue
Block a user