本文整理汇总了C++中Corpse::AddImpulse方法的典型用法代码示例。如果您正苦于以下问题:C++ Corpse::AddImpulse方法的具体用法?C++ Corpse::AddImpulse怎么用?C++ Corpse::AddImpulse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Corpse
的用法示例。
在下文中一共展示了Corpse::AddImpulse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlayerKilledPlayer
void Client::PlayerKilledPlayer(spades::client::Player *killer,
spades::client::Player *victim, KillType kt) {
// play hit sound
if (kt == KillTypeWeapon || kt == KillTypeHeadshot) {
// don't play on local: see BullethitPlayer
if (victim != world->GetLocalPlayer()) {
if (!IsMuted()) {
Handle<IAudioChunk> c;
switch (SampleRandomInt(0, 2)) {
case 0:
c = audioDevice->RegisterSound("Sounds/Weapons/Impacts/Flesh1.opus");
break;
case 1:
c = audioDevice->RegisterSound("Sounds/Weapons/Impacts/Flesh2.opus");
break;
case 2:
c = audioDevice->RegisterSound("Sounds/Weapons/Impacts/Flesh3.opus");
break;
}
AudioParam param;
param.volume = 4.f;
audioDevice->Play(c, victim->GetEye(), param);
}
}
}
// The local player is dead; initialize the look-you-are-dead cam
if (victim == world->GetLocalPlayer()) {
followCameraState.enabled = false;
Vector3 v = -victim->GetFront();
followAndFreeCameraState.yaw = atan2(v.y, v.x);
followAndFreeCameraState.pitch = 30.f * M_PI / 180.f;
}
// emit blood (also for local player)
// FIXME: emiting blood for either
// client-side or server-side hit?
switch (kt) {
case KillTypeGrenade:
case KillTypeHeadshot:
case KillTypeMelee:
case KillTypeWeapon: Bleed(victim->GetEye()); break;
default: break;
}
// create ragdoll corpse
if (cg_ragdoll && victim->GetTeamId() < 2) {
Corpse *corp;
corp = new Corpse(renderer, map, victim);
if (victim == world->GetLocalPlayer())
lastMyCorpse = corp;
if (killer != victim && kt != KillTypeGrenade) {
Vector3 dir = victim->GetPosition() - killer->GetPosition();
dir = dir.Normalize();
if (kt == KillTypeMelee) {
dir *= 6.f;
} else {
if (killer->GetWeapon()->GetWeaponType() == SMG_WEAPON) {
dir *= 2.8f;
} else if (killer->GetWeapon()->GetWeaponType() == SHOTGUN_WEAPON) {
dir *= 4.5f;
} else {
dir *= 3.5f;
}
}
corp->AddImpulse(dir);
} else if (kt == KillTypeGrenade) {
corp->AddImpulse(MakeVector3(0, 0, -4.f - SampleRandomFloat() * 4.f));
}
corp->AddImpulse(victim->GetVelocty() * 32.f);
corpses.emplace_back(corp);
if (corpses.size() > corpseHardLimit) {
corpses.pop_front();
} else if (corpses.size() > corpseSoftLimit) {
RemoveInvisibleCorpses();
}
}
// add chat message
std::string s;
s = ChatWindow::TeamColorMessage(killer->GetName(), killer->GetTeamId());
std::string cause;
bool isFriendlyFire = killer->GetTeamId() == victim->GetTeamId();
if (killer == victim)
isFriendlyFire = false;
Weapon *w =
killer ? killer->GetWeapon() : nullptr; // only used in case of KillTypeWeapon
switch (kt) {
case KillTypeWeapon:
switch (w ? w->GetWeaponType() : RIFLE_WEAPON) {
case RIFLE_WEAPON: cause += _Tr("Client", "Rifle"); break;
case SMG_WEAPON: cause += _Tr("Client", "SMG"); break;
case SHOTGUN_WEAPON: cause += _Tr("Client", "Shotgun"); break;
}
break;
case KillTypeFall:
//.........这里部分代码省略.........