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

Commit

Permalink
Implement p_viewmodel, fix corpse deletion
Browse files Browse the repository at this point in the history
Fixes #42. Took long enough
  • Loading branch information
nonperforming committed Feb 17, 2023
1 parent 9db7401 commit a0f3ce6
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions Sources/Client/ClientPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ DEFINE_SPADES_SETTING(cg_animations, "0");
SPADES_SETTING(cg_shake);
SPADES_SETTING(r_hdr);
DEFINE_SPADES_SETTING(cg_environmentalAudio, "1");
DEFINE_SPADES_SETTING(cg_debugToolSkinAnchors, "0");

DEFINE_SPADES_SETTING(cg_viewWeaponX, "0");
DEFINE_SPADES_SETTING(cg_viewWeaponY, "0");
DEFINE_SPADES_SETTING(cg_viewWeaponZ, "0");
DEFINE_SPADES_SETTING(cg_debugToolSkinAnchors, "0");

SPADES_SETTING(p_viewmodel);
SPADES_SETTING(p_corpse);

namespace spades {
namespace client {
Expand Down Expand Up @@ -442,6 +441,23 @@ namespace spades {
Vector3 right = player.GetRight();
Vector3 up = player.GetUp();

if (p_viewmodel)
{
// Offset the view weapon according to the player movement
viewWeaponOffset.x += Vector3::Dot(vel, right) * scale;
viewWeaponOffset.y -= Vector3::Dot(vel, front) * scale;
viewWeaponOffset.z += Vector3::Dot(vel, up) * scale;

// Offset the view weapon according to the camera movement
Vector3 diff = front - lastFront;
viewWeaponOffset.x += Vector3::Dot(diff, right) * 0.05f;
viewWeaponOffset.z += Vector3::Dot(diff, up) * 0.05f;
}
else
{
viewWeaponOffset = Vector3{0.f, -100.f, 0.f} * (1.f - aimDownState); // TODO: incredibly hacky, please fix later
}

lastFront = front;

if (dt > 0.f)
Expand Down Expand Up @@ -717,18 +733,9 @@ namespace spades {
}

// manual adjustment
if (!p_viewmodel)
{
viewWeaponOffset +=
Vector3{0.f, -100.f, 0.f} * (1.f - aimDownState); // TODO: incredibly hacky, please fix later
// TODO: fix
}
else
{
viewWeaponOffset +=
Vector3{cg_viewWeaponX, cg_viewWeaponY, cg_viewWeaponZ} * (1.f - aimDownState);
}

viewWeaponOffset +=
Vector3{cg_viewWeaponX, cg_viewWeaponY, cg_viewWeaponZ} * (1.f - aimDownState);

asIScriptObject *skin;

if (currentTool == Player::ToolSpade) {
Expand Down Expand Up @@ -839,16 +846,16 @@ namespace spades {
World *world = client.GetWorld();

if (!p.IsAlive()) {
if (!cg_ragdoll) {
if (!cg_ragdoll || p_viewmodel ) {
ModelRenderParam param;
param.matrix = Matrix4::Translate(p.GetOrigin() + MakeVector3(0, 0, 1));
if (!p_corpse)
if (p_viewmodel)
{
param.matrix = param.matrix * Matrix4::Scale(0.f); // TODO: incredibly hacky. please fix.
param.matrix = param.matrix * Matrix4::Scale(.1f);
}
else
{
param.matrix = param.matrix * Matrix4::Scale(.1f);
param.matrix = param.matrix * Matrix4::Scale(0.f);
}
IntVector3 col = p.GetColor();
param.customColor = MakeVector3(col.x / 255.f, col.y / 255.f, col.z / 255.f);
Expand Down Expand Up @@ -1299,7 +1306,7 @@ namespace spades {
Vector3 muzzle = ShouldRenderInThirdPersonView() ? GetMuzzlePosition()
: GetMuzzlePositionInFirstPersonView();

// make dynamic light
// make dlight
client.MuzzleFire(muzzle, player.GetFront(), &player == world.GetLocalPlayer());

if (cg_ejectBrass) {
Expand Down

0 comments on commit a0f3ce6

Please sign in to comment.