AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   movetype_follow offset (https://forums.alliedmods.net/showthread.php?t=319210)

CrazY. 10-19-2019 10:34

movetype_follow offset
 
I created an entity that follows the player. I want to add an offset so it stay above of player's head. According to the "movement follow" code, all I would need to do is add the offset to the entity's v_angle, but it's not working.

Code:

// Just copy angles and origin of parent
void SV_Physics_Follow(edict_t *ent)
{
        // regular thinking
        if (!SV_RunThink(ent))
                return;

        edict_t        *parent = ent->v.aiment;
        if (!ent->v.aiment)
        {
                Con_DPrintf("%s movetype FOLLOW with NULL aiment\n", &pr_strings[ent->v.classname]);
                ent->v.movetype = MOVETYPE_NONE;
                return;
        }

        VectorAdd(parent->v.origin, ent->v.v_angle, ent->v.origin);
        VectorCopy(parent->v.angles, ent->v.angles);

        SV_LinkEdict(ent, TRUE);
}

Here's my code

Code:
new g_voiceicon[MAX_PLAYERS+1]; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     RegisterHamPlayer(Ham_Spawn, "Player_Spawn_Post", 1); } public plugin_precache() {     precache_model("sprites/voiceicon.spr"); } public client_disconnected(id) {     if (is_valid_ent(g_voiceicon[id]))         remove_entity(g_voiceicon[id]); } public Player_Spawn_Post(id) {     if (!is_user_alive(id) || !(1 <= get_user_team(id) <= 2))         return;     if (is_valid_ent(g_voiceicon[id]))         return;     new ent = create_entity("env_sprite");     entity_set_model(ent, "sprites/voiceicon.spr");     entity_set_int(ent, EV_INT_renderfx, kRenderFxNoDissipation);     entity_set_int(ent, EV_INT_rendermode, kRenderTransAdd);     entity_set_float(ent, EV_FL_renderamt, 255.0);     set_pev(ent, pev_v_angle, Float:{75.0, 75.0, 75.0});     entity_set_int(ent, EV_INT_movetype, MOVETYPE_FOLLOW);     entity_set_edict(ent, EV_ENT_aiment, id);     //entity_set_float(ent, EV_FL_scale, 0.2);     g_voiceicon[id] = ent; }

Natsheh 10-19-2019 11:22

Re: movetype_follow offset
 
have you tried giving it a size?

CrazY. 10-20-2019 09:29

Re: movetype_follow offset
 
Yes, still not working.

Natsheh 10-20-2019 11:00

Re: movetype_follow offset
 
Then you need to change the movetype and achieve it through think

I'm not sure movetype_follow will work with sprites

Or try editing the sprite and give it height.

iNvectus 10-23-2019 02:44

Re: movetype_follow offset
 
It is not working, because you cannot change the Z origin of a movetype. You can spawn an info_target and set the model to the sprite, then set the origin to the origin +/- the difference with entity_set_model and entity_set_origin then set EV_INT_movetype to MOVETYPE_FOLLOW.

This way it will probably work, but if you just want to have a sprite above the player's head, instead I'd rather use TE_PLAYERATTACHMENT.

PHP Code:

write_byte(TE_PLAYERATTACHMENT)
write_byte(entity index of player)
write_coord(vertical offset) (attachment origin.player origin.vertical offset)
write_short(model index)
write_short(life 10 

https://www.amxmodx.org/api/message_const

CrazY. 10-23-2019 08:56

Re: movetype_follow offset
 
It doesn't work, I guess I've to do what natsheh said, give height to sprite.
That message would work but I need to scale the sprite, that's why I'm using entities.

iNvectus 10-24-2019 01:19

Re: movetype_follow offset
 
I guess this is what you are looking for https://forums.alliedmods.net/showthread.php?t=181306

Here it is done this way:

PHP Code:

public create_rank_entityindex )
{
    
gi_PlayerRankindex ] = engfunc EngFunc_CreateNamedEntityengfunc EngFunc_AllocString"env_sprite" ) )
    
    if( 
pev_validgi_PlayerRankindex ] ) )
    {
        
set_pevgi_PlayerRankindex ], pev_solidSOLID_NOT )
        
set_pevgi_PlayerRankindex ], pev_iuser2index )
        
set_pevgi_PlayerRankindex ], pev_iuser1pevgi_PlayerRankindex ], pev_owner ) )
        
set_pevgi_PlayerRankindex ], pev_scale0.5 )
        
engfuncEngFunc_SetModelgi_PlayerRankindex ], ranks_model )
        
set_pevgi_PlayerRankindex ], pev_renderfxkRenderTransAlpha )
        
set_pevgi_PlayerRankindex ], pev_renderamt0.0 )
        
set_pevgi_PlayerRankindex ], pev_frame0.0 )
    }



Natsheh 10-24-2019 10:15

Re: movetype_follow offset
 
@iNvectus please read carefully what he requested, in post #5 what have you said clearly doesn't make any sense in the thread.


All times are GMT -4. The time now is 02:40.

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