AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved FL_ONGROUND counts standing on entity (https://forums.alliedmods.net/showthread.php?t=298906)

TBagT 06-26-2017 03:56

FL_ONGROUND counts standing on entity
 
Hello,

So FL_ONGROUND counts as standing on entity ? Is there a work around or check if player is standing on entity or on map ground ? I tried xPaws code:
PHP Code:

if( ( pevidpev_flags ) & FL_ONGROUND ) && pevidpev_groundentity ) == ent ) {
// player is on entity


But then touching the ground of the map is being also disabled. Or it would be better to somehow check if player touched an entity which is in front of him because what I am trying to do is to play a sprite when player touches anything but the ground, the problem is that if the player is standing on some specific entities on map the sprite plays immediately.

PHP Code:

public fw_touchidvictim ) {
        if( !
g_playerid][ ability_in_use ] )
                return;

        static 
sz_classname32 ];
        
entity_get_stringvictimEV_SZ_classnamesz_classnamecharsmaxsz_classname ) );

        
// effects of hitting //
        
static Floatstop_origin];
        
entity_get_vectoridEV_VEC_originstop_origin );

        
message_beginMSG_BROADCASTSVC_TEMPENTITY );
        
write_byteTE_BEAMCYLINDER );
        
engfuncEngFunc_WriteCoordstop_origin] );
        
engfuncEngFunc_WriteCoordstop_origin] );
        
engfuncEngFunc_WriteCoordstop_origin] );
        
engfuncEngFunc_WriteCoordstop_origin] );
        
engfuncEngFunc_WriteCoordstop_origin] );
        
engfuncEngFunc_WriteCoordstop_origin] + get_pcvar_floatg_cvarsRADIUS ] ) * );
        
write_shortexplosion_spr );
        
write_byte);
        
write_byte);
        
write_byte);
        
write_byte20 );
        
write_byte);
        
write_byte211 );
        
write_byte197 );
        
write_byte180 );
        
write_byte150 );
        
write_byte);
        
message_end( );

        
// End run //
        
emit_soundidCHAN_STREAMg_hit1.0ATTN_NORM0PITCH_NORM );
        
fw_sprint_endid TASK_SPRINT );



Natsheh 06-26-2017 04:05

Re: FL_ONGROUND counts standing on entity
 
Worldspawn is. Also the ground entity its id is 0

TBagT 06-26-2017 04:21

Re: FL_ONGROUND counts standing on entity
 
Quote:

Originally Posted by Natsheh (Post 2531763)
Worldspawn is. Also the ground entity its id is 0

Thanks
PHP Code:

if( equalsz_classname"worldspawn" ) ) { ... } 

worked

Edit: another problem if player hits a slope or falls down it also activates :D any work around ? I am thinking of making an entity in the middle of the player and check whenever it touches something maybe it'll work ?

Natsheh 06-26-2017 05:41

Re: FL_ONGROUND counts standing on entity
 
I didnt get you explain more...

What are you trying to achieve..

TBagT 06-26-2017 05:52

Re: FL_ONGROUND counts standing on entity
 
Okay so if the player touches worldspawn entity while sprinting, it stops the sprinting and creates a sprite, everything works fine but if player falls on ground, touches a small slope on ground or stairs like in de_dust2 it it counts as touching, any work around for this ?

Sprite code:
PHP Code:

if( equalsz_classname"worldspawn" ) && ( flags FL_ONGROUND ) ) {
        
// effects of hitting //
        
static Floatstop_origin];
        
entity_get_vectoridEV_VEC_originstop_origin );

        
message_beginMSG_BROADCASTSVC_TEMPENTITY );
        
write_byteTE_BEAMCYLINDER );
        
engfuncEngFunc_WriteCoordstop_origin] );
        
engfuncEngFunc_WriteCoordstop_origin] );
        
engfuncEngFunc_WriteCoordstop_origin] );
        
engfuncEngFunc_WriteCoordstop_origin] );
        
engfuncEngFunc_WriteCoordstop_origin] );
        
engfuncEngFunc_WriteCoordstop_origin] + get_pcvar_floatg_cvarsRADIUS ] ) * );
        
write_shortexplosion_spr );
        
write_byte);
        
write_byte);
        
write_byte);
        
write_byte20 );
        
write_byte);
        
write_byte211 );
        
write_byte197 );
        
write_byte180 );
        
write_byte150 );
        
write_byte);
        
message_end( );

        
// End run //
        
emit_soundidCHAN_BODYg_hit1.0ATTN_NORM0PITCH_NORM );
        
fw_charger_sprint_endid TASK_SPRINT );

        
client_printidprint_center"Ent touched: %s || %d"sz_classnamevictim );



Natsheh 06-26-2017 06:04

Re: FL_ONGROUND counts standing on entity
 
You have to check the player velocity might not be hooking the touch fwd is the best choice

TBagT 06-26-2017 09:20

Re: FL_ONGROUND counts standing on entity
 
Thanks got it to work somehow with get_user_velocity( id, ... ); vector_length( ... ); :).
Another question is it possible to keep another player in front of another player by some units ? Like charger from l4d for example. Right now I used velocity but if one player gets stuck while the carried player moves forward.
PHP Code:

                        if( ( flags & ( FL_ONGROUND FL_PARTIALGROUND FL_INWATER FL_CONVEYOR FL_FLOAT ) ) ) {
                                new 
lookOrigin], FloatlookOriginF], FloatsprVel];
                                
get_user_originidlookOrigin);

                                
lookOriginF] = floatlookOrigin] );
                                
lookOriginF] = floatlookOrigin] );
                                
lookOriginF] = floatlookOrigin] );

                                
get_velocity_to_originidlookOriginFget_pcvar_floatg_cvarsSPRINT_SPEED ] ), sprVel );

                                
sprVel] = 0.0;
                                
set_pevidpev_velocitysprVel );

                                if( 
g_playerid ][ grabbed_victim ] )
                                        
set_pevg_playerid ][ grabbed_victim ], pev_velocitysprVel );

                                
g_playerid ][ startedSprinting ] = true;
                        } 


Natsheh 06-26-2017 09:28

Re: FL_ONGROUND counts standing on entity
 
Check entities distances if they are far move 1 to the other

Craxor 06-26-2017 09:30

Re: FL_ONGROUND counts standing on entity
 
PHP Code:

    new lookOrigin], FloatlookOriginF], FloatsprVel];
                                
get_user_originidlookOrigin);

                                
lookOriginF] = floatlookOrigin] );
                                
lookOriginF] = floatlookOrigin] );
                                
lookOriginF] = floatlookOrigin] ); 

Also if you use fakemeta, replace get_user_origin() with pev( Entity, pev_origin ... ) and you can remove float().


All times are GMT -4. The time now is 23:07.

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