-
Автор темы
- #1
ihave all entities but i just wanna understand which one is hero and which one is tower which one is creeps etc ...
he my CBaseEntity.h , CDOTABaseNPC.h
he my CBaseEntity.h , CDOTABaseNPC.h
cpp:
#pragma once
enum DOTA_GC_TEAM : int {
DOTA_GC_TEAM_GOOD_GUYS = 0,
DOTA_GC_TEAM_BAD_GUYS = 1,
DOTA_GC_TEAM_BROADCASTER = 2,
DOTA_GC_TEAM_SPECTATOR = 3,
DOTA_GC_TEAM_PLAYER_POOL = 4,
DOTA_GC_TEAM_NOTEAM = 5,
DOTA_GC_TEAM_CUSTOM_1 = 6,
DOTA_GC_TEAM_CUSTOM_2 = 7,
DOTA_GC_TEAM_CUSTOM_3 = 8,
DOTA_GC_TEAM_CUSTOM_4 = 9,
DOTA_GC_TEAM_CUSTOM_5 = 10,
DOTA_GC_TEAM_CUSTOM_6 = 11,
DOTA_GC_TEAM_CUSTOM_7 = 12,
DOTA_GC_TEAM_CUSTOM_8 = 13,
DOTA_GC_TEAM_NEUTRALS = 14
};
#include "../base/VClass.h"
#include "../base/NormalClass.h"
#include "../base/Definitions.h"
#include "../base/Vector.h"
#include "../base/Color.h"
#include "CEntityIdentity.h"
#include "CHandle.h"
#include "../VMI.h"
class CDOTAPlayerController;
struct CEntSchemaClassBinding {
const char
* binaryName, // ex: C_DOTA_Unit_Hero_Nevermore
* serverName; // ex: CDOTA_Unit_Hero_Nevermore
void* parent;
const char* fullName; // ex: client.dll!C_DOTA_Unit_Hero_Nevermore
void* idk;
int listIndex;
PAD(4 + 8 * 2);
};
class CBaseEntity : public VClass {
public:
struct CModelState : public NormalClass {
FIELD(uint64_t, MeshGroupMask, 0x198);
GETTER(const char*, GetModelName, 0xa8);
NormalClass* GetModel() const {
return [I]Member<NormalClass*[/I]>(0xa0);
};
};
struct CSkeletonInstance : public VClass {
// reversed from xref: "CBaseModelEntity::SetBodygroup(%d,%d) failed: CBaseModelEntity has no model!\n"
// last two subs are get and set
GETTER(CBaseEntity*, GetOwner, 0x30);
IGETTER(CModelState, GetModelState, 0x170)
};
CEntSchemaClassBinding* SchemaBinding() const {
return GetVFunc(VMI::CBaseEntity::GetSchemaBinding).Call<CEntSchemaClassBinding*>();
};
inline static void(__fastcall* OnColorChanged)(void*) = {};
GETTER(CEntityIdentity*, GetIdentity, 0x10);
GETTER(int, GetHealth, 0x34c);
GETTER(int, GetMaxHealth, 0x348);
GETTER(DOTA_GC_TEAM, GetTeam, 0x3eb);
GETTER(int8_t, GetLifeState, 0x350);
GETTER(CHandle<CDOTAPlayerController>, GetOwnerEntityHandle, 0x43c);
GETTER(CSkeletonInstance*, GetGameSceneNode, 0x330);
bool IsAlive() const {
return GetLifeState() == 0;
}
bool IsDormant() const {
return GetIdentity() && GetIdentity()->IsDormant();
}
const char* GetModelName() const {
// og's explanation:
// CModelState has 3 CStrongHandle pointers at 0xA0 and below
// These strong handles have a model pointer and its name
return GetGameSceneNode()->GetModelState()->GetModelName();
}
bool IsSameTeam(CBaseEntity* other) const {
return GetTeam() == other->GetTeam();
}
uint32_t GetHandle() const {
auto id = GetIdentity();
if (!IsValidReadPtr(id))
return INVALID_HANDLE;
return id->entHandle;
}
// Returns the index of this entity in the entity system
uint32_t GetIndex() const {
return H2IDX(GetHandle());
}
void SetColor(Color clr)
{
Field<Color>(0x5f0) = clr;
OnColorChanged(this);
}
float& ModelScale() const {
return Member<VClass*>(0x330)
->Field<float>(0xcc);
}
Vector GetPos() const {
return Member<VClass*>(0x330)
->Member<Vector>(0xd0);
}
// In degrees from 180 to -180(on 0 it looks right)
float GetRotation() const {
return Member<VClass*>(0x330)
->Member<Vector>(0xc0).y;
}
// Gets the point in front of the entity at the specified distance
Vector GetForwardVector(float dist) const {
auto pos = GetPos();
float rotation = GetRotation() * M_PI / 180;
float sine = sinf(rotation), cosine = cosf(rotation);
auto forwardVec = Vector(cosine * dist, sine * dist, 0);
return pos + forwardVec;
}
};
C++:
#pragma once
#include "CBaseEntity.h"
#include "CDOTAItem.h"
#include "CDOTAUnitInventory.h"
#include "CDOTAModifierManager.h"
#include "../Enums.h"
class CEconWearable;
class CDOTABaseNPC : public CBaseEntity {
public:
inline static float(*GetAttackSpeed)(CDOTABaseNPC* npc) = nullptr;
struct BarrierData {
float
maxPhys,
maxMagic,
maxAll,
phys, // physical blocks damage
magic, // blocks magical damage
all; // blocks all forms of damage
};
GETTER(BarrierData, GetBarriers, 0x17E4);
IGETTER(CDOTAModifierManager, GetModifierManager, 0xc80);
bool HasModifier(std::string_view name) const {
return GetModifier(name) != nullptr;
}
float GetPhysicalArmorValue() const {
return GetVFunc(VMI::CDOTABaseNPC::GetPhysicalArmorValue).Call<float>(0ull);
}
float GetMagicalArmorValue() const {
return GetVFunc(VMI::CDOTABaseNPC::GetMagicalArmorValue).Call<float>(0ull, 0ull);
}
VGETTER(float, GetIdealSpeed, VMI::CDOTABaseNPC::GetIdealSpeed);
VGETTER(void, OnWearablesChanged, VMI::CDOTABaseNPC::OnWearablesChanged);
bool IsTargetable() const {
return !IsDormant() && IsAlive() && !IsWaitingToSpawn();
}
// JS func, uses another vtable at offset
bool IsRoshan() const {
return MemberInline<VClass>(0xA38)->GetVFunc(VMI::CDOTABaseNPC::IsRoshan).Call<bool>();
}
int GetAttackDamageMin() const { return Member<int>(0xc68) + Member<int>(0xc70); }
float GetAttackRange() const {
return GetVFunc(VMI::CDOTABaseNPC::GetAttackRange).Call<float>(0, 1);
};
GETTER(bool, IsWaitingToSpawn, 0x1510);
GETTER(bool, IsAncient, 0xab0);
GETTER(float, GetArmor, 0x1408);
GETTER(float, GetBaseMagicalResistance, 0x140c);
GETTER(const char*, GetUnitName, 0xbc8);
GETTER(DOTAUnitAttackCapability_t, GetAttackCapabilities, 0x1184);
GETTER(float, GetHealthRegen, 0xac0);
GETTER(float, GetMana, 0xb00);
GETTER(float, GetMaxMana, 0xb04);
GETTER(float, GetManaRegen, 0xb08);
GETTER(float, GetBaseAttackTime, 0xaf0);
GETTER(float, GetHullRadius, 0xbb8);
GETTER(int, GetMoveSpeed, 0xae8);
GETTER(bool, IsMoving, 0x1528);
FIELD(CUtlVector<CHandle<CEconWearable>>, Wearables, 0x9d0);
FIELD(CUtlVector<CHandle<CEconWearable>>, OldWearables, 0x16e0);
IGETTER(CDOTAUnitInventory, GetInventory, 0xfa0);
std::span<CHandle<CDOTAItem>, 19> GetItems() const {
return GetInventory()->GetItems();
}
std::span<CHandle<CDOTABaseAbility>, 35> GetAbilities() const {
auto hAbilities = MemberInline<CHandle<CDOTABaseAbility>>(0xb28);
return std::span<CHandle<CDOTABaseAbility>, 35>(hAbilities, 35);
}
CDOTABaseAbility* GetAbility(int index) const
{
if (index < 0 || index >= 35)
return nullptr;
return MemberInline<CHandle<CDOTABaseAbility>>(0xb28)[index];
}
CDOTABaseAbility* GetAbility(std::string_view name) const
{
auto abilities = GetAbilities();
auto ability = std::find_if(abilities.begin(), abilities.end(),
[name](auto x) {
return x.IsValid() && x->GetIdentity()->GetName() && x->GetIdentity()->GetName() == name;
}
);
return ability != abilities.end() ? *ability : nullptr;
}
CDOTAModifier* GetModifier(std::string_view name) const {
auto arr = GetModifierManager()->GetModifierList();
auto res = std::find_if(arr.begin(), arr.end(),
[name](auto x) {
return x->GetName() == name;
}
);
return res != arr.end() ? *res : nullptr;
}
CDOTAItem* FindItemBySubstring(const char* str) const {
for (const auto& item : GetItems())
if (
item.IsValid()
&& item->GetIdentity()->GetName()
&& strstr(item->GetIdentity()->GetName(), str)
)
return item;
return nullptr;
}
CDOTAItem* FindItem(std::string_view name) const {
auto items = GetItems();
auto item = std::find_if(items.begin(), items.end(),
[name](auto item) {
return item.IsValid() && item->GetIdentity()->GetName() && item->GetIdentity()->GetName() == name;
}
);
return item != items.end() ? **item : nullptr;
}
bool HasState(ModifierState state) const {
auto unitState = Member<uint64_t>(0x1080);
return (unitState & (1Ui64 << (int)state));
}
bool IsDisabled() const {
return HasState(MODIFIER_STATE_FEARED)
|| HasState(MODIFIER_STATE_HEXED)
|| HasState(MODIFIER_STATE_MUTED)
|| HasState(MODIFIER_STATE_NIGHTMARED)
|| HasState(MODIFIER_STATE_OUT_OF_GAME)
|| HasState(MODIFIER_STATE_SILENCED)
|| HasState(MODIFIER_STATE_STUNNED)
|| HasState(MODIFIER_STATE_TAUNTED);
}
bool CanUseAbility(CDOTABaseAbility* ability) const {
for (auto& ab : GetAbilities()) {
if (ab->Member<float>(0x5b8))
return false;
}
return IsAlive() &&
ability->GetLevel() > 0
&& !IsDisabled()
&& !ability->GetCooldown()
&& ability->GetManaCost() <= GetMana()
&& !ability->IsInAbilityPhase();
}
Vector GetHealthBarPos() const {
auto pos = GetPos();
pos.z += Member<int>(0xaf8);
return pos;
};
const char* GetModifiedAssetString(const char* str) const {
return MemberInline<VClass>(0xA38)->GetVFunc(67).Call<const char*>(str);
}
const char* GetSmallIcon() const {
return GetModifiedAssetString(GetIdentity()->GetName());
}
};