Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help :)

Natalie Oe
Huh?
Join date: 3 Oct 2005
Posts: 679
08-24-2007 20:22
Hi

I created a hug and kiss AO using a script created by francis chung.

I am using my own custom animations, the problem is this, the 2 avatars do not get close enough to each other.

This is the script

// Francis was here

// Constants
integer sensorDistance = 10;
list hug_cmd = [ "hug", "/hug" ];
integer linkChannel = 598242;
string linkStringRequest = "HUG_TARGET_=^..^=REQUEST";
string linkStringStart = "HUG_TARGET_=^..^=START";
string linkStringAnim = "HUG_TARGET_=^..^=ANIM";
string linkStringReset = "HUG_TARGET_=^..^=RESET";
string animName = "hug";
integer animTime = 15;
vector posOffset1 = <0.3, 0, 0>;
vector posOffset2 = <0, 0, 0>;

// Not Constants
string avTarget = "";
vector avPos = ZERO_VECTOR;
key avKey = NULL_KEY;
rotation avRot = ZERO_ROTATION;
string avName = "";
integer avFindName = TRUE;

string checkMatch( string str, list prefixes ) {
integer numElements = llGetListLength( prefixes );
integer i;
integer lastChar;
string curPrefix;
string curStr = llToLower( str );

for( i=0; i<numElements; i++ ) {
curPrefix = llList2String(prefixes, i);
lastChar = llStringLength( curPrefix );
lastChar -= 1;
if ( llGetSubString(curStr, 0, lastChar) == curPrefix )
return curPrefix;
}
return "";
}

integer setAvTarget( string message, string match ) {
integer mesgLen = llStringLength( message );
integer matchLen = llStringLength( match );
if ( mesgLen <= matchLen + 1 ) {
avTarget = "";
return FALSE;
}
else {
mesgLen -= 1;
avTarget = llGetSubString( message, matchLen+1, mesgLen );
avTarget = llToLower( avTarget );
return TRUE;
}
}

usageMessage() {
llInstantMessage( llGetOwner(), "Usage: Face your target and Say '/hug [person's name]' or '/1hug [person's name]'" );
}

default
{
state_entry() {
if ( llGetAttached() )
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
usageMessage();
}

on_rez( integer startcode ) {
llResetScript();
}

attach( key k ) {
if ( k != NULL_KEY )
llResetScript();
}

run_time_permissions(integer parm) {
if( parm & PERMISSION_TRIGGER_ANIMATION ) {
llListen( 0, "", llGetOwner(), "" );
llListen( 1, "", llGetOwner(), "" );
}
}

sensor(integer total_number) {
if ( avFindName ) {
integer i;
for ( i = 0; i < total_number; i++ ) {
vector pos;
rotation rot;
if ( llSubStringIndex(llToLower(llDetectedName(i)), avTarget) >= 0
&& llDetectedKey(i) != llGetOwner() ) {
avName = llDetectedName(i);
llInstantMessage( llGetOwner(), "You have offered to hug " + avName + "." );
llMessageLinked( LINK_SET, linkChannel, linkStringRequest, llDetectedKey(i) );
avPos = llDetectedPos(i);
avRot = llDetectedRot(i);
avName = llList2String( llParseString2List( avName, [" "], [] ), 0 );
avKey = llDetectedKey(i);
return;
}
}
}
else {
vector pos;
vector size = llGetAgentSize( llGetOwner() );
float mass = size.x * size.y * size.z;

avPos = llDetectedPos(0);
avRot = llDetectedRot(0);

//mass = mass * 1000;
pos = avPos + posOffset1 * avRot;
llMoveToTarget( pos, .5 );
llSleep(.6);
pos = avPos + posOffset2 * avRot;
llMoveToTarget( pos, .5 );
llSleep(.6);
llMoveToTarget( pos, 1 );
//llLookAt( avPos, mass/2, mass/20 );
//llApplyRotationalImpulse( mass*<1,1,1>, FALSE );
//llSleep(3);
//llStopLookAt();
//return;

// Okay, first say a nice message
string origName = llGetObjectName();
string owner;
owner = llKey2Name( llGetOwner() );
owner = llList2String( llParseString2List( owner, [" "], [] ), 0 );
llSetObjectName( owner );
llSay( 0, "/me gives " + avName + " a big hug." );
llSetObjectName( origName );

// And then, do the anim
llMessageLinked( LINK_SET, linkChannel, linkStringAnim, NULL_KEY );
llStartAnimation( animName );
llSleep( animTime );
llStopAnimation( animName );
llStopMoveToTarget();
}
}

no_sensor() {
llInstantMessage( llGetOwner(), "Couldn't find hug target, '" + avTarget + "'" );
llMessageLinked( LINK_SET, linkChannel, linkStringReset, NULL_KEY );
}

link_message( integer sender, integer i, string s, key k ) {
if ( i == linkChannel && s == linkStringStart ) {
avFindName = FALSE;
llSensor( "", avKey, AGENT, sensorDistance, PI );
}
}

listen(integer channel,string name,key id,string message) {
string match;
match = checkMatch( message, hug_cmd );
if( match != "" ) {
if ( !setAvTarget( message, match ) )
usageMessage();
else {
avFindName = TRUE;
llSensor( "", NULL_KEY, AGENT, sensorDistance, PI );
}
}
}
}

I tried changing the 0.3 in the vector offset, I tried 0.4 and neither av moved, So i lowered it to 0.2 and it moved but still not close enough.

Any suggestions?

Thanks
_____________________
Seeking texture artists interested in commission based selling space. For more information please contact Natalie Oe in world
Darko Lednev
Registered User
Join date: 20 Aug 2007
Posts: 31
08-24-2007 21:08
Try setting the

vector posOffset1 = <0.3, 0, 0>;

to

vector posOffset1 = <-0.1, 0, 0>;
Natalie Oe
Huh?
Join date: 3 Oct 2005
Posts: 679
08-24-2007 21:14
From: Darko Lednev
Try setting the

vector posOffset1 = <0.3, 0, 0>;

to

vector posOffset1 = <-0.1, 0, 0>;


Thanks Darko, I'll give it a go.
_____________________
Seeking texture artists interested in commission based selling space. For more information please contact Natalie Oe in world
Natalie Oe
Huh?
Join date: 3 Oct 2005
Posts: 679
08-26-2007 15:47
From: Natalie Oe
Thanks Darko, I'll give it a go.


Ok that didn't work, It got me a little closer but still not close enough

Any other suggestions?
_____________________
Seeking texture artists interested in commission based selling space. For more information please contact Natalie Oe in world
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-26-2007 16:12
From: Natalie Oe
Ok that didn't work, It got me a little closer but still not close enough

Any other suggestions?


Think about it a minute now, if changing:

vector posOffset1 = <0.3, 0, 0>;

to

vector posOffset1 = <-0.1, 0, 0>;

moved the 2 avatars closer then increasing the negative number even more will move them even closer right?

Try:

vector posOffset1 = <-1.0, 0, 0>;

Notice the difference and keep playing with that one variable
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
Been there, failed to do that...
08-27-2007 10:14
I think the problem is that the AVs bump into one another, so they cannot get that close.

A couple of things you can try...

Once the two AVs are in position, apply a force to each toward the other.

Once they are in position, rez an invisible non-phantom cylinder around them, and then shrink the cylinder. Maybe instead of invisible, you could make it a golden cord, or something.

Rez a couple of hug pose balls instead of using a script.
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
btw
08-27-2007 10:16
The script uses two offsets. After moving to a point .3 m in fron of the other av, it sleeps for .6 seconds, and then tries to move to a point offset2 in front. That's the one you need to mess with.
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
08-27-2007 13:42
The hug script I wrote was never intended to be released open-source. Due to a permission flaw and some enterprising individuals, it has been rampantly pirated and redistributed.
_____________________
--
~If you lived here, you would be home by now~