Advertisement
Abnormal202

Snails_Pace

Feb 21st, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.17 KB | None | 0 0
  1. #using scripts\codescripts\struct;
  2.  
  3. #using scripts\shared\array_shared;
  4. #using scripts\shared\clientfield_shared;
  5. #using scripts\shared\exploder_shared;
  6. #using scripts\shared\flag_shared;
  7. #using scripts\shared\system_shared;
  8. #using scripts\shared\util_shared;
  9. #using scripts\shared\visionset_mgr_shared;
  10.  
  11. #insert scripts\shared\shared.gsh;
  12. #insert scripts\shared\version.gsh;
  13.  
  14. #using scripts\zm\_util;
  15. #using scripts\zm\_zm;
  16. #using scripts\zm\_zm_perks;
  17. #using scripts\zm\_zm_pers_upgrades;
  18. #using scripts\zm\_zm_pers_upgrades_functions;
  19. #using scripts\zm\_zm_pers_upgrades_system;
  20. #using scripts\zm\_zm_stats;
  21. #using scripts\zm\_zm_utility;
  22.  
  23. #insert scripts\zm\_zm_perk_custom_perk.gsh;
  24. #insert scripts\zm\_zm_perks.gsh;
  25. #insert scripts\zm\_zm_utility.gsh;
  26.  
  27. /***************************** WARDOGSK93: Start *****************************/
  28. #using scripts\wardog\wardog_addon;
  29.  
  30. #insert scripts\wardog\wardog_addon.gsh;
  31. /***************************** WARDOGSK93: End *****************************/
  32.  
  33. //#precache( "material", QUICK_REVIVE_SHADER );
  34. //#precache( "string", "ZOMBIE_PERK_QUICKREVIVE" );
  35. //#precache( "fx", "zombie/fx_perk_quick_revive_zmb" );
  36. #precache( "material", "snails_pace_shader" ); // CHANGE THIS TO YOUR PERK SHADER
  37.  
  38. #namespace zm_perk_custom_perk;
  39.  
  40. REGISTER_SYSTEM( "zm_perk_custom_perk", &__init__, undefined )
  41.  
  42. // QUICK REVIVE ( QUICK REVIVE )
  43.  
  44. //-----------------------------------------------------------------------------------
  45. // setup
  46. //-----------------------------------------------------------------------------------
  47. function __init__()
  48. {
  49.     enable_custom_perk_for_level();
  50.     //level.check_quickrevive_hotjoin = &check_quickrevive_for_hotjoin;
  51. }
  52.  
  53. function enable_custom_perk_for_level()
  54. {  
  55.     // register quick revive perk for level
  56.     zm_perks::register_perk_basic_info( PERK_CUSTOM_PERK, "customperk", CUSTOM_PERK_COST, "Hold [{+activate}] for Snail's Pace [Cost: &&1]", GetWeapon( CUSTOM_PERK_BOTTLE_WEAPON ) );
  57.     zm_perks::register_perk_precache_func( PERK_CUSTOM_PERK, &custom_perk_precache );
  58.     zm_perks::register_perk_clientfields( PERK_CUSTOM_PERK, &custom_perk_register_clientfield, &custom_perk_set_clientfield );
  59.     zm_perks::register_perk_machine( PERK_CUSTOM_PERK, &custom_perk_machine_setup );
  60.     zm_perks::register_perk_threads( PERK_CUSTOM_PERK, &give_custom_perk, &take_custom_perk );
  61.     zm_perks::register_perk_host_migration_params( PERK_CUSTOM_PERK, CUSTOM_RADIANT_MACHINE_NAME, CUSTOM_MACHINE_LIGHT_FX );
  62.     //zm_perks::register_perk_machine_power_override( PERK_CUSTOM_PERK, &turn_revive_on ); // custom power function gets threaded here
  63.     //level flag::init( "solo_revive" );
  64.    
  65. }
  66.  
  67. function custom_perk_precache()
  68. {
  69.     // PRECACHE SHIT HERE
  70.     /*
  71.     if( IsDefined(level.quick_revive_precache_override_func) )
  72.     {
  73.         [[ level.quick_revive_precache_override_func ]]();
  74.         return;
  75.     }
  76.    
  77.     level._effect[QUICK_REVIVE_MACHINE_LIGHT_FX] = "zombie/fx_perk_quick_revive_zmb";
  78.     */
  79.  
  80.     level.machine_assets[PERK_CUSTOM_PERK] = SpawnStruct();
  81.     level.machine_assets[PERK_CUSTOM_PERK].weapon = GetWeapon( CUSTOM_PERK_BOTTLE_WEAPON );
  82.     level.machine_assets[PERK_CUSTOM_PERK].off_model = CUSTOM_MACHINE_DISABLED_MODEL;
  83.     level.machine_assets[PERK_CUSTOM_PERK].on_model = CUSTOM_MACHINE_ACTIVE_MODEL; 
  84.    
  85.     addon_message = "hud|";
  86.     addon_message += PERK_CUSTOM_PERK + "|"; // Replace PERK_NAME to your perks name
  87.     addon_message += "shader|";
  88.     addon_message += CUSTOM_SHADER; // Replace PERK_SHADER to your perks shader
  89.  
  90.     wardog_addon::send_addon_message("Unknown", ADDON_NAME_PERK_HUD, addon_message);
  91. }
  92.  
  93. function custom_perk_register_clientfield()
  94. {
  95.     clientfield::register( "clientuimodel", PERK_CLIENTFIELD_CUSTOMPERK, VERSION_SHIP, 2, "int" );
  96. }
  97.  
  98. function custom_perk_set_clientfield( state )
  99. {
  100.     self clientfield::set_player_uimodel( PERK_CLIENTFIELD_CUSTOMPERK, state );
  101. }
  102.  
  103. function custom_perk_machine_setup( use_trigger, perk_machine, bump_trigger, collision )
  104. {
  105.     use_trigger.script_sound = "mus_perks_revive_jingle";
  106.     use_trigger.script_string = "revive_perk";
  107.     use_trigger.script_label = "mus_perks_revive_sting";
  108.     use_trigger.target = CUSTOM_RADIANT_MACHINE_NAME;
  109.     perk_machine.script_string = "revive_perk";
  110.     perk_machine.targetname = CUSTOM_RADIANT_MACHINE_NAME;
  111.     if(IsDefined(bump_trigger))
  112.     {
  113.         bump_trigger.script_string = "revive_perk";
  114.     }
  115. }
  116.  
  117. function give_custom_perk()
  118. {
  119.     // quick revive in solo gives an extra life
  120.     // give perk here
  121.     self.hasCustomPerk = true;
  122.     self.has_custom_perks++;
  123.     self thread check_for_close_zoms();
  124.     addon_message = "hud|";
  125.     addon_message += PERK_CUSTOM_PERK + "|";
  126.     addon_message += "give";
  127.  
  128.     wardog_addon::send_addon_message("Unknown", ADDON_NAME_PERK_HUD, addon_message, self);
  129.  
  130.     trigger = GetEnt("vending_snails_pace", "target"); // CHANGE THIS TO YOUR PERK MACHINE NAME
  131.     trigger SetHintStringForPlayer(self, "");
  132.    
  133. }
  134.  
  135. function take_custom_perk( b_pause, str_perk, str_result )
  136. {
  137.     // take perk here
  138.     self.hasCustomPerk = false;
  139.     self.has_custom_perks--;
  140.     trigger = GetEnt("vending_snails_pace", "target");
  141.     trigger SetHintStringForPlayer(self, "Hold [{+activate}] for Snail's Pace [Cost: 300]"); // CHANGE THIS TO YOUR HINTSTRING ABOVE
  142.     addon_message = "hud|";
  143.     addon_message += PERK_CUSTOM_PERK + "|";
  144.     addon_message += "take";
  145.  
  146.     wardog_addon::send_addon_message("Unknown", ADDON_NAME_PERK_HUD, addon_message, self);
  147. }
  148.  
  149.  
  150. function check_for_close_zoms()
  151. {
  152.     while(self.hasCustomPerk)
  153.     {
  154.         zoms = GetAISpeciesArray( "axis", "all" );
  155.         zoms_1 = util::get_array_of_closest( self.origin, zoms , undefined , undefined, 100 );
  156.         zoms_2 = util::get_array_of_closest( self.origin, zoms , undefined , undefined, 80 );
  157.         foreach( zom in zoms_1 )
  158.         {
  159.             if( !isDefined( zom.is_snailed ))
  160.                 zom thread warp_time();
  161.         }
  162.         foreach( zom in zoms_2 )
  163.         {
  164.             if( isDefined( zom.is_snailed ))
  165.                 zom thread back_to_normal();
  166.         }
  167.         wait(0.05);
  168.     }
  169. }
  170. function warp_time()
  171. {
  172.     self.is_snailed = true;
  173.     self ASMSetAnimationRate(0.6);
  174.     self SetMoveSpeedScale(0.6);
  175.     wait (3);
  176.     self thread back_to_normal();
  177. }
  178. function back_to_normal()
  179. {
  180.     self.is_snailed = undefined;
  181.     self ASMSetAnimationRate(1);
  182.     self SetMoveSpeedScale(1);
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement