ref: e8b63e57ae6b804c15dce24c87db7edff6f8ba45
parent: e52f88ab940639d0b0e209d39404a19fe0c2df4d
author: qwx <qwx@sciops.net>
date: Fri Sep 4 05:31:42 EDT 2020
drw: set last movement frame when returning to idle state
--- a/dat.h
+++ b/dat.h
@@ -123,6 +123,7 @@
struct Mobj{
Obj *o;
Pics *pics;
+ int freezefrm;
Point;
int px;
int py;
--- a/drw.c
+++ b/drw.c
@@ -265,21 +265,28 @@
0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,
9,9,10,10,11,11,12,12,13,13,14,14,15,15,16
};
- int θ;
+ int θ, frm;
Pics *pp;
Pic *p;
- θ = mo->θ * 32.0 / 256;
pp = mo->pics;
+ if(pp->pic != nil)
+ frm = tc % pp->nf;
+ else{
+ pp = &mo->o->pmove;
+ frm = mo->freezefrm;
+ }
+ assert(pp->pic != nil && pp->shadow != nil);
+ θ = mo->θ * 32.0 / 256;
switch(pp->nr){
case 17: θ = rot17[θ]; break;
default: θ = 0; break;
}
if(notshadow){
- p = pp->pic[tc % pp->nf];
+ p = pp->pic[frm];
p += nteam * θ + mo->team - 1;
}else{
- p = pp->shadow[tc % pp->nf];
+ p = pp->shadow[frm];
p += θ;
}
return p;
--- a/sce/sce.db
+++ b/sce/sce.db
@@ -17,9 +17,7 @@
spr,scv,0x8002,17,0
spr,control,2,1,0
spr,control,0x8002,1,0
-spr,drone,2,17,0
spr,drone,4,17,0,1,2,3,4
-spr,drone,0x8002,17,0
spr,drone,0x8004,17,0,1,2,3,4
spr,hatchery,2,1,0,1,2,3,3,2,1,0
spr,hatchery,0x8002,1,0,0,0,0,0,0,0,0
--- a/sim.c
+++ b/sim.c
@@ -88,6 +88,8 @@
{
unlinkmobj(mo->movingp);
mo->pathp = nil;
+ if(mo->pics->nf > 0)
+ mo->freezefrm = tc % mo->pics->nf;
mo->pics = &mo->o->pidle;
resetcoords(mo);
}