 |
WiiLi.org a new revolution
|
| View previous topic :: View next topic |
| Author |
Message |
wrathofzhan
Joined: 26 Dec 2007 Posts: 20
Digg It |
Posted: Wed Jun 04, 2008 1:46 am Post subject: |
|
|
| CAn someone solve this problem for me also. How can I use ppjoy for ir aming in r4 using this script? |
|
| Back to top |
|
 |
wrathofzhan
Joined: 26 Dec 2007 Posts: 20
Digg It |
Posted: Fri Jun 06, 2008 5:03 am Post subject: |
|
|
can someone tell me why this script does not work?
/*'Resident Evil 4'
by Tiger (Tiger@globaldonimation.com)
Thanks to Carl Kenner for 'IR to keys' code.
*******************************************************************************
This script is designed to map the controls of the PC version of 'Resident Evil
4' (a.k.a. 'Biohazard 4') to match the controls of the recently announced
'Resident Evil 4: Wii Edition' This script can be run without the use of any
mouse mods.
A video demonstration of this script can be seen here:
http://www.youtube.com/watch?v=eDyDC891pFM
*******************************************************************************
To use the pointing/aiming functionality, this script requires two IR sources
such as in the Wii Sensor Bar, 3rd party Sensor Bars, or two candles. To use
an unmodified Wii Sensor Bar on the PC, simply sync your Remote to your PC,
then turn on the Wii.
Controls:
D-pad = Move camera
B button = Ready weapon / Aim
C button = Ready knife
A button = Action, attack, confirm
'Minus' button = Status screen
'Plus' button = Call Ashley
'1' button = Map
'Home' button = Options, skip movies
Z button = Run (while moving forward), 180 turn (while moving backward)
B button + move Remote = Aim weapon
B button + shake Remote = Reload
C button + shake Remote = Knife attack
*/
//0 = directinput or xy = 1
if wiimote.two = true then
if var.two = false then
if var.input = 1 then
var.input = 0
else
var.input = 1
endif
endif
var.one = true
endif
if wiimote.two = false then
var.one = false
endif
pie.FrameRate = 100
//rotation deadzone
var.rn = 36
pie.MouseDPI = 1640
//smoothsoftdeadzone
var.deadzone = 1
//adjust sensitivty mousedpi/100 works best
If not var.scrmultchngd = 1 then
var.scrmult = 22
endif
//areas for IR pointing ----------------
//direct pointing area
var.czonex = (screen.Width/1.2)/var.scrmult
var.czoney = (screen.Height/1.2)/var.scrmult
//faster direct pointing area
var.izonex = (screen.Width/4)/var.scrmult
var.izoney = (screen.Height/4)/var.scrmult
//continous movment around inner area
//-------------------------------------
//speed factors-----------------------
var.cfactor = 1/30
var.ifactor = 1/30
var.0factor = 1/30
//y-axis adjustment
var.factory = 0.00002
//acceleration adjust
var.cpower = 0.002
var.ipower = 0.03
var.0power = 0.05
//-------------------------------------
//wiimoteroll convert
if var.onedot = 0
var.cos0 = var.cos
var.sin0 = var.sin
endif
var.roll = 0 - wiimote.roll
if var.roll < 0 then
var.roll = var.roll + 360
endif
var.cos = cos(var.roll)
var.sin = -sin(var.roll)
var.0cos = var.cos - var.cos0
var.0sin = var.sin - var.sin0
var.0cos = smooth(var.0cos,2)
var.0sin = smooth(var.0sin,2)
var.cos = smooth(var.cos,25)
var.sin = smooth(var.sin,25)
var.sinpitch = sin(wiimote.Pitch)
var.sinpitch = smooth(var.sinpitch,5)
if wiimote.dot1vis or wiimote.dot2vis then
//phantomdot creation if only one dot is visible
if (not wiimote.dot1vis) or (not wiimote.dot2vis) then
if var.onedot < pie.FrameRate
var.onedot ++
endif
//compensate for pitch
var.distf = 1+((abs(var.y)^1/640-1)*((abs(var.sinpitch)^1)*(var.dist-1))/(640-1))*sign(var.sinpitch)*sign(var.y)
var.px = var.cos*var.dist*var.distf
var.py = var.sin*var.dist*var.distf
if wiimote.dot1vis then
var.d0x = (640/2)- wiimote.dot1x
var.d0y = (640/2) - wiimote.dot1y
var.dot2f = 2
var.dot1f = 1
else
var.d0x = (640/2)- wiimote.dot2x
var.d0y = (640/2) - wiimote.dot2y
var.dot1f = 2
var.dot2f = 1
endif
//check which dot is which
if sqrt(sqr(var.d0x-var.d1x)+sqr(var.d0y-var.d1y))*var.dot1f > sqrt(sqr(var.d0x-var.d2x)+sqr(var.d0y-var.d2y))*var.dot2f then
var.d3x = var.d1x
var.d3y = var.d1y
var.0d3x = var.d01x
var.0d3y = var.d01y
var.0d0x = var.d02x
var.0d0y = var.d02y
else
var.d3x = var.d2x
var.d3y = var.d2y
var.0d3x = var.d02x
var.0d3y = var.d02y
var.0d0x = var.d01x
var.0d0y = var.d01y
endif
//var.roll = var.roll - var.dr
if sqrt(sqr(var.d0x+var.px-var.d3x)+sqr(var.d0y+var.py-var.d3y)) > sqrt(sqr(var.d0x-var.px-var.d3x)+sqr(var.d0y-var.py-var.d3y)) then
var.px = var.px*(-1)
var.py = var.py*(-1)
endif
if var.onedot < 3 // set to +1 0sin / 0cos smooth value
//eliminte glitches at transition form 2 to 1 ir dots visible
var.0dx = var.px - var.0d3x + var.0d0x - var.0cos*var.dist
var.0dy = var.py - var.0d3y + var.0d0y - var.0sin*var.dist
endif
var.d2x = var.d0x + var.px - var.0dx
var.d2y = var.d0y + var.py - var.0dy
var.d1x = var.d0x
var.d1y = var.d0y
else
//read IR if both dots are visible
var.onedot = 0
var.d2x = (640/2)- wiimote.dot2x
var.d2y = (640/2) - wiimote.dot2y
var.d1x = (640/2)- wiimote.dot1x
var.d1y = (640/2) - wiimote.dot1y
var.dist = sqrt(sqr(var.d1x-var.d2x)+sqr(var.d1y-var.d2y))
endif
var.rotc = acos((var.d1x-var.d2x)/sqrt(sqr(var.d1x-var.d2x)+sqr(var.d1y-var.d2y)))
if ((var.d1y-var.d2y)/sqrt(sqr(var.d1x-var.d2x)+sqr(var.d1y-var.d2y))) > 0 then
var.rotc = 360 - var.rotc
endif
var.rots = - asin((var.d1y-var.d2y)/sqrt(sqr(var.d1x-var.d2x)+sqr(var.d1y-var.d2y)))
if ((var.d1x-var.d2x)/sqrt(sqr(var.d1x-var.d2x)+sqr(var.d1y-var.d2y))) < 0 then
var.rots = 180 - var.rots
endif
if var.rots < 0 then
var.rots = 360 + var.rots
endif
var.rot = var.rotc/2 + var.rots/2
//rotation neutralization
if (360 -var.rn) > abs(var.rot - var.roll) > (var.rn) then
var.rot = var.rot - 180
if var.rot < 0 then
var.rot = 360 + var.rot
endif
var.d0x = var.d1x
var.d0y = var.d1y
var.d1x = var.d2x
var.d1y = var.d2y
var.d2x = var.d0x
var.d2y = var.d0y
endif
//store last dots
if var.onedot = 0
var.d01x = var.d1x
var.d01y = var.d1y
var.d02x = var.d2x
var.d02y = var.d2y
endif
//smooth movement
var.d1x = smooth(var.d1x,2)
var.d1y = smooth(var.d1y,2)
var.d2x = smooth(var.d2x,2)
var.d2y = smooth(var.d2y,2)
//store last coordinates
var.0x = var.x
var.0y = var.y
//coordinate calculation
var.y = ((var.d1y*var.d2x)-(var.d1x*var.d2y)) / (sqrt(sqr(var.d2x-var.d1x) + sqr(var.d2y-var.d1y)))/((640))*screen.height/var.scrmult
var.x = (sqr(var.d1x)-sqr(var.d2x)+sqr(var.d1y)-sqr(var.d2y)) / (2*(sqrt(sqr(var.d2x-var.d1x) + sqr(var.d2y-var.d1y))))/(1024)*screen.Width/var.scrmult
//NAN bug workaround
if var.x = NAN then
var.x = 0
var.0x = 0
endif
if var.y = NAN then
var.y = 0
var.0y = 0
endif
//softsmoothdeadzone
if abs(var.x-var.0x) < var.deadzone then
var.x = var.x - ((var.x-var.0x)*(1-((abs((var.deadzone-abs(var.x-var.0x))/var.deadzone)))^0.5))
var.x = smooth(var.x,4)
endif
if abs(var.y-var.0y) < var.deadzone then
var.y = var.y - ((var.y-var.0y)*(1-((abs((var.deadzone-abs(var.y-var.0y))/var.deadzone)))^0.5))
var.x = smooth(var.x,4)
endif
var.x = smooth(var.x,2)
var.y = smooth(var.y,2)
if var.input = 0 then
if abs(var.x) > var.czonex
var.x = var.x*abs(1+(abs(abs(var.x)-var.czonex)/abs(var.x))*var.cpower)*var.cfactor
endif
if abs(var.y) > var.czoney
var.y = var.y*abs(1+(abs(abs(var.y)-var.czoney)/abs(var.y))*var.cpower*var.factory)*var.cfactor
endif
endif
if var.input = 1 then
var.inputx = smooth(((var.x/screen.Width*var.scrmult)*1.5 + 0.5),3)
var.inputy = smooth(((var.y/screen.Height*var.scrmult)*1.2 + 0.5),3)
endif
//fps mouse movement
if var.input = 0 then
if abs(var.x) > var.izonex then
var.inputx = var.inputx + var.x*abs((abs((abs(var.x)-var.izonex)^var.ipower)/abs(abs(var.x)^var.ipower)))*var.ifactor
endif
if abs(var.y) > var.izoney then
var.inputy = var.inputy + var.y*abs((abs((abs(var.y)-var.izoney)^var.ipower)/abs(abs(var.y)^var.ipower)))*var.ifactor
endif
var.inputx = var.inputx + var.x - var.0x
var.inputy = var.inputy + var.y - var.0y
endif
else
//continue mouse movement if no IR visible
if var.input = 0 then
if abs(var.x) > var.izonex then
var.InputX = var.InputX + var.x*abs((abs((abs(var.x)-var.izonex)^var.ipower)/abs(abs(var.x)^var.ipower)))*var.ifactor
else
var.InputX = var.InputX + var.x*abs(1+abs(var.x)*var.0power)*var.0factor
endif
if abs(var.y) > var.izoney then
var.InputY = var.InputY + var.y*abs((abs(abs(abs(var.y)-var.izoney)^var.ipower)/abs(abs(var.y)^var.ipower)))*var.ifactor
else
var.InputY = var.InputY + var.y*abs(1+abs(var.y)*var.0power*var.factory)*var.0factor
endif
endif
endif
Left = Wiimote.Left //Camera left
Right = Wiimote.Right //Camera right
Up = Wiimote.Up //Camera up
Down = Wiimote.Down //Camera down
LeftShift = Nunchuk.CButton //Ready knife
RightShift = Wiimote.B //Ready weapon
Enter = Wiimote.A //Action, attack, confirm
F = Wiimote.Plus //Call Ashley
I = Wiimote.Minus //Status screen
M = Wiimote.One //Map
Esc = Wiimote.Home //Options, skip movies
RightCtrl = Nunchuk.ZButton //Run, 180 turn
var.IRCount = 2
//Wiimote knife
If Nunchuk.CButton
Enter = (Wiimote.RawAccX > 15) or (Wiimote.RawAccX < -15)
var.Cam = "Aim"
EndIf
//Wiimote reload
If Wiimote.B
RightCtrl = (Wiimote.RawAccX > 15) or (Wiimote.RawAccX < -15)
EndIf
// Camera/Aim
var.Cam = "Move"
If Wiimote.B
var.Cam = "Aim"
ElseIf released(Wiimote.B)
W = False
A = False
S = False
D = False
Else
var.Cam = "Move"
EndIf
If var.Cam = "Aim"
PPJoy.Analog0 = var.inputx
PPJoy.Analog1 = var.inputy
ppjoy.digital1 = wiimote.A
ElseIf var.Cam = "Move"
//Joystick movement
If Nunchuk.JoyY > 0.55
S = True
Wait 10ms
S = False
EndIf
If Nunchuk.JoyY > 0.35 and < 0.55
S = True
Wait 25ms
S = False
EndIf
If Nunchuk.JoyY > 0.15 and < 0.35
S = True
Wait 35ms
S = False
EndIf
If Nunchuk.JoyY < -0.55
W = True
Wait 10ms
W = False
EndIf
If Nunchuk.JoyY < -0.35 and > -0.55
W = True
Wait 25ms
W = False
EndIf
If Nunchuk.JoyY < -0.15 and > -0.35
W = True
Wait 35ms
W = False
EndIf
If Nunchuk.JoyX < -0.55
A = True
Wait 10ms
A = False
EndIf
If Nunchuk.JoyX < -0.35 and > -0.55
A = True
Wait 25ms
A = False
EndIf
If Nunchuk.JoyX < -0.15 and > -0.35
A = True
Wait 35ms
A = False
EndIf
If Nunchuk.JoyX > 0.55
D = True
Wait 10ms
D = False
EndIf
If Nunchuk.JoyX > 0.35 and < 0.55
D = True
Wait 25ms
D = False
EndIf
If Nunchuk.JoyX > 0.15 and < 0.35
D = True
Wait 35ms
D = False
EndIf
EndIf
var.dummy = Wiimote.RawForceX
var.dummy = Wiimote.RawForceZ
debug = ("dot1x: " + wiimote.dot1x+ " dot1y: " +wiimote.dot1y + " dot2x: " +wiimote.dot2x + " dot2y: " + wiimote.dot2y +" var.x: " +var.x + " var.y: " +var.y + " rot: " + var.rot +" roll: " + var.roll + " mouse: " + mouse.DirectInputPos +" batt: " +wiimote.Battery)
end if |
|
| Back to top |
|
 |
TigerGD
Joined: 16 Apr 2007 Posts: 72 Location: SoCal
Digg It |
Posted: Fri Jun 06, 2008 4:34 pm Post subject: |
|
|
| Does anything else work in GlovePIE? Do any other PPJoy scripts work? Are you using GlovePIE .30 or .29? This script was written for and tested in GlovePIE .29, and I don't know yet if it works in .30. |
|
| 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
|