I'm going to do this against my better judgement i know that this section is basically dead without a doubt but regardless..
gentlemen i give you ground to space guns or possibly similar to the coalition concepts defenses or that mod which has been deleted.
you may of notice something on the top of it that looks similar to a dropcrate and it is, i'd like it to be a pilotable vehicle if possible meaning that unless a actor is preset in the box that can mean anything from a crab to a brain it won't be able to function beyond being able to suck in a actor if selected in the pipemenu.
now as for the piemenu they would be two functions - heavy door above the module that is slightly thicker than the standard door and is made entirely out of concrete and would only work if trigger by the gun while actor is preset in vehicle and would automatically close if your actor leaves the vehicle - normal function of crate suck in things..
Author:
Bad Boy [ Mon May 12, 2014 2:15 am ]
Post subject:
Re: Static Defence Turrets
Well, I have very little idea what you're asking for in the last part but if you want pilotable stuff, here's a script I made for the UNSC mod to make the turrets pilotable. I can't say it'll work with the most recent version of cc, I don't remember off the top of my head if the ai file structure has been changed and if it does you'll have to fiddle with this.
It's got a few things you probably don't need, breaking off guns to carry them around and such. Also, I think I fixed them all but there may be a few crashy things somewhere in there still.
It's also got a bit of auto ai stuff, so sentry mode actors will auto use turrets and maybe auto eject if the gun is dead. If you or anyone else wants to use it, feel free to do so, just give credit
Notes: I've attached the lua file too in case you want to avoid the horrible 3 spaces, ruiner of tabbing. Also, you'll need two frames for a pie button called IconRepair. I nicked mine from unitec for testing, you can probably do the same.
Code:
function UNSCLeaveRideableTurret(self) --Pie function here self.Sharpness = 1; end function UNSCDetachRideableTurret(self) --Other pie function here self.Sharpness = 2; end --Main stuff from here onwards require("Actors/AI/NativeCrabAI") function Create(self) --Stuff for making the entry area for the pilot self.PreviousFlip = self.HFlipped; --The previous hflipped, saves a bit of resources in the update self.PreviousPos = Vector(self.Pos.X, self.Pos.Y); --The previous position, saves a bit of resources in the update --Note about previouspos: Setting it to equal self.Pos makes it keep updating. Wtf? self.FlipNumber = 1; --A numerical value for HFlipped self.EntryAreaSize = 80; --The size of the box in each direction self.EntryArea = Box(Vector(self.Pos.X - (self.EntryAreaSize*self.FlipNumber), self.Pos.Y - self.EntryAreaSize) , Vector(self.Pos.X - (10*self.FlipNumber), self.Pos.Y + self.EntryAreaSize/2));
--Stuff for finding and setting the pilot self.PilotFindTimer = Timer(); --set up a delay so it's not too system heavy self.TapTimer1 = Timer(); --Two timers for double tapping self.TapTimer2 = Timer(); --i.e. tap down then up self.Pilot = nil; --The actual pilot
--Stuff for when we have the pilot self.POffset = 10; --The amount we offset the pilot from the turret when he exists self.OffsetPos = Vector(0,0); --A vector with the desired offset position, for convenience self.PilotHere = false; --A flag for if the pilot is actually at the turret or not
self.AI = NativeCrabAI:Create(self)
--Timer for pie button objective arrows self.PieTimer = Timer(); end function UpdateAI(self) self.AI:Update(self) end function Update(self) if UInputMan:KeyPressed(3) then self:ReloadScripts() PresetMan:ReloadAllScripts(); print ("turret scripts reloaded"); end if UInputMan:KeyPressed(2) then if self.Pilot ~= nil and MovableMan:IsActor(self.Pilot) then self.Pilot:GibThis(); end end if UInputMan:KeyPressed(26) then self.Health = 20; end
--If we're spinning ridiculously or dead/don't exist, the pilot falls out if math.abs(self.AngularVel) > 7 or not MovableMan:IsActor(self) or self.Health <= 0 then self.Pilot = nil; self.PilotHere = false; end
--If the hflipped or position changes if self.HFlipped ~= self.PreviousFlip or self.PreviousPos.X ~= self.Pos.X or self.PreviousPos.Y ~= self.Pos.Y then --Change the flip number if self.HFlipped == true then self.FlipNumber = -1; elseif self.HFlipped == false then self.FlipNumber = 1; end --Change the box direction self.EntryArea = Box(Vector(self.Pos.X - (self.EntryAreaSize*self.FlipNumber), self.Pos.Y - self.EntryAreaSize) , Vector(self.Pos.X - (10*self.FlipNumber), self.Pos.Y + self.EntryAreaSize/2)); --Set previous flip to be hflipped and the previous pos to be self.pos self.PreviousFlip = self.HFlipped; self.PreviousPos = Vector(self.Pos.X, self.Pos.Y); end
--Do a large variety of things every 10 MS to cut down a bit on potential lag if self.PilotFindTimer:IsPastSimMS(10) and self ~= nil and MovableMan:IsActor(self) then --If we have no pilot if self.Pilot == nil then
--Right the turret if it's tipped, but only if it's not spinning rapidly if math.abs(self.RotAngle) > 0 and math.abs(self.AngularVel) > 0 and math.abs(self.AngularVel) < 6 then if self.RotAngle < -5 then self.AngularVel = 5; elseif self.RotAngle > 5 then self.AngularVel = -5; elseif self.RotAngle >= -5 and self.RotAngle <= 5 then self.RotAngle = 0; self.AngularVel = 0; end end
--Disable the turret's controller and ai and make it unselectable if self:GetController().InputMode ~= Controller.CIM_DISABLED then self:SetControllerMode(Controller.CIM_DISABLED , self:GetController().Player); self.AIMode = Actor.AIMODE_NONE; end
--Swap from turret if it's selected if MovableMan:IsActor(self) and self ~= nil then local selected = ToGameActivity(ActivityMan:GetActivity()):GetControlledActor(self.Team).ID; if selected == self.ID then if self:GetController():IsState(Controller.ACTOR_NEXT) then ToGameActivity(ActivityMan:GetActivity()):SwitchToNextActor(self:GetController().Player, self.Team, self); elseif self:GetController():IsState(Controller.ACTOR_PREV) then ToGameActivity(ActivityMan:GetActivity()):SwitchToPrevActor(self:GetController().Player, self.Team, self); else ToGameActivity(ActivityMan:GetActivity()):SwitchToPrevActor(self:GetController().Player, self.Team, self); end end end
--Make the turret aim down self:SetAimAngle(-math.pi/8);
--Look for a pilot and set any actor that is close enough and holds crouch as pilot. Also, add ai actors if they're in sentry mode and are close enough for actor in MovableMan.Actors do if actor.ClassName == "AHuman" and actor.AIMode ~= Actor.AIMODE_GOLDDIG and actor.AIMode ~= Actor.AIMODE_NONE and actor.Team == self.Team and self.EntryArea:WithinBox(actor.Pos) then ToGameActivity(ActivityMan:GetActivity()):AddObjectivePoint("Available pilot, hold down to take control.", actor.AboveHUDPos, self.Team, GameActivity.ARROWDOWN);
--[[if actor:GetController():IsState(Controller.HOLD_DOWN) then self.TapTimer1:Reset(); end if not self.TapTimer1:IsPastSimMS(20) then if not actor:GetController():IsState(Controller.HOLD_DOWN) then self.TapTimer2:Reset() end end
if not self.TapTimer2:IsPastSimMS(100) then if actor:GetController():IsState(Controller.HOLD_UP) then--]]
--Changed from tap down then up to hold down for 1 second if actor:IsPlayerControlled() then if not actor:GetController():IsState(Controller.HOLD_DOWN) then self.TapTimer1:Reset(); elseif actor:GetController():IsState(Controller.HOLD_DOWN) then if self.TapTimer1:IsPastSimMS(500) then --Set the actor to be the pilot self.Pilot = actor; --Set the turret to aim straight forwards when it activates self:SetAimAngle(0); end end else --Set any sentry mode actors in the area who aren't using more expensive weapons than its gun if actor.AIMode == Actor.AIMODE_SENTRY and (actor:GetTotalValue(0, 3) - actor:GetGoldValue(0, 3) < 220) then --Set the actor to be the pilot self.Pilot = actor; --Set the turret to aim straight forwards when it activates self:SetAimAngle(0); end end end end --If we have a pilot elseif self.Pilot ~= nil then --If he's alive, do stuff if MovableMan:IsActor(self.Pilot) and self.Pilot.Health > 0 then --If the pilot is far away, have him walk close and if he's close keep him there. self.OffsetPos = Vector(self.Pos.X - self.POffset*self.FlipNumber, self.Pos.Y); if self.PilotHere == false then --Set the pilot to golddig mode, to make sure only one turret can claim him (hopefully). --TODO come up with a more elegant solution self.Pilot.AIMode = Actor.AIMODE_GOLDDIG; --Too far left if self.Pilot.Pos.X < self.OffsetPos.X - 3 then self.Pilot:GetController():SetState(Controller.MOVE_RIGHT, true); self.Pilot:GetController():SetState(Controller.MOVE_LEFT, false); --Too far right elseif self.Pilot.Pos.X > self.OffsetPos.X + 3 then self.Pilot:GetController():SetState(Controller.MOVE_LEFT, true); self.Pilot:GetController():SetState(Controller.MOVE_RIGHT, false); --Perfect elseif self.Pilot.Pos.X >= self.OffsetPos.X - 3 then --Switch to the turret ToGameActivity(ActivityMan:GetActivity()):SwitchToActor(ToActor(MovableMan:GetMOFromID(self.ID)), self.Pilot:GetController().Player, self.Pilot.Team); self.PilotHere = true; end end
--If the pilot is in position if self.PilotHere == true then --Keep him here and face him the right way self.Pilot.Pos = self.OffsetPos; self.Pilot.Vel = self.Vel; self.Pilot.HFlipped = self.HFlipped;
--Disable his controller and ai if self.Pilot:GetController().InputMode ~= Controller.CIM_DISABLED or self.Pilot.AIMode ~= Actor.AIMODE_NONE then self.Pilot:SetControllerMode(Controller.CIM_DISABLED , self.Pilot:GetController().Player); self.Pilot.AIMode = Actor.AIMODE_NONE; end
--Set the turret to be controllable and go to sentry ai if self:GetController().InputMode == Controller.CIM_DISABLED or self.AIMode == Actor.AIMODE_NONE then self:SetControllerMode(Controller.CIM_PLAYER , self:GetController().Player); self.AIMode = Actor.AIMODE_SENTRY; end
--Swap onwards if the pilot is selected, depending on which direction it's selected from local selected = ToGameActivity(ActivityMan:GetActivity()):GetControlledActor(self.Team).ID; if selected == self.Pilot.ID then if self.Pilot:GetController():IsState(Controller.ACTOR_NEXT) then ToGameActivity(ActivityMan:GetActivity()):SwitchToNextActor(self.Pilot:GetController().Player, self.Pilot.Team, self.Pilot); elseif self.Pilot:GetController():IsState(Controller.ACTOR_PREV) then ToGameActivity(ActivityMan:GetActivity()):SwitchToPrevActor(self.Pilot:GetController().Player, self.Pilot.Team, self.Pilot); --else -- ToGameActivity(ActivityMan:GetActivity()):SwitchToActor(ToActor(MovableMan:GetMOFromID(self.ID)), self.Pilot:GetController().Player, self.Pilot.Team); end end
--Remove the pilot when there's no gun and break the turret when it's low health if (self.FirearmIsReady == true or self.FirearmIsEmpty == true) and self.Health <= 5 then self.Sharpness = 2; --Break the gun elseif self.FirearmIsReady == false and self.FirearmIsEmpty == false then self.Sharpness = 1; --Leave the turret end end
--If he's not alive set to nil elseif not MovableMan:IsActor(self.Pilot) or self.Pilot.Health <= 0 then self.Pilot = nil; self.PilotHere = false; end end self.PilotFindTimer:Reset(); end
--Pie button stuff --Remove pilot and disable turret if self.Sharpness == 0 then self.PieTimer:Reset(); elseif self.Sharpness == 1 then if self.Pilot ~= nil and MovableMan:IsActor(self.Pilot) and self ~= nil and MovableMan:IsActor(self) then self.Pilot:SetControllerMode(Controller.CIM_PLAYER , self.Pilot:GetController().Player); self.Pilot.AIMode = Actor.AIMODE_SENTRY; ToGameActivity(ActivityMan:GetActivity()):SwitchToActor(self.Pilot, self:GetController().Player, self.Team); self.Pilot = nil; self.PilotHere = false; if self.FirearmNeedsReload then self:ReloadFirearm(); end self.Sharpness = 0; elseif (self.Pilot == nil or not MovableMan:IsActor(self.Pilot)) and self ~= nil and MovableMan:IsActor(self) then ToGameActivity(ActivityMan:GetActivity()):AddObjectivePoint("No pilot to remove", self.AboveHUDPos, self.Team, GameActivity.ARROWDOWN); if self.PieTimer:IsPastSimMS(1000) then self.Sharpness = 0; end end
--Break turret and remove gun elseif self.Sharpness == 2 then if self.Pilot ~= nil and MovableMan:IsActor(self.Pilot) and self ~= nil and MovableMan:IsActor(self) then if self.PilotHere == true then if self.FirearmIsReady or self.FirearmIsEmpty then self.Pilot:SetControllerMode(Controller.CIM_PLAYER , self.Pilot:GetController().Player); self.Pilot.AIMode = Actor.AIMODE_SENTRY; ToGameActivity(ActivityMan:GetActivity()):SwitchToActor(self.Pilot, self:GetController().Player, self.Team); self.Pilot:AddInventoryItem(CreateHDFirearm("M247H HMG- Machine Gun" , "UNSC.rte")); self.Pilot = nil; self.PilotHere = false; self:GibThis(); self = nil; elseif self.FirearmIsReady == false and self.FirearmIsEmpty == false then ToGameActivity(ActivityMan:GetActivity()):AddObjectivePoint("There is no gun to detach.", self.AboveHUDPos, self.Team, GameActivity.ARROWDOWN); if self.PieTimer:IsPastSimMS(1000) then self.Sharpness = 0; end end elseif self.PilotHere == false and self.Pilot ~= nil then ToGameActivity(ActivityMan:GetActivity()):AddObjectivePoint("The pilot is not close enough to break off the gun.", self.AboveHUDPos, self.Team, GameActivity.ARROWDOWN); if self.PieTimer:IsPastSimMS(1000) then self.Sharpness = 0; end end elseif (self.Pilot == nil or not MovableMan:IsActor(self.Pilot)) and self ~= nil and MovableMan:IsActor(self) then ToGameActivity(ActivityMan:GetActivity()):AddObjectivePoint("No pilot available to break off gun.", self.AboveHUDPos, self.Team, GameActivity.ARROWDOWN); if self.PieTimer:IsPastSimMS(1000) then self.Sharpness = 0; end end end end function Destroy(self) end
Awesome i honestly haven't got a clue how to use it but if you want i can put some sprites together for testing haven't done it in ages but its worth a shot.
Author:
Bad Boy [ Mon May 12, 2014 2:50 am ]
Post subject:
Re: Static Defence Turrets
Sure, if you want. You'll have to do ini too though, since I don't touch that stuff.
Also, keep in mind I'm not doing much CC stuff at the moment so I won't be too fast or available for it, but it should be a pretty simple matter to tweak my script so it's useable for what you want. If you find someone who's more active at it than I am and wants to use my script as a base, that's completely fine too.
Author:
Sims_Doc [ Mon May 12, 2014 2:53 am ]
Post subject:
Re: Static Defence Turrets
Bad Boy wrote:
Sure, if you want. You'll have to do ini too though, since I don't touch that stuff.
Also, keep in mind I'm not doing much CC stuff at the moment so I won't be too fast or available for it, but it should be a pretty simple matter to tweak my script so it's useable for what you want. If you find someone who's more active at it than I am and wants to use my script as a base, that's completely fine too.
this is becoming a tomb forum but i'm sure someone will popup just the same, so I'll put together those sprites and see what happens.