Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Freezing an Avatar, Animating, Taking Away Controls

Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
09-16-2008 12:04
help!

okay, i'm scripting a game... its a greased pig game. when the player hits the pig, he has a chance of missing, and something disasterous/hilarious happening. such as being kicked up in the air and falling down into the mud. i want it to be kinda like falling in sl, where you cant move for 2 seconds while the 'pick yourself up' animation plays.

okay, so...

i pick some flavor text (text), an animation to play that is in the pig (anim), how much push to push (push), and how long to freeze the avatar (time).
forget push for a second, cuz its working on me, and i know all about push vs no push land and the owner and yadda yadda.

the animations are not playing, and the controls are not freezing. keep in mind, that this is for tinies, so they have a robust ao going on as well.


when a capture attempt is failed, this routine happens:

MissPiggy()
{
llSay(0, text);
if(time > 0)
{
llTakeControls(controls, 0, 0);
//--this is dead, i think, except other controls
llSetTimerEvent(time*3);
}
if(anim != "")
llStartAnimation(anim); //--this should go on who it has perms for
if(push >1)
llPushObject(player, <0.0, 0.0, push*2>, ZERO_VECTOR, FALSE);


PickMiss(); //--this is the routine picking another miss scenario.

}


now according to the wiki, this take controls 0, 0 should capture all the controls and not let them affect the avatar. ie: freeze them in place. if i'm running while this goes on, i seem to still keep running. so, not good.
(controls, by the way, are all the keyboard control arrows, etc.)

the anim sometimes plays, but usually not. i suspect the ao is taking over and playing the running animation -- which it shouldnt, because i froze its controls, and the avatar should be immobile.


the timer event releases -- or rater, just returns to passing controls

timer()
{
llSetTimerEvent(0.0);
llTakeControls(controls, 0, 1);
//--should pass all controls with no intercepts
//--or should it just release controls!?
}

this seems to be fine, though i dont know the difference between this and releasing controls. i suspect that since i want to capture the controls a lot, i shouldnt release them in between. maybe that's an erroneous thought.

also... could it be that the control forward being held down slips past the take controls? it just stays down to move me? that is not good.


should i freeze the avatar in another manner? ie: by sticking them to the ground? might work better. :/




is there anything flaky with freezing controls
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
09-16-2008 12:40
(Controls, FALSE, FALSE) would allow the listed controls to work normally.
(Controls, TRUE, FALSE) would freeze the player in place. Or not listing movement keys in controls for FALSE, FALSE.

Took me awhile to figure that one out while making a "Stun" function myself...

EDIT: llTakeControls(CONTROL_LBUTTON, FALSE, FALSE); has always worked for me in testing, even if I'm running/walking when it's called, I stop moving.
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
09-17-2008 06:25
hey hey;

ah, okay.... take l-mouse false false works... although i really wanted them to be able to turn in place while frozen.

okay so

controls, false, false means.... freeze everything BUT controls.

controls, true, false means... freeze ONLY controls?

gawd, so what is the code for making them work normally again? or should i just release controls at that point? :/

controls, false, true, right? that's what im using, THAT seems to work.



GAH! now i stopped the script in the middle and i cant move! lol!


MEANWHILE...
controls are going good. animations still not playing very reliably. i guess i will try taking off other animations while doing mine. which will also probably be messy.


thanks faust!
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
09-17-2008 07:03
If the game doesn't need Controls for anything else, then yes just Release them. If it does just call the ones you need, TRUE, TRUE as it automatically releases the old control paramaters.

If you want them able to turn while held, just use (CONTROL_ROT_RIGHT | CONTROL_ROT LEFT, FALSE, FALSE) as listed controls behave normally under FALSE, FALSE.

And NP. The animations thing usually is AO interference.