GlovePIE:Comunitary fps script project

From WiiLi

Jump to: navigation, search

Contents

[edit] About It

The idea here is to cooperatively code the best FPS IR script possible.

A few rules to better cooperate:

  • If you are adding a functionality that replaces an existing one in the script, instead of replacing it you should code a preference variable and separate the two ways to do it with an IF statement.
  • When improving an existing functionality try to confirm it is an improvement instead of a replacement.
  • Try to code with others in mind, don't make a code that only fits your completely unique way to play a specific game. Code for all players of all FPS games.
  • Comment as much as possible. If you see someone else's code is uncommented but you understand what it is doing, try to comment on it as best as you can.
  • When you change or add stuff to the code, try only pasting the changed part to avoid overwriting changes someone made after you downloaded the code.


[edit] To do

[edit] on the text about it

  • define the precise license everyone's code will be under
  • revise
  • improve the "rules for cooperation"
  • check what else is needed in this part of the article


FIELD_MESSAGE_siteltdelcac

[edit] How to setup PPJoy

  • first download PPJoy.[1]
  • Next open the installer and let it work.
  • The resulting downloaded file will have to be installed by running setup.exe
  • add a new joystick and then map, then modify the mapping. You'll need 2 axes.
  • Axis 1 = X Axis
  • Axis 2 = Y Axis
  • Then:
  • X Axis = Analog 0
  • Y Axis = Analog 1
  • no buttons or anything else is needed.

[edit] now to the code itself

////////////////////////////////////////////////////////////////////////////////
////////////////////// Comunitary fps script project ///////////////////////////
//////////////////////////////- version 2.0 -///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

//Thanks for choosing our product, it's the resluts of the hard work of many
//       people.
//
//PLEASE CONTINUE READING FOR SETUP INSTRUCTIONS!!!
//
//This Script enables you to play you PC FPS games with the ease if the Wii
//       Remote's IR capabilities.  The controls have been designed to be
//       comparable to Metroid Prime 3 and the like.  Some other features
//       include:
//               -Led lights indicate how much batter charge is left.
//               -fully mapable buttons
//               -many customizations
//
//       Please Note: 
//             - sometimes the Nunchuk isn't recognized when you run
//               a glovePIE script.  To fix this, simply disconnect and
//               reconnect the Nunchuk.
//
//             - if you all-of-the-sudden stop turning, the Wii Remote
//               has probably stopped "seeing" your sensor bar meaning
//               you pointed to far away from the light.
//
//Many features are user defined so there are a few things you will need
//       to set up.  We'll try to keep this as simple as possible and it may
//       require you to follow some instructions.
//
//
//Option 1: Can your game use a joystick to move?
//       if -no- leave the following option set to "true"
//       if -yes- change the "true" to "false" and you will need PPJoy set up.
//                if you don't know how to do that,
//                follow the guide at this link: http://www.wiili.org/index.php/GlovePIE:Comunitary_fps_script_project#How_to_setup_PPJoy
var.WASD = true
//       PLEASE NOTE: "true" will map the nunchuck to a default "WASD" setting.
//
//
//Option 2: Do you want rumble when you press the A and B buttons?
//       if -yes- leave the following option set to "true"
//       if -no- change the "true" to "false"
var.Triggerrumble = true
//
//
//Now you must set the key binding to the Wii Remote and Nunchuck.
//       **You could leave them the way they are, then just map them in game.
//               if so, just skip to "Option 3:"
//       -OR- you can change them here:
//       NOTE: the B button is auto set to the left mouse button and the A
//               button is set to the right mouse button.
//
//To change the key mappings here you have to change where it seys "key.?" to
//       what you want it to be.
//               EX: if you want the home button to be "X"
//               then change the parameter "key.Escape = Wiimote1.Home" to
//               to "key.X = Wiimote1.Home"
key.F & mouse.rightbutton = Wiimote1.A
key.B & mouse.LeftButton = Wiimote1.B
key.M = Wiimote1.Minus
key.P = Wiimote1.Plus
key.O = Wiimote1.One
key.T = Wiimote1.Two
key.Escape = Wiimote1.Home
key.Z = Wiimote1.Nunchuk.ZButton
key.C = Wiimote1.Nunchuk.CButton
if Wiimote1.HasNunchuk  //if the nunchuk is present these are the keys to set
   key.L = Wiimote1.Left
   key.U = Wiimote1.Up
   key.R = Wiimote1.Right
   key.Y = Wiimote1.Down
else                    //if the nunchuk isn't present, d-pad defaults to WASD
   key.W = Wiimote1.Up
   key.A = Wiimote1.Left
   key.S = Wiimote1.Down
   key.D = Wiimote1.Right
endif
//
//
//
//Option 3: Would you like to have "shaking" the Wii Remote and Nunchuck to
//       do something in game?
//       if -yes- continue on
//       if -no- you can be done with the setup and go to your game or there
//               are more in depth setting starting with "Option 4:"
//For a Wii Remote swing to do something, map it below:
//       EX: if you want a swing of the Remote to output "Q", change the
//       "key.G"'s in the following parameter to "key.Q"'s.
if (Wiimote1.RelAccX > 35 or < -35) or (Wiimote1.RelAccY > 35 or < -35) or (Wiimote1.RelAccZ > 35 or < -35)
   key.G = true
else
   key.G = false
   var.swing = 0
endif
//
//For a Nunchuk swing, do the same thing here:
if (Wiimote1.Nunchuk.RawAccX > 25 or < -25) or (Wiimote1.Nunchuk.RawAccY > 25 or < -25) or (Wiimote1.Nunchuk.RawAcc > 25 or < -25)
   key.N = true
else
   key.N = false
endif
//
//
//
//Option 4: How big do you want the "bounding box"?
//       set from the smallest at "1" to the largest at "10"   --default is "3"
var.box = 3
//
//Option 5: How fast do you want to turn?
//       set from the slowest at "10" to the fastest at "100"  --default is "22"
var.boxs1 = 22
//
//
//
//IF YOUR GAME DOESN'T WORK:
//If the game is listed here you can go to the following link for some further
//       instructions on how to get it to work.
//http://www.wiili.org/index.php/GlovePIE:Comunitary_fps_script_project#Specific Game Setup
//   - Half-Life
//   - (more comming soon)
//
//
//
//That's it!! ENJOY!!!!
////////////////////////////////////////////////////////////////////////////////




// various variable sets ///////////////////////////////////////////////////////
var.Nunchuckdeadzone= 0.5        // Dead zone setting for the Nunchuck
var.DisplayCoords = TRUE
var.saystate = false
var.Wiimote1present = Wiimote1.Exists
var.Nunchuck= Wiimote1.HasNunchuk
var.Classic= Wiimote1.HasClassic
var.boxs = var.boxs1 * 10        //mods turn speed var for IR section
var.box1 = var.box / 10          //mods bounding box var for IR section
var.m1 = (var.m * -1) + 11
var.m2 = (1 - (1 / var.m1)) / 2
////////////////////////////////////////////////////////////////////////////////


if (var.Wiimote1present)then  //makes sure the Wiimote is connected/////////////
    // Code for Nunchuck movement suppport
   if var.Nunchuck = true
      if var.WASD = true  //if user opts to not have analog control stick support:
         key.W = (-1.2 < Wiimote1.Nunchuk.JoyY < -var.Nunchuckdeadzone) //Joystick Up = negative Y axis
         key.A = (-1.2 < Wiimote1.Nunchuk.JoyX < -var.Nunchuckdeadzone) //Joystick Left = minus X axis
         key.S = (var.Nunchuckdeadzone < Wiimote1.Nunchuk.JoyY < 1.2)   //Joystick Down = positive Y axis
         key.D = (var.Nunchuckdeadzone < Wiimote1.Nunchuk.JoyX < 1.2)   //Joystick Right = positive X axis
      else   //if user has analog support
         PPJoy1.Analog0 = MapRange(Wiimote1.Nunchuk.JoyX, -1,1, -1,1)  //sets joystick x with deadzone
         PPJoy1.Analog1 = MapRange(Wiimote1.Nunchuk.JoyY, -1,1, -1,1)  //sets joystick y with deadzone
      endif
   endif
endif
////////////////////////////////////////////////////////////////////////////////


// Code for rumble support /////////////////////////////////////////////////////
if var.Triggerrumble = true
   if Wiimote1.A
      Wiimote1.rumble = 1
      wait 500ms
      Wiimote1.rumble = 0
   endif
   if Wiimote1.B
      Wiimote1.rumble = 1
      wait 100ms
      Wiimote1.rumble = 0
   endif
endif
////////////////////////////////////////////////////////////////////////////////


//Wiimote IR and "bounding box"/////////////////////////////////////////////////
if (Wiimote1.dot1vis & Wiimote1.dot2vis)= true      //the next 3 "ifs" sets var.dot1x to the wiimote IR AND compensates if there is two lights on the sensor bar
   var.dot1x = (Wiimote1.dot1x + Wiimote1.dot2x) / 2
endif
if (wiimote.dot1vis) = true
   var.dot1x = Wiimote1.dot1x
endif
if (wiimote.dot2vis) = true
   var.dot1x = Wiimote1.dot2x
endif
var.dot1y = wiimote.dot1y
var.wpx = ((Wiimote1.PointerX) - .5) * 2  //sets var to pionter input and mods it to conform to user input (box size)
if Wiimote1.PointerVisible but not var.PointerBump then    //if the remote is sensing IR input then...
   if var.wpx > var.box1 or < -var.box1           //if the ir is outside the "bounding box" set by user then...
     var.cnt1 = var.cnt1 + 1             //counter...
      if var.cnt1 < 2                            //makes it so it sets this variable only once right when you leave the bounding box
         var.joyx = Wiimote1.PointerX
      endif
      var.joyx1 = Wiimote1.pointerx - var.joyx    //this makes the game turn in an analog fashon independant of where the IR is as long as it leaves the "bounding box"
   else                          //if outside the
      var.cnt1 = 0                //reset counter
      var.joyx = 0               //reset var
      var.joyx1 = 0              //reset var
   endif                       //after this is what happens independant of the "bounding box"
         var.joyx2 = var.joyx2 + var.joyx1      //sets joyx1 to joyx2 so it is independant
         mouse.DirectInputX = (((var.dot1x - (var.joyx2 * var.boxs))* -1) + 500)/ 2     //sets mouse X variable with new calculations
         mouse.DirectInputY = ((var.dot1y) - 200)                                       //sets mouse Y variable
endif                   //done with IR
////////////////////////////////////////////////////////////////////////////////


// leds based on battery life 25/ 50/ 75/ 100% /////////////////////////////////
var.abatt = (Wiimote1.Battery / 2 + 4)
if var.abatt < 25
   var.aLeds = 1
endif
if var.abatt < 50 and > 24
   var.aLeds = 3
endif
if var.abatt < 75 and > 49
   var.aLeds = 7
endif
if var.abatt > 74
   var.aLeds = 15
endif
Wiimote1.leds = var.aLeds
////////////////////////////////////////////////////////////////////////////////


[edit] Specific Game Setup

This section is for setting up specific games that may need extra instruction. If you add a new game, add it to the list inside the script at the bottom.

[edit] Half-Life

I don't know if the same problem exists for other version, this is for the version downloaded from steam[2].

  • open notepad
  • paste the following text:
 joyname "Half-Life"
 joyadvanced 1
 joyadvaxisx 1
 joyadvaxisy 1
 joyadvaxisz 0
 joyadvaxisr 0
 joyadvaxisu 0
 joyadvaxisv 0
 joyforwardsensitivity -1.0
 joysidesensitivity 1.0
 joypitchsensitivity -0.25
 joyyawsensitivity -0.5
 joyforwardthreshold 0.0
 joysidethreshold 0.0
 joyyawthreshold 0.0
 joypitchthreshold 0.0
 joyadvancedupdate
  • save it as "joystick.cfg" in the half-life folder.

(for steam, this is installed under where you installed steam, Default:C:\Program Files\Steam\steamapps\(username)\half-life source\)

Personal tools