Advertisement
Guest User

Ray Gun Mark 3 Fix

a guest
Jun 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.35 KB | None | 0 0
  1. //Fixed mark3 search for FIX to see what I did
  2. //#using scripts\codescripts\struct;
  3. //
  4. #using scripts\shared\ai_shared;
  5. #using scripts\shared\callbacks_shared;
  6. #using scripts\shared\clientfield_shared;
  7. #using scripts\shared\flag_shared;
  8. #using scripts\shared\scene_shared;
  9. #using scripts\shared\system_shared;
  10. #using scripts\shared\util_shared;
  11. #using scripts\shared\visionset_mgr_shared;
  12.  
  13. #using scripts\zm\_util;
  14. #using scripts\zm\_zm;
  15. #using scripts\zm\_zm_audio;
  16. #using scripts\zm\_zm_spawner;
  17. #using scripts\zm\_zm_utility;
  18.  
  19. #insert scripts\shared\shared.gsh;
  20. #insert scripts\shared\version.gsh;
  21. #insert scripts\zm\_zm_utility.gsh;
  22.  
  23. #insert scripts\zm\_zm_weap_raygun_mark3.gsh;
  24.  
  25.  
  26. #define N_RAYGUN_MARK3LH_VORTEX_DURATION 3000 // in ms
  27. #define N_RAYGUN_MARK3LH_UPGRADED_VORTEX_DURATION 3000 // in ms
  28.  
  29. #define N_RAYGUN_MARK3LH_SLOWDOWN_RATE 0.7
  30. #define N_RAYGUN_MARK3LH_UPGRADED_SLOWDOWN_RATE 0.5
  31.  
  32. #define N_RAYGUN_MARK3LH_SLOWDOWN_DURATION 2.0
  33. #define N_RAYGUN_MARK3LH_UPGRADED_SLOWDOWN_DURATION 3.0
  34.  
  35. #define N_RAYGUN_MARK3LH_VORTEX_RANGE_SM 128
  36. #define N_RAYGUN_MARK3LH_VORTEX_RANGE_LG 128
  37.  
  38. #define N_RAYGUN_MARK3LH_VORTEX_PULSE_INTERVAL 0.5
  39.  
  40. #define N_RAYGUN_MARK3LH_VORTEX_PULSE_DAMAGE_SM 50
  41. #define N_RAYGUN_MARK3LH_VORTEX_PULSE_DAMAGE_LG 1000
  42. #define N_RAYGUN_MARK3LH_UPGRADED_VORTEX_PULSE_DAMAGE_SM 100
  43. #define N_RAYGUN_MARK3LH_UPGRADED_VORTEX_PULSE_DAMAGE_LG 5000
  44.  
  45. #define N_RAYGUN_MARK3_VORTEX_Z_OFFSET 32 // How far off the ground we should default position the vortex
  46.  
  47. // Screen FX
  48. // Prioritized below Beast mode and Parasite/Elemental round screen overlays
  49. #define N_RAYGUN_MARK3_VORTEX_ENTER_DURATION 0.25
  50. #define N_RAYGUN_MARK3_VORTEX_LOOP_DURATION 2.0
  51. #define N_RAYGUN_MARK3_VORTEX_EXIT_DURATION 0.25
  52.  
  53.  
  54. #precache( "model", "p7_fxanim_zm_stal_ray_gun_ball_mod" );
  55.  
  56. #namespace _zm_weap_raygun_mark3;
  57.  
  58. REGISTER_SYSTEM_EX( "zm_weap_raygun_mark3", &__init__, &__main__, undefined )
  59.  
  60.  
  61. function __init__()
  62. {
  63. level.w_raygun_mark3 = GetWeapon( STR_RAYGUN_MARK3_WEAPON );
  64. level.w_raygun_mark3lh = GetWeapon( STR_RAYGUN_MARK3LH_WEAPON );
  65. level.w_raygun_mark3_upgraded = GetWeapon( STR_RAYGUN_MARK3_UPGRADED_WEAPON );
  66. level.w_raygun_mark3lh_upgraded = GetWeapon( STR_RAYGUN_MARK3LH_UPGRADED_WEAPON );
  67.  
  68. zm_utility::register_slowdown( STR_RAYGUN_MARK3LH_WEAPON, N_RAYGUN_MARK3LH_SLOWDOWN_RATE, N_RAYGUN_MARK3LH_SLOWDOWN_DURATION );
  69. zm_utility::register_slowdown( STR_RAYGUN_MARK3LH_UPGRADED_WEAPON, N_RAYGUN_MARK3LH_UPGRADED_SLOWDOWN_RATE, N_RAYGUN_MARK3LH_UPGRADED_SLOWDOWN_DURATION );
  70.  
  71. zm_spawner::register_zombie_damage_callback( &raygun_mark3_damage_response );
  72.  
  73. clientfield::register( "scriptmover", "slow_vortex_fx", VERSION_DLC3, 2, "int" );
  74.  
  75. clientfield::register( "actor", "ai_disintegrate", VERSION_DLC3, 1, "int" );
  76. clientfield::register( "vehicle", "ai_disintegrate", VERSION_DLC3, 1, "int" );
  77.  
  78. clientfield::register( "actor", "ai_slow_vortex_fx", VERSION_DLC3, 2, "int" );
  79. clientfield::register( "vehicle", "ai_slow_vortex_fx", VERSION_DLC3, 2, "int" );
  80.  
  81. visionset_mgr::register_info( "visionset", "raygun_mark3_vortex_visionset", VERSION_DLC3, N_RAYGUN_MARK3_VORTEX_VISIONSET_PRIORITY, N_RAYGUN_MARK3_VORTEX_VISIONSET_LERP_COUNT, true, &visionset_mgr::ramp_in_out_thread_per_player, true );
  82. visionset_mgr::register_info( "overlay", "raygun_mark3_vortex_blur", VERSION_DLC3, N_RAYGUN_MARK3_VORTEX_VISIONSET_PRIORITY, N_RAYGUN_MARK3_VORTEX_VISIONSET_LERP_COUNT, true, &visionset_mgr::ramp_in_out_thread_per_player, true );
  83.  
  84. callback::on_connect( &watch_raygun_impact);
  85. }
  86.  
  87. function __main__()
  88. {
  89.  
  90. }
  91.  
  92.  
  93. // Was Damage from the left-hand slow gun?
  94. function is_slow_raygun( weapon )
  95. {
  96. if ( weapon === level.w_raygun_mark3lh || weapon === level.w_raygun_mark3lh_upgraded )
  97. {
  98. return true;
  99. }
  100.  
  101. return false;
  102. }
  103.  
  104.  
  105. // Was Damage was from the right-hand beam gun?
  106. function is_beam_raygun( weapon )
  107. {
  108. if ( weapon === level.w_raygun_mark3 || weapon === level.w_raygun_mark3_upgraded )
  109. {
  110. return true;
  111. }
  112.  
  113. return false;
  114. }
  115.  
  116.  
  117. // Repositions Vortex damage origin if too close to a horizontal surface on the navmesh
  118. function raygun_vortex_reposition( v_impact_origin )
  119. {
  120. v_nearest_navmesh_point = GetClosestPointOnNavMesh( v_impact_origin, 50, 32 );
  121. if ( isdefined(v_nearest_navmesh_point) )
  122. {
  123. v_vortex_origin = v_nearest_navmesh_point + ( 0, 0, N_RAYGUN_MARK3_VORTEX_Z_OFFSET);
  124. }
  125. else
  126. {
  127. v_vortex_origin = v_impact_origin;
  128. }
  129.  
  130. return v_vortex_origin;
  131. }
  132.  
  133.  
  134. // Track left-hand projectile impact
  135. // self is a player
  136. function watch_raygun_impact()
  137. {
  138. self endon("disconnect");
  139.  
  140. while( true )
  141. {
  142. self waittill( "projectile_impact", w_weapon, v_pos, n_radius, e_projectile, v_normal );
  143.  
  144. v_pos_final = raygun_vortex_reposition( v_pos + ( v_normal*N_RAYGUN_MARK3_VORTEX_Z_OFFSET ) );
  145.  
  146. if( is_slow_raygun( w_weapon ) )
  147. {
  148. //TODO Adjust position if too low or too close to wall. Look at idgun.
  149. self thread start_slow_vortex( w_weapon, v_pos, v_pos_final, n_radius, e_projectile, v_normal );
  150. }
  151. }
  152. }
  153.  
  154.  
  155. // spawn a slow vortex
  156. // self is a player
  157. function start_slow_vortex( w_weapon, v_pos, v_pos_final, n_radius, e_attacker, v_normal )
  158. {
  159. self endon( "disconnect" );
  160.  
  161. mdl_vortex = Spawn( "script_model", v_pos );
  162. mdl_vortex SetModel( "p7_fxanim_zm_stal_ray_gun_ball_mod" );
  163. playsoundatposition ("wpn_mk3_orb_created", mdl_vortex.origin);
  164. mdl_vortex.angles = ( 270, 0, 0 );
  165. mdl_vortex clientfield::set( "slow_vortex_fx", N_ZM_WEAP_RGM3_SLOW_VORTEX_SM );
  166. util::wait_network_frame(); // ensure this position is used over the network
  167.  
  168. mdl_vortex MoveTo( v_pos_final, 0.1 ); // quickly move into position
  169. util::wait_network_frame(); // ensure this position is used over the network
  170.  
  171. mdl_vortex.health = 100000;
  172. mdl_vortex.takedamage = true;
  173.  
  174. mdl_vortex thread pulse_damage( self, w_weapon );
  175. mdl_vortex thread wait_for_beam_damage();
  176. }
  177.  
  178. // Periodically pulse damage to grab zombies in the area.
  179. // self is the vortex blob model
  180. function pulse_damage( e_owner, w_weapon )
  181. {
  182. self endon( "death" );
  183.  
  184. self.n_damage_type = N_ZM_WEAP_RGM3_SLOW_VORTEX_SM;
  185. self.n_end_time = GetTime() + N_RAYGUN_MARK3LH_VORTEX_DURATION;
  186. self.e_owner = e_owner;
  187.  
  188. if ( w_weapon == level.w_raygun_mark3lh )
  189. {
  190. //playsoundatposition ("wpn_mk3_orb_zark", self.origin);
  191. }
  192. else
  193. {
  194. playsoundatposition ("wpn_mk3_orb_zark_far", self.origin);
  195. }
  196.  
  197. // Now periodically pulse damage
  198. while ( GetTime() <= self.n_end_time )
  199. {
  200. if ( self.n_damage_type == N_ZM_WEAP_RGM3_SLOW_VORTEX_SM )
  201. {
  202. n_radius = N_RAYGUN_MARK3LH_VORTEX_RANGE_SM;
  203. //playsoundatposition ("wpn_mk3_orb_zark", self.origin);
  204.  
  205. if ( w_weapon == level.w_raygun_mark3lh )
  206. {
  207. n_pulse_damage = N_RAYGUN_MARK3LH_VORTEX_PULSE_DAMAGE_SM;
  208. }
  209. else
  210. {
  211. n_pulse_damage = N_RAYGUN_MARK3LH_UPGRADED_VORTEX_PULSE_DAMAGE_SM;
  212. }
  213. }
  214. else // LG Vortex
  215. {
  216. n_radius = N_RAYGUN_MARK3LH_VORTEX_RANGE_LG;
  217. playsoundatposition ("wpn_mk3_orb_zark_far", self.origin);
  218.  
  219. if ( w_weapon == level.w_raygun_mark3lh )
  220. {
  221. n_pulse_damage = N_RAYGUN_MARK3LH_VORTEX_PULSE_DAMAGE_LG;
  222. }
  223. else
  224. {
  225. n_pulse_damage = N_RAYGUN_MARK3LH_UPGRADED_VORTEX_PULSE_DAMAGE_LG;
  226. }
  227. }
  228.  
  229. // Pulse Damage
  230. n_radius_squared = n_radius * n_radius;
  231. a_ai = GetAITeamArray( "axis" );
  232. foreach( ai in a_ai )
  233. {
  234.  
  235. if ( IS_TRUE( ai.b_ignore_mark3_pulse_damage ) )
  236. {
  237. continue;
  238. }
  239.  
  240. if ( DistanceSquared( self.origin, ai.origin ) <= n_radius_squared )
  241. {
  242. ai thread apply_vortex_fx( self.n_damage_type, N_RAYGUN_MARK3LH_SLOWDOWN_DURATION );
  243.  
  244. if ( ai.health > n_pulse_damage )
  245. {
  246. ai DoDamage( n_pulse_damage, self.origin, e_owner, self, undefined, "MOD_UNKNOWN", 0, w_weapon );
  247. }
  248. else if ( self.n_damage_type == N_ZM_WEAP_RGM3_SLOW_VORTEX_LG )
  249. {
  250. if (ai.in_the_ground == true) // FIX Zombies that are flat out removed in the Rise Up spawn animation will sometimes cause invisible and invincible zombies.
  251. ai DoDamage( n_pulse_damage, self.origin, e_owner, self, undefined, "MOD_UNKNOWN", 0, w_weapon ); // FIX
  252. else
  253. ai thread disintegrate_zombie( self, e_owner, w_weapon );
  254. }
  255. }
  256. }
  257.  
  258. // Check to see if any players are in the radius
  259. foreach( e_player in level.activeplayers )
  260. {
  261. if( IsDefined(e_player) && !IS_TRUE( e_player.raygun_mark3_vision_on ) )
  262. {
  263. // If Player is within vortex range, apply vision overlay
  264. if( Distance( e_player.origin, self.origin ) < Float( n_radius / 2 ) )
  265. {
  266. e_player thread player_vortex_visionset();
  267. }
  268. }
  269. }
  270.  
  271. wait N_RAYGUN_MARK3LH_VORTEX_PULSE_INTERVAL;
  272. }
  273.  
  274. // Vortex expired
  275. self clientfield::set( "slow_vortex_fx", 0 );
  276.  
  277. playsoundatposition ("wpn_mk3_orb_disappear", self.origin);
  278. self Delete();
  279. }
  280.  
  281.  
  282. // Vision overlay and blur when player enters vortex
  283. // self == player
  284. function player_vortex_visionset()
  285. {
  286. self notify( "player_vortex_visionset" );
  287. self endon( "player_vortex_visionset" );
  288.  
  289. self endon( "death" );
  290.  
  291. thread visionset_mgr::activate( "visionset", "raygun_mark3_vortex_visionset", self, N_RAYGUN_MARK3_VORTEX_ENTER_DURATION, N_RAYGUN_MARK3_VORTEX_LOOP_DURATION, N_RAYGUN_MARK3_VORTEX_EXIT_DURATION );
  292. thread visionset_mgr::activate( "overlay", "raygun_mark3_vortex_blur", self, N_RAYGUN_MARK3_VORTEX_ENTER_DURATION, N_RAYGUN_MARK3_VORTEX_LOOP_DURATION, N_RAYGUN_MARK3_VORTEX_EXIT_DURATION );
  293. self.raygun_mark3_vision_on = true;
  294. wait 2.5; // minimal amount of time to keep it up
  295.  
  296. self.raygun_mark3_vision_on = false;
  297. }
  298.  
  299.  
  300. // wait for damage
  301. // self is a vortex model
  302. function wait_for_beam_damage()
  303. {
  304. self endon( "death" );
  305. self playloopsound ("wpn_mk3_orb_loop");
  306. while( true )
  307. {
  308. self waittill( "damage", n_damage, e_attacker, v_direction, v_point, str_means_of_death, str_tag_name, str_model_name, str_part_name, w_weapon );
  309.  
  310. if ( is_beam_raygun( w_weapon ) )
  311. {
  312. self stoploopsound();
  313. self SetModel( "tag_origin" ); // remove the original vortex
  314. self playloopsound ("wpn_mk3_orb_loop_activated");
  315. self.takedamage = false;
  316. self.n_damage_type = N_ZM_WEAP_RGM3_SLOW_VORTEX_LG;
  317. self clientfield::set( "slow_vortex_fx", self.n_damage_type );
  318. self.n_end_time = GetTime() + N_RAYGUN_MARK3LH_UPGRADED_VORTEX_DURATION;
  319. wait N_RAYGUN_MARK3LH_UPGRADED_VORTEX_DURATION / 1000;
  320. playsoundatposition ("wpn_mk3_orb_disappear", self.origin);
  321. self Delete();
  322. return;
  323. }
  324. else
  325. {
  326. self.health = 100000;
  327. }
  328. }
  329. }
  330.  
  331.  
  332. // Zombies damaged by the left-hand ray gun will beome slowed temporarily
  333. // Self is a damaged entity
  334. function raygun_mark3_damage_response( str_mod, str_hit_location, v_hit_origin, e_player, n_amount, w_weapon, v_direction, str_tag, str_model, str_part, n_flags, e_inflictor, n_chargeLevel )
  335. {
  336. if ( isdefined( w_weapon ) )
  337. {
  338. if ( w_weapon == level.w_raygun_mark3lh || w_weapon == level.w_raygun_mark3lh_upgraded )
  339. {
  340. // Run override if available
  341. if ( isdefined( self.func_raygun_mark3_damage_response ) )
  342. {
  343. return [[ self.func_raygun_mark3_damage_response ]]( str_mod, str_hit_location, v_hit_origin, e_player, n_amount, w_weapon, v_direction, str_tag, str_model, str_part, n_flags, e_inflictor, n_chargeLevel );
  344. }
  345.  
  346. // Add slowdown effect
  347. if ( w_weapon == level.w_raygun_mark3lh )
  348. {
  349. self thread zm_utility::slowdown_ai( STR_RAYGUN_MARK3LH_WEAPON );
  350. return true;
  351. }
  352. else if ( w_weapon == level.w_raygun_mark3lh_upgraded )
  353. {
  354. self thread zm_utility::slowdown_ai( STR_RAYGUN_MARK3LH_UPGRADED_WEAPON );
  355. return true;
  356. }
  357. }
  358. }
  359.  
  360. // Don't affect damage dealt
  361. return false;
  362. }
  363.  
  364.  
  365. // Apply fx to affected AI
  366. // self is an AI
  367. function apply_vortex_fx( n_damage_type, n_time )
  368. {
  369. self notify( "apply_vortex_fx" );
  370. self endon( "apply_vortex_fx" );
  371. self endon( "death" );
  372.  
  373. if ( !IS_TRUE( self.b_vortex_fx_applied ) )
  374. {
  375. self.b_vortex_fx_applied = true;
  376. if ( IS_TRUE( self.allowPain ) )
  377. {
  378. self.b_old_allow_pain = true;
  379. self ai::disable_pain();
  380. }
  381.  
  382. if ( n_damage_type == N_ZM_WEAP_RGM3_SLOW_VORTEX_SM )
  383. {
  384. self clientfield::set( "ai_slow_vortex_fx", N_ZM_WEAP_RGM3_SLOW_VORTEX_SM );
  385. }
  386. else
  387. {
  388. self clientfield::set( "ai_slow_vortex_fx", N_ZM_WEAP_RGM3_SLOW_VORTEX_LG );
  389. }
  390. }
  391.  
  392. util::waittill_any_timeout( n_time, "death", "apply_vortex_fx" );
  393.  
  394. if ( IS_TRUE( self.b_old_allow_pain ) )
  395. {
  396. self ai::enable_pain();
  397. }
  398. self clientfield::set( "ai_slow_vortex_fx", 0 );
  399. }
  400.  
  401.  
  402. function disintegrate_zombie( e_inflictor, e_attacker, w_weapon )
  403. {
  404. self endon( "death" );
  405.  
  406. if ( IS_TRUE( self.b_disintegrating ) )
  407. {
  408. return;
  409. }
  410.  
  411. if (self.in_the_ground == true) //FIX
  412. {
  413. return;
  414. }
  415. self.b_disintegrating = true;
  416.  
  417. // these scenes prevent death
  418. self clientfield::set( "ai_disintegrate", 1 );
  419.  
  420. if ( IsVehicle( self ) )
  421. {
  422. self ai::set_ignoreall( true );
  423. wait 1.1;
  424.  
  425. self Ghost();
  426. self DoDamage( self.health, self.origin, e_attacker, e_inflictor, undefined, "MOD_UNKNOWN", 0, w_weapon );
  427. }
  428. else
  429. {
  430. self scene::play( "cin_zm_dlc3_zombie_dth_deathray_0" + RandomIntRange( 1, 5 ), self );
  431. self clientfield::set( "ai_slow_vortex_fx", 0 );
  432. util::wait_network_frame();
  433.  
  434. self Ghost(); // The corpse will appear normal, so we need to hide it.
  435. self DoDamage( self.health, self.origin, e_attacker, e_inflictor, undefined, "MOD_UNKNOWN", 0, w_weapon );
  436. }
  437. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement