not working dispenser radar
This commit is contained in:
parent
fa5263a253
commit
a231bff4f6
BIN
res/bin/dispenser.o
Normal file
BIN
res/bin/dispenser.o
Normal file
Binary file not shown.
BIN
res/dispenser
Normal file
BIN
res/dispenser
Normal file
Binary file not shown.
BIN
res/dispenser.png
Normal file
BIN
res/dispenser.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
29
src/gui/ncc/Radar.cpp
Normal file
29
src/gui/ncc/Radar.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Radar.cpp
|
||||
*
|
||||
* Created on: Mar 28, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "Radar.hpp"
|
||||
#include "../../common.h"
|
||||
|
||||
namespace menu { namespace ncc {
|
||||
|
||||
Radar::Radar() : CBaseWidget("ncc_radar") {}
|
||||
|
||||
std::pair<int, int> Radar::GetSize() {
|
||||
return { (int)hacks::tf::radar::size, (int)hacks::tf::radar::size };
|
||||
}
|
||||
|
||||
void Radar::Update() {
|
||||
if (!hacks::tf::radar::radar_enabled) Hide();
|
||||
else Show();
|
||||
SetOffset((int)hacks::tf::radar::radar_x, (int)hacks::tf::radar::radar_y);
|
||||
if (IsPressed()) {
|
||||
hacks::tf::radar::radar_x = (int)hacks::tf::radar::radar_x + g_pGUI->mouse_dx;
|
||||
hacks::tf::radar::radar_y = (int)hacks::tf::radar::radar_y + g_pGUI->mouse_dy;
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
25
src/gui/ncc/Radar.hpp
Normal file
25
src/gui/ncc/Radar.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Radar.hpp
|
||||
*
|
||||
* Created on: Mar 28, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifndef RADAR_HPP_
|
||||
#define RADAR_HPP_
|
||||
|
||||
#include "../CBaseWidget.h"
|
||||
|
||||
namespace menu { namespace ncc {
|
||||
|
||||
class Radar : public CBaseWidget {
|
||||
public:
|
||||
Radar();
|
||||
virtual void Update() override;
|
||||
virtual std::pair<int, int> GetSize() override;
|
||||
//virtual void Draw() override;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif /* RADAR_HPP_ */
|
@ -8,6 +8,7 @@
|
||||
#include "Root.hpp"
|
||||
#include "Menu.hpp"
|
||||
#include "Tooltip.hpp"
|
||||
#include "Radar.hpp"
|
||||
#include "../../common.h"
|
||||
|
||||
namespace menu { namespace ncc {
|
||||
@ -32,6 +33,7 @@ void Root::Setup() {
|
||||
tooltip = new Tooltip();
|
||||
AddChild(tooltip);
|
||||
AddChild(&menu::ncc::MainList());
|
||||
AddChild(new Radar());
|
||||
menu::ncc::MainList().Show();
|
||||
menu::ncc::MainList().SetOffset(500, 500);
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ Texture textures[2][9] = {
|
||||
}
|
||||
};
|
||||
|
||||
Texture buildings[1] = { Texture(&_binary_dispenser_start, 128, 128) };
|
||||
|
||||
CatVar size(CV_INT, "radar_size", "300", "Radar size", "Defines radar size in pixels");
|
||||
CatVar zoom(CV_FLOAT, "radar_zoom", "20", "Radar zoom", "Defines radar zoom (1px = Xhu)");
|
||||
CatVar healthbar(CV_SWITCH, "radar_health", "1", "Radar healthbar", "Show radar healthbar");
|
||||
@ -81,21 +83,39 @@ std::pair<int, int> WorldToRadar(int x, int y) {
|
||||
|
||||
void DrawEntity(int x, int y, CachedEntity* ent) {
|
||||
if (CE_GOOD(ent)) {
|
||||
if (CE_BYTE(ent, netvar.iLifeState)) return; // DEAD. not big surprise.
|
||||
const int& clazz = CE_INT(ent, netvar.iClass);
|
||||
const int& team = CE_INT(ent, netvar.iTeamNum);
|
||||
int idx = team - 2;
|
||||
if (idx < 0 || idx > 1) return;
|
||||
if (clazz <= 0 || clazz > 9) return;
|
||||
const auto& wtr = WorldToRadar(ent->m_vecOrigin.x, ent->m_vecOrigin.y);
|
||||
textures[idx][clazz - 1].Draw(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size);
|
||||
draw::OutlineRect(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size, idx ? colors::blu_v : colors::red_v);
|
||||
if (ent->m_iMaxHealth && healthbar) {
|
||||
float healthp = (float)ent->m_iHealth / (float)ent->m_iMaxHealth;
|
||||
int clr = colors::Health(ent->m_iHealth, ent->m_iMaxHealth);
|
||||
if (healthp > 1.0f) healthp = 1.0f;
|
||||
draw::OutlineRect(x + wtr.first, y + wtr.second + (int)icon_size, (int)icon_size, 4, colors::black);
|
||||
draw::DrawRect(x + wtr.first + 1, y + wtr.second + (int)icon_size + 1, ((float)icon_size - 2.0f) * healthp, 2, clr);
|
||||
if (ent->m_Type == ENTITY_PLAYER) {
|
||||
if (CE_BYTE(ent, netvar.iLifeState)) return; // DEAD. not big surprise.
|
||||
const int& clazz = CE_INT(ent, netvar.iClass);
|
||||
const int& team = CE_INT(ent, netvar.iTeamNum);
|
||||
int idx = team - 2;
|
||||
if (idx < 0 || idx > 1) return;
|
||||
if (clazz <= 0 || clazz > 9) return;
|
||||
const auto& wtr = WorldToRadar(ent->m_vecOrigin.x, ent->m_vecOrigin.y);
|
||||
textures[idx][clazz - 1].Draw(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size);
|
||||
draw::OutlineRect(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size, idx ? colors::blu_v : colors::red_v);
|
||||
if (ent->m_iMaxHealth && healthbar) {
|
||||
float healthp = (float)ent->m_iHealth / (float)ent->m_iMaxHealth;
|
||||
int clr = colors::Health(ent->m_iHealth, ent->m_iMaxHealth);
|
||||
if (healthp > 1.0f) healthp = 1.0f;
|
||||
draw::OutlineRect(x + wtr.first, y + wtr.second + (int)icon_size, (int)icon_size, 4, colors::black);
|
||||
draw::DrawRect(x + wtr.first + 1, y + wtr.second + (int)icon_size + 1, ((float)icon_size - 2.0f) * healthp, 2, clr);
|
||||
}
|
||||
} else if (ent->m_Type == ENTITY_BUILDING) {
|
||||
/*if (ent->m_iClassID == g_pClassID->CObjectDispenser) {
|
||||
const int& team = CE_INT(ent, netvar.iTeamNum);
|
||||
int idx = team - 2;
|
||||
if (idx < 0 || idx > 1) return;
|
||||
const auto& wtr = WorldToRadar(ent->m_vecOrigin.x, ent->m_vecOrigin.y);
|
||||
buildings[0].Draw(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size, idx ? colors::blu : colors::red );
|
||||
draw::OutlineRect(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size, idx ? colors::blu_v : colors::red_v);
|
||||
if (ent->m_iMaxHealth && healthbar) {
|
||||
float healthp = (float)ent->m_iHealth / (float)ent->m_iMaxHealth;
|
||||
int clr = colors::Health(ent->m_iHealth, ent->m_iMaxHealth);
|
||||
if (healthp > 1.0f) healthp = 1.0f;
|
||||
draw::OutlineRect(x + wtr.first, y + wtr.second + (int)icon_size, (int)icon_size, 4, colors::black);
|
||||
draw::DrawRect(x + wtr.first + 1, y + wtr.second + (int)icon_size + 1, ((float)icon_size - 2.0f) * healthp, 2, clr);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,10 +130,11 @@ void Draw() {
|
||||
draw::DrawLine(x, y + (int)size / 2, (int)size, 0, GUIColor());
|
||||
static std::vector<CachedEntity*> enemies {};
|
||||
if (enemies_over_teammates) enemies.clear();
|
||||
for (int i = 1; i < 32 && i < HIGHEST_ENTITY; i++) {
|
||||
for (int i = 1; i < HIGHEST_ENTITY; i++) {
|
||||
CachedEntity* ent = ENTITY(i);
|
||||
if (CE_BAD(ent)) continue;
|
||||
if (i == g_IEngine->GetLocalPlayer()) continue;
|
||||
if (!enemies_over_teammates) DrawEntity(x, y, ent);
|
||||
if (!enemies_over_teammates || ent->m_Type != ENTITY_PLAYER) DrawEntity(x, y, ent);
|
||||
else {
|
||||
if (ent->m_bEnemy) enemies.push_back(ent);
|
||||
else DrawEntity(x, y, ent);
|
||||
|
@ -30,12 +30,19 @@ extern unsigned char _binary_sniper_blue_start;
|
||||
extern unsigned char _binary_spy_start;
|
||||
extern unsigned char _binary_spy_blue_start;
|
||||
|
||||
extern unsigned char _binary_dispenser_start;
|
||||
|
||||
namespace hacks { namespace tf { namespace radar {
|
||||
|
||||
extern Texture textures[2][9];
|
||||
extern Texture buildings[1];
|
||||
|
||||
extern CatVar size;
|
||||
extern CatVar zoom;
|
||||
extern CatVar radar_enabled;
|
||||
extern CatVar radar_x;
|
||||
extern CatVar radar_y;
|
||||
|
||||
|
||||
void Init();
|
||||
std::pair<int, int> WorldToRadar(int x, int y);
|
||||
|
@ -24,9 +24,9 @@ void Texture::Load() {
|
||||
g_ISurface->DrawSetTextureRGBAEx(id, start_addr, w, h, ImageFormat::IMAGE_FORMAT_RGBA8888);
|
||||
}
|
||||
|
||||
void Texture::Draw(int x, int y, int sw, int sh) {
|
||||
void Texture::Draw(int x, int y, int sw, int sh, int color) {
|
||||
if (!g_ISurface->IsTextureIDValid(id)) throw std::runtime_error("Invalid texture ID!");
|
||||
g_ISurface->DrawSetColor(255, 255, 255, 255);
|
||||
g_ISurface->DrawSetColor(*reinterpret_cast<Color*>(&color));
|
||||
g_ISurface->DrawSetTexture(id);
|
||||
g_ISurface->DrawTexturedRect(x, y, x + sw, y + sh);
|
||||
}
|
||||
|
@ -8,12 +8,14 @@
|
||||
#ifndef RESOURCE_HPP_
|
||||
#define RESOURCE_HPP_
|
||||
|
||||
#include "drawing.h"
|
||||
|
||||
class Texture {
|
||||
public:
|
||||
Texture(unsigned char* start, unsigned w, unsigned h);
|
||||
~Texture();
|
||||
void Load();
|
||||
void Draw(int x, int y, int w, int h);
|
||||
void Draw(int x, int y, int w, int h, int color = colors::Create(255, 255, 255, 255));
|
||||
public:
|
||||
int id { 0 };
|
||||
const unsigned char* const start_addr;
|
||||
|
Reference in New Issue
Block a user