Raised This Month: $ Target: $400
 0% 

"Drawing" on the HUD - like in Arx Fatalis


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Lulu the hero
Senior Member
Join Date: Oct 2009
Location: Budapest, Hungary
Old 02-07-2011 , 12:40   Re: "Drawing" on the HUD
Reply With Quote #7

Allright, implemented the code, it's working so far, time to edit it.
PHP Code:
//-> https://forums.alliedmods.net/showthread.php?t=65427

#pragma semicolon 1

#include <amxmodx>
#include <bit>
#include <fakemeta>

new const CLASSNAME_CAMERA[] =    "player_camera";
#define MODEL_CAM        "models/can.mdl"

new in_magic;
new 
Float:premagic_angles[32][3];

public 
plugin_init()
{
    
register_plugin("Fix camera angle test""0.0""Lulu the hero");
    
    
register_concmd("+magic""cmd_magic_on");
    
register_concmd("-magic""cmd_magic_off");
    
    
register_event("DeathMsg""event_death""a");
    
    
register_forward(FM_Think"forward_think");
}

public 
plugin_precache()
{
    
precache_model(MODEL_CAM);
}

public 
cmd_magic_on(id)
{
    if(!
is_player_flag_set(in_magicid) && is_user_alive(id))
    {
        
pev(idpev_v_anglepremagic_angles[id-1]);
        
create_camera(id);
        
set_player_flag(in_magicid);
    }
}

public 
cmd_magic_off(id)
{
    if(
is_player_flag_set(in_magicid))
    {
        
clear_player_flag(in_magicid);
    }
}

public 
event_death()
{
    new 
victim read_data(2);
    if(
is_player_flag_set(in_magicvictim))
    {
        
clear_player_flag(in_magicvictim);
    }
}

public 
forward_think(ent)
{
    static 
classname[32];
    
pev(entpev_classnameclassnamesizeof classname 1);
    
    if(!
equal(classnameCLASSNAME_CAMERA)) return FMRES_IGNORED;

    static 
owner;
    
owner pev(entpev_owner);
    
    if(!
is_player_flag_set(in_magicowner))
    {
        
engfunc(EngFunc_SetViewownerowner);
        
engfunc(EngFunc_RemoveEntityent);
        return 
FMRES_IGNORED;
    }
    
    static 
Float:origin[3], Float:angle[3];
    
pev(ownerpev_originorigin);
    
    
//pev(owner, pev_v_angle, angle);
    
angle[0] = premagic_angles[owner-1][0];
    
angle[1] = premagic_angles[owner-1][1];
    
angle[2] = premagic_angles[owner-1][2];
    
    static 
Float:back[3];
    
angle_vector(angleANGLEVECTOR_FORWARDback);
    
    
origin[2] += 20.0;
    
    
origin[0] += ( -back[0] * 150.0 );
    
origin[1] += ( -back[1] * 150.0 );
    
origin[2] += ( -back[2] * 150.0 );
    
    
engfunc(EngFunc_SetOriginentorigin);
    
    
set_pev(entpev_anglesangle);
    
set_pev(entpev_nextthinkget_gametime());
    
    return 
FMRES_HANDLED;
}

stock create_camera(id)
{
    static const 
classname[] = "classname";
    new 
ent;
    while((
ent engfuncEngFunc_FindEntityByStringentclassnameCLASSNAME_CAMERA)) != 0)
    {
        if(
pev(entpev_owner) == id)
        {
            
engfunc(EngFunc_SetViewident);
            return;
        }
    }
    
    static const 
info_target[] = "info_target";
    
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringinfo_target));
    
    if(!
ent) return;
    
    static const 
cam_model[] = MODEL_CAM;
    
set_pev(entpev_classnameCLASSNAME_CAMERA);
    
engfunc(EngFunc_SetModelentcam_model);
    
    
set_pev(entpev_solidSOLID_TRIGGER);
    
set_pev(entpev_movetypeMOVETYPE_FLY);
    
set_pev(entpev_ownerid);
    
    
set_pev(entpev_rendermodekRenderTransTexture);
    
set_pev(entpev_renderamt0.0);
    
    
engfunc(EngFunc_SetViewident);
    
set_pev(entpev_nextthinkget_gametime());

Edit: I've changed the camera model to a halflife model, so that it can be applied to mods other, than cs too.

Last edited by Lulu the hero; 02-10-2011 at 20:26.
Lulu the hero is offline
 



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 10:19.


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