raze/source/games/blood/src/choke.cpp

97 lines
2.6 KiB
C++
Raw Normal View History

2019-09-19 22:42:45 +00:00
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
This file is part of NBlood.
NBlood is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
2019-09-19 22:42:45 +00:00
#include "build.h"
#include "blood.h"
#include "choke.h"
BEGIN_BLD_NS
2019-09-19 22:42:45 +00:00
2021-12-29 19:03:42 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void CChoke::init(int a1, void(*a2)(PLAYER*))
2019-09-19 22:42:45 +00:00
{
callback = a2;
if (!qav && a1 != -1)
{
qav = getQAV(a1);
if (!qav)
I_Error("Could not load QAV %d\n", a1);
qav->x = x;
qav->y = y;
duration = qav->duration;
time = 0;
}
2019-09-19 22:42:45 +00:00
}
2021-12-29 19:03:42 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void CChoke::animateChoke(int x, int y, double interpfrac)
2019-09-19 22:42:45 +00:00
{
if (!qav)
return;
int myclock = PlayClock + int(4 * interpfrac);
qav->x = x;
qav->y = y;
int vd = myclock - time;
time = myclock;
duration -= vd;
if (duration <= 0 || duration > qav->duration)
duration = qav->duration;
int vdi = qav->duration - duration;
qav->Play(vdi - vd, vdi, -1, nullptr);
// This originally overlaid the HUD but that simply doesn't work right with the HUD being a genuine overlay.
// It also never adjusted for a reduced 3D view
qav->Draw(vdi, 10, 0, 0, true, interpfrac);
2019-09-19 22:42:45 +00:00
}
2021-12-29 19:03:42 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-11-21 19:10:45 +00:00
void chokeCallback(PLAYER* pPlayer)
2019-09-19 22:42:45 +00:00
{
int t = gGameOptions.nDifficulty + 2;
if (pPlayer->handTime < 64)
pPlayer->handTime = min(pPlayer->handTime + t, 64);
if (pPlayer->handTime > (7 - gGameOptions.nDifficulty) * 5)
pPlayer->blindEffect = min(pPlayer->blindEffect + t * 4, 128);
2019-09-19 22:42:45 +00:00
}
CChoke gChoke;
END_BLD_NS