# SFDecos.SFPickBoxTrigger

00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 |
    //=============================================================================
    // Spatial Fear
    // Class: SFPickBoxTrigger
    // Descripton: Used by SFPickBox to stop carrying a box.
    //             DO NOT ADD THIS TO A MAP in UnrealEd !!
    //
    // Author: Jacek 'mOOse' Zagrodzki
    //=============================================================================
    class SFPickBoxTrigger expands SFUseKeyTrigger;

    var SFPlayer	aPlayer;
    var SFPickBox	TheBox;
    var bool		bCarried;

    var SFPickBoxGun	EmptyGun;
    var Weapon		OldGun;

    function FireEvent( actor Other )
    {
    	local vector	OldPivot;
    	local weapon	OldWeapon;

    	aPlayer = SFPlayer(Other);
    	if(aPlayer == None)
    		return;

    	if( !bCarried )
    	{
    	//////// hiding weapon when picking up a box (in fact the current weapon is changed to an "empty" gun
    		EmptyGun = spawn(class'SFPickBoxGun', aPlayer);
    		EmptyGun.TheTrigger = Self;

    		aPlayer.PendingWeapon = EmptyGun;	// setting a weapon to which the current one will be changed
    		OldGun = aPlayer.Weapon;		// saving which weapon player had in hand when picked up a box
    		aPlayer.Weapon.PutDown();		// force changing weapon
    	//////////

    		bCarried = true;
    		TheBox.SetOwner(aPlayer);
    		TheBox.SetPhysics(PHYS_Trailer);
    		aPlayer.SetCollisionSize(aPlayer.CollisionRadius+15.0, aPlayer.CollisionHeight);
    		SetPhysics(PHYS_Flying);
    	}
    	else
    	{
    		OldPivot = TheBox.PrePivot;
    		TheBox.PrePivot = vect(0,0,0);
    		if(!TheBox.SetLocation(TheBox.Location + OldPivot))	// if player can't drop a box in front of him/her
    		{
    			TheBox.PrePivot = OldPivot;
    			return;
    		}

    	//////// dropping a box:
    		bCarried = false;
    		TheBox.SetOwner(None);
    		SetPhysics(PHYS_Trailer);
    		aPlayer.SetCollisionSize(aPlayer.CollisionRadius-15.0, aPlayer.CollisionHeight);

    		TheBox.SetPhysics(PHYS_Falling);
    		TheBox.Velocity = aPlayer.Velocity/2 + vector(aPlayer.ViewRotation)*(Vsize(aPlayer.Velocity)/2);
    		aPlayer.Velocity = aPlayer.Velocity/3;
    	//////////

    		// bringing up an old weapon:
    		aPlayer.PendingWeapon = OldGun;
    		EmptyGun.Destroy();
    		aPlayer.ChangedWeapon();
    	}
    }

    function Tick(float DTime)
    {
    	local vector	OffSet;

    	if(bCarried)
    	{
    		// checking if the carrying player is alive, if not drop the box::
    		if(aPlayer.IsInState('Dying'))
    			FireEvent(aPlayer);

    		// setting location of a trigger, used to deactivate bot, in front of a player
    		OffSet = 3*vector(aPlayer.ViewRotation);
    		SetLocation(aPlayer.Location + aPlayer.EyeHeight * vect(0,0,1) + OffSet);
    	}
    }

    defaultproperties
    {
         Physics=PHYS_Trailer
         CollisionRadius=13.000000
         CollisionHeight=13.000000
         bCollideActors=False
    }

class file time: 12/7/2003 3:58:26 PM - creation time: 12/7/2003 4:03:45 PM
Created with UnCodeX