【PIE】Die by the Sword(gravity).PIE - version 2.2 Wiiリモコンの傾きで剣の操作。ヌンチャクで移動と盾の操作。
センサーバーは使わず、Wiiリモコンとヌンチャクの傾きを使ってDie by the SwordでJoystick VSIM操作するスクリプトです。PPJoyの設定の仕方も含まれています。
Wiiリモコンを傾けると剣が動きます。剣を左右に振る時は、Wiiリモコンを左右に捻り(傾け)ます。剣を上下に振る時は、Wiiリモコンを上下に傾けます。ある程度以上の加速度でWiiリモコンを動かすと、Wiiリモコンが振動します。
Die by the Sword(gravity).PIE by Cpkppp
version 2.2
12, Jan 2008
/*
Die by the Sword(gravity).PIE by Cpkppp
version 2.2
12, Jan 2008
-------------------------------------------------------------------------------
About the setting of PPJoy
-------------------------------------------------------------------------------
Install PPJoy and confirm there is "PPJoy Virtual joystick 1" in joystick
option.
Select "Modify the mapping for this controller" in the first of the PPJoy's
mapping wizard. You need to set 2 axes. Then map axes like the below in
"Define the number and type of axes...".
X axis as Axis1
Y axis as Axis2
Then set axes like the below in "Configure mapping for axes".
Analog0 as X Axis
Analog1 as Y Axis
Other PPJoy settings are not needed for this script. Also if you use WinXP,
you must set PPJoy Virtual Joystick as the default device used in an old
application, in control panel of the joystick.
About the Nunchuk thing, it just performs a custom movement which I have set
for the shield/off-arm so you need to make the similar custom movements and
set them for your custom movements.
-------------------------------------------------------------------------------
How to use
-------------------------------------------------------------------------------
[Wiimote]
Roll is for analog0(X) and pitch is for analog1(Y). When acceleration is over
var.RumbleDeadzone, the wiimote vibrates.
[Nunchuk]
If you have a nunchuk you can use it together. Joystick is for EDSF. C and Z
are for turning right or left. Roll and pitch are for mainly custom movement.
[etc.]
Wiimote's LEDs show battery level.
Note:
Since wiimote doesn't capture Yaw movement without IR sensor bar,
roll movement is used for x axis: you need to roll/twist the wiimote to input
x axis. But you can swing your arm to have the vibrate longer, rolling the
wiimote.
-------------------------------------------------------------------------------
How to make a shield movement
-------------------------------------------------------------------------------
I will explain how to make a keep-the-shield-up movement that allows player to
swing the sword independently of the custom movement playing.
Firstly, make only the Offarm/shield record then record it to hit keypad 8 to
move the shield up.
Secondly, make Body record(red triangle), Arm stop(square) and Offarm
play(yellow triangle) then record it until the shield's play ends.
Thirdly, cut the excessive frames. I set the frame length about 20.
Now you can use it with Nunchak motion after mapping it in DbtS configuration.
Btw I use 4 shield movements; up, down, right-to-left and default position.
*/
//-----------------------------------------------------------------------------
// Key setting
//-----------------------------------------------------------------------------
// Wiimote key setting
// Die by the Sword can't recognize over 4 buttons of joystick, so I recomend you
// to use keyboard for the assign, not PPJoy.Digital*.
Key.One = Wiimote1.Up
Key.Two = Wiimote1.Down
Key.Three = Wiimote1.Left
Key.Four = Wiimote1.Right
Key.Five = Wiimote1.A
Key.Six = Wiimote1.B
Key.Seven = Wiimote1.Minus
Key.Eight = Wiimote1.Plus
//Key.ScrollLock = Wiimote1.Minus // for screenshot with Fraps
// to select the savedata in Quest
Key.Enter = Wiimote1.Home
Key.Escape = DoubleClicked(Wiimote1.Home)
Key.PageUp = Wiimote1.One
Key.PageDown = Wiimote1.Two
PPJoy.Analog0 = maprange(Wiimote1.gX, 0.7, -0.7, -1,1) //roll
PPJoy.Analog1 = -maprange(Wiimote1.gZ, 0.5, -0.5, -1,1) //pitch
// Nunchuk key setting
Key.Space = Wiimote1.Nunchuk.CButton
Key.Shift = Wiimote1.Nunchuk.ZButton
var.NunchukJoyDeadzone = 0.3
Key.F = Wiimote1.Nunchuk.JoyX > var.NunchukJoyDeadzone
Key.S = Wiimote1.Nunchuk.JoyX < -var.NunchukJoyDeadzone
Key.D = Wiimote1.Nunchuk.JoyY > var.NunchukJoyDeadzone
Key.E = Wiimote1.Nunchuk.JoyY < -var.NunchukJoyDeadzone
/*
This part can make dodge easy to input EDSF near the max input of joystick,
though I don't use it.
// Nunchuk dodge setting
var.DodgeDeadzone = 0.92
if DoubleClicked(Wiimote1.Nunchuk.JoyX > var.DodgeDeadzone) then
Key.F = false
wait 10ms
Key.F = true
wait 10ms
Key.F = false
wait 10ms
Key.F = true
wait 10ms
Key.F = false
endif
if DoubleClicked(Wiimote1.Nunchuk.JoyX < -var.DodgeDeadzone) then
Key.S = false
wait 10ms
Key.S = true
wait 10ms
Key.S = false
wait 10ms
Key.S = true
wait 10ms
Key.S = false
endif
if DoubleClicked(Wiimote1.Nunchuk.JoyY > var.DodgeDeadzone) then
Key.D = false
wait 10ms
Key.D = true
wait 10ms
Key.D = false
wait 10ms
Key.D = true
wait 10ms
Key.D = false
endif
if DoubleClicked(Wiimote1.Nunchuk.JoyY < -var.DodgeDeadzone) then
Key.E = false
wait 10ms
Key.E = true
wait 10ms
Key.E = false
wait 10ms
Key.E = true
wait 10ms
Key.E = false
endif
*/
// Nunchuk tilt setting
var.NunchukTiltDeadzonePitch = 0.5
var.NunchukTiltDeadzoneRoll = 0.7
// continuous input mainly for keeping to do a custom movement of the shield
if Wiimote1.Nunchuk.gz > var.NunchukTiltDeadzonePitch then // pitch up
Key.Up = true
wait 10ms
Key.Up = false
wait 0.5s
else if Wiimote1.Nunchuk.gz < -var.NunchukTiltDeadzonePitch then // pitch down
Key.Down = true
wait 10ms
Key.Down = false
wait 0.5s
else if Wiimote1.Nunchuk.gx > var.NunchukTiltDeadzoneRoll then // roll left
Key.Left = true
wait 10ms
Key.Left = false
wait 0.5s
else if Wiimote1.Nunchuk.gx < -var.NunchukTiltDeadzoneRoll then // roll right
Key.Right = true
wait 10ms
Key.Right = false
wait 0.5s
endif
// rumble code
var.RumbleDeadzone = 2 // the smaller, the more sensitive
if (abs(Wiimote1.RelAccX) > var.RumbleDeadzone) or (abs(Wiimote1.RelAccZ) > var.RumbleDeadzone) then
Wiimote1.Rumble = true
else
Wiimote1.Rumble = false
endif
// debug code
debug = "PPJoy.Analog0: " + PPJoy.Analog0 + " PPJoy.Analog1: " + PPJoy.Analog1 + " RelAccX: " + Wiimote1.RelAccX + "RelAccY: " +Wiimote1.RelAccY + "RelAccZ: " +Wiimote1.RelAccZ + "NunGX: " + Wiimote1.Nunchuk.gX + " NunGZ: " + Wiimote1.Nunchuk.gZ + " NunJoyX " + Wiimote1.Nunchuk.JoyX + " NunJoyY " + Wiimote1.Nunchuk.JoyY
//-----------------------------------------------------------------------------
// Battery display code
//-----------------------------------------------------------------------------
//Wiimote Battery Display
//by J.Coulston
// Modified by Carl Kenner for GlovePIE 0.25
// use up battery power :-)
// comment out this line if you don't need it
//wiimote1.Rumble = shift
//A full battery gives 0xC0 (192)
var.Batt = wiimote1.Battery / 48
if true then
wait 5 seconds
//it sends an instruction that tells the Wiimote to actually
//send the report.
wiimote1.Report15 = 0x80 | Int(wiimote1.Rumble)
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
wiimote1.Leds = 1
//wait var.Blink
//wiimote1.Leds = 0
//wait var.Blink
elseif 0.25 < var.Batt<=1 then
wiimote1.Leds = 1
elseif 1 < var.Batt<=1.25 then
wiimote1.Leds = 3
//wait var.Blink
//wiimote1.Leds = 1
//wait var.Blink
elseif 1.25 < var.Batt<=2 then
wiimote1.Leds = 3
elseif 2 < var.Batt<=2.25 then
wiimote1.Leds = 7
//wait var.Blink
//wiimote1.Leds = 3
//wait var.Blink
elseif 2.25 < var.Batt<=3 then
wiimote1.Leds = 7
elseif 3 < var.Batt<=3.25 then
wiimote1.Leds = 15
//wait var.Blink
//wiimote1.Leds = 7
//wait var.Blink
elseif 3.25 < var.Batt<=4 then
wiimote1.Leds = 15
else
wiimote1.Leds = 0
endif
Posted by Cpkppp at 01:59│
Comments(5)│
TrackBack(0)
この記事へのトラックバックURL
http://trackback.blogsys.jp/livedoor/b2pencil/299470
e9cdtU As I have expected, the writer blurted out..!!
コンバージョンレンズ
アウトドア腕時計
I think there is no error or something like that in the script because I can play DbtS with it. I guess you have BlueSoleil and you got some trouble of the stack. Sorry to reply your message.
Hello, I was trying to follow your guide on how to use Wii mote to play Die By the Sword and I must say, that I was rather unssuccesfull:-( ... I either didnt manage to detect the movements of the Wiimote at all or I gust got some strange readings and GlovePIE found many errors in your script. All of them about not valid value of something ... the Wii mote was vibrating every time I tilted it and the blue light signals were all blinking fastly ...