Guest User

Stickman

a guest
Aug 28th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.71 KB | None | 0 0
  1. @name Paper Stick Man 2
  2. @inputs Pos:vector FaceDir:vector BodyDir:vector Scale
  3. @outputs
  4. @persist StillCount Arm_AnimSeq Arm_AnimActions:array Arm_AnimActionIndex Arm_AnimTickCount Leg_AnimSeq Leg_AnimActions:array Leg_AnimActionIndex Leg_AnimTickCount AnimLeftLeg:angle AnimRightLeg:angle AnimLeftArm:angle AnimRightArm:angle Seq_Legs_Run:array Seq_Arms_Run:array Seq_Arms_LClick:array Seq_Arms_RClick:array IHead IBody ILeftArm IRightArm ILeftLeg IRightLeg ArmAng:angle LastPos:vector LeftArmEndPos:vector RightArmEndPos:vector ICylinder1 IBullet1 Bullet1State Bullet1Pos:vector Bullet1Target:vector Bullet1Tick
  5. @trigger all
  6. Offset = 0
  7. Scale = 0.7 # This means draw him at normal size.
  8. # If this is set to 3, it will draw him
  9. # triple the size, 0.1 will draw him at
  10. # 1/10 th the size.
  11. # This scale function seems to work perfectly.
  12.  
  13. if( first() | duped() )
  14. {
  15. entity():owner():setColor(0,0,0)
  16. entity():owner():setMaterial("Models/effects/vol_light001")
  17.  
  18. # Initialize
  19. runOnTick(1)
  20. print("Stick Man!")
  21. print("Made By Paper Clip")
  22.  
  23. # Initialize the animation sequence data
  24. AnimSeqIndex = 0
  25. AnimSeq = 0
  26.  
  27. # Intialize the tranformation angles for the animations
  28. AnimLeftLeg = ang(0,0,0)
  29. AnimRightLeg = ang(0,0,0)
  30.  
  31. if( Pos == vec() | FaceDir == vec() | BodyDir == vec() )
  32. {
  33. # Use the player's position if no position or no angle
  34. # was specified.
  35. Pos = entity():owner():pos() + entity():owner():forward()*100
  36. FaceDir = entity():owner():eye()
  37. BodyDir = entity():owner():forward()
  38. }
  39. if( Scale == 0 ) { Scale = 1 }
  40.  
  41. # Make the owner invisible
  42.  
  43.  
  44. # Create the holograms
  45. BaseIndex=round(random(1,100000)) # Thanks to Halkion for this idea!
  46. #head
  47. IHead = BaseIndex
  48. holoCreate(IHead,Pos,vec(2*Scale,2*Scale,2*Scale),FaceDir:toAngle(),vec(1,255,0))
  49. holoModel(IHead,"sphere")
  50. #body
  51. IBody = BaseIndex+1
  52. holoCreate(IBody,Pos,vec(1*Scale,1*Scale,3*Scale),BodyDir:toAngle(),vec(1,255,0))
  53. holoModel(IBody,"cylinder")
  54. #arms
  55. ILeftArm = BaseIndex+2
  56. holoCreate(ILeftArm,Pos,vec(1*Scale,1*Scale,2.5*Scale),BodyDir:toAngle(),vec(1,255,0))
  57. holoModel(ILeftArm,"cylinder")
  58. IRightArm = BaseIndex+3
  59. holoCreate(IRightArm,Pos,vec(1*Scale,1*Scale,2.5*Scale),BodyDir:toAngle(),vec(1,255,0))
  60. holoModel(IRightArm,"cylinder")
  61. #legs
  62. ILeftLeg = BaseIndex+4
  63. holoCreate(ILeftLeg,Pos,vec(1*Scale,1*Scale,3*Scale),BodyDir:toAngle(),vec(1,255,0))
  64. holoModel(ILeftLeg,"cylinder")
  65. IRightLeg = BaseIndex+5
  66. holoCreate(IRightLeg,Pos,vec(1*Scale,1*Scale,3*Scale),BodyDir:toAngle(),vec(1,255,0))
  67. holoModel(IRightLeg,"cylinder")
  68. #cylinder special effect
  69. ICylinder1 = BaseIndex+6
  70. holoCreate(ICylinder1,vec(0,0,0),vec(0,0,0),ang(0,0,0),vec(0,0,255))
  71. holoModel(ICylinder1,"cylinder")
  72. #bullet special effect
  73. IBullet1 = BaseIndex+7
  74. holoCreate(IBullet1,vec(0,0,0),vec(0,0,0),ang(0,0,0),vec(255,0,0))
  75. holoModel(IBullet1,"sphere")
  76.  
  77.  
  78. ######## Create the LEGS animation sequences #######
  79. # Sequences are in format of:
  80. # time: The number of ticks this action will be performed
  81. # before moving onto the next action.
  82. # special: 0 for nothing,
  83. # 1 to play walk sound at start of step,
  84. # 2 to play walk sound at end of step,
  85. # 3 to restart the sequence of actions but
  86. # skip the first action. Use this if you don't want the first
  87. # action to execute when it is looping. Otherwise it will
  88. # automatically restart from the first action at the end of
  89. # of the action sequence.
  90. # 4 to play walk sound at start and end of step,
  91. # angle velocity left leg:
  92. # Specifies the velocity of the left leg:
  93. # ie. ang(2,0,0) will extend his foot directly
  94. # towards his head sideways.
  95. # ang(0,2,0) will spin his foot towards his
  96. # front.
  97. # ang(5,5,0) will perform a forward kick,
  98. # by bring his foot around to the front and
  99. # increasing the pitch.
  100. # Note: With ang(2,0,0) his foot will
  101. # be slowly pitched exactly 40 degrees
  102. # if you time = 20; So you can perform
  103. # accurate movements!
  104. # angle velocity right leg:
  105. # Specifies the velocity of the left leg:
  106. ###############################################
  107.  
  108.  
  109. #### RUNNING LEGS SEQUENCE ###########
  110. #ACTION1# put feet together straight up instantly (They are starting out at 45 degrees sideways)
  111. Count = 0
  112. Seq_Legs_Run:setNumber(Count,1 ) # Do this animation for 1 tick
  113. Seq_Legs_Run:setNumber(Count+1, 1 ) # Play walk sound at start of step
  114. Seq_Legs_Run:setAngle(Count+2,ang(-45,90,0)) # Move left leg to perfectly vertical and rotate it forwards.
  115. Seq_Legs_Run:setAngle(Count+3,ang(-45,90,0)) # Move right leg to perfectly vertical and rotate it forwards.
  116. Count += 4
  117. #ACTION1# left leg forward
  118. Seq_Legs_Run:setNumber(Count,8 ) # Do this animation for 8 ticks
  119. Seq_Legs_Run:setNumber(Count+1, 0 )
  120. Seq_Legs_Run:setAngle(Count+2,ang(10,0,0)) # Move left leg up to (8[ticks]*10[deg/tick]=80 deg)
  121. Seq_Legs_Run:setAngle(Count+3,ang(-10,0,0)) # Move right leg the opposite direction
  122. Count += 4
  123. #ACTION2# move left leg backwards
  124. Seq_Legs_Run:pushNumber( 16 )
  125. Seq_Legs_Run:pushNumber( 4 ) # Play Walk Sound at start and end of step
  126. Seq_Legs_Run:pushAngle(ang(-10,0,0)) # Move left leg up to (16[ticks]*10[deg/tick]=160 deg)
  127. Seq_Legs_Run:pushAngle(ang(10,0,0))
  128. #ACTION3# move both legs back to standing
  129. Seq_Legs_Run:pushNumber( 8 )
  130. Seq_Legs_Run:pushNumber( 3 ) # SPECIAL FLAG -> LOOP FROM ACTION1 INSTEAD OF ACTION0
  131. Seq_Legs_Run:pushAngle(ang(10,0,0))
  132. Seq_Legs_Run:pushAngle(ang(-10,0,0))
  133. # It will automatically loop back to ACTION1
  134.  
  135. ######## Create the ARMS animation sequences #######
  136. # Sequences are in format of:
  137. # time: The number of ticks this action will be performed
  138. # before moving onto the next action.
  139. #
  140. # special: 0 for nothing,
  141. # 1 to fire a ball from right hand
  142. # 2 to fire a ball from left hand
  143. # 4 to fire a ball from both arms
  144. # 5 to draw a transparent cylinder from
  145. # right arm to world coordinates
  146. # in variable 'aim_position'
  147. # 6 to draw a transparent cylinder from
  148. # left arm to world coordinates
  149. # in variable 'aim_position'
  150. # 7 to draw a transparent cylinder from
  151. # both arms to world coordinates
  152. # in variable 'aim_position'
  153. # 3 to restart the sequence of actions but
  154. # skip the first action. Use this if you don't want the first
  155. # action to execute when it is looping. Otherwise it will
  156. # automatically restart from the first action at the end of
  157. # of the action sequence.
  158. #
  159. # aim specifier:
  160. # 0 to not auto-aim any arms
  161. # 1 to aim right hand at world coordinates
  162. # in variable 'aim_position'
  163. # 2 to aim left hand at world coordinates
  164. # in variable 'aim_position'
  165. # 3 to aim both hands at world coordinates
  166. # in variable 'aim_position'
  167. # (aim_position) -> This is an expression vector variable
  168. #
  169. # angle velocity left arm:
  170. # Specifies the velocity of the left leg:
  171. # ie. ang(2,0,0) will extend his foot directly
  172. # towards his head sideways.
  173. # ang(0,2,0) will spin his foot towards his
  174. # front.
  175. # ang(5,5,0) will perform a forward kick,
  176. # by bring his foot around to the front and
  177. # increasing the pitch.
  178. # Note: With ang(2,0,0) his foot will
  179. # be slowly pitched exactly 40 degrees
  180. # if you time = 20; So you can perform
  181. # accurate movements!
  182. # angle velocity right arm:
  183. # Specifies the velocity of the left leg:
  184. ###############################################
  185.  
  186.  
  187. ######### RUNNING ARM SEQUENCE ####
  188. #ACTION1# left arm slightly forward
  189. Count = 0
  190. Seq_Arms_Run:setNumber(Count,8 ) # Do this animation for 8 ticks
  191. Seq_Arms_Run:setNumber(Count+1, 0 ) # No special
  192. Seq_Arms_Run:setNumber(Count+2, 0 ) # Do not auto-aim arms
  193. Seq_Arms_Run:setAngle(Count+3,ang(1,3,0)) # Move left arm slightly forward and up
  194. Seq_Arms_Run:setAngle(Count+4,ang(-1,-3,0)) # Move left arm opposite
  195. Count += 5
  196. #ACTION2# move left arm backwards
  197. Seq_Arms_Run:pushNumber( 16 )
  198. Seq_Arms_Run:pushNumber( 0 )
  199. Seq_Arms_Run:pushNumber( 0 )
  200. Seq_Arms_Run:pushAngle(ang(-1,-3,0))
  201. Seq_Arms_Run:pushAngle(ang(1,3,0))
  202. #ACTION3# move left arm forwards
  203. Seq_Arms_Run:pushNumber( 8 )
  204. Seq_Arms_Run:pushNumber( 0 )
  205. Seq_Arms_Run:pushNumber( 0 )
  206. Seq_Arms_Run:pushAngle(ang(1,3,0))
  207. Seq_Arms_Run:pushAngle(ang(-1,-3,0))
  208. # It will automatically loop back to ACTION1
  209.  
  210.  
  211.  
  212. ######### LEFT-CLICK HOLD-DOWN SEQUENCE ####
  213. ###### This creates a cylinders beam at
  214. ###### your target so that it looks
  215. ###### like the stickman is manipulating
  216. ###### your contraption.
  217.  
  218. #ACTION1# Auto-aim right hand at target
  219. Seq_Arms_LClick:setNumber(0,800 ) # Do this animation for 800 ticks
  220. Seq_Arms_LClick:setNumber(1, 5 ) # Draw transparent cylinder from right hand
  221. Seq_Arms_LClick:setNumber(2, 1 ) # Auto-aim right hand
  222. Seq_Arms_LClick:setAngle(3,ang(0,0,0))
  223. Seq_Arms_LClick:setAngle(4,ang(0,0,0))
  224. # It will automatically loop back to ACTION1
  225.  
  226.  
  227.  
  228. ######### RIGHT-CLICK HOLD-DOWN SEQUENCE ####
  229. ###### This fires a ball at the target
  230. ###### while making a large explosion on
  231. ###### impact. (holographic impact, it doesn't
  232. ###### do any real damage of course!
  233.  
  234. #ACTION1# Auto-aim right hand at target
  235. Seq_Arms_RClick:setNumber(0,800 ) # Do this animation for 800 ticks
  236. Seq_Arms_RClick:setNumber(1, 1 ) # Fire sphere from right hand
  237. Seq_Arms_RClick:setNumber(2, 1 ) # Auto-aim right hand
  238. Seq_Arms_RClick:setAngle(3,ang(0,0,0))
  239. Seq_Arms_RClick:setAngle(4,ang(0,0,0))
  240. # It will automatically loop back to ACTION1
  241.  
  242. print("initialized")
  243. exit()
  244. }
  245.  
  246. if( tickClk() )
  247. {
  248. # Set the input variables if they were not specified
  249. if( Pos == vec() | FaceDir == vec() | BodyDir == vec() )
  250. {
  251. # Use the player's position if no position or no angle
  252. # was specified.
  253. Pos = entity():owner():pos() + entity():owner():forward()*Offset
  254.  
  255.  
  256. FaceDir = entity():owner():eye()
  257. BodyDir = entity():owner():forward()
  258. }
  259. if( Scale == 0 ) { Scale = 1 }
  260.  
  261. #### ANIMATION SEQUENCE EXECUTION
  262.  
  263. # Walking animation - overrides other animations
  264. if( (LastPos != Pos) & (Leg_AnimSeq != 1) )
  265. {
  266. # Play the walk leg animation
  267. Leg_AnimSeq = 1 # index 1 is for walking
  268. Leg_AnimTickCount = 0
  269. Leg_AnimActionIndex = 0
  270. Leg_AnimActions = Seq_Legs_Run # Set the run sequence to the current sequence
  271.  
  272. # Play the walk arm animation
  273. Arm_AnimSeq = 1 # index 1 is for walking
  274. Arm_AnimTickCount = 0
  275. Arm_AnimActionIndex = 0
  276. Arm_AnimActions = Seq_Arms_Run # Set the run sequence to the current sequence
  277. }elseif( Leg_AnimSeq == 1 ){
  278. # Disable the walking animation sequence
  279. if(LastPos == Pos)
  280. {
  281. StillCount++
  282. if(StillCount > 3)
  283. {
  284. if( Arm_AnimSeq == 1 )
  285. { Arm_AnimSeq = 0 }
  286. holoScale(ICylinder1,vec(0,0,0))
  287. Leg_AnimSeq = 0
  288. StillCount = 0
  289. }
  290. }else{
  291. StillCount = 0
  292. }
  293. }
  294.  
  295. # Left-Click Animation
  296. if( entity():owner():keyAttack1() & Arm_AnimSeq != 2 )
  297. {
  298. # Begin the aim sequence
  299. Arm_AnimSeq = 2 # index 1 is for walking
  300. Arm_AnimTickCount = 0
  301. Arm_AnimActionIndex = 0
  302. Arm_AnimActions = Seq_Arms_LClick # Set the run sequence to the current sequence
  303.  
  304. # Play the beam engage sound
  305. entity():owner():soundPlay(3,1000,"weapons/357/357_spin1.wav")
  306. entity():owner():soundPlay(4,0,"weapons/physcannon/hold_loop.wav")
  307.  
  308. }elseif( (Arm_AnimSeq == 2) & (entity():owner():keyAttack1()!=1) & Leg_AnimSeq == 1 )
  309. {
  310. # Play the walk arm animation
  311. Arm_AnimSeq = 1 # index 1 is for walking
  312. Arm_AnimTickCount = 0
  313. Arm_AnimActionIndex = 0
  314. Arm_AnimActions = Seq_Arms_Run # Set the run sequence to the current sequence
  315. soundStop(4)
  316. }elseif( (Arm_AnimSeq == 2) & (entity():owner():keyAttack1()!=1) )
  317. {
  318. # Play no arm animation sequence
  319. Arm_AnimSeq = 0
  320. holoScale(ICylinder1,vec(0,0,0))
  321. soundStop(4)
  322. }
  323.  
  324. # Right-Click Animation
  325. if( entity():owner():keyAttack2() & Arm_AnimSeq != 3 )
  326. {
  327. # Begin the fire sphere sequence
  328. Arm_AnimSeq = 3
  329. Arm_AnimTickCount = 0
  330. Arm_AnimActionIndex = 0
  331. Arm_AnimActions = Seq_Arms_RClick # Set the run sequence to the current sequence
  332. }elseif( (Arm_AnimSeq == 3) & (entity():owner():keyAttack2()!=1) & Leg_AnimSeq == 1 )
  333. {
  334. # Play the walk arm animation
  335. Arm_AnimSeq = 1 # index 1 is for walking
  336. Arm_AnimTickCount = 0
  337. Arm_AnimActionIndex = 0
  338. Arm_AnimActions = Seq_Arms_Run # Set the run sequence to the current sequence
  339. }elseif( (Arm_AnimSeq == 3) & (entity():owner():keyAttack2()!=1) )
  340. {
  341. # Play no arm animation sequence
  342. Arm_AnimSeq = 0
  343. }
  344.  
  345.  
  346. ############# LEG ANIMATION SEQUENCE UPDATE ##############
  347. if( Leg_AnimSeq != 0 )
  348. {
  349. # Check to see if we should move on to the next action
  350. #print(AnimActionIndex:toString() + ": " + AnimTickCount + " tick needed: " +(SRun:number(AnimActionIndex*7)))
  351. if( Leg_AnimActions:number(Leg_AnimActionIndex*4) <= Leg_AnimTickCount )
  352. {
  353. Special = Leg_AnimActions:number((Leg_AnimActionIndex)*4+1)
  354. if( Special == 2 | Special == 4 )
  355. {
  356. # Play the end of action sound
  357. entity():owner():soundPlay(5,1000,"npc/dog/dog_footstep4.wav")
  358. soundVolume(5,0.5)
  359. }
  360.  
  361. # Move on to the next action
  362. Leg_AnimActionIndex = Leg_AnimActionIndex + 1
  363.  
  364. if( Leg_AnimActionIndex*4 < Leg_AnimActions:count() )
  365. {
  366. Special = Leg_AnimActions:number((Leg_AnimActionIndex)*4+1)
  367. if( Special == 1 | Special == 4 )
  368. {
  369. # Play the start of action sound
  370. entity():owner():soundPlay(5,1000,"npc/dog/dog_footstep4.wav")
  371. soundVolume(5,0.5)
  372. }
  373. }
  374.  
  375. Leg_AnimTickCount = 0
  376. }
  377.  
  378. # Check for a looping of the sequence
  379. if( Leg_AnimActionIndex*4 >= Leg_AnimActions:count() )
  380. {
  381. # Read in the special variable of the last event
  382. Special = Leg_AnimActions:number((Leg_AnimActionIndex-1)*4+1)
  383. if( Special == 3 )
  384. {
  385. # Restart at second element
  386. Leg_AnimActionIndex = 1
  387. }else{
  388. # Restart to first element
  389. Leg_AnimActionIndex = 0
  390. }
  391. }
  392.  
  393. # Play the current action
  394. AnimLeftLeg = AnimLeftLeg + Leg_AnimActions:angle(Leg_AnimActionIndex*4+2)
  395. AnimRightLeg = AnimRightLeg + Leg_AnimActions:angle(Leg_AnimActionIndex*4+3):setYaw(-Leg_AnimActions:angle(Leg_AnimActionIndex*4+3):yaw())
  396.  
  397. # Increase the tick count
  398. Leg_AnimTickCount = Leg_AnimTickCount + 1
  399. }else{
  400. AnimRightLeg = ang(0,0,0)
  401. AnimLeftLeg = ang(0,0,0)
  402. }
  403.  
  404. ############# ARM ANIMATION SEQUENCE UPDATE ##############
  405. if( Arm_AnimSeq != 0 )
  406. {
  407. # Check to see if we should move on to the next action
  408. if( Arm_AnimActions:number(Arm_AnimActionIndex*5) <= Arm_AnimTickCount )
  409. {
  410. # Move on to the next action
  411. Arm_AnimActionIndex = Arm_AnimActionIndex + 1
  412. Arm_AnimTickCount = 0
  413. }
  414.  
  415. # Check for a looping of the sequence
  416. if( Arm_AnimActionIndex*5 >= Arm_AnimActions:count() )
  417. {
  418. # Read in the special variable of the last event
  419. Special = Arm_AnimActions:number((Arm_AnimActionIndex-1)*5+1)
  420. if( Special == 3 )
  421. {
  422. # Restart at second element
  423. Arm_AnimActionIndex = 1
  424. }else{
  425. # Restart to first element
  426. Arm_AnimActionIndex = 0
  427. }
  428. }
  429.  
  430. # Play the current action
  431.  
  432. # Read in the aim specifier variable
  433. AimSpecifier = Arm_AnimActions:number(Arm_AnimActionIndex*5+2)
  434. if( AimSpecifier == 0 )
  435. {
  436. # No auto-aim
  437. AnimLeftArm = AnimLeftArm + Arm_AnimActions:angle(Arm_AnimActionIndex*5+3)
  438. AnimRightArm = AnimRightArm + Arm_AnimActions:angle(Arm_AnimActionIndex*5+4):setYaw(-Arm_AnimActions:angle(Arm_AnimActionIndex*5+4):yaw())
  439. }elseif( AimSpecifier == 1 )
  440. {
  441. # No auto-aim for left hand
  442. AnimLeftArm = AnimLeftArm + Arm_AnimActions:angle(Arm_AnimActionIndex*5+3)
  443.  
  444. # Auto-aim right hand
  445. Direction = owner():aimPos() - RightArmEndPos
  446. AnimRightArm = ang(45,90,0) + (Direction:toAngle() - BodyDir:toAngle()):setPitch(-(Direction:toAngle() - BodyDir:toAngle()):pitch())
  447. }
  448.  
  449. # Perform the special drawing actions
  450. Special = Arm_AnimActions:number(Arm_AnimActionIndex*5+1)
  451. if( Special == 5 )
  452. {
  453. # Draw a cylinder from the right hand to the target
  454. Direction = owner():aimPos() - RightArmEndPos
  455. holoScaleUnits(ICylinder1,vec(5*Scale,5*Scale,Direction:length()) )
  456. holoPos(ICylinder1,RightArmEndPos+Direction/2)
  457. holoAng(ICylinder1,Direction:toAngle()+ang(90,0,0))
  458. }else{
  459. holoScale(ICylinder1,vec(0,0,0))
  460. }
  461. if( Special == 1 )
  462. {
  463. if(Bullet1State == 0)
  464. {
  465. # Launch a new bullet
  466. Bullet1Pos = RightArmEndPos
  467. Bullet1Target = owner():aimPos()
  468. holoPos(IBullet1,Bullet1Pos)
  469. holoScale(IBullet1,vec(1*Scale,1*Scale,1*Scale))
  470. holoColor(IBullet1,vec(255,0,0)) #Red
  471. Bullet1State = 1
  472.  
  473. # Play the fire sound: weapons/mortar/mortar_fire1.wav
  474. entity():owner():soundPlay(1,1000,"weapons/mortar/mortar_fire1.wav")
  475. }
  476. }
  477.  
  478.  
  479. # Increase the tick count
  480. Arm_AnimTickCount = Arm_AnimTickCount + 1
  481. }else{
  482. AnimRightArm = ang(0,0,0)
  483. AnimLeftArm = ang(0,0,0)
  484. }
  485.  
  486. #### Process the bullet fire
  487. if( Bullet1State == 1 )
  488. {
  489. # Bullet is in travelling state
  490. Speed = 50
  491. Direction = Bullet1Target - Bullet1Pos
  492.  
  493. # Check to see if we hit the target
  494. if( Direction:length() < 100 )
  495. {
  496. # We hit the target, BOOM!
  497. Bullet1State = 2
  498. Bullet1Tick = 1
  499. #holoPos(IBullet1,Bullet1Target)
  500. holoColor(IBullet1,vec(255,255,0)) #Yellow
  501. holoScale(IBullet1,vec((1+Bullet1Tick)*Scale,(1+Bullet1Tick)*Scale,(1+Bullet1Tick)*Scale))
  502.  
  503. # Play the explode sound on the nearest entity to the explosion
  504. findInSphere(Bullet1Target,5000)
  505. ExplodeSound = findClosest(Bullet1Target)
  506. if( ExplodeSound )
  507. {
  508. ExplodeSound:soundPlay(2,1000,"weapons/explode5.wav")
  509. soundVolume(2,1000)
  510. }
  511. }else{
  512. # Move it towards it's target
  513. Bullet1Pos = Bullet1Pos + Direction:normalized()*Speed
  514. holoPos(IBullet1,Bullet1Pos)
  515. }
  516. }elseif( Bullet1State == 2 )
  517. {
  518. # Explosion state
  519. holoScale(IBullet1,vec((1+Bullet1Tick*2)*Scale,(1+Bullet1Tick*2)*Scale,(1+Bullet1Tick*2)*Scale))
  520. if( mod(Bullet1Tick,2) == 0 )
  521. {
  522. holoColor(IBullet1,vec(255,255,0)) #Yellow
  523. }else{
  524. holoColor(IBullet1,vec(255,0,0)) #Red
  525. }
  526.  
  527. if( Bullet1Tick > 15 )
  528. {
  529. # Explosion done
  530. holoScale(IBullet1,vec(0,0,0))
  531. Bullet1State = 0
  532. }
  533.  
  534. Bullet1Tick = Bullet1Tick + 1
  535. }
  536.  
  537. LastPos = Pos
  538. ############# Update the position of the stickman
  539. #head
  540. holoPos(IHead,Pos+vec(0,0,85*Scale))
  541. holoAng(IHead,FaceDir:toAngle())
  542. #body
  543. holoPos(IBody,Pos+vec(0,0,50*Scale))
  544. holoAng(IBody,BodyDir:toAngle())
  545. #arms
  546. LeftArmDir = (BodyDir:cross(vec(0,0,1)):normalized() - vec(0,0,1)):normalized()
  547. LeftArmAng = AnimLeftArm + LeftArmDir:toAngle()
  548. TmpAng = AnimLeftArm:setPitch(-AnimLeftArm:pitch()) + LeftArmDir:toAngle()
  549. LeftArmDir = -vec( cos(TmpAng:pitch())*cos(TmpAng:yaw()), cos(TmpAng:pitch())*sin(TmpAng:yaw()),sin(TmpAng:pitch())):normalized()
  550. LeftArmPos = LeftArmDir*13*Scale - BodyDir:cross(vec(0,0,1))*10*Scale + Pos + vec(0,0,60*Scale)
  551. LeftArmEndPos = LeftArmPos + LeftArmDir*17*Scale
  552.  
  553. RightArmDir = (-BodyDir:cross(vec(0,0,1)):normalized() - vec(0,0,1)):normalized()
  554. RightArmAng = angnorm(AnimRightArm + RightArmDir:toAngle())
  555. TmpAng = angnorm(AnimRightArm:setPitch(-AnimRightArm:pitch()) + RightArmDir:toAngle())
  556. RightArmDir = -vec( cos(TmpAng:pitch())*cos(TmpAng:yaw()), cos(TmpAng:pitch())*sin(TmpAng:yaw()),sin(TmpAng:pitch())):normalized()
  557. RightArmPos = RightArmDir*13*Scale + BodyDir:cross(vec(0,0,1))*10*Scale + Pos + vec(0,0,60*Scale)
  558. RightArmEndPos = RightArmPos + RightArmDir*17*Scale
  559.  
  560. holoPos(ILeftArm,LeftArmPos)
  561. holoAng(ILeftArm,LeftArmAng)
  562. holoPos(IRightArm,RightArmPos)
  563. holoAng(IRightArm,RightArmAng)
  564. #legs
  565. LeftLegDir = (BodyDir:cross(vec(0,0,1)):normalized() - vec(0,0,1)):normalized()
  566. LeftLegAng = AnimLeftLeg + LeftLegDir:toAngle()
  567. TmpAng = AnimLeftLeg:setPitch(-AnimLeftLeg:pitch()) + LeftLegDir:toAngle()
  568. LeftLegDir = -vec( cos(TmpAng:pitch())*cos(TmpAng:yaw()), cos(TmpAng:pitch())*sin(TmpAng:yaw()),sin(TmpAng:pitch())):normalized()
  569. LeftLegPos = LeftLegDir*20*Scale - BodyDir:cross(vec(0,0,1))*5*Scale + Pos + vec(0,0,30*Scale)
  570.  
  571. RightLegDir = (-BodyDir:cross(vec(0,0,1)):normalized() - vec(0,0,1)):normalized()
  572. RightLegAng = angnorm(AnimRightLeg + RightLegDir:toAngle())
  573. TmpAng = angnorm(AnimRightLeg:setPitch(-AnimRightLeg:pitch()) + RightLegDir:toAngle())
  574. RightLegDir = -vec( cos(TmpAng:pitch())*cos(TmpAng:yaw()), cos(TmpAng:pitch())*sin(TmpAng:yaw()),sin(TmpAng:pitch())):normalized()
  575. RightLegPos = RightLegDir*20*Scale + BodyDir:cross(vec(0,0,1))*5*Scale + Pos + vec(0,0,30*Scale)
  576. holoPos(IRightLeg,RightLegPos)
  577. holoAng(IRightLeg,RightLegAng)
  578. holoPos(ILeftLeg,LeftLegPos)
  579. holoAng(ILeftLeg,LeftLegAng)
  580. }
Add Comment
Please, Sign In to add comment