Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Custom projectile deflect function.
- //Reflect a projectile, called in CanCollideWith(), returns false if it succeeds, meaning to ignore collision with the actor, otherwise returns true to collide normally.
- Bool DoProjectileDeflection (Actor Projectile, Int DeflectChance, Double DamageReductionFactor, Double SlowDownFactor = 0, Vector2 RandomAngle = (0,0), Vector2 RandomPitch = (0,0))
- {
- If (!Projectile || Projectile && !Projectile.bMissile) Return True;
- If (Random (0,255) < DeflectChance) Return True; //Fission mailed
- Int Damage = Projectile.GetMissileDamage(7,1); //Get the projectiles' damage, be it a static number or a damage function.
- DamageMobj (Projectile,Projectile.Target,Damage*DamageReductionFactor,Projectile.DamageType); //Harm the caller with the projectile even when deflected.
- console.printf ("the projectiles' velocity is %f %f %f",projectile.vel.x,projectile.vel.y,projectile.vel.z);
- //Slow down the projectile randomly.
- Projectile.Angle -= 180; //Turn projectile around.
- Projectile.Vel *= -1; //Opposite day today
- Projectile.Vel.X += FRandom (0,-Vel.X/5*SlowDownFactor);
- Projectile.Vel.Y += FRandom (0,-Vel.Y/5*SlowDownFactor);
- Projectile.Vel.Z += FRandom (0,-Vel.Z/5*SlowDownFactor);
- console.printf ("and now it's %f %f %f",projectile.vel.x,projectile.vel.y,projectile.vel.z);
- //Randomize the direction it'll fly to.
- Projectile.Angle += FRandom (RandomAngle.X,RandomAngle.Y);
- Projectile.Pitch += FRandom (RandomPitch.X,RandomPitch.Y);
- Return False;
- }
- //The CanCollideWith override in the actor meant to deflect certain projectiles.
- Override Bool CanCollideWith (Actor Other, Bool Passive)
- {
- If (!Passive && Other && Other == Turret && ((MVP_BaseTurret(Turret).bFallOnDeath && !IsDead (Turret)) || !MVP_BaseTurret(Turret).bFallOnDeath))
- Return False;
- If (Passive)
- {
- If (Other Is "MVP_RifleBullet") {Return DoProjectileDeflection (Other,0,0.5,randomangle:(3,-3),randompitch:(3,-3));}
- }
- Return Super.CanCollideWith (Other, Passive);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement