Guest User

Untitled

a guest
Dec 4th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ToxicPawn contains all of the new behaviors for AI and Players alike.
  2. // New features:
  3. // * Jetpack
  4. // Created: 9/9/2011 Eric Hobbs
  5. // Changelog:
  6. //  9/18/2011 - Eric Hobbs - Added Basic Jetpack functionality.
  7. class ToxicPawn extends UTPawn;
  8.  
  9. // Jetpack configuration
  10. var float maxJetpackVelocity;
  11. var int maxJetpackFuel;
  12. var float jetpackRechargeRate;
  13. var AudioComponent jetpackNoise;
  14. var Actor jetpackEmitter;
  15.  
  16. // Jetpack state
  17. var bool isJetpacking;
  18. var int currentJetpackFuel;
  19.  
  20.  
  21. //Pawn Tick
  22. var float timeLastTick;
  23.  
  24. exec simulated function FeignDeath()
  25. {
  26.     `log("feign death called");
  27.     if(isJetpacking)
  28.         StopJetpack();
  29.     else
  30.         StartJetpack();
  31. }
  32.  
  33. //Make sure the jetpack stops.
  34. function bool Died(Controller Killer, class<DamageType> damageType, Vector HitLocation)
  35. {
  36.     StopJetpack();
  37.     return super.Died(killer,damageType,HitLocation);
  38. }
  39.  
  40. //Starts the effects/sounds for the players jetpack
  41. exec simulated function StartJetpack()
  42. {
  43.     isJetpacking = true;
  44.     //jetpackNoise.Play();
  45.     //if(jetpackEmitter == none)
  46.     //jetpackEmitter = WorldInfo.MyEmitterPool.Spawn(class'blah');
  47. }
  48.  
  49. //Stops the effects/sounds for the players jetpack
  50. exec simulated function StopJetpack()
  51. {
  52.     isJetpacking = false;
  53.     //jetpackNoise.Stop();
  54. }
  55.  
  56. function Tick(float deltaTime)
  57. {
  58.  
  59.     timeLastTick += deltaTime;
  60.  
  61.     if(isJetpacking)
  62.     {
  63.         Velocity.Z = Clamp(Velocity.Z+JumpZ,Velocity.Z,maxJetpackVelocity); //Set the maximum +Z velocity to the configured max.
  64.         SetPhysics(PHYS_Falling);   //Falling is required for velocity to take effect.
  65.     }
  66.  
  67.     //do this every second (might be over, will never be under).
  68.     if(timeLastTick >= 1)
  69.     {
  70.         if(isJetpacking)
  71.         {
  72.             if( (WorldInfo.TimeSeconds - timeLastTick) > 1)
  73.             {
  74.                 `log("Jetpack running, using 5 units of fuel.");
  75.                 currentJetpackFuel -= 5;
  76.                 if(currentJetpackFuel < 0)
  77.                     isJetpacking = false;
  78.             }
  79.             timeLastTick = WorldInfo.TimeSeconds;
  80.         }
  81.         else
  82.         {
  83.             if(currentJetpackFuel > maxJetpackFuel)
  84.             {
  85.                 currentJetpackFuel = maxJetpackFuel;
  86.             }
  87.             if(currentJetpackFuel < maxJetpackFuel)
  88.             {
  89.                 currentJetpackFuel += jetpackRechargeRate;
  90.                 `log("Fuel regen +"$jetpackRechargeRate);
  91.             }
  92.            
  93.         }
  94.         timeLastTick = 0.0f;
  95.     }
  96.  
  97.     super.Tick(deltaTime);
  98. }
  99.  
  100. DefaultProperties
  101. {
  102.     maxJetpackFuel = 25;
  103.     maxJetpackVelocity = 332; /*JumpZ*/
  104.     jetpackRechargeRate = 1;
  105.     isJetpacking=false;
  106.     currentJetpackFuel = 0;
  107. }
Add Comment
Please, Sign In to add comment