GlovePIE: Light Gun

From WiiLi

Jump to: navigation, search

Script written by Tre Lantana

Video of script in use is most likely forthcoming.


/*
Wii Light Gun
Version 0.1
Written April 27th, 2008

Scripted by Tre Lantana
AKA WearingTheHatofShame
AKA Anonymous J
AKA BisKit
AKA Biz Kit

 ________________
|                |
|     NOTES:     |
|________________|
This script will only work on games and applications that
  do not require direct input to be used.
For example, this can be used with:
  most emulators,
  House of the Dead 2
  House of the Dead 3
  Most PC Light gun games
  Etcetera

 ________________
|                |
|  Instructions  |
|________________|

  Start the script
  Aim at the top edge of the screen and press B
  Aim at the bottom edge of the screen and press B
  Aim at the left edge of the screen and press B
  Aim at the right edge of the screen and press B
  Enjoy

 ________________
|                |
|   Controls:    |
|________________|

  Point at the screen to move the mouse

  Wiimote Btn  - Keyboard/Mouse Button
  B Button     - Left Click (mouse)
  A Button     - Right Click (mouse)
  1 Button     - Middle Click (mouse)
  2 Button     - Enter (keyboard)
  Dpad Up      - W (keyboard)
  Dpad Left    - A (keyboard)
  Dpad Down    - S (keyboard)
  Dpad Right   - D (keyboard)
  Plus Button  - Numpad Plus (keyboard)
  Minus Button - Numpad Minus (keyboard)
  Home Button  - Home key (keyboard)
  Shake        - Right Click (mouse)
  Aim off screen to the right - Right Click (mouse) 


*/


if(!var.inited) var.inited = 0;
if(var.inited == 0) {
  var.topofscreen = 0;
  debug = wiimote.pointery;
  debug = "Hold the wiimote level, aim at the top edge of the screen, and press B.  ("+wiimote.pointery+")";
  if(wiimote.B) {
    var.topofscreen = wiimote.pointery;
    var.inited = 1;
  }
}
if(var.inited == 1) {
  debug = "Release the B button";
  if(!wiimote.B) {
    var.inited = 2;
  }
}
if(var.inited == 2) {
  var.bottomofscreen = 0;
  debug = wiimote.pointery;
  debug = "Hold the wiimote level, aim at the bottom edge of the screen, and press B.  ("+wiimote.pointery+")";
  if(wiimote.B) {
    var.bottomofscreen = wiimote.pointery;
    var.inited = 3;
  }
}
if(var.inited == 3) {
  debug = "Release the B button";
  if(!wiimote.B) {
    var.inited = 4;
  }
}
if(var.inited == 4) {
  //var.leftofscreen = 0;
  debug = wiimote.pointerx;
  debug = "Hold the wiimote level, aim at the left edge of the screen, and press B.  ("+wiimote.pointerx+")";
  if(wiimote.B) {
    var.leftofscreen = wiimote.pointerx;
    var.inited = 5;
  }
}
if(var.inited == 5) {
  debug = "Release the B button";
  if(!wiimote.B) {
    var.inited = 6;
  }
}
if(var.inited == 6) {
  //var.rightofscreen = 0;
  debug = wiimote.pointerx;
  debug = "Hold the wiimote level, aim at the right edge of the screen, and press B.  ("+wiimote.pointerx+")";
  if(wiimote.B) {
    var.rightofscreen = wiimote.pointerx;
    var.inited = 7;
  }
}
if(var.inited == 7) {
  debug = "Release the B button";
  if(!wiimote.B) {
    var.inited = 8;
  }
}

if(var.inited == 8) {

  var.xamount = 1/(var.rightofscreen-var.leftofscreen);
  var.yamount = 1/(var.bottomofscreen-var.topofscreen);

  var.inited = 9;

}
if(var.inited == 9) {
 
  var.mx = wiimote.pointerx;
  if(var.mx >= var.leftofscreen and var.mx <= var.rightofscreen) {
    var.aimedx = (var.mx-var.leftofscreen)*var.xamount;
  }
  if(var.mx < var.leftofscreen) var.aimedx = 0;
  if(var.mx > var.rightofscreen) var.aimedx = 1;

  
  var.my = wiimote.pointery;
  if(var.my >= var.topofscreen and var.mx <= var.bottomofscreen) {
    var.aimedy = (var.my-var.topofscreen)*var.yamount;
  }
  if(var.my < var.topofscreen) var.aimedy = 0;
  if(var.my > var.bottomofscreen) var.aimedy = 1;

  mouse.x = var.aimedx;
  mouse.y = var.aimedy;
  debug = "1 / "+var.rightofscreen+"-"+var.leftofscreen+" = "+var.xamount;
  //debug = var.mx-var.leftofscreen + " " + (var.mx-var.leftofscreen)*var.xamount;

  mouse.leftbutton = wiimote.B;
  mouse.rightbutton = wiimote.A or var.mx > var.rightofscreen or wiimote.rawforce > 80;
  key.enter = wiimote.Two;
  key.w = wiimote.Up;
  key.s = wiimote.Down;
  key.a = wiimote.Left;
  key.d = wiimote.Right;
  key.numpadplus = wiimote.Plus;
  key.numpadminus = wiimote.Minus;
  key.home = wiimote.Home;
  mouse.middlebutton = wiimote.One;
}
if(var.inited != 9) {
  mouse.x = wiimote.pointerx;
  mouse.y = wiimote.pointery;
}
Personal tools
Online Casino - best online casino reviews.
Facebook Developers - facebook applications, facebook developers, facebook development, social network application development and viral widget social media strategy