2019-08-31 19:18:15 -07:00
|
|
|
/*
|
2022-07-07 09:10:14 -07:00
|
|
|
* Copyright (c) 2016-2022 Vera Visions LLC.
|
2019-08-31 19:18:15 -07:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2022-07-07 09:10:14 -07:00
|
|
|
*/
|
2019-01-20 18:00:14 -08:00
|
|
|
|
2021-03-29 12:52:53 -07:00
|
|
|
/*
|
|
|
|
====================
|
2021-05-08 08:44:16 -07:00
|
|
|
Event_Callback
|
2021-03-29 12:52:53 -07:00
|
|
|
|
2021-05-08 08:44:16 -07:00
|
|
|
Calls one event based on viewmodel frame timeline, to avoid running more than once.
|
|
|
|
Prediction runs through weapon many times per frame, so we have to do call special
|
|
|
|
events based on time passed on the viewmodel.
|
2021-03-29 12:52:53 -07:00
|
|
|
====================
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Event_Callback(float mtime, __inout float btime)
|
|
|
|
{
|
2021-05-08 08:44:16 -07:00
|
|
|
/* don't bother if no valid function is set */
|
2021-03-29 12:52:53 -07:00
|
|
|
if (pSeat->m_pEventCall == __NULL__)
|
|
|
|
return;
|
|
|
|
|
2021-05-08 08:44:16 -07:00
|
|
|
/* if the sequence ain't the same anymore... */
|
2021-03-29 22:30:33 -07:00
|
|
|
if (pSeat->m_flEventFrame != pSeat->m_eViewModel.frame)
|
|
|
|
return;
|
2022-06-20 23:34:51 -07:00
|
|
|
|
2021-05-08 08:44:16 -07:00
|
|
|
/* if the model changed... */
|
2021-04-06 00:18:17 -07:00
|
|
|
if (pSeat->m_flEventMdl != pSeat->m_eViewModel.modelindex)
|
|
|
|
return;
|
2021-03-29 22:30:33 -07:00
|
|
|
|
2022-06-20 23:34:51 -07:00
|
|
|
/* weapon changed */
|
2024-01-08 14:58:45 -08:00
|
|
|
NSClientPlayer pl = (NSClientPlayer)(pSeat->m_ePlayer);
|
2022-06-20 23:34:51 -07:00
|
|
|
|
|
|
|
if (pSeat->m_iEventWeapon != pl.activeweapon)
|
|
|
|
return;
|
|
|
|
|
2021-03-29 12:52:53 -07:00
|
|
|
/* only play once */
|
|
|
|
if (mtime == btime)
|
|
|
|
return;
|
|
|
|
|
2021-05-08 08:44:16 -07:00
|
|
|
/* call when we've passed the keyframe the first time */
|
2021-03-29 12:52:53 -07:00
|
|
|
if (btime <= pSeat->m_flEventTime && (mtime > pSeat->m_flEventTime)) {
|
|
|
|
pSeat->m_pEventCall();
|
|
|
|
pSeat->m_pEventCall = __NULL__;
|
2022-06-20 23:34:51 -07:00
|
|
|
pSeat->m_flEventMdl = 0;
|
|
|
|
pSeat->m_flEventFrame = -1;
|
2021-03-29 12:52:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
btime = mtime;
|
|
|
|
}
|