proc int random(int $max) { int $time = `currentTime -q`; seed $time; int $For_return = rand($max); return $For_return; } global proc addnextclip(string $Circle_char, int $loc, int $blend) { //ENUMERATIONS int $FLOCK = 0; int $FIND_TARGET = 1; int $ATTACK = 2; int $DEAD = 3; int $SQUARE_WIN = 8; int $CIRCLE_WIN = 9; int $NeedBlend = 0; //Gets CircleGuy#.grp string and string that corresponds to it. string $__temp1 = $Circle_char + ".grp"; string $Circle_Guy_GroupName = `getAttr $__temp1`; //Gets the current clip string $Circle_char_currentclipstring = $Circle_char + ".currentclip"; string $Circle_char_currentclip = `getAttr $Circle_char_currentclipstring`; //Gets Opponent Name string $Circle_char_opponent = $Circle_Guy_GroupName + ".Target"; //Gets the actual opponent name string $Square_Guy_GroupName = `getAttr $Circle_char_opponent`; //Gets opponent.char string $Square_Guy_char = $Square_Guy_GroupName + ".char"; //Gets the character that corresponds to the opponent string $Square_char = `getAttr $Square_Guy_char`; //Get the opponent character's current clip string $Square_char_currentclipstring = $Square_char + ".currentclip"; string $Square_char_currentclip = `getAttr $Square_char_currentclipstring`; string $Circle_status = $Circle_Guy_GroupName + ".ib"; string $Square_status = $Square_Guy_GroupName + ".ib"; int $dostuff = 0; int $addhold = 0; // 1 = square, 2 = circle; //int $num = 12; //7-9 square dies, 10-12 circle dies //int $rand = random($num); string $Circle_new_ani; string $Square_new_ani; string $ani_len; string $Circle_ani; string $Square_ani; int $rand = random(9); if($rand > 7) { $rand = 6; } int $storerand = $rand; if($rand < 6) { $Circle_ani = "Circle" + $rand; $Square_ani = "Square" + $rand; } if (($rand == 6)) {//square dies $rand = random(3); //Only 3 attacks; not 6 setAttr $Circle_status $CIRCLE_WIN; setAttr $Square_status $DEAD; $Circle_ani = "Circle" + $rand; $Square_ani = "Square" + 6; print($rand); } if (($rand == 7)) {//circle dies $rand = random(3); $rand += 3; //Ensures that the square guy does an attack instead of a dodge setAttr $Circle_status $SQUARE_WIN; $addhold = 1; //setAttr $Circle_status 3; //setAttr $Square_status 0; $Circle_ani = "Circle" + 6; $Square_ani = "Square" + $rand; } //This block of code actually sets the chosen clip if ($Circle_char_currentclip!=0) { $NeedBlend = 1; $loc-=$blend; } clip -copy $Circle_ani; string $new_clip[] = `clip -pasteInstance -aa -sc 1 -startTime $loc -mapMethod byAttrName $Circle_char`; $Circle_new_ani = $new_clip[0]; string $clip_len = $new_clip[0] + ".sourceEnd"; int $frame = `getAttr $clip_len`; $ani_len = $Circle_char + ".clipdone"; int $ani_length = `getAttr $ani_len`; setAttr $ani_len ($ani_length + $frame); string $__temp1 = $Circle_char + ".grp"; string $Circle_Guy_GroupName = `getAttr $__temp1`; clip -copy $Square_ani; string $new_clip1[] = `clip -pasteInstance -aa -sc 1 -startTime $loc -mapMethod byAttrName $Square_char`; $Square_new_ani = $new_clip1[0]; string $Circle_char_updateclip = $Circle_char + ".currentclip"; setAttr $Circle_char_updateclip -typ "string" $Circle_new_ani; string $Square_char_updateclip = $Square_char + ".currentclip"; setAttr $Square_char_updateclip -typ "string" $Square_new_ani; if ($NeedBlend == 1) { setAttr $ani_len (`getAttr $ani_len` - $blend); select -d; select -add $Circle_char_currentclip $Circle_new_ani; doBlendClip( "clipEditorPanel1ClipEditor", 1, 3); select -d; select -add $Square_char_currentclip $Square_new_ani; doBlendClip( "clipEditorPanel1ClipEditor", 1, 3); } //keep walking if ($storerand == 6) { clip -copy "CircleWalk"; int $place = $loc + `getAttr ($Circle_new_ani + ".sourceEnd")` - $blend; string $walk_clip[] = `clip -pasteInstance -aa -sc 1 -startTime $place -mapMethod byAttrName $Circle_char`; setAttr ($walk_clip[0] + ".postCycle") 100; setAttr $Circle_char_updateclip -typ "string" ($walk_clip[0]); select -d; select -add $walk_clip[0] $Circle_new_ani; doBlendClip( "clipEditorPanel1ClipEditor", 1, 3); } if ($storerand == 7) { clip -copy "SquareWalk"; int $place = $loc + `getAttr ($Square_new_ani + ".sourceEnd")` - $blend; string $walk_clip[] = `clip -pasteInstance -aa -sc 1 -startTime $place -mapMethod byAttrName $Square_char`; setAttr ($walk_clip[0] + ".postCycle") 100; setAttr $Square_char_updateclip -typ "string" ($walk_clip[0]); select -d; select -add $walk_clip[0] $Square_new_ani; doBlendClip( "clipEditorPanel1ClipEditor", 1, 3); } }