SHARE
TWEET

Untitled

a guest Jun 5th, 2018 136 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * Custom Barney/Barnabus monster entity
  3. * Call BarneyCustom::Register() to register this entity.
  4. * Entity classname: monster_barney_custom
  5. */
  6.  
  7. namespace BarneyCustom
  8. {
  9.  
  10. const int BARNEY_AE_DRAW            = 2;
  11. const int BARNEY_AE_SHOOT           = 3;
  12. const int BARNEY_AE_HOLSTER         = 4;
  13. const int BARNEY_BODY_GUNHOLSTERED  = 0;
  14. const int BARNEY_BODY_GUNDRAWN      = 1;
  15. const int BARNEY_BODY_GUNGONE       = 2;
  16.  
  17. class CMonsterBarneyCustom : ScriptBaseMonsterEntity
  18. {
  19.     private bool    m_fGunDrawn;
  20.     private float   m_painTime;
  21.     private int     m_head;
  22.     private int     m_iBrassShell;
  23.     private int     m_cClipSize;
  24.     private float   m_flNextFearScream;
  25.    
  26.     CMonsterBarneyCustom()
  27.     {
  28.         @this.m_Schedules = @monster_barney_schedules;
  29.     }
  30.    
  31.     int ObjectCaps()
  32.     {
  33.         if( self.IsPlayerAlly() )
  34.             return FCAP_IMPULSE_USE;
  35.         else
  36.             return BaseClass.ObjectCaps();
  37.     }
  38.    
  39.     void RunTask( Task@ pTask )
  40.     {
  41.         switch ( pTask.iTask )
  42.         {
  43.         case TASK_RANGE_ATTACK1:
  44.             //if (self.m_hEnemy().IsValid() && (self.m_hEnemy().GetEntity().IsPlayer()))
  45.                 self.pev.framerate = 1.5f;
  46.  
  47.                 //m_flThinkDelay = 0.0f;
  48.  
  49.  
  50.             //Friendly fire stuff.
  51.             if( !self.NoFriendlyFire() )
  52.             {
  53.                 self.ChangeSchedule( self.GetScheduleOfType ( SCHED_FIND_ATTACK_POINT ) );
  54.                 return;
  55.             }
  56.  
  57.             BaseClass.RunTask( pTask );
  58.             break;
  59.         case TASK_RELOAD:
  60.             {
  61.                 self.MakeIdealYaw ( self.m_vecEnemyLKP );
  62.                 self.ChangeYaw ( int(self.pev.yaw_speed) );
  63.  
  64.                 if ( self.m_fSequenceFinished )
  65.                 {
  66.                     self.m_cAmmoLoaded = m_cClipSize;
  67.                     self.ClearConditions(bits_COND_NO_AMMO_LOADED);
  68.                     //m_Activity = ACT_RESET;
  69.  
  70.                     self.TaskComplete();
  71.                 }
  72.                 break;
  73.             }
  74.         default:
  75.             BaseClass.RunTask( pTask );
  76.             break;
  77.         }
  78.     }
  79.    
  80.     int ISoundMask()
  81.     {
  82.         return  bits_SOUND_WORLD    |
  83.                 bits_SOUND_COMBAT   |
  84.                 bits_SOUND_BULLETHIT|
  85.                 bits_SOUND_CARCASS  |
  86.                 bits_SOUND_MEAT     |
  87.                 bits_SOUND_GARBAGE  |
  88.                 bits_SOUND_DANGER   |
  89.                 bits_SOUND_PLAYER;
  90.     }
  91.    
  92.     int Classify()
  93.     {
  94.         return self.GetClassification( CLASS_HUMAN_MILITARY );
  95.     }
  96.    
  97.     void SetYawSpeed()
  98.     {
  99.         int ys = 0;
  100.  
  101.         /*
  102.         switch ( m_Activity )
  103.         {
  104.         case ACT_TURN_LEFT:
  105.         case ACT_TURN_RIGHT:
  106.             ys = 180;
  107.             break;
  108.         case ACT_IDLE:
  109.         case ACT_WALK:
  110.             ys = 70;   
  111.             break;
  112.         case ACT_RUN:  
  113.             ys = 90;   
  114.             break;
  115.         default:      
  116.             ys = 70;   
  117.             break;
  118.         }
  119.         */
  120.  
  121.         ys = 360; //270 seems to be an ideal speed, which matches most animations
  122.  
  123.         self.pev.yaw_speed = ys;
  124.     }
  125.    
  126.     bool CheckRangeAttack1( float flDot, float flDist )
  127.     {  
  128.         if ( flDist <= 2048 && flDot >= 0.5 && self.NoFriendlyFire())
  129.         {
  130.             CBaseEntity@ pEnemy = self.m_hEnemy.GetEntity();
  131.             TraceResult tr;
  132.             Vector shootOrigin = self.pev.origin + Vector( 0, 0, 55 );
  133.             Vector shootTarget = (pEnemy.BodyTarget( shootOrigin ) - pEnemy.Center()) + self.m_vecEnemyLKP;
  134.             g_Utility.TraceLine( shootOrigin, shootTarget, dont_ignore_monsters, self.edict(), tr );
  135.                        
  136.             if ( tr.flFraction == 1.0 || tr.pHit is pEnemy.edict() )
  137.                 return true;
  138.         }
  139.  
  140.         return false;
  141.     }
  142.    
  143.     void BarneyFirePistol()
  144.     {
  145.         Math.MakeVectors( self.pev.angles );
  146.         Vector vecShootOrigin = self.pev.origin + Vector( 0, 0, 55 );
  147.         Vector vecShootDir  = self.ShootAtEnemy( vecShootOrigin );
  148.         Vector angDir           = Math.VecToAngles( vecShootDir );
  149.  
  150.         self.FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_9MM );
  151.         Vector vecShellVelocity = g_Engine.v_right * Math.RandomFloat(40,90) + g_Engine.v_up * Math.RandomFloat(75,200) + g_Engine.v_forward * Math.RandomFloat(-40, 40);
  152.         g_EntityFuncs.EjectBrass( vecShootOrigin - vecShootDir * -17, vecShellVelocity, self.pev.angles.y, m_iBrassShell, TE_BOUNCE_SHELL);
  153.  
  154.         int pitchShift = Math.RandomLong( 0, 20 );
  155.         if ( pitchShift > 10 )// Only shift about half the time
  156.             pitchShift = 0;
  157.         else
  158.             pitchShift -= 5;
  159.        
  160.         self.SetBlending( 0, angDir.x );
  161.         self.pev.effects = EF_MUZZLEFLASH;
  162.         GetSoundEntInstance().InsertSound ( bits_SOUND_COMBAT, self.pev.origin, NORMAL_GUN_VOLUME, 0.3, self );
  163.         g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_WEAPON, "weapons/pl_gun3.wav", 1, ATTN_NORM, 0, PITCH_NORM + pitchShift );
  164.  
  165.  
  166.         if( self.pev.movetype != MOVETYPE_FLY && self.m_MonsterState != MONSTERSTATE_PRONE )
  167.         {
  168.             self.m_flAutomaticAttackTime = g_Engine.time + Math.RandomFloat(0.2, 0.5);
  169.         }
  170.  
  171.         // UNDONE: Reload?
  172.         --self.m_cAmmoLoaded;// take away a bullet!
  173.     }
  174.    
  175.     void CheckAmmo()
  176.     {
  177.         if ( self.m_cAmmoLoaded <= 0 )
  178.             self.SetConditions( bits_COND_NO_AMMO_LOADED );
  179.     }
  180.    
  181.     void HandleAnimEvent( MonsterEvent@ pEvent )
  182.     {
  183.         switch( pEvent.event )
  184.         {
  185.         case BARNEY_AE_SHOOT:
  186.             BarneyFirePistol();
  187.             break;
  188.         case BARNEY_AE_DRAW:
  189.             // barney's bodygroup switches here so he can pull gun from holster
  190.             self.pev.body = BARNEY_BODY_GUNDRAWN;
  191.             m_fGunDrawn = true;
  192.             break;
  193.  
  194.         case BARNEY_AE_HOLSTER:
  195.             // change bodygroup to replace gun in holster
  196.             self.pev.body = BARNEY_BODY_GUNHOLSTERED;
  197.             m_fGunDrawn = false;
  198.             break;
  199.  
  200.         default:
  201.             BaseClass.HandleAnimEvent( pEvent );
  202.         }
  203.     }
  204.    
  205.     void Precache()
  206.     {
  207.         BaseClass.Precache();
  208.        
  209.         g_Game.AlertMessage( at_console, "model: %1\n", string( self.pev.model ) );
  210.  
  211.         //Model precache optimization
  212.         if( string( self.pev.model ).IsEmpty() )
  213.         {
  214.             g_Game.AlertMessage( at_console, "setting model: %1\n", self.IsPlayerAlly() );
  215.             if( self.IsPlayerAlly() )
  216.                 g_Game.PrecacheModel("models/barney.mdl");
  217.             else
  218.                 g_Game.PrecacheModel("models/barnabus.mdl");
  219.         }
  220.  
  221.         //g_SoundSystem.PrecacheSound("barney/ba_attack1.wav");
  222.         g_SoundSystem.PrecacheSound("barney/ba_attack2.wav");
  223.         g_SoundSystem.PrecacheSound("barney/ba_pain1.wav");
  224.         g_SoundSystem.PrecacheSound("barney/ba_pain2.wav");
  225.         g_SoundSystem.PrecacheSound("barney/ba_pain3.wav");
  226.         g_SoundSystem.PrecacheSound("barney/ba_die1.wav");
  227.         g_SoundSystem.PrecacheSound("barney/ba_die2.wav");
  228.         g_SoundSystem.PrecacheSound("barney/ba_die3.wav");
  229.  
  230.         g_SoundSystem.PrecacheSound("barney/down.wav");
  231.         g_SoundSystem.PrecacheSound("barney/hey.wav");
  232.         g_SoundSystem.PrecacheSound("barney/aghh.wav");
  233.  
  234.         m_iBrassShell = g_Game.PrecacheModel("models/shell.mdl");
  235.     }
  236.    
  237.     void Spawn()
  238.     {
  239.         Precache();
  240.        
  241.         if( !self.SetupModel() )
  242.             self.SetupFriendly();
  243.  
  244.         g_EntityFuncs.SetSize( self.pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX );
  245.    
  246.         pev.solid                   = SOLID_SLIDEBOX;
  247.         pev.movetype                = MOVETYPE_STEP;
  248.         self.m_bloodColor           = BLOOD_COLOR_RED;
  249.         if( self.pev.health == 0.0f )
  250.             self.pev.health  = 100.0f;
  251.         self.pev.view_ofs           = Vector( 0, 0, 50 );// position of the eyes relative to monster's origin.
  252.         self.m_flFieldOfView        = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so npc will notice player and say hello
  253.         self.m_MonsterState         = MONSTERSTATE_NONE;
  254.         self.pev.body               = 0; // gun in holster
  255.         m_fGunDrawn                 = false;
  256.         self.m_afCapability         = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP | bits_CAP_USE_TANK;
  257.         self.m_fCanFearCreatures    = true; // Can attempt to run away from things like zombies
  258.         m_flNextFearScream          = g_Engine.time;
  259.         //self.m_afMoveShootCap()   = bits_MOVESHOOT_RANGE_ATTACK1;
  260.  
  261.         m_cClipSize                 = 17; //17 Shots
  262.         self.m_cAmmoLoaded          = m_cClipSize;
  263.  
  264.         if( string( self.m_FormattedName ).IsEmpty() )
  265.         {
  266.             if( self.IsPlayerAlly() )
  267.                 self.m_FormattedName = "Barney";
  268.             else
  269.                 self.m_FormattedName = "Barnabus";
  270.         }
  271.  
  272.         self.MonsterInit();
  273.        
  274.         if( self.IsPlayerAlly() )
  275.             SetUse( UseFunction( this.FollowerUse ) );
  276.     }
  277.    
  278.     void SetupFriendly()
  279.     {
  280.         if( self.IsPlayerAlly() )
  281.             g_EntityFuncs.SetModel( self, "models/barney.mdl" );
  282.         else
  283.             g_EntityFuncs.SetModel( self, "models/barnabus.mdl" );
  284.     }
  285.    
  286.     int TakeDamage( entvars_t@ pevInflictor, entvars_t@ pevAttacker, float flDamage, int bitsDamageType)
  287.     {  
  288.         if( pevAttacker is null )
  289.             return 0;
  290.  
  291.         CBaseEntity@ pAttacker = g_EntityFuncs.Instance( pevAttacker );
  292.  
  293.         if( self.CheckAttacker( pAttacker ) )
  294.             return 0;
  295.  
  296.         // make sure friends talk about it if player hurts talkmonsters...
  297.         int ret = BaseClass.TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType);
  298.         if ( ( !self.IsAlive() || self.pev.deadflag == DEAD_DYING) && (!self.IsPlayerAlly()))   // evils dont alert friends!
  299.             return ret;
  300.  
  301.         if ( self.m_MonsterState != MONSTERSTATE_PRONE && (pevAttacker.flags & FL_CLIENT) != 0 )
  302.         {
  303.             // This is a heurstic to determine if the player intended to harm me
  304.             // If I have an enemy, we can't establish intent (may just be crossfire)
  305.             if ( !self.m_hEnemy.IsValid() )
  306.             {      
  307.                 if( self.pev.deadflag == DEAD_NO )
  308.                 {
  309.                     // If the player was facing directly at me, or I'm already suspicious, get mad
  310.                     if ( (self.m_afMemory & bits_MEMORY_SUSPICIOUS) != 0 || pAttacker.IsFacing( self.pev, 0.96f ) )
  311.                     {
  312.                         // Alright, now I'm pissed!
  313.                         //PlaySentence( "BA_MAD", 4, VOL_NORM, ATTN_NORM );
  314.  
  315.                         self.Remember( bits_MEMORY_PROVOKED );
  316.                         self.StopFollowing( true );
  317.                     }
  318.                     else
  319.                     {
  320.                         // Hey, be careful with that
  321.                         //PlaySentence( "BA_SHOT", 4, VOL_NORM, ATTN_NORM );
  322.                         self.Remember( bits_MEMORY_SUSPICIOUS );
  323.                     }
  324.                 }
  325.             }
  326.             else if ( (!self.m_hEnemy.GetEntity().IsPlayer()) && self.pev.deadflag == DEAD_NO )
  327.             {
  328.                 //PlaySentence( "BA_SHOT", 4, VOL_NORM, ATTN_NORM );
  329.             }
  330.         }
  331.  
  332.         return ret;
  333.     }
  334.    
  335.     void FearScream()
  336.     {
  337.         if( m_flNextFearScream < g_Engine.time )
  338.         {
  339.             switch (Math.RandomLong(0,2))
  340.             {
  341.             case 0: g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_VOICE, "barney/down.wav", 1, ATTN_NORM, 0, PITCH_NORM); break;
  342.             case 1: g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_VOICE, "barney/aghh.wav", 1, ATTN_NORM, 0, PITCH_NORM); break;
  343.             case 2: g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_VOICE, "barney/hey.wav", 1, ATTN_NORM, 0, PITCH_NORM); break;
  344.             }
  345.  
  346.             m_flNextFearScream = g_Engine.time + Math.RandomLong(2,5);
  347.         }
  348.     }
  349.    
  350.     void PainSound()
  351.     {
  352.         if (g_Engine.time < m_painTime)
  353.             return;
  354.        
  355.         m_painTime = g_Engine.time + Math.RandomFloat(0.5, 0.75);
  356.         switch (Math.RandomLong(0,2))
  357.         {
  358.         case 0: g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_VOICE, "barney/ba_pain1.wav", 1, ATTN_NORM, 0, PITCH_NORM); break;
  359.         case 1: g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_VOICE, "barney/ba_pain2.wav", 1, ATTN_NORM, 0, PITCH_NORM); break;
  360.         case 2: g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_VOICE, "barney/ba_pain3.wav", 1, ATTN_NORM, 0, PITCH_NORM); break;
  361.         }
  362.     }
  363.    
  364.     void DeathSound()
  365.     {
  366.         switch (Math.RandomLong(0,2))
  367.         {
  368.         case 0: g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_VOICE, "barney/ba_die1.wav", 1, ATTN_NORM, 0, PITCH_NORM); break;
  369.         case 1: g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_VOICE, "barney/ba_die2.wav", 1, ATTN_NORM, 0, PITCH_NORM); break;
  370.         case 2: g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_VOICE, "barney/ba_die3.wav", 1, ATTN_NORM, 0, PITCH_NORM); break;
  371.         }
  372.     }
  373.    
  374.     void TraceAttack( entvars_t@ pevAttacker, float flDamage, Vector vecDir, TraceResult& in ptr, int bitsDamageType)
  375.     {
  376.         switch( ptr.iHitgroup)
  377.         {
  378.         case HITGROUP_CHEST:
  379.         case HITGROUP_STOMACH:
  380.             if (( bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_BLAST) ) != 0)
  381.             {
  382.                 if(flDamage >= 2)
  383.                     flDamage -= 2;
  384.  
  385.                 flDamage *= 0.5;
  386.             }
  387.             break;
  388.         case 10:
  389.             if (( bitsDamageType & (DMG_SNIPER | DMG_BULLET | DMG_SLASH | DMG_CLUB) ) != 0)
  390.             {
  391.                 flDamage -= 20;
  392.                 if (flDamage <= 0)
  393.                 {
  394.                     g_Utility.Ricochet( ptr.vecEndPos, 1.0 );
  395.                     flDamage = 0.01;
  396.                 }
  397.             }
  398.             // always a head shot
  399.             ptr.iHitgroup = HITGROUP_HEAD;
  400.             break;
  401.         }
  402.  
  403.         BaseClass.TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType );
  404.     }
  405.    
  406.     Schedule@ GetScheduleOfType ( int Type )
  407.     {      
  408.         Schedule@ psched;
  409.  
  410.         switch( Type )
  411.         {
  412.         case SCHED_ARM_WEAPON:
  413.             if ( self.m_hEnemy.IsValid() )
  414.                 return slBarneyEnemyDraw;// face enemy, then draw.
  415.             break;
  416.  
  417.         // Hook these to make a looping schedule
  418.         case SCHED_TARGET_FACE:
  419.             // call base class default so that barney will talk
  420.             // when 'used'
  421.             @psched = BaseClass.GetScheduleOfType(Type);
  422.            
  423.             if (psched is Schedules::slIdleStand)
  424.                 return slBaFaceTarget;  // override this for different target face behavior
  425.             else
  426.                 return psched;
  427.                
  428.  
  429.         case SCHED_RELOAD:
  430.             return slBaReloadQuick; //Immediately reload.
  431.  
  432.         case SCHED_BARNEY_RELOAD:
  433.             return slBaReload;
  434.  
  435.         case SCHED_TARGET_CHASE:
  436.             return slBaFollow;
  437.  
  438.         case SCHED_IDLE_STAND:
  439.             // call base class default so that scientist will talk
  440.             // when standing during idle
  441.             @psched = BaseClass.GetScheduleOfType(Type);
  442.  
  443.             if (psched is Schedules::slIdleStand)      
  444.                 return slIdleBaStand;// just look straight ahead.
  445.             else
  446.                 return psched; 
  447.         }
  448.  
  449.         return BaseClass.GetScheduleOfType( Type );
  450.     }
  451.    
  452.     Schedule@ GetSchedule()
  453.     {
  454.         if ( self.HasConditions( bits_COND_HEAR_SOUND ) )
  455.         {
  456.             CSound@ pSound = self.PBestSound();
  457.  
  458.             if ( pSound !is null && (pSound.m_iType & bits_SOUND_DANGER) != 0 )
  459.             {
  460.                 FearScream(); //AGHH!!!!
  461.                 return self.GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND );
  462.             }
  463.         }
  464.  
  465.         if ( self.HasConditions( bits_COND_ENEMY_DEAD ) )
  466.             self.PlaySentence( "BA_KILL", 4, VOL_NORM, ATTN_NORM );
  467.  
  468.         switch( self.m_MonsterState )
  469.         {
  470.         case MONSTERSTATE_COMBAT:
  471.             {
  472.                 // dead enemy
  473.                 if ( self.HasConditions( bits_COND_ENEMY_DEAD ) )              
  474.                     return BaseClass.GetSchedule();// call base class, all code to handle dead enemies is centralized there.
  475.  
  476.                 // always act surprized with a new enemy
  477.                 if ( self.HasConditions( bits_COND_NEW_ENEMY ) && self.HasConditions( bits_COND_LIGHT_DAMAGE) )
  478.                     return self.GetScheduleOfType( SCHED_SMALL_FLINCH );
  479.                    
  480.                 // wait for one schedule to draw gun
  481.                 if( !m_fGunDrawn )
  482.                     return self.GetScheduleOfType( SCHED_ARM_WEAPON );
  483.  
  484.                 if ( self.HasConditions( bits_COND_HEAVY_DAMAGE ) )
  485.                     return self.GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY );
  486.                
  487.                 //Barney reloads now.
  488.                 if ( self.HasConditions ( bits_COND_NO_AMMO_LOADED ) )
  489.                     return self.GetScheduleOfType ( SCHED_BARNEY_RELOAD );
  490.             }
  491.             break;
  492.  
  493.         case MONSTERSTATE_IDLE:
  494.                 //Barney reloads now.
  495.                 if ( self.m_cAmmoLoaded != m_cClipSize )
  496.                     return self.GetScheduleOfType( SCHED_BARNEY_RELOAD );
  497.  
  498.         case MONSTERSTATE_ALERT:   
  499.             {
  500.                 if ( self.HasConditions(bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE) )
  501.                     return self.GetScheduleOfType( SCHED_SMALL_FLINCH ); // flinch if hurt
  502.  
  503.                 //The player might have just +used us, immediately follow and dis-regard enemies.
  504.                 //This state gets set (alert) when the monster gets +used
  505.                 if ( (!self.m_hEnemy.IsValid() || !self.HasConditions( bits_COND_SEE_ENEMY)) && self.IsPlayerFollowing() )  //Start Player Following
  506.                 {
  507.                     if ( !self.m_hTargetEnt.GetEntity().IsAlive() )
  508.                     {                  
  509.                         self.StopFollowing( false );// UNDONE: Comment about the recently dead player here?
  510.                         break;
  511.                     }
  512.                     else
  513.                     {
  514.                            
  515.                         return self.GetScheduleOfType( SCHED_TARGET_FACE );
  516.                     }
  517.                 }
  518.             }
  519.             break;
  520.         }
  521.        
  522.         return BaseClass.GetSchedule();
  523.     }
  524.    
  525.     void FollowerUse( CBaseEntity@ pActivator, CBaseEntity@ pCaller, USE_TYPE useType, float flValue )
  526.     {
  527.         self.FollowerPlayerUse( pActivator, pCaller, useType, flValue );
  528.        
  529.         CBaseEntity@ pTarget = self.m_hTargetEnt;
  530.        
  531.         if( pTarget is pActivator )
  532.         {
  533.             g_SoundSystem.PlaySentenceGroup( self.edict(), "BA_OK", 1.0, ATTN_NORM, 0, PITCH_NORM );
  534.         }
  535.         else
  536.             g_SoundSystem.PlaySentenceGroup( self.edict(), "BA_WAIT", 1.0, ATTN_NORM, 0, PITCH_NORM );
  537.     }
  538. }
  539.  
  540. array<ScriptSchedule@>@ monster_barney_schedules;
  541.  
  542. ScriptSchedule slBaFollow(
  543.     bits_COND_NEW_ENEMY     |
  544.     bits_COND_LIGHT_DAMAGE  |
  545.     bits_COND_HEAVY_DAMAGE  |
  546.     bits_COND_HEAR_SOUND,
  547.     bits_SOUND_DANGER,
  548.     "Follow" );
  549.        
  550. ScriptSchedule slBaFaceTarget(
  551.     //bits_COND_CLIENT_PUSH |
  552.     bits_COND_NEW_ENEMY     |
  553.     bits_COND_LIGHT_DAMAGE  |
  554.     bits_COND_HEAVY_DAMAGE  |
  555.     bits_COND_HEAR_SOUND ,
  556.     bits_SOUND_DANGER,
  557.     "FaceTarget" );
  558.    
  559. ScriptSchedule slIdleBaStand(
  560.     bits_COND_NEW_ENEMY     |
  561.     bits_COND_LIGHT_DAMAGE  |
  562.     bits_COND_HEAVY_DAMAGE  |
  563.     bits_COND_HEAR_SOUND    |
  564.     bits_COND_SMELL,
  565.  
  566.     bits_SOUND_COMBAT       |// sound flags - change these, and you'll break the talking code. 
  567.     bits_SOUND_DANGER       |
  568.     bits_SOUND_MEAT         |// scents
  569.     bits_SOUND_CARCASS      |
  570.     bits_SOUND_GARBAGE,
  571.     "IdleStand" );
  572.    
  573. ScriptSchedule slBaReload(
  574.     bits_COND_HEAVY_DAMAGE  |
  575.     bits_COND_HEAR_SOUND,
  576.     bits_SOUND_DANGER,
  577.     "Barney Reload");
  578.    
  579. ScriptSchedule slBaReloadQuick(
  580.     bits_COND_HEAVY_DAMAGE  |
  581.     bits_COND_HEAR_SOUND,
  582.     bits_SOUND_DANGER,
  583.     "Barney Reload Quick");
  584.        
  585. ScriptSchedule slBarneyEnemyDraw( 0, 0, "Barney Enemy Draw" );
  586.  
  587. void InitSchedules()
  588. {
  589.        
  590.     slBaFollow.AddTask( ScriptTask(TASK_MOVE_TO_TARGET_RANGE, 128.0f) );
  591.     slBaFollow.AddTask( ScriptTask(TASK_SET_SCHEDULE, SCHED_TARGET_FACE) );
  592.    
  593.     slBarneyEnemyDraw.AddTask( ScriptTask(TASK_STOP_MOVING) );
  594.     slBarneyEnemyDraw.AddTask( ScriptTask(TASK_FACE_ENEMY) );
  595.     slBarneyEnemyDraw.AddTask( ScriptTask(TASK_PLAY_SEQUENCE_FACE_ENEMY, float(ACT_ARM)) );
  596.        
  597.     slBaFaceTarget.AddTask( ScriptTask(TASK_SET_ACTIVITY, float(ACT_IDLE)) );
  598.     slBaFaceTarget.AddTask( ScriptTask(TASK_FACE_TARGET) );
  599.     slBaFaceTarget.AddTask( ScriptTask(TASK_SET_ACTIVITY, float(ACT_IDLE)) );
  600.     slBaFaceTarget.AddTask( ScriptTask(TASK_SET_SCHEDULE, float(SCHED_TARGET_CHASE)) );
  601.        
  602.     slIdleBaStand.AddTask( ScriptTask(TASK_STOP_MOVING) );
  603.     slIdleBaStand.AddTask( ScriptTask(TASK_SET_ACTIVITY, float(ACT_IDLE)) );
  604.     slIdleBaStand.AddTask( ScriptTask(TASK_WAIT, 2) );
  605.     //slIdleBaStand.AddTask( ScriptTask(TASK_TLK_HEADRESET) );
  606.        
  607.     slBaReload.AddTask( ScriptTask(TASK_STOP_MOVING) );
  608.     slBaReload.AddTask( ScriptTask(TASK_SET_FAIL_SCHEDULE, float(SCHED_RELOAD)) );
  609.     slBaReload.AddTask( ScriptTask(TASK_FIND_COVER_FROM_ENEMY) );
  610.     slBaReload.AddTask( ScriptTask(TASK_RUN_PATH) );
  611.     slBaReload.AddTask( ScriptTask(TASK_REMEMBER, float(bits_MEMORY_INCOVER)) );
  612.     slBaReload.AddTask( ScriptTask(TASK_WAIT_FOR_MOVEMENT_ENEMY_OCCLUDED) );
  613.     slBaReload.AddTask( ScriptTask(TASK_RELOAD) );
  614.     slBaReload.AddTask( ScriptTask(TASK_FACE_ENEMY) );
  615.            
  616.     slBaReloadQuick.AddTask( ScriptTask(TASK_STOP_MOVING) );
  617.     slBaReloadQuick.AddTask( ScriptTask(TASK_RELOAD) );
  618.     slBaReloadQuick.AddTask( ScriptTask(TASK_FACE_ENEMY) );
  619.    
  620.     array<ScriptSchedule@> scheds = {slBaFollow, slBarneyEnemyDraw, slBaFaceTarget, slIdleBaStand, slBaReload, slBaReloadQuick};
  621.    
  622.     @monster_barney_schedules = @scheds;
  623. }
  624.  
  625. enum monsterScheds
  626. {
  627.     SCHED_BARNEY_RELOAD = LAST_COMMON_SCHEDULE + 1,
  628. }
  629.  
  630. void Register()
  631. {
  632.     InitSchedules();
  633.     g_CustomEntityFuncs.RegisterCustomEntity( "BarneyCustom::CMonsterBarneyCustom", "monster_barney_custom" );
  634. }
  635.  
  636. } // end of namespace
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top