Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
- Modified some events for more target information
Browse files Browse the repository at this point in the history
- Added more events to replay
- Added more icons
  • Loading branch information
v0idp committed Feb 11, 2022
1 parent a96a2bf commit 9309d5b
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 41 deletions.
3 changes: 3 additions & 0 deletions AmongUsMenu.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,12 @@
</ItemGroup>
<ItemGroup>
<Image Include="resources\airship.png" />
<Image Include="resources\kill.png" />
<Image Include="resources\mira_hq.png" />
<Image Include="resources\polus.png" />
<Image Include="resources\the_skald.png" />
<Image Include="resources\vent_in.png" />
<Image Include="resources\vent_out.png" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resources\resource_data.rc" />
Expand Down
9 changes: 9 additions & 0 deletions AmongUsMenu.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,15 @@
<Image Include="resources\airship.png">
<Filter>resources</Filter>
</Image>
<Image Include="resources\vent_in.png">
<Filter>resources</Filter>
</Image>
<Image Include="resources\vent_out.png">
<Filter>resources</Filter>
</Image>
<Image Include="resources\kill.png">
<Filter>resources</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<None Include="framework\version.def">
Expand Down
3 changes: 2 additions & 1 deletion events/KillEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#include "_events.h"
#include "utility.h"

KillEvent::KillEvent(EVENT_PLAYER source, EVENT_PLAYER target, Vector2 position) : EventInterface(source, EVENT_KILL) {
KillEvent::KillEvent(EVENT_PLAYER source, EVENT_PLAYER target, Vector2 position, Vector2 targetPosition) : EventInterface(source, EVENT_KILL) {
this->target = target;
this->targetPosition = targetPosition;
this->position = position;
this->systemType = GetSystemTypes(position);
}
Expand Down
3 changes: 2 additions & 1 deletion events/ReportDeadBodyEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#include "_events.h"
#include "utility.h"

ReportDeadBodyEvent::ReportDeadBodyEvent(EVENT_PLAYER source, std::optional<EVENT_PLAYER> target, Vector2 position)
ReportDeadBodyEvent::ReportDeadBodyEvent(EVENT_PLAYER source, std::optional<EVENT_PLAYER> target, Vector2 position, std::optional<Vector2> targetPosition)
: EventInterface(source, (target.has_value() ? EVENT_REPORT : EVENT_MEETING)) {
this->target = target;
this->position = position;
this->targetPosition = targetPosition;
this->systemType = GetSystemTypes(position);
}

Expand Down
38 changes: 21 additions & 17 deletions events/_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ using namespace app;
#define EVENT_TYPES_SIZE 11

enum EVENT_TYPES {
EVENT_KILL = 0,
EVENT_VENT = 1,
EVENT_TASK = 2,
EVENT_REPORT = 3,
EVENT_MEETING = 4,
EVENT_VOTE = 5,
EVENT_CHEAT = 6,
EVENT_DISCONNECT = 7,
EVENT_SHAPESHIFT = 8,
EVENT_PROTECTPLAYER = 9,
EVENT_WALK = 10
EVENT_KILL,
EVENT_VENT,
EVENT_TASK,
EVENT_REPORT,
EVENT_MEETING,
EVENT_VOTE,
EVENT_CHEAT,
EVENT_DISCONNECT,
EVENT_SHAPESHIFT,
EVENT_PROTECTPLAYER,
EVENT_WALK
};

enum VENT_ACTIONS {
VENT_ENTER = 0x0,
VENT_EXIT = 0x1
VENT_ENTER,
VENT_EXIT
};

enum CHEAT_ACTIONS {
CHEAT_TELEPORT = 0x0,
CHEAT_KILL_IMPOSTOR = 0x1
CHEAT_TELEPORT,
CHEAT_KILL_IMPOSTOR
};

const std::vector<const char*> CHEAT_ACTION_NAMES = { "Teleporting", "Killed impostor" };
Expand Down Expand Up @@ -96,13 +96,15 @@ class KillEvent : public EventInterface {
private:
EVENT_PLAYER target;
Vector2 position;
Vector2 targetPosition;
SystemTypes__Enum systemType;
public:
KillEvent(EVENT_PLAYER source, EVENT_PLAYER target, Vector2 position);
KillEvent(EVENT_PLAYER source, EVENT_PLAYER target, Vector2 position, Vector2 targetPosition);
virtual void Output() override;
virtual void ColoredEventOutput() override;
std::optional<EVENT_PLAYER> GetTarget() { return this->target; }
Vector2 GetPosition() { return this->position; }
Vector2 GetTargetPosition() { return this->targetPosition; }
SystemTypes__Enum GetSystemType() { return this->systemType; }
};

Expand Down Expand Up @@ -154,13 +156,15 @@ class ReportDeadBodyEvent : public EventInterface {
private:
std::optional<EVENT_PLAYER> target;
Vector2 position;
std::optional<Vector2> targetPosition;
SystemTypes__Enum systemType;
public:
ReportDeadBodyEvent(EVENT_PLAYER source, std::optional<EVENT_PLAYER> target, Vector2 position);
ReportDeadBodyEvent(EVENT_PLAYER source, std::optional<EVENT_PLAYER> target, Vector2 position, std::optional<Vector2> targetPosition);
virtual void Output() override;
virtual void ColoredEventOutput() override;
std::optional<EVENT_PLAYER> GetTarget() { return this->target; }
Vector2 GetPosition() { return this->position; }
std::optional<Vector2> GetTargetPosition() { return this->targetPosition; }
SystemTypes__Enum GetSystemType() { return this->systemType; }
};

Expand Down
59 changes: 47 additions & 12 deletions gui/replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,35 +134,70 @@ namespace Replay
if (e->getType() == EVENT_TYPES::EVENT_KILL)
{
auto kill_event = dynamic_cast<KillEvent*>(e);
auto position = kill_event->GetPosition();
float mapX = maps[MapType].x_offset + (position.x * maps[MapType].scale) + winpos.x;
float mapY = maps[MapType].y_offset - (position.y * maps[MapType].scale) + winpos.y;

// TODO replace with proper icon
drawList->AddCircleFilled(ImVec2(mapX, mapY), 4.5F, GetReplayPlayerColor(e->getSource().colorId));
auto position = kill_event->GetTargetPosition();
IconTexture icon = icons.at(ICON_TYPES::KILL);
float mapX = maps[MapType].x_offset + (position.x - (icon.iconImage.imageWidth * icon.scale * 0.5f)) * maps[MapType].scale + winpos.x;
float mapY = maps[MapType].y_offset - (position.y - (icon.iconImage.imageHeight * icon.scale * 0.5f)) * maps[MapType].scale + winpos.y;
float mapXMax = maps[MapType].x_offset + (position.x + (icon.iconImage.imageWidth * icon.scale * 0.5f)) * maps[MapType].scale + winpos.x;
float mapYMax = maps[MapType].y_offset - (position.y + (icon.iconImage.imageHeight * icon.scale * 0.5f)) * maps[MapType].scale + winpos.y;

drawList->AddImage((void*)icon.iconImage.shaderResourceView,
ImVec2(mapX, mapY),
ImVec2(mapXMax, mapYMax),
ImVec2(0.0f, 1.0f),
ImVec2(1.0f, 0.0f));
}
else if (e->getType() == EVENT_TYPES::EVENT_VENT)
{
auto vent_event = dynamic_cast<VentEvent*>(e);
auto position = vent_event->GetPosition();
float mapX = maps[MapType].x_offset + (position.x * maps[MapType].scale) + winpos.x;
float mapY = maps[MapType].y_offset - (position.y * maps[MapType].scale) + winpos.y;
ICON_TYPES iconType;

switch (vent_event->GetEventActionEnum())
{
case VENT_ACTIONS::VENT_ENTER:
// TODO replace with proper icon
drawList->AddCircleFilled(ImVec2(mapX, mapY), 4.5F, GetReplayPlayerColor(e->getSource().colorId));
iconType = ICON_TYPES::VENT_IN;
break;

case VENT_ACTIONS::VENT_EXIT:
// TODO replace with proper icon
drawList->AddCircleFilled(ImVec2(mapX, mapY), 4.5F, GetReplayPlayerColor(e->getSource().colorId));
iconType = ICON_TYPES::VENT_OUT;
break;

default:
iconType = ICON_TYPES::VENT_IN;
break;
}

IconTexture icon = icons.at(iconType);
float mapX = maps[MapType].x_offset + (position.x - (icon.iconImage.imageWidth * icon.scale * 0.5f)) * maps[MapType].scale + winpos.x;
float mapY = maps[MapType].y_offset - (position.y - (icon.iconImage.imageHeight * icon.scale * 0.5f)) * maps[MapType].scale + winpos.y;
float mapXMax = maps[MapType].x_offset + (position.x + (icon.iconImage.imageWidth * icon.scale * 0.5f)) * maps[MapType].scale + winpos.x;
float mapYMax = maps[MapType].y_offset - (position.y + (icon.iconImage.imageHeight * icon.scale * 0.5f)) * maps[MapType].scale + winpos.y;

drawList->AddImage((void*)icon.iconImage.shaderResourceView,
ImVec2(mapX, mapY),
ImVec2(mapXMax, mapYMax),
ImVec2(0.0f, 1.0f),
ImVec2(1.0f, 0.0f));
}
else if (e->getType() == EVENT_TYPES::EVENT_REPORT)
{
auto report_event = dynamic_cast<ReportDeadBodyEvent*>(e);
Vector2 position = report_event->GetPosition();
auto targetPos = report_event->GetTargetPosition();
if (targetPos.has_value())
position = targetPos.value();
IconTexture icon = icons.at(ICON_TYPES::KILL);
float mapX = maps[MapType].x_offset + (position.x - (icon.iconImage.imageWidth * icon.scale * 0.5f)) * maps[MapType].scale + winpos.x;
float mapY = maps[MapType].y_offset - (position.y - (icon.iconImage.imageHeight * icon.scale * 0.5f)) * maps[MapType].scale + winpos.y;
float mapXMax = maps[MapType].x_offset + (position.x + (icon.iconImage.imageWidth * icon.scale * 0.5f)) * maps[MapType].scale + winpos.x;
float mapYMax = maps[MapType].y_offset - (position.y + (icon.iconImage.imageHeight * icon.scale * 0.5f)) * maps[MapType].scale + winpos.y;

drawList->AddImage((void*)icon.iconImage.shaderResourceView,
ImVec2(mapX, mapY),
ImVec2(mapXMax, mapYMax),
ImVec2(0.0f, 1.0f),
ImVec2(1.0f, 0.0f));
}
else if (e->getType() == EVENT_TYPES::EVENT_WALK)
{
Expand Down
5 changes: 5 additions & 0 deletions hooks/DirectX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ HANDLE DirectX::hRenderSemaphore;
constexpr DWORD MAX_RENDER_THREAD_COUNT = 5; //Should be overkill for our purposes

std::vector<MapTexture> maps = std::vector<MapTexture>();
std::unordered_map<ICON_TYPES, IconTexture> icons;

typedef struct Cache
{
Expand Down Expand Up @@ -120,6 +121,10 @@ bool ImGuiInitialization(IDXGISwapChain* pSwapChain) {
maps.push_back({ D3D11Image(Resource(IDB_PNG3), pDevice), 8.F, 21.F, 10.F });
maps.push_back({ D3D11Image(Resource(IDB_PNG4), pDevice), 162.F, 107.F, 6.F });

icons.insert({ ICON_TYPES::VENT_IN, { D3D11Image(Resource(IDB_PNG5), pDevice), 0.02f }});
icons.insert({ ICON_TYPES::VENT_OUT, { D3D11Image(Resource(IDB_PNG6), pDevice), 0.02f }});
icons.insert({ ICON_TYPES::KILL, { D3D11Image(Resource(IDB_PNG7), pDevice), 0.02f } });

DirectX::hRenderSemaphore = CreateSemaphore(
NULL, // default security attributes
MAX_RENDER_THREAD_COUNT, // initial count
Expand Down
13 changes: 13 additions & 0 deletions hooks/DirectX.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@
#include "resources.h"
#include "directx11.h"
#include <vector>
#include <unordered_map>
#include <imgui/imgui.h>

enum ICON_TYPES {
VENT_IN,
VENT_OUT,
KILL
};

struct MapTexture {
D3D11Image mapImage;
float x_offset;
float y_offset;
float scale;
};

struct IconTexture {
D3D11Image iconImage;
float scale;
};

extern std::vector<MapTexture> maps;
extern std::unordered_map<ICON_TYPES, IconTexture> icons;

extern D3D_PRESENT_FUNCTION oPresent;
HRESULT __stdcall dPresent(IDXGISwapChain* __this, UINT SyncInterval, UINT Flags);
Expand Down
21 changes: 13 additions & 8 deletions hooks/PlayerControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ void dPlayerControl_FixedUpdate(PlayerControl* __this, MethodInfo* method) {
app::PlayerControl_FixedUpdate(__this, method);
}

void dPlayerControl_RpcSyncSettings(PlayerControl* __this, GameOptionsData* gameOptions, MethodInfo* method) {
void dPlayerControl_RpcSyncSettings(PlayerControl* __this, GameOptionsData* gameOptions, MethodInfo* method)
{
State.PrevPlayerSpeed = gameOptions->fields.PlayerSpeedMod;
State.PlayerSpeed = gameOptions->fields.PlayerSpeedMod;
State.PrevKillDistance = gameOptions->fields.KillDistance;
Expand All @@ -186,24 +187,28 @@ void dPlayerControl_RpcSyncSettings(PlayerControl* __this, GameOptionsData* game
PlayerControl_RpcSyncSettings(__this, gameOptions, method);
}

void dPlayerControl_MurderPlayer(PlayerControl* __this, PlayerControl* target, MethodInfo* method) {

void dPlayerControl_MurderPlayer(PlayerControl* __this, PlayerControl* target, MethodInfo* method)
{
if (PlayerIsImpostor(GetPlayerData(__this)) && PlayerIsImpostor(GetPlayerData(target)))
{
State.events[__this->fields.PlayerId][EVENT_CHEAT].push_back(new CheatDetectedEvent(GetEventPlayerControl(__this).value(), CHEAT_KILL_IMPOSTOR));
State.consoleEvents.push_back(new CheatDetectedEvent(GetEventPlayerControl(__this).value(), CHEAT_KILL_IMPOSTOR));
}

State.events[__this->fields.PlayerId][EVENT_KILL].push_back(new KillEvent(GetEventPlayerControl(__this).value(), GetEventPlayerControl(target).value(), PlayerControl_GetTruePosition(__this, NULL)));
State.consoleEvents.push_back(new KillEvent(GetEventPlayerControl(__this).value(), GetEventPlayerControl(target).value(), PlayerControl_GetTruePosition(__this, NULL)));
State.events[__this->fields.PlayerId][EVENT_KILL].push_back(new KillEvent(GetEventPlayerControl(__this).value(), GetEventPlayerControl(target).value(), PlayerControl_GetTruePosition(__this, NULL), PlayerControl_GetTruePosition(target, NULL)));
State.consoleEvents.push_back(new KillEvent(GetEventPlayerControl(__this).value(), GetEventPlayerControl(target).value(), PlayerControl_GetTruePosition(__this, NULL), PlayerControl_GetTruePosition(target, NULL)));

PlayerControl_MurderPlayer(__this, target, method);
}

void dPlayerControl_ReportDeadBody(PlayerControl*__this, GameData_PlayerInfo* target, MethodInfo *method) {
void dPlayerControl_ReportDeadBody(PlayerControl*__this, GameData_PlayerInfo* target, MethodInfo *method)
{
std::optional<Vector2> targetPosition = std::nullopt;
if (target)
targetPosition = PlayerControl_GetTruePosition(target->fields._object, NULL);

State.events[__this->fields.PlayerId][(GetEventPlayer(target).has_value() ? EVENT_REPORT : EVENT_MEETING)].push_back(new ReportDeadBodyEvent(GetEventPlayerControl(__this).value(), GetEventPlayer(target), PlayerControl_GetTruePosition(__this, NULL)));
State.consoleEvents.push_back(new ReportDeadBodyEvent(GetEventPlayerControl(__this).value(), GetEventPlayer(target), PlayerControl_GetTruePosition(__this, NULL)));
State.events[__this->fields.PlayerId][(GetEventPlayer(target).has_value() ? EVENT_REPORT : EVENT_MEETING)].push_back(new ReportDeadBodyEvent(GetEventPlayerControl(__this).value(), GetEventPlayer(target), PlayerControl_GetTruePosition(__this, NULL), targetPosition));
State.consoleEvents.push_back(new ReportDeadBodyEvent(GetEventPlayerControl(__this).value(), GetEventPlayer(target), PlayerControl_GetTruePosition(__this, NULL), targetPosition));

PlayerControl_ReportDeadBody(__this, target, method);
}
Expand Down
2 changes: 1 addition & 1 deletion includes/imgui/imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ namespace ImGui
IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size, ImGuiButtonFlags flags = 0); // flexible button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& pos_offset, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& pos_offset = ImVec2(0, 0), const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
IMGUI_API bool Checkbox(const char* label, bool* v);
IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
Expand Down
Binary file added resources/kill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion resources/resource_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
#define IDB_PNG2 102
#define IDB_PNG3 103
#define IDB_PNG4 104
#define IDB_PNG5 105
#define IDB_PNG6 106
#define IDB_PNG7 107

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
Expand Down
6 changes: 6 additions & 0 deletions resources/resource_data.rc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ IDB_PNG3 PNG "polus.png"

IDB_PNG4 PNG "airship.png"

IDB_PNG5 PNG "vent_in.png"

IDB_PNG6 PNG "vent_out.png"

IDB_PNG7 PNG "kill.png"

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down
Binary file added resources/vent_in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/vent_out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions user/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class Settings {
bool LockRadar = false;

bool ShowReplay = false;
std::chrono::system_clock::time_point RoundStart;
std::chrono::system_clock::time_point RoundEnd;

bool ShowEsp = false;
bool ShowEsp_Ghosts = true;
Expand Down

0 comments on commit 9309d5b

Please sign in to comment.