Raised This Month: $32 Target: $400
 8% 

[Help] 3rd View shoot accuracy (Not Solved)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 05-16-2014 , 02:56   [Help] 3rd View shoot accuracy (Not Solved)
Reply With Quote #1

I have this code
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <xs>

#define VERSION "0.0.2"

#define MAX_PLAYERS    32

#define USE_TOGGLE 3


#define CAMERA_FORWARD -35.0
#define CAMERA_RIGHT 30.0
#define CAMERA_UP 10.0
#define CAMERA_FRACTION -35.0

new g_iPlayerCamera[MAX_PLAYERS+1]

new 
g_iMaxPlayers

public plugin_init()
{
    
register_plugin("Camera View AUTOMATIC"VERSION"ConnorMcLeod")
    
    
RegisterHam(Ham_Spawn"player""CBasePlayer_Spawn_Post"1)
    
register_forward(FM_SetView"SetView")
    
RegisterHam(Ham_Think"trigger_camera""Camera_Think")
    
    
g_iMaxPlayers get_maxplayers()
}

public 
CBasePlayer_Spawn_Postid )
{
    if( !
is_user_alive(id) )
    {
        return
    }
    
    new 
iEnt g_iPlayerCamera[id]
    if( !
pev_valid(iEnt) )
    {
        static 
iszTriggerCamera
        
if( !iszTriggerCamera )
        {
            
iszTriggerCamera engfunc(EngFunc_AllocString"trigger_camera")
        }
        
iEnt engfunc(EngFunc_CreateNamedEntityiszTriggerCamera)
        
set_kvd(0KV_ClassName"trigger_camera")
        
set_kvd(0KV_fHandled0)
        
set_kvd(0KV_KeyName"wait")
        
set_kvd(0KV_Value"999999")
        
dllfunc(DLLFunc_KeyValueiEnt0)
        
        
set_pev(iEntpev_spawnflagsSF_CAMERA_PLAYER_TARGET|SF_CAMERA_PLAYER_POSITION)
        
set_pev(iEntpev_flagspev(iEntpev_flags) | FL_ALWAYSTHINK)
        
        
dllfunc(DLLFunc_SpawniEnt)
        
        
g_iPlayerCamera[id] = iEnt
        
//   }
        
        
new Float:flMaxSpeediFlags pev(idpev_flags)
        
pev(idpev_maxspeedflMaxSpeed)
        
        
ExecuteHam(Ham_UseiEntididUSE_TOGGLE1.0)
        
        
set_pev(idpev_flagsiFlags)
        
// depending on mod, you may have to send SetClientMaxspeed here.
        // engfunc(EngFunc_SetClientMaxspeed, id, flMaxSpeed)
        
set_pev(idpev_maxspeedflMaxSpeed)
    }
}

public 
SetView(idiEnt)
{
    if( 
is_user_alive(id) )
    {
        new 
iCamera g_iPlayerCamera[id]
        if( 
iCamera && iEnt != iCamera )
        {
            new 
szClassName[16]
            
pev(iEntpev_classnameszClassNamecharsmax(szClassName))
            if( !
equal(szClassName"trigger_camera") ) // should let real cams enabled
            
{
                
engfunc(EngFunc_SetViewidiCamera// shouldn't be always needed
                
return FMRES_SUPERCEDE
            
}
        }
    }
    return 
FMRES_IGNORED
}

public 
client_disconnect(id)
{
    new 
iEnt g_iPlayerCamera[id]
    if( 
pev_valid(iEnt) )
    {
        
engfunc(EngFunc_RemoveEntityiEnt)
    }
    
g_iPlayerCamera[id] = 0
}

public 
client_putinserver(id)
{
    
g_iPlayerCamera[id] = 0
}

public 
get_cam_owner(iEnt)
{
    static 
id
    
for(id 1id<=g_iMaxPlayersid++)
    {
        if( 
g_iPlayerCamera[id] == iEnt )
        {
            return 
id
        
}
    }
    return 
0
}

public 
Camera_ThinkiEnt )
{
    static 
id
    
if( !(id get_cam_owneriEnt )) )
    {
        return
    }
    
    static 
Float:fVecPlayerOrigin[3], Float:fVecCameraOrigin[3], Float:fVecAngles[3], 
    
Float:fVecForward[3], Float:fVecRight[3], Float:fVecUp[3]

    
pev(idpev_originfVecPlayerOrigin)
    
pev(idpev_view_ofsfVecAngles)
    
    
fVecPlayerOrigin[2] += fVecAngles[2]
    
pev(idpev_v_anglefVecAngles)
    
    
angle_vector(fVecAnglesANGLEVECTOR_FORWARDfVecForward)
    
angle_vector(fVecAnglesANGLEVECTOR_RIGHTfVecRight)
    
angle_vector(fVecAnglesANGLEVECTOR_UPfVecUp)
    
    
fVecCameraOrigin[0] = fVecPlayerOrigin[0] + fVecForward[0] * CAMERA_FORWARD fVecRight[0] * CAMERA_RIGHT fVecUp[0] * CAMERA_UP
    fVecCameraOrigin
[1] = fVecPlayerOrigin[1] + fVecForward[1] * CAMERA_FORWARD fVecRight[1] * CAMERA_RIGHT fVecUp[1] * CAMERA_UP
    fVecCameraOrigin
[2] = fVecPlayerOrigin[2] + fVecForward[2] * CAMERA_FORWARD fVecRight[2] * CAMERA_RIGHT fVecUp[2] * CAMERA_UP
    
    engfunc
(EngFunc_TraceLinefVecPlayerOriginfVecCameraOriginIGNORE_MONSTERSid0)
    static 
Float:flFraction
    get_tr2
(0TR_flFractionflFraction)
    if( 
flFraction != 1.0 // adjust camera place if close to a wall
    
{
        
flFraction *= CAMERA_FRACTION
        
        
//fVecCameraOrigin[0] = fVecPlayerOrigin[0] + fVecForward[0] * flFraction + fVecRight[0] * flFraction + fVecUp[0] * flFraction
        //fVecCameraOrigin[1] = fVecPlayerOrigin[1] + fVecForward[1] * flFraction + fVecRight[1] * flFraction + fVecUp[1] * flFraction
        //fVecCameraOrigin[2] = fVecPlayerOrigin[2] + fVecForward[2] * flFraction + fVecRight[2] * flFraction + fVecUp[2] * flFraction
        
        
fVecCameraOrigin[0] = fVecPlayerOrigin[0] + (fVecForward[0] * flFraction)
        
fVecCameraOrigin[1] = fVecPlayerOrigin[1] + (fVecForward[1] * flFraction)
        
fVecCameraOrigin[2] = fVecPlayerOrigin[2] + (fVecForward[2] * flFraction)
    }
    
    
set_pev(iEntpev_originfVecCameraOrigin)
    
set_pev(iEntpev_anglesfVecAngles)

This code make the players see their character from back side and right side... But when i fire a bullet, the hit origin is different from the crosshair origin... Could someone help me to solve it ?


Last edited by dias; 05-16-2014 at 06:39.
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 05-16-2014 , 09:14   Re: [Help] 3rd View shoot accuracy (Not Solved)
Reply With Quote #2

When i created new camera system i had one problem what cant be fixed.
The camera movements was really laggy. Well movements was not that bad but the rotation was just horrible.
Have you tested this plugin in server side? ( and i dont mean local server or lan )

============================================= =======================
Now lets talk about solution.
What if you set player v_angle after setting camera angles so it will aim to the correct place?

idea
PHP Code:
static float:a[3]
pevidpev_v_angle)
a[1] += 5.0
a
[0] += 1.0 
If the origin of two points ( where and where it must aim ) is always same then just mess with those values i gave.
.Dare Devil. is offline
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 05-16-2014 , 09:26   Re: [Help] 3rd View shoot accuracy (Not Solved)
Reply With Quote #3

1. Don't worry, i knew this laggy problem... This code is from Connor, fixed lag problem. it doesn't lag in ServerSide or ClientSide. You can try it
2. Can you edit my code?
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 05-16-2014 , 12:35   Re: [Help] 3rd View shoot accuracy (Not Solved)
Reply With Quote #4

Quote:
Originally Posted by dias View Post
1. Don't worry, i knew this laggy problem... This code is from Connor, fixed lag problem. it doesn't lag in ServerSide or ClientSide. You can try it
2. Can you edit my code?
wait so your code doenst lag at all? Like spectatoring other player?
Thats the most amazing thing ive ever heard. I can make so many stuff if this is true.
Anyway, i will edit your code when i get back home. I need to test it and etc...
.Dare Devil. is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 05-16-2014 , 13:31   Re: [Help] 3rd View shoot accuracy (Not Solved)
Reply With Quote #5

Connor is setting the camera origin in its think, so it's still frame driven which will probably result in the same lag as others.

Last edited by Backstabnoob; 05-16-2014 at 13:31.
Backstabnoob is offline
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 05-16-2014 , 20:44   Re: [Help] 3rd View shoot accuracy (Not Solved)
Reply With Quote #6

Connor uses the original camera of Spectator... I tested in Server-Side, it doesn't lag like the other camera 3rd
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 05-16-2014 , 20:53   Re: [Help] 3rd View shoot accuracy (Not Solved)
Reply With Quote #7

Well, "don't know exactly" but things that are directly coded in a module works faster than doing it in a plugin, this is about execution time, that's why engine's custom cameras does not fully lag
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
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 11:21.


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