Monthly Target: $400 Donations: $32
 8% 

CS 1.6 Custom 3rd Person View


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OneEyed
AMX Mod X Beta Tester
Join Date: Jun 2005
Old 01-08-2008 , 07:04   CS 1.6 Custom 3rd Person View
Reply With Quote #1

Hey guys, I was messing around and made my own 3rd person camera. This camera has several different things compared with using set_view from engine module.

Differences:
- Precision where your aiming is better.
- Your model isn't alpha'd.
- Your model stutters a bit with this method.
- Doesn't require rocket.mdl (uses a weapon file from mod thats already precached)

Heres the code using ENGINE module. It can be converted to FAKEMETA tho.

Code:
//Call this wherever you want. Create_PlayerCamera( id ) {     new entid;     while( (entid = find_ent_by_class(entid, "PlayerCamera")) != 0)         if( entity_get_edict( entid, EV_ENT_owner ) == id )         {             attach_view( id, entid );             return;         }             entid = create_entity("info_target");             if(entid)     {         entity_set_string(entid,EV_SZ_classname,"PlayerCamera");         entity_set_model(entid,"models/w_usp.mdl");         entity_set_int( entid, EV_INT_solid, SOLID_TRIGGER);         entity_set_int( entid, EV_INT_movetype, MOVETYPE_FLY );                  //Set owner         entity_set_edict( entid, EV_ENT_owner, id );         //Don't draw         entity_set_int( entid, EV_INT_rendermode, kRenderTransTexture);         entity_set_float( entid, EV_FL_renderamt, 0.0);         //Attach our view to this entity.         attach_view( id, entid );         //Think!         entity_set_float( entid, EV_FL_nextthink, get_gametime() );     }    } //Requires registering a Think method for "PlayerCamera" entity. // OR you could save the camera's entity ID in the function above // and call this in client_PostThink or wherever that gets called alot. public Think_PlayerCamera( entid ) {     new id = entity_get_edict( entid, EV_ENT_owner );         //Kill our entity if we hit USE key     new buttons = entity_get_int( id, EV_INT_button );     if(buttons & IN_USE)     {         attach_view( id, id );         remove_entity(entid);         return;     }     new Float:origin[3], Float:angle[3], Float:vBack[3];     entity_get_vector( id, EV_VEC_origin, origin );     entity_get_vector( id, EV_VEC_v_angle, angle );     angle_vector( angle, ANGLEVECTOR_FORWARD, vBack );     origin[2] += 20.0; //So we're closer to the eyes.         //Move back to see ourself (150 units)     origin[0] += (-vBack[0] * 150.0);     origin[1] += (-vBack[1] * 150.0);     origin[2] += (-vBack[2] * 150.0);     entity_set_origin( entid, origin );     entity_set_vector( entid, EV_VEC_angles, angle );            //For thinking only     entity_set_float( entid, EV_FL_nextthink, get_gametime() ); }

That's it. You can change how the player can turn this off if you don't want to use my USE key method, just copy attach_view( id, id ); and remove_entity(entid); where you want to do it.

Here's a screenshot:
Attached Thumbnails
Click image for larger version

Name:	thirdperson.jpg
Views:	5054
Size:	40.4 KB
ID:	22811  
__________________

Last edited by OneEyed; 01-08-2008 at 07:07.
OneEyed is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 01-08-2008 , 07:53   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #2

wow, this is so cool, and with fakemeta, this will be awesome. Good Job OneEyed.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-08-2008 , 12:53   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #3

Fakemeta way.

Code:
    #include <amxmodx>     #include <fakemeta>     new const g_sCamclass[] = "PlayerCamera";     public plugin_init()     {         register_clcmd( "say /cam", "cmdCam" );         register_forward( FM_Think, "Think_PlayerCamera" );     }     public cmdCam( id )         Create_PlayerCamera( id );     Create_PlayerCamera( id )     {         new iEnt; static const sClassname[] = "classname";         while( ( iEnt = engfunc( EngFunc_FindEntityByString, iEnt, sClassname, g_sCamclass ) ) != 0 )         {             if( pev( iEnt, pev_owner) == id )             {                 engfunc( EngFunc_SetView, id, iEnt );                 return;             }         }         static const sInfo_target[] = "info_target";         iEnt = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, sInfo_target ) )         if( !iEnt )             return;                 static const sCam_model[] = "models/w_usp.mdl";         set_pev( iEnt, pev_classname, g_sCamclass );         engfunc( EngFunc_SetModel, iEnt, sCam_model );         set_pev( iEnt, pev_solid, SOLID_TRIGGER );         set_pev( iEnt, pev_movetype, MOVETYPE_FLY );         set_pev( iEnt, pev_owner, id );         set_pev( iEnt, pev_rendermode, kRenderTransTexture );         set_pev( iEnt, pev_renderamt, 0.0 );         engfunc( EngFunc_SetView, id, iEnt );         set_pev( iEnt, pev_nextthink, get_gametime() );     }     public Think_PlayerCamera( iEnt )     {         static sClassname[32];         pev( iEnt, pev_classname, sClassname, sizeof sClassname - 1 );         if( !equal( sClassname, g_sCamclass ) )             return FMRES_IGNORED;         static iOwner;         iOwner = pev( iEnt, pev_owner );         if( !is_user_alive( iOwner ) )             return FMRES_IGNORED;         static iButtons;         iButtons = pev( iOwner, pev_button );         if( iButtons & IN_USE )         {             engfunc( EngFunc_SetView, iOwner, iOwner );             engfunc( EngFunc_RemoveEntity, iEnt );             return FMRES_IGNORED;         }         static Float:fOrigin[3], Float:fAngle[3];         pev( iOwner, pev_origin, fOrigin );         pev( iOwner, pev_v_angle, fAngle );         static Float:fVBack[3];         angle_vector( fAngle, ANGLEVECTOR_FORWARD, fVBack );         fOrigin[2] += 20.0;         fOrigin[0] += ( -fVBack[0] * 150.0 );         fOrigin[1] += ( -fVBack[1] * 150.0 );         fOrigin[2] += ( -fVBack[2] * 150.0 );         engfunc( EngFunc_SetOrigin, iEnt, fOrigin );         set_pev( iEnt, pev_angles, fAngle );         set_pev( iEnt, pev_nextthink, get_gametime() );         return FMRES_HANDLED;     }
__________________
Working on : CS Weapon Mod (72%) , MonsterAI (PAUSED),


Last edited by Arkshine; 01-08-2008 at 13:50.
Arkshine is online now
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-08-2008 , 14:36   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #4

I'm jealous that you were able to get attach_view to work. Good job!
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
mut2nt
Senior Member
Join Date: Oct 2006
Location: in HELL!
Old 09-24-2008 , 15:35   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #5

and how can i set it to normal?
__________________
Anyone who helps me +KARMA
mut2nt is offline
Send a message via Yahoo to mut2nt Send a message via Skype™ to mut2nt
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 09-24-2008 , 15:38   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #6

engine:
Code:
        attach_view( id, id );
        remove_entity(entid);
fakemeta:
Code:
            engfunc( EngFunc_SetView, iOwner, iOwner );
            engfunc( EngFunc_RemoveEntity, iEnt );
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
mut2nt
Senior Member
Join Date: Oct 2006
Location: in HELL!
Old 09-24-2008 , 15:46   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #7

i get it :*! 10x!
__________________
Anyone who helps me +KARMA
mut2nt is offline
Send a message via Yahoo to mut2nt Send a message via Skype™ to mut2nt
niFe
Senior Member
Join Date: Apr 2008
Location: Planet Green
Old 02-12-2009 , 01:04   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #8

ohhh yes oneEyed!!
__________________
niFe is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 04-17-2009 , 11:47   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #9

Here is my method, improved some things , the model doesn't shake anymore.

PHP Code:
#include <amxmodx>
#include <engine>

new const pl_cm_class[] = "PlayerCamera"

public plugin_init()
{
    
register_clcmd"say /cam""cmdCam" )
    
register_think(pl_cm_class,"Think_PlayerCamera")
}

public 
cmdCam(id)
    
Create_PlayerCamera(id)

Create_PlayerCamera(id)
{
    new 
ent = -1
    
while ((ent find_ent_by_class(ent,pl_cm_class)) != 0)
    {
        if (
entity_get_edict(ent,EV_ENT_owner) == id)
        {
            
attach_view(id ent)
            return
        }
    }
    
ent create_entity("info_target")
    
    if( !
ent )
        return;
    
    
entity_set_string(entEV_SZ_classnamepl_cm_class)
    
    
entity_set_model(ent"models/w_usp.mdl")
    
    
entity_set_byte(entEV_INT_solidSOLID_TRIGGER)
    
entity_set_int(entEV_INT_movetypeMOVETYPE_FLYMISSILE)
    
    
entity_set_edict(entEV_ENT_ownerid)
    
    
entity_set_int(ent,EV_INT_rendermodekRenderTransTexture)
    
entity_set_float(entEV_FL_renderamt0.0 )
    
    
attach_view(id,ent)
    
entity_set_float(entEV_FL_nextthinkget_gametime())
}

public 
Think_PlayerCamera(ent)
{
    static 
owner
    owner 
entity_get_edict(ent,EV_ENT_owner)
    
    static 
iButtons;
    
iButtons entity_get_int(ownerEV_INT_button)
    
    if( 
iButtons IN_USE  || !is_user_alive(owner))
    {
        
attach_view(owner,owner)
        
remove_entity(ent)
        return 
PLUGIN_CONTINUE;
    }
    
    
    static 
Float:origin[3], Float:fAngle[3],Float:origin2[3];
    
entity_get_vector(owner,EV_VEC_origin,origin)
    
entity_get_vector(owner,EV_VEC_v_angle,fAngle)
    
    
origin2[0] = origin[0]
    
origin2[1] = origin[1]
    
origin2[2] = origin[2]
    
    static 
Float:fVBack[3];
    
angle_vectorfAngleANGLEVECTOR_FORWARDfVBack );
    
    
origin[2] += 20.0;
    
    
origin[0] += ( -fVBack[0] * 150.0 );
    
origin[1] += ( -fVBack[1] * 150.0 );
    
origin[2] += ( -fVBack[2] * 150.0 );
    
    
trace_line(owner,origin2,origin,origin)
    
    
entity_set_vector(ent,EV_VEC_origin,origin)
    
    
entity_get_vector(owner,EV_VEC_velocity,origin2)
    
entity_set_vector(ent,EV_VEC_velocity,origin2)
    
    
entity_set_vector(ent,EV_VEC_angles,fAngle)
    
entity_set_float(entEV_FL_nextthinkget_gametime())
    
    return 
PLUGIN_CONTINUE;

__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 04-17-2009 at 11:55.
ot_207 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 04-17-2009 , 14:39   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #10

Quote:
Originally Posted by ot_207 View Post
Here is my method, improved some things , the model doesn't shake anymore.
Is there a reason for changing MOVETYPE_FLY to MOVETYPE_FLYMISSILE?
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Old 04-17-2009, 14:41
xPaw
This message has been deleted by xPaw. Reason: nvm -_-
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:25.


Powered by vBulletin®
Copyright ©2000 - 2015, vBulletin Solutions, Inc.
Theme made by Freecode