BOZO
Joined: 11 Oct 2004 Posts: 48
|
Posted: Mon May 09, 2005 9:31 pm Post subject: |
|
|
Here is the relevant code that controls this for Pawns:
Code: |
function DropDecoration()
{
if (CarriedDecoration != None)
{
CarriedDecoration.bWasCarried = true;
CarriedDecoration.SetBase(None);
CarriedDecoration.SetPhysics(PHYS_Falling);
CarriedDecoration.Velocity = Velocity + 10 * VRand();
CarriedDecoration.Instigator = self;
CarriedDecoration = None;
}
}
function GrabDecoration()
{
local vector lookDir, HitLocation, HitNormal, T1, T2, extent;
local actor HitActor;
if ( carriedDecoration == None )
{
//first trace to find it
lookDir = vector(Rotation);
lookDir.Z = 0;
T1 = Location + BaseEyeHeight * vect(0,0,1) + lookDir * 0.8 * CollisionRadius;
T2 = T1 + lookDir * 1.2 * CollisionRadius;
HitActor = Trace(HitLocation, HitNormal, T2, T1, true);
if ( HitActor == None )
{
T1 = T2 - (BaseEyeHeight + CollisionHeight - 2) * vect(0,0,1);
HitActor = Trace(HitLocation, HitNormal, T1, T2, true);
}
else if ( HitActor == Level )
{
T2 = HitLocation - lookDir;
T1 = T2 - (BaseEyeHeight + CollisionHeight - 2) * vect(0,0,1);
HitActor = Trace(HitLocation, HitNormal, T1, T2, true);
}
if ( (HitActor == None) || (HitActor == Level) )
{
extent.X = CollisionRadius;
extent.Y = CollisionRadius;
extent.Z = CollisionHeight;
HitActor = Trace(HitLocation, HitNormal, Location + lookDir * 1.2 * CollisionRadius, Location, true, extent);
}
if ( Mover(HitActor) != None )
{
if ( Mover(HitActor).bUseTriggered )
HitActor.Trigger( self, self );
}
else if ( (Decoration(HitActor) != None) && ((weapon == None) || (weapon.Mass < 20)) )
{
CarriedDecoration = Decoration(HitActor);
if ( !CarriedDecoration.bPushable || (CarriedDecoration.Mass > 40)
|| (CarriedDecoration.StandingCount > 0) )
{
CarriedDecoration = None;
return;
}
lookDir.Z = 0;
if ( CarriedDecoration.SetLocation(Location + (0.5 * CollisionRadius + CarriedDecoration.CollisionRadius) * lookDir) )
{
CarriedDecoration.SetPhysics(PHYS_None);
CarriedDecoration.SetBase(self);
}
else
CarriedDecoration = None;
}
}
} |
The meat of the operation is for a thing to be picked up has to be subclassed off of Decoration. Its mass must be less than or equal to 40 and it must not have its bPushable setting set to true. Also you cannot be carrying a weapon with a mass greater than 20 at the time you try to do the grab. You can also only pick up the top object from a stack of objects.
It gives me a good idea to build a level made completely from movable stuff... _________________ Darn Floppy Feet!!
{KDS}BOZO / <NDP>BOZO / LordBozo
bozo@kds-clan.com |
|