1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 2010-2019 EDuke32 developers and contributors
4 Copyright (C) 2019 Nuke.YKT
5 
6 This file is part of NBlood.
7 
8 NBlood is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License version 2
10 as published by the Free Software Foundation.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 
16 See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 */
22 //-------------------------------------------------------------------------
23 #include "build.h"
24 #include "compat.h"
25 #include "common_game.h"
26 #include "blood.h"
27 #include "choke.h"
28 #include "globals.h"
29 #include "levels.h"
30 #include "player.h"
31 #include "qav.h"
32 #include "resource.h"
33 
34 
sub_83F54(char * a1,int _x,int _y,void (* a2)(PLAYER *))35 void CChoke::sub_83F54(char *a1, int _x, int _y, void (*a2)(PLAYER*))
36 {
37     at14 = _x;
38     at18 = _y;
39     at0 = a1;
40     at1c = a2;
41     if (!at4 && at0)
42     {
43         at4 = gSysRes.Lookup(at0, "QAV");
44         if (!at4)
45             ThrowError("Could not load QAV %s\n", at0);
46         at8 = (QAV*)gSysRes.Lock(at4);
47         at8->nSprite = -1;
48         at8->x = at14;
49         at8->y = at18;
50         at8->Preload();
51         sub_84218();
52     }
53 }
54 
sub_83ff0(int a1,void (* a2)(PLAYER *))55 void CChoke::sub_83ff0(int a1, void(*a2)(PLAYER*))
56 {
57     at0 = NULL;
58     at1c = a2;
59     if (!at4 && a1 != -1)
60     {
61         at4 = gSysRes.Lookup(a1, "QAV");
62         if (!at4)
63             ThrowError("Could not load QAV %d\n", a1);
64         at8 = (QAV*)gSysRes.Lock(at4);
65         at8->nSprite = -1;
66         at8->x = at14;
67         at8->y = at18;
68         at8->Preload();
69         sub_84218();
70     }
71 }
72 
sub_84080(char * a1,void (* a2)(PLAYER *))73 void CChoke::sub_84080(char *a1, void(*a2)(PLAYER*))
74 {
75     at0 = a1;
76     at1c = a2;
77     if (!at4 && at0)
78     {
79         at4 = gSysRes.Lookup(at0, "QAV");
80         if (!at4)
81             ThrowError("Could not load QAV %s\n", at0);
82         at8 = (QAV*)gSysRes.Lock(at4);
83         at8->nSprite = -1;
84         at8->x = at14;
85         at8->y = at18;
86         at8->Preload();
87         sub_84218();
88     }
89 }
90 
sub_84110(int x,int y)91 void CChoke::sub_84110(int x, int y)
92 {
93     if (!at4)
94         return;
95     ClockTicks v4 = gFrameClock;
96     gFrameClock = totalclock;
97     at8->x = x;
98     at8->y = y;
99     int vd = (int)totalclock-at10;
100     at10 = (int)totalclock;
101     atc -= vd;
102     if (atc <= 0 || atc > at8->at10)
103         atc = at8->at10;
104     int vdi = at8->at10-atc;
105     at8->Play(vdi-vd, vdi, -1, NULL);
106     int vb = windowxy1.x;
107     int v10 = windowxy1.y;
108     int vc = windowxy2.x;
109     int v8 = windowxy2.y;
110     windowxy1.x = windowxy1.y = 0;
111     windowxy2.x = xdim-1;
112     windowxy2.y = ydim-1;
113     at8->Draw(vdi, 10, 0, 0);
114     windowxy1.x = vb;
115     windowxy1.y = v10;
116     windowxy2.x = vc;
117     windowxy2.y = v8;
118     gFrameClock = v4;
119 }
120 
sub_84218()121 void CChoke::sub_84218()
122 {
123     atc = at8->at10;
124     at10 = (int)totalclock;
125 }
126 
sub_84230(PLAYER * pPlayer)127 void sub_84230(PLAYER *pPlayer)
128 {
129     int t = gGameOptions.nDifficulty+2;
130     if (pPlayer->handTime < 64)
131         pPlayer->handTime = ClipHigh(pPlayer->handTime+t, 64);
132     if (pPlayer->handTime > (7-gGameOptions.nDifficulty)*5)
133         pPlayer->blindEffect = ClipHigh(pPlayer->blindEffect+t*4, 128);
134 }
135 
136 CChoke gChoke;