Advertisement
SongJo

Untitled

Mar 16th, 2020
1,438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// @function skeletonHumanoidUpdate
  2. /// @param {instance} *instance
  3.  
  4. with ((argument_count > 0) ? argument[0] : id)
  5. {
  6.     var _angle              = floor(direction / 90) % 4,
  7.         _scale              ,//= skeleton[SkeletonHumanoid.SCALE],
  8.         _jointHead          = skeleton[SkeletonHumanoid.JOINT_HEAD],
  9.         _jointTorso         = skeleton[SkeletonHumanoid.JOINT_TORSO],
  10.         _jointShoulderLeft  = skeleton[SkeletonHumanoid.JOINT_SHOULDER_LEFT],
  11.         _jointShoulderRight = skeleton[SkeletonHumanoid.JOINT_SHOULDER_RIGHT],
  12.         _jointLegLeft       = skeleton[SkeletonHumanoid.JOINT_LEG_LEFT],
  13.         _jointLegRight      = skeleton[SkeletonHumanoid.JOINT_LEG_RIGHT],
  14.         _jointKneeLeft      = skeleton[SkeletonHumanoid.JOINT_KNEE_LEFT],
  15.         _jointKneeRight     = skeleton[SkeletonHumanoid.JOINT_KNEE_RIGHT],
  16.         _pointHolster1      = skeleton[SkeletonHumanoid.POINT_HOLSTER_1],
  17.         _pointHolster2      = skeleton[SkeletonHumanoid.POINT_HOLSTER_2],
  18.         _headPos            ,//= skeleton[SkeletonHumanoid.HEAD_POS],
  19.         _torsoPos           ,//= skeleton[SkeletonHumanoid.TORSO_POS],
  20.         _armLeftUpperPos    ,//= skeleton[SkeletonHumanoid.ARM_LEFT_UPPER_POS],
  21.         _armLeftLowerPos    ,//= skeleton[SkeletonHumanoid.ARM_LEFT_LOWER_POS],
  22.         _armRightUpperPos   ,//= skeleton[SkeletonHumanoid.ARM_RIGHT_UPPER_POS],
  23.         _armRightLowerPos   ,//= skeleton[SkeletonHumanoid.ARM_RIGHT_LOWER_POS],
  24.         _legLeftUpperPos    ,//= skeleton[SkeletonHumanoid.LEG_LEFT_UPPER_POS],
  25.         _legLeftLowerPos    ,//= skeleton[SkeletonHumanoid.LEG_LEFT_LOWER_POS],
  26.         _legRightUpperPos   ,//= skeleton[SkeletonHumanoid.LEG_RIGHT_UPPER_POS],
  27.         _legRightLowerPos   ,//= skeleton[SkeletonHumanoid.LEG_RIGHT_LOWER_POS],
  28.         _stepSize           = skeleton[SkeletonHumanoid.STEP_SIZE],
  29.         _armSwing           = skeleton[SkeletonHumanoid.ARM_SWING],
  30.         _armLength          = skeleton[SkeletonHumanoid.ARM_LENGTH],
  31.         _anim               = sin(moveTime * 15);
  32.    
  33.     var _armRot = [60, 120];
  34.    
  35.     switch (_angle)
  36.     {
  37.         case 0: // Right Up
  38.            
  39.             _scale = [1,1];
  40.            
  41.             _headPos          = [_jointHead[0] * _scale[0],_jointHead[1] * _scale[1]];
  42.             _torsoPos         = [_jointTorso[0] * _scale[0],_jointTorso[1] * _scale[1]];
  43.             _legLeftUpperPos  = [_jointLegLeft[0], _jointLegLeft[1] - _stepSize * max(_anim, 0)];
  44.             _legLeftLowerPos  = [_jointKneeLeft[0], _jointKneeLeft[1] - _stepSize * 2 * max(_anim, 0)];
  45.             _legRightUpperPos = [_jointLegRight[0], _jointLegRight[1] - _stepSize * max(-_anim, 0)];
  46.             _legRightLowerPos = [_jointKneeRight[0], _jointKneeRight[1] - _stepSize * 2 *  max(-_anim, 0)];
  47.            
  48.             if (holstered || (!holstered && is_undefined(weapon)))
  49.             {
  50.                 _armSwing = _armSwing * _scale[0] * _anim;
  51.                
  52.                 _armLeftUpperPos  = [_jointShoulderLeft[0] * _scale[0], _jointShoulderLeft[1] * _scale[1], _armSwing - 90];
  53.                 _armLeftLowerPos  = [_armLeftUpperPos[0] + lengthdir_x(_armLength, _armLeftUpperPos[2]),_armLeftUpperPos[1] + lengthdir_y(_armLength, _armLeftUpperPos[2]), _armLeftUpperPos[2]];
  54.                 _armRightUpperPos = [_jointShoulderRight[0] * _scale[0], _jointShoulderRight[1] * _scale[1], -_armSwing - 90];
  55.                 _armRightLowerPos = [_armRightUpperPos[0] + lengthdir_x(_armLength, _armRightUpperPos[2]),_armRightUpperPos[1] + lengthdir_y(_armLength, _armRightUpperPos[2]), _armRightUpperPos[2]];
  56.                
  57.                 handLeft[2]  = _armLeftLowerPos[2];
  58.                 handRight[2] = _armRightLowerPos[2];
  59.             }
  60.             else
  61.             {
  62.                 //var _armRot = [75.522, 180 - 28.955];
  63.                
  64.                 _armSwing = _armSwing * _scale[0] * _anim;
  65.                
  66.                 _armLeftUpperPos  = [_jointShoulderLeft[0] * _scale[0], _jointShoulderLeft[1] * _scale[1], _armSwing - 90];
  67.                 _armLeftLowerPos  = [_armLeftUpperPos[0] + lengthdir_x(_armLength, _armLeftUpperPos[2]),_armLeftUpperPos[1] + lengthdir_y(_armLength, _armLeftUpperPos[2]), _armLeftUpperPos[2]];
  68.                 _armRightUpperPos = [_jointShoulderRight[0] * _scale[0], _jointShoulderRight[1] * _scale[1], direction - _armRot[0]];
  69.                 _armRightLowerPos = [_armRightUpperPos[0] + lengthdir_x(_armLength, _armRightUpperPos[2]),_armRightUpperPos[1] + lengthdir_y(_armLength, _armRightUpperPos[2]), _armRightUpperPos[2] + _armRot[1]];
  70.                
  71.                 handLeft[2]  = _armLeftLowerPos[2];
  72.                 handRight[2] = direction;
  73.             }
  74.            
  75.             break;
  76.            
  77.         case 1: // Left Up
  78.            
  79.             _scale = [1,1];
  80.            
  81.             _headPos          = [_jointHead[0] * _scale[0],_jointHead[1] * _scale[1]];
  82.             _torsoPos         = [_jointTorso[0] * _scale[0],_jointTorso[1] * _scale[1]];
  83.             _legLeftUpperPos  = [_jointLegLeft[0], _jointLegLeft[1] - _stepSize * max(_anim, 0)];
  84.             _legLeftLowerPos  = [_jointKneeLeft[0], _jointKneeLeft[1] - _stepSize * 2 * max(_anim, 0)];
  85.             _legRightUpperPos = [_jointLegRight[0], _jointLegRight[1] - _stepSize * max(-_anim, 0)];
  86.             _legRightLowerPos = [_jointKneeRight[0], _jointKneeRight[1] - _stepSize * 2 *  max(-_anim, 0)];
  87.            
  88.             if (holstered || (!holstered && is_undefined(weapon)))
  89.             {
  90.                 _armSwing = _armSwing * _scale[0] * _anim;
  91.                
  92.                 _armLeftUpperPos  = [_jointShoulderLeft[0] * _scale[0], _jointShoulderLeft[1] * _scale[1], _armSwing - 90];
  93.                 _armLeftLowerPos  = [_armLeftUpperPos[0] + lengthdir_x(_armLength, _armLeftUpperPos[2]),_armLeftUpperPos[1] + lengthdir_y(_armLength, _armLeftUpperPos[2]), _armLeftUpperPos[2]];
  94.                 _armRightUpperPos = [_jointShoulderRight[0] * _scale[0], _jointShoulderRight[1] * _scale[1], -_armSwing - 90];
  95.                 _armRightLowerPos = [_armRightUpperPos[0] + lengthdir_x(_armLength, _armRightUpperPos[2]),_armRightUpperPos[1] + lengthdir_y(_armLength, _armRightUpperPos[2]), _armRightUpperPos[2]];
  96.                
  97.                 handLeft[2]  = _armLeftLowerPos[2];
  98.                 handRight[2] = _armRightLowerPos[2];
  99.             }
  100.             else
  101.             {
  102.                 //var _armRot = [75.522, 180 - 28.955];
  103.                
  104.                 _armSwing = _armSwing * _scale[0] * _anim;
  105.                
  106.                 _armLeftUpperPos  = [_jointShoulderLeft[0] * _scale[0], _jointShoulderLeft[1] * _scale[1], _armSwing - 90];
  107.                 _armLeftLowerPos  = [_armLeftUpperPos[0] + lengthdir_x(_armLength, _armLeftUpperPos[2]),_armLeftUpperPos[1] + lengthdir_y(_armLength, _armLeftUpperPos[2]), _armLeftUpperPos[2]];
  108.                 _armRightUpperPos = [_jointShoulderRight[0] * _scale[0], _jointShoulderRight[1] * _scale[1], direction + _armRot[0] + 25]; // << Temp
  109.                 _armRightLowerPos = [_armRightUpperPos[0] + lengthdir_x(_armLength, _armRightUpperPos[2]),_armRightUpperPos[1] + lengthdir_y(_armLength, _armRightUpperPos[2]), _armRightUpperPos[2] - _armRot[1]];
  110.                
  111.                 handLeft[2]  = _armLeftLowerPos[2];
  112.                 handRight[2] = direction;
  113.                
  114.                 handLeft[2]  = _armLeftLowerPos[2];
  115.                 handRight[2] = direction;
  116.             }
  117.            
  118.             break;
  119.            
  120.         case 2: // Left Down
  121.            
  122.             _scale = [-1,1];
  123.            
  124.             _headPos          = [_jointHead[0] * _scale[0],_jointHead[1] * _scale[1]];
  125.             _torsoPos         = [_jointTorso[0] * _scale[0],_jointTorso[1] * _scale[1]];
  126.             _legLeftUpperPos  = [_jointLegLeft[0], _jointLegLeft[1] - _stepSize * max(_anim, 0)];
  127.             _legLeftLowerPos  = [_jointKneeLeft[0], _jointKneeLeft[1] - _stepSize * 2 * max(_anim, 0)];
  128.             _legRightUpperPos = [_jointLegRight[0], _jointLegRight[1] - _stepSize * max(-_anim, 0)];
  129.             _legRightLowerPos = [_jointKneeRight[0], _jointKneeRight[1] - _stepSize * 2 *  max(-_anim, 0)];
  130.            
  131.             if (holstered || (!holstered && is_undefined(weapon)))
  132.             {
  133.                 _armSwing = _armSwing * _scale[0] * _anim;
  134.                
  135.                 _armLeftUpperPos  = [_jointShoulderLeft[0] * _scale[0], _jointShoulderLeft[1] * _scale[1], _armSwing - 90];
  136.                 _armLeftLowerPos  = [_armLeftUpperPos[0] + lengthdir_x(_armLength, _armLeftUpperPos[2]),_armLeftUpperPos[1] + lengthdir_y(_armLength, _armLeftUpperPos[2]), _armLeftUpperPos[2]];
  137.                 _armRightUpperPos = [_jointShoulderRight[0] * _scale[0], _jointShoulderRight[1] * _scale[1], -_armSwing - 90];
  138.                 _armRightLowerPos = [_armRightUpperPos[0] + lengthdir_x(_armLength, _armRightUpperPos[2]),_armRightUpperPos[1] + lengthdir_y(_armLength, _armRightUpperPos[2]), _armRightUpperPos[2]];
  139.                
  140.                 handLeft[2]  = _armLeftLowerPos[2];
  141.                 handRight[2] = _armRightLowerPos[2];
  142.             }
  143.             else
  144.             {
  145.                 //var _armRot = [75.522, 180 - 28.955];
  146.                
  147.                 _armSwing = _armSwing * _scale[0] * _anim;
  148.                
  149.                 _armLeftUpperPos  = [_jointShoulderLeft[0] * _scale[0], _jointShoulderLeft[1] * _scale[1], _armSwing - 90];
  150.                 _armLeftLowerPos  = [_armLeftUpperPos[0] + lengthdir_x(_armLength, _armLeftUpperPos[2]),_armLeftUpperPos[1] + lengthdir_y(_armLength, _armLeftUpperPos[2]), _armLeftUpperPos[2]];
  151.                 _armRightUpperPos = [_jointShoulderRight[0] * _scale[0], _jointShoulderRight[1] * _scale[1], direction + _armRot[0] + 27]; // << Temp
  152.                 _armRightLowerPos = [_armRightUpperPos[0] + lengthdir_x(_armLength, _armRightUpperPos[2]),_armRightUpperPos[1] + lengthdir_y(_armLength, _armRightUpperPos[2]), _armRightUpperPos[2] - _armRot[1]];
  153.                
  154.                 handLeft[2]  = _armLeftLowerPos[2];
  155.                 handRight[2] = direction;
  156.             }
  157.            
  158.             break;
  159.            
  160.         case 3: // Right Down
  161.            
  162.             _scale = [-1,1];
  163.            
  164.             _headPos          = [_jointHead[0] * _scale[0],_jointHead[1] * _scale[1]];
  165.             _torsoPos         = [_jointTorso[0] * _scale[0],_jointTorso[1] * _scale[1]];
  166.             _legLeftUpperPos  = [_jointLegLeft[0], _jointLegLeft[1] - _stepSize * max(_anim, 0)];
  167.             _legLeftLowerPos  = [_jointKneeLeft[0], _jointKneeLeft[1] - _stepSize * 2 * max(_anim, 0)];
  168.             _legRightUpperPos = [_jointLegRight[0], _jointLegRight[1] - _stepSize * max(-_anim, 0)];
  169.             _legRightLowerPos = [_jointKneeRight[0], _jointKneeRight[1] - _stepSize * 2 *  max(-_anim, 0)];
  170.            
  171.             if (holstered || (!holstered && is_undefined(weapon)))
  172.             {
  173.                 _armSwing = _armSwing * _scale[0] * _anim;
  174.                
  175.                 _armLeftUpperPos  = [_jointShoulderLeft[0] * _scale[0], _jointShoulderLeft[1] * _scale[1], _armSwing - 90];
  176.                 _armLeftLowerPos  = [_armLeftUpperPos[0] + lengthdir_x(_armLength, _armLeftUpperPos[2]),_armLeftUpperPos[1] + lengthdir_y(_armLength, _armLeftUpperPos[2]), _armLeftUpperPos[2]];
  177.                 _armRightUpperPos = [_jointShoulderRight[0] * _scale[0], _jointShoulderRight[1] * _scale[1], -_armSwing - 90];
  178.                 _armRightLowerPos = [_armRightUpperPos[0] + lengthdir_x(_armLength, _armRightUpperPos[2]),_armRightUpperPos[1] + lengthdir_y(_armLength, _armRightUpperPos[2]), _armRightUpperPos[2]];
  179.                
  180.                 handLeft[2]  = _armLeftLowerPos[2];
  181.                 handRight[2] = _armRightLowerPos[2];
  182.             }
  183.             else
  184.             {
  185.                 //var _armRot = [48.19, 48.19 * 2];
  186.                 //var _armRot = [75.522, 180 - 28.955];
  187.                
  188.                 _armSwing = _armSwing * _scale[0] * _anim;
  189.                
  190.                 _armLeftUpperPos  = [_jointShoulderLeft[0] * _scale[0], _jointShoulderLeft[1] * _scale[1], _armSwing - 90];
  191.                 _armLeftLowerPos  = [_armLeftUpperPos[0] + lengthdir_x(_armLength, _armLeftUpperPos[2]),_armLeftUpperPos[1] + lengthdir_y(_armLength, _armLeftUpperPos[2]), _armLeftUpperPos[2]];
  192.                 _armRightUpperPos = [_jointShoulderRight[0] * _scale[0], _jointShoulderRight[1] * _scale[1], direction - _armRot[0]];
  193.                 _armRightLowerPos = [_armRightUpperPos[0] + lengthdir_x(_armLength, _armRightUpperPos[2]),_armRightUpperPos[1] + lengthdir_y(_armLength, _armRightUpperPos[2]), _armRightUpperPos[2] + _armRot[1]];
  194.                
  195.                 handLeft[2]  = _armLeftLowerPos[2];
  196.                 handRight[2] = direction;
  197.             }
  198.            
  199.             break;
  200.     }
  201.    
  202.     handLeft  = [x + _armLeftLowerPos[0]  + lengthdir_x(_armLength, _armLeftLowerPos[2]),    y + _armLeftLowerPos[1]  + lengthdir_y(_armLength, _armLeftLowerPos[2]), handLeft[2]];
  203.     handRight = [x + _armRightLowerPos[0] + lengthdir_x(_armLength, _armRightLowerPos[2]),y + _armRightLowerPos[1] + lengthdir_y(_armLength, _armRightLowerPos[2]),handRight[2]];
  204.    
  205.     holsterPoint[0,0] = x  + _pointHolster1[0] * _scale[0];
  206.     holsterPoint[0,1] = y  + _pointHolster1[1] * _scale[1];
  207.     holsterPoint[0,2] = 90 + angle_difference(_pointHolster1[2], 90) * _scale[0];
  208.     holsterPoint[1,0] = x  + _pointHolster2[0] * _scale[0];
  209.     holsterPoint[1,1] = y  + _pointHolster2[1] * _scale[1];
  210.     holsterPoint[1,2] = 90 + angle_difference(_pointHolster2[2], 90) * _scale[0];
  211.    
  212.     if (is_defined(weapon))
  213.     {
  214.         if (holstered)
  215.         {
  216.             var _hand = weapon[? "Hands"] - 1;
  217.             weaponTip = [holsterPoint[_hand,0],holsterPoint[_hand,1],shoulderY, holsterPoint[_hand,2]];
  218.         }
  219.         else
  220.         {
  221.             var _offset = weapon[? "Tip Offset"];
  222.             if (abs(angle_difference(handRight[2], 0)) > 90) _offset[1] *= -1;
  223.             weaponTip = [handRight[0] + lengthdir_x(_offset[0], handRight[2] + _offset[1]), handRight[1] + lengthdir_y(_offset[0], handRight[2] + _offset[1]), shoulderY, handRight[2]];
  224.         }
  225.     }
  226.    
  227.     skeleton[SkeletonHumanoid.HEAD_POS]            = _headPos;
  228.     skeleton[SkeletonHumanoid.TORSO_POS]           = _torsoPos;
  229.     skeleton[SkeletonHumanoid.ARM_LEFT_UPPER_POS]  = _armLeftUpperPos;
  230.     skeleton[SkeletonHumanoid.ARM_LEFT_LOWER_POS]  = _armLeftLowerPos;
  231.     skeleton[SkeletonHumanoid.ARM_RIGHT_UPPER_POS] = _armRightUpperPos;
  232.     skeleton[SkeletonHumanoid.ARM_RIGHT_LOWER_POS] = _armRightLowerPos;
  233.     skeleton[SkeletonHumanoid.LEG_LEFT_UPPER_POS]  = _legLeftUpperPos;
  234.     skeleton[SkeletonHumanoid.LEG_LEFT_LOWER_POS]  = _legLeftLowerPos;
  235.     skeleton[SkeletonHumanoid.LEG_RIGHT_UPPER_POS] = _legRightUpperPos;
  236.     skeleton[SkeletonHumanoid.LEG_RIGHT_LOWER_POS] = _legRightLowerPos;
  237. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement