CTv0.1.2w

This commit is contained in:
funkyfranky 2018-10-29 16:25:09 +01:00
parent ae754fe334
commit 5f40feb1af
2 changed files with 61 additions and 18 deletions

View File

@ -118,15 +118,21 @@ do -- UserSound
--- Play the usersound to the given @{Wrapper.Group}. --- Play the usersound to the given @{Wrapper.Group}.
-- @param #USERSOUND self -- @param #USERSOUND self
-- @param Wrapper.Group#GROUP Group The @{Wrapper.Group} to play the usersound to. -- @param Wrapper.Group#GROUP Group The @{Wrapper.Group} to play the usersound to.
-- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0.
-- @return #USERSOUND The usersound instance. -- @return #USERSOUND The usersound instance.
-- @usage -- @usage
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" ) -- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
-- local PlayerGroup = GROUP:FindByName( "PlayerGroup" ) -- Search for the active group named "PlayerGroup", that contains a human player. -- local PlayerGroup = GROUP:FindByName( "PlayerGroup" ) -- Search for the active group named "PlayerGroup", that contains a human player.
-- BlueVictory:ToGroup( PlayerGroup ) -- Play the sound that Blue has won to the player group. -- BlueVictory:ToGroup( PlayerGroup ) -- Play the sound that Blue has won to the player group.
-- --
function USERSOUND:ToGroup( Group ) --R2.3 function USERSOUND:ToGroup( Group, Delay ) --R2.3
trigger.action.outSoundForGroup( Group:GetID(), self.UserSoundFileName ) Delay=Delay or 0
if Delay>0 then
SCHEDULER:New(nil, USERSOUND.ToGroup,{self, Group}, Delay)
else
trigger.action.outSoundForGroup( Group:GetID(), self.UserSoundFileName )
end
return self return self
end end

View File

@ -201,7 +201,7 @@ CARRIERTRAINER.MenuF10={}
--- Carrier trainer class version. --- Carrier trainer class version.
-- @field #string version -- @field #string version
CARRIERTRAINER.version="0.1.2" CARRIERTRAINER.version="0.1.2w"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@ -384,6 +384,7 @@ function CARRIERTRAINER:OnEventBirth(EventData)
self:_InitNewRound(self.players[_playername]) self:_InitNewRound(self.players[_playername])
end end
-- Test
CARRIERTRAINER.LSOcall.HIGHL:ToGroup(_group) CARRIERTRAINER.LSOcall.HIGHL:ToGroup(_group)
end end
@ -840,6 +841,9 @@ function CARRIERTRAINER:_CallTheBall(playerData)
-- Player altitude -- Player altitude
local alt=playerData.unit:GetAltitude() local alt=playerData.unit:GetAltitude()
-- Player group.
local player=playerData.unit:GetGroup()
-- Get velocities. -- Get velocities.
local playerVelocity = playerData.unit:GetVelocityKMH() local playerVelocity = playerData.unit:GetVelocityKMH()
local carrierVelocity = self.carrier:GetVelocityKMH() local carrierVelocity = self.carrier:GetVelocityKMH()
@ -850,19 +854,54 @@ function CARRIERTRAINER:_CallTheBall(playerData)
return return
end end
-- Lineup. We need to correct for the end of the carrier deck and the tilted angle of the runway. -- Runway is at an angle of -10 degrees wrt to carrier X direction.
-- TODO: make this parameter of the carrier. -- TODO: make this carrier dependent
local lineup = math.asin(diffZ/(-(diffX-100))) local rwyangle=-10
local lineuperror = math.deg(lineup)-10 local deckheight=22
local tailpos=-100
-- Position at the end of the deck. From there we calculate the angle.
-- TODO: Check exact number and make carrier dependent.
local b={}
b.x=tailpos
b.z=0
-- Position of the aircraft wrt carrier coordinates.
local a={}
a.x=diffX
a.z=diffZ
--a.x=-200
--a.y= 0
--a.z=17.632698070846 --(100)*math.tan(math.rad(10))
--a.z=20
--print(a.z)
-- Vector from plane to ref point on boad.
local c={}
c.x=b.x-a.x
c.z=b.z-a.z
-- Current line up and error wrt to final heading of the runway.
local lineup=math.atan2(c.z, c.x)
local lineuperror=math.deg(lineup)-rwyangle
if lineuperror<0 then
env.info("come left")
elseif lineuperror>0 then
env.info("Right for lineup")
end
-- Glideslope. Wee need to correct for the height of the deck. The ideal glide slope is 3.5 degrees. -- Glideslope. Wee need to correct for the height of the deck. The ideal glide slope is 3.5 degrees.
-- TODO: make this parameter of the carrier. local h=playerData.unit:GetAltitude()-deckheight
local glideslope = math.atan((playerData.unit:GetAltitude()-22)/(-diffX)) local x=math.abs(diffX-tailpos)
local glideslopeError = math.deg(glideslope) - 3.5 local glideslope=math.atan(h/x)
local glideslopeError=math.deg(glideslope) - 3.5
if diffX>-UTILS.NMToMeters(0.75) and diffX<-100 and playerData.calledball==false then if diffX>-UTILS.NMToMeters(0.75) and diffX<-100 and playerData.calledball==false then
self:_SendMessageToPlayer("Call the ball.", 8, playerData) self:_SendMessageToPlayer("Call the ball.", 8, playerData)
playerData.calledball=true playerData.calledball=true
CARRIERTRAINER.LSOcall.CALLTHEBALL:ToGroup(player)
return return
end end
@ -870,8 +909,6 @@ function CARRIERTRAINER:_CallTheBall(playerData)
local time=timer.getTime() local time=timer.getTime()
local deltaT=time-playerData.Tlso local deltaT=time-playerData.Tlso
-- Player group.
local player=playerData.unit:GetGroup()
-- Check if we are beween 3/4 NM and end of ship. -- Check if we are beween 3/4 NM and end of ship.
if diffX>-UTILS.NMToMeters(0.75) and diffX<-100 and deltaT>=3 then if diffX>-UTILS.NMToMeters(0.75) and diffX<-100 and deltaT>=3 then
@ -896,16 +933,16 @@ function CARRIERTRAINER:_CallTheBall(playerData)
end end
-- Lineup left/right calls. -- Lineup left/right calls.
if lineuperror>3 then if lineuperror<3 then
text=text.."Come left!" text=text.."Come left!"
CARRIERTRAINER.LSOcall.COMELEFTL:ToGroup(player) CARRIERTRAINER.LSOcall.COMELEFTL:ToGroup(player)
elseif lineuperror>1 then elseif lineuperror<1 then
text=text.."Come left." text=text.."Come left."
CARRIERTRAINER.LSOcall.COMELEFTS:ToGroup(player) CARRIERTRAINER.LSOcall.COMELEFTS:ToGroup(player)
elseif lineuperror<3 then elseif lineuperror>3 then
text=text.."Right for lineup!" text=text.."Right for lineup!"
CARRIERTRAINER.LSOcall.RIGHTFORLINEUPL:ToGroup(player) CARRIERTRAINER.LSOcall.RIGHTFORLINEUPL:ToGroup(player)
elseif lineuperror<1 then elseif lineuperror>1 then
text=text.."Right for lineup." text=text.."Right for lineup."
CARRIERTRAINER.LSOcall.RIGHTFORLINEUPS:ToGroup(player) CARRIERTRAINER.LSOcall.RIGHTFORLINEUPS:ToGroup(player)
else else