Last active
September 25, 2023 20:57
-
-
Save FelixWolf/8b9f61f5f52b19fc2c4f79a8f6ddb027 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#name|anthro|feral|flags|pos|rot | |
Walk Right|stand|wolf_stance1|8|<-0.25,-0.65,0> | |
Walk Left|stand|wolf_stance1|8|<-0.25,0.65,0> | |
Sit|stand|wolf_sit,wolf_head_1|0|<0,0,0>|<0,0,0,0> | |
Lap|sitting_pet|wolf_lay6|0|<-0.081803, 0.226859, -0.460814>|<0.000000, 0.000000, -0.707107, 0.707107> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
integer nextBlink; | |
integer clearEarFlick=1; | |
integer reloadDeforms; | |
integer isTalking; | |
integer jawPose; | |
integer chan; | |
key owner; | |
integer getChatChannel(key a, key b){ | |
return (llHash(a) ^ llHash(b)) | 0x80000000; | |
} | |
/******************************************************************************/ | |
//Animations | |
stopAllAnimations(){ | |
list anims = llGetObjectAnimationNames(); | |
integer i; | |
integer l = llGetListLength(anims); | |
for(;i<l;i++) | |
llStopObjectAnimation(llList2String(anims, i)); | |
} | |
//Deformer | |
restartDeformer(){ | |
llStopObjectAnimation("wolf_joint_deforms"); | |
llSleep(0.01); | |
llStartObjectAnimation("wolf_joint_deforms"); | |
} | |
//Tail | |
string currentTailAnim = "relax"; | |
setTailAnim(string name){ | |
llStopObjectAnimation("wolf_tail_"+currentTailAnim); | |
llStartObjectAnimation("wolf_tail_"+(currentTailAnim=name)); | |
} | |
//Main Anim | |
list currentMainAnim = ["wolf_stance1"]; | |
setMainAnim(list name){ | |
integer i = 0; | |
integer l = llGetListLength(currentMainAnim); | |
for(;i<l;i++) | |
llStopObjectAnimation(llList2String(currentMainAnim,i)); | |
i = 0; | |
l = llGetListLength(name); | |
for(;i<l;i++) | |
llStartObjectAnimation(llList2String(name, i)); | |
currentMainAnim = name; | |
} | |
//Anthro Anim | |
list currentAnthroAnim = ["stand"]; | |
setAnthroAnim(list name){ | |
if((llGetPermissions()&PERMISSION_TRIGGER_ANIMATION)==0){ | |
llOwnerSay("NO PERMS!"); | |
return; | |
} | |
integer i = 0; | |
integer l = llGetListLength(currentAnthroAnim); | |
for(;i<l;i++) | |
llStopAnimation(llList2String(currentAnthroAnim,i)); | |
i = 0; | |
l = llGetListLength(name); | |
for(;i<l;i++) | |
llStartAnimation(llList2String(name, i)); | |
currentAnthroAnim = name; | |
} | |
/******************************************************************************/ | |
integer walkState = -1; | |
integer controls; | |
updateWalkAnim(){ | |
integer agentFlags = llGetAgentInfo(owner); | |
if(agentFlags & AGENT_WALKING){ | |
if(agentFlags & AGENT_CROUCHING){ | |
if(walkState != 5){ | |
setMainAnim(["wolf_crawl"]); | |
walkState = 5; | |
} | |
}else if(agentFlags & AGENT_ALWAYS_RUN){ | |
if(walkState != 2){ | |
setMainAnim(["wolf_run"]); | |
walkState = 2; | |
} | |
}else if(walkState != 1){ | |
setMainAnim(["wolf_walk"]); | |
walkState = 1; | |
} | |
}else if(controls & CONTROL_ROT_LEFT){ | |
if(walkState != 3){ | |
setMainAnim(["wolf_walk_base", "wolf_turnL"]); | |
walkState = 3; | |
} | |
}else if(controls & CONTROL_ROT_RIGHT){ | |
if(walkState != 4){ | |
setMainAnim(["wolf_walk_base", "wolf_turnR"]); | |
walkState = 4; | |
} | |
}else if(agentFlags & AGENT_CROUCHING){ | |
if(walkState != 6){ | |
setMainAnim(["wolf_crouch"]); | |
walkState = 6; | |
} | |
}else{ | |
if((agentFlags & AGENT_WALKING) == 0){ | |
if(walkState != 0){ | |
setMainAnim(["stand", "wolf_base", "wolf_head_3", "wolf_stance1"]); | |
walkState = 0; | |
} | |
} | |
} | |
if(llFrand(1) < 0.1){ | |
llStartObjectAnimation(llList2String([ | |
"wolf_fidget", | |
"wolf_shake", | |
"wolf_sniff", | |
"wolf_stretch", | |
"wolf_survey", | |
"wolf_surveyR" | |
], llRound(llFrand(5)))); | |
} | |
} | |
/******************************************************************************/ | |
vector setPos; | |
key ncReader; | |
integer ncLine; | |
integer animStride = 6; | |
list animations = []; | |
integer animCount = 0; | |
loadNC(){ | |
animations = []; | |
animCount = 0; | |
ncReader = llGetNotecardLine("!anims", ncLine = 0); | |
} | |
/******************************************************************************/ | |
integer currentFlags; | |
setFlags(integer flags){ | |
currentFlags = flags; | |
} | |
integer page = 0; | |
dialog(){ | |
list tmp = llList2ListStrided(animations, 0, -1, animStride); | |
if(page>(animCount/9))page=0; | |
else if(page < 0)page=(animCount/9); | |
llDialog(llGetOwner(), | |
"Anim: "+currentAnimName | |
+"\nAnthro: "+llList2CSV(currentAnthroAnim) | |
+"\nFeral: "+llList2CSV(currentMainAnim) | |
+"\nPos: "+(string)llGetLocalPos() | |
+"\nRot: "+(string)llGetLocalRot() | |
+"\nPage: "+(string)(page+1)+"/"+(string)((animCount/9)+1) | |
+"\nChan: "+(string)chan | |
+"\nMemory: "+(string)llGetUsedMemory(), | |
["< Prev", "Dump Info", "Next >"] + llList2List(tmp, page*9, (page*9)+8), chan); | |
} | |
string currentAnimName; | |
handleDialog(string m){ | |
if(m == "Dump Info"){ | |
llOwnerSay(llDumpList2String([currentAnimName, llList2CSV(currentAnthroAnim), llList2CSV(currentMainAnim), 0, llGetLocalPos(), llGetLocalRot()],"|")); | |
}else{ | |
integer index = llListFindList(llList2ListStrided(animations, 0, -1, animStride), [m]); | |
if(index == -1){ | |
llOwnerSay("Couldn't find anim: "+m); | |
}else{ | |
index = index * animStride; | |
currentAnimName = m; | |
setAnthroAnim(llCSV2List(llList2String(animations, index+1))); | |
setMainAnim(llCSV2List(llList2String(animations, index+2))); | |
setFlags(llList2Integer(animations, index+3)); | |
llSetLinkPrimitiveParamsFast(LINK_ROOT, [ | |
PRIM_POSITION, llList2Vector(animations, index+4), | |
PRIM_ROTATION, llList2Rot(animations, index+5) | |
]); | |
} | |
} | |
} | |
default{ | |
attach(key id){ | |
if(id) | |
llResetScript(); | |
} | |
state_entry(){ | |
if(llGetAttached()) | |
llRequestPermissions(owner=llGetOwner(), PERMISSION_TRIGGER_ANIMATION|PERMISSION_TAKE_CONTROLS); | |
stopAllAnimations(); | |
restartDeformer(); | |
setTailAnim(currentTailAnim); | |
setMainAnim(currentMainAnim); | |
llSetTimerEvent(0.5); | |
loadNC(); | |
chan = getChatChannel(owner, llGetKey()); | |
llListen(1,"","",""); | |
llListen(chan, "", "", ""); | |
} | |
run_time_permissions(integer p){ | |
if(p){ | |
llTakeControls(0xFFFFFFFF, TRUE, TRUE); | |
} | |
} | |
touch_start(integer dt){ | |
if(llDetectedKey(0) == owner){ | |
page = 0; | |
dialog(); | |
} | |
} | |
changed(integer c){ | |
if(c&CHANGED_INVENTORY){ | |
if(ncReader != llGetInventoryKey("!anims")){ | |
loadNC(); | |
} | |
} | |
} | |
dataserver(key req, string data){ | |
if(req == ncReader){ | |
if(data == EOF){ | |
ncReader = llGetInventoryKey("!anims"); | |
animCount = llCeil(llGetListLength(animations)/animStride); | |
llOwnerSay("Loaded "+(string)animCount+" animations!"); | |
handleDialog(llList2String(animations, 0)); | |
}else{ | |
if(llGetSubString(data,0,0) != "#"){ | |
list d = llParseStringKeepNulls(data, ["|"], []); | |
animations += [ | |
llList2String(d, 0), | |
llList2String(d, 1), | |
llList2String(d, 2), | |
(integer)llList2String(d, 3), | |
(vector)llList2String(d, 4), | |
(rotation)llList2String(d, 5) | |
]; | |
} | |
ncLine += 1; | |
ncReader = llGetNotecardLine("!anims", ncLine); | |
} | |
} | |
} | |
timer(){ | |
integer time = llGetUnixTime(); | |
if(time>nextBlink){ | |
llStartObjectAnimation("wolf_brow_blink"); | |
nextBlink = time + (integer)llFrand(5) + 5; | |
} | |
if(time>reloadDeforms){ | |
restartDeformer(); | |
reloadDeforms = time + 60; | |
} | |
if(99<llFrand(100)){ | |
if(0.5>llFrand(1)){ | |
llStartObjectAnimation("wolf_ear_flick_L"); | |
}else{ | |
llStartObjectAnimation("wolf_ear_flick_R"); | |
} | |
clearEarFlick = time + 1; | |
} | |
if(clearEarFlick&&time>clearEarFlick){ | |
clearEarFlick = 0; | |
llStopObjectAnimation("wolf_ear_flick_L"); | |
llStopObjectAnimation("wolf_ear_flick_R"); | |
llStartObjectAnimation("wolf_ear_relax_L"); | |
llStartObjectAnimation("wolf_ear_relax_R"); | |
llSleep(0.01); | |
llStopObjectAnimation("wolf_ear_relax_L"); | |
llStopObjectAnimation("wolf_ear_relax_R"); | |
} | |
if(currentFlags&8){ | |
updateWalkAnim(); | |
} | |
} | |
listen(integer i, string n, key k, string m){ | |
if(llGetOwnerKey(k) != llGetOwner()) | |
return; | |
if(i == 1){ | |
if(llGetSubString(m, 0,4) != "anim ") | |
return; | |
list d = llParseStringKeepNulls(m, ["|"], []); | |
currentAnimName = llList2String(d,0); | |
setAnthroAnim(llCSV2List(llList2String(d,1))); | |
setMainAnim(llCSV2List(llList2String(d,2))); | |
setFlags((integer)llList2String(d,3)); | |
llSetLinkPrimitiveParamsFast(LINK_ROOT, [ | |
PRIM_POSITION, (vector)llList2String(d,4), | |
PRIM_ROTATION, (rotation)llList2String(d,5) | |
]); | |
return; | |
}else if(i == chan){ | |
if(m == "< Prev") | |
page--; | |
else if(m == "Next >") | |
page++; | |
else | |
handleDialog(m); | |
dialog(); | |
} | |
} | |
control(key id, integer level, integer edge){ | |
controls = level & ~edge; | |
if(currentFlags&8){ | |
updateWalkAnim(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment