MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / FireBullet

Method FireBullet

ogsr_engine/xrGame/ShootingObject.cpp:412–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410};
411
412void CShootingObject::FireBullet(const Fvector& pos, const Fvector& shot_dir, float fire_disp, const CCartridge& cartridge, u16 parent_id, u16 weapon_id, bool send_hit)
413{
414 Fvector dir;
415 dir.random_dir(shot_dir, fire_disp);
416
417 if (!Core.Features.test(xrCore::Feature::npc_simplified_shooting) || ParentIsActor())
418 if (!fis_zero(constDeviation.pitch) || !fis_zero(constDeviation.yaw))
419 {
420 // WARN: при больших значениях девиации стрелок может отсрелить себе голову!
421 float dir_yaw, dir_pitch;
422 dir.getHP(dir_yaw, dir_pitch);
423 dir_pitch += constDeviation.pitch;
424 dir_yaw += constDeviation.yaw;
425 dir.setHP(dir_yaw, dir_pitch);
426 }
427
428 m_iCurrentParentID = parent_id;
429
430 bool aim_bullet;
431 if (m_bUseAimBullet)
432 {
433 if (ParentIsActor())
434 {
435 if (m_fPredBulletTime == 0.0)
436 {
437 aim_bullet = true;
438 }
439 else
440 {
441 if ((Device.fTimeGlobal - m_fPredBulletTime) >= m_fTimeToAim)
442 {
443 aim_bullet = true;
444 }
445 else
446 {
447 aim_bullet = false;
448 }
449 }
450 }
451 else
452 {
453 aim_bullet = false;
454 }
455 }
456 else
457 {
458 aim_bullet = false;
459 }
460 m_fPredBulletTime = Device.fTimeGlobal;
461
462 float l_fHitPower;
463 if (ParentIsActor()) //если из оружия стреляет актёр(игрок)
464 {
465 l_fHitPower = fvHitPower[g_SingleGameDifficulty];
466 }
467 else
468 {
469 l_fHitPower = fvHitPower[egdMaster];

Callers

nothing calls this directly

Calls 5

fis_zeroFunction · 0.85
random_dirMethod · 0.80
getHPMethod · 0.80
setHPMethod · 0.80
testMethod · 0.45

Tested by

no test coverage detected