void WeaponItem::ObjectTouch(HOBJECT hObject, bool bForcePickup/*=false*/) { if (!hObject) return; // If we hit non-player objects, just ignore them... if (IsPlayer(hObject)) { CCharacter* pCharObj = (CCharacter*)g_pLTServer->HandleToObject(hObject); if (pCharObj && !pCharObj->IsDead()) { CAutoMessage cMsg; cMsg.Writeuint32(MID_ADDWEAPON); cMsg.Writeuint8(m_nWeaponId); cMsg.Writeuint8(m_nAmmoId); cMsg.Writeint32(m_nAmmo); cMsg.Writebool(bForcePickup); g_pLTServer->SendToObject(cMsg.Read(), m_hObject, hObject, MESSAGE_GUARANTEED); } } }
void AmmoBox::ObjectTouch(HOBJECT hObject, bool bForcePickup/*=false*/) { if (!hObject) return; // If we hit non-player objects, just ignore them... if (IsPlayer(hObject)) { CCharacter* pCharObj = (CCharacter*)g_pLTServer->HandleToObject(hObject); if (pCharObj && !pCharObj->IsDead()) { int nValidIds = 0; for (int i=0; i < AB_MAX_TYPES; i++) { if (m_nAmmoId[i] != WMGR_INVALID_ID && m_nAmmoCount[i] > 0) { nValidIds++; } } if (nValidIds) { CAutoMessage cMsg; cMsg.Writeuint32(MID_AMMOBOX); cMsg.Writeuint8(nValidIds); for (int i=0; i < AB_MAX_TYPES; i++) { if (m_nAmmoId[i] != WMGR_INVALID_ID && m_nAmmoCount[i] > 0) { cMsg.Writeuint8(m_nAmmoId[i]); cMsg.Writeint32(m_nAmmoCount[i]); } } g_pLTServer->SendToObject(cMsg.Read(), m_hObject, hObject, MESSAGE_GUARANTEED); } } } }
void CClientMeleeCollisionController::HandleCollision(HOBJECT hTarget, HMODELNODE hNodeHit, EPhysicsGroup eHitPhysics, const LTVector& vPos, const LTVector& vDir) { // Check if the attack has been blocked via rigidbody... if (eHitPhysics == PhysicsUtilities::ePhysicsGroup_UserBlockMelee) { HandleBlocked(hTarget, vPos, vDir); return; } // Check if the attack has been blocked via forced blocking (what the AI does)... CCharacterFX* pTargetFX = g_pGameClientShell->GetSFXMgr()->GetCharacterFX(hTarget); if (pTargetFX && pTargetFX->IsBlocking()) { HandleBlocked(hTarget, vPos, vDir); return; } // Handle normal damage... CAutoMessage cMsg; cMsg.Writeuint8(MID_OBJECT_MESSAGE); cMsg.WriteObject(m_hObject); cMsg.Writeuint32(MID_MELEEATTACK); cMsg.WriteObject(hTarget); cMsg.Writeuint32(hNodeHit); cMsg.WriteLTVector(vPos); cMsg.WriteLTVector(vDir); cMsg.Writeint32(g_pGameClientShell->GetServerRealTimeMS()); g_pLTClient->SendToServer(cMsg.Read(), MESSAGE_GUARANTEED); //!!ARL: Maybe DisableCollisions for hTarget if they are blocking? // (to avoid the weirdness of taking damage but still blocking the attack) // For local player targets, send an AttackRecoil stimulus so a proper animation can be played. if (hTarget == g_pPlayerMgr->GetMoveMgr()->GetObject()) { CPlayerBodyMgr::Instance().HandleAnimationStimulus("CS_RecoilFromAttack"); } }