AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   "Drawing" on the HUD - like in Arx Fatalis (https://forums.alliedmods.net/showthread.php?t=141220)

Lulu the hero 10-21-2010 00:30

"Drawing" on the HUD - like in Arx Fatalis
 
Hi everyone again!

Is it possible to "draw" on the HUD?
What I would like is when a player is moving the mouse, then the camera is not moving with it and a cursor is shown on the hud to see where is the mouse on the screen. Then add some sprites and lightings in front of the player to act as a mouse movement tracer. Basicly I would like to get an effect seen in the game: Arx Fatalis( not a HL engine game ).

See the video of what I mean( 0: 30 ).
http://www.youtube.com/watch?v=oMR-83YpIQM


Oh and maybe get the coords of the mouse.

Then from the coords I could try to estimate of what simbol was the user drawing.

So my question is, can this be done in HL with amxmodx?

Thank you in advance for any ideas and comments.

Sylwester 10-21-2010 00:58

Re: "Drawing" on the HUD
 
You can't draw directly on the HUD. The best you can do is draw like this:
http://forums.alliedmods.net/showthread.php?p=487998

Lulu the hero 10-21-2010 01:03

Re: "Drawing" on the HUD
 
Okay, but to fix the camera for the player for a time, like in NS on a CO map, a menu pops up, and you see the cursor, you can select items from the menu...

Lulu the hero 10-21-2010 20:47

Re: "Drawing" on the HUD
 
Come to think of it...
In Arx Fatalis, while I run forward and cast a spell, then a part of "magic drawing" is getting left behind, so it is indeed this way: the sparkle entites are drawn in front of the player and they do live for about 1-1.5 secs.
And that could be done with the get_user_origin() function.

And I've also thinked of: NS's ATTACK2 called menu works exactly like the ingame menu of CStrike - default key H, so that's propably the way it's done.

But is it possible to toggle mouse look ingame controlled via a plugin?

Edit:
On disabling mouse look I mean the mouse is not used for rotating the camera and the cursor can be moved around on the HUD( or like that ) and not just stays in the center.

Lulu the hero 11-27-2010 10:38

Re: "Drawing" on the HUD
 
Okay guys, new approach.
First of all I need to disable rotating view with the mouse. I read in the coords of the player's angle, then calculate the direction, where the mouse moved. Then I draw a sprite( a hud icon ) to the position, plus I need to hide the actual cursor, while drawing. Also I need to disable any weapon orientated things. So far the code is this, and I will write my problem under the code:
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define id_to_flag(%1)    (1<<(%1-1))

#define clear(%1,%2)    (%1 = %1 & ~id_to_flag(%2))
#define set(%1,%2)    (%1 = %1 | id_to_flag(%2))
#define is_set(%1,%2)    (%1 & id_to_flag(%2))

/*
new const Float:MAX_COORDS[2] =
{
    640.0,
    480.0
}
*/

new magic_mode;

//new Float:last_coords[32][2];
new Float:last_angles[32][3];

public 
plugin_init()
{
    
register_plugin("Arx Magic""0.0""Lulu the hero");
    
    
register_concmd("+magic""cmd_magic_on");
    
register_concmd("-magic""cmd_magic_off");
    
    
register_forward(FM_PlayerPreThink"fw_player_think");
}

public 
client_putinserver(id)
{
    
clear(magic_modeid);
    
last_angles[id-1][0] = 0.0;
    
last_angles[id-1][1] = 0.0;
    
last_angles[id-1][2] = 0.0;
}

public 
cmd_magic_on(id)
{
    
// filtering comes here
    
set(magic_modeid);
    
/*
    last_coords[id-1][0] = MAX_COORDS[0]/2;
    last_coords[id-1][1] = MAX_COORDS[1]/2;
    */
}

public 
cmd_magic_off(id)
{
    
clear(magic_modeid);
}

public 
fw_player_think(id)
{
    static 
/*Float:coord[2],*/ Float:angle[3];
    
    
pev(idpev_anglesangle);
    
    if(!
is_set(magic_modeid))
    {
        
last_angles[id-1] = angle;
        return 
FMRES_IGNORED;
    }
    
    
// Warning, the line below does not work!
    
set_pev(idpev_angleslast_angles[id-1]);
    
    
// Here we calculate the 2d screen coords from the angles.
    
    //last_coords[id-1] = coord;
    
    
return FMRES_SUPERCEDE;


I've also noted it in the source, that angles setting to a player does not work.
But somehow it is possible to fix the camera. Tried setting pev_fixangle, but it didn't work as expected. Everyone experiances camera fixing, when a player's view is dragged around in a "video", or in spectator mode, or when dying.

I saw on this forum somewhere a plugin, which allows disabling HUD elements, like money, or crosschair - maybe ConnorMcLeod's code?
Also I saw a code here too, which I could draw a HUD icon to any position on the HUD.

Thank you all for your helps in advance.

Lulu the hero 02-07-2011 11:23

Re: "Drawing" on the HUD
 
Maybe there is an ugly way to fix a user's view.:twisted:
Put a camera in the position of the player and hide the player to itself with FM_AddToFullPack. I think the camera's can be fixed that it goes only in a given direction( not paying attention to the player's angles ) with the method of not attaching the camera to the player.
an get the coords by the angle settings of the player.

I'm going to abuse this: https://forums.alliedmods.net/showthread.php?t=65427

Lulu the hero 02-07-2011 12:40

Re: "Drawing" on the HUD
 
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.

bibu 02-07-2011 12:48

Re: "Drawing" on the HUD
 
Would like to see what you're doing, but:

Quote:

Error: Cannot read from file: "boolean" on line 4
:mrgreen:

DarkGod 02-07-2011 13:03

Re: "Drawing" on the HUD
 
Quote:

Originally Posted by bibu (Post 1409399)
Would like to see what you're doing, but:



:mrgreen:

http://forums.alliedmods.net/showthread.php?t=144645

Lulu the hero 02-07-2011 13:28

Re: "Drawing" on the HUD
 
Thank you!, forgot to add the file... :3

The plugin above on activation sets an external camera with fixed angles. I want to limit the player's rotation abilities, plus I want to remove the player model for the player.


All times are GMT -4. The time now is 10:19.

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