Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ToxicPawn contains all of the new behaviors for AI and Players alike.
- // New features:
- // * Jetpack
- // Created: 9/9/2011 Eric Hobbs
- // Changelog:
- // 9/18/2011 - Eric Hobbs - Added Basic Jetpack functionality.
- class ToxicPawn extends UTPawn;
- // Jetpack configuration
- var float maxJetpackVelocity;
- var int maxJetpackFuel;
- var float jetpackRechargeRate;
- var AudioComponent jetpackNoise;
- var Actor jetpackEmitter;
- // Jetpack state
- var bool isJetpacking;
- var int currentJetpackFuel;
- //Pawn Tick
- var float timeLastTick;
- exec simulated function FeignDeath()
- {
- `log("feign death called");
- if(isJetpacking)
- StopJetpack();
- else
- StartJetpack();
- }
- //Make sure the jetpack stops.
- function bool Died(Controller Killer, class<DamageType> damageType, Vector HitLocation)
- {
- StopJetpack();
- return super.Died(killer,damageType,HitLocation);
- }
- //Starts the effects/sounds for the players jetpack
- exec simulated function StartJetpack()
- {
- isJetpacking = true;
- //jetpackNoise.Play();
- //if(jetpackEmitter == none)
- //jetpackEmitter = WorldInfo.MyEmitterPool.Spawn(class'blah');
- }
- //Stops the effects/sounds for the players jetpack
- exec simulated function StopJetpack()
- {
- isJetpacking = false;
- //jetpackNoise.Stop();
- }
- function Tick(float deltaTime)
- {
- timeLastTick += deltaTime;
- if(isJetpacking)
- {
- Velocity.Z = Clamp(Velocity.Z+JumpZ,Velocity.Z,maxJetpackVelocity); //Set the maximum +Z velocity to the configured max.
- SetPhysics(PHYS_Falling); //Falling is required for velocity to take effect.
- }
- //do this every second (might be over, will never be under).
- if(timeLastTick >= 1)
- {
- if(isJetpacking)
- {
- if( (WorldInfo.TimeSeconds - timeLastTick) > 1)
- {
- `log("Jetpack running, using 5 units of fuel.");
- currentJetpackFuel -= 5;
- if(currentJetpackFuel < 0)
- isJetpacking = false;
- }
- timeLastTick = WorldInfo.TimeSeconds;
- }
- else
- {
- if(currentJetpackFuel > maxJetpackFuel)
- {
- currentJetpackFuel = maxJetpackFuel;
- }
- if(currentJetpackFuel < maxJetpackFuel)
- {
- currentJetpackFuel += jetpackRechargeRate;
- `log("Fuel regen +"$jetpackRechargeRate);
- }
- }
- timeLastTick = 0.0f;
- }
- super.Tick(deltaTime);
- }
- DefaultProperties
- {
- maxJetpackFuel = 25;
- maxJetpackVelocity = 332; /*JumpZ*/
- jetpackRechargeRate = 1;
- isJetpacking=false;
- currentJetpackFuel = 0;
- }
Add Comment
Please, Sign In to add comment