CGrappleHook* CGrappleHook :: Create( Vector Pos, Vector Aim, CBasePlayer* Owner ) { ALERT( at_console, "^2HLU -> ^3weapon_grapple ^2-> Tongue spawned.\n"); CGrappleHook* Hook = GetClassPtr( (CGrappleHook*)NULL ); UTIL_SetOrigin( Hook->pev, Pos ); Hook->pev->angles = Aim; Hook->Spawn(); Hook->SetTouch( &CGrappleHook::Hit ); Hook->pev->owner = Owner->edict(); Hook->myowner = Owner; return Hook; }
CGrappleHook *CGrappleHook::HookCreate(const Vector &vecOrigin, const QAngle &angAngles, CBaseEntity *pentOwner) { // Create a new entity with CGrappleHook private data CGrappleHook *pHook = (CGrappleHook *)CreateEntityByName("grapple_hook"); UTIL_SetOrigin(pHook, vecOrigin); pHook->SetAbsAngles(angAngles); pHook->Spawn(); CWeaponGrapple *pOwner = (CWeaponGrapple *)pentOwner; pHook->m_hOwner = pOwner; pHook->SetOwnerEntity(pOwner->GetOwner()); pHook->m_hPlayer = (CBasePlayer *)pOwner->GetOwner(); return pHook; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponGrapple::FireHook(void) { if (m_bMustReload) return; CBasePlayer *pOwner = ToBasePlayer(GetOwner()); if (pOwner == NULL) return; #ifndef CLIENT_DLL Vector vecAiming = pOwner->GetAutoaimVector(0); Vector vecSrc = pOwner->Weapon_ShootPosition(); QAngle angAiming; VectorAngles(vecAiming, angAiming); CGrappleHook *pHook = CGrappleHook::HookCreate(vecSrc, angAiming, this); if (pOwner->GetWaterLevel() == 3) { pHook->SetAbsVelocity(vecAiming * BOLT_WATER_VELOCITY); } else { pHook->SetAbsVelocity(vecAiming * BOLT_AIR_VELOCITY); } m_hHook = pHook; CreateRope(); #endif pOwner->ViewPunch(QAngle(-2, 0, 0)); WeaponSound(SINGLE); WeaponSound(SPECIAL2); SendWeaponAnim(ACT_VM_PRIMARYATTACK); m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + 0.75; DoLoadEffect(); SetChargerState(CHARGER_STATE_DISCHARGE); }