Is that possible?
The SetCollisionSize() doesn't work.
Moderator: Forum Guards
//=============================================================================
// Vehicle. By [FGS]Kalman
//=============================================================================
class Vehicle expands DeusExPickup;
var(Vehicle) LodMesh vehiclemesh;
var(Vehicle) string vehiclename;
var(Vehicle) string entermessage;
var(Vehicle) float DScale;
var(Vehicle) bool bArmored;
var(Vehicle) float StepHeight; //Max Step Height, in metres
var(Vehicle) class<Inventory> VehicleInventory;
var(Vehicle) Texture VehicleSkins[8];
var(Vehicle) float VehicleLength;
var(Vehicle) float VehicleHeight;
var(Vehicle) Sound EngineSound;
var Texture defaultskins[8];
var DeusExPlayer Driver;
var View behinder; // Our behindview target
var vector x;
var vehicle newvehicle;
replication
{
reliable if( Role <ROLE_Authority)
Driver, behinder, newvehicle;
unreliable if(Role <ROLE_Authority)
GetIn,GetOut,DisableStrafe,EnableStrafe,Explode;
}
function PreBeginPlay()
{
local int i;
Super.PreBeginPlay();
Mesh = Vehiclemesh;
DrawScale = DScale;
SetCollisionSize(VehicleLength, VehicleHeight);
PickupViewMesh=vehiclemesh;
PickupViewScale=DScale;
ItemName=vehiclename;
PickupMessage=entermessage;
for (i=0; i<8; i++)
{
MultiSkins[i] = VehicleSkins[i];
}
}
auto state pickup // Activate it, when it picked up
{
simulated function Frob(actor frobber, inventory frobwith)
{
Super.Frob(Frobber, frobWith);
GetIn(Frobber);
}
}
function GetIn( actor Other)
{
local int i;
local Inventory item, nextitem;
local int i2;
Driver = DeusExPlayer(Other);
Driver.AddInventory(Self);
Driver.ConsoleCommand("SET INPUT ENTER GETOUT"); // We need to set a key for the leaving
Driver.AmbientSound = EngineSound;
Driver.Mesh=Vehiclemesh;
Driver.DrawScale = DScale;
Driver.SetLocation(Location);
Driver.SetCollisionSize(VehicleLength, VehicleHeight);
Driver.JumpZ=0; // A vehicle can't jump man
Driver.FamiliarName = vehiclename;// I need to store somewhere these properties.
Driver.UnFamiliarName = entermessage;// These settings are unused in multiplayer, so it's great for me.
Driver.bBehindView = True;
Driver.AccelRate = 100;// Change the player's speed, a player can't be faster than a vehicle
Driver.GroundSpeed = 20000;
Driver.Prepivot.Z = Prepivot.Z;
DisableStrafe();
behinder = spawn(Class'view',,,); // Spawn our behindview target
behinder.SetLocation( Driver.Location + Normal(Driver.Velocity*2*VehicleLength) *128 + vect(0,0,128));
behinder.setowner(Driver);
Driver.ViewTarget= behinder;
Driver.Mass = Mass; // Make the player heavier
Driver.Bob = 0; // Disable the bob
Driver.MaxStepHeight = StepHeight*52;
Driver.bCanStrafe = False;
Driver.setcollision(false,true,true);
for (i=0; i<8; i++) // Store the player's skin, then change to the vehicle's skin
{
defaultskins[i] = Driver.MultiSkins[i];
Driver.MultiSkins[i] = VehicleSkins[i];
}
while((item != None) && (item.IsA('NanoKeyRing') || (!item.bDisplayableInv))) //Destroy player's inventory, except NanoKeyRing
{
item = item.Inventory;
if (item != None)
{
nextItem = item.Inventory;
Driver.DeleteInventory(item);
}
}
if (bArmored)
{
Driver.Health = 200; // If armored, increase player's health
Driver.HealthHead = 250;
Driver.HealthTorso = 200;
Driver.ReducedDamagePct = 25;
Driver.ReducedDamageType = 'Shoot';// And reduce the damage of shots
}
else // Else just increase the health
{
Driver.Health = 115;
Driver.HealthHead = 130;
Driver.HealthTorso = 115;
}
}
function Explode()
{
local ExplosionLight light;
local float explosionDamage;
local float explosionRadius;
explosionDamage = Driver.Health*10;
explosionRadius = 256;
light = Spawn(class'ExplosionLight',,, Location);
if (light != None)
light.size = 4;
Spawn(class'ExplosionSmall',,, Location + 2*VRand()*CollisionRadius); // Draw some explosion
Spawn(class'ExplosionMedium',,, Location + 2*VRand()*CollisionRadius);
Spawn(class'ExplosionMedium',,, Location + 2*VRand()*CollisionRadius);
Spawn(class'ExplosionLarge',,, Location + 2*VRand()*CollisionRadius);
HurtRadius(explosionDamage, explosionRadius, 'Exploded', explosionDamage*100, Location);// And hurt the player
}
simulated function Tick( float DeltaTime )
{
local float MomentumTransfer;
local SmokeTrail st;
local actor p;
local int i;
if(driver != None)
{
if(Driver.Health < 10)
{ GetOut(); // Take out the player
Driver.Health = 100; // Heal the player, so he will thinks the vehicle was damaged, not himself
Explode(); //Explode the vehicle
}
behinder.SetLocation( Driver.Location - 1.5*Normal(Driver.Velocity) *128 + vect(0,0,128) );
if(st !=none && Driver.Health < 50){
st = spawn(class'SmokeTrail',,,); // If the player's health is less than 50, spawn some smoke
st.SetLocation(Driver.Location + vect(0,0,128));
st.drawscale=4.0;}
}
foreach visiblecollidingactors(class'actor', p, collisionradius,, true)
{
if(P.IsA('Pawn') ||P.IsA('DeusExDecoration') && P != Driver) {
PlaySound(Sound'Fleshhit2', SLOT_Interface, 2.0);
p.velocity.z = 500;
p.TakeDamage( (Driver.Velocity.X*Driver.Velocity.Y*0.3), instigator, p.Location, MomentumTransfer * Normal(driver.Velocity), 'Shoot');
}
}
}
exec function GetOut()
{
local vector loc;
local rotator rot;
local int i;
loc = Driver.Location + vect(0,0,64); // A bit higher than the player's location
rot = Driver.Rotation;
newvehicle= Spawn(Class'vehicle',Self,,loc,rot);
newvehicle.Prepivot.Z = Driver.Prepivot.Z;
newvehicle.PICKUPVIEWmesh = Driver.Mesh; // Can't set as vehiclemesh, I don't know why
newvehicle.vehiclelength = Driver.CollisionRadius;
newvehicle.vehicleheight = Driver.CollisionHeight;
newvehicle.SetCollision(true,true,true);
newvehicle.vehiclename = Driver.FamiliarName;
newvehicle.entermessage = Driver.UnFamiliarName;
newvehicle.SetCollision(true, true, true);
behinder.Destroy(); // Destroy our behindview target
PlaySound(Sound'KeysRattling', SLOT_Interface, 2.0);
for (i=0; i<8; i++)
{
Driver.MultiSkins[i] = defaultskins[i];
}
Driver.Prepivot.Z = Driver.default.Prepivot.Z;
Driver.Mesh=Driver.default.mesh;
Driver.DrawScale = Driver.Default.DrawScale;
Driver.SetCollisionSize(Driver.Default.CollisionRadius,Driver.Default.CollisionHeight);
Driver.SetLocation(Location);
Driver.BaseEyeHeight = CollisionHeight*0.85;
Driver.JumpZ=Driver.Default.JumpZ;
Driver.bBehindView = False;
Driver.ViewTarget= Driver;
EnableStrafe();
Driver.Mass = Driver.Default.Mass;
Driver.Bob = 0.016000; // It's the default value, the Driver.Default.Bob doesn't work
Driver.MaxStepHeight = Driver.Default.MaxStepHeight;
Driver.bCanStrafe = Driver.Default.bCanStrafe;
Driver.SetPhysics(PHYS_Walking);
Driver.gotostate('playerwalking');
Driver.AccelRate = Driver.Default.AccelRate;
Driver.GroundSpeed = Driver.Default.GroundSpeed;
Driver.ViewTarget= None;
Driver.bBehindView = False;
Driver.AmbientSound = None;
Driver.Tag = Driver.Default.Tag;
Driver.SetLocation(newvehicle.Location + Normal(Vect(128,128,0)));
Driver = None;
Destroy(); // Destroy the player's vehicle
}
function DisableStrafe()
{
driver.ConsoleCommand("SET INPUT Right TurnRight");
driver.ConsoleCommand("SET INPUT Left TurnLeft");
}
function EnableStrafe()
{
driver.ConsoleCommand("SET INPUT Left StrafeLeft");
driver.ConsoleCommand("SET INPUT Right StrafeRight");
}