Skip to content

Commit

Permalink
fix melee blocking in Gothic 1
Browse files Browse the repository at this point in the history
  • Loading branch information
thokkat committed Jun 25, 2024
1 parent 927851a commit fb92dde
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
2 changes: 1 addition & 1 deletion game/graphics/mdlvisual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ const Animation::Sequence* MdlVisual::startAnimAndGet(Npc& npc, AnimationSolver:
bs = BS_RUN;
break;
case AnimationSolver::Anim::MoveBack:
if(st!=WeaponState::NoWeapon)
if(st==WeaponState::Fist || st==WeaponState::W1H || st==WeaponState::W2H)
bs = BS_PARADE; else
bs = BS_RUN;
case AnimationSolver::Anim::RotL:
Expand Down
28 changes: 18 additions & 10 deletions game/graphics/mesh/animationsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "world/world.h"
#include "game/serialize.h"
#include "utils/fileext.h"
#include "gothic.h"
#include "skeleton.h"
#include "pose.h"
#include "resources.h"
Expand Down Expand Up @@ -117,8 +118,10 @@ const Animation::Sequence* AnimationSolver::implSolveAnim(AnimationSolver::Anim
return solveFrm("T_FISTATTACKMOVE");
return solveFrm("S_FISTATTACK");
}
if(a==Anim::AttackBlock)
return solveFrm("T_FISTPARADE_0");
if(a==Anim::AttackBlock) {
bool g2 = Gothic::inst().version().game==2;
return g2 ? solveFrm("T_FISTPARADE_0") : solveFrm("T_FISTPARADE_O");
}
}
else if(st==WeaponState::W1H || st==WeaponState::W2H) {
if(a==Anim::Attack && pose.hasState(BS_RUN))
Expand All @@ -130,15 +133,20 @@ const Animation::Sequence* AnimationSolver::implSolveAnim(AnimationSolver::Anim
if(a==Anim::Attack || a==Anim::AttackL || a==Anim::AttackR)
return solveFrm("S_%sATTACK",st);
if(a==Anim::AttackBlock) {
const Animation::Sequence* s=nullptr;
switch(std::rand()%3){
case 0: s = solveFrm("T_%sPARADE_0", st); break;
case 1: s = solveFrm("T_%sPARADE_0_A2",st); break;
case 2: s = solveFrm("T_%sPARADE_0_A3",st); break;
bool g2 = Gothic::inst().version().game==2;
if(g2) {
const Animation::Sequence* s=nullptr;
switch(std::rand()%3) {
case 0: s = solveFrm("T_%sPARADE_0", st); break;
case 1: s = solveFrm("T_%sPARADE_0_A2",st); break;
case 2: s = solveFrm("T_%sPARADE_0_A3",st); break;
}
if(s==nullptr)
s = solveFrm("T_%sPARADE_0",st);
return s;
} else {
return solveFrm("T_%sPARADE_O",st);
}
if(s==nullptr)
s = solveFrm("T_%sPARADE_0",st);
return s;
}
if(a==Anim::AttackFinish)
return solveFrm("T_%sSFINISH",st);
Expand Down
21 changes: 3 additions & 18 deletions game/graphics/mesh/pose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,31 +608,16 @@ bool Pose::isDefWindow(uint64_t tickCount) const {
}

bool Pose::isDefence(uint64_t tickCount) const {
static const char* alt[3]={"","_A2","_A3"};

for(auto& i:lay) {
if(i.seq->isDefWindow(tickCount-i.sAnim)) {
// FIXME: seems like name check is not needed
for(int h=1;h<=2;++h) {
for(int v=0;v<3;++v) {
string_frm buf("T_",h,"HPARADE_0",alt[v]);
if(i.seq->name==buf)
return true;
}
}
}
if(i.bs==BS_PARADE && i.seq->isDefWindow(tickCount-i.sAnim))
return true;
}
return false;
}

bool Pose::isJumpBack() const {
for(auto& i:lay) {
for(int h=1;h<=2;++h) {
string_frm buf("T_",h,"HJUMPB");
if(i.seq->name==buf)
return true;
}
if(i.seq->name=="T_FISTPARADEJUMPB")
if(i.bs==BS_PARADE && i.seq->data->defParFrame.empty())
return true;
}
return false;
Expand Down

0 comments on commit fb92dde

Please sign in to comment.