Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.02 KB | None | 0 0
  1. #using scripts\codescripts\struct;
  2.  
  3. #using scripts\shared\aat_shared;
  4. #using scripts\shared\array_shared;
  5. #using scripts\shared\clientfield_shared;
  6. #using scripts\shared\flag_shared;
  7. #using scripts\shared\spawner_shared;
  8. #using scripts\shared\system_shared;
  9. #using scripts\shared\trigger_shared;
  10. #using scripts\shared\util_shared;
  11.  
  12. #insert scripts\shared\archetype_shared\archetype_shared.gsh;
  13. #insert scripts\shared\shared.gsh;
  14. #insert scripts\shared\version.gsh;
  15.  
  16. #insert scripts\shared\aat_zm.gsh;
  17. #using scripts\zm\_util;
  18. #using scripts\zm\_zm;
  19. #using scripts\zm\_zm_audio;
  20. #using scripts\zm\_zm_net;
  21. #using scripts\zm\_zm_powerups;
  22. #using scripts\zm\_zm_score;
  23. #using scripts\zm\_zm_spawner;
  24. #using scripts\zm\_zm_stats;
  25. #using scripts\zm\_zm_utility;
  26.  
  27. #using scripts\shared\ai\zombie_utility;
  28.  
  29. #insert scripts\zm\_zm_utility.gsh;
  30.  
  31. #precache( "fx", "zombie/fx_dog_lightning_buildup_zmb" );
  32. #precache( "fx", "zombie/fx_dog_eyes_zmb" );
  33. #precache( "fx", "zombie/fx_dog_explosion_zmb" );
  34. #precache( "fx", "zombie/fx_dog_fire_trail_zmb" );
  35.  
  36. #define ZM_DOGS_HERO_WEAPON_KILL_POWER 2
  37.  
  38. #namespace zm_ai_dogs;
  39.  
  40. REGISTER_SYSTEM( "zm_ai_dogs", &__init__, "aat" )
  41.  
  42. function __init__()
  43. {
  44. clientfield::register( "actor", "dog_fx", VERSION_SHIP, 1, "int" );
  45.  
  46. init_dog_fx();
  47. init();
  48. }
  49.  
  50. function init()
  51. {
  52. level.dogs_enabled = true;
  53. level.dog_rounds_enabled = false;
  54. level.dog_round_count = 1;
  55.  
  56. level.dog_spawners = [];
  57.  
  58. //utility::flag_init( "dog_round" );
  59. level flag::init( "dog_clips" );
  60.  
  61. if ( GetDvarString( "zombie_dog_animset" ) == "" )
  62. {
  63. SetDvar( "zombie_dog_animset", "zombie" );
  64. }
  65.  
  66. if ( GetDvarString( "scr_dog_health_walk_multiplier" ) == "" )
  67. {
  68. SetDvar( "scr_dog_health_walk_multiplier", "4.0" );
  69. }
  70.  
  71. if ( GetDvarString( "scr_dog_run_distance" ) == "" )
  72. {
  73. SetDvar( "scr_dog_run_distance", "500" );
  74. }
  75.  
  76. level.melee_range_sav = GetDvarString( "ai_meleeRange" );
  77. level.melee_width_sav = GetDvarString( "ai_meleeWidth" );
  78. level.melee_height_sav = GetDvarString( "ai_meleeHeight" );
  79.  
  80. zombie_utility::set_zombie_var( "dog_fire_trail_percent", 50 );
  81.  
  82. // AAT IMMUNITIES
  83. level thread aat::register_immunity( ZM_AAT_BLAST_FURNACE_NAME, ARCHETYPE_ZOMBIE_DOG, false, true, true );
  84. level thread aat::register_immunity( ZM_AAT_DEAD_WIRE_NAME, ARCHETYPE_ZOMBIE_DOG, false, true, true );
  85. level thread aat::register_immunity( ZM_AAT_FIRE_WORKS_NAME, ARCHETYPE_ZOMBIE_DOG, true, true, true );
  86. level thread aat::register_immunity( ZM_AAT_THUNDER_WALL_NAME, ARCHETYPE_ZOMBIE_DOG, false, false, true );
  87. level thread aat::register_immunity( ZM_AAT_TURNED_NAME, ARCHETYPE_ZOMBIE_DOG, true, true, true );
  88.  
  89. // Init dog targets - mainly for testing purposes.
  90. // If you spawn a dog without having a dog round, you'll get SREs on hunted_by.
  91. dog_spawner_init();
  92.  
  93. level thread dog_clip_monitor();
  94. }
  95.  
  96. function init_dog_fx()
  97. {
  98. level._effect[ "lightning_dog_spawn" ] = "zombie/fx_dog_lightning_buildup_zmb";
  99. level._effect[ "dog_eye_glow" ] = "zombie/fx_dog_eyes_zmb";
  100. level._effect[ "dog_gib" ] = "zombie/fx_dog_explosion_zmb";
  101. level._effect[ "dog_trail_fire" ] = "zombie/fx_dog_fire_trail_zmb";
  102. }
  103.  
  104. //
  105. // If you want to enable dog rounds, then call this.
  106. // Specify an override func if needed.
  107. function enable_dog_rounds()
  108. {
  109. level.dog_rounds_enabled = true;
  110.  
  111. if( !isdefined( level.dog_round_track_override ) )
  112. {
  113. level.dog_round_track_override =&dog_round_tracker;
  114. }
  115.  
  116. level thread [[level.dog_round_track_override]]();
  117. }
  118.  
  119.  
  120. function dog_spawner_init()
  121. {
  122. level.dog_spawners = getEntArray( "zombie_dog_spawner", "script_noteworthy" );
  123. later_dogs = getentarray("later_round_dog_spawners", "script_noteworthy" );
  124. level.dog_spawners = ArrayCombine( level.dog_spawners, later_dogs, true, false );
  125.  
  126. if( level.dog_spawners.size == 0 )
  127. {
  128. return;
  129. }
  130.  
  131. for( i = 0; i < level.dog_spawners.size; i++ )
  132. {
  133. if ( zm_spawner::is_spawner_targeted_by_blocker( level.dog_spawners[i] ) )
  134. {
  135. level.dog_spawners[i].is_enabled = false;
  136. }
  137. else
  138. {
  139. level.dog_spawners[i].is_enabled = true;
  140. level.dog_spawners[i].script_forcespawn = true;
  141. }
  142. }
  143.  
  144. assert( level.dog_spawners.size > 0 );
  145. level.dog_health = 100;
  146.  
  147. array::thread_all( level.dog_spawners,&spawner::add_spawn_function,&dog_init );
  148. }
  149.  
  150.  
  151. function dog_round_spawning()
  152. {
  153. level endon( "intermission" );
  154. level endon( "end_of_round" );
  155. level endon( "restart_round" );
  156.  
  157. level.dog_targets = getplayers();
  158. for( i = 0 ; i < level.dog_targets.size; i++ )
  159. {
  160. level.dog_targets[i].hunted_by = 0;
  161. }
  162.  
  163. level endon( "kill_round" );
  164.  
  165. if( level.intermission )
  166. {
  167. return;
  168. }
  169.  
  170. level.dog_intermission = true;
  171. level thread dog_round_aftermath();
  172. players = GetPlayers();
  173. array::thread_all( players,&play_dog_round );
  174. wait(1);
  175. level thread zm_audio::sndAnnouncerPlayVox("dogstart");
  176. wait(6);
  177.  
  178. if( level.dog_round_count < 3 )
  179. {
  180. max = players.size * 40;
  181. }
  182. else
  183. {
  184. max = players.size * 80;
  185. }
  186.  
  187. level.zombie_total = max;
  188. dog_health_increase();
  189.  
  190.  
  191.  
  192. count = 0;
  193. while( true )
  194. {
  195. // added ability to pause spawning
  196. level flag::wait_till( "spawn_zombies" );
  197.  
  198. while( zombie_utility::get_current_zombie_count() >= level.zombie_ai_limit || level.zombie_total <= 0 )
  199. {
  200. wait 0.1;
  201. }
  202.  
  203. num_player_valid = zm_utility::get_number_of_valid_players();
  204.  
  205. while( zombie_utility::get_current_zombie_count() >= num_player_valid * 6 )
  206. {
  207. wait( 2 );
  208. num_player_valid = zm_utility::get_number_of_valid_players();
  209. }
  210.  
  211. //update the player array.
  212. players = GetPlayers();
  213. favorite_enemy = get_favorite_enemy();
  214.  
  215. if ( isdefined( level.dog_spawn_func ) )
  216. {
  217. spawn_loc = [[level.dog_spawn_func]]( level.dog_spawners, favorite_enemy );
  218.  
  219. ai = zombie_utility::spawn_zombie( level.dog_spawners[0] );
  220. if( isdefined( ai ) )
  221. {
  222. ai.favoriteenemy = favorite_enemy;
  223. spawn_loc thread dog_spawn_fx( ai, spawn_loc );
  224. level.zombie_total--;
  225. count++;
  226. level flag::set( "dog_clips" );
  227. }
  228. }
  229. else
  230. {
  231. // Default method
  232. spawn_point = dog_spawn_factory_logic( favorite_enemy );
  233. ai = zombie_utility::spawn_zombie( level.dog_spawners[0] );
  234.  
  235. if( isdefined( ai ) )
  236. {
  237. ai.favoriteenemy = favorite_enemy;
  238. spawn_point thread dog_spawn_fx( ai, spawn_point );
  239. level.zombie_total--;
  240. count++;
  241. level flag::set( "dog_clips" );
  242. }
  243. }
  244.  
  245.  
  246. waiting_for_next_dog_spawn( count, max );
  247. }
  248. }
  249.  
  250. function waiting_for_next_dog_spawn( count, max )
  251. {
  252. default_wait = 1.0;
  253.  
  254. if( level.dog_round_count == 1)
  255. {
  256. default_wait = 1.0;
  257. }
  258. else if( level.dog_round_count == 2)
  259. {
  260. default_wait = 1.0;
  261. }
  262. else if( level.dog_round_count == 3)
  263. {
  264. default_wait = 1.0;
  265. }
  266. else
  267. {
  268. default_wait = 1.0;
  269. }
  270.  
  271. default_wait = default_wait - ( count / max );
  272.  
  273. default_wait = max( default_wait, 0.05 );
  274.  
  275. wait( default_wait );
  276. }
  277.  
  278. function dog_round_aftermath()
  279. {
  280. level waittill( "last_ai_down", e_last );
  281.  
  282. level thread zm_audio::sndMusicSystem_PlayState( "dog_end" );
  283.  
  284. power_up_origin = level.last_dog_origin;
  285. if ( isdefined(e_last) )
  286. {
  287. power_up_origin = e_last.origin;
  288. }
  289.  
  290. if( isdefined( power_up_origin ) )
  291. {
  292. level thread zm_powerups::specific_powerup_drop( "full_ammo", power_up_origin );
  293. level thread zm_powerups::specific_powerup_drop( "bonfire_sale", power_up_origin );
  294. level thread zm_powerups::specific_powerup_drop( "free_perk", power_up_origin );
  295. }
  296.  
  297. wait(2);
  298. util::clientNotify( "dog_stop" );
  299. wait(6);
  300. level.dog_intermission = false;
  301.  
  302. //level thread dog_round_aftermath();
  303.  
  304. }
  305.  
  306.  
  307. //
  308. // In Factory, there's a single spawner and the struct is passed in as the second argument.
  309. function dog_spawn_fx( ai, ent )
  310. {
  311. ai endon( "death" );
  312.  
  313. /*if ( !IsDefined(ent) )
  314. {
  315. ent = struct::get( self.target, "targetname" );
  316. }*/
  317.  
  318. ai SetFreeCameraLockOnAllowed( false );
  319. if ( isdefined( ent ) )
  320. {
  321. Playfx( level._effect["lightning_dog_spawn"], ent.origin );
  322. playsoundatposition( "zmb_hellhound_prespawn", ent.origin );
  323. wait( 1.5 );
  324. playsoundatposition( "zmb_hellhound_bolt", ent.origin );
  325.  
  326. Earthquake( 0.5, 0.75, ent.origin, 1000);
  327. PlayRumbleOnPosition("explosion_generic", ent.origin);
  328. playsoundatposition( "zmb_hellhound_spawn", ent.origin );
  329.  
  330. // face the enemy
  331. if ( IsDefined( ai.favoriteenemy ) )
  332. {
  333. angle = VectorToAngles( ai.favoriteenemy.origin - ent.origin );
  334. angles = ( ai.angles[0], angle[1], ai.angles[2] );
  335. }
  336. else
  337. {
  338. angles = ent.angles;
  339. }
  340. ai ForceTeleport( ent.origin, angles );
  341. }
  342.  
  343. assert( isdefined( ai ), "Ent isn't defined." );
  344. assert( IsAlive( ai ), "Ent is dead." );
  345. assert( ai.isdog, "Ent isn't a dog;" );
  346. assert( zm_utility::is_magic_bullet_shield_enabled( ai ), "Ent doesn't have a magic bullet shield." );
  347.  
  348. ai zombie_setup_attack_properties_dog();
  349. ai util::stop_magic_bullet_shield();
  350.  
  351. wait( 0.1 ); // dog should come out running after this wait
  352. ai show();
  353. ai SetFreeCameraLockOnAllowed( true );
  354. ai.ignoreme = false; // don't let attack dogs give chase until the wolf is visible
  355. ai notify( "visible" );
  356. }
  357.  
  358.  
  359. //
  360. // Dog spawning logic for Factory.
  361. // Makes use of the _zm_zone_manager and specially named structs for each zone to
  362. // indicate dog spawn locations instead of constantly using ents.
  363. //
  364. function dog_spawn_factory_logic( favorite_enemy)
  365. {
  366. dog_locs = array::randomize( level.zm_loc_types[ "dog_location" ] );
  367. //assert( dog_locs.size > 0, "Dog Spawner locs array is empty." );
  368.  
  369. for( i = 0; i < dog_locs.size; i++ )
  370. {
  371. if( isdefined( level.old_dog_spawn ) && level.old_dog_spawn == dog_locs[i] )
  372. {
  373. continue;
  374. }
  375.  
  376. dist_squared = DistanceSquared( dog_locs[i].origin, favorite_enemy.origin );
  377. if( dist_squared > ( 400 * 400 ) && dist_squared < ( 1000 * 1000 ) )
  378. {
  379. level.old_dog_spawn = dog_locs[i];
  380. return dog_locs[i];
  381. }
  382. }
  383.  
  384. return dog_locs[0];
  385. }
  386.  
  387.  
  388. function get_favorite_enemy()
  389. {
  390. dog_targets = getplayers();
  391. least_hunted = dog_targets[0];
  392. for( i = 0; i < dog_targets.size; i++ )
  393. {
  394. if ( !isdefined( dog_targets[i].hunted_by ) )
  395. {
  396. dog_targets[i].hunted_by = 0;
  397. }
  398.  
  399. if( !zm_utility::is_player_valid( dog_targets[i] ) )
  400. {
  401. continue;
  402. }
  403.  
  404. if( !zm_utility::is_player_valid( least_hunted ) )
  405. {
  406. least_hunted = dog_targets[i];
  407. }
  408.  
  409. if( dog_targets[i].hunted_by < least_hunted.hunted_by )
  410. {
  411. least_hunted = dog_targets[i];
  412. }
  413.  
  414. }
  415. // do not return the default first player if he is invalid
  416. if( !zm_utility::is_player_valid( least_hunted ) )
  417. {
  418. return undefined;
  419. }
  420. else
  421. {
  422. least_hunted.hunted_by += 1;
  423.  
  424. return least_hunted;
  425. }
  426.  
  427. }
  428.  
  429.  
  430. function dog_health_increase()
  431. {
  432. players = getplayers();
  433.  
  434. if( level.dog_round_count == 1 )
  435. {
  436. level.dog_health = 400;
  437. }
  438. else if( level.dog_round_count == 2 )
  439. {
  440. level.dog_health = 900;
  441. }
  442. else if( level.dog_round_count == 3 )
  443. {
  444. level.dog_health = 1300;
  445. }
  446. else if( level.dog_round_count == 4 )
  447. {
  448. level.dog_health = 1600;
  449. }
  450.  
  451. if( level.dog_health > 1600 )
  452. {
  453. level.dog_health = 1600;
  454. }
  455. }
  456.  
  457. function dog_round_wait_func()
  458. {
  459. if( level flag::get("dog_round" ) )
  460. {
  461. wait(7);
  462. while( level.dog_intermission )
  463. {
  464. wait(0.5);
  465. }
  466. zm::increment_dog_round_stat("finished");
  467. }
  468.  
  469. level.sndMusicSpecialRound = true;
  470. }
  471.  
  472. function dog_round_tracker()
  473. {
  474. level.dog_round_count = 1;
  475.  
  476. // PI_CHANGE_BEGIN - JMA - making dog rounds random between round 5 thru 7
  477. // NOTE: RandomIntRange returns a random integer r, where min <= r < max
  478.  
  479. level.next_dog_round = ( 2 );
  480. // PI_CHANGE_END
  481.  
  482. old_spawn_func = level.round_spawn_func;
  483. old_wait_func = level.round_wait_func;
  484.  
  485. while ( 1 )
  486. {
  487. level waittill ( "between_round_over" );
  488.  
  489. if ( level.round_number == level.next_dog_round )
  490. {
  491. level.sndMusicSpecialRound = true;
  492. old_spawn_func = level.round_spawn_func;
  493. old_wait_func = level.round_wait_func;
  494. dog_round_start();
  495. level.round_spawn_func = &dog_round_spawning;
  496. level.round_wait_func = &dog_round_wait_func;
  497.  
  498. level.next_dog_round = level.round_number + randomintrange( 4, 6 );
  499. }
  500. else if ( level flag::get( "dog_round" ) )
  501. {
  502. dog_round_stop();
  503. level.round_spawn_func = old_spawn_func;
  504. level.round_wait_func = old_wait_func;
  505. level.dog_round_count += 1;
  506. }
  507. }
  508. }
  509.  
  510.  
  511. function dog_round_start()
  512. {
  513. level flag::set( "dog_round" );
  514. level flag::set( "special_round" );
  515. level flag::set( "dog_clips" );
  516.  
  517. level notify( "dog_round_starting" );
  518. level thread zm_audio::sndMusicSystem_PlayState( "dog_start" );
  519. util::clientNotify( "dog_start" );
  520.  
  521. if(isdefined(level.dog_melee_range))
  522. {
  523. SetDvar( "ai_meleeRange", level.dog_melee_range );
  524. }
  525. else
  526. {
  527. SetDvar( "ai_meleeRange", 100 );
  528. }
  529. }
  530.  
  531.  
  532. function dog_round_stop()
  533. {
  534. level flag::clear( "dog_round" );
  535. level flag::clear( "special_round" );
  536. level flag::clear( "dog_clips" );
  537.  
  538. level notify( "dog_round_ending" );
  539. util::clientNotify( "dog_stop" );
  540.  
  541. SetDvar( "ai_meleeRange", level.melee_range_sav );
  542. SetDvar( "ai_meleeWidth", level.melee_width_sav );
  543. SetDvar( "ai_meleeHeight", level.melee_height_sav );
  544. }
  545.  
  546.  
  547. function play_dog_round()
  548. {
  549. self playlocalsound( "zmb_dog_round_start" );
  550. variation_count =5;
  551.  
  552. wait(4.5);
  553.  
  554. players = getplayers();
  555. num = randomintrange(0,players.size);
  556. players[num] zm_audio::create_and_play_dialog( "general", "dog_spawn" );
  557. }
  558.  
  559.  
  560. function dog_init()
  561. {
  562. self.targetname = "zombie_dog";
  563. self.script_noteworthy = undefined;
  564. self.animname = "zombie_dog";
  565. self.ignoreall = true;
  566. self.ignoreme = true; // don't let attack dogs give chase until the wolf is visible
  567. self.allowdeath = true; // allows death during animscripted calls
  568. self.allowpain = false;
  569. self.force_gib = true; // needed to make sure this guy does gibs
  570. self.is_zombie = true; // needed for melee.gsc in the animscripts
  571. // out both legs and then the only allowed stance should be prone.
  572. self.gibbed = false;
  573. self.head_gibbed = false;
  574. self.default_goalheight = 40;
  575. self.ignore_inert = true;
  576.  
  577. self.holdfire = true;
  578.  
  579. // self.disableArrivals = true;
  580. // self.disableExits = true;
  581. self.grenadeawareness = 0;
  582. self.badplaceawareness = 0;
  583.  
  584. self.ignoreSuppression = true;
  585. self.suppressionThreshold = 1;
  586. self.noDodgeMove = true;
  587. self.dontShootWhileMoving = true;
  588. self.pathenemylookahead = 0;
  589.  
  590. self.badplaceawareness = 0;
  591. self.chatInitialized = false;
  592.  
  593. self.team = level.zombie_team;
  594. self.heroweapon_kill_power = ZM_DOGS_HERO_WEAPON_KILL_POWER;
  595.  
  596. self AllowPitchAngle( 1 );
  597. self setPitchOrient();
  598. self setAvoidanceMask( "avoid none" );
  599.  
  600. self PushActors( true );
  601.  
  602. health_multiplier = 1.0;
  603. if ( GetDvarString( "scr_dog_health_walk_multiplier" ) != "" )
  604. {
  605. health_multiplier = GetDvarFloat( "scr_dog_health_walk_multiplier" );
  606. }
  607.  
  608. self.maxhealth = int( level.dog_health * health_multiplier );
  609. self.health = int( level.dog_health * health_multiplier );
  610.  
  611. self.freezegun_damage = 0;
  612.  
  613. self.zombie_move_speed = "sprint";
  614. self.a.nodeath = true;
  615.  
  616. self thread dog_run_think();
  617. self thread dog_stalk_audio();
  618.  
  619. self thread zombie_utility::round_spawn_failsafe();
  620. self ghost();
  621. self thread util::magic_bullet_shield();
  622.  
  623. self thread dog_death();
  624.  
  625. level thread zm_spawner::zombie_death_event( self );
  626. self thread zm_spawner::enemy_death_detection();
  627. self thread zm_audio::zmbAIVox_NotifyConvert();
  628.  
  629. self.a.disablePain = true;
  630. self zm_utility::disable_react(); // SUMEET - zombies dont use react feature.
  631. self ClearGoalVolume();
  632.  
  633. self.flame_damage_time = 0;
  634. self.meleeDamage = 40;
  635.  
  636. self.thundergun_knockdown_func =&dog_thundergun_knockdown;
  637.  
  638. self zm_spawner::zombie_history( "zombie_dog_spawn_init -> Spawned = " + self.origin );
  639.  
  640. if ( isdefined(level.achievement_monitor_func) )
  641. {
  642. self [[level.achievement_monitor_func]]();
  643. }
  644. }
  645.  
  646. function dog_death()
  647. {
  648. self waittill( "death" );
  649.  
  650. if( zombie_utility::get_current_zombie_count() == 0 && level.zombie_total == 0 )
  651. {
  652.  
  653. level.last_dog_origin = self.origin;
  654. level notify( "last_ai_down", self );
  655.  
  656. }
  657.  
  658. // score
  659. if( IsPlayer( self.attacker ) )
  660. {
  661. event = "death";
  662. if ( self.damageweapon.isBallisticKnife )
  663. {
  664. event = "ballistic_knife_death";
  665. }
  666.  
  667. if ( !IS_TRUE( self.deathpoints_already_given ) )
  668. {
  669. self.attacker zm_score::player_add_points( event, self.damagemod, self.damagelocation, true );
  670. }
  671.  
  672. if( isdefined(level.hero_power_update))
  673. {
  674. [[level.hero_power_update]]( self.attacker, self );
  675. }
  676.  
  677. if( RandomIntRange(0,100) >= 80 )
  678. {
  679. self.attacker zm_audio::create_and_play_dialog( "kill", "hellhound" );
  680. }
  681.  
  682. //stats
  683. self.attacker zm_stats::increment_client_stat( "zdogs_killed" );
  684. self.attacker zm_stats::increment_player_stat( "zdogs_killed" );
  685. }
  686.  
  687. // switch to inflictor when SP DoDamage supports it
  688. if( isdefined( self.attacker ) && isai( self.attacker ) )
  689. {
  690. self.attacker notify( "killed", self );
  691. }
  692.  
  693. // sound
  694. self stoploopsound();
  695.  
  696. // just explode if we died on an incline greater than 10 degrees
  697. if ( !IS_TRUE( self.a.nodeath ) )
  698. {
  699. trace = GroundTrace( self.origin + ( 0, 0, 10 ), self.origin - ( 0, 0, 30 ), false, self );
  700. if ( trace["fraction"] < 1 )
  701. {
  702. pitch = Acos( VectorDot( trace["normal"], ( 0, 0, 1 ) ) );
  703. if ( pitch > 10 )
  704. {
  705. self.a.nodeath = true;
  706. }
  707. }
  708. }
  709.  
  710. if ( isdefined( self.a.nodeath ) )
  711. {
  712. level thread dog_explode_fx( self.origin );
  713. self delete();
  714. }
  715. else
  716. {
  717. self notify( "bhtn_action_notify", "death" );
  718. }
  719. }
  720.  
  721.  
  722. function dog_explode_fx( origin )
  723. {
  724. PlayFX( level._effect["dog_gib"], origin );
  725. PlaySoundAtPosition( "zmb_hellhound_explode", origin );
  726. }
  727.  
  728.  
  729. // this is where zombies go into attack mode, and need different attributes set up
  730. function zombie_setup_attack_properties_dog()
  731. {
  732. self zm_spawner::zombie_history( "zombie_setup_attack_properties()" );
  733.  
  734. self thread dog_behind_audio();
  735.  
  736. // allows zombie to attack again
  737. self.ignoreall = false;
  738.  
  739. //self.pathEnemyFightDist = 64;
  740. self.meleeAttackDist = 64;
  741.  
  742. // turn off transition anims
  743. self.disableArrivals = true;
  744. self.disableExits = true;
  745.  
  746. if ( isdefined( level.dog_setup_func ) )
  747. {
  748. self [[level.dog_setup_func]]();
  749. }
  750. }
  751.  
  752.  
  753. //COLLIN'S Audio Scripts
  754. function stop_dog_sound_on_death()
  755. {
  756. self waittill("death");
  757. self stopsounds();
  758. }
  759.  
  760. function dog_behind_audio()
  761. {
  762. self thread stop_dog_sound_on_death();
  763.  
  764. self endon("death");
  765. self util::waittill_any( "dog_running", "dog_combat" );
  766.  
  767. self notify( "bhtn_action_notify", "close" );
  768. wait( 3 );
  769.  
  770. while(1)
  771. {
  772. players = GetPlayers();
  773. for(i=0;i<players.size;i++)
  774. {
  775. dogAngle = AngleClamp180( vectorToAngles( self.origin - players[i].origin )[1] - players[i].angles[1] );
  776.  
  777. if(isAlive(players[i]) && !isdefined(players[i].revivetrigger))
  778. {
  779. if ((abs(dogAngle) > 90) && distance2d(self.origin,players[i].origin) > 100)
  780. {
  781. self notify( "bhtn_action_notify", "close" );
  782. wait( 3 );
  783. }
  784. }
  785. }
  786.  
  787. wait(.75);
  788. }
  789. }
  790.  
  791.  
  792. //
  793. // Keeps dog_clips up if there is a dog running around in the level.
  794. function dog_clip_monitor()
  795. {
  796. clips_on = false;
  797. level.dog_clips = GetEntArray( "dog_clips", "targetname" );
  798. while (1)
  799. {
  800. for ( i=0; i<level.dog_clips.size; i++ )
  801. {
  802. // level.dog_clips[i] TriggerEnable( false );
  803. level.dog_clips[i] ConnectPaths();
  804. }
  805.  
  806. level flag::wait_till( "dog_clips" );
  807.  
  808. if(isdefined(level.no_dog_clip) && level.no_dog_clip == true)
  809. {
  810. return;
  811. }
  812.  
  813. for ( i=0; i<level.dog_clips.size; i++ )
  814. {
  815. // level.dog_clips[i] TriggerEnable( true );
  816. level.dog_clips[i] DisconnectPaths();
  817. util::wait_network_frame();
  818. }
  819.  
  820. dog_is_alive = true;
  821. while ( dog_is_alive || level flag::get( "dog_round" ) )
  822. {
  823. dog_is_alive = false;
  824. dogs = GetEntArray( "zombie_dog", "targetname" );
  825. for ( i=0; i<dogs.size; i++ )
  826. {
  827. if ( IsAlive(dogs[i]) )
  828. {
  829. dog_is_alive = true;
  830. }
  831. }
  832. wait( 1 );
  833. }
  834.  
  835. level flag::clear( "dog_clips" );
  836. wait(1);
  837. }
  838. }
  839.  
  840. //
  841. // Allows dogs to be spawned independent of the round spawning
  842. function special_dog_spawn( num_to_spawn, spawners, spawn_point )
  843. {
  844. dogs = GetAISpeciesArray( "all", "zombie_dog" );
  845.  
  846. if ( isdefined( dogs ) && dogs.size >= 9 )
  847. {
  848. return false;
  849. }
  850.  
  851. if ( !isdefined(num_to_spawn) )
  852. {
  853. num_to_spawn = 1;
  854. }
  855.  
  856. spawn_point = undefined;
  857. count = 0;
  858. while ( count < num_to_spawn )
  859. {
  860. //update the player array.
  861. players = GetPlayers();
  862. favorite_enemy = get_favorite_enemy();
  863.  
  864. if ( isdefined( spawners ) )
  865. {
  866. if ( !isdefined( spawn_point ) )
  867. {
  868. spawn_point = spawners[ RandomInt(spawners.size) ];
  869. }
  870. ai = zombie_utility::spawn_zombie( spawn_point );
  871.  
  872. if( isdefined( ai ) )
  873. {
  874. ai.favoriteenemy = favorite_enemy;
  875. spawn_point thread dog_spawn_fx( ai );
  876. count++;
  877. level flag::set( "dog_clips" );
  878. }
  879. }
  880. else
  881. {
  882. if ( isdefined( level.dog_spawn_func ) )
  883. {
  884. spawn_loc = [[level.dog_spawn_func]]( level.dog_spawners, favorite_enemy );
  885.  
  886. ai = zombie_utility::spawn_zombie( level.dog_spawners[0] );
  887. if( isdefined( ai ) )
  888. {
  889. ai.favoriteenemy = favorite_enemy;
  890. spawn_loc thread dog_spawn_fx( ai, spawn_loc );
  891. count++;
  892. level flag::set( "dog_clips" );
  893. }
  894. }
  895. else
  896. {
  897. // Default method
  898. spawn_point = dog_spawn_factory_logic( favorite_enemy );
  899. ai = zombie_utility::spawn_zombie( level.dog_spawners[0] );
  900.  
  901. if( isdefined( ai ) )
  902. {
  903. ai.favoriteenemy = favorite_enemy;
  904. spawn_point thread dog_spawn_fx( ai, spawn_point );
  905. count++;
  906. level flag::set( "dog_clips" );
  907. }
  908. }
  909. }
  910.  
  911. waiting_for_next_dog_spawn( count, num_to_spawn );
  912. }
  913.  
  914. return true;
  915. }
  916.  
  917. function dog_run_think()
  918. {
  919. self endon( "death" );
  920.  
  921. // these should go back in when the stalking stuff is put back in, the visible check will do for now
  922. //self util::waittill_any( "dog_running", "dog_combat" );
  923. self playsound( "zdog_close" );
  924. self waittill( "visible" );
  925.  
  926. // decrease health
  927. if ( self.health > level.dog_health )
  928. {
  929. self.maxhealth = level.dog_health;
  930. self.health = level.dog_health;
  931. }
  932.  
  933. // start glowing eyes & fire trail
  934. self clientfield::set( "dog_fx", 1 );
  935. self playloopsound( "zmb_hellhound_loop_fire" );
  936.  
  937. //Check to see if the enemy is not valid anymore
  938. while( true )
  939. {
  940. if( !zm_utility::is_player_valid(self.favoriteenemy) )
  941. {
  942. //We are targetting an invalid player - select another one
  943. self.favoriteenemy = get_favorite_enemy();
  944. }
  945. if( isdefined( level.custom_dog_target_validity_check ) )
  946. {
  947. self [[ level.custom_dog_target_validity_check ]]();
  948. }
  949. wait( 0.2 );
  950.  
  951. }
  952. }
  953.  
  954. function dog_stalk_audio()
  955. {
  956. self endon( "death" );
  957. self endon( "dog_running" );
  958. self endon( "dog_combat" );
  959.  
  960. while(1)
  961. {
  962. self notify( "bhtn_action_notify", "ambient" );
  963. wait randomfloatrange(3,6);
  964. }
  965. }
  966.  
  967. function dog_thundergun_knockdown( player, gib )
  968. {
  969. self endon( "death" );
  970.  
  971. damage = int( self.maxhealth * 0.5 );
  972. self DoDamage( damage, player.origin, player );
  973. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement