Jump to content
You are about to reply to a thread that has been inactive for 3122 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Posted

Next question, and perhaps more difficult...

My weapon script only needs to do something if I'm in mouselook, and then needs to monitor all the arrow keys, Pg-Down and Left Mouse. I have two options:

1. Have llTakeControls active all the time monitoring all the controls (with pass on), and test if we are in mouselook as soon as the script enters the event handler. That's a lot of movement control inputs generating events that might not be relevent most of the time. Is that an issue?

2. Poll llGetAgentInfo for mouselook at a fast rate (0.1s for instance) and turn on/off the active llTakeControls accordingly. I don't think that polling at that rate is a lag problem in itself, but I'm not sure if it can reliably* react quickly enough to go into taking control events when I suddenly go into mouselook and attack.

Given that deciding on the above might take a lot of in-world testing to get a convincing answer, I'm hoping someone has already determined it. Obviously I need to cause as little lag as possible, but the script also needs to be very responsive and reliable* or it's pointless.

*at leat as reliable as anything can be in SL scripting ;)

 

Posted

i would recommend option 1

Nothing is happening when the avatar is motionless. So the script doesnt need the server runtime engine to do anything in this state

basically let the server do the polling where possible

eta: i just suggest a way

 

integer gMouseview = TRUE or FALSE// we only need to test for avatar state on keydown and keyup (edge)if (edge) gMouseview = function mouseviewstate();

 

eta more: i simplify the exampe pcode

Posted

Thanks for that. I'm still concerned about the continual firing of the event when I'm moving which, if I have the weapon out, I'm likely to be doing a lot. If only the event only fired on a change of key state, instead of continually all the time a key is held.

A quick test shows that the event is fired a bit over 30 times per second when a key is held down. That, versus my ten times per second poll with a call to llGetAgentInfo. Hmm...

After a good night's sleep, at least I realised that all I need to check for at the start of the event is CONTROL_ML_LBUTTON. All the attacks use that in combination with another key. Since that can only occur in mouselook, I don't even have to call llGetAgentInfo so there's only one simple test to do (and fail) in the handler if I'm not actually attacking.

 

I'm going to try it the first way (not polling) and see how it works out. Might have to do some execution time tests when things are more finished.

 

Posted

most weapons use the control event to track things like ammo depletion and stuff like that. Like you say when we only intercept what we do need to know then is not a biggie

as you notice, can unload a 30 bullet mag with a semi-automatic in a fraction over 1 second, if a person could ever click that fast

You are about to reply to a thread that has been inactive for 3122 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...