注册 登录
MOD中国同盟社 返回首页

编程爱好者 http://www.modchina.com/?25792 [收藏] [复制] [分享] [RSS] 空间主要记录一些AMXX代码

日志

离开人物自由走动的照相机

热度 3已有 855 次阅读2011-7-23 17:23 |个人分类:Amxx调试| 照相机

#include < amxmodx >
#include < amxmisc >
#include < engine >
#include < fakemeta >
#include < hamsandwich >

new g_iCamera[ 33 ];
new bool:g_bFlying[ 33 ];

public plugin_init( ) {
    register_plugin( "Fly As Soul", "0.0.1", "Exolent" );
    
    RegisterHam( Ham_Spawn, "player", "FwdPlayerSpawn", 1 );
    RegisterHam( Ham_Killed, "player", "FwdPlayerDeath", 1 );
    
    register_forward( FM_CmdStart, "FwdCmdStart" );
    
    new iMaxPlayers = get_maxplayers( );
    
    new iEntity;
    for( new client = 1; client <= iMaxPlayers; client++ ) {
        iEntity = create_entity( "info_target" );
        entity_set_string( iEntity, EV_SZ_classname, "player_soul" );
        entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_NOCLIP );
        entity_set_int( iEntity, EV_INT_solid, SOLID_NOT );
        entity_set_model( iEntity, "models/w_usp.mdl" );
        set_rendering( iEntity, kRenderFxNone, 0, 0, 0, kRenderTransTexture, 0 );
        g_iCamera[ client ] = iEntity;
    }
}

public client_disconnect( client ) {
    if( g_bFlying[ client ] ) {
        ResetCamera( client );
    }
}

public FwdPlayerSpawn( client ) {
    if( is_user_alive( client ) && g_bFlying[ client ] ) {
        ResetCamera( client );
    }
}

public FwdPlayerDeath( client ) {
    if( !is_user_alive( client ) && g_bFlying[ client ] ) {
        ResetCamera( client );
    }
}

public FwdCmdStart( client, ucHandle ) {
    if( !is_user_alive( client ) ) {
        return;
    }
    
    static iButtons;
    iButtons = get_uc( ucHandle, UC_Buttons );
    
    if( ( iButtons & IN_DUCK ) && ( iButtons & IN_USE ) ) {
        if( g_bFlying[ client ] ) {
            ResetCamera( client );
        } else {
            g_bFlying[ client ] = true;
            attach_view( client, g_iCamera[ client ] );
            
            static Float:vOrigin[ 3 ];
            entity_get_vector( client, EV_VEC_origin, vOrigin );
            entity_set_vector( g_iCamera[ client ], EV_VEC_origin, vOrigin );
        }
    }
    if( g_bFlying[ client ] ) {
        // Should be made more efficient
        // Wrote this in Notepad in my Programming class :P
        entity_set_int( client, EV_INT_flags, ( entity_get_int( client, EV_INT_flags ) & FL_FROZEN ) );
        
        static Float:vAimVelocity[ 3 ];
        velocity_by_aim( client, 250, vAimVelocity );
        
        new Float:vVelocity[ 3 ];
        if( iButtons & IN_FORWARD ) {
            vVelocity[ 0 ] += vAimVelocity[ 0 ];
            vVelocity[ 1 ] += vAimVelocity[ 1 ];
            vVelocity[ 2 ] += vAimVelocity[ 2 ];
        }
        if( iButtons & IN_BACK ) {
            vVelocity[ 0 ] -= vAimVelocity[ 0 ];
            vVelocity[ 1 ] -= vAimVelocity[ 1 ];
            vVelocity[ 2 ] -= vAimVelocity[ 2 ];
        }
        if( iButtons & IN_MOVERIGHT ) {
            vVelocity[ 0 ] += vAimVelocity[ 1 ];
            vVelocity[ 1 ] -= vAimVelocity[ 0 ];
        }
        if( iButtons & IN_MOVELEFT ) {
            vVelocity[ 0 ] -= vAimVelocity[ 1 ];
            vVelocity[ 1 ] += vAimVelocity[ 0 ];
        }
        entity_set_vector( g_iCamera[ client ], EV_VEC_velocity, vVelocity );
        
        entity_get_vector( client, EV_VEC_v_angle, vVelocity );
        entity_set_vector( g_iCamera[ client ], EV_VEC_angles, vVelocity );
    }
}

ResetCamera( client ) {
    g_bFlying[ client ] = false;
    attach_view( client, client );
    entity_set_int( client, EV_INT_flags, ( entity_get_int( client, EV_INT_flags ) & ~FL_FROZEN ) );
}  

路过

鸡蛋
2

鲜花

握手

雷人

刚表态过的朋友 (2 人)

收藏 分享 转发到开心网 举报

发表评论 评论 (2 个评论)

回复 david0944 2011-7-26 19:27
  
回复 szfzafa 2011-10-6 16:49
何必死后设置 活人灵魂出窍有什么不好

facelist

您需要登录后才可以评论 登录 | 注册
验证问答 换一个 验证码 换一个

回顶部