Toro Turret
2 posters
RigidChips :: Rigid-Chips :: Files :: Turrets
Page 1 of 1
Toro Turret
The Toro Turret started with a basic recoil reduction design. It now sports a chaingun/shotgun switch, adjustable focus and rate of turn, 3 controller options, and more. There is still room for optimization in the code and some of the numbers should probably be tweaked a bit, but this is good enough for a first release.
- Code:
// [RCD]
Val
{
FOCUS0(default=-60, min=-360, max=360)
FOCUS1(default=150, min=-360, max=360)
GUN0(default=0, max=500000)
GUN1(default=0, max=500000, disp=0)
GUN10(default=0, max=500000, disp=0)
GUN11(default=0, max=500000, disp=0)
GUN2(default=0, max=500000, disp=0)
GUN3(default=0, max=500000, disp=0)
GUN4(default=0, max=500000, disp=0)
GUN5(default=0, max=500000, disp=0)
GUN6(default=0, max=500000, disp=0)
GUN7(default=0, max=500000, disp=0)
GUN8(default=0, max=500000, disp=0)
GUN9(default=0, max=500000, disp=0)
RUD(default=180, min=-400, max=400)
TILT(default=90, max=100)
}
Key
{
}
Body
{
Core() {
N:TrimF(option=1) {
W:RudderF(angle=FOCUS0) {
W:RudderF(angle=FOCUS1, name=HAND0) {
W:Arm(power=GUN0, option=50000, name=ARM0) { }
E:Frame(angle=150) {
E:Jet(angle=120, power=GUN0) { }
}
}
}
E:RudderF(angle=-FOCUS0) {
E:RudderF(angle=-FOCUS1, name=HAND1) {
E:Arm(power=GUN1, option=50000, name=ARM1) { }
W:Frame(angle=150) {
W:Jet(angle=120, power=GUN1) { }
}
}
}
}
N:TrimF(angle=30, option=1) {
W:RudderF(angle=FOCUS0) {
W:RudderF(angle=FOCUS1, name=HAND2) {
W:Arm(power=GUN2, option=50000, name=ARM2) { }
E:Frame(angle=150) {
E:Jet(angle=120, power=GUN2) { }
}
}
}
E:RudderF(angle=-FOCUS0) {
E:RudderF(angle=-FOCUS1, name=HAND3) {
E:Arm(power=GUN3, option=50000, name=ARM3) { }
W:Frame(angle=150) {
W:Jet(angle=120, power=GUN3) { }
}
}
}
}
N:TrimF(angle=60, option=1) {
W:RudderF(angle=FOCUS0) {
W:RudderF(angle=FOCUS1, name=HAND4) {
W:Arm(power=GUN4, option=50000, name=ARM4) { }
E:Frame(angle=150) {
E:Jet(angle=120, power=GUN4) { }
}
}
}
E:RudderF(angle=-FOCUS0) {
E:RudderF(angle=-FOCUS1, name=HAND5) {
E:Arm(power=GUN5, option=50000, name=ARM5) { }
W:Frame(angle=150) {
W:Jet(angle=120, power=GUN5) { }
}
}
}
}
N:TrimF(angle=90, option=1) {
W:RudderF(angle=FOCUS0) {
W:RudderF(angle=FOCUS1, name=HAND6) {
W:Arm(power=GUN6, option=50000, name=ARM6) { }
E:Frame(angle=150) {
E:Jet(angle=120, power=GUN6) { }
}
}
}
E:RudderF(angle=-FOCUS0) {
E:RudderF(angle=-FOCUS1, name=HAND7) {
E:Arm(power=GUN7, option=50000, name=ARM7) { }
W:Frame(angle=150) {
W:Jet(angle=120, power=GUN7) { }
}
}
}
}
N:TrimF(angle=120, option=1) {
W:RudderF(angle=FOCUS0) {
W:RudderF(angle=FOCUS1, name=HAND8) {
W:Arm(power=GUN8, option=50000, name=ARM8) { }
E:Frame(angle=150) {
E:Jet(angle=120, power=GUN8) { }
}
}
}
E:RudderF(angle=-FOCUS0) {
E:RudderF(angle=-FOCUS1, name=HAND9) {
E:Arm(power=GUN9, option=50000, name=ARM9) { }
W:Frame(angle=150) {
W:Jet(angle=120, power=GUN9) { }
}
}
}
}
N:TrimF(angle=150, option=1) {
W:RudderF(angle=FOCUS0) {
W:RudderF(angle=FOCUS1, name=HAND10) {
W:Arm(power=GUN10, option=50000, name=ARM10) { }
E:Frame(angle=150) {
E:Jet(angle=120, power=GUN10) { }
}
}
}
E:RudderF(angle=-FOCUS0) {
E:RudderF(angle=-FOCUS1, name=HAND11) {
E:Arm(power=GUN11, option=50000, name=ARM11) { }
W:Frame(angle=150) {
W:Jet(angle=120, power=GUN11) { }
}
}
}
}
S:Frame(angle=TILT) {
S:Frame(angle=30) {
S:Frame(angle=60) {
S:Frame(angle=90) {
N:TrimF(angle=-RUD) {
E:Trim(angle=90) {
N:Weight(angle=30) {
N:Weight(angle=-15, spring=.05, damper=.05) { }
}
E:Weight(angle=30) {
E:Weight(angle=-15, spring=.05, damper=.05) { }
}
S:Weight(angle=30) {
S:Weight(angle=-15, spring=.05, damper=.05) { }
}
}
W:Trim(angle=90) {
S:Weight(angle=-30) {
S:Weight(angle=15, spring=.05, damper=.05) { }
}
N:Weight(angle=-30) {
N:Weight(angle=15, spring=.05, damper=.05) { }
}
W:Weight(angle=-30) {
W:Weight(angle=15, spring=.05, damper=.05) { }
}
}
}
}
}
}
}
}
}
Lua
{mx,my,calib=0,0,0
i=0
form=1
FormName={"off","Linear","Web",}
control=2
ControlName={"Joystick","Arrow Key","Mouse"}
GunControl={"[C]","[C]","Left Click"}
firemode=1
FireName={"ChainGun","Shotgun"}
SensName={"Joystick throttle","[V]/[B]","[V]/[B]"}
throt=50
function doc()
out(0,"'Toro' Multipurpose Turret")
out(2, "[Q] to cycle control: ",ControlName[control])
out(3,"[W] to cycle reticle: ",FormName[form])
out(4,SensName[control]," to adjust sensitivity")
out(5,"[Z]/[X] and [A]/[S] to adjust focus/arm positioning")
out(6,"[F] to toggle firemode, ",GunControl[control]," to fire ",FireName[firemode])
end
function beams()
form=math.max(1,math.mod(form+_KEYDOWN(15),4))
_SETCOLOR(math.random(16777215))
if form==2 then
for i=0,11 do
_MOVE3D(_X(_G["ARM"..i]),_Y(_G["ARM"..i]),_Z(_G["ARM"..i]))
destx=_X(_G["ARM"..i]) - 1000* (_X(_G["HAND"..i])-_X(_G["ARM"..i]))
desty=_Y(_G["ARM"..i]) - 1000* (_Y(_G["HAND"..i])-_Y(_G["ARM"..i]))
destz=_Z(_G["ARM"..i]) - 1000* (_Z(_G["HAND"..i])-_Z(_G["ARM"..i]))
_LINE3D(destx,desty,destz)
end
end
if form==3 then
for i=0,11 do
for j=i,11 do
k=math.mod(i+j,12)
_MOVE3D(_X(_G["HAND"..i]),_Y(_G["HAND"..i]),_Z(_G["HAND"..i]))
_LINE3D(_X(_G["ARM"..k]),_Y(_G["ARM"..k]),_Z(_G["ARM"..k]))
end
end
end
end
function move()
control=math.max(1,math.mod(control+_KEYDOWN(14),4))
FOCUS0=FOCUS0+(_KEY(4)-_KEY(5))*0.125
FOCUS1=FOCUS1+(_KEY(7)-_KEY(8))*0.125
if control==1 then
throt=_ANALOG(2)+1050
RUD=math.mod(RUD-_ANALOG(0)*0.0000025*throt,360)
TILT=TILT+_ANALOG(1)*0.0000025*throt
end
if control==2 then
throt=math.min(math.max(50,throt+(_KEYDOWN(11)-_KEYDOWN(10))*250),2050)
RUD=math.mod(RUD-(_KEY(2)-_KEY(3))*0.0025*throt,360)
TILT=TILT+(_KEY(0)-_KEY(1))*0.0025*throt
end
if control==3 then
if calib==0 then
out(14,"Hold [G] and run the cursor to the bottom right of the screen to calibrate")
end
if _KEYDOWN(13)==1 then
mx,my,calib=0,0,0
end
if _KEYUP(13)==1 then
calib=1
end
if _KEY(13)==1 then
mx=math.max(_MX(),mx)
my=math.max(_MY(),my)
out(15,_MX()," -- ",_MY())
out(16,mx," -- ",my)
end
if calib==1 then
RUD=math.mod(RUD+throt*(_MX()-mx/2)*0.000025,360)
TILT=TILT+(_MY()-my/2)*0.0025
throt=math.min(math.max(50,throt+(_KEYDOWN(11)-_KEYDOWN(10))*250),2050)
end
_MOVE2D(0.15,0)
_LINE2D(-0.15,0)
_MOVE2D(0,0.125)
_LINE2D(0,-0.125)
end
end
function fire()
firemode=math.max(1,math.mod(firemode+_KEYDOWN(12),3))
FireControl={_KEY(6),_KEY(6),_ML()}
for k=0,11 do
_G["GUN"..k]=0
end
if firemode==1 then
i=math.mod(i+1,12)
if FireControl[control]==1 and _E(_G["ARM"..i])==50000 then
_G["GUN"..i]=50000
end
else
c=0
for k=0,11 do
if _E(_G["ARM"..k])==50000 then
c=c+1
end
end
if c==12 then
for k=0,11 do
_G["GUN"..k]=50000*FireControl[control]
end
else
for k=0,11 do
_G["GUN"..k]=0
end
end
end
end
function main()
doc()
beams()
move()
fire()
end}
MrSparks- Tank
- Posts : 73
Join date : 2012-01-05
Age : 34
Location : Michigan
Re: Toro Turret
Very impressive firepower, especially once I tweaked all the guns to option 100k. However, it seems a little over-engineered for the purpose, and the whole affair is quite fragile.
Rainman- Tank
- Posts : 80
Join date : 2011-02-14
Age : 31
Location : New England, US
Re: Toro Turret
Yes, it is highly over-engineered. I have a habit of doing that with my models, especially turrets. And I decided not to include the Lua that patches the fragility issue via exploit. Although, what the heck. Here's the exploitative version of the fire() function:
- Code:
function fire()
firemode=math.max(1,math.mod(firemode+_KEYDOWN(12),3))
FireControl={_KEY(6),_KEY(6),_ML()}
for k=0,11 do
_G["GUN"..k]=0
end
if firemode==1 then
i=math.mod(i+1,12)
if FireControl[control]==1 and _E(_G["ARM"..i])==50000 then
_G["GUN"..i]=50000
_SETTICKS(300)
else
_SETTICKS(100)
end
else
c=0
for k=0,11 do
if _E(_G["ARM"..k])==50000 then
c=c+1
end
end
if c==12 then
_SETTICKS(100+(200*FireControl[control]))
for k=0,11 do
_G["GUN"..k]=50000*FireControl[control]
end
else
_SETTICKS(100)
for k=0,11 do
_G["GUN"..k]=0
end
end
end
end
Last edited by MrSparks on Tue Jun 19, 2012 6:25 am; edited 1 time in total (Reason for editing : fixedc bug in shotgun)
MrSparks- Tank
- Posts : 73
Join date : 2012-01-05
Age : 34
Location : Michigan
RigidChips :: Rigid-Chips :: Files :: Turrets
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum