Ravenfield

Ravenfield

117 个评价
automatic CIWS and Missile turret
   
奖励
收藏
已收藏
取消收藏
Content Type: Vehicles
标签: Modded Content
文件大小
发表于
1.813 MB
2022 年 5 月 21 日 下午 6:56
1 项改动说明 ( 查看 )

订阅以下载
automatic CIWS and Missile turret

描述
Modified attack boat with CIWS and Missile turret.

CIWS automically attacks neraby aircrafts, but when the missile is detected it tries to intercept it (not always successful due to bullet spread)

Missile turret automically launch missiles to nearby aircrafts.

Consider this as a teaser of the Vanilla+ battleship mod Sofa is going to make.






behaviour("ciwsship")
function ciwsship:Start()
self.vehicle = self.gameObject.GetComponent(Vehicle)
self.tgt=nil
self.msltgt=nil
self.cooldown=0
end

function ciwsship:Update()
if self.vehicle.hasDriver then

self.msltgt=nil
local ac=ActorManager.AliveActorsInRange(self.targets.mslturret.transform.position,900)
if #ac>0 then
for i = 1, #ac do
if ac.team~=self.vehicle.driver.team and ActorManager.ActorCanSeePlayer(ac) and ac.activeVehicle~=nil and (ac.activeVehicle.isHelicopter or ac.activeVehicle.isAirplane) and (self.msltgt==nil or Vector3.distance(ac.transform.position,self.targets.mslturret.transform.position)<Vector3.distance(self.msltgt.transform.position,self.targets.mslturret.transform.position) ) then
self.msltgt=ac.activeVehicle
end
end
end

local mslrot=self.vehicle.transform.rotation

if self.msltgt~=nil then
mslrot=Quaternion.LookRotation(self.msltgt.transform.position-self.targets.mslturret.transform.position,self.vehicle.transform.up)

if Vector3.Angle(self.msltgt.transform.position - self.targets.mslturret.transform.position, self.targets.mslturret.transform.forward) <= 1 then
local wep = self.vehicle.seats[1].weapons[1]
wep.Unholster()
wep.Shoot(false)
end

end

self.targets.mslturret.transform.rotation=Quaternion.RotateTowards(self.targets.mslturret.transform.rotation, mslrot, 180 * Time.deltaTime)

local ismsl=false
self.tgt=nil
if self.vehicle.isTrackedByMissile then
local msl = self.vehicle.GetTrackingMissiles()
for i=1,#msl do
if self.tgt==nil or Vector3.distance(msl.transform.position,self.targets.turret.transform.position)<Vector3.distance(self.tgt.transform.position,self.targets.turret.transform.position) then
self.tgt=msl
ismsl=true
end
end
else
local ac=ActorManager.AliveActorsInRange(self.targets.turret.transform.position,500)
if #ac>0 then
for i = 1, #ac do
if ac.team~=self.vehicle.driver.team and ActorManager.ActorCanSeePlayer(ac) and ac.activeVehicle~=nil and (ac.activeVehicle.isHelicopter or ac.activeVehicle.isAirplane) and (self.tgt==nil or Vector3.distance(ac.transform.position,self.targets.turret.transform.position)<Vector3.distance(self.tgt.transform.position,self.targets.turret.transform.position) ) then
self.tgt=ac
end
end
end
end

local gyrorot=self.vehicle.transform.rotation

if self.tgt~=nil then

local tgtpos=self.tgt.transform.position+self.tgt.transform.up*0.65
local tgtspd=self.tgt.velocity
local bulletspd=350

local gyroguidepos=tgtpos
for i=1,5 do
gyroguidepos=tgtpos + (Vector3.distance(gyroguidepos,self.targets.muzzle.transform.position)/bulletspd)*( tgtspd )
end

if self.cooldown==0 and Vector3.Angle(gyroguidepos - self.targets.muzzle.transform.position, self.targets.muzzle.transform.forward) <= 1 then
local blt=self.gameObject.Instantiate(self.targets.bullet, self.targets.muzzle.transform.position,Quaternion.Euler(self.targets.muzzle.transform.eulerAngles.x-1+2*math.random(),self.targets.muzzle.transform.eulerAngles.y-1+2*math.random(),self.targets.muzzle.transform.eulerAngles.z))
if ismsl==true then
local bltsc=self.script.GetScript(blt.gameObject)
bltsc.tgtmsl=self.tgt
end

blt=blt.gameObject.GetComponent(Projectile)
blt.source=self.vehicle.driver
local snd=self.targets.muzzle.gameObject.GetComponent(AudioSource)
snd.play()
self.cooldown=0.05
end

gyrorot=Quaternion.LookRotation(gyroguidepos-self.targets.turret.transform.position,self.vehicle.transform.up)

if self.cooldown>0 then
self.cooldown=self.cooldown-Time.deltaTime
if self.cooldown<=0 then
self.cooldown=0
end
end

end

self.targets.turret.transform.rotation=Quaternion.RotateTowards(self.targets.turret.transform.rotation, gyrorot, 180 * Time.deltaTime)

end
end
热门讨论 查看全部(1)
2
2024 年 4 月 30 日 上午 3:26
Download my toolspack
Hijong park
34 条留言
Sir Pasta 2024 年 7 月 25 日 下午 5:41 
This doesn't work anymore, the textures are missing and the CIWS only fires one shot ever few seconds.
SleepDeprivedJanitor :3 2022 年 9 月 5 日 上午 5:04 
You should collab with other content creators for modern ships like the type 55 destroyer
HonNguyn_ 2022 年 8 月 9 日 下午 8:00 
mortar pls
Hijong park  [作者] 2022 年 7 月 11 日 上午 1:06 
not that hard once you figure out the logic
Don'tknowwhattoput 2022 年 7 月 11 日 上午 12:45 
How long did it take for a automatic AI gunner to just shoot down missiles and planes, also how painful is it to make it
Hijong park  [作者] 2022 年 5 月 31 日 下午 1:50 
Not possible because changing engine value via script has no effect
Gazzer 2022 年 5 月 31 日 上午 8:06 
would it be possible to make the rotors and propellers on planes and helicopters continue spinning even after when the vehicle is disabled or there is no pilot and the vehicle is currently in the air? when a pilot ejects out of their vehicle the engine turns off automatically and it bothers me a tad bit
Hijong park  [作者] 2022 年 5 月 30 日 上午 3:46 
The new rhino isn't in toolspack
Gazzer 2022 年 5 月 30 日 上午 2:53 
could you do a modded version of the vanilla rhino tank where its turret ejects into the air when destroyed? i tried out beta 5 earlier and wondered why steel didnt add it to the current rhino
Hijong park  [作者] 2022 年 5 月 28 日 上午 2:16 
That's something map designers should improve