I'm trying to utilize "GetDistance" from within my .dll. I'm using OBSE 21 source code.
I found this section of code in GameOjects.h (see third line from the bottom)
Spoiler
// 058
class TESObjectREFR : public TESForm
{
public:
#if OBLIVION
MEMBER_FN_PREFIX(TESObjectREFR);
DEFINE_MEMBER_FN(IsOffLimitsToPlayer, bool, kTESObjectREFR_IsOffLimitsToPlayerAddr);
#endif
enum
{
// TESForm flags
// if(!IsActor())
kChanged_IsEmpty = 0x00010000,
// CHANGE_OBJECT_EMPTY
// no data?
kChanged_Inventory = 0x08000000,
// CHANGE_REFR_INVENTORY
// ### todo: see 0048BA40
// if((changed & ((version < 0x43) ? 0x177577F0 : 0x177577E0))) || IsActor())
// {
// // this is all part of its own function
//
// }
// if(!IsActor())
kChanged_Animation = 0x02000000,
// CHANGE_REFR_ANIMATION
// UInt16 dataLen;
// UInt8 data[dataLen];
kChanged_Move = 0x00000004,
// TESObjectCELL cell
// float pos[3]
// float rot[3]
kChanged_HavokMove = 0x00000008,
// CHANGE_REFR_HAVOK_MOVE
kChanged_MapMarkerFlags = 0x00000400,
// CHANGE_MAPMARKER_EXTRA_FLAGS
kChanged_HadHavokMoveFlag = 0x00000800,
// CHANGEFLAG_REFR_HAD_HAVOK_MOVE_FLAG
// if either of these are set
// UInt16 dataLen;
// UInt8 data[dataLen];
// if(version > 0x43)
kChanged_Scale = 0x00000010,
// CHANGE_REFR_SCALE
// float scale;
kChanged_DoorOpenDefaultState = 0x00040000,
// CHANGE_DOOR_OPEN_DEFAULT_STATE
// no data
kChanged_DoorOpenState = 0x00080000,
// CHANGE_DOOR_OPEN_STATE
// no data
kChanged_DoorExtraTeleport = 0x00100000,
// CHANGE_DOOR_EXTRA_TELEPORT
kChanged_ExtraOwner = 0x00000080,
// CHANGE_OBJECT_EXTRA_OWNER
};
enum
{
kFlags_Persistent = 0x00000400, //shared bit with kFormFlags_QuestItem
kFlags_Disabled = 0x00000800,
kFlags_Unk00000002 = 0x00000002, // set when an item reference is picked up by an actor
kFlags_Deleted = 0x00000020, // refr removed from .esp or savegame
kFlags_Unk128 = 0x80000000,
kFlags_Temporary = 0x00004000,
// both flags are set when an item picked up from gameworld
// one or the other flag by itself is not sufficient
kFlags_Taken = kFlags_Deleted | kFlags_Unk00000002
};
TESObjectREFR();
~TESObjectREFR();
virtual void Unk_37(void) = 0;
virtual void Unk_38(void) = 0; // 38
virtual void Unk_39(void) = 0;
virtual void Unk_3A(void) = 0;
virtual float GetScale(void) = 0;
virtual void GetStartingAngle(float * pos) = 0;
virtual void GetStartingPos(float * pos) = 0;
virtual void Unk_3E(void) = 0;
virtual void Unk_3F(void) = 0;
virtual void RemoveItem(TESForm* toRemove, BaseExtraList* extraList, UInt32 unk2, UInt32 unk3, UInt32 unk4, TESObjectREFR* destRef,
UInt32 unk6, UInt32 unk7, UInt32 unk8, UInt8 unk9) = 0; // 40 unk2 quantity?
virtual void Unk_41(void) = 0;
virtual void Unk_42(void) = 0;
virtual void Unk_43(void) = 0;
virtual void Unk_44(void) = 0;
virtual void AddItem(TESForm* item, ExtraDataList* xDataList) = 0;
virtual void Unk_46(void) = 0;
virtual void Unk_47(void) = 0;
virtual void Unk_48(void) = 0;
virtual MagicTarget * GetMagicTarget(void) = 0;
virtual void Unk_4A(void) = 0;
virtual void Unk_4B(void) = 0;
virtual void Unk_4C(void) = 0;
virtual void Unk_4D(void) = 0;
virtual void Unk_4E(void) = 0;
virtual void Unk_4F(void) = 0;
virtual void Unk_50(void) = 0; // 50
virtual void Unk_51(void) = 0;
virtual void Unk_52(void) = 0; // inits animation-related data, and more
virtual NiNode* GenerateNiNode(void) = 0;
virtual void Set3D(NiNode* niNode);
virtual NiNode * GetNiNode(void) = 0;
virtual void Unk_56(void) = 0;
virtual void Unk_57(UInt32 arg0) = 0;
virtual void Unk_58(void) = 0;
virtual void Unk_59(void) = 0;
virtual void Unk_5A(void) = 0;
virtual void Unk_5B(void) = 0;
virtual TESForm * GetBaseForm(void) = 0; // returns type this object references
virtual float * GetPos(void) = 0;
virtual void Unk_5E(void) = 0;
virtual void Unk_5F(void) = 0;
virtual void Unk_60(void) = 0; // 60
virtual void Unk_61(void) = 0;
virtual void Unk_62(void) = 0;
virtual UInt8 GetSleepState(void) = 0;
virtual bool IsActor(void) = 0;
virtual void ChangeCell(TESObjectCELL * newCell) = 0;
virtual bool IsDead(bool arg0) = 0;
virtual void Unk_67(void) = 0;
virtual void Unk_68(void) = 0;
virtual void Unk_69(void) = 0;
TESChildCell childCell; // 018
TESForm * baseForm; // 01C
// U8(typeInfo + 4) == 0x23 is true if the object is a character
float rotX, rotY, rotZ; // 020 - either public or accessed via simple inline accessor common to all child classes
float posX, posY, posZ; // 02C - seems to be private
float scale; // 038
NiNode * niNode; // 03C
TESObjectCELL * parentCell; // 040
BaseExtraList baseExtraList; // 044
ScriptEventList* GetEventList() const;
bool IsTaken() const { return ((flags & kFlags_Taken) == kFlags_Taken) ? true : false; }
bool IsDeleted() const;
void SetTaken(bool bTaken) {
flags = (bTaken) ? (flags | kFlags_Taken) : (flags & ~kFlags_Taken);
}
bool IsDisabled() { return flags & kFlags_Disabled ? true : false; }
void SetDisabled(bool bDisabled) {
flags = bDisabled ? (flags | kFlags_Disabled) : (flags & ~kFlags_Disabled);
}
bool IsPersistent() { return (flags & kFlags_Persistent) ? true : false; }
bool IsTemporary() { return (flags & kFlags_Temporary) ? true : false; }
TESForm * GetInventoryItem(UInt32 itemIndex, bool bGetWares);
void Disable();
void Enable();
bool RunScripts(); // runs magic effect and object scripts plus any scripts on items in inventory
bool GetTeleportCellName(BSStringT* outName);
bool Update3D();
TESContainer* GetContainer();
bool IsMapMarker();
float GetDistance(TESObjectREFR* other, bool bIncludeDisabled);
ExtraTeleport::Data* GetExtraTeleportData();
static TESObjectREFR* Create(bool bTemp = false);
};
and in GameObjects.cpp
Spoiler
float TESObjectREFR::GetDistance(TESObjectREFR* other, bool bIncludeDisabled)
{
#if OBLIVION_VERSION == OBLIVION_VERSION_1_2_416
float result;
ThisStdCall(0x0065D270, this, other, bIncludeDisabled);
__asm { fstp [result] }
#else
#error unsupported Oblivion version
#endif
return result;
}
With everything else that I do, usually I can do Actor/Reference->k_value or Actor/Reference->SomeFunction() if the value or function is a member of the calling class.
So logically, you would think that the following would work:
bool GetLOSAlt(Script* scriptObj, Actor * dActor, Actor * tActor){I've tried it with just using the actor (because TESObjectREFR is a parent class) and also having the second argument be 0.
... snip ...
TESObjectREFR * dRef = (TESObjectREFR*)dActor;
TESObjectREFR * tRef = (TESObjectREFR*)tActor;
float distanceToTarget = dRef->GetDistance(tRef,1);
float fScale = dRef->GetScale();
if (distanceToTarget < dDetectLifeRange){bDetectLifeApplies = 1;}
Console_Print("SDR dll: DL Check | Dist: %.4f | Scale: %.4f | Det: %s (%08X) | Targ: %s (%08X)"
,distanceToTarget
,fScale
,GetFullName(dActor)
,dActor ? dActor->refID : 0
,GetFullName(tActor)
,tActor ? tActor->refID : 0
);
.... snip ...
It compiles with no errors, however the result of distanceToTarget is always 0. But the fScale returns with an accurate result. Both functions are pulled from the exact same class structure.
Can someone please explain to me why?
Why?
Why the F does this NOT work??!!!
So bloody frustrating.