Skip to content

Commit

Permalink
Merge pull request #41 from SalatielSauer/main
Browse files Browse the repository at this point in the history
Fix monsters yaw and restore .md2 animations
  • Loading branch information
Big-Onche authored Jan 13, 2025
2 parents ba6986c + 7562df2 commit 01fefff
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 5 deletions.
8 changes: 8 additions & 0 deletions config/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ loop i (listlen $modenames) [
mapcomplete $mname
]

spmodenames = "sp dmsp"
loop i (listlen $spmodenames) [
local mname
mname = (at $spmodenames $i)
alias $mname [ if (mode (- @i 3)) [if (> $numargs 0) [map $arg1] [map]] ]
mapcomplete $mname
]

demo = [stopdemo; if (mode -1) [map $arg1]]
varcomplete demo demodir dmo

Expand Down
1 change: 1 addition & 0 deletions packages/models/monster/bauul/md2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ md2pitch .25
mdlspec 50
mdlscale 240
mdltrans 0 0 24
mdlyaw 90
1 change: 1 addition & 0 deletions packages/models/monster/goblin/md2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ md2pitch .25
mdlspec 50
mdlscale 130
mdltrans 0 0 24
mdlyaw 90
3 changes: 1 addition & 2 deletions packages/models/monster/hellpig/md2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ md2pitch .25
mdlspec 50
mdlscale 120
mdltrans 0 0 24


mdlyaw 90
3 changes: 1 addition & 2 deletions packages/models/monster/knight/md2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ md2pitch .25
mdlspec 50
mdlscale 180
mdltrans 0 0 24


mdlyaw 90
1 change: 1 addition & 0 deletions packages/models/monster/md2.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
md2pitch .25
mdlspec 50
mdltrans 0 0 24
mdlyaw 90
1 change: 1 addition & 0 deletions packages/models/monster/rat/md2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ md2pitch .25
mdlspec 50
mdlscale 140
mdltrans 0 0 24
mdlyaw 90
1 change: 1 addition & 0 deletions packages/models/monster/rhino/md2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ md2pitch .25
mdlspec 50
mdlscale 80
mdltrans 0 0 24
mdlyaw 90
2 changes: 1 addition & 1 deletion packages/models/monster/slith/md2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ md2pitch .25
mdlspec 50
mdlscale 180
mdltrans 0 0 24

mdlyaw 90
1 change: 1 addition & 0 deletions packages/models/monster/spider/md3.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ md3anim dying 120 17 50
md3anim dead 137 1

mdlscale 2000
mdlyaw 90
1 change: 1 addition & 0 deletions packages/models/ogro/md2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ md2pitch .25
mdlspec 50
mdlscale 100
mdltrans 0 0 24
mdlyaw 90
49 changes: 49 additions & 0 deletions src/engine/md2.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,55 @@ struct md2 : vertloader<md2>
}
};

struct md2part : part
{
md2part(animmodel* model, int index = 0) : part(model, index)
{
}

void getdefaultanim(animinfo& info, int anim, uint varseed, dynent* d)
{
// 0 3 6 7 8 9 10 11 12 13 14 15 16 17
// D D D D D D A P I R, E J T W FO SA GS GI
static const int _frame[] = { 178, 184, 190, 183, 189, 197, 46, 54, 0, 40, 162, 67, 95, 112, 72, 84, 7, 6 };
static const int _range[] = { 6, 6, 8, 1, 1, 1, 8, 4, 40, 6, 1, 1, 17, 11, 12, 11, 18, 1 };
// DE DY I F B L R H1 H2 H3 H4 H5 H6 H7 A1 A2 A3 A4 A5 A6 A7 PA J SI SW ED LA T WI LO GI GS
static const int animfr[] = { 5, 2, 8, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 7, 11, 8, 9, 10, 14, 12, 13, 15, 17, 16 };

anim &= ANIM_INDEX;
if ((size_t)anim >= sizeof(animfr) / sizeof(animfr[0]))
{
info.frame = 0;
info.range = 1;
return;
}
int n = animfr[anim];
switch (anim)
{
case ANIM_DYING:
case ANIM_DEAD:
n -= varseed % 3;
break;
case ANIM_FORWARD:
case ANIM_BACKWARD:
case ANIM_LEFT:
case ANIM_RIGHT:
case ANIM_SWIM:
info.speed = 5500.0f / d->maxspeed;
break;
}
info.frame = _frame[n];
info.range = _range[n];
}
};

md2part& addpart()
{
md2part* p = new md2part(this, parts.length());
parts.add(p);
return *p;
}

vertmeshgroup *newmeshes() { return new md2meshgroup; }

bool loadconfig() { return false; }
Expand Down

0 comments on commit 01fefff

Please sign in to comment.