Raised This Month: $ Target: $400
 0% 

[HELP] Beam Follow


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 01-16-2016 , 18:30   [HELP] Beam Follow
Reply With Quote #1

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() 
__________________

Last edited by Depresie; 01-16-2016 at 18:30.
Depresie is offline
Old 01-16-2016, 22:43
Chihuahuax
This message has been deleted by Chihuahuax.
addicted2sex
Senior Member
Join Date: May 2009
Location: localhost
Old 01-17-2016 , 04:48   Re: [HELP] Beam Follow
Reply With Quote #2

Quote:
Originally Posted by Depresie View Post
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
__________________
Let 7he gr0ovE r3Lease y0ur m!nd
addicted2sex is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 01-17-2016 , 06:34   Re: [HELP] Beam Follow
Reply With Quote #3

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
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
Depresie
Veteran Member
Join Date: Nov 2013
Old 01-17-2016 , 08:32   Re: [HELP] Beam Follow
Reply With Quote #4

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?
__________________
Depresie is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 01-18-2016 , 16:35   Re: [HELP] Beam Follow
Reply With Quote #5

check the trails plugin: https://forums.alliedmods.net/showth...64803?p=164803
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
addicted2sex
Senior Member
Join Date: May 2009
Location: localhost
Old 01-19-2016 , 17:46   Re: [HELP] Beam Follow
Reply With Quote #6

Quote:
Originally Posted by Depresie View Post
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).
__________________
Let 7he gr0ovE r3Lease y0ur m!nd
addicted2sex is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 01-20-2016 , 07:12   Re: [HELP] Beam Follow
Reply With Quote #7

Quote:
Originally Posted by addicted2sex View Post
The beam is a temp entity - I think you cannot kill it.
yes u can.
Quote:
Originally Posted by georgik57 View Post
Quote:
Originally Posted by addicted2sex View Post
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.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Reply



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 09:33.


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