Liberty Unleashed

Scripting => Script Releases => Topic started by: Windlord on January 15, 2011, 08:12:46 pm

Title: Team Fortress 2 Style Death Cam
Post by: Windlord on January 15, 2011, 08:12:46 pm
Team Fortress 2 Style Death Cam Script

Description
A client-side script written in the Squirrel scripting language, the TF2 style death cam script allows for players to see their killers when being killed on LU.
When killed, the camera will detach from the player and zoom in onto the killer while panning to face the killer's face.
A gui with the killer's name, health bar and armour bar will be displayed once the camera zooms in.


Example
Thanks to [Ka]KilleR - TF2 Style Death Cam for LU (http://www.xfire.com/video/3f0c35/) (xfire)

Please feel free to post more videos using this script!
You can use this script at the "Windscript Testing Server" over at windlord.net:2301
Use /goto name to teleport /wep wepname to get weapons and start killing!


Installation
Move the script into a folder in Scripts/.
Make sure that LU/Content.xml includes:
Code: [Select]
<script folder="foldername" />
Inside Script.xml make sure there is:
Code: [Select]
<script file="DeathCam.nut" client="1"/>

Download
DeathCam.zip (http://files.windlord.net/DeathCam.zip)



Code: [Select]
/*
Team Fortress 2 Style Death Cam
[Ka]Windlord
*/


local LocalPlayer = FindLocalPlayer();
local _pos      = Vector( 0.0, 0.0, 0.0 );
local _inc_pos = Vector( 0.0, 0.0, 0.0 );
local _rot      = Vector( 0.0, 0.0, 0.0 );
local _inc_rot = Vector( 0.0, 0.0, 0.0 );
local _target  = null;
local _run      = 0;
local _dur      = 30;
local _fin_wait = 0;
local _rad      = 0.0174532925;
local _dpi      = 6.283185307;
local _gui, _guilabel, _guihealth, _guiarmour;

function _Initiate ( source, target )
{
_pos = source.Pos;
_rot = Vector( 0.0, 0.0, 0.0 );
_rot.z = ( source.Angle   90 ) * _rad;
_target = target;
_CalcFinal();

_Update();
_run = 1;
}

function _Process ()
{
if ( _run )
{
if ( _run < _dur   1 )
{
if (_inc_pos.x) _pos.x  = _inc_pos.x;
if (_inc_pos.y) _pos.y  = _inc_pos.y;
if (_inc_pos.z) _pos.z  = _inc_pos.z;

if ( _inc_rot.x) _rot.x  = _inc_rot.x;
if ( _inc_rot.z) _rot.z  = _inc_rot.z;
_Update();
_run  ;
}
else
{
_run = false;
_guilabel.Text = _target.Name;
_guihealth.Value = _target.Health;
_guiarmour.Value = _target.Armour;
_gui.Visible = true;
_fin_wait  ;
}
}
if ( _fin_wait ) {
if ( _fin_wait > 30 )
{
ShakeCamera( 250 );
RestoreCamera();
_gui.Visible = false;
_fin_wait = 0;
}
else
{
_PanAfterZoom();
_fin_wait  ;
}
}
}

function _CalcFinal ()
{
local ang = ( _target.Angle   90 ) * _rad;
local _fin_pos = Vector( 0.0, 0.0, 0.0 );
local _fin_rot = Vector( 0.0, 0.0, 0.0 );

_fin_pos = _target.Pos;
_fin_pos.x  = RandNum( 30, 70 ) / 10  * cos( ang );
_fin_pos.y  = RandNum( 30, 70 ) / 10  * sin( ang );
_fin_pos.z  = RandNum( 120 ) / 50;

local dx = _target.Pos.x - _fin_pos.x;
local dy = _target.Pos.y - _fin_pos.y;
local dz = _target.Pos.z - _fin_pos.z;
local dist = sqrt( dx*dx   dy*dy   dz*dz );
dx = dx / dist, dy = dy / dist, dz = dz / dist;

_fin_rot.x = asin( dz );
_fin_rot.z = atan2( dy, dx );

_inc_pos.x = ( _fin_pos.x - _pos.x ) / _dur;
_inc_pos.y = ( _fin_pos.y - _pos.y ) / _dur;
_inc_pos.z = ( _fin_pos.z - _pos.z ) / _dur;
_inc_rot.x = ( _fin_rot.x - _rot.x ) / _dur;
_inc_rot.z = ReduceAngle(_fin_rot.z - _rot.z) / _dur;
}

function _Update ()
{
local target = Vector( 0.0, 0.0, 0.0 );
target.x = _pos.x   cos( _rot.x ) * cos( _rot.z );
target.y = _pos.y   cos( _rot.x ) * sin( _rot.z );
target.z = _pos.z   sin( _rot.x );
SetCameraMatrix( _pos, target );
}

function _PanAfterZoom ()
{
local _fin_rot = Vector( 0.0, 0.0, 0.0 );

local dx = _target.Pos.x - _pos.x;
local dy = _target.Pos.y - _pos.y;
local dz = _target.Pos.z - _pos.z;
local dist = sqrt( dx*dx   dy*dy   dz*dz );
dx = dx / dist, dy = dy / dist, dz = dz / dist;

_fin_rot.x = asin( dz );
_fin_rot.z = atan2( dy, dx );
local drx = _fin_rot.x - _rot.x;
local drz = ReduceAngle(_fin_rot.z - _rot.z);

if ( abs(drx) > 0.1 ) _inc_rot.x = drx / abs(drx) * 0.1;
if ( abs(drz) > 0.1 ) _inc_rot.z = drz / abs(drz) * 0.1;
_rot.x  = _inc_rot.x;
_rot.z  = _inc_rot.z;
_Update();
}

function onScriptLoad ()
{
local pos = VectorScreen( ScreenWidth / 2   50, ScreenHeight - 200 );
local size = ScreenSize( 250, 70 );
_gui = GUIWindow( pos, size, "None" );
_gui.Colour = Colour( 0, 0, 0 );
_gui.Transparent = true;
_gui.Moveable = false;
_gui.Titlebar = false;
_gui.Alpha = 150;

pos = VectorScreen( 10, 23 );
size = ScreenSize( 230, 20 );
_guilabel = GUILabel( pos, size, "None" );
_guilabel.FontName = "Verdana";
_guilabel.FontSize = 20 ;
_guilabel.TextAlignment = ALIGN_MIDDLE_LEFT;
_guilabel.TextColour = Colour( 255, 255, 255 );
_gui.AddChild( _guilabel );

pos = VectorScreen( 10, 50 );
size = ScreenSize( 230, 12 );
_guihealth = GUIProgressBar( pos, size );
_guihealth.Thickness = 2;
_guihealth.MaxValue = 100;
_guihealth.StartColour = Colour( 255, 0, 0 );
_guihealth.EndColour = Colour( 34, 139, 34 );
_gui.AddChild( _guihealth );

pos = VectorScreen( 10, 65 );
size = ScreenSize( 230, 12 );
_guiarmour = GUIProgressBar( pos, size );
_guiarmour.Thickness = 2;
_guiarmour.MaxValue = 100;
_guiarmour.StartColour = Colour( 50, 50, 50 );
_guiarmour.EndColour = Colour( 255, 255, 255 );
_gui.AddChild( _guiarmour );

AddGUILayer( _gui );
SendGUILayerToFront( _gui );
_gui.Visible = false;
}

function onClientRender()
_Process();

function onClientDeath ( killer, weapon, bodypart )
{
if ( killer ) _Initiate( LocalPlayer, killer );
}

function ReduceAngle ( ang )
{
local absang = abs( ang );
while ( absang > _dpi )
{
absang -= _dpi;
if ( ang > 0 ) ang -= _dpi;
else ang  = _dpi;
}

if ( absang > PI )
{
if ( ang < 0 ) ang  = _dpi;
else ang = _dpi - ang;
}
return ang;
}

function RandNum ( start, ... )
{
        local end;
        if ( vargv.len() > 0 ) end = vargv[ 0 ];
        else { end = start; start = 1; }
        local ticks = GetTickCount();
        return start   ( ticks % ( end - start ) );
}

not sure if its modified or not but i think everything should be in here :P
Title: Re: Team Fortress 2 Style Death Cam
Post by: Thijn on January 17, 2011, 04:26:02 pm
/me wonders why no one said "FUCKING AWESOME" yet...


FUCKING AWESOME!!!

Nice work ;)
Title: Re: Team Fortress 2 Style Death Cam
Post by: Orpheus on January 17, 2011, 06:46:34 pm
I saids "FUCKING AWESOMES!" when he was makings it  :o and it's even more awesome now! and i tolds him on irc!
Title: Re: Team Fortress 2 Style Death Cam
Post by: Windlord on January 17, 2011, 07:49:49 pm
Cheers guys :)
Title: Re: Team Fortress 2 Style Death Cam
Post by: Knucis on January 18, 2011, 10:59:01 pm
Yey this is awesome!
Title: Re: Team Fortress 2 Style Death Cam
Post by: Demi God on February 08, 2012, 03:14:31 pm
So sorry for dumping this old topic. but can anyone give me a new link please?
Title: Re: Team Fortress 2 Style Death Cam
Post by: Bryce on February 09, 2012, 11:56:06 am
File not found, look here (http://i39.tinypic.com/13z8kd1.jpg)
Title: Re: Team Fortress 2 Style Death Cam
Post by: SugarD on February 09, 2012, 04:49:09 pm
Anyone here who has an unmodified copy that can upload it somewhere?
Title: Re: Team Fortress 2 Style Death Cam
Post by: VetalYA on February 10, 2012, 10:54:57 pm
I in doubt, that someone have this file. But of course i have no doubt, that such file can be written again. :D
Title: Re: Team Fortress 2 Style Death Cam
Post by: VetalYA on February 11, 2012, 05:51:27 pm
Nice script,  ;)
Title: Re: Team Fortress 2 Style Death Cam
Post by: GuenosNoLife on January 17, 2013, 07:12:27 pm
Link is dead, please new link download thank's!
Title: Re: Team Fortress 2 Style Death Cam
Post by: GuenosNoLife on January 17, 2013, 07:24:41 pm
Read my upper post.
Oh thank's  :-*! I thought it was modified, I want without modified
Sorry, I'm stupid  :-X
Title: Re: Team Fortress 2 Style Death Cam
Post by: SugarD on January 17, 2013, 07:53:44 pm
Updated the first post with a quote of it to get rid of some confusion. :)
Title: Re: Team Fortress 2 Style Death Cam
Post by: highsinberg on October 12, 2013, 08:36:34 pm
I made a new upload took me a few minutes the clients 0 keep giving me errors i think you guys uploaded the wrong client last time. This ones is good to go 


Make sure that LU/Content.xml includes: <script folder="Deathcam" />


 

 >> CLICK ME <<  Nice upload WindLord. thanks   

If dropbox asks for login use [email protected] password= gta123 click link above for the file (https://www.dropbox.com/s/00nf9djachwjpv5/Deathcam.zip)