[Weapon]: PlayerCmd_initialWeaponRaise (#803)
This commit is contained in:
parent
538705c04d
commit
3a3cf77b06
@ -19,7 +19,7 @@ namespace Components
|
||||
// Probably a macro 'originally' but this is fine
|
||||
static Game::gentity_s* Scr_GetPlayerEntity(Game::scr_entref_t entref)
|
||||
{
|
||||
if (entref.classnum != 0)
|
||||
if (entref.classnum)
|
||||
{
|
||||
Game::Scr_ObjectError("not an entity");
|
||||
return nullptr;
|
||||
|
@ -548,6 +548,35 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
void Weapon::PlayerCmd_initialWeaponRaise(Game::scr_entref_t entref)
|
||||
{
|
||||
auto* ent = Script::Scr_GetPlayerEntity(entref);
|
||||
const auto* weapon = Game::Scr_GetString(0);
|
||||
const auto index = Game::G_GetWeaponIndexForName(weapon);
|
||||
|
||||
auto* ps = &ent->client->ps;
|
||||
if (!Game::BG_IsWeaponValid(ps, index))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
assert(ps);
|
||||
|
||||
if (!index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto* equippedWeapon = Game::BG_GetEquippedWeaponState(ps, index);
|
||||
if (!equippedWeapon)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
equippedWeapon->usedBefore = false;
|
||||
Game::Player_SwitchToWeapon(ent);
|
||||
}
|
||||
|
||||
void Weapon::AddScriptMethods()
|
||||
{
|
||||
Script::AddMethod("DisableWeaponPickup", [](Game::scr_entref_t entref)
|
||||
@ -563,6 +592,8 @@ namespace Components
|
||||
|
||||
ent->client->ps.weapCommon.weapFlags &= ~Game::PWF_DISABLE_WEAPON_PICKUP;
|
||||
});
|
||||
|
||||
Script::AddMethod("InitialWeaponRaise", PlayerCmd_initialWeaponRaise);
|
||||
}
|
||||
|
||||
Weapon::Weapon()
|
||||
|
@ -34,6 +34,9 @@ namespace Components
|
||||
static void JavelinResetHook_Stub();
|
||||
|
||||
static void WeaponEntCanBeGrabbed_Stub();
|
||||
|
||||
static void PlayerCmd_initialWeaponRaise(Game::scr_entref_t entref);
|
||||
|
||||
static void AddScriptMethods();
|
||||
};
|
||||
}
|
||||
|
@ -8,4 +8,7 @@ namespace Game
|
||||
BG_LoadWeaponCompleteDefInternal_t BG_LoadWeaponCompleteDefInternal = BG_LoadWeaponCompleteDefInternal_t(0x4B5F10);
|
||||
BG_GetWeaponDef_t BG_GetWeaponDef = BG_GetWeaponDef_t(0x440EB0);
|
||||
BG_GetEntityTypeName_t BG_GetEntityTypeName = BG_GetEntityTypeName_t(0x43A0E0);
|
||||
BG_IsWeaponValid_t BG_IsWeaponValid = BG_IsWeaponValid_t(0x415BA0);
|
||||
BG_GetEquippedWeaponIndex_t BG_GetEquippedWeaponIndex = BG_GetEquippedWeaponIndex_t(0x4D8BA0);
|
||||
BG_GetEquippedWeaponState_t BG_GetEquippedWeaponState = BG_GetEquippedWeaponState_t(0x4E79E0);
|
||||
}
|
||||
|
@ -19,4 +19,13 @@ namespace Game
|
||||
|
||||
typedef const char*(*BG_GetEntityTypeName_t)(int eType);
|
||||
extern BG_GetEntityTypeName_t BG_GetEntityTypeName;
|
||||
|
||||
typedef bool(*BG_IsWeaponValid_t)(const playerState_s* ps, unsigned int weaponIndex);
|
||||
extern BG_IsWeaponValid_t BG_IsWeaponValid;
|
||||
|
||||
typedef int(*BG_GetEquippedWeaponIndex_t)(const playerState_s* ps, unsigned int weaponIndex);
|
||||
extern BG_GetEquippedWeaponIndex_t BG_GetEquippedWeaponIndex;
|
||||
|
||||
typedef PlayerEquippedWeaponState*(*BG_GetEquippedWeaponState_t)(playerState_s* ps, unsigned int weaponIndex);
|
||||
extern BG_GetEquippedWeaponState_t BG_GetEquippedWeaponState;
|
||||
}
|
||||
|
@ -213,13 +213,6 @@ namespace Game
|
||||
Weapon_RocketLauncher_Fire_t Weapon_RocketLauncher_Fire = Weapon_RocketLauncher_Fire_t(0x424680);
|
||||
Bullet_Fire_t Bullet_Fire = Bullet_Fire_t(0x4402C0);
|
||||
|
||||
Jump_ClearState_t Jump_ClearState = Jump_ClearState_t(0x04B3890);
|
||||
PM_playerTrace_t PM_playerTrace = PM_playerTrace_t(0x458980);
|
||||
PM_Trace_t PM_Trace = PM_Trace_t(0x441F60);
|
||||
PM_GetEffectiveStance_t PM_GetEffectiveStance = PM_GetEffectiveStance_t(0x412540);
|
||||
PM_UpdateLean_t PM_UpdateLean = PM_UpdateLean_t(0x43DED0);
|
||||
PM_IsSprinting_t PM_IsSprinting = PM_IsSprinting_t(0x4B3830);
|
||||
|
||||
IN_RecenterMouse_t IN_RecenterMouse = IN_RecenterMouse_t(0x463D80);
|
||||
|
||||
IN_MouseMove_t IN_MouseMove = IN_MouseMove_t(0x64C490);
|
||||
@ -784,7 +777,6 @@ namespace Game
|
||||
I_strncpyz_s(dest, destsize, src, destsize);
|
||||
}
|
||||
|
||||
#pragma optimize("", off)
|
||||
__declspec(naked) float UI_GetScoreboardLeft(void* /*a1*/)
|
||||
{
|
||||
__asm
|
||||
@ -1196,5 +1188,16 @@ namespace Game
|
||||
return answer;
|
||||
}
|
||||
|
||||
#pragma optimize("", on)
|
||||
void Player_SwitchToWeapon(gentity_s* player)
|
||||
{
|
||||
static DWORD Player_SwitchToWeapon_t = 0x5D97B0;
|
||||
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
mov ebx, player
|
||||
call Player_SwitchToWeapon_t
|
||||
popad
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -500,24 +500,6 @@ namespace Game
|
||||
typedef int(*Bullet_Fire_t)(gentity_s* attacker, float spread, weaponParms* wp, gentity_s* weaponEnt, PlayerHandIndex hand, int gameTime);
|
||||
extern Bullet_Fire_t Bullet_Fire;
|
||||
|
||||
typedef void(*Jump_ClearState_t)(playerState_s* ps);
|
||||
extern Jump_ClearState_t Jump_ClearState;
|
||||
|
||||
typedef void(*PM_playerTrace_t)(pmove_s* pm, trace_t* results, const float* start, const float* end, const Bounds* bounds, int passEntityNum, int contentMask);
|
||||
extern PM_playerTrace_t PM_playerTrace;
|
||||
|
||||
typedef void(*PM_Trace_t)(pmove_s* pm, trace_t* results, const float* start, const float* end, const Bounds* bounds, int passEntityNum, int contentMask);
|
||||
extern PM_Trace_t PM_Trace;
|
||||
|
||||
typedef EffectiveStance(*PM_GetEffectiveStance_t)(const playerState_s* ps);
|
||||
extern PM_GetEffectiveStance_t PM_GetEffectiveStance;
|
||||
|
||||
typedef void(*PM_UpdateLean_t)(playerState_s* ps, float msec, usercmd_s* cmd, void(*capsuleTrace)(trace_t*, const float*, const float*, const Bounds*, int, int));
|
||||
extern PM_UpdateLean_t PM_UpdateLean;
|
||||
|
||||
typedef bool(*PM_IsSprinting_t)(const playerState_s* ps);
|
||||
extern PM_IsSprinting_t PM_IsSprinting;
|
||||
|
||||
typedef void(*IN_RecenterMouse_t)();
|
||||
extern IN_RecenterMouse_t IN_RecenterMouse;
|
||||
|
||||
@ -803,4 +785,6 @@ namespace Game
|
||||
|
||||
void I_strncpyz_s(char* dest, std::size_t destsize, const char* src, std::size_t count);
|
||||
void I_strcpy(char* dest, std::size_t destsize, const char* src);
|
||||
|
||||
void Player_SwitchToWeapon(gentity_s* player);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "FileSystem.hpp"
|
||||
#include "Functions.hpp"
|
||||
#include "Dvars.hpp"
|
||||
#include "PlayerMovement.hpp"
|
||||
#include "PreProcessor.hpp"
|
||||
#include "Script.hpp"
|
||||
#include "Server.hpp"
|
||||
|
11
src/Game/PlayerMovement.cpp
Normal file
11
src/Game/PlayerMovement.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <STDInclude.hpp>
|
||||
|
||||
namespace Game
|
||||
{
|
||||
Jump_ClearState_t Jump_ClearState = Jump_ClearState_t(0x04B3890);
|
||||
PM_playerTrace_t PM_playerTrace = PM_playerTrace_t(0x458980);
|
||||
PM_Trace_t PM_Trace = PM_Trace_t(0x441F60);
|
||||
PM_GetEffectiveStance_t PM_GetEffectiveStance = PM_GetEffectiveStance_t(0x412540);
|
||||
PM_UpdateLean_t PM_UpdateLean = PM_UpdateLean_t(0x43DED0);
|
||||
PM_IsSprinting_t PM_IsSprinting = PM_IsSprinting_t(0x4B3830);
|
||||
}
|
22
src/Game/PlayerMovement.hpp
Normal file
22
src/Game/PlayerMovement.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
namespace Game
|
||||
{
|
||||
typedef void(*Jump_ClearState_t)(playerState_s* ps);
|
||||
extern Jump_ClearState_t Jump_ClearState;
|
||||
|
||||
typedef void(*PM_playerTrace_t)(pmove_s* pm, trace_t* results, const float* start, const float* end, const Bounds* bounds, int passEntityNum, int contentMask);
|
||||
extern PM_playerTrace_t PM_playerTrace;
|
||||
|
||||
typedef void(*PM_Trace_t)(pmove_s* pm, trace_t* results, const float* start, const float* end, const Bounds* bounds, int passEntityNum, int contentMask);
|
||||
extern PM_Trace_t PM_Trace;
|
||||
|
||||
typedef EffectiveStance(*PM_GetEffectiveStance_t)(const playerState_s* ps);
|
||||
extern PM_GetEffectiveStance_t PM_GetEffectiveStance;
|
||||
|
||||
typedef void(*PM_UpdateLean_t)(playerState_s* ps, float msec, usercmd_s* cmd, void(*capsuleTrace)(trace_t*, const float*, const float*, const Bounds*, int, int));
|
||||
extern PM_UpdateLean_t PM_UpdateLean;
|
||||
|
||||
typedef bool(*PM_IsSprinting_t)(const playerState_s* ps);
|
||||
extern PM_IsSprinting_t PM_IsSprinting;
|
||||
}
|
Loading…
Reference in New Issue
Block a user