AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Beam Follow (https://forums.alliedmods.net/showthread.php?t=277792)

Depresie 01-16-2016 18:30

[HELP] Beam Follow
 
I have a message in a think function which is creating a trail when the player holds certain buttons, but the problem is sometimes there are drawn too many sprites at the same time, resulting in low fps

Is there any way I can limit the number of sprites drawn at once per player excluding reducing their life to 1? I want to create a flame like trail :)

PHP Code:

        entity_get_vector(entEV_VEC_originOrigin)
        
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYOrigin0)
        
write_byte(TE_BEAMFOLLOW)
        
write_short(id)
        
write_short(SprSmoke)
        
write_byte(1)
        
write_byte(7)
        
write_byte(128)
        
write_byte(32)
        
write_byte(8)
        
write_byte(192)
        
message_end() 


addicted2sex 01-17-2016 04:48

Re: [HELP] Beam Follow
 
Quote:

Originally Posted by Depresie (Post 2383874)
I have a message in a think function which is creating a trail when the player holds certain buttons, but the problem is sometimes there are drawn too many sprites at the same time, resulting in low fps

Is there any way I can limit the number of sprites drawn at once per player excluding reducing their life to 1? I want to create a flame like trail :)

PHP Code:

        entity_get_vector(entEV_VEC_originOrigin)
        
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYOrigin0)
        
write_byte(TE_BEAMFOLLOW)
        
write_short(id)
        
write_short(SprSmoke)
        
write_byte(1)
        
write_byte(7)
        
write_byte(128)
        
write_byte(32)
        
write_byte(8)
        
write_byte(192)
        
message_end() 


1. Move the code into a separate timer and kill it when the player stops holding that button.
or
2. Something like this

PHP Code:

new BeamCounter[MAXPLAYERS+1];
BeamCounter++;
if (
BeamCounter >= 100) {
//Send message with the trail creation
BeamCounter 0;


The idea is to sent the trail creation every 100 thinks (or more) but thats player dependable. The Pre/PostThink is fps/StartCmd dependant so one player can make ~100 thinks per second (if he's running on 100fps) or 200-300 (with developer 1).

3. (And probably the best one) Using get_gametime() and creating the trail every 0.1/0.2s

Chihuahuax 01-17-2016 06:34

Re: [HELP] Beam Follow
 
Using a boolean would be much more efficient

Set the bool to true when "certain button" is pressed
And to false when the button is released

Depresie 01-17-2016 08:32

Re: [HELP] Beam Follow
 
the problem is not when he is not holding the button, be when he is holding it for a little bit longer, it will spam too many sprties...

About the beam counter, I was thinking for it, but I have no idea yet when or how to decrease it, since the life of the sprites I don't think it is in seconds..

Btw how do you kill the beam exactly?

georgik57 01-18-2016 16:35

Re: [HELP] Beam Follow
 
check the trails plugin: https://forums.alliedmods.net/showth...64803?p=164803

addicted2sex 01-19-2016 17:46

Re: [HELP] Beam Follow
 
Quote:

Originally Posted by Depresie (Post 2384028)
the problem is not when he is not holding the button, be when he is holding it for a little bit longer, it will spam too many sprties...

About the beam counter, I was thinking for it, but I have no idea yet when or how to decrease it, since the life of the sprites I don't think it is in seconds..

Btw how do you kill the beam exactly?

As I said the best way is to use get_gametime().
1. Send the beam for 0.4s (third WRITE_BYTE(4))
2. Set Float:NextBeam = get_gametime() + 0.3; //Dont make it 0.4 here as "clipping" effect may occur
3. if get_gametime() >= NextBeam -> Goto 1.

The beam is a temp entity - I think you cannot kill it. Its automatically killed from the engine. Read here

Have in mind that those "seconds" are engine seconds (since map start) and their tick can differ from real time seconds (just to know).

georgik57 01-20-2016 07:12

Re: [HELP] Beam Follow
 
Quote:

Originally Posted by addicted2sex (Post 2384706)
The beam is a temp entity - I think you cannot kill it.

yes u can.
Quote:

Originally Posted by georgik57 (Post 2384420)

Quote:

Originally Posted by addicted2sex (Post 2384706)
Have in mind that those "seconds" are engine seconds (since map start) and their tick can differ from real time seconds (just to know).

didn't know that. ty.


All times are GMT -4. The time now is 09:33.

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