/*
Die by the Sword(gravity).PIE by Cpkppp
version 2.4
16, Mar 2008
[Features]
- Wiimote VSIM by the accelerometer
- Wiimote Vibrates while swinging(to enable it, make var.RumbleDeadzone = 1)
- Pseud analog turn by Nunchuk roll(3 levels)
- Shield motion gesture by custom movement modifier
- LED Battery indicator
_______
/______ /|
(POWER) ------ o | |
| _ | |
| _| |_ | | Climb
||_ _|--------- Sheathe Action
| |_| | | Weapon block mode
| | |
Jump -------- A |B ------ Crouch
| | |
| - 0 + _________ Glance camera
Raise camera ______/ |____________ Enter(Escape by DoubleClick)
| | |
| | |
PageUp --------- 1 | |
| | |
PageDown --------- 2 | |
|* * * * -------- Battery level
|__Wii__|/
| | |
|____|/
|
//\ _______
EDSF ---- // \ / \
\ / |) ---- Custom movement(Swing the right(right cursor key))
/ |
| ___|] ---- Custom movement modifier(See below description)
| /
| /
| |
| |
| |
| |
| |
|______/
|_|
|
[Custom movement modifier]
-Hold Z button: the shield moves to the neutral position(left cursor key)
-Hold Z button and pitch up the Nunchuk: the shield moves upward(up cursor key)
-Hold Z button and pitch down the Nunchuk: the shield moves downward(down cursor key)
-------------------------------------------------------------------------------
Control layout of Die by the Sword
-------------------------------------------------------------------------------
You need to set the control layout like as the below.
The function marked as (null) is not used on this script.
[Options]
Control : Joystick VSIM
VSIM Invert Y: No
[Movement controls]
Move forward : E
Move backward : D
Spin right : V
Spin left : A
Sidestep right: F
Sidespep left : S
Crouch : 6
Jump : 5
Climb : 1
[VSIM controls]
Weapon extend : (null)
Weapon block mode : 2
[Other controls]
Sheathe : 3
Action : 4
Show limb damage : (null)
Show compass : (null)
[Custom move controls]
Custom move 0 : Up Arrow *must be a custom movement performs shield-up
Custom move 1 : Down *must be a custom movement performs shield-down
Custom move 2 : Left Arrow *must be a custom movement performs shield-neutral
Custom move 3 : Right Arrow *must be a custom movement performs shield-swing
[Camera controls]
Normal Camera : (null)
Scout Camera : (null)
Fixed Camera(toggle) : (null)
Raised Camera(toggle) : 7
Glance Camera : 8
-------------------------------------------------------------------------------
About the setting of PPJoy
-------------------------------------------------------------------------------
PPJoy gives joystick emulation to GlovePIE. You need it to use this script and
can get it from the below link.
PPJoy - Parallel Port Joystick driver for Windows 98, Me, 2000 and XP
http://www.geocities.com/deonvdw/Docs/PPJoyMain.htm
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. Nunchuk C
button is for one of custom movements. Nunchuk Z button is a modifier/trigger
of Nunchuk pitch for other 3 custom movements. Nunchuk roll is for turning.
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 custom shield movement
-------------------------------------------------------------------------------
I explain how to make a custom shield movement that allows player to
swing the sword independently of the custom movement playing. If you don't make
it like this, it would prevent you to VSIM the sword when you are performimg
the custom movement.
In this description, I make a shield-to-upward movement. Other movement petterns
can be made with the same steps. winmedit.exe
[status icon]
O : record
|> : play
[] : stop
0. Choose a character
Default character is Enric. If you chanage it, click "Character". If you
change the color or weapon, click the face or sword.
1. Offarm record
Body :[]
Arm :[]
Offarm :O
Record only Offarm(practically means the shield). Hold keypad 8 to move the
shield up. Then click the record button at the middle and bottom. After a few
second, stop it to click the stop button next to the record button.
2. Arm tweak
Body :[]
Arm :|>
Offarm :|>
Make Arm as |>. Nothing happens but it's needed somewhat.
3. Playback
Body :[]
Arm :[]
Offarm :|>
Click the play button and confirm that you can swing the sword when the shield
movement is being performed.
4. Frame adjustment
Cut the excessive frames. If the movement is too long to perform, you can set
the entire length of it. For example, when the entire length is 50 and the
length of the shield movement is 20, you enter 20 as the entire length and
can cut the needless 30 frames.
You can directly input the frame length to click the 3 digits. The top row
numbers of the keyboard are available to enter the numbers.
If you want to slow the timing of a recorded part, click the ">" button next
to the body parts. To fastenWhen you make a mixed movement, it allows you to
coordinate the timing of each parts.
I set the frame length of shield movement as 20.
5. Save as
Save it as "Enric_sword_shieldup" or what you like.
Now you can use the motion with Nunchuk gesture after mapping it in DbtS'
"Options>Custom moves". To set other character or weapon, click the face upper
left.
If you have "Limb from Limb" and want to use the same custom movements on
every characters and weapons, Unfortunately, you must make a set of custom
movement to each characters and weapons.
I use 4 shield movements: default position, up, down and Right-to-left. This
script expects they are ready.
You can guard ogre's rectangle strike and Dark Enric's leg slash with your
shield. Coordinated movements of sword, shield and footwork reveal the
potential of this game. There are DbtS forms...
*/
//-----------------------------------------------------------------------------
// Script
//-----------------------------------------------------------------------------
//------------------------------------
// Wiimote key setting
//------------------------------------
/*
Die by the Sword can't recognize over 4 digital 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 // take a 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.6, -0.6, -1,1) //roll
PPJoy.Analog1 = -maprange(Wiimote1.gZ, 0.5, -0.5, -1,1) //pitch
// Movement
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
//------------------------------------
// Custom movement
//------------------------------------
/*
When Nunchuk Z button is pressed and Nunchuk is pitched, the shield moves up and
down.
*/
Key.Right = Wiimote1.Nunchuk.CButton // swing the shield right to left
// Nunchuk pitch deadzone
var.NunchukPitchDeadzoneUp = 0.3
var.NunchukPitchDeadzoneDown = 0.3
var.NunchukPitch = maprange(Wiimote1.Nunchuk.gz,0.7,-0.7,1,-1)
// continuous input mainly for keeping to do a custom movement of the shield
if Wiimote1.Nunchuk.ZButton then
if var.NunchukPitch > var.NunchukPitchDeadzoneUp then // keep the shield up
Key.Up = true
wait 10ms
Key.Up = false
wait 0.5s
else if var.NunchukPitch < -var.NunchukPitchDeadzoneDown then // keep the shield down
Key.Down = true
wait 10ms
Key.Down = false
wait 0.5s
else // keep the shield middle: neutral position
Key.Left = true
wait 10ms
Key.Left = false
wait 0.5s
endif
endif
//------------------------------------
// Turn
//------------------------------------
/*
You roll the Nunchuk and Enric turns. The speed of turning changes in 3 levels
by the tilt. It is not so good but works when Enric moves.
*/
// Nunchuk roll deadzone
var.NunchuklRollDeadzoneFull = 0.9
var.NunchuklRollDeadzoneMiddle = 0.7
var.NunchuklRollDeadzoneLow = 0.5
var.NunchuklRoll = maprange(Wiimote1.Nunchuk.gx,0.7,-0.7,1,-1)
// initialize the turn keys
if var.NunchuklRollDeadzoneLow > var.NunchuklRoll > -var.NunchuklRollDeadzoneLow then
Key.A = false
Key.V = false
var.NunchukRollFull = false
var.NunchukRollFullMiddle = false
endif
// Full turn with Nunchuk roll
if var.NunchuklRoll > var.NunchuklRollDeadzoneFull then // roll left
Key.A = true
var.NunchukRollFull = true
endif
if var.NunchuklRoll < -var.NunchuklRollDeadzoneFull then // roll right
Key.V = true
var.NunchukRollFull = true
endif
// Middle turn with Nunchuk roll
if not var.NunchukRollFull then
if var.NunchuklRollDeadzoneFull > var.NunchuklRoll > var.NunchuklRollDeadzoneMiddle then
var.NunchukRollFullMiddle = true
Key.A = false
wait 10ms
Key.A = true
wait 150ms
Key.A = false
wait 200ms
endif
if -var.NunchuklRollDeadzoneFull < var.NunchuklRoll < -var.NunchuklRollDeadzoneMiddle then
var.NunchukRollFullMiddle = true
Key.V = false
wait 10ms
Key.V = true
wait 150ms
Key.V = false
wait 200ms
endif
endif
// Low turn with Nunchuk roll
if (not var.NunchukRollFull) and (not var.NunchukRollFullMiddle) then
if var.NunchuklRollDeadzoneMiddle > var.NunchuklRoll > var.NunchuklRollDeadzoneLow then
Key.A = false
wait 10ms
Key.A = true
wait 50ms
Key.A = false
wait 200ms
endif
if -var.NunchuklRollDeadzoneMiddle < var.NunchuklRoll < -var.NunchuklRollDeadzoneLow then
Key.V = false
wait 10ms
Key.V = true
wait 50ms
Key.V = false
wait 200ms
endif
endif
//------------------------------------
// Rumble
//------------------------------------
/*
When you swing the Wiimote, it vibrates. If you don't like it, make
var.RumbleDeadzone as 100 then it is practically disabled.
*/
var.RumbleDeadzone = 100 // Default 1. The smaller, the more sensitive. If you don't like it, make it 100.
if (abs(Wiimote1.RelAccX) > 0) and (abs(Wiimote1.RelAccZ) > 0) then
var.Rumble = (abs(Wiimote1.RelAccX) + abs(Wiimote1.RelAccZ))/2
if var.Rumble > var.RumbleDeadzone then
Wiimote1.Rumble = true
else
Wiimote1.Rumble = false
endif
else if (abs(Wiimote1.RelAccX) > 0) xor (abs(Wiimote1.RelAccZ) > 0) then
if abs(Wiimote1.RelAccX) > abs(Wiimote1.RelAccZ) then
var.Rumble = abs(Wiimote1.RelAccX)
if var.Rumble > var.RumbleDeadzone then
Wiimote1.Rumble = true
else
Wiimote1.Rumble = false
endif
else if abs(Wiimote1.RelAccX) < abs(Wiimote1.RelAccZ) then
var.Rumble = abs(Wiimote1.RelAccZ)
if var.Rumble > var.RumbleDeadzone then
Wiimote1.Rumble = true
else
Wiimote1.Rumble = false
endif
endif
endif
//------------------------------------
// Auto dodge
//------------------------------------
/*
This part can make auto dodge to input Nunchak joystick(EDSF) near the max value,
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
*/
//------------------------------------
// Wiimote Battery Display
//------------------------------------
//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
//------------------------------------
// Debug
//------------------------------------
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
Posted by Cpkppp at 14:16│
Comments(4)│
TrackBack(0)
ApjSHJ Strange but true. Your resource is expensive. At least it could be sold for good money on its auction!....