----------------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------------- function CF_InitRapidBuy(movman) CF_IsBuying = false; CF_SelectedPreset = 1; CF_PresetParticle = nil; CF_PresetIconOffset = Vector(0 , -85); CF_DropPos = nil; CF_DropArrowParticle = nil; CF_DropEtaParticle = nil; CF_DropTimer = nil; CF_DropEta = nil; CF_DownInARow = 0; end ----------------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------------- function CF_ProcessRapidBuy() if CF_DropPos ~= nil then if CF_DropTimer:IsPastSimMS(1000) then CF_DropEta = CF_DropEta - 1 CF_DropTimer:Reset(); if CF_DropEta < 0 then if MovableMan:IsParticle(CF_DropArrowParticle) then MovableMan:RemoveParticle(CF_DropArrowParticle); end if MovableMan:IsParticle(CF_DropEtaParticle) then MovableMan:RemoveParticle(CF_DropEtaParticle); end CF_DeliverPreset(CF_DropPos , CF_SelectedPreset); CF_DropPos = nil; CF_DropArrowParticle = nil; CF_DropEtaParticle = nil; CF_DropTimer = nil; CF_DropEta = nil; else if MovableMan:IsParticle(CF_DropEtaParticle) then MovableMan:RemoveParticle(CF_DropEtaParticle); end CF_DropEtaParticle = CreateMOSRotating("LandingEta" , "UnmappedLands.rte"); CF_DropEtaParticle.Pos = CF_DropPos; CF_DropEtaParticle.Frame = CF_DropEta; MovableMan:AddParticle(CF_DropEtaParticle); end end end local actor = ActivityMan:GetActivity():GetControlledActor(CF_PlayerTeam); if actor and MovableMan:IsActor(actor) and not CF_DropTimer and actor.ClassName == "AHuman" then local cont = actor:GetController(); if CF_IsBuying then local cont = actor:GetController(); if cont:IsState(Controller.PRESS_LEFT) then CF_RemovePreset(actor.Pos + CF_PresetIconOffset , CF_SelectedPreset) CF_SelectedPreset = CF_SelectedPreset - 1; if CF_SelectedPreset < 1 then CF_SelectedPreset = #CF_RapidBuyPresets[CF_PlayerFaction]; end CF_DrawPreset(actor.Pos + CF_PresetIconOffset , CF_SelectedPreset) end if cont:IsState(Controller.PRESS_RIGHT) then CF_RemovePreset(actor.Pos + CF_PresetIconOffset , CF_SelectedPreset) CF_SelectedPreset = CF_SelectedPreset + 1; if CF_SelectedPreset > #CF_RapidBuyPresets[CF_PlayerFaction] then CF_SelectedPreset = 1; end CF_DrawPreset(actor.Pos + CF_PresetIconOffset , CF_SelectedPreset) end if cont:IsState(Controller.PRESS_UP) then CF_RemovePreset(actor.Pos + CF_PresetIconOffset , CF_SelectedPreset) CF_IsBuying = false; if CF_OrderPreset(actor.Pos , CF_SelectedPreset) then local lastobstacle = Vector(0,0); local lastfree = Vector(0,0); SceneMan:CastObstacleRay(Vector(actor.Pos.X, 0) , Vector(0, SceneMan.Scene.Height) , lastobstacle , lastfree , 0 , 0 , 5); CF_DropPos = Vector(lastfree.X , lastfree.Y - 20); --CF_DropPos = Vector(actor.Pos.X , actor.Pos.Y - 30); CF_DropTimer = Timer(); CF_DropTimer:Reset(); CF_DropEta = 4; CF_DropArrowParticle = CreateMOSRotating("LandingArrow" , "UnmappedLands.rte"); CF_DropArrowParticle.Pos = CF_DropPos; CF_DropArrowParticle.SpriteAnimMode = 1; MovableMan:AddParticle(CF_DropArrowParticle); CF_DropEtaParticle = CreateMOSRotating("LandingEta" , "UnmappedLands.rte"); CF_DropEtaParticle.Pos = CF_DropPos; CF_DropEtaParticle.Frame = CF_DropEta; MovableMan:AddParticle(CF_DropEtaParticle); else actor:FlashWhite(750); end end if cont:IsState(Controller.ACTOR_NEXT) or cont:IsState(Controller.ACTOR_PREV) or cont:IsState(Controller.PRESS_DOWN) then CF_RemovePreset(actor.Pos + CF_PresetIconOffset , CF_SelectedPreset) CF_IsBuying = false; end end -- If buying -- Old rapid buy control scheme - hold down for 1.5 secs, down to confirm, up to cancel --[[if cont:IsState(Controller.HOLD_DOWN) then if not CF_IsBuying then if CF_ControlTimer == nil then CF_ControlTimer = Timer(); CF_ControlTimer:Reset(); else if CF_ControlTimer:IsPastSimMS(1500) then CF_ControlTimer = nil; if CF_RapidBuyPresets[CF_PlayerFaction] ~= nil then CF_DrawPreset(actor.Pos + CF_PresetIconOffset , CF_SelectedPreset); CF_IsBuying = true; end end end end else CF_ControlTimer = nil; end]]-- -- New rapid buy control scheme - press down 3 times, up - confirm, down - cancel if cont:IsState(Controller.PRESS_DOWN) then if CF_ControlTimer == nil then CF_ControlTimer = Timer(); CF_ControlTimer:Reset(); CF_DownInARow = 0; else if CF_ControlTimer:IsPastSimMS(250) then CF_ControlTimer:Reset(); CF_DownInARow = 0; else CF_ControlTimer:Reset(); end end CF_DownInARow = CF_DownInARow + 1; if CF_DownInARow == 3 then CF_ControlTimer = nil; CF_DownInARow = 0; if CF_RapidBuyPresets[CF_PlayerFaction] ~= nil then CF_DrawPreset(actor.Pos + CF_PresetIconOffset , CF_SelectedPreset); CF_IsBuying = true; end end end if actor.Health <= 0 then CF_IsBuying = false; CF_ControlTimer = nil; CF_RemovePreset(actor.Pos + CF_PresetIconOffset , CF_SelectedPreset) end end end ----------------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------------- function CF_RemovePreset(pos , preset) print ("Remove Preset") if MovableMan:IsParticle(CF_PresetParticle) then MovableMan:RemoveParticle(CF_PresetParticle); end end ----------------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------------- function CF_DrawPreset(pos , preset) print ("Draw Preset") local presetname; local modulename; if CF_RapidBuyPresets[CF_PlayerFaction][preset]["Icon"] ~= nil then presetname = CF_RapidBuyPresets[CF_PlayerFaction][preset]["Icon"]; modulename = CF_RapidBuyPresets[CF_PlayerFaction][preset]["IconModule"]; else presetname = "PresetIconGeneric"..tostring(preset); modulename = "UnmappedLands.rte" end CF_PresetParticle = CreateMOSRotating(presetname , modulename); CF_PresetParticle.Pos = pos; MovableMan:AddParticle(CF_PresetParticle); end ----------------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------------- function CF_DeliverPreset(pos , preset) local shippreset; local shipmodule; if CF_RapidBuyPresets[CF_PlayerFaction][preset]["Dropship"] ~= nil then shippreset = CF_RapidBuyPresets[CF_PlayerFaction][preset]["Dropship"]; shipmodule = CF_RapidBuyPresets[CF_PlayerFaction][preset]["TrooperModule"]; else shippreset = "Drop Ship MK1"; shipmodule = "Base.rte"; end ship = CreateACDropShip(shippreset , shipmodule); ship.AIMode = Actor.AIMODE_DELIVER; ship.Team = CF_PlayerTeam; ship.Pos = Vector(pos.X, -10); ship:SetControllerMode(Controller.CIM_AI, -1); actor = CreateAHuman(CF_RapidBuyPresets[CF_PlayerFaction][preset]["Trooper"] , CF_RapidBuyPresets[CF_PlayerFaction][preset]["TrooperModule"]); actor.AIMode = Actor.AIMODE_SENTRY; actor.Team = CF_PlayerTeam; for i = 1, #CF_RapidBuyPresets[CF_PlayerFaction][preset]["Weapons"] do actor:AddInventoryItem(CreateHDFirearm(CF_RapidBuyPresets[CF_PlayerFaction][preset]["Weapons"][i] , CF_RapidBuyPresets[CF_PlayerFaction][preset]["WeaponModules"][i])); end ship:AddInventoryItem(actor); MovableMan:AddActor(ship); end ----------------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------------- function CF_OrderPreset(pos , preset) local ret = false; if MovableMan:GetMOIDCount() < CF_MOIDLimit then if ActivityMan:GetActivity():GetTeamFunds(CF_PlayerTeam) > CF_RapidBuyPresets[CF_PlayerFaction][preset]["Price"] then ActivityMan:GetActivity():SetTeamFunds(ActivityMan:GetActivity():GetTeamFunds(CF_PlayerTeam) - CF_RapidBuyPresets[CF_PlayerFaction][preset]["Price"] , CF_PlayerTeam); ret = true; end end return ret; end ----------------------------------------------------------------------------------------- -- -----------------------------------------------------------------------------------------