WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FPSGames: NoIR+Noslidewhilemoving+DynamicMouseSpeed edition

 
Post new topic   Reply to topic    WiiLi.org Forum Index -> GlovePie
View previous topic :: View next topic  
Author Message
Lotti



Joined: 08 Jan 2007
Posts: 17

Digg It
PostPosted: Sun Jan 28, 2007 12:54 pm    Post subject: FPSGames: NoIR+Noslidewhilemoving+DynamicMouseSpeed edition

well this script is nothing special but is better than other scripts made by insane people that just use to copy&paste code without understand it and without giving credits.. (i found scripts with some documented unused variables..)

what i did to the script made by kasten:
- Rewrote the nunchuk analog movement. now you won't slide in the game (expect for hl2.. you have to push up the glovepie process priority to high. this because hl2 takes almost total control of the cpu)

- dynamic speed increase for the wiimote mouse emulation. the mouse will move as fast as how much you turn/move the wiimote.

- automatic configuration of wiimote's offsets (thanks to TaggeD)

pls give me feedbacks. thanks

Code:

// FPSGame by Kasten, improved by Lotti
// Thanks to TaggeD for the automatic configuration of the wiimote's offsets

// Motion Mouse
// Manual Configuration
// When configuring the offsets please put the wiimote flat and do not move it.
// These are offsets change them so that your debug output reads 0,28,0
// The debug output is at the top of this window.
// Ex if you get -7,33,-6 then change the offsets to 7,-5,6

var.xNunchukOffset = 5
var.yNunchukOffset = -3
var.zOffset = 4

var.xRot = Wiimote.RawForceX + var.xNunchukOffset
var.yRot = Wiimote.RawForceY + var.yNunchukOffset
var.zRot = Wiimote.RawForceZ + var.zOffset

debug = 'X:' + var.xRot + ', ' + 'Y:' + var.yRot + ', ' + 'Z:' + var.zRot

// Automatic Configuration
// Simple press - and + buttons on wiimote before start playing

if Wiimote.Minus && Wiimote.Plus then
var.xNunchukOffset = -Wiimote.RawForceX
var.zOffset = -Wiimote.RawForceZ
var.yNunchukOffset = -Wiimote.RawForceY + 28
endif

// Change this if you would like your mouse to go faster
var.xMinSpeed = 1
var.xMaxSpeed = 5
var.xSpeedDivision = 27    //default 27
var.zMinSpeed = 1
var.zMaxSpeed = 5
var.zSpeedDivision = 27    //default 27

// change these to a higher number if your hands are not steady or lower if they are
var.xCutoff = 4
var.zCutoff = 4

// X/Y offsets for Analog. If it's too sensitive then make the numbers larger.
var.xNunchukOff = .07
var.yNunchukOff = .07

//Switch off the leds
Wiimote.leds = 0

//
// Game buttons.
//

mouse.LeftButton = Wiimote.B
mouse.RightButton = Wiimote.A
mouse.WheelUp = Wiimote.Plus
mouse.WheelDown = Wiimote.Minus
mouse.WheelUp = Wiimote.Right
mouse.WheelDown = Wiimote.Left
key.Escape = Wiimote.Two

key.e = Wiimote.Down
key.Space = Wiimote.Up
key.q = Wiimote.Nunchuk.CButton
key.Shift = Wiimote.Nunchuk.ZButton

//
// Analog Movements
//

   if Wiimote.Nunchuk.JoyX < -var.xNunchukOff then
      key.a = true
      else key.a = false
   endif
   if Wiimote.Nunchuk.JoyX > var.xNunchukOff then
      key.d = true
      else key.d = false
   endif
   if Wiimote.Nunchuk.JoyY < -var.yNunchukOff then
      key.w = true
      else key.w = false
   endif
   if Wiimote.Nunchuk.JoyY > var.yNunchukOff then
      key.s = true
      else key.s = false
   endif

//
// Reload
//

if Wiimote.Nunchuk.RawForceY > 60 then
  key.r = true
  Wiimote.Rumble = true
  Wiimote.Leds = 15
else
  key.r = false
  Wiimote.Rumble = false
  Wiimote.Leds = 0
endif

// This is the code that moves your mouse
var.xSpeedInc=(var.xMaxSpeed-var.xMinSpeed)/var.xSpeedDivision
var.zSpeedInc=(var.zMaxSpeed-var.zMinSpeed)/var.zSpeedDivision

var.xSpeed=var.xMinSpeed+abs(var.xRot)*var.xSpeedInc
var.zSpeed=var.zMinSpeed+abs(var.zRot)*var.zSpeedInc

if var.xRot > var.xCutoff then mouse.x = mouse.x - .001 * var.xSpeed * (var.xRot - var.xCutoff)
if var.xRot < -var.xCutoff then mouse.x = mouse.x - .001 * var.xSpeed * (var.xRot + var.xCutoff)
if var.zRot > var.zCutoff then mouse.y = mouse.y - .001 * var.zSpeed * (var.zRot - var.zCutoff)
if var.zRot < -var.zCutoff then mouse.y = mouse.y - .001 * var.zSpeed * (var.zRot + var.zCutoff)

//debug = 'X:' + var.xRot + ', ' + 'Z:' + var.zRot


Last edited by Lotti on Sun Jan 28, 2007 10:13 pm; edited 3 times in total
Back to top
View user's profile Send private message
TaggeD



Joined: 27 Jan 2007
Posts: 2

Digg It
PostPosted: Sun Jan 28, 2007 5:18 pm    Post subject: Nice work

well done on the script, it is quite annoying when people simply copy and paste, but we can't all be programmers Wink

Just one helpful modification.. Instead of having the user require editing the script for calibration (offsets), you should have this automatic. Quick rundown

if var.RunOnce is 0 then
//
if Wiimote.A then
var.xOffset = Wiimote.RawForceX
var.zOffset = Wiimote.RawForceZ
var.yOffset = Wiimote.RawForceY - 28
var.RunOnce = 1
endif
//
endif

That would produce a script which run for the first time required the user to steady the wiimote then press A. It's 3am in the morning over in Australia, so excuse me if I did something wrong.. If I did, just check out my first script (posted on the forum) it adds 2 features that I believe are very important for Wiimote Scripts and easily documented for non-programmers to copy/paste Very Happy

Otherwise, nice work on the modification! The more scripts the better I say, helps advance the Wii/PC community.
TaggeD
Back to top
View user's profile Send private message
Lotti



Joined: 08 Jan 2007
Posts: 17

Digg It
PostPosted: Sun Jan 28, 2007 5:39 pm    Post subject:

thanks for your feedback. your idea is pretty good and i'll add it. now you just made me curious about your works and i'll go to see them Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> GlovePie All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group