atom0s
8 years ago
commit
e0fb8af501
9 changed files with 1722 additions and 0 deletions
@ -0,0 +1,221 @@
@@ -0,0 +1,221 @@
|
||||
# ---> VisualStudio |
||||
## Ignore Visual Studio temporary files, build results, and |
||||
## files generated by popular Visual Studio add-ons. |
||||
|
||||
# User-specific files |
||||
*.suo |
||||
*.user |
||||
*.userosscache |
||||
*.sln.docstates |
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio) |
||||
*.userprefs |
||||
|
||||
# Build results |
||||
[Dd]ebug/ |
||||
[Dd]ebugPublic/ |
||||
[Rr]elease/ |
||||
[Rr]eleases/ |
||||
x64/ |
||||
x86/ |
||||
build/ |
||||
bld/ |
||||
[Bb]in/ |
||||
[Oo]bj/ |
||||
|
||||
# Visual Studio 2015 cache/options directory |
||||
.vs/ |
||||
# Uncomment if you have tasks that create the project's static files in wwwroot |
||||
#wwwroot/ |
||||
|
||||
# MSTest test Results |
||||
[Tt]est[Rr]esult*/ |
||||
[Bb]uild[Ll]og.* |
||||
|
||||
# NUNIT |
||||
*.VisualState.xml |
||||
TestResult.xml |
||||
|
||||
# Build Results of an ATL Project |
||||
[Dd]ebugPS/ |
||||
[Rr]eleasePS/ |
||||
dlldata.c |
||||
|
||||
# DNX |
||||
project.lock.json |
||||
artifacts/ |
||||
|
||||
*_i.c |
||||
*_p.c |
||||
*_i.h |
||||
*.ilk |
||||
*.meta |
||||
*.obj |
||||
*.pch |
||||
*.pdb |
||||
*.pgc |
||||
*.pgd |
||||
*.rsp |
||||
*.sbr |
||||
*.tlb |
||||
*.tli |
||||
*.tlh |
||||
*.tmp |
||||
*.tmp_proj |
||||
*.log |
||||
*.vspscc |
||||
*.vssscc |
||||
.builds |
||||
*.pidb |
||||
*.svclog |
||||
*.scc |
||||
|
||||
# Chutzpah Test files |
||||
_Chutzpah* |
||||
|
||||
# Visual C++ cache files |
||||
ipch/ |
||||
*.aps |
||||
*.ncb |
||||
*.opensdf |
||||
*.sdf |
||||
*.cachefile |
||||
|
||||
# Visual Studio profiler |
||||
*.psess |
||||
*.vsp |
||||
*.vspx |
||||
*.sap |
||||
|
||||
# TFS 2012 Local Workspace |
||||
$tf/ |
||||
|
||||
# Guidance Automation Toolkit |
||||
*.gpState |
||||
|
||||
# ReSharper is a .NET coding add-in |
||||
_ReSharper*/ |
||||
*.[Rr]e[Ss]harper |
||||
*.DotSettings.user |
||||
|
||||
# JustCode is a .NET coding add-in |
||||
.JustCode |
||||
|
||||
# TeamCity is a build add-in |
||||
_TeamCity* |
||||
|
||||
# DotCover is a Code Coverage Tool |
||||
*.dotCover |
||||
|
||||
# NCrunch |
||||
_NCrunch_* |
||||
.*crunch*.local.xml |
||||
nCrunchTemp_* |
||||
|
||||
# MightyMoose |
||||
*.mm.* |
||||
AutoTest.Net/ |
||||
|
||||
# Web workbench (sass) |
||||
.sass-cache/ |
||||
|
||||
# Installshield output folder |
||||
[Ee]xpress/ |
||||
|
||||
# DocProject is a documentation generator add-in |
||||
DocProject/buildhelp/ |
||||
DocProject/Help/*.HxT |
||||
DocProject/Help/*.HxC |
||||
DocProject/Help/*.hhc |
||||
DocProject/Help/*.hhk |
||||
DocProject/Help/*.hhp |
||||
DocProject/Help/Html2 |
||||
DocProject/Help/html |
||||
|
||||
# Click-Once directory |
||||
publish/ |
||||
|
||||
# Publish Web Output |
||||
*.[Pp]ublish.xml |
||||
*.azurePubxml |
||||
# TODO: Comment the next line if you want to checkin your web deploy settings |
||||
# but database connection strings (with potential passwords) will be unencrypted |
||||
*.pubxml |
||||
*.publishproj |
||||
|
||||
# NuGet Packages |
||||
*.nupkg |
||||
# The packages folder can be ignored because of Package Restore |
||||
**/packages/* |
||||
# except build/, which is used as an MSBuild target. |
||||
!**/packages/build/ |
||||
# Uncomment if necessary however generally it will be regenerated when needed |
||||
#!**/packages/repositories.config |
||||
|
||||
# Windows Azure Build Output |
||||
csx/ |
||||
*.build.csdef |
||||
|
||||
# Windows Store app package directory |
||||
AppPackages/ |
||||
|
||||
# Visual Studio cache files |
||||
# files ending in .cache can be ignored |
||||
*.[Cc]ache |
||||
# but keep track of directories ending in .cache |
||||
!*.[Cc]ache/ |
||||
|
||||
# Others |
||||
ClientBin/ |
||||
[Ss]tyle[Cc]op.* |
||||
~$* |
||||
*~ |
||||
*.dbmdl |
||||
*.dbproj.schemaview |
||||
*.pfx |
||||
*.publishsettings |
||||
node_modules/ |
||||
orleans.codegen.cs |
||||
|
||||
# RIA/Silverlight projects |
||||
Generated_Code/ |
||||
|
||||
# Backup & report files from converting an old project file |
||||
# to a newer Visual Studio version. Backup files are not needed, |
||||
# because we have git ;-) |
||||
_UpgradeReport_Files/ |
||||
Backup*/ |
||||
UpgradeLog*.XML |
||||
UpgradeLog*.htm |
||||
|
||||
# SQL Server files |
||||
*.mdf |
||||
*.ldf |
||||
|
||||
# Business Intelligence projects |
||||
*.rdl.data |
||||
*.bim.layout |
||||
*.bim_*.settings |
||||
|
||||
# Microsoft Fakes |
||||
FakesAssemblies/ |
||||
|
||||
# Node.js Tools for Visual Studio |
||||
.ntvs_analysis.dat |
||||
|
||||
# Visual Studio 6 build log |
||||
*.plg |
||||
|
||||
# Visual Studio 6 workspace options file |
||||
*.opt |
||||
|
||||
# Visual Studio LightSwitch build output |
||||
**/*.HTMLClient/GeneratedArtifacts |
||||
**/*.DesktopClient/GeneratedArtifacts |
||||
**/*.DesktopClient/ModelManifest.xml |
||||
**/*.Server/GeneratedArtifacts |
||||
**/*.Server/ModelManifest.xml |
||||
_Pvt_Extensions |
||||
|
||||
/Ashita.exp |
||||
/Ashita.lib |
@ -0,0 +1,219 @@
@@ -0,0 +1,219 @@
|
||||
#define RBUFP(p,pos) (((uint8_t*)(p)) + (pos)) |
||||
#define RBUFB(p,pos) (*(uint8_t*)RBUFP((p),(pos))) |
||||
#define RBUFW(p,pos) (*(uint16_t*)RBUFP((p),(pos))) |
||||
#define RBUFL(p,pos) (*(uint32_t*)RBUFP((p),(pos))) |
||||
#define RBUFF(p,pos) (*(float*)RBUFP((p),(pos))) |
||||
|
||||
#define WBUFP(p,pos) (((uint8_t*)(p)) + (pos)) |
||||
#define WBUFB(p,pos) (*(uint8_t*)WBUFP((p),(pos))) |
||||
#define WBUFW(p,pos) (*(uint16_t*)WBUFP((p),(pos))) |
||||
#define WBUFL(p,pos) (*(uint32_t*)WBUFP((p),(pos))) |
||||
#define WBUFF(p,pos) (*(float*)WBUFP((p),(pos))) |
||||
|
||||
#include <stdint.h> |
||||
|
||||
uint32_t packBitsBE(uint8_t* target, uint64_t value, int32_t byteOffset, int32_t bitOffset, uint8_t lengthInBit) |
||||
{ |
||||
byteOffset += (bitOffset >> 3); //correct bitOffsets>=8
|
||||
bitOffset %= 8; |
||||
|
||||
uint64_t bitmask = 0xFFFFFFFFFFFFFFFFLL; //Generate bitmask
|
||||
|
||||
bitmask >>= (64 - lengthInBit); |
||||
bitmask <<= bitOffset; |
||||
|
||||
value <<= bitOffset; //shift value
|
||||
value &= bitmask; |
||||
|
||||
bitmask ^= 0xFFFFFFFFFFFFFFFFLL; //invert bitmask
|
||||
|
||||
if ((lengthInBit + bitOffset) <= 8) //write shifted value to target
|
||||
{ |
||||
uint8_t* dataPointer = (uint8_t*)&target[byteOffset]; |
||||
|
||||
uint8_t bitmaskUC = (uint8_t)bitmask; |
||||
uint8_t valueUC = (uint8_t)value; |
||||
|
||||
*dataPointer &= bitmaskUC; |
||||
*dataPointer |= valueUC; |
||||
} |
||||
else if ((lengthInBit + bitOffset) <= 16) |
||||
{ |
||||
uint16_t* dataPointer = (uint16_t*)&target[byteOffset]; |
||||
|
||||
uint16_t bitmaskUC = (uint16_t)bitmask; |
||||
uint16_t valueUC = (uint16_t)value; |
||||
|
||||
*dataPointer &= bitmaskUC; |
||||
*dataPointer |= valueUC; |
||||
} |
||||
else if ((lengthInBit + bitOffset) <= 32) |
||||
{ |
||||
uint32_t* dataPointer = (uint32_t*)&target[byteOffset]; |
||||
|
||||
uint32_t bitmaskUC = (uint32_t)bitmask; |
||||
uint32_t valueUC = (uint32_t)value; |
||||
|
||||
*dataPointer &= bitmaskUC; |
||||
*dataPointer |= valueUC; |
||||
} |
||||
else if ((lengthInBit + bitOffset) <= 64) |
||||
{ |
||||
uint64_t* dataPointer = (uint64_t*)&target[byteOffset]; |
||||
|
||||
*dataPointer &= bitmask; |
||||
*dataPointer |= value; |
||||
} |
||||
else |
||||
{ |
||||
//ShowError("Pack Bits Error: packBitsBE(...) not implemented for targetsizes above 64 bits.\n Targetsize: %d\n", (lengthInBit + bitOffset));
|
||||
} |
||||
return ((byteOffset << 3) + bitOffset + lengthInBit); |
||||
} |
||||
|
||||
uint32_t packBitsBE(uint8_t* target, uint64_t value, int32_t bitOffset, uint8_t lengthInBit) |
||||
{ |
||||
return packBitsBE(target, value, 0, bitOffset, lengthInBit); |
||||
} |
||||
|
||||
uint64_t unpackBitsBE(uint8_t* target, int32_t byteOffset, int32_t bitOffset, uint8_t lengthInBit) |
||||
{ |
||||
byteOffset += (bitOffset >> 3); |
||||
bitOffset %= 8; |
||||
|
||||
uint64_t bitmask = 0xFFFFFFFFFFFFFFFFLL; |
||||
|
||||
bitmask >>= (64 - lengthInBit); |
||||
bitmask <<= bitOffset; |
||||
|
||||
uint64_t retVal; |
||||
|
||||
if ((lengthInBit + bitOffset) <= 8) |
||||
{ |
||||
uint8_t* dataPointer = (uint8_t*)&target[byteOffset]; |
||||
|
||||
retVal = ((*dataPointer)&(uint8_t)bitmask) >> bitOffset; |
||||
} |
||||
else if ((lengthInBit + bitOffset) <= 16) |
||||
{ |
||||
uint16_t* dataPointer = (uint16_t*)&target[byteOffset]; |
||||
|
||||
retVal = ((*dataPointer)&(uint16_t)bitmask) >> bitOffset; |
||||
} |
||||
else if ((lengthInBit + bitOffset) <= 32) |
||||
{ |
||||
uint32_t* dataPointer = (uint32_t*)&target[byteOffset]; |
||||
|
||||
retVal = ((*dataPointer)&(uint32_t)bitmask) >> bitOffset; |
||||
} |
||||
else if ((lengthInBit + bitOffset) <= 64) |
||||
{ |
||||
uint64_t* dataPointer = (uint64_t*)&target[byteOffset]; |
||||
|
||||
retVal = ((*dataPointer)&(uint64_t)bitmask) >> bitOffset; |
||||
} |
||||
else |
||||
{ |
||||
//ShowError("Unpack Bits Error: unpackBits(...) not implemented for targetsizes above 64 bits.\n Targetsize: %d\n", (lengthInBit + bitOffset));
|
||||
return 0; |
||||
} |
||||
return retVal; |
||||
} |
||||
|
||||
uint64_t unpackBitsBE(uint8_t* target, int32_t bitOffset, uint8_t lengthInBit) |
||||
{ |
||||
return unpackBitsBE(target, 0, bitOffset, lengthInBit); |
||||
} |
||||
|
||||
uint32_t packBitsLE(uint8_t* target, uint64_t value, int32_t byteOffset, int32_t bitOffset, uint8_t lengthInBit) |
||||
{ |
||||
byteOffset += (bitOffset >> 3); //correct bitOffsets >= 8
|
||||
bitOffset %= 8; |
||||
|
||||
uint8_t bytesNeeded; //calculate how many bytes are needed
|
||||
if ((bitOffset + lengthInBit) <= 8) |
||||
bytesNeeded = 1; |
||||
else if ((bitOffset + lengthInBit) <= 16) |
||||
bytesNeeded = 2; |
||||
else if ((bitOffset + lengthInBit) <= 32) |
||||
bytesNeeded = 4; |
||||
else if ((bitOffset + lengthInBit) <= 64) |
||||
bytesNeeded = 8; |
||||
else |
||||
{ |
||||
//ShowError("Pack Bits Error: packBitsLE(...) not implemented for targetsizes above 64 bits.\n Targetsize: %d\n", (lengthInBit + bitOffset));
|
||||
return 0; |
||||
} |
||||
|
||||
uint8_t* modifiedTarget = new uint8_t[bytesNeeded]; //convert byteOrder to Big Endian
|
||||
|
||||
for (uint8_t curByte = 0; curByte < bytesNeeded; ++curByte) |
||||
{ |
||||
modifiedTarget[curByte] = target[byteOffset + (bytesNeeded - 1) - curByte]; |
||||
} |
||||
|
||||
int32_t newBitOffset = (bytesNeeded << 3) - (bitOffset + lengthInBit); //calculate new bitOffset
|
||||
|
||||
packBitsBE(&modifiedTarget[0], value, 0, newBitOffset, lengthInBit); //write data to modified array
|
||||
|
||||
for (uint8_t curByte = 0; curByte < bytesNeeded; ++curByte) //copy back to target
|
||||
{ |
||||
target[byteOffset + (bytesNeeded - 1) - curByte] = modifiedTarget[curByte]; |
||||
} |
||||
|
||||
if (modifiedTarget) delete[] modifiedTarget; |
||||
return ((byteOffset << 3) + bitOffset + lengthInBit); |
||||
} |
||||
|
||||
uint32_t packBitsLE(uint8_t* target, uint64_t value, int32_t bitOffset, uint8_t lengthInBit) |
||||
{ |
||||
return packBitsLE(target, value, 0, bitOffset, lengthInBit); |
||||
} |
||||
|
||||
uint64_t unpackBitsLE(uint8_t* target, int32_t byteOffset, int32_t bitOffset, uint8_t lengthInBit) |
||||
{ |
||||
byteOffset += (bitOffset >> 3); |
||||
bitOffset %= 8; |
||||
|
||||
uint8_t bytesNeeded; |
||||
if ((bitOffset + lengthInBit) <= 8) |
||||
bytesNeeded = 1; |
||||
else if ((bitOffset + lengthInBit) <= 16) |
||||
bytesNeeded = 2; |
||||
else if ((bitOffset + lengthInBit) <= 32) |
||||
bytesNeeded = 4; |
||||
else if ((bitOffset + lengthInBit) <= 64) |
||||
bytesNeeded = 8; |
||||
else |
||||
{ |
||||
//ShowError("Unpack Bits Error: packBitsLE(...) not implemented for targetsizes above 64 bits.\n Targetsize: %d\n", (lengthInBit + bitOffset));
|
||||
return 0; |
||||
} |
||||
|
||||
uint64_t retVal; |
||||
|
||||
uint8_t* modifiedTarget = new uint8_t[bytesNeeded]; |
||||
|
||||
for (uint8_t curByte = 0; curByte < bytesNeeded; ++curByte) |
||||
{ |
||||
modifiedTarget[curByte] = target[byteOffset + (bytesNeeded - 1) - curByte]; |
||||
} |
||||
if (bytesNeeded == 1) |
||||
{ |
||||
uint8_t bitmask = 0xFF >> bitOffset; |
||||
retVal = (modifiedTarget[0] & bitmask) >> (8 - (lengthInBit + bitOffset)); |
||||
} |
||||
else |
||||
{ |
||||
int32_t newBitOffset = (bytesNeeded * 8) - (bitOffset + lengthInBit); |
||||
retVal = unpackBitsBE(&modifiedTarget[0], 0, newBitOffset, lengthInBit); |
||||
} |
||||
|
||||
if (modifiedTarget) delete[]modifiedTarget; |
||||
return retVal; |
||||
} |
||||
|
||||
uint64_t unpackBitsLE(uint8_t* target, int32_t bitOffset, uint8_t lengthInBit) |
||||
{ |
||||
return unpackBitsLE(target, 0, bitOffset, lengthInBit); |
||||
} |
@ -0,0 +1,220 @@
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* Copyright (c) 2011-2014 - Ashita Development Team |
||||
* |
||||
* Ashita is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* Ashita is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Ashita. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef __ASHITA_Deeps_H_INCLUDED__ |
||||
#define __ASHITA_Deeps_H_INCLUDED__ |
||||
|
||||
#if defined (_MSC_VER) && (_MSC_VER >= 1020) |
||||
#pragma once |
||||
#endif |
||||
|
||||
enum REACTION |
||||
{ |
||||
REACTION_NONE = 0x00, |
||||
REACTION_MISS = 0x01, |
||||
REACTION_PARRY = 0x03, |
||||
REACTION_BLOCK = 0x04, |
||||
REACTION_HIT = 0x08, |
||||
REACTION_EVADE = 0x09, |
||||
REACTION_HIT2 = 0x10, |
||||
REACTION_GUARD = 0x14 |
||||
}; |
||||
|
||||
enum SPECEFFECT |
||||
{ |
||||
SPECEFFECT_NONE = 0x00, |
||||
SPECEFFECT_BLOOD = 0x02, |
||||
SPECEFFECT_HIT = 0x10, |
||||
SPECEFFECT_RAISE = 0x11, |
||||
SPECEFFECT_RECOIL = 0x20, |
||||
SPECEFFECT_CRITICAL_HIT = 0x22 |
||||
}; |
||||
|
||||
/**
|
||||
* @brief Required includes for an extension. |
||||
*/ |
||||
#include "C:\Ashita 3\plugins\ADK\Ashita.h" |
||||
#include <map> |
||||
#include <functional> |
||||
#include <stdint.h> |
||||
|
||||
struct damage_t |
||||
{ |
||||
uint64_t total; |
||||
uint32_t max; |
||||
uint32_t min; |
||||
uint32_t count; |
||||
|
||||
damage_t() |
||||
{ |
||||
total = 0; |
||||
max = 0; |
||||
min = 0; |
||||
count = 0; |
||||
} |
||||
bool operator > (const damage_t& o) const |
||||
{ |
||||
return (count > o.count); |
||||
} |
||||
uint32_t avg() |
||||
{ |
||||
return count > 0 ? (total / count) : 0; |
||||
} |
||||
}; |
||||
|
||||
struct source_t |
||||
{ |
||||
std::string name; |
||||
std::map<const char*, damage_t> damage; |
||||
|
||||
source_t() |
||||
{ |
||||
|
||||
} |
||||
|
||||
uint64_t total() const |
||||
{ |
||||
uint64_t tot = 0; |
||||
for (auto d : damage) |
||||
{ |
||||
tot += d.second.total; |
||||
} |
||||
return tot; |
||||
} |
||||
|
||||
bool operator > (const source_t& o) const |
||||
{ |
||||
return (total() > o.total()); |
||||
} |
||||
}; |
||||
|
||||
struct entitysources_t |
||||
{ |
||||
std::string name; |
||||
uint32_t color; |
||||
std::map<uint32_t, source_t> sources; |
||||
|
||||
uint64_t total() const |
||||
{ |
||||
int64_t total = 0; |
||||
for (auto s : sources) |
||||
{ |
||||
total += s.second.total(); |
||||
} |
||||
return total; |
||||
} |
||||
bool operator == (const entitysources_t& o) const |
||||
{ |
||||
return (total() == o.total()); |
||||
} |
||||
|
||||
bool operator > (const entitysources_t& o) const |
||||
{ |
||||
return (total() > o.total()); |
||||
} |
||||
}; |
||||
|
||||
std::map<uint32_t, entitysources_t> entities; |
||||
std::map<IFontObject*, std::string> clickMap; |
||||
|
||||
static const std::vector<uint16_t> hitMessages = { 1, 2, 77, 132, 157, 161, 163, 185, 187, 197, 227, 264, 281, 317, 352, 413, 522, 576, 577 }; |
||||
static const std::vector<uint16_t> critMessages = { 67, 252, 265, 274, 353, 379 }; |
||||
static const std::vector<uint16_t> missMessages = { 15, 85, 158, 188, 245, 284, 324, 354 }; |
||||
static const std::vector<uint16_t> evadeMessages = { 14, 30, 31, 32, 33, 189, 248, 282, 283, 323, 355 }; |
||||
static const std::vector<uint16_t> parryMessages = { 69, 70 }; |
||||
|
||||
static const std::vector<D3DCOLOR> Colors = { D3DCOLOR_ARGB(255, 12, 0, 155), D3DCOLOR_ARGB(255, 140, 0, 0), D3DCOLOR_ARGB(255, 255, 177, 32), D3DCOLOR_ARGB(255, 143, 143, 143), |
||||
D3DCOLOR_ARGB(255, 68, 68, 68), D3DCOLOR_ARGB(255, 255, 0, 0), D3DCOLOR_ARGB(255, 0, 164, 49), D3DCOLOR_ARGB(255, 198, 198, 0), |
||||
D3DCOLOR_ARGB(255, 116, 0, 145), D3DCOLOR_ARGB(255, 165, 153, 10), D3DCOLOR_ARGB(255, 184, 128, 10), D3DCOLOR_ARGB(255, 224, 0, 230), |
||||
D3DCOLOR_ARGB(255, 234, 100, 0), D3DCOLOR_ARGB(255, 119, 0, 0), D3DCOLOR_ARGB(255, 130, 17, 255), D3DCOLOR_ARGB(255, 79, 196, 0), |
||||
D3DCOLOR_ARGB(255, 0, 16, 217), D3DCOLOR_ARGB(255, 136, 68, 0), D3DCOLOR_ARGB(255, 244, 98, 0), D3DCOLOR_ARGB(255, 15, 190, 220), |
||||
D3DCOLOR_ARGB(255, 0, 123, 145) }; |
||||
|
||||
void g_onClick(int, void*, float, float); |
||||
|
||||
/**
|
||||
* @brief Global copy of our plugin data. |
||||
*/ |
||||
plugininfo_t* g_PluginInfo = NULL; |
||||
|
||||
/**
|
||||
* @brief Our Main Plugin Class |
||||
* |
||||
* @note The main class of your plugin MUST use PluginBase as a base class. This is the |
||||
* internal base class that Ashita uses to communicate with your plugin! |
||||
*/ |
||||
class Deeps : IPlugin |
||||
{ |
||||
/**
|
||||
* @brief Internal class variables. |
||||
*/ |
||||
IAshitaCore* m_AshitaCore; |
||||
ILogManager* m_LogManager; |
||||
DWORD m_PluginId; |
||||
IDirect3DDevice8* m_Direct3DDevice; |
||||
|
||||
private: |
||||
source_t* getDamageSource(entitysources_t* entityInfo, uint8_t actionType, uint16_t actionID); |
||||
bool updateDamageSource(source_t* source, uint16_t message, uint32_t damage); |
||||
void repairBars(IFontObject* deepsBase, uint8_t size); |
||||
void report(char mode, int max); |
||||
uint16_t getIndex(std::function<bool(IEntity*, int)>); |
||||
uint32_t m_charInfo; |
||||
std::string m_sourceInfo; |
||||
uint8_t m_bars; |
||||
bool m_debug; |
||||
|
||||
public: |
||||
/**
|
||||
* @brief Constructor and deconstructor. |
||||
*/ |
||||
Deeps(void); |
||||
virtual ~Deeps(void); |
||||
|
||||
/**
|
||||
* @brief GetPluginData implementation. |
||||
*/ |
||||
plugininfo_t GetPluginInfo(void); |
||||
|
||||
/**
|
||||
* @brief PluginBase virtual overrides. |
||||
*/ |
||||
bool Initialize(IAshitaCore* core, ILogManager* log, uint32_t id); |
||||
void Release(void); |
||||
bool HandleCommand(const char* command, int32_t type); |
||||
bool HandleIncomingText(int16_t mode, const char* message, int16_t* modifiedMode, char* modifiedMessage, bool blocked); |
||||
bool HandleIncomingPacket(uint16_t id, uint32_t size, void* data, void* modified, bool blocked); |
||||
bool HandleOutgoingPacket(uint16_t id, uint32_t size, void* data, void* modified, bool blocked); |
||||
bool Direct3DInitialize(IDirect3DDevice8* device); |
||||
void Direct3DRelease(void); |
||||
void Direct3DPreRender(void); |
||||
void Direct3DRender(void); |
||||
void onClick(int, IFontObject*, float, float); |
||||
}; |
||||
|
||||
// Global pointer to this
|
||||
|
||||
Deeps* g_Deeps = NULL; |
||||
|
||||
/**
|
||||
* @brief Required Plugin Exports |
||||
*/ |
||||
__declspec(dllexport) double __stdcall GetInterfaceVersion(void); |
||||
__declspec(dllexport) void __stdcall CreatePluginInfo(plugininfo_t* lpBuffer); |
||||
__declspec(dllexport) IPlugin* __stdcall CreatePlugin(void); |
||||
|
||||
#endif // __ASHITA_Deeps_H_INCLUDED__
|
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
LIBRARY "Deeps" |
||||
EXPORTS |
||||
GetInterfaceVersion |
||||
CreatePluginInfo |
||||
CreatePlugin |
@ -0,0 +1,824 @@
@@ -0,0 +1,824 @@
|
||||
/**
|
||||
* Copyright (c) 2011-2014 - Ashita Development Team |
||||
* |
||||
* Ashita is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* Ashita is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Ashita. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#include "Deeps.h" |
||||
#include "DSP-Utils.h" |
||||
|
||||
#include <algorithm> |
||||
#include <thread> |
||||
|
||||
source_t* Deeps::getDamageSource(entitysources_t* entityInfo, uint8_t actionType, uint16_t actionID) |
||||
{ |
||||
uint32_t key = (actionID << 8) + actionType; |
||||
auto sourcesIt = entityInfo->sources.find(key); |
||||
|
||||
source_t* source; |
||||
|
||||
if (sourcesIt != entityInfo->sources.end()) |
||||
{ |
||||
source = &sourcesIt->second; |
||||
} |
||||
else |
||||
{ |
||||
source_t newsource; |
||||
|
||||
sourcesIt = entityInfo->sources.insert(std::make_pair(key, newsource)).first; |
||||
|
||||
source = &sourcesIt->second; |
||||
if (actionType == 1) { source->name.append("Attack"); } |
||||
else if (actionType == 2) { source->name.append("Ranged Attack"); } |
||||
else if (actionType == 3 || actionType == 11){ source->name.append(m_AshitaCore->GetResourceManager()->GetAbilityById(actionID)->Name[2]); } |
||||
else if (actionType == 4) { source->name.append(m_AshitaCore->GetResourceManager()->GetSpellById(actionID)->Name[2]); } |
||||
else if (actionType == 6 || actionType == 14 || actionType == 15) { source->name.append(m_AshitaCore->GetResourceManager()->GetAbilityById(actionID + 512)->Name[2]); } |
||||
|
||||
} |
||||
return source; |
||||
} |
||||
|
||||
bool Deeps::updateDamageSource(source_t* source, uint16_t message, uint32_t damage) |
||||
{ |
||||
damage_t* type = NULL; |
||||
bool val = false; |
||||
if (std::find(hitMessages.begin(), hitMessages.end(), message) != hitMessages.end()) |
||||
{ |
||||
type = &source->damage["Hit"]; |
||||
val = true; |
||||
} |
||||
else if (std::find(critMessages.begin(), critMessages.end(), message) != critMessages.end()) |
||||
{ |
||||
type = &source->damage["Crit"]; |
||||
val = true; |
||||
} |
||||
else if (std::find(missMessages.begin(), missMessages.end(), message) != missMessages.end()) |
||||
{ |
||||
type = &source->damage["Miss"]; |
||||
} |
||||
else if (std::find(evadeMessages.begin(), evadeMessages.end(), message) != evadeMessages.end()) |
||||
{ |
||||
type = &source->damage["Evade"]; |
||||
} |
||||
else if (std::find(parryMessages.begin(), parryMessages.end(), message) != parryMessages.end()) |
||||
{ |
||||
type = &source->damage["Parry"]; |
||||
} |
||||
if (type) |
||||
{ |
||||
damage = val ? damage : 0; |
||||
type->total += damage; |
||||
type->count++; |
||||
type->min = (damage < type->min ? damage : type->min); |
||||
type->max = (damage > type->max ? damage : type->max); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
uint16_t Deeps::getIndex(std::function<bool(IEntity*, int)> func) |
||||
{ |
||||
for (int i = 0; i < 2048; i++) |
||||
{ |
||||
if (func(m_AshitaCore->GetDataManager()->GetEntity(), i)) |
||||
{ |
||||
return i; |
||||
} |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Constructor and Deconstructor |
||||
*/ |
||||
Deeps::Deeps(void) |
||||
: m_AshitaCore(NULL) |
||||
, m_PluginId(0) |
||||
, m_Direct3DDevice(NULL) |
||||
{ } |
||||
Deeps::~Deeps(void) |
||||
{ } |
||||
|
||||
/**
|
||||
* @brief Obtains the plugin data for this plugin. |
||||
* |
||||
* @return The PluginData structure for this plugin. |
||||
*/ |
||||
plugininfo_t Deeps::GetPluginInfo(void) |
||||
{ |
||||
return (*g_PluginInfo); |
||||
} |
||||
|
||||
/**
|
||||
* @brief Initializes our plugin. This is the main call that happens when your plugin is loaded. |
||||
* |
||||
* @param ashitaCore The main Ashita Core object interface to interact with Ashita. |
||||
* @param scriptEngine The main script engine object interface to interact with the script engine. |
||||
* @param dwPluginId The base address of your plugin. This is used as the ID. |
||||
* |
||||
* @return True on success, false otherwise. |
||||
* |
||||
* @note If your plugin returns false here, it will be unloaded immediately! |
||||
*/ |
||||
bool Deeps::Initialize(IAshitaCore* core, ILogManager* log, uint32_t id) |
||||
{ |
||||
// Store the variables we are passed..
|
||||
this->m_AshitaCore = core; |
||||
this->m_PluginId = id; |
||||
this->m_LogManager = log; |
||||
|
||||
g_Deeps = this; |
||||
srand(time(NULL)); |
||||
|
||||
m_charInfo = 0; |
||||
m_bars = 0; |
||||
|
||||
m_AshitaCore->GetConfigurationManager()->Load("Deeps", "Deeps.xml"); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Releases this plugin. This is called when your plugin is unloaded. |
||||
* |
||||
* @note Your plugin should cleanup all its data here before it unloads. Anything such as: |
||||
* - Font objects. |
||||
* - Gui objects. |
||||
* - Bindings to the script engine (if you extended it any). |
||||
*/ |
||||
void Deeps::Release(void) |
||||
{ |
||||
} |
||||
|
||||
/**
|
||||
* @brief Allows a plugin to attempt to handle a game command. |
||||
* |
||||
* @param pszCommand The command being processed. |
||||
* @param nCommandType The type of command being processed. |
||||
* |
||||
* @return True on handled, false otherwise. |
||||
*/ |
||||
bool Deeps::HandleCommand(const char* command, int32_t type) |
||||
{ |
||||
std::vector<std::string> args; |
||||
auto count = Ashita::Commands::GetCommandArgs(command, &args); |
||||
if (count <= 0) return false; |
||||
HANDLECOMMAND("/deeps", "/dps") |
||||
{ |
||||
if (count >= 2) |
||||
{ |
||||
if (args[1] == "reset") |
||||
{ |
||||
entities.clear(); |
||||
m_sourceInfo.clear(); |
||||
m_charInfo = 0; |
||||
return true; |
||||
} |
||||
else if (args[1] == "report") |
||||
{ |
||||
char mode = 0x00; |
||||
int max = 3; |
||||
if (count > 2) |
||||
{ |
||||
if (std::all_of(args[2].begin(), args[2].end(), ::isdigit)) |
||||
{ |
||||
max = atoi(args[2].c_str()); |
||||
} |
||||
else |
||||
{ |
||||
mode = args[2][0]; |
||||
if (count > 3) |
||||
{ |
||||
if (std::all_of(args[2].begin(), args[2].end(), ::isdigit)) |
||||
{ |
||||
max = atoi(args[2].c_str()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
std::thread(&Deeps::report, this, mode, max).detach(); |
||||
|
||||
return true; |
||||
} |
||||
else if (args[1] == "debug") |
||||
{ |
||||
m_debug = !m_debug; |
||||
if (m_debug) |
||||
{ |
||||
m_AshitaCore->GetChatManager()->AddChatMessage(5, "Deeps: Debug on"); |
||||
} |
||||
else |
||||
{ |
||||
m_AshitaCore->GetChatManager()->AddChatMessage(5, "Deeps: Debug off"); |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
m_AshitaCore->GetChatManager()->AddChatMessage(5, "Deeps usage: /dps reset, /dps report [s/p/l] [#]"); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
void Deeps::report(char mode, int max) |
||||
{ |
||||
IFontObject* deepsBase = m_AshitaCore->GetFontManager()->Get("DeepsBackground"); |
||||
if (deepsBase) |
||||
{ |
||||
std::string line; |
||||
char buff[256]; |
||||
if (mode != 0x00) |
||||
{ |
||||
sprintf_s(buff, 256, "/%c ", mode); |
||||
line.append(buff); |
||||
} |
||||
line.append(deepsBase->GetText()); |
||||
m_AshitaCore->GetChatManager()->QueueCommand(line.c_str(), (int32_t)Ashita::CommandInputType::Typed); |
||||
for (int i = 0; i < m_bars; i++) |
||||
{ |
||||
if (i > max) |
||||
break; |
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1100)); |
||||
line.clear(); |
||||
memset(buff, sizeof buff, 0); |
||||
if (mode != 0x00) |
||||
{ |
||||
sprintf_s(buff, 256, "/%c ", mode); |
||||
line.append(buff); |
||||
} |
||||
sprintf_s(buff, 256, "%d -", i + 1); |
||||
line.append(buff); |
||||
char name[32]; |
||||
sprintf_s(name, 32, "DeepsBar%d", i); |
||||
IFontObject* bar = m_AshitaCore->GetFontManager()->Get(name); |
||||
line.append(bar->GetText()); |
||||
m_AshitaCore->GetChatManager()->QueueCommand(line.c_str(), (int32_t)Ashita::CommandInputType::Typed); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Allows a plugin to attempt to handle a new chat line. |
||||
* |
||||
* @param sMode The chat type being added. |
||||
* @param pszChatLine The chat line being added. |
||||
* |
||||
* @return True on handled, false otherwise. |
||||
*/ |
||||
bool Deeps::HandleIncomingText(int16_t mode, const char* message, int16_t* modifiedMode, char* modifiedMessage, bool blocked) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Allows a plugin to attempt to handle an incoming packet. |
||||
* |
||||
* @param uiPacketId The id of the packet. |
||||
* @param uiPacketSize The size of the packet. |
||||
* @param lpRawData The raw packet data. |
||||
* |
||||
* @return True on handled, false otherwise. |
||||
* |
||||
* @note Returning true on this will block the packet from being handled! This can |
||||
* have undesired effects! Use with caution as this can get you banned! |
||||
*/ |
||||
bool Deeps::HandleIncomingPacket(uint16_t id, uint32_t size, void* data, void* modified, bool blocked) |
||||
{ |
||||
if (id == 0x28) //action
|
||||
{ |
||||
uint8_t actionNum = (uint8_t)(unpackBitsBE((unsigned char*)data, 182, 4)); |
||||
uint8_t targetNum = RBUFB(data, 0x09); |
||||
uint8_t actionType = (uint8_t)(unpackBitsBE((unsigned char*)data, 82, 4)); |
||||
//uint8_t reaction = 0;
|
||||
//uint8_t speceffect = 0;
|
||||
uint16_t actionID = (uint16_t)(unpackBitsBE((unsigned char*)data, 86, 10)); |
||||
uint32_t userID = RBUFL(data, 0x05); |
||||
uint16_t startBit = 150; |
||||
uint16_t damage = 0; |
||||
|
||||
if (userID > 0x1000000) |
||||
return false; |
||||
|
||||
auto it = entities.find(userID); |
||||
entitysources_t* entityInfo = NULL; |
||||
|
||||
if (it != entities.end()) |
||||
{ |
||||
entityInfo = &it->second; |
||||
} |
||||
else |
||||
{ |
||||
uint16_t index = getIndex([&](IEntity* entities, int i){if (entities->GetServerId(i) == userID) return true; return false; }); |
||||
if (index != 0) |
||||
{ |
||||
entitysources_t newInfo; |
||||
newInfo.name = m_AshitaCore->GetDataManager()->GetEntity()->GetName(index); |
||||
newInfo.color = Colors[rand() % Colors.size()]; |
||||
entityInfo = &entities.insert(std::make_pair(userID, newInfo)).first->second; |
||||
} |
||||
} |
||||
|
||||
if (entityInfo) |
||||
{ |
||||
if (m_debug) |
||||
{ |
||||
m_AshitaCore->GetChatManager()->Writef("Action Type: %d Action ID: %d", actionType, actionID); |
||||
} |
||||
|
||||
if ((actionType >= 1 && actionType <= 4) || (actionType == 6) || (actionType == 11) || (actionType == 14) || (actionType == 15)) |
||||
{ |
||||
if (actionID == 0) |
||||
return false; |
||||
source_t* source = getDamageSource(entityInfo, actionType, actionID); |
||||
uint16_t messageID = (uint16_t)(unpackBitsBE((unsigned char*)data, startBit + 80, 10)); |
||||
|
||||
uint32_t addEffectDamage = 0; |
||||
uint8_t addEffectCount = 0; |
||||
uint16_t addMessageID = 0; |
||||
for (int i = 0; i < targetNum; i++) |
||||
{ |
||||
for (int j = 0; j < actionNum; j++) |
||||
{ |
||||
uint8_t reaction = (uint8_t)(unpackBitsBE((unsigned char*)data, startBit + 36, 5)); |
||||
uint16_t animation = (uint16_t)(unpackBitsBE((unsigned char*)data, startBit + 41, 12)); |
||||
uint32_t mainDamage = (uint16_t)(unpackBitsBE((unsigned char*)data, startBit + 63, 17)); |
||||
uint8_t speceffect = (uint8_t)(unpackBitsBE((unsigned char*)data, startBit + 53, 9)); |
||||
|
||||
if (m_debug) |
||||
{ |
||||
m_AshitaCore->GetChatManager()->Writef("Reaction: %d Animation: %d", reaction, animation); |
||||
m_AshitaCore->GetChatManager()->Writef("Speceffect: %d Param: %d", speceffect, mainDamage); |
||||
} |
||||
|
||||
//Daken (ranged attack on attack)
|
||||
if (actionType == 1 && animation == 4) |
||||
source = getDamageSource(entityInfo, actionType+1, actionID); |
||||
|
||||
if (!updateDamageSource(source, messageID, mainDamage)) |
||||
return false; |
||||
|
||||
if ((unpackBitsBE((unsigned char*)data, startBit + 121, 1) & 0x1) && actionType != 6) |
||||
{ |
||||
addMessageID = (uint16_t)(unpackBitsBE((unsigned char*)data, startBit + 149, 10)); |
||||
if (addMessageID == 163 || addMessageID == 229 || (addMessageID >= 288 && addMessageID <= 302)) |
||||
{ |
||||
addEffectDamage = (uint16_t)(unpackBitsBE((unsigned char*)data, startBit + 132, 16)); |
||||
uint32_t key = 0; |
||||
if (addMessageID == 163 || addMessageID == 229) |
||||
key = 1 << 8; |
||||
else |
||||
key = 2 << 8; |
||||
auto sourcesIt = entityInfo->sources.find(key); |
||||
|
||||
source_t* source; |
||||
|
||||
if (sourcesIt != entityInfo->sources.end()) |
||||
{ |
||||
source = &sourcesIt->second; |
||||
} |
||||
else |
||||
{ |
||||
source_t newsource; |
||||
if (key == 1 << 8) { newsource.name.append("Additional Effect"); } |
||||
else { newsource.name.append("Skillchain"); } |
||||
|
||||
sourcesIt = entityInfo->sources.insert(std::make_pair(key, newsource)).first; |
||||
source = &sourcesIt->second; |
||||
} |
||||
source->damage["Hit"].count += 1; |
||||
source->damage["Hit"].total += addEffectDamage; |
||||
source->damage["Hit"].min = (addEffectDamage < source->damage["Hit"].min ? addEffectDamage : source->damage["Hit"].min); |
||||
source->damage["Hit"].max = (addEffectDamage > source->damage["Hit"].max ? addEffectDamage : source->damage["Hit"].max); |
||||
} |
||||
|
||||
startBit += 37; |
||||
} |
||||
startBit += 1; |
||||
if (unpackBitsBE((unsigned char*)data, startBit + 121, 1) & 0x1) |
||||
{ |
||||
startBit += 34; |
||||
} |
||||
startBit += 86; |
||||
} |
||||
startBit += 36; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Allows a plugin to attempt to handle an outgoing packet. |
||||
* |
||||
* @param uiPacketId The id of the packet. |
||||
* @param uiPacketSize The size of the packet. |
||||
* @param lpRawData The raw packet data. |
||||
* |
||||
* @return True on handled, false otherwise. |
||||
* |
||||
* @note Returning true on this will block the packet from being handled! This can |
||||
* have undesired effects! Use with caution as this can get you banned! |
||||
*/ |
||||
bool Deeps::HandleOutgoingPacket(uint16_t id, uint32_t size, void* data, void* modified, bool blocked) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Direct3D initialize call to prepare this plugin for Direct3D calls. |
||||
* |
||||
* @param lpDevice The Direct3D device currently wrapped by Ashita. |
||||
* |
||||
* @return True on success, false otherwise. |
||||
* |
||||
* @note Plugins that do not return true on this call will not receive any other |
||||
* Direct3D calls listed below! |
||||
*/ |
||||
bool Deeps::Direct3DInitialize(IDirect3DDevice8* device) |
||||
{ |
||||
this->m_Direct3DDevice = device; |
||||
|
||||
float xpos = m_AshitaCore->GetConfigurationManager()->get_float("Deeps", "xpos", 300.0f); |
||||
float ypos = m_AshitaCore->GetConfigurationManager()->get_float("Deeps", "ypos", 300.0f); |
||||
|
||||
IFontObject* font = m_AshitaCore->GetFontManager()->Create("DeepsBackground"); |
||||
font->SetFontFamily("Consolas"); |
||||
font->SetFontHeight(10); |
||||
font->SetAutoResize(false); |
||||
font->GetBackground()->SetColor(D3DCOLOR_ARGB(0xCC, 0x00, 0x00, 0x00)); |
||||
font->GetBackground()->SetVisibility(true); |
||||
font->GetBackground()->SetWidth(158); |
||||
font->GetBackground()->SetHeight(256); |
||||
font->SetColor(D3DCOLOR_ARGB(0xFF, 0xFF, 0xFF, 0xFF)); |
||||
font->SetBold(false); |
||||
font->SetText(""); |
||||
font->SetPositionX(xpos); |
||||
font->SetPositionY(ypos); |
||||
font->SetVisibility(true); |
||||
font->SetMouseEventFunction(g_onClick); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Direct3D release call to allow this plugin to cleanup any Direct3D objects. |
||||
*/ |
||||
void Deeps::Direct3DRelease(void) |
||||
{ |
||||
IFontObject* deepsBase = m_AshitaCore->GetFontManager()->Get("DeepsBackground"); |
||||
|
||||
m_AshitaCore->GetConfigurationManager()->set_value("Deeps", "xpos", std::to_string(deepsBase->GetPositionX()).c_str()); |
||||
m_AshitaCore->GetConfigurationManager()->set_value("Deeps", "ypos", std::to_string(deepsBase->GetPositionY()).c_str()); |
||||
m_AshitaCore->GetConfigurationManager()->Save("Deeps", "Deeps.xml"); |
||||
|
||||
m_AshitaCore->GetFontManager()->Delete("DeepsBackground"); |
||||
|
||||
for (int i = 0; i < m_bars; i++) |
||||
{ |
||||
char name[32]; |
||||
sprintf_s(name, 32, "DeepsBar%d", i); |
||||
m_AshitaCore->GetFontManager()->Delete(name); |
||||
memset(name, 0, sizeof name); |
||||
sprintf_s(name, 32, "DeepsBarClick%d", i); |
||||
m_AshitaCore->GetFontManager()->Delete(name); |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Direct3D prerender call to allow this plugin to prepare for rendering. |
||||
* |
||||
* @note This will only be called if you returned true in Direct3DInitialize! |
||||
*/ |
||||
void Deeps::Direct3DPreRender(void) |
||||
{ |
||||
} |
||||
|
||||
/**
|
||||
* @brief Direct3D render call to allow this plugin to render any custom things. |
||||
* |
||||
* @note This will only be called if you returned true in Direct3DInitialize! |
||||
*/ |
||||
void Deeps::Direct3DRender(void) |
||||
{ |
||||
IFontObject* deepsBase = m_AshitaCore->GetFontManager()->Get("DeepsBackground"); |
||||
|
||||
if (m_charInfo == 0) |
||||
{ |
||||
deepsBase->SetText(" Deeps - Damage Done"); |
||||
deepsBase->GetBackground()->SetWidth(158); |
||||
std::vector<entitysources_t> temp; |
||||
uint64_t total = 0; |
||||
for (auto e : entities) |
||||
{ |
||||
if (e.second.total() != 0 && temp.size() < 15) |
||||
{ |
||||
temp.push_back(e.second); |
||||
total += e.second.total(); |
||||
} |
||||
} |
||||
std::sort(temp.begin(), temp.end(), [](entitysources_t a, entitysources_t b){return a > b; }); |
||||
repairBars(deepsBase, temp.size()); |
||||
|
||||
int i = 0; |
||||
uint64_t max = 0; |
||||
clickMap.clear(); |
||||
for (auto e : temp) |
||||
{ |
||||
char name[32]; |
||||
sprintf_s(name, 32, "DeepsBar%d", i); |
||||
IFontObject* bar = m_AshitaCore->GetFontManager()->Get(name); |
||||
if (e.total() > max) max = e.total(); |
||||
bar->GetBackground()->SetWidth(150 * (total == 0 ? 1 : ((float)e.total() / (float)max))); |
||||
bar->GetBackground()->SetColor(e.color); |
||||
char string[256]; |
||||
sprintf_s(string, 256, " %-10.10s %6llu %03.1f%%\n", e.name.c_str(), e.total(), total == 0 ? 0 : 100 * ((float)e.total() / (float)total)); |
||||
bar->SetText(string); |
||||
memset(name, 0, sizeof name); |
||||
sprintf_s(name, 32, "DeepsBarClick%d", i); |
||||
bar = m_AshitaCore->GetFontManager()->Get(name); |
||||
bar->GetBackground()->SetWidth(150); |
||||
clickMap.insert(std::pair<IFontObject*, std::string>(bar, e.name)); |
||||
i++; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
auto it = entities.find(m_charInfo); |
||||
if (it != entities.end()) |
||||
{ |
||||
if (m_sourceInfo == "") |
||||
{ |
||||
std::vector<source_t> temp; |
||||
uint64_t total = 0; |
||||
for (auto s : it->second.sources) |
||||
{ |
||||
if (s.second.total() != 0 && temp.size() < 15) |
||||
{ |
||||
temp.push_back(s.second); |
||||
total += s.second.total(); |
||||
} |
||||
} |
||||
std::sort(temp.begin(), temp.end(), [](source_t a, source_t b){return a > b; }); |
||||
char string[256]; |
||||
sprintf_s(string, 256, " %s - Sources\n", it->second.name.c_str()); |
||||
deepsBase->SetText(string); |
||||
deepsBase->GetBackground()->SetWidth(158); |
||||
|
||||
repairBars(deepsBase, temp.size()); |
||||
int i = 0; |
||||
uint64_t max = 0; |
||||
clickMap.clear(); |
||||
for (auto s : temp) |
||||
{ |
||||
char name[32]; |
||||
sprintf_s(name, 32, "DeepsBar%d", i); |
||||
IFontObject* bar = m_AshitaCore->GetFontManager()->Get(name); |
||||
if (s.total() > max) max = s.total(); |
||||
bar->GetBackground()->SetWidth(150 * (total == 0 ? 1 : ((float)s.total() / (float)max))); |
||||
bar->GetBackground()->SetColor(it->second.color); |
||||
char string[256]; |
||||
sprintf_s(string, 256, " %-10.10s %6llu %03.1f%%\n", s.name.c_str(), s.total(), total == 0 ? 0 : 100 * ((float)s.total() / (float)total)); |
||||
bar->SetText(string); |
||||
memset(name, 0, sizeof name); |
||||
sprintf_s(name, 32, "DeepsBarClick%d", i); |
||||
bar = m_AshitaCore->GetFontManager()->Get(name); |
||||
bar->GetBackground()->SetWidth(150); |
||||
clickMap.insert(std::pair<IFontObject*, std::string>(bar, s.name)); |
||||
i++; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
for (auto s : it->second.sources) |
||||
{ |
||||
if (s.second.name == m_sourceInfo) |
||||
{ |
||||
std::vector<std::pair<const char*, damage_t> > temp; |
||||
uint32_t count = 0; |
||||
for (auto d : s.second.damage) |
||||
{ |
||||
if (d.second.count != 0 && temp.size() < 15) |
||||
{ |
||||
temp.push_back(d); |
||||
count += d.second.count; |
||||
} |
||||
} |
||||
std::sort(temp.begin(), temp.end(), [](std::pair<const char*, damage_t> a, std::pair<const char*, damage_t> b){return a.second > b.second; }); |
||||
char string[256]; |
||||
sprintf_s(string, 256, " %s - %s\n", it->second.name.c_str(), s.second.name.c_str()); |
||||
deepsBase->SetText(string); |
||||
deepsBase->GetBackground()->SetWidth(262); |
||||
repairBars(deepsBase, temp.size()); |
||||
int i = 0; |
||||
uint32_t max = 0; |
||||
for (auto s : temp) |
||||
{ |
||||
char name[32]; |
||||
sprintf_s(name, 32, "DeepsBar%d", i); |
||||
IFontObject* bar = m_AshitaCore->GetFontManager()->Get(name); |
||||
if (s.second.count > max) max = s.second.count; |
||||
bar->GetBackground()->SetWidth(254 * (count == 0 ? 1 : 1 * ((float)s.second.count / (float)max))); |
||||
bar->GetBackground()->SetColor(it->second.color); |
||||
char string[256]; |
||||
sprintf_s(string, 256, " %-5s Cnt:%4d Avg:%5d Max:%5d %3.1f%%\n", s.first, s.second.count, s.second.avg(), s.second.max, count == 0 ? 0 : 100 * ((float)s.second.count / (float)count)); |
||||
bar->SetText(string); |
||||
i++; |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
deepsBase->GetBackground()->SetHeight(m_bars * 16 + 17); |
||||
} |
||||
|
||||
void Deeps::repairBars(IFontObject* deepsBase, uint8_t size) |
||||
{ |
||||
IFontObject* previous = deepsBase; |
||||
if (m_AshitaCore->GetFontManager()->Get("DeepsBar0") != NULL) |
||||
{ |
||||
char name[32] = "DeepsBar0"; |
||||
int i = 1; |
||||
while (m_AshitaCore->GetFontManager()->Get(name) != NULL) |
||||
{ |
||||
previous = m_AshitaCore->GetFontManager()->Get(name); |
||||
sprintf_s(name, 32, "DeepsBar%d", i); |
||||
i++; |
||||
} |
||||
} |
||||
while (m_bars != size) |
||||
{ |
||||
if (m_bars > size) |
||||
{ |
||||
char name[32]; |
||||
sprintf_s(name, 32, "DeepsBar%d", m_bars - 1); |
||||
m_AshitaCore->GetFontManager()->Delete(name); |
||||
memset(name, 0, sizeof name); |
||||
sprintf_s(name, 32, "DeepsBarClick%d", m_bars - 1); |
||||
m_AshitaCore->GetFontManager()->Delete(name); |
||||
m_bars--; |
||||
} |
||||
else if (m_bars < size) |
||||
{ |
||||
char name[32]; |
||||
sprintf_s(name, 32, "DeepsBar%d", m_bars); |
||||
IFontObject* bar = m_AshitaCore->GetFontManager()->Create(name); |
||||
bar->SetParent(previous); |
||||
if (previous == deepsBase) |
||||
{ |
||||
bar->SetPositionX(4); |
||||
bar->SetPositionY(15); |
||||
} |
||||
else |
||||
{ |
||||
bar->SetAnchorParent((uint32_t)Ashita::FrameAnchor::BottomLeft); |
||||
bar->SetPositionX(0); |
||||
bar->SetPositionY(3); |
||||
} |
||||
bar->SetAutoResize(false); |
||||
bar->SetFontFamily("Consolas"); |
||||
bar->SetFontHeight(8); |
||||
bar->GetBackground()->SetColor(D3DCOLOR_ARGB(0xFF, 0x00, 0x7C, 0x5C)); |
||||
bar->GetBackground()->SetVisibility(true); |
||||
std::string path = m_AshitaCore->GetAshitaInstallPathA(); |
||||
path.append("\\Resources\\Deeps\\bar.tga"); |
||||
bar->GetBackground()->SetTextureFromFile(path.c_str()); |
||||
bar->GetBackground()->SetWidth(254); |
||||
bar->GetBackground()->SetHeight(13); |
||||
bar->SetVisibility(true); |
||||
|
||||
memset(name, 0, sizeof name); |
||||
sprintf_s(name, 32, "DeepsBarClick%d", m_bars); |
||||
IFontObject* clickBar = m_AshitaCore->GetFontManager()->Create(name); |
||||
clickBar->SetParent(bar); |
||||
clickBar->SetPositionX(0); |
||||
clickBar->SetPositionY(0); |
||||
clickBar->SetAutoResize(false); |
||||
clickBar->GetBackground()->SetColor(D3DCOLOR_ARGB(0x00, 0x00, 0x00, 0x00)); |
||||
clickBar->GetBackground()->SetVisibility(true); |
||||
clickBar->GetBackground()->SetWidth(254); |
||||
clickBar->GetBackground()->SetHeight(13); |
||||
clickBar->SetVisibility(true); |
||||
clickBar->SetMouseEventFunction(g_onClick); |
||||
|
||||
m_bars++; |
||||
previous = bar; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void Deeps::onClick(int type, IFontObject* font, float xPos, float yPos) |
||||
{ |
||||
if (type == 1 && font == m_AshitaCore->GetFontManager()->Get("DeepsBackground")) |
||||
{ |
||||
if (m_sourceInfo != "") |
||||
{ |
||||
m_sourceInfo = ""; |
||||
} |
||||
else |
||||
{ |
||||
m_charInfo = 0; |
||||
} |
||||
return; |
||||
} |
||||
|
||||
if (m_charInfo == 0) |
||||
{ |
||||
//Char was clicked
|
||||
if (type == 0) |
||||
{ |
||||
// left click
|
||||
try |
||||
{ |
||||
auto name = clickMap.at(font); |
||||
for (auto entity : entities) |
||||
{ |
||||
if (entity.second.name == name) |
||||
{ |
||||
m_charInfo = entity.first; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
catch (...) |
||||
{ |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
if (m_sourceInfo == "") |
||||
{ |
||||
//source was clicked
|
||||
if (type == 0) |
||||
{ |
||||
try |
||||
{ |
||||
auto name = clickMap.at(font); |
||||
m_sourceInfo.assign(name); |
||||
} |
||||
catch (...) |
||||
{ |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Gets the interface version this plugin was compiled with. |
||||
* |
||||
* @note This is a required export, your plugin must implement this! |
||||
*/ |
||||
__declspec(dllexport) double __stdcall GetInterfaceVersion(void) |
||||
{ |
||||
return ASHITA_INTERFACE_VERSION; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Gets the plugin data for this plugin. |
||||
* |
||||
* @note This is a required export, your plugin must implement this! |
||||
*/ |
||||
__declspec(dllexport) void __stdcall CreatePluginInfo(plugininfo_t* lpBuffer) |
||||
{ |
||||
g_PluginInfo = lpBuffer; |
||||
|
||||
strcpy_s(g_PluginInfo->Name, sizeof(g_PluginInfo->Name), "Deeps"); |
||||
strcpy_s(g_PluginInfo->Author, sizeof(g_PluginInfo->Author), "kjLotus"); |
||||
|
||||
g_PluginInfo->InterfaceVersion = ASHITA_INTERFACE_VERSION; |
||||
g_PluginInfo->PluginVersion = 2.03f; |
||||
g_PluginInfo->Priority = 0; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Creates an instance of this plugin object. |
||||
* |
||||
* @note This is a required export, your plugin must implement this! |
||||
*/ |
||||
__declspec(dllexport) IPlugin* __stdcall CreatePlugin(void) |
||||
{ |
||||
return (IPlugin*)new Deeps(); |
||||
} |
||||
|
||||
void g_onClick(int type, void* font, float xPos, float yPos) |
||||
{ |
||||
g_Deeps->onClick(type, (IFontObject*)font, xPos, yPos); |
||||
} |
Loading…
Reference in new issue