adjustment physics of amoury_entity (#51)

This commit is contained in:
s1lentq 2016-08-02 09:03:01 +00:00 committed by GitHub
parent 07e861eb30
commit c3e632eacc
4 changed files with 34 additions and 11 deletions

View File

@ -288,7 +288,7 @@ void printEntities()
NOINLINE edict_t *EXT_FUNC CREATE_NAMED_ENTITY(string_t iClass) NOINLINE edict_t *EXT_FUNC CREATE_NAMED_ENTITY(string_t iClass)
{ {
edict_t *named = g_engfuncs.pfnCreateNamedEntity(iClass); edict_t *named = g_engfuncs.pfnCreateNamedEntity(iClass);
if (named != NULL) if (named)
{ {
AddEntityHashValue(&named->v, STRING(iClass), CLASSNAME); AddEntityHashValue(&named->v, STRING(iClass), CLASSNAME);
} }
@ -715,7 +715,7 @@ void EXT_FUNC DispatchObjectCollsionBox(edict_t *pent)
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent);
if (pEntity != NULL) if (pEntity)
{ {
pEntity->SetObjectCollisionBox(); pEntity->SetObjectCollisionBox();
} }
@ -918,7 +918,7 @@ int CBaseEntity::__MAKE_VHOOK(Restore)(CRestore &restore)
// Initialize absmin & absmax to the appropriate box // Initialize absmin & absmax to the appropriate box
void SetObjectCollisionBox(entvars_t *pev) void SetObjectCollisionBox(entvars_t *pev)
{ {
if ((pev->solid == SOLID_BSP) && (pev->angles.x || pev->angles.y || pev->angles.z)) if (pev->solid == SOLID_BSP && (pev->angles.x || pev->angles.y || pev->angles.z))
{ {
// expand for rotation // expand for rotation
float_precision max, v; float_precision max, v;

View File

@ -3169,7 +3169,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
// FIXME: Probably don't need to cast this just to read m_iDeaths // FIXME: Probably don't need to cast this just to read m_iDeaths
CBasePlayer *plr = UTIL_PlayerByIndex(i); CBasePlayer *plr = UTIL_PlayerByIndex(i);
if (plr != NULL) if (plr)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, NULL, pl->edict()); MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, NULL, pl->edict());
WRITE_BYTE(i); // client number WRITE_BYTE(i); // client number
@ -3211,7 +3211,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
{ {
CBasePlayer *plr = UTIL_PlayerByIndex(i); CBasePlayer *plr = UTIL_PlayerByIndex(i);
if (plr != NULL) if (plr)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgTeamInfo, NULL, pl->edict()); MESSAGE_BEGIN(MSG_ONE, gmsgTeamInfo, NULL, pl->edict());
WRITE_BYTE(plr->entindex()); WRITE_BYTE(plr->entindex());
@ -3242,7 +3242,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
{ {
CBaseEntity *pWeaponC4 = UTIL_FindEntityByClassname(NULL, "weapon_c4"); CBaseEntity *pWeaponC4 = UTIL_FindEntityByClassname(NULL, "weapon_c4");
if (pWeaponC4 != NULL) if (pWeaponC4)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgBombDrop, NULL, pl->edict()); MESSAGE_BEGIN(MSG_ONE, gmsgBombDrop, NULL, pl->edict());
WRITE_COORD(pWeaponC4->pev->origin.x); WRITE_COORD(pWeaponC4->pev->origin.x);
@ -3256,11 +3256,11 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
void CHalfLifeMultiplay::__MAKE_VHOOK(ClientDisconnected)(edict_t *pClient) void CHalfLifeMultiplay::__MAKE_VHOOK(ClientDisconnected)(edict_t *pClient)
{ {
if (pClient != NULL) if (pClient)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(CBaseEntity::Instance(pClient)); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(CBaseEntity::Instance(pClient));
if (pPlayer != NULL) if (pPlayer)
{ {
pPlayer->has_disconnected = true; pPlayer->has_disconnected = true;
pPlayer->pev->deadflag = DEAD_DEAD; pPlayer->pev->deadflag = DEAD_DEAD;
@ -3319,7 +3319,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(ClientDisconnected)(edict_t *pClient)
// destroy all of the players weapons and items // destroy all of the players weapons and items
pPlayer->RemoveAllItems(TRUE); pPlayer->RemoveAllItems(TRUE);
if (pPlayer->m_pObserver != NULL) if (pPlayer->m_pObserver)
{ {
pPlayer->m_pObserver->SUB_Remove(); pPlayer->m_pObserver->SUB_Remove();
} }

View File

@ -4224,7 +4224,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(PreThink)()
// These buttons have changed this frame // These buttons have changed this frame
int buttonsChanged = (m_afButtonLast ^ pev->button); int buttonsChanged = (m_afButtonLast ^ pev->button);
//this means the player has pressed or released a key // this means the player has pressed or released a key
if (buttonsChanged) if (buttonsChanged)
{ {
m_fLastMovement = gpGlobals->time; m_fLastMovement = gpGlobals->time;

View File

@ -486,7 +486,7 @@ void CBasePlayerItem::FallInit()
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin(pev, pev->origin);
//pointsize until it lands on the ground. // pointsize until it lands on the ground.
UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0));
SetTouch(&CBasePlayerItem::DefaultTouch); SetTouch(&CBasePlayerItem::DefaultTouch);
@ -1418,6 +1418,7 @@ void CBasePlayerAmmo::__MAKE_VHOOK(Spawn)()
{ {
pev->movetype = MOVETYPE_TOSS; pev->movetype = MOVETYPE_TOSS;
pev->solid = SOLID_TRIGGER; pev->solid = SOLID_TRIGGER;
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin(pev, pev->origin);
@ -2107,6 +2108,12 @@ char *armouryItemModels[] = {
void CArmoury::__MAKE_VHOOK(Spawn)() void CArmoury::__MAKE_VHOOK(Spawn)()
{ {
Precache(); Precache();
#ifdef REGAMEDLL_FIXES
// do it earlier than set UTIL_SetSize to avoid resetting mins/maxs.
SET_MODEL(ENT(pev), armouryItemModels[m_iItem]);
#endif
pev->movetype = MOVETYPE_TOSS; pev->movetype = MOVETYPE_TOSS;
pev->solid = SOLID_TRIGGER; pev->solid = SOLID_TRIGGER;
@ -2114,13 +2121,21 @@ void CArmoury::__MAKE_VHOOK(Spawn)()
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin(pev, pev->origin);
SetTouch(&CArmoury::ArmouryTouch); SetTouch(&CArmoury::ArmouryTouch);
#ifndef REGAMEDLL_FIXES
SET_MODEL(ENT(pev), armouryItemModels[m_iItem]); SET_MODEL(ENT(pev), armouryItemModels[m_iItem]);
#endif
if (m_iCount <= 0) if (m_iCount <= 0)
{ {
m_iCount = 1; m_iCount = 1;
} }
#ifdef REGAMEDLL_ADD
// Cache the placed origin of source point
pev->oldorigin = pev->origin;
#endif
m_bAlreadyCounted = false; m_bAlreadyCounted = false;
m_iInitialCount = m_iCount; m_iInitialCount = m_iCount;
} }
@ -2186,6 +2201,14 @@ void CArmoury::__MAKE_VHOOK(Restart)()
if (m_iCount < 1) if (m_iCount < 1)
m_iCount = 1; m_iCount = 1;
#ifdef REGAMEDLL_ADD
// Restored origin from the cache
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
UTIL_SetOrigin(pev, pev->oldorigin);
DROP_TO_FLOOR(edict());
#endif
Draw(); Draw();
} }