Author Topic: Team Fortress 2 Style Death Cam  (Read 9864 times)

Windlord

  • Guest
Team Fortress 2 Style Death Cam
« on: January 15, 2011, 09: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 (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



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
« Last Edit: January 17, 2013, 08:53:20 pm by SugarD »

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Team Fortress 2 Style Death Cam
« Reply #1 on: January 17, 2011, 05:26:02 pm »
* Thijn wonders why no one said "FUCKING AWESOME" yet...


FUCKING AWESOME!!!

Nice work ;)

Orpheus

  • Newbie
  • *
  • Posts: 49
  • Karma: +1/-0
  • Music is a way of life.
    • View Profile
    • Orphtown UK
Re: Team Fortress 2 Style Death Cam
« Reply #2 on: January 17, 2011, 07: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!

Windows: A 64-bit/32-bit extension to a 16-bit GUI on an 8-bit OS written for a 4-bit architecture by a 2-bit company who can not stand 1-bit of competition.

Windlord

  • Guest
Re: Team Fortress 2 Style Death Cam
« Reply #3 on: January 17, 2011, 08:49:49 pm »
Cheers guys :)

Knucis

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +2/-2
    • View Profile
Re: Team Fortress 2 Style Death Cam
« Reply #4 on: January 18, 2011, 11:59:01 pm »
Yey this is awesome!

Demi God

  • Newbie
  • *
  • Posts: 20
  • Karma: +1/-1
    • View Profile
Re: Team Fortress 2 Style Death Cam
« Reply #5 on: February 08, 2012, 04:14:31 pm »
So sorry for dumping this old topic. but can anyone give me a new link please?
Liberty Unleashed daily user!
[DW] Clan owner!
[DW] || Battle-Grounds server owner!
Click here to join us!

Bryce

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Team Fortress 2 Style Death Cam
« Reply #6 on: February 09, 2012, 12:56:06 pm »
File not found, look here

SugarD

  • Argonath RPG Dev/Manager
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: Team Fortress 2 Style Death Cam
« Reply #7 on: February 09, 2012, 05:49:09 pm »
Anyone here who has an unmodified copy that can upload it somewhere?

VetalYA

  • Guest
Re: Team Fortress 2 Style Death Cam
« Reply #8 on: February 10, 2012, 11: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

VetalYA

  • Guest
Re: Team Fortress 2 Style Death Cam
« Reply #9 on: February 11, 2012, 06:51:27 pm »
Nice script,  ;)

GuenosNoLife

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +12/-14
    • View Profile
Re: Team Fortress 2 Style Death Cam
« Reply #10 on: January 17, 2013, 08:12:27 pm »
Link is dead, please new link download thank's!
Little back... Maybe not maybe yes...

GuenosNoLife

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +12/-14
    • View Profile
Re: Team Fortress 2 Style Death Cam
« Reply #11 on: January 17, 2013, 08:24:41 pm »
Read my upper post.
Oh thank's  :-*! I thought it was modified, I want without modified
Sorry, I'm stupid  :-X
Little back... Maybe not maybe yes...

SugarD

  • Argonath RPG Dev/Manager
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: Team Fortress 2 Style Death Cam
« Reply #12 on: January 17, 2013, 08:53:44 pm »
Updated the first post with a quote of it to get rid of some confusion. :)

highsinberg

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Team Fortress 2 Style Death Cam
« Reply #13 on: October 12, 2013, 09: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
« Last Edit: December 03, 2013, 11:08:18 am by highsinberg »

 

© Liberty Unleashed Team.