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

Commit

Permalink
区分死斗和正常respawn
Browse files Browse the repository at this point in the history
  • Loading branch information
huoji120 committed Oct 8, 2023
1 parent 337bf4b commit 2693ae3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions csgo2/csgo2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpplatest</LanguageStandard>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
8 changes: 4 additions & 4 deletions csgo2/offset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ uint64_t MaxPlayerNumsPtr;
HashFunction_t FnServerHashFunction;
StateChanged_t FnStateChanged;
NetworkStateChanged_t FnNetworkStateChanged;
RespawnPlayer_t FnRespawnPlayer;
RespawnPlayerInDeathMatch_t FnRespawnPlayerInDeathMatch;
GiveNamedItem_t FnGiveNamedItem;
EntityRemove_t FnEntityRemove;
UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
Expand Down Expand Up @@ -71,7 +71,7 @@ auto Init() -> bool {
server.FindPattern(pattern_CreateCCSGameRulesInterFacePtr)
.ToAbsolute(3, 0)
.Get(CCSGameRulesInterFacePtr);
server.FindPattern(pattern_FnRespawnPlayer).Get(FnRespawnPlayer);
server.FindPattern(pattern_FnRespawnPlayerInDeathMatch).Get(FnRespawnPlayerInDeathMatch);
server.FindPattern(pattern_FnEntityRemove).Get(FnEntityRemove);
server.FindPattern(pattern_FnGiveNamedItemPtr).Get(FnGiveNamedItem);
server.FindPattern(pattern_fnHost_SayPtr).Get(Host_SayPtr);
Expand Down Expand Up @@ -123,7 +123,7 @@ auto Init() -> bool {
LOG("[huoji]FnNetworkStateChanged : %llx \n", FnNetworkStateChanged);
LOG("[huoji]FnServerHashFunction : %llx \n", FnServerHashFunction);
LOG("[huoji]FnStateChanged : %llx \n", FnStateChanged);
LOG("[huoji]FnRespawnPlayer : %llx \n", FnRespawnPlayer);
LOG("[huoji]FnRespawnPlayerInDeathMatch : %llx \n", FnRespawnPlayerInDeathMatch);
LOG("[huoji]FnGiveNamedItem : %llx \n", FnGiveNamedItem);
LOG("[huoji]FnClientPrint : %llx \n", FnClientPrint);
LOG("[huoji]FnUTIL_ClientPrintAll : %llx \n", FnUTIL_ClientPrintAll);
Expand Down Expand Up @@ -154,7 +154,7 @@ auto Init() -> bool {
0, NULL);
// LOG("FnServerHashFunction: %llx \n", FnServerHashFunction("here",
// sizeof("here") - 1, 0x31415926));
return FnCCSWeaponBase_Spawn && FnEntityRemove && FnRespawnPlayer && FnGiveNamedItem &&
return FnCCSWeaponBase_Spawn && FnEntityRemove && FnRespawnPlayerInDeathMatch && FnGiveNamedItem &&
FnServerHashFunction && Host_SayPtr && InterFaces::IVEngineServer &&
InterFaces::GameResourceServiceServer &&
InterFaces::IServerGameClient && InterFaces::GameEventManager &&
Expand Down
7 changes: 4 additions & 3 deletions csgo2/offset.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ typedef void(__fastcall* StateChanged_t)(void* networkTransmitComponent,
typedef void(__fastcall* NetworkStateChanged_t)(uintptr_t chainEntity,
uintptr_t offset, uintptr_t a3);
typedef void*(__fastcall* CreateGameRuleInterFace_t)();
typedef bool(__fastcall* RespawnPlayer_t)(CCSPlayerPawn* player);
typedef bool(__fastcall* RespawnPlayerInDeathMatch_t)(CCSPlayerPawn* player);
typedef void(__fastcall* GiveNamedItem_t)(void* itemService,
const char* pchName, void* iSubType,
void* pScriptItem, void* a5,
Expand All @@ -26,7 +26,6 @@ typedef void*(__fastcall* UTIL_SayTextFilter_t)(IRecipientFilter&, const char*,
typedef void(__fastcall* UTIL_ClientPrintAll_t)(int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4);
typedef void(__fastcall* ClientPrint_t)(CCSPlayerController* player, int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4);
typedef void(__fastcall* CCSWeaponBase_Spawn_t)(CBaseEntity*, void*);

class CSchemaSystem;
class CGameResourceService;
class CLocalize;
Expand Down Expand Up @@ -79,6 +78,8 @@ static const auto pattern_CreateCCSGameRulesInterFacePtr = THE_GAME_SIG(
"?? ?? 4C 8D ?? ?? ?? 49 8B ?? ?? 49 8B ?? ?? 49 8B ?? ?? 49 8B E3 41 5F "
"41 5E 5F C3");
static const auto pattern_FnRespawnPlayer = THE_GAME_SIG(
"48 89 ?? ?? ?? 48 89 ?? ?? ?? 56 48 ?? ?? ?? ?? ?? ?? 48 8B DA 48 8B E9 48 85 D2 0F ?? ?? ?? ?? ?? 48 8B 02 48 8B CA FF ?? ?? ?? ?? ?? 84 C0 0F ?? ?? ?? ?? ?? 83 BB ?? ?? ?? ?? ?? 0F ?? ?? ?? ?? ??");
static const auto pattern_FnRespawnPlayerInDeathMatch = THE_GAME_SIG(
"48 89 ?? ?? ?? 57 48 ?? ?? ?? 48 8D ?? ?? ?? 48 8B F9 E8 ?? ?? ?? ?? 83 "
"?? ?? 74 ?? 48 ?? ?? ?? ?? ?? ?? 48 8B CF 48 8B 10 48 8B ?? ?? ?? ?? ?? "
"48 8D ?? ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? ?? ?? ?? ??");
Expand All @@ -102,7 +103,7 @@ extern uint64_t MaxPlayerNumsPtr;
extern HashFunction_t FnServerHashFunction;
extern StateChanged_t FnStateChanged;
extern NetworkStateChanged_t FnNetworkStateChanged;
extern RespawnPlayer_t FnRespawnPlayer;
extern RespawnPlayerInDeathMatch_t FnRespawnPlayerInDeathMatch;
extern GiveNamedItem_t FnGiveNamedItem;
extern EntityRemove_t FnEntityRemove;
extern UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
Expand Down
17 changes: 16 additions & 1 deletion csgo2/script_apis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ auto luaApi_SetPlayerCurrentWeaponAmmo(lua_State* luaVm) -> int {
lua_pop(luaVm, 3);
return 0;
}
//
auto luaApi_RespawnPlayer(lua_State* luaVm) -> int {
const auto playerIndex = lua_tointeger(luaVm, 1);
int playerArmorValue = 0;
Expand All @@ -120,7 +121,20 @@ auto luaApi_RespawnPlayer(lua_State* luaVm) -> int {
if (playerPawn == nullptr) {
return;
}
Offset::FnRespawnPlayer(playerPawn);
Offset::InterFaces::CCSGameRulesInterFace->PlayerRespawn(playerPawn);
});
return 0;
}
auto luaApi_RespawnPlayerInDeathMatch(lua_State* luaVm) -> int {
const auto playerIndex = lua_tointeger(luaVm, 1);
int playerArmorValue = 0;
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
const auto playerPawn =
playerController->m_hPawn().Get<CCSPlayerPawn>();
if (playerPawn == nullptr) {
return;
}
Offset::FnRespawnPlayerInDeathMatch(playerPawn);
});
return 0;
}
Expand Down Expand Up @@ -753,6 +767,7 @@ auto initFunciton(lua_State* luaVm) -> void {
lua_register(luaVm, "luaApi_SetPlayerArmorValue",
luaApi_SetPlayerArmorValue);
lua_register(luaVm, "luaApi_RespawnPlayer", luaApi_RespawnPlayer);
lua_register(luaVm, "luaApi_RespawnPlayerInDeathMatch", luaApi_RespawnPlayerInDeathMatch);
lua_register(luaVm, "luaApi_CreateTimer", luaApi_CreateTimer);
lua_register(luaVm, "luaApi_CreateTickRunFunction",
luaApi_CreateTickRunFunction);
Expand Down
4 changes: 3 additions & 1 deletion loader/loader/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <document.h>
struct _Config
{
std::string dll;
std::string path;
std::string command;
};
Expand All @@ -32,9 +33,10 @@ namespace Config {
for (rapidjson::SizeType i = 0; i < servers.Size(); i++) { // Uses SizeType instead of size_t
const rapidjson::Value& server = servers[i];
assert(server.IsObject()); // Each server should be an object.
if (server.HasMember("path") && server["path"].IsString() && server.HasMember("command") && server["command"].IsString())
if (server.HasMember("path") && server["path"].IsString() && server.HasMember("command") && server["command"].IsString() && server.HasMember("dll") && server["dll"].IsString())
{
configs.push_back(_Config{
.dll = server["dll"].GetString(),
.path = server["path"].GetString(),
.command = server["command"].GetString()
});
Expand Down
1 change: 1 addition & 0 deletions loader/loader/loader.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down

0 comments on commit 2693ae3

Please sign in to comment.