本文整理汇总了C++中SHit类的典型用法代码示例。如果您正苦于以下问题:C++ SHit类的具体用法?C++ SHit怎么用?C++ SHit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SHit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Hit
void CPHCollisionDamageReceiver::Hit(u16 source_id,u16 bone_id,float power,const Fvector& dir,Fvector &pos )
{
DAMAGE_BONES_I i=FindBone(bone_id);
if(i==m_controled_bones.end())return;
power*=i->second;
if(power<hit_threthhold)return;
NET_Packet P;
CPhysicsShellHolder *ph=PPhysicsShellHolder();
SHit HS;
HS.GenHeader(GE_HIT,ph->ID()); // ph->u_EventGen(P,GE_HIT,ph->ID());
HS.whoID = ph->ID(); // P.w_u16 (ph->ID());
HS.weaponID = source_id; // P.w_u16 (source_id);
HS.dir = dir; // P.w_dir (dir);
HS.power = power; // P.w_float (power);
HS.boneID = s16(bone_id); // P.w_s16 (s16(bone_id));
HS.p_in_bone_space = pos; // P.w_vec3 (pos);
HS.impulse = 0.f; // P.w_float (0.f);
HS.hit_type = (ALife::eHitTypeStrike); // P.w_u16 (ALife::eHitTypeStrike);
HS.Write_Packet(P);
ph->u_EventSend(P);
}
示例2: object
void CStalkerActionKillWounded::execute ()
{
inherited::execute ();
if (!object().memory().enemy().selected())
return;
const CEntityAlive *enemy = object().memory().enemy().selected();
object().sight().setup (CSightAction(enemy,true));
object().set_goal (eObjectActionFire1,weapon_to_kill(&object()),MIN_QUEUE,MAX_QUEUE,MIN_INTERVAL,MAX_INTERVAL);
if (object().memory().visual().visible_now(enemy) && object().can_kill_enemy() && !object().can_kill_member())
return;
// this is fake
// but sometimes enemy can not be visible
// when it plays animation inside another object
// therefore we should use this ugly workaround
// and hit enemy virtually
NET_Packet P;
SHit HS;
HS.GenHeader (GE_HIT, enemy->ID());
HS.whoID = object().ID();
HS.weaponID = weapon_to_kill(&object())->object().ID();
HS.dir = Fvector().set(0.f,0.f,1.f);
HS.power = 1.f;
HS.boneID = smart_cast<CKinematics*>((const_cast<CEntityAlive*>(enemy))->Visual())->LL_GetBoneRoot();
HS.p_in_bone_space = Fvector().set(0.f,0.f,0.f);
HS.impulse = 1.f;
HS.hit_type = ALife::eHitTypeWound;
HS.Write_Packet (P);
object().u_EventSend (P);
}
示例3: predicate
bool predicate( CEntityAlive& ea, const SHit& H, MotionID &m, float &angle ) const
{
if( H.initiator() != Level().CurrentControlEntity())
return false;
if(H.type() == ALife::eHitTypeExplosion)
{
edirection dr = dir( ea, H, angle );
m = motion( dr );
type_motion_diagnostic( "type_motion6: 7. √ранта", dr, ea, H, m );
return true;
}
CObject* O = Level().Objects.net_Find( H.weaponID );
if(!O)
{
m = MotionID();
return false;
}
if( smart_cast<CExplosive*>( O ) != 0 )
{
edirection dr = dir( ea, H, angle );
m = motion( dr );
type_motion_diagnostic( "type_motion6: 7. √ранта - осколок", dr, ea, H, m );
return true;
}
return false;
}
示例4: switch
void CAI_Rat::Exec_Action(float /**dt/**/)
{
switch (m_tAction) {
case eRatActionAttackBegin : {
u32 dwTime = Device.dwTimeGlobal;
sound().play (eRatSoundAttack);//,0,0,m_dwHitInterval+1,m_dwHitInterval);
if (memory().enemy().selected() && memory().enemy().selected()->g_Alive() && (dwTime - m_dwStartAttackTime > m_dwHitInterval)) {
m_bActionStarted = true;
m_dwStartAttackTime = dwTime;
Fvector tDirection;
Fvector position_in_bone_space;
position_in_bone_space.set(0.f,0.f,0.f);
tDirection.sub(memory().enemy().selected()->Position(),this->Position());
vfNormalizeSafe(tDirection);
if (this->Local() && memory().enemy().selected()) {
CEntityAlive *entity_alive = const_cast<CEntityAlive*>(memory().enemy().selected());
VERIFY (entity_alive);
// entity_alive->Hit(m_fHitPower,tDirection,this,0,position_in_bone_space,0);
u16 id_to = entity_alive->ID();
u16 id_from = ID();
NET_Packet l_P;
SHit HS;
HS.GenHeader(GE_HIT, id_to); // u_EventGen (l_P,GE_HIT, id_to);
HS.whoID = (id_from); // l_P.w_u16 (id_from);
HS.weaponID = (id_from); // l_P.w_u16 (id_from);
HS.dir = (tDirection); // l_P.w_dir (tDirection);
HS.power = (m_fHitPower); // l_P.w_float (m_fHitPower);
HS.boneID = (0); // l_P.w_s16 (0);
HS.p_in_bone_space = (position_in_bone_space); // l_P.w_vec3 (position_in_bone_space);
HS.impulse = (0.f); // l_P.w_float (0.f);
HS.hit_type = (ALife::eHitTypeWound); // l_P.w_u16 ((u16)ALife::eHitTypeWound);
HS.Write_Packet(l_P);
u_EventSend (l_P);
}
}
else
m_bActionStarted = false;
break;
}
case eRatActionAttackEnd : {
m_bActionStarted = false;
break;
}
default:
break;
}
}
示例5: DBG_OpenCashedDraw
void CExplosive::ExplodeWaveProcessObject(collide::rq_results& storage, CPhysicsShellHolder*l_pGO)
{
Fvector l_goPos;
if(l_pGO->Visual()) l_pGO->Center (l_goPos);
else return; //мне непонятно зачем наносить хит от взрыва по объектам не имеющим вижуал - поэтому игнорируем
#ifdef DEBUG
if(ph_dbg_draw_mask.test(phDbgDrawExplosions))
{
DBG_OpenCashedDraw();
}
#endif
float l_effect=ExplosionEffect(storage,this,l_pGO,m_vExplodePos,m_fBlastRadius);
float l_impuls = m_fBlastHitImpulse * l_effect;
float l_hit = m_fBlastHit * l_effect;
if(l_impuls > .001f||l_hit> 0.001)
{
Fvector l_dir;l_dir.sub(l_goPos,m_vExplodePos);
float rmag=_sqrt(m_fUpThrowFactor*m_fUpThrowFactor+1.f+2.f*m_fUpThrowFactor*l_dir.y);
l_dir.y += m_fUpThrowFactor;
//rmag -модуль l_dir после l_dir.y += m_fUpThrowFactor, модуль=_sqrt(l_dir^2+y^2+2.*(l_dir,y)),y=(0,m_fUpThrowFactor,0) (до этого модуль l_dir =1)
l_dir.mul(1.f/rmag);//перенормировка
NET_Packet P;
SHit HS;
HS.GenHeader(GE_HIT, l_pGO->ID()); // cast_game_object()->u_EventGen (P,GE_HIT,l_pGO->ID());
HS.whoID =Initiator(); // P.w_u16 (Initiator());
HS.weaponID = cast_game_object()->ID(); // P.w_u16 (cast_game_object()->ID());
HS.dir = l_dir; // P.w_dir (l_dir);
HS.power = l_hit; // P.w_float (l_hit);
HS.p_in_bone_space = l_goPos; // P.w_vec3 (l_goPos);
HS.impulse = l_impuls; // P.w_float (l_impuls);
HS.hit_type = (m_eHitTypeBlast); // P.w_u16 (u16(m_eHitTypeBlast));
HS.boneID = 0; // P.w_s16 (0);
HS.Write_Packet(P);
cast_game_object()->u_EventSend (P);
}
#ifdef DEBUG
if(ph_dbg_draw_mask.test(phDbgDrawExplosions))
{
DBG_ClosedCashedDraw(100000);
}
#endif
}
示例6: Hit_Wound
void CBaseMonster::Hit_Wound(CObject *object, float value, const Fvector &dir, float impulse)
{
NET_Packet P;
SHit HS;
HS.GenHeader(GE_HIT, object->ID()); // u_EventGen (P,GE_HIT, object->ID());
HS.whoID = (ID()); // P.w_u16 (ID());
HS.weaponID = (ID()); // P.w_u16 (ID());
HS.dir = (dir); // P.w_dir (dir);
HS.power = (value); // P.w_float (value);
HS.boneID = (smart_cast<IKinematics*>(object->Visual())->LL_GetBoneRoot()); // P.w_s16 (smart_cast<IKinematics*>(object->Visual())->LL_GetBoneRoot());
HS.p_in_bone_space = (Fvector().set(0.f,0.f,0.f)); // P.w_vec3 (Fvector().set(0.f,0.f,0.f));
HS.impulse = (impulse); // P.w_float (impulse);
HS.hit_type = (ALife::eHitTypeWound); // P.w_u16 (u16(ALife::eHitTypeWound));
HS.Write_Packet(P);
u_EventSend (P);
}
示例7: Hit_Psy
void CBaseMonster::Hit_Psy(CObject *object, float value)
{
NET_Packet P;
SHit HS;
HS.GenHeader (GE_HIT, object->ID()); // // u_EventGen (P,GE_HIT, object->ID()); //
HS.whoID = (ID()); // own // P.w_u16 (ID()); // own
HS.weaponID = (ID()); // own // P.w_u16 (ID()); // own
HS.dir = (Fvector().set(0.f,1.f,0.f)); // direction // P.w_dir (Fvector().set(0.f,1.f,0.f)); // direction
HS.power = (value); // hit value // P.w_float (value); // hit value
HS.boneID = (BI_NONE); // bone // P.w_s16 (BI_NONE); // bone
HS.p_in_bone_space = (Fvector().set(0.f,0.f,0.f)); // P.w_vec3 (Fvector().set(0.f,0.f,0.f));
HS.impulse = (0.f); // P.w_float (0.f);
HS.hit_type = (ALife::eHitTypeTelepatic); // P.w_u16 (u16(ALife::eHitTypeTelepatic));
HS.Write_Packet (P);
u_EventSend (P);
}
示例8: character_physics_support
void CActor::g_Physics (Fvector& _accel, float jump, float dt)
{
// Correct accel
Fvector accel;
accel.set (_accel);
hit_slowmo -= dt;
if (hit_slowmo<0) hit_slowmo = 0.f;
accel.mul (1.f-hit_slowmo);
if(g_Alive())
{
if(mstate_real&mcClimb&&!cameras[eacFirstEye]->bClampYaw)accel.set(0.f,0.f,0.f);
character_physics_support()->movement()->Calculate (accel,cameras[cam_active]->vDirection,0,jump,dt,false);
bool new_border_state=character_physics_support()->movement()->isOutBorder();
if(m_bOutBorder!=new_border_state && Level().CurrentControlEntity() == this)
{
SwitchOutBorder(new_border_state);
}
character_physics_support()->movement()->GetPosition (Position());
character_physics_support()->movement()->bSleep =false;
}
if (Local() && g_Alive()) {
if (character_physics_support()->movement()->gcontact_Was)
Cameras().AddCamEffector (xr_new<CEffectorFall> (character_physics_support()->movement()->gcontact_Power));
if (!fis_zero(character_physics_support()->movement()->gcontact_HealthLost)) {
const ICollisionDamageInfo* di=character_physics_support()->movement()->CollisionDamageInfo();
Fvector hdir;di->HitDir(hdir);
SetHitInfo(this, NULL, 0, Fvector().set(0, 0, 0), hdir);
// Hit (m_PhysicMovementControl->gcontact_HealthLost,hdir,di->DamageInitiator(),m_PhysicMovementControl->ContactBone(),di->HitPos(),0.f,ALife::eHitTypeStrike);//s16(6 + 2*::Random.randI(0,2))
if (Level().CurrentControlEntity() == this)
{
SHit HDS = SHit(character_physics_support()->movement()->gcontact_HealthLost,hdir,di->DamageInitiator(),character_physics_support()->movement()->ContactBone(),di->HitPos(),0.f,di->HitType());
// Hit(&HDS);
NET_Packet l_P;
HDS.GenHeader(GE_HIT, ID());
HDS.whoID = di->DamageInitiator()->ID();
HDS.weaponID = di->DamageInitiator()->ID();
HDS.Write_Packet(l_P);
u_EventSend (l_P);
}
}
}
}
示例9: in_Hit
void CCharacterPhysicsSupport::in_Hit( SHit &H, bool is_killing )
{
m_sv_hit = H;
m_hit_valide_time = Device.dwTimeGlobal + hit_valide_time;
if( m_EntityAlife.use_simplified_visual ( ) || esRemoved == m_eState )
return;
if( m_flags.test( fl_block_hit ) )
{
VERIFY2( !m_EntityAlife.g_Alive( ),
make_string("entity [%s][%d] is dead", m_EntityAlife.Name(), m_EntityAlife.ID()).c_str());
if( Device.dwTimeGlobal - m_EntityAlife.GetLevelDeathTime( ) >= 2000 )
m_flags.set(fl_block_hit,FALSE);
else return;
}
//is_killing = is_killing || ( m_eState==esAlive && !m_EntityAlife.g_Alive( ) );
if( m_EntityAlife.g_Alive( ) && is_killing && H.type( ) == ALife::eHitTypeExplosion && H.damage( ) > 70.f )
CPHDestroyable::Destroy( );
if( ( !m_EntityAlife.g_Alive() || is_killing ) )
m_character_shell_control.set_kill_hit( H );
if(!m_pPhysicsShell&&is_killing)
KillHit( H );
if( m_flags.test(fl_use_hit_anims) && Type() != etBitting && !m_flags.test(fl_death_anim_on) ) //&& Type() == etStalker
{
m_hit_animations.PlayHitMotion( H.direction( ), H.bone_space_position(), H.bone( ), m_EntityAlife );
}
if( !( m_pPhysicsShell && m_pPhysicsShell->isActive( ) ) )
{
if( !is_killing && m_EntityAlife.g_Alive( ) )
m_PhysicMovementControl->ApplyHit( H.direction( ), H.phys_impulse( ), H.type( ) );
} else {
#ifdef DEBUG
if( is_killing && death_anim_debug && !is_imotion( m_interactive_motion ) )
{
Msg( "death anim: applied fatal impulse dir: (%f,%f,%f), value: (%f) ", H.dir.x,H.dir.y,H.dir.z, H.impulse );
}
#endif
m_pPhysicsShell->applyHit( H.bone_space_position( ), H.direction( ), H.phys_impulse( ), H.bone(), H.type( ) );
}
}
示例10: ProcessDamage
void CBreakableObject::ProcessDamage()
{
NET_Packet P;
SHit HS;
HS.GenHeader (GE_HIT, ID());
HS.whoID = (ID());
HS.weaponID = (ID());
HS.dir = (m_contact_damage_dir);
HS.power = (m_max_frame_damage);
HS.boneID = (PKinematics(Visual())->LL_GetBoneRoot());
HS.p_in_bone_space = (m_contact_damage_pos);
HS.impulse = (0.f);
HS.hit_type = (ALife::eHitTypeStrike);
HS.Write_Packet (P);
u_EventSend (P);
m_max_frame_damage = 0.f;
b_resived_damage =false;
}
示例11: GetHitImmunity
//void CCar::Hit(float P,Fvector &dir,CObject * who,s16 element,Fvector p_in_object_space, float impulse, ALife::EHitType hit_type)
void CCar::Hit (SHit* pHDS)
{
SHit HDS = *pHDS;
//if(CDelayedActionFuse::isActive()||Initiator()==u16(-1)&&HDS.hit_type==ALife::eHitTypeStrike)
//{
// HDS.power=0.f;
//}
//if(HDS.who->ID()!=ID())
//{
// CExplosive::SetInitiator(HDS.who->ID());
//}
WheelHit(HDS.damage(),HDS.bone(),HDS.hit_type);
DoorHit(HDS.damage(),HDS.bone(),HDS.hit_type);
float hitScale=1.f,woundScale=1.f;
if(HDS.hit_type!=ALife::eHitTypeStrike) CDamageManager::HitScale(HDS.bone(), hitScale, woundScale);
HDS.power *= GetHitImmunity(HDS.hit_type)*hitScale;
inherited::Hit(&HDS);
if(!CDelayedActionFuse::isActive())
{
CDelayedActionFuse::CheckCondition(GetfHealth());
}
CDamagableItem::HitEffect();
// if(Owner()&&Owner()->ID()==Level().CurrentEntity()->ID())
// CurrentGameUI()->UIMainIngameWnd->CarPanel().SetCarHealth(GetfHealth());
}
示例12: XFORM
void CRadioactiveZone::UpdateWorkload (u32 dt)
{
if (IsEnabled() && GameID() != GAME_SINGLE)
{
OBJECT_INFO_VEC_IT it;
Fvector pos;
XFORM().transform_tiny(pos,CFORM()->getSphere().P);
for(it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it)
{
if( !(*it).object->getDestroy() && (*it).object->CLS_ID == CLSID_OBJECT_ACTOR)
{
//=====================================
NET_Packet l_P;
l_P.write_start();
l_P.read_start();
float dist = (*it).object->Position().distance_to(pos);
float power = Power(dist)*dt/1000;
/// Msg("Zone Dist %f, Radiation Power %f, ", dist, power);
SHit HS;
HS.GenHeader(GE_HIT, (*it).object->ID());
HS.whoID =ID();
HS.weaponID = ID();
HS.dir = Fvector().set(0,0,0);
HS.power = power;
HS.boneID = BI_NONE;
HS.p_in_bone_space = Fvector().set(0, 0, 0);
HS.impulse = 0.0f;
HS.hit_type = ALife::eHitTypeRadiation;
HS.Write_Packet_Cont(l_P);
(*it).object->OnEvent(l_P, HS.PACKET_TYPE);
//=====================================
};
}
}
inherited::UpdateWorkload(dt);
}
示例13: XFORM
void CRadioactiveZone::UpdateWorkload (u32 dt)
{
if (IsEnabled() && GameID() != eGameIDSingle)
{
OBJECT_INFO_VEC_IT it;
Fvector pos;
XFORM().transform_tiny(pos,CFORM()->getSphere().P);
for(it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it)
{
if( !(*it).object->getDestroy() && smart_cast<CActor*>((*it).object))
{
//=====================================
NET_Packet l_P;
l_P.write_start();
l_P.read_start();
float dist = (*it).object->Position().distance_to(pos);
float power = Power(dist,nearest_shape_radius(it))*dt/1000;
SHit HS;
HS.GenHeader (GE_HIT, (*it).object->ID());
HS.whoID = ID();
HS.weaponID = ID();
HS.dir = Fvector().set(0,0,0);
HS.power = power;
HS.boneID = BI_NONE;
HS.p_in_bone_space = Fvector().set(0, 0, 0);
HS.impulse = 0.0f;
HS.hit_type = m_eHitTypeBlowout;
HS.Write_Packet_Cont(l_P);
(*it).object->OnEvent(l_P, HS.PACKET_TYPE);
//=====================================
};
}
}
inherited::UpdateWorkload(dt);
}
示例14: type_motion_diagnostic
void type_motion_diagnostic( LPCSTR message, type_motion::edirection dr, const CEntityAlive& ea, const SHit& H, const MotionID &m )
{
#ifdef DEBUG
if(! death_anim_debug )
return;
IKinematicsAnimated *KA = smart_cast<IKinematicsAnimated*>( ea.Visual() );
VERIFY( KA );
IKinematics *K = smart_cast<IKinematics*>( ea.Visual() );
LPCSTR bone_name = "not_definite";
if( H.bone() != BI_NONE )
{
CBoneData& bd = K->LL_GetData( H.bone() );
bone_name = bd.name.c_str();
}
LPCSTR motion_name = "not_set";
if( m.valid() )
motion_name = KA->LL_MotionDefName_dbg( m ).first;
Msg( "death anims: %s, dir: %s, motion: %s, obj: %s, model: %s, bone: %s " ,message ,motion_dirs[ dr ].name, motion_name, ea.cName().c_str(), ea.cNameVisual().c_str(), bone_name );
#endif
}
示例15: SHit
void CCustomZone::CreateHit ( u16 id_to,
u16 id_from,
const Fvector& hit_dir,
float hit_power,
s16 bone_id,
const Fvector& pos_in_bone,
float hit_impulse,
ALife::EHitType hit_type)
{
if (OnServer())
{
if(m_owner_id != u32(-1) )
id_from = (u16)m_owner_id;
NET_Packet l_P;
Fvector hdir = hit_dir;
SHit Hit = SHit(hit_power, hdir, this, bone_id, pos_in_bone, hit_impulse, hit_type, 0.0f, false);
Hit.GenHeader (GE_HIT, id_to);
Hit.whoID = id_from;
Hit.weaponID = this->ID();
Hit.Write_Packet (l_P);
u_EventSend (l_P);
};
}