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 

Analog Racing Script - Without the hassle of PPJoy!
Goto page 1, 2  Next
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts
View previous topic :: View next topic  
Author Message
US of Anarchy



Joined: 13 Dec 2006
Posts: 41

Digg It
PostPosted: Thu Jan 11, 2007 3:15 am    Post subject: Analog Racing Script - Without the hassle of PPJoy!

I've been trying to come up with a good, simple racing script without the use of PPJoy, as I find PPJoy to be a hassle. The key was relating the time in between presses of the arrow keys to the tilt. This was done by dividing a constant by the rawaccz value to result in a number that gets smaller the further it is tilted - Less time in between presses and thus sharper turning.
Here's the script:

Code:
//Analog Racing Script 1.2 by Freeman Speaketh/US of Anarchy
//Feel free to modify and redistribute, but leave this here

//Debug
debug = "Tilt = " + wiimote.smoothpitch + ", Digital = " + var.digital

//Adjusts speed of steering (in percent)
var.speed = 100
//Adjusts minimum tilt to steer at all (in degrees)
var.min = 5
//Adjusts the most you want the wheel to turn (in degrees)
var.max = 70
//Adjusts rumble (set to -1 for off)
var.rumble = 15

//Single click the Home button to quit program, double click to exit GlovePIE
if doubleclicked(wiimote.Home)
ExitPie
else if singleclicked(wiimote.Home)
ExitProgram
endif

//Turning
var.digital = 100 / var.speed * (100 - math.abs(math.maprange(wiimote.smoothpitch,-var.max,var.max,-100,100)))

if wiimote.smoothpitch > var.min
keyboard.right = 1
wait 1 ms
keyboard.right = 0
wait var.digital ms

else if wiimote.smoothpitch < - var.min
keyboard.left = 1
wait 1 ms
keyboard.left = 0
wait var.digital ms
endif

//LEDs
if math.abs(var.digital) <= 20
wiimote.leds = 15
else if 20 < math.abs(var.digital) <= 40
wiimote.leds = 7
else if 40 < math.abs(var.digital) <= 60
wiimote.leds = 3
else if 60 < math.abs(var.digital) <= 80
wiimote.leds = 1
else if 80 < math.abs(var.digital) <= 100
wiimote.leds = 0
endif

//Accelerate and reverse

if wiimote.two
keyboard.up = 1
keyboard.up = 0
endif

if wiimote.One
keyboard.down = 1
keyboard.down = 0
endif

//Rumble
if wiimote.two and var.rumble > 0
wiimote.rumble = 1
wait 10 ms
wiimote.rumble = 0
wait var.rumble ms
keyboard.up = 0
endif

if wiimote.One and var.rumble > 0 and not wiimote.two
wiimote.rumble = 1
wait 10 ms
wiimote.rumble = 0
wait var.rumble ms
endif

//Other Key assignments
Keyboard.Escape = Wiimote.Plus


Adjust the variables at the top to work for your game (I tested it with TrackMania, and it worked well, but other games may vary). No key assignments besides pause, but those are easy to add. Enjoy.


Last edited by US of Anarchy on Sun Feb 04, 2007 9:53 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail
Zac-uk



Joined: 09 Jan 2007
Posts: 26

Digg It
PostPosted: Thu Jan 11, 2007 3:50 pm    Post subject:

Alright! Ill test this out on a few PSX racing games, gran tourismo and colin macrae rally seem too sensitive for them, ill try these out on a variety of games and maybe me and you could help to configure the script to suit a lot of different racing games.

EDIT
Ok, i tweaked the buttons a little to suit Gran Tourismo II for the PSX, i agree its a nice simple script yet i have problems, even when i hold still the remote or leave it on the floor, the car on the game swerves left and right, is there anyway to maybe create a deadzone that doesnt detect movements? Maybe from the flat horizontal pose to maybe 45 degrees?
Back to top
View user's profile Send private message
US of Anarchy



Joined: 13 Dec 2006
Posts: 41

Digg It
PostPosted: Thu Jan 11, 2007 8:17 pm    Post subject:

Yea just make the var.min variable higher.
Back to top
View user's profile Send private message Send e-mail
US of Anarchy



Joined: 13 Dec 2006
Posts: 41

Digg It
PostPosted: Sun Jan 14, 2007 2:58 am    Post subject:

I uploaded version 1.1 which is far better. It now uses the actual angle of the wiimote in degrees to do the turning, which means it is more easily customizable. Also, you can adjust the speed of turning simply by changing the variable var.speed, which is in a percentage for easy use.

Anyhoo check it out on the first post.
Back to top
View user's profile Send private message Send e-mail
US of Anarchy



Joined: 13 Dec 2006
Posts: 41

Digg It
PostPosted: Sun Jan 14, 2007 11:29 pm    Post subject:

Thanks for the replies, guys Crying or Very sad
Back to top
View user's profile Send private message Send e-mail
Vattu



Joined: 11 Jan 2007
Posts: 96

Digg It
PostPosted: Tue Jan 30, 2007 12:10 pm    Post subject:

I've written an alternative script for racing games.

I use a different approach in calculating the angle the wiimote is tilted, and also the steering-algorithm.

This script should work for any race game, but mine is just tested for FlatOut2. Use it at your own risk!

Code:
/*  ~~~ Racing script ~~~

v1.0

Author: Vattu

Please follow the instructions below before playing!*/

/* ----- Balance calibration: ----- */
// Put the wiimote flat on a level surface, button-side up.
// Change the values below so that the 2 values in debug show 0.
var.yOffset = -32 //first value
var.zOffset = 6   //second value

/* ----- Outer deadzone: ----- */
// Put the wiimote on a level surface, button-side down.
// Change the value below to the first value that debug shows.
var.YoDZ = -52

// Put the wiimote on a level surface, IR-sensor-side up.
// Change the value below to the second value that debug shows.
var.ZoDZ = 27

/* ----- Inner deadzone: ----- */
// Choose this to whatever you want. (Between 0 and 180).
var.iAngle = 5

/* ----- Angle of freedom (from center): ----- */
// Choose this to whatever you want. (Between inner deadzone angle and 180).
var.fAngle = 100

/* ----- Sampling time: ----- */
// Try different values while playing the game (milliseconds).
var.sTime = 100

/* ----- Rumble ----- */
// If you want your wiimote to rumble when turning max,
// assign 1 to the value below, otherwise 0.

var.rumble = 1

/* ----- Button assignment ----- */
// Change below to your desired configuration!

b = Wiimote.Left    //Look behind
h = Wiimote.A       //HandBrake
n = Wiimote.B       //Nitrous
w = Wiimote.2       //Accelerate
s = Wiimote.1       //Brake/reverse
t = Wiimote.Down    //Race status
c = Wiimote.Plus    //Change view
r = Wiimote.Minus   //Reset car
Esc = Wiimote.Home  //Escape-button (pauses the race)
a = var.left        //Turn left
d = var.right       //Turn right

/* This is the end of the calibration. Happy playing! */
////////////////////////////////////////////////////////

var.yRot = Wiimote.RawForceY + var.yOffset
var.zRot = Wiimote.RawForceZ + var.zOffset

var.yRots = EnsureMapRange(var.yRot, 0, var.YoDZ, 0, 1)

var.pAngle = EnsureRange(acos(-2*var.yRots+1)*sign(var.zRot), -var.fAngle, var.fAngle)

var.pHold = var.sTime*abs(var.pAngle/var.fAngle)
var.pRelease = var.sTime-var.pHold

if var.pHold = var.sTime and var.rumble
  wiimote.rumble = 1
  wait 1 ms
  wiimote.rumble = 0
endif

if var.pAngle > var.iAngle        // turn right
  var.right = true
  wait var.pHold ms
  var.right = false
  wait var.pRelease ms
else if -var.pAngle > var.iAngle  // turn left
  var.left = true
  wait var.pHold ms
  var.left = false
  wait var.pRelease ms
else                              // do nothing if wiimote is level
  wait var.sTime ms
endif

debug = var.yRot+', '+var.zRot
Back to top
View user's profile Send private message
plumpman



Joined: 28 Jan 2007
Posts: 8

Digg It
PostPosted: Tue Jan 30, 2007 5:09 pm    Post subject:

That script posted above has many problems, and only works ok. I'm going to try the one in the first post to see the differance.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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