 |
WiiLi.org a new revolution
|
| View previous topic :: View next topic |
| Author |
Message |
elmerohueso
Joined: 05 Mar 2007 Posts: 8
Digg It |
Posted: Tue Mar 06, 2007 6:59 am Post subject: Halo: Combat Evolved script |
|
|
This is my first script for Halo. The mouse movement is not perfect, but it's a good start I think. The mouse movement is based on scripts by US of Anarchy and Hezzech. When you reach the edge of the screen, your view will continue to move horizontally in the direction you were moving (kind of slowly, which I'm trying to fix) until you bring the mouse back onto the screen. It is kind of jumpy when you try to bring your cursor back on screen, and I'm working on that too. I also want to implement an LED battery indicator. Try it out and let me know what you think.
| Code: | /*Halo: Combat Evolved for GlovePIE and PPjoy
Use the default controls in Halo.
Movement controls are mapped to the joystick either as emulated
WASD keys or as analog axis for more precision (requires a PPjoy
virtual joystick with 2 axis with Analog0 as the X axis and Analog1
as the Y axis))
Button controls are as follows:
A = Throw Grenade
B = Fire Weapon
Switch Grenade = Left or Right
Switch Weapon = Down
Reload = +
Melee Attach = 2
Exchange Weapon = -
Jump = C
Crouch = Z
Flashlight = 1
Scope Zoom = Up
Action = Home
*/
// Leds 1 and 4 show script is running
wiimote.Leds = 9
// Movement configuration
// Uncomment the following 2 lines to map the analog stick to PPjoy
PPJoy1.Analog0 = MapRange(Wiimote.Nunchuk.JoyX, -1,1, -1,1)
PPJoy1.Analog1 = MapRange(Wiimote.Nunchuk.JoyY, -1,1, -1,1)
// Uncomment the following 4 lines to make the analog stick emulate WASD
//A = (-1.2 < wiimote.Nunchuk.JoyX < -0.5)
//D = (0.5 < wiimote.Nunchuk.JoyX < 1.2)
//W = (-1.2 < wiimote.Nunchuk.JoyY < -0.5)
//S = (0.5 < wiimote.Nunchuk.JoyY < 1.2)
// Button Configuration
Space = Wiimote.Nunchuk.CButton
LeftControl = Wiimote.Nunchuk.ZButton
Z = Wiimote.Up
Tab = Wiimote.Down
G = Wiimote.Left
G = Wiimote.Right
Mouse.ReftButton = Wiimote.A
Mouse.LeftButton = Wiimote.B
Wiimote.Rumble = Wiimote.B
R = Wiimote.Plus
X = Wiimote.Minus
E = Wiimote.Home
Q = Wiimote.One
F = Wiimote.Two
if wiimote.dot1vis then
var.oldx = var.x
var.oldy = var.y
var.x = ((1024 -(wiimote.dot1x))*screen.width/3072)
var.y = round(wiimote.dot1y)*screen.height/2304
var.xdiff = (var.x - var.oldx)
var.ydiff = (var.y - var.oldy)
Mouse.DirectInputX = Mouse.DirectInputX + var.xdiff
Mouse.DirectInputY = Mouse.DirectInputY + var.ydiff
endif
Mouse.DirectInputX = Mouse.DirectInputX + var.xdiff |
Any help from other coders would be helpful.
I think the most accurate cursor would have to base all movements from the center of the screen, but that's way beyond me! |
|
| Back to top |
|
 |
elmerohueso
Joined: 05 Mar 2007 Posts: 8
Digg It |
Posted: Tue Mar 06, 2007 6:06 pm Post subject: Perfected |
|
|
This is my new 'almost perfect' script for Halo. I borrowed some code from other scripts, but I tried to give credit in the comments.
| Code: | /*Halo: Combat Evolved for GlovePIE and PPjoy compiled by B.Bone
With script inserts written/inspired by J.Coulston, US of Anarchy,
Rmanqueros, and Hezzech
Use the default controls in Halo.
Movement controls are mapped to the joystick either as emulated
WASD keys or as analog axis for more precision (requires a PPjoy
virtual joystick with 2 axis with Analog0 as the X axis and Analog1
as the Y axis))
Button controls are as follows:
A = Throw Grenade
B = Fire Weapon
Switch Grenade = Left or Right
Switch Weapon = Down
Reload = +
Melee Attach = 2
Exchange Weapon = -
Jump = C
Crouch = Z
Flashlight = 1
Scope Zoom = Up
Action = Home
*/
// Movement configuration
// Uncomment the following 2 lines to map the analog stick to PPjoy
PPJoy1.Analog0 = MapRange(Wiimote.Nunchuk.JoyX, -1,1, -1,1)
PPJoy1.Analog1 = MapRange(Wiimote.Nunchuk.JoyY, -1,1, -1,1)
// Uncomment the following 4 lines to make the analog stick emulate WASD
//A = (-1.2 < wiimote.Nunchuk.JoyX < -0.5)
//D = (0.5 < wiimote.Nunchuk.JoyX < 1.2)
//W = (-1.2 < wiimote.Nunchuk.JoyY < -0.5)
//S = (0.5 < wiimote.Nunchuk.JoyY < 1.2)
// Button Configuration
Space = Wiimote.Nunchuk.CButton
LeftControl = Wiimote.Nunchuk.ZButton
Z = Wiimote.Up
Tab = Wiimote.Down
G = Wiimote.Left
G = Wiimote.Right
Mouse.RightButton = Wiimote.A
Mouse.LeftButton = Wiimote.B
// Wiimote rumbles when you shoot
Wiimote.Rumble = Wiimote.B
R = Wiimote.Plus
X = Wiimote.Minus
E = Wiimote.Home
Q = Wiimote.One
F = Wiimote.Two
if wiimote.dot2vis then
// Your cursor turns you character about 365 degrees laterally
var.posX=round((screen.Width*(1024-(wiimote.dot2x/1024/1.5))))
var.posY=round(screen.Height*(wiimote.dot2y/768/2))
var.MouseDxPosX=mouse.DirectInputX
var.MouseDxPosY=mouse.DirectInputY
var.incX=(var.posX-var.MouseDxPosX)
var.incY=(var.posY-var.MouseDxPosY)
Mouse.DirectInputX=mouse.DirectInputX+var.incX+var.xoff
Mouse.DirectInputY=mouse.DirectInputY+var.incY
var.xoff=0
else
// Once your cursor goes out of view, you will continue rotating
var.xoff=mouse.DirectInputX+var.incX
Mouse.DirectInputX=var.xoff
endif
//Wiimote Battery Display
//by J.Coulston
//Modified by Carl Kenner for GlovePIE 0.25
//A full battery gives 0xC0 (192)
var.Batt = wiimote.Battery / 48
if true then
wait 5 seconds
//it sends an instruction that tells the Wiimote to actually
//send the report.
Wiimote.Report15 = 0x80
end if
//Display the battery level of your wiimote using the four LEDs on the bottom.
//Battery level is displayed in four levels increasing to the right, like a cell
//phone battery gauge. As the battery gets close to the next level down, the LED
//for the current level will blink.
//Blink rate
var.Blink = 500ms
debug = "Battery level: " + 100*48*var.Batt/192 + "%"
if 0<=var.Batt<=0.25 then
Wiimote.Leds = 1
wait var.Blink
Wiimote.Leds = 0
wait var.Blink
elseif 0.25 < var.Batt<=1 then
Wiimote.Leds = 1
elseif 1 < var.Batt<=1.25 then
Wiimote.Leds = 3
wait var.Blink
Wiimote.Leds = 1
wait var.Blink
elseif 1.25 < var.Batt<=2 then
Wiimote.Leds = 3
elseif 2 < var.Batt<=2.25 then
Wiimote.Leds = 7
wait var.Blink
Wiimote.Leds = 3
wait var.Blink
elseif 2.25 < var.Batt<=3 then
Wiimote.Leds = 7
elseif 3 < var.Batt<=3.25 then
Wiimote.Leds = 15
wait var.Blink
Wiimote.Leds = 7
wait var.Blink
elseif 3.25 < var.Batt<=4 then
Wiimote.Leds = 15
else
Wiimote.Leds = 0
endif |
|
|
| Back to top |
|
 |
|
|
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
|