From d466b2ae5146161bb625298a8dff225deafc7d95 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 6 Sep 2016 02:15:31 +0000 Subject: [PATCH] Add bit 1 to action flags: use the viewpoint's position relative to the actor when calculating which rotation to display, instead of the viewpoint's angle, for viewtypes 2/3/4/8. 5/7 already do this. git-svn-id: https://svn.eduke32.com/eduke32@5850 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/actors.h | 5 +++++ polymer/eduke32/source/game.c | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/polymer/eduke32/source/actors.h b/polymer/eduke32/source/actors.h index dc4a044e5..a72bcdfac 100644 --- a/polymer/eduke32/source/actors.h +++ b/polymer/eduke32/source/actors.h @@ -110,6 +110,11 @@ enum actionparams ACTION_PARAM_COUNT, }; +enum actionflags +{ + AF_VIEWPOINT = 1u<<0u, +}; + #ifdef LUNATIC struct action { diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 1c1d238b7..a12b12ab3 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -4077,8 +4077,10 @@ PALONLY: goto skip; l = apScript[scrofs_action + ACTION_VIEWTYPE]; + uint16_t const action_flags = apScript[scrofs_action + ACTION_FLAGS]; #else l = viewtype; + uint16_t const action_flags = actor[i].ac.flags; #endif #ifdef USE_OPENGL @@ -4092,19 +4094,26 @@ PALONLY: switch (l) { case 2: - frameOffset = (((pSprite->ang+3072+128-oura)&2047)>>8)&1; + { + int const viewAng = (action_flags & AF_VIEWPOINT) ? getangle(pSprite->x-ourx, pSprite->y-oury) : oura; + frameOffset = (((pSprite->ang + 3072 + 128 - viewAng) & 2047) >> 8) & 1; break; + } case 3: case 4: - frameOffset = (((pSprite->ang+3072+128-oura)&2047)>>7)&7; + { + int const viewAng = (action_flags & AF_VIEWPOINT) ? getangle(pSprite->x-ourx, pSprite->y-oury) : oura; + frameOffset = (((pSprite->ang + 3072 + 128 - viewAng) & 2047) >> 7) & 7; if (frameOffset > 3) { t->cstat |= 4; - frameOffset = 7-frameOffset; + frameOffset = 7 - frameOffset; } - else t->cstat &= ~4; + else + t->cstat &= ~4; break; + } case 5: case -5: @@ -4116,10 +4125,13 @@ PALONLY: break; case 8: case -8: - frameOffset = (l > 0) ? (((pSprite->ang + 3072 + 128 - oura) & 2047) >> 8) & 7 - : (((oura + 3072 + 128 - pSprite->ang) & 2047) >> 8) & 7; + { + int const viewAng = (action_flags & AF_VIEWPOINT) ? getangle(pSprite->x-ourx, pSprite->y-oury) : oura; + int const angDiff = l > 0 ? pSprite->ang - viewAng : viewAng - pSprite->ang; + frameOffset = (((angDiff + 3072 + 128) & 2047) >> 8) & 7; t->cstat &= ~4; break; + } default: frameOffset = 0; break;