Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.58 KB | None | 0 0
  1. /-----------------------------------------------------------------------------
  2. // Ability: Fire Breath
  3. //-----------------------------------------------------------------------------
  4. #ifdef CLIENT_DLL
  5. #define CDOTA_Ability_Creature_Fire_Breath C_DOTA_Ability_Creature_Fire_Breath
  6. #endif
  7. schema class CDOTA_Ability_Creature_Fire_Breath : public CDOTABaseAbility
  8. {
  9.     DECLARE_ENTITY_CLASS( CDOTA_Ability_Creature_Fire_Breath, CDOTABaseAbility, "creature_fire_breath" );
  10. public:
  11.    
  12.     void OnSpellStart( void ) OVERRIDE;
  13.  
  14.     bool OnProjectileHit( EHANDLE hTarget, const Vector &vLocation ) OVERRIDE;
  15.  
  16. #ifdef SERVER_DLL
  17.     virtual void OnChannelThink( float flInterfClampedVal ) OVERRIDE;
  18. #endif
  19.  
  20. public:
  21.  
  22.     int speed;
  23.     int projectile_count;
  24.     float rotation_angle;
  25.     float damage;
  26.     float radius;
  27.     CountdownTimer ctTimer;
  28.     Vector m_vecStartRot;
  29.     Vector m_vecEndRot;
  30. };
  31.  
  32.  
  33. LINK_ENTITY_TO_CLASS( creature_fire_breath, CDOTA_Ability_Creature_Fire_Breath );
  34.  
  35.  
  36. //-----------------------------------------------------------------------------
  37.  
  38. void CDOTA_Ability_Creature_Fire_Breath::OnSpellStart( void )
  39. {
  40. #ifdef SERVER_DLL
  41.     DOTA_ABILITY_RETRIEVE_VALUE( rotation_angle );
  42.     DOTA_ABILITY_RETRIEVE_VALUE( radius );
  43.     DOTA_ABILITY_RETRIEVE_VALUE( speed );
  44.     DOTA_ABILITY_RETRIEVE_VALUE( damage );
  45.     DOTA_ABILITY_RETRIEVE_VALUE( projectile_count );
  46.  
  47.     QAngle angles = GetCaster()->GetAbsAngles();
  48.     Vector vecFwd;
  49.     AngleVectors( angles, &vecFwd );
  50.     matrix3x4_t matRot;
  51.     Vector vecRotAxis = Vector ( 0, 0, 1 );
  52.     MatrixBuildRotationAboutAxis ( vecRotAxis, -rotation_angle/2, matRot );
  53.     VectorRotate( vecFwd, matRot, m_vecStartRot );
  54.     MatrixBuildRotationAboutAxis ( vecRotAxis, rotation_angle/2, matRot );
  55.     VectorRotate( vecFwd, matRot, m_vecEndRot );
  56.  
  57.     float flTiming = GetChannelTime() / float( projectile_count );
  58.     ctTimer.Start( flTiming );
  59.  
  60.     DOTA_EmitSound( DOTA_EMIT_SOUND_FLAGS_NEARBY | DOTA_EMIT_SOUND_FLAGS_VISIBLE, "Creature.FireBreath.Cast", GetCaster() );
  61. #endif
  62. }
  63.  
  64. //-----------------------------------------------------------------------------
  65. #ifdef SERVER_DLL
  66. void CDOTA_Ability_Creature_Fire_Breath::OnChannelThink( float flInterfClampedVal )
  67. {
  68.     BaseClass::OnChannelThink( flInterfClampedVal );
  69.     if ( !ctTimer.IsElapsed() )
  70.         return;
  71.  
  72.     ctTimer.Reset();
  73.  
  74.     Vector vDirection = VectorLerp( m_vecStartRot, m_vecEndRot, RemapValClamped( GetGameTime(), GetChannelStartTime(),  GetChannelStartTime() + GetChannelTime(), 0.0f, 1.0f  ));
  75.  
  76.     VectorNormalize( vDirection );
  77.  
  78.     sLinearProjectileCreateInfo info;
  79.     info.pszEffectName = "particles/neutral_fx/mini_rosh_fire.vpcf";
  80.     info.bStickyFoWReveal = true;
  81.     info.pAbility = this;
  82.     info.vVelocity = vDirection * speed;
  83.     info.vSpawnOrigin = GetCaster()->GetAbsOrigin();
  84.     info.fDistance = GetCastRange();
  85.     info.fStartRadius = radius;
  86.     info.fEndRadius = radius;
  87.     info.hSource = GetCaster();
  88.     info.iUnitTargetTeam = DOTA_UNIT_TARGET_TEAM_ENEMY;
  89.     info.iUnitTargetType = DOTA_UNIT_TARGET_HERO | DOTA_UNIT_TARGET_BASIC;
  90.     info.iUnitTargetFlags = DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES;
  91.     info.iVisionTeamNumber = GetCaster()->GetTeamNumber();
  92.  
  93.     g_DOTAProjectileManager.CreateLinearProjectile( info );
  94.  
  95. }
  96. #endif
  97.  
  98.  
  99. //-----------------------------------------------------------------------------
  100.  
  101. bool CDOTA_Ability_Creature_Fire_Breath::OnProjectileHit( EHANDLE hTarget, const Vector &vLocation )
  102. {
  103. #ifdef SERVER_DLL
  104.     CDOTA_BaseNPC *pTarget = ToDOTABaseNPC( hTarget );
  105.     if ( pTarget && !pTarget->IsInvulnerable() && !pTarget->IsAncient() )
  106.     {
  107.         ApplyDamage( GetCaster(), pTarget, this, damage, DAMAGE_TYPE_MAGICAL );
  108.     }
  109. #endif
  110.  
  111.     return false;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement