Advertisement
apadamson

Broke Age GlovePIE

Jan 22nd, 2014
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. //Resident Evil Movement Script //Barley Modded for Broken Age
  2. //To calibrate, use the nunchuk joystick to move the mouse cursor to each corner of the screen as indicated. Stop just at
  3. //the corner. Going further will decrease accuracy.
  4. //Then press the B button and continue calibrating the other corners as instructed.
  5. //Nunchuk no longer controls mouse after calibration.
  6.  
  7.  
  8. //"Enhanced pointer precision" should be turned off. Found in mouse settings control panel on winXP
  9.  
  10.  
  11. //Using the computer mouse will disrupt the calibration.
  12. //Press ALT on the keyboard to restart calibration.
  13.  
  14.  
  15.  
  16. //Mouse Control Script using IR
  17. //by vkapadia with much assistance from inio
  18. //####### censored web address
  19. //
  20. //Calibration:
  21. //To calibrate, run this program and put the wiimote1 on a flat surface face-up.
  22. //Then read the values in the debug line (next to the run button).
  23.  
  24. //Change these values until the debug line reads approx. all zeros.
  25. var.xtrim = 0
  26. var.ytrim = 0
  27. var.ztrim = 0
  28. //display ""
  29. var.accx = wiimote1.RawForceX + var.xtrim
  30. var.accy = wiimote1.RawForceY + var.ytrim
  31. var.accz = wiimote1.RawForceZ + var.ztrim
  32. //debug = var.accx + "," + var.accy + "," + var.accz
  33. if wiimote1.dot1vis and wiimote1.dot2vis then //if both led's are visible
  34.  
  35. if var.accy > -7 then
  36. var.orientation = 0
  37. // display "held in normaly"
  38. elseif var.accy > -45 then
  39. if var.accx < 0 then
  40. var.orientation = 3
  41. // display "twisted right"
  42. else
  43. var.orientation = 1
  44. // display "twisted left"
  45. endif
  46. else
  47. var.orientation = 2
  48. //display "upside down"
  49. endif
  50.  
  51. if var.leftpoint = 0 then
  52. if var.orientation = 0 then
  53. if wiimote1.dot1x < wiimote1.dot2x then
  54. var.leftpoint = 1
  55. // display "coming in to view from left, normal pos"
  56. else
  57. var.leftpoint = 2
  58. // display "coming in to view from right, normal pos"
  59. endif
  60. endif
  61. if var.orientation = 1 then
  62. if wiimote1.dot1y > wiimote1.dot2y then
  63. var.leftpoint = 1
  64. //display "coming in to view from left, twisted left"
  65. else
  66. var.leftpoint = 2
  67. //display "coming in to view from right, twisted left"
  68. endif
  69. endif
  70. if var.orientation = 2 then
  71. if wiimote1.dot1x > wiimote1.dot2x then
  72. var.leftpoint = 1
  73. // display "coming in to view from left, upside down"
  74. else
  75. var.leftpoint = 2
  76. //display "coming in to view from right, upside down"
  77. endif
  78. endif
  79. if var.orientation = 3 then
  80. if wiimote1.dot1y < wiimote1.dot2y then
  81. var.leftpoint = 1
  82. //display "coming in to view from left, twisted right"
  83. else
  84. var.leftpoint = 2
  85. // display "coming in to view from right, twisted right"
  86. endif
  87. endif
  88. endif
  89.  
  90. if var.leftpoint = 1 then
  91. var.fix1x = wiimote1.dot1x
  92. var.fix1y = wiimote1.dot1y
  93. var.fix2x = wiimote1.dot2x
  94. var.fix2y = wiimote1.dot2y
  95. else
  96. var.fix1x = wiimote1.dot2x
  97. var.fix1y = wiimote1.dot2y
  98. var.fix2x = wiimote1.dot1x
  99. var.fix2y = wiimote1.dot1y
  100. endif
  101.  
  102. var.dx = var.fix2x - var.fix1x
  103. var.dy = var.fix2y - var.fix1y
  104. var.cx = (var.fix1x+var.fix2x)/1024.0 - 1 //gets x distence from centre
  105. var.cy = (var.fix1y+var.fix2y)/1024.0 - .75 //gets y distence from centre of screen
  106.  
  107. var.d = sqrt(var.dx*var.dx+var.dy*var.dy)
  108.  
  109. var.dx = var.dx / var.d
  110. var.dy = var.dy / var.d
  111.  
  112. var.ox = -var.dy*var.cy-var.dx*var.cx;
  113. var.oy = -var.dx*var.cy+var.dy*var.cx;
  114.  
  115. var.ax = (var.ox * screen.desktopwidth) + (screen.desktopwidth / 2)
  116. var.ay = (-var.oy * screen.desktopwidth) + (screen.desktopheight / 2)
  117.  
  118. var.dx = var.ax - mouse.cursorposx
  119. var.dy = var.ay - mouse.cursorposy
  120.  
  121. var.d = sqrt((var.dx*var.dx)+(var.dy*var.dy))
  122.  
  123. var.a = 180 / (200 + var.d * var.d * var.d * .001)
  124. var.a = sqrt(var.a)*sqrt(var.a)
  125.  
  126.  
  127. var.finalx = mouse.cursorposx * var.a + var.ax * (1 - var.a)
  128. var.finaly = mouse.cursorposy * var.a + var.ay * (1 - var.a)
  129.  
  130. //mouse.cursorposx = var.finalx
  131. //mouse.cursorposy = var.finaly
  132.  
  133.  
  134. else
  135.  
  136. var.leftpoint = 0
  137.  
  138. endif
  139.  
  140.  
  141. //################################################ RES EVIL movement script by mucka@mucka.tk
  142.  
  143. if (keyboard.Alt)
  144. var.poscalb = false
  145. var.topleftx = false
  146. var.toplefty = false
  147. var.toprightx = false
  148. var.toprighty = false
  149. var.bottomleftx = false
  150. var.bottomlefty = false
  151. var.bottomrightx = false
  152. var.bottomrighty = false
  153. endif
  154.  
  155.  
  156. if (var.poscalb == 0)
  157. mouse.directinputx = mouse.directinputx + wiimote.nunchuk.joyx*10
  158. mouse.directinputy = mouse.directinputy + wiimote.nunchuk.joyy*10
  159. endif
  160.  
  161.  
  162.  
  163.  
  164. var.time = ((timestamp - var.calbtime) > 2)
  165. var.posx = mouse.DirectInputx
  166. var.posy = mouse.directinputy
  167. if (var.poscalb == false)
  168.  
  169. if (var.topleftx == false)
  170. display("Shoot top left")
  171.  
  172. endif
  173. if (wiimote.b and var.topleftx == false)
  174. var.topleftx = mouse.DirectInputx
  175. var.toplefty = mouse.DirectInputy
  176. var.calbtime = timestamp
  177. display("Saved")
  178. wait 1s
  179. display("Shoot top right")
  180. elseif (wiimote.b and var.toprightx == false and ((timestamp - var.calbtime) > 2))
  181. var.toprightx = mouse.DirectInputx
  182. var.toprighty = mouse.DirectInputy
  183. var.calbtime = timestamp
  184. display("Saved")
  185. wait 1s
  186. display("Shoot bottom right")
  187. elseif (wiimote.b and var.bottomrightx == false and ((timestamp - var.calbtime) > 2))
  188. var.bottomrightx = mouse.DirectInputx
  189. var.bottomrighty = mouse.DirectInputy
  190. var.calbtime = timestamp
  191. display("Saved")
  192. wait 1s
  193. display("Shoot bottom left")
  194. elseif (wiimote.b and ((timestamp - var.calbtime) > 2))
  195. var.bottomleftx = mouse.DirectInputx
  196. var.bottomlefty = mouse.DirectInputy
  197.  
  198. /*
  199. var.leftx = (var.topleftx + var.bottomleftx + var.toprightx + var.bottomrightx + (1536))/4
  200. var.topy = (var.toplefty + var.toprighty + var.bottomlefty + var.bottomrighty + (2048))/4
  201. */d
  202.  
  203.  
  204.  
  205. //screen size in mickeys
  206. var.left = (var.topleftx + var.bottomleftx)/2
  207. var.right = (var.toprightx + var.bottomrightx)/2
  208. var.top = (var.toplefty + var.toprighty)/2
  209. var.bottom = (var.bottomlefty + var.bottomrighty)/2
  210.  
  211. var.screenwidthmickeys = var.right - var.left
  212. var.screenheightmickeys = var.bottom - var.top
  213.  
  214. var.mickeysperpixelx = removeunits(var.screenwidthmickeys) / removeunits(screen.width)
  215. var.mickeysperpixely = removeunits(var.screenheightmickeys) / removeunits(screen.height)
  216.  
  217.  
  218. var.poscalb = 1
  219. display("Saved")
  220. wait 1s
  221. display("")
  222.  
  223. endif
  224.  
  225. endif
  226.  
  227.  
  228.  
  229.  
  230. if (var.poscalb) and wiimote1.dot1vis and wiimote1.dot2vis
  231.  
  232. var.directinputx = removeunits(var.left) + removeunits(var.finalx * var.mickeysperpixelx)
  233. var.directinputy = removeunits(var.top) + removeunits(var.finaly * var.mickeysperpixely)
  234.  
  235. mouse.directinputpos = [var.directinputx, var.directinputy]
  236.  
  237. endif
  238.  
  239. //Broken Age INPUTS
  240. mouse.leftbutton = wiimote.A
  241. Key.Space = Wiimote.Minus
  242. Key.I = Wiimote.Plus
  243. Key.Escape = Wiimote.Home
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement