• Я зарабатываю 100 000 RUB / месяц на этом сайте!

    А знаешь как? Я всего-лишь публикую (создаю темы), а админ мне платит. Трачу деньги на мороженое, робуксы и сервера в Minecraft. А ещё на паль из Китая. 

    Хочешь так же? Пиши и узнавай условия: https://t.me/alex_redact
    Реклама: https://t.me/yougame_official

Вопрос Issues with getting items and abilities

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
11 Фев 2023
Сообщения
126
Реакции
3
hello guys mostly iam trying to log the entity items and abilities

here is my code


GetItems() and GetAbilities():
Expand Collapse Copy
IGETTER(CDOTAUnitInventory, GetInventory, Offsets.m_Inventory);

std::span<CHandle<CDOTAItem>, 19> GetItems() const {
    return GetInventory()->GetItems();
}

std::span<CHandle<CDOTABaseAbility>, 35> GetAbilities() const {
    auto hAbilities = MemberInline<CHandle<CDOTABaseAbility>>(Offsets.m_hAbilities);
    return std::span<CHandle<CDOTABaseAbility>, 35>(hAbilities, 35);
}

// here is the GetInventory() -> GetItems()

std::span<CHandle<CDOTAItem>, 19> GetItems() {
    return std::span<CHandle<CDOTAItem>, 19>(MemberInline<CHandle<CDOTAItem>>(Offsets.m_hItems), 19);
}

// and here is how to use it
auto npc = reinterpret_cast<CDOTABaseNPC*>(const_cast<CBaseEntity*>(entity));
if (!npc || !IsValidReadPtr(npc)) {
    Logger::LogEntity("HERO: %s of address 0x%p - npc not accessible\n", entityName, entity);
    return;
}

auto npc = reinterpret_cast<CDOTABaseNPC*>(const_cast<CBaseEntity*>(entity));
if (!npc || !IsValidReadPtr(npc)) {
    Logger::LogEntity("HERO: %s of address 0x%p - npc not accessible\n", entityName, entity);
    return;
}

try {
    std::string abilitiesList = "[";
    int validAbilities = 0;
    auto abilities = npc->GetAbilities();
    for (size_t i = 0; i < abilities.size() && i < 10; i++) { // Limit to first 10 abilities
        try {
            auto abilityHandle = abilities[i];
            if (!abilityHandle.IsValid()) continue;
            auto ability = abilityHandle.Entity();
            if (!ability || !ability->GetIdentity() || !ability->GetIdentity()->GetName())
                continue;

            if (validAbilities > 0) abilitiesList += ", ";
            abilitiesList += std::string(ability->GetIdentity()->GetName());
            validAbilities++;
        } catch (...) {
            continue;
        }
    }
    abilitiesList += "]";
    Logger::LogEntity("HERO: %s of address 0x%p has abilities of %s (found %d valid abilities)\n",
                      entityName, entity, abilitiesList.c_str(), validAbilities);
} catch (...) {
    Logger::LogEntity("HERO: %s of address 0x%p - ERROR accessing abilities\n", entityName, entity);
}


// and the GetItems
auto items = npc->GetItems();
for (size_t i = 0; i < items.size() && i < 10; i++) { // Limit to first 10 items
    try {
        auto itemHandle = items[i];
        if (!itemHandle.IsValid()) continue;
        auto item = itemHandle.Entity();
        if (!item || !item->GetIdentity() || !item->GetIdentity()->GetName())
            continue;

        if (validItems > 0) itemsList += ", ";
        itemsList += std::string(item->GetIdentity()->GetName());
        validItems++;
    } catch (...) {
        continue;
    }
}
itemsList += "]";
Logger::LogEntity("HERO: %s of address 0x%p has items of %s (found %d valid items)\n",
                  entityName, entity, itemsList.c_str(), validItems);


i know iam doing something wrong but i cant figure it out at all
 
hello guys mostly iam trying to log the entity items and abilities

here is my code


GetItems() and GetAbilities():
Expand Collapse Copy
IGETTER(CDOTAUnitInventory, GetInventory, Offsets.m_Inventory);

std::span<CHandle<CDOTAItem>, 19> GetItems() const {
    return GetInventory()->GetItems();
}

std::span<CHandle<CDOTABaseAbility>, 35> GetAbilities() const {
    auto hAbilities = MemberInline<CHandle<CDOTABaseAbility>>(Offsets.m_hAbilities);
    return std::span<CHandle<CDOTABaseAbility>, 35>(hAbilities, 35);
}

// here is the GetInventory() -> GetItems()

std::span<CHandle<CDOTAItem>, 19> GetItems() {
    return std::span<CHandle<CDOTAItem>, 19>(MemberInline<CHandle<CDOTAItem>>(Offsets.m_hItems), 19);
}

// and here is how to use it
auto npc = reinterpret_cast<CDOTABaseNPC*>(const_cast<CBaseEntity*>(entity));
if (!npc || !IsValidReadPtr(npc)) {
    Logger::LogEntity("HERO: %s of address 0x%p - npc not accessible\n", entityName, entity);
    return;
}

auto npc = reinterpret_cast<CDOTABaseNPC*>(const_cast<CBaseEntity*>(entity));
if (!npc || !IsValidReadPtr(npc)) {
    Logger::LogEntity("HERO: %s of address 0x%p - npc not accessible\n", entityName, entity);
    return;
}

try {
    std::string abilitiesList = "[";
    int validAbilities = 0;
    auto abilities = npc->GetAbilities();
    for (size_t i = 0; i < abilities.size() && i < 10; i++) { // Limit to first 10 abilities
        try {
            auto abilityHandle = abilities[i];
            if (!abilityHandle.IsValid()) continue;
            auto ability = abilityHandle.Entity();
            if (!ability || !ability->GetIdentity() || !ability->GetIdentity()->GetName())
                continue;

            if (validAbilities > 0) abilitiesList += ", ";
            abilitiesList += std::string(ability->GetIdentity()->GetName());
            validAbilities++;
        } catch (...) {
            continue;
        }
    }
    abilitiesList += "]";
    Logger::LogEntity("HERO: %s of address 0x%p has abilities of %s (found %d valid abilities)\n",
                      entityName, entity, abilitiesList.c_str(), validAbilities);
} catch (...) {
    Logger::LogEntity("HERO: %s of address 0x%p - ERROR accessing abilities\n", entityName, entity);
}


// and the GetItems
auto items = npc->GetItems();
for (size_t i = 0; i < items.size() && i < 10; i++) { // Limit to first 10 items
    try {
        auto itemHandle = items[i];
        if (!itemHandle.IsValid()) continue;
        auto item = itemHandle.Entity();
        if (!item || !item->GetIdentity() || !item->GetIdentity()->GetName())
            continue;

        if (validItems > 0) itemsList += ", ";
        itemsList += std::string(item->GetIdentity()->GetName());
        validItems++;
    } catch (...) {
        continue;
    }
}
itemsList += "]";
Logger::LogEntity("HERO: %s of address 0x%p has items of %s (found %d valid items)\n",
                  entityName, entity, itemsList.c_str(), validItems);


i know iam doing something wrong but i cant figure it out at all
it's m_vecAbilities and it's a cutlvector now. m_hItems is still an array though(25 items) but the first int is the size or something like that...
 
Назад
Сверху Снизу