diff --git a/lua/entities/gmod_tardis/modules/cl_classic_doors.lua b/lua/entities/gmod_tardis/modules/cl_classic_doors.lua new file mode 100644 index 000000000..a91bd0a96 --- /dev/null +++ b/lua/entities/gmod_tardis/modules/cl_classic_doors.lua @@ -0,0 +1,17 @@ +ENT:AddHook("ShouldDraw", "classic_doors_exterior", function(self) + if self.metadata.EnableClassicDoors + and wp.drawing and wp.drawingent == self.interior.portals.interior + then + return false + end + +end) + +ENT:AddHook("ShouldDrawPart", "classic_doors_exterior_door", function(self, part) + if self.metadata.EnableClassicDoors == true and part ~= nil + and wp.drawing and wp.drawingent == self.interior.portals.interior + and part == TARDIS:GetPart(self, "door") + then + return false + end +end) \ No newline at end of file diff --git a/lua/entities/gmod_tardis/modules/sh_cloak.lua b/lua/entities/gmod_tardis/modules/sh_cloak.lua index de4f39e33..b7576e6c9 100644 --- a/lua/entities/gmod_tardis/modules/sh_cloak.lua +++ b/lua/entities/gmod_tardis/modules/sh_cloak.lua @@ -188,17 +188,23 @@ else if self:GetData("cloak",false) and not self:GetData("cloak-animating",false) then return false end end) - ENT:OnMessage("cloak", function(self) + ENT:OnMessage("cloak", function(self) local on = net.ReadBool() self:SetData("cloak", on) self:SetData("cloak-animating", true) - local snd = self.metadata.Exterior.Sounds.Cloak - if on and TARDIS:GetSetting("cloaksound-enabled") and TARDIS:GetSetting("sound") then - self:EmitSound(snd) + local snd + if on then + snd = self.metadata.Exterior.Sounds.Cloak + else + snd = self.metadata.Exterior.Sounds.CloakOff + end - if IsValid(self.interior) then - self.interior:EmitSound(snd) - end - end - end) + if TARDIS:GetSetting("cloaksound-enabled") and TARDIS:GetSetting("sound") then + self:EmitSound(snd) + + if IsValid(self.interior) then + self.interior:EmitSound(snd) + end + end + end) end \ No newline at end of file diff --git a/lua/entities/gmod_tardis/modules/sh_doors.lua b/lua/entities/gmod_tardis/modules/sh_doors.lua index d8eb8e913..274c12cec 100644 --- a/lua/entities/gmod_tardis/modules/sh_doors.lua +++ b/lua/entities/gmod_tardis/modules/sh_doors.lua @@ -13,7 +13,7 @@ if SERVER then callback(state) end) end - + function ENT:ToggleDoor(callback) if not IsValid(self.interior) then return false end if not self:GetData("doorchangecallback",false) then @@ -29,12 +29,12 @@ if SERVER then return false end doorstate=not doorstate - + self:SetData("doorstatereal",doorstate,true) self:SetData("doorchangewait",not doorstate) - + self:CallHook("ToggleDoorReal",doorstate) - + if doorstate then self:SetData("doorstate",true,true) self:SetData("doorchange",CurTime()) @@ -47,11 +47,15 @@ if SERVER then if callback then callbacks[callback]=true end - self:SetData("doorchange",CurTime()+self.metadata.Exterior.DoorAnimationTime) + local dooranimtime = self.metadata.Exterior.DoorAnimationTime + if self.metadata.EnableClassicDoors == true then + dooranimtime = math.max(dooranimtime, self.metadata.Interior.IntDoorAnimationTime) + end + self:SetData("doorchange",CurTime() + dooranimtime) end return true end - + function ENT:OpenDoor(callback) if self:GetData("doorstate",false) then delay(callback,true) @@ -59,7 +63,7 @@ if SERVER then self:ToggleDoor(callback) end end - + function ENT:CloseDoor(callback) if self:GetData("doorstate",false) ~= self:GetData("doorstatereal",false) then local callbacks=self:GetData("doorchangecallback") @@ -70,7 +74,7 @@ if SERVER then self:ToggleDoor(callback) end end - + function ENT:DoorOpen(real) if real then return self:GetData("doorstatereal",false) @@ -78,11 +82,11 @@ if SERVER then return self:GetData("doorstate",false) end end - + ENT:AddHook("Initialize", "doors", function(self) self:SetBodygroup(1,1) end) - + ENT:AddHook("ToggleDoor", "intdoors", function(self,open) local intdoor=TARDIS:GetPart(self.interior,"door") if IsValid(intdoor) then @@ -121,7 +125,7 @@ if SERVER then net.WriteBool(open) end) end) - + ENT:AddHook("Think", "doors", function(self) if self:GetData("doorchangewait",false) and CurTime()>self:GetData("doorchange",0) then self:SetData("doorchangewait",nil) @@ -140,13 +144,13 @@ if SERVER then end end end) - + ENT:AddHook("ShouldThinkFast","doors",function(self) if self:GetData("doorchangewait") then return true end end) - + ENT:AddHook("SkinChanged","doors",function(self,i) local door=TARDIS:GetPart(self,"door") local intdoor=TARDIS:GetPart(self.interior,"door") @@ -157,7 +161,7 @@ if SERVER then intdoor:SetSkin(i) end end) - + ENT:AddHook("BodygroupChanged","doors",function(self,bodygroup,value) local door=TARDIS:GetPart(self,"door") local intdoor=TARDIS:GetPart(self.interior,"door") @@ -178,7 +182,7 @@ else type="bool", option=true }) - + function ENT:DoorOpen(real) local door=self:GetPart("door") if real and IsValid(door) then @@ -187,7 +191,7 @@ else return self:GetData("doorstate",false) end end - + function ENT:DoorMoving() local door=self:GetPart("door") if IsValid(door) then @@ -196,23 +200,28 @@ else return false end end - + ENT:OnMessage("ToggleDoorReal",function(self) self:CallHook("ToggleDoorReal",net.ReadBool()) end) - + ENT:AddHook("ToggleDoorReal","doorsounds",function(self,open) - local snds = self.metadata.Exterior.Sounds.Door - if snds.enabled and TARDIS:GetSetting("doorsounds-enabled") and TARDIS:GetSetting("sound") then - local extpart = self:GetPart("door") - local snd = open and snds.open or snds.close - if IsValid(extpart) and extpart.exterior:CallHook("ShouldEmitDoorSound")~=false then - extpart:EmitSound(snd) + local extsnds = self.metadata.Exterior.Sounds.Door + local intsnds = self.metadata.Interior.Sounds.Door or extsnds + + if TARDIS:GetSetting("doorsounds-enabled") and TARDIS:GetSetting("sound") then + if extsnds.enabled then + local extpart = self:GetPart("door") + local extsnd = open and extsnds.open or extsnds.close + if IsValid(extpart) and extpart.exterior:CallHook("ShouldEmitDoorSound")~=false then + extpart:EmitSound(extsnd) + end end - if IsValid(self.interior) then + if intsnds.enabled and IsValid(self.interior) then local intpart = self.interior:GetPart("door") + local intsnd = open and intsnds.open or intsnds.close if IsValid(intpart) then - intpart:EmitSound(snd) + intpart:EmitSound(intsnd) end end end diff --git a/lua/entities/gmod_tardis/modules/sh_flight.lua b/lua/entities/gmod_tardis/modules/sh_flight.lua index 4c52c07ab..9a67b3247 100644 --- a/lua/entities/gmod_tardis/modules/sh_flight.lua +++ b/lua/entities/gmod_tardis/modules/sh_flight.lua @@ -1,5 +1,45 @@ -- Flight +-- Settings + +TARDIS:AddSetting({ + id="opened-door-no-boost", + name="Disable boost with opened doors", + desc="Should the TARDIS boost stop working when doors are opened in flight?", + section="Misc", + value=false, + type="bool", + option=true, + networked=true +}) + +TARDIS:AddSetting({ + id="boost-speed", + name="Boost Speed", + desc="The increase of speed the TARDIS gets with the boost key enabled", + section="Misc", + type="number", + value=2.5, + min=1.0, + max=4.0, + networked=true +}) + +CreateConVar("tardis2_boost_speed", 2.5, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "TARDIS - Boost Speed") + +if SERVER then + cvars.AddChangeCallback("tardis2_boost_speed", function(cvname, oldvalue, newvalue) + local nvnum = tonumber(newvalue) + if nvnum < 1.0 or nvnum > 4.0 then + nvnum = math.max(1.0, math.min(4.0, nvnum)) + GetConVar("tardis2_boost_speed"):SetFloat(nvnum) + return + end + print("TARDIS boost speed has been set to "..nvnum) + TARDIS:SetSetting("boost-speed", nvnum, true) + end, "UpdateOnChange") +end + -- Binds TARDIS:AddKeyBind("flight-toggle",{ name="Toggle Flight", @@ -78,18 +118,7 @@ TARDIS:AddKeyBind("flight-spindir",{ func=function(self,down,ply) if TARDIS:HUDScreenOpen(ply) then return end if down and ply==self.pilot then - local dir - if self.spindir==-1 then - self.spindir=0 - dir="none" - elseif self.spindir==0 then - self.spindir=1 - dir="clockwise" - elseif self.spindir==1 then - self.spindir=-1 - dir="anti-clockwise" - end - TARDIS:Message(ply, "Spin direction set to "..dir) + TARDIS:Control("spin_cycle", ply) end end, key=MOUSE_RIGHT, @@ -98,12 +127,12 @@ TARDIS:AddKeyBind("flight-spindir",{ }) -if SERVER then +if SERVER then function ENT:ToggleFlight() local on = not self:GetData("flight",false) return self:SetFlight(on) end - + function ENT:SetFlight(on) if not on and self:CallHook("CanTurnOffFlight")==false then return false @@ -121,7 +150,7 @@ if SERVER then self:SetFloat(on) return true end - + ENT:AddHook("PowerToggled", "flight", function(self,on) if on and self:GetData("power-lastflight",false)==true then self:SetFlight(true) @@ -136,7 +165,7 @@ if SERVER then return true end end) - + ENT:AddHook("CanTurnOffFloat", "flight", function(self) if self:GetData("flight") then return false end end) @@ -146,7 +175,7 @@ if SERVER then return false end end) - + ENT:AddHook("ThirdPerson", "flight", function(self,ply,enabled) if enabled then if IsValid(self.pilot) then @@ -181,7 +210,7 @@ if SERVER then end end end) - + ENT:AddHook("PilotChanged","flight",function(self,old,new) self:SetData("pilot",new,true) self:SendMessage("PilotChanged",function() @@ -189,21 +218,17 @@ if SERVER then net.WriteEntity(new) end) end) - - ENT:AddHook("Initialize", "flight", function(self) - self.spindir=-1 - end) - + ENT:AddHook("Think", "flight", function(self) if self:GetData("flight") then self.phys:Wake() end end) - + ENT:AddHook("PhysicsUpdate", "flight", function(self,ph) if self:GetData("flight") then local phm=FrameTime()*66 - + local up=self:GetUp() local ri2=self:GetRight() local left=ri2*-1 @@ -218,10 +243,14 @@ if SERVER then local force=15 local vforce=5 local rforce=2 - local tforce=400 + local tforce=200 local tilt=0 local control=self:CallHook("FlightControl")~=false - + + local spindir = self:GetSpinDir() + local spin = (spindir ~= 0) + local brakes = false + if self.pilot and IsValid(self.pilot) and control then local p=self.pilot local eye=p:GetTardisData("viewang") @@ -230,12 +259,35 @@ if SERVER then end local fwd=eye:Forward() local ri=eye:Right() - + if TARDIS:IsBindDown(self.pilot,"flight-boost") then - force=force*2.5 - vforce=vforce*2.5 - rforce=rforce*2.5 - tilt=5 + + local force_mult + local door = self:DoorOpen() + + if door and TARDIS:GetSetting("opened-door-no-boost", true, self:GetCreator()) then + force_mult = 0.25 + brakes = true -- no spin, no tilt + local lastmsg = self.bad_flight_boost_msg + if lastmsg == nil or (lastmsg ~= nil and CurTime() - lastmsg > 5.5) then + self.bad_flight_boost_msg = CurTime() + TARDIS:ErrorMessage(self.pilot, "Boost doesn't work with doors open") + end + else + if self.bad_flight_boost_msg ~= nil then + self.bad_flight_boost_msg = nil + end + force_mult = TARDIS:GetSetting("boost-speed") + if not spin then + force_mult = math.max(1, force_mult * 0.6) + end + end + + force = force * force_mult + vforce = vforce * force_mult + rforce = rforce * force_mult + elseif self.bad_flight_boost_msg ~= nil then + self.bad_flight_boost_msg = nil end if TARDIS:IsBindDown(self.pilot,"flight-forward") then ph:AddVelocity(fwd*force*phm) @@ -261,27 +313,33 @@ if SERVER then tilt=tilt+5 end end - + if TARDIS:IsBindDown(self.pilot,"flight-down") then ph:AddVelocity(-up*vforce*phm) elseif TARDIS:IsBindDown(self.pilot,"flight-up") then ph:AddVelocity(up*vforce*phm) end end - - if self.spindir==0 then - tilt=0 - elseif self.spindir==1 then - tforce=-tforce + + if not spin or brakes then + tilt = 0 end - - ph:ApplyForceOffset( up*-ang.p,cen-fwd2*lev) - ph:ApplyForceOffset(-up*-ang.p,cen+fwd2*lev) - ph:ApplyForceOffset( up*-(ang.r-tilt),cen-ri2*lev) - ph:ApplyForceOffset(-up*-(ang.r-tilt),cen+ri2*lev) - - if not (self.spindir==0) then - local twist=Vector(0,0,vell/tforce) + + + -- lean into the flight + ph:ApplyForceOffset( vel * 0.005, cen + up * lev) + ph:ApplyForceOffset(-vel * 0.005, cen - up * lev) + + -- stabilise pitch + ph:ApplyForceOffset( up * -ang.p, cen - fwd2 * lev) + ph:ApplyForceOffset(-up * -ang.p, cen + fwd2 * lev) + + -- stabilise roll and apply tilt + ph:ApplyForceOffset( up * -(ang.r - tilt), cen - ri2 * lev) + ph:ApplyForceOffset(-up * -(ang.r - tilt), cen + ri2 * lev) + + if spin and not brakes then + local twist = Vector(0, 0, -spindir * math.sqrt(vell / tforce)) ph:AddAngleVelocity(twist) end local angbrake=angvel*-0.015 @@ -302,8 +360,8 @@ if SERVER then end elseif name == "Spinmode" and TARDIS:CheckPP(e2.player, self) then local spindir = args[1] - self.spindir = spindir - return self.spindir + self:SetSpinDir(spindir) + return self:GetSpinDir() elseif name == "Track" and TARDIS:CheckPP(e2.player, self) then return 0 -- Not yet implemented end @@ -328,14 +386,14 @@ else type="bool", option=true }) - + ENT:AddHook("OnRemove", "flight", function(self) if self.flightsound then self.flightsound:Stop() self.flightsound=nil end end) - + local function ChooseFlightSound(ent) if ent:GetData("health-warning", false) then ent.flightsound = CreateSound(ent, ent.metadata.Exterior.Sounds.FlightLoopDamaged) diff --git a/lua/entities/gmod_tardis/modules/sh_lock.lua b/lua/entities/gmod_tardis/modules/sh_lock.lua index a9db3f5fd..7c6368122 100644 --- a/lua/entities/gmod_tardis/modules/sh_lock.lua +++ b/lua/entities/gmod_tardis/modules/sh_lock.lua @@ -82,11 +82,13 @@ else }) ENT:OnMessage("locksound",function(self) - local snd = self.metadata.Exterior.Sounds.Lock + local extsound = self.metadata.Exterior.Sounds.Lock + local intsound = self.metadata.Interior.Sounds.Lock or extsound + if TARDIS:GetSetting("locksound-enabled") and TARDIS:GetSetting("sound") then - self:EmitSound(snd) + self:EmitSound(extsound) if IsValid(self.interior) then - self.interior:EmitSound(snd) + self.interior:EmitSound(intsound) end end end) diff --git a/lua/entities/gmod_tardis/modules/sh_spin.lua b/lua/entities/gmod_tardis/modules/sh_spin.lua new file mode 100644 index 000000000..5038fbf11 --- /dev/null +++ b/lua/entities/gmod_tardis/modules/sh_spin.lua @@ -0,0 +1,84 @@ +-- Spin + +TARDIS:AddSetting({ + id="opened-door-no-spin", + name="Stop spinning with opened door", + desc="Should the TARDIS stop spinning when doors are opened in flight?", + section="Misc", + value=true, + type="bool", + option=true, + networked=true +}) + +if CLIENT then return end + + +ENT:AddHook("Initialize", "spin", function(self) + self:SetData("spindir", -1) + self:SetData("spindir_prev", 0) +end) + +function ENT:ToggleSpin() + local current = self:GetData("spindir", -1) + local prev = self:GetData("spindir_prev", 0) + + self:SetData("spindir_prev", current) + self:SetData("spindir", prev) +end + +function ENT:CycleSpinDir() + local current = self:GetData("spindir", -1) + local prev = self:GetData("spindir_prev", 0) + + self:SetData("spindir_prev", current) + self:SetData("spindir", -prev) +end + +function ENT:SwitchSpinDir() + local current = self:GetData("spindir", -1) + local prev = self:GetData("spindir_prev", 0) + + self:SetData("spindir_prev", -prev) + self:SetData("spindir", -current) +end + +function ENT:GetSpinDir() + return self:GetData("spindir", -1) +end + +function ENT:SetSpinDir(dir) + return self:SetData("spindir", dir) +end + +function ENT:GetSpinDirText(show_next) + local current = self:GetData("spindir", -1) + if show_next == true then + current = self:GetData("spindir_prev", 0) + end + + if current == -1 then + return "anti-clockwise" + elseif current == 0 then + return "none" + elseif current == 1 then + return "clockwise" + end +end + +ENT:AddHook("ToggleDoor", "spin-dir", function(self,open) + if TARDIS:GetSetting("opened-door-no-spin", false, self:GetCreator()) then + local current = self:GetData("spindir", -1) + local before = self:GetData("spindir_before_door", nil) + + if open and self:GetSpinDir() ~= 0 then + self:SetData("spindir_before_door", current) + self:SetData("spindir_prev", current) + self:SetData("spindir", 0) + elseif not open and self:GetSpinDir() == 0 and before ~= nil then + self:SetData("spindir_before_door", nil) + self:SetData("spindir_prev", current) + self:SetData("spindir", before) + end + end +end) \ No newline at end of file diff --git a/lua/entities/gmod_tardis/modules/sh_vortex.lua b/lua/entities/gmod_tardis/modules/sh_vortex.lua index 7d86c5904..a228693c6 100644 --- a/lua/entities/gmod_tardis/modules/sh_vortex.lua +++ b/lua/entities/gmod_tardis/modules/sh_vortex.lua @@ -56,8 +56,8 @@ if SERVER then elseif TARDIS:IsBindDown(self.pilot,"flight-right") then ph:AddAngleVelocity(Vector(0,0,-rforce)) end - elseif not (self.spindir==0) then - local twist=Vector(0,0,vel*mul*-self.spindir) + elseif not (self:GetSpinDir() == 0) then + local twist=Vector(0, 0, vel * mul * - self:GetSpinDir()) ph:AddAngleVelocity(twist) ph:ApplyForceOffset( up*-ang.p,cen-fwd2*lev) ph:ApplyForceOffset(-up*-ang.p,cen+fwd2*lev) diff --git a/lua/entities/gmod_tardis/shared.lua b/lua/entities/gmod_tardis/shared.lua index a101d668c..1a814c468 100644 --- a/lua/entities/gmod_tardis/shared.lua +++ b/lua/entities/gmod_tardis/shared.lua @@ -8,6 +8,12 @@ ENT.Author="Dr. Matt" ENT.TardisExterior=true ENT.Interior="gmod_tardis_interior" +-- this is for developer debugging purposes only +local spm_overrides = DEBUG_TARDIS_SPAWNMENU_CATEGORY_OVERRIDES +if spm_overrides ~= nil and spm_overrides["all"] then + ENT.Category = spm_overrides["all"] +end + if SERVER then ENT.Spawnable = true else diff --git a/lua/entities/gmod_tardis_interior/modules/cl_classic_doors.lua b/lua/entities/gmod_tardis_interior/modules/cl_classic_doors.lua new file mode 100644 index 000000000..41aa2d2c6 --- /dev/null +++ b/lua/entities/gmod_tardis_interior/modules/cl_classic_doors.lua @@ -0,0 +1,18 @@ +ENT:AddHook("ShouldDrawPart", "classic_doors_intdoor", function(self, part) + if self.metadata.EnableClassicDoors == true and part ~= nil + and wp.drawing and wp.drawingent == self.portals.exterior + and part == TARDIS:GetPart(self, "intdoor") + then + return false + end +end) + +ENT:AddHook("ShouldDrawPart", "classic_doors_door_mirror", function(self, part) + if self.metadata.EnableClassicDoors == true and part ~= nil + and part == TARDIS:GetPart(self, "door") + and not (wp.drawing and wp.drawingent == self.portals.exterior) + then + return false + end + +end) \ No newline at end of file diff --git a/lua/entities/gmod_tardis_interior/modules/sh_interior_screens.lua b/lua/entities/gmod_tardis_interior/modules/sh_interior_screens.lua index d90dcaa41..1d9dc2f23 100644 --- a/lua/entities/gmod_tardis_interior/modules/sh_interior_screens.lua +++ b/lua/entities/gmod_tardis_interior/modules/sh_interior_screens.lua @@ -24,6 +24,7 @@ end function ENT:SetScreensOn(on) if not on or self:CallHook("CanEnableScreens") ~= false then self:SetData("screens_on", on, true) + self:CallHook("ScreensToggled", on) end return true end diff --git a/lua/entities/gmod_tardis_interior/modules/sh_portals.lua b/lua/entities/gmod_tardis_interior/modules/sh_portals.lua index 9bfea984e..5e4d03b85 100644 --- a/lua/entities/gmod_tardis_interior/modules/sh_portals.lua +++ b/lua/entities/gmod_tardis_interior/modules/sh_portals.lua @@ -44,7 +44,7 @@ else end if dont then return false, black - elseif (not (self.DoorOpen and self:DoorOpen(true))) and portal==self.portals.interior then + elseif (not (self.DoorOpen and self:DoorOpen(false))) and portal==self.portals.interior then return false elseif (not TARDIS:GetSetting("portals-enabled")) then return false, self.portals.interior==portal or portal.black diff --git a/lua/entities/gmod_tardis_part/init.lua b/lua/entities/gmod_tardis_part/init.lua index 16128f95e..91576b76c 100644 --- a/lua/entities/gmod_tardis_part/init.lua +++ b/lua/entities/gmod_tardis_part/init.lua @@ -6,4 +6,14 @@ function ENT:OnTakeDamage(dmginfo) if not self.ShouldTakeDamage then return end if self.parent:CallHook("ShouldTakeDamage",dmginfo)==false then return end self.parent:CallHook("OnTakeDamage", dmginfo) +end + +function ENT:SetCollide(collide, notrace) + if collide then + self:SetCollisionGroup(COLLISION_GROUP_NONE) + elseif notrace then + self:SetCollisionGroup(COLLISION_GROUP_IN_VEHICLE) + else + self:SetCollisionGroup(COLLISION_GROUP_WORLD) + end end \ No newline at end of file diff --git a/lua/tardis/controls/sh_control_door.lua b/lua/tardis/controls/sh_control_door.lua index 55fb44d2f..3b5ee42e0 100644 --- a/lua/tardis/controls/sh_control_door.lua +++ b/lua/tardis/controls/sh_control_door.lua @@ -2,6 +2,22 @@ TARDIS:AddControl({ id = "door", ext_func=function(self,ply) local oldstate = self:GetData("doorstate") + + if self:GetData("locked", false) then + TARDIS:ErrorMessage(ply, "The doors are locked.") + return + end + + if not self:GetPower() then + if not self.metadata.EnableClassicDoors or oldstate then + TARDIS:ErrorMessage(ply, "The door switch doesn't work.") + TARDIS:ErrorMessage(ply, "Power is disabled.") + return + end + TARDIS:Message(ply, "Using emergency power to open the door...") + TARDIS:ErrorMessage(ply, "Power is disabled.") + end + if self:ToggleDoor() then TARDIS:StatusMessage(ply, "Door", not oldstate, "opened", "closed") else @@ -9,7 +25,7 @@ TARDIS:AddControl({ end end, serveronly=true, - power_independent = false, + power_independent = true, screen_button = { virt_console = true, mmenu = false, diff --git a/lua/tardis/controls/sh_control_doorlock.lua b/lua/tardis/controls/sh_control_doorlock.lua index 6f6ad1505..015311413 100644 --- a/lua/tardis/controls/sh_control_doorlock.lua +++ b/lua/tardis/controls/sh_control_doorlock.lua @@ -1,6 +1,15 @@ TARDIS:AddControl({ id = "doorlock", ext_func=function(self,ply) + if not self:GetPower() and not self:GetData("locked", false) then + TARDIS:ErrorMessage(ply, "The door lock doesn't work.") + TARDIS:ErrorMessage(ply, "Power is disabled.") + return + elseif not self:GetPower() then + TARDIS:Message(ply, "Using emergency power to disengage the lock...") + TARDIS:ErrorMessage(ply, "Power is disabled.") + end + self:ToggleLocked(function(result) if result then TARDIS:StatusMessage(ply, "Door", self:GetData("locked"), "locked", "unlocked") diff --git a/lua/tardis/controls/sh_control_interior_lights.lua b/lua/tardis/controls/sh_control_interior_lights.lua new file mode 100644 index 000000000..254fc0970 --- /dev/null +++ b/lua/tardis/controls/sh_control_interior_lights.lua @@ -0,0 +1,13 @@ +TARDIS:AddControl({ + id = "interior_lights", + ext_func=function(self,ply) + TARDIS:Message(ply, "This hasn't been implemented yet.") + end, + clientonly=true, + power_independent = false, + screen_button = { + virt_console = false, + mmenu = false, + }, + tip_text = "Lights", +}) \ No newline at end of file diff --git a/lua/tardis/controls/sh_control_shields.lua b/lua/tardis/controls/sh_control_shields.lua new file mode 100644 index 000000000..57e74cf2f --- /dev/null +++ b/lua/tardis/controls/sh_control_shields.lua @@ -0,0 +1,13 @@ +TARDIS:AddControl({ + id = "shields", + ext_func=function(self,ply) + TARDIS:Message(ply, "This hasn't been implemented yet.") + end, + clientonly=true, + power_independent = false, + screen_button = { + virt_console = false, + mmenu = false, + }, + tip_text = "Shields", +}) \ No newline at end of file diff --git a/lua/tardis/controls/sh_control_spin_cycle.lua b/lua/tardis/controls/sh_control_spin_cycle.lua new file mode 100644 index 000000000..5bdcf4eaa --- /dev/null +++ b/lua/tardis/controls/sh_control_spin_cycle.lua @@ -0,0 +1,20 @@ +TARDIS:AddControl({ + id = "spin_cycle", + ext_func=function(self,ply) + self:CycleSpinDir() + TARDIS:Message(ply, "Spin direction set to " .. self:GetSpinDirText()) + end, + serveronly=true, + power_independent = false, + screen_button = { + virt_console = true, + mmenu = false, + toggle = false, + frame_type = {0, 1}, + text = "Spin direction", + pressed_state_from_interior = false, + pressed_state_data = nil, + order = 16, + }, + tip_text = "Spin", +}) \ No newline at end of file diff --git a/lua/tardis/controls/sh_control_spin_switch.lua b/lua/tardis/controls/sh_control_spin_switch.lua new file mode 100644 index 000000000..abe35183d --- /dev/null +++ b/lua/tardis/controls/sh_control_spin_switch.lua @@ -0,0 +1,18 @@ +TARDIS:AddControl({ + id = "spin_switch", + ext_func=function(self,ply) + self:SwitchSpinDir() + if self:GetSpinDir() ~= 0 then + TARDIS:Message(ply, "Spin direction set to " .. self:GetSpinDirText()) + else + TARDIS:Message(ply, "Spin is disabled, but spin direction set to " .. self:GetSpinDirText(true)) + end + end, + serveronly=true, + power_independent = false, + screen_button = { + virt_console = false, + mmenu = false, + }, + tip_text = "Spin direction", +}) \ No newline at end of file diff --git a/lua/tardis/controls/sh_control_spin_toggle.lua b/lua/tardis/controls/sh_control_spin_toggle.lua new file mode 100644 index 000000000..2894ebf39 --- /dev/null +++ b/lua/tardis/controls/sh_control_spin_toggle.lua @@ -0,0 +1,17 @@ +TARDIS:AddControl({ + id = "spin_toggle", + ext_func=function(self,ply) + self:ToggleSpin() + if self:GetSpinDir() ~= 0 then + TARDIS:Message(ply, "Spin direction set to " .. self:GetSpinDirText()) + end + TARDIS:StatusMessage(ply, "Spin", (self:GetSpinDir() ~= 0)) + end, + serveronly=true, + power_independent = false, + screen_button = { + virt_console = false, + mmenu = false, + }, + tip_text = "Toggle spin", +}) \ No newline at end of file diff --git a/lua/tardis/controls/sh_control_stabilizers.lua b/lua/tardis/controls/sh_control_stabilizers.lua new file mode 100644 index 000000000..d7af0771b --- /dev/null +++ b/lua/tardis/controls/sh_control_stabilizers.lua @@ -0,0 +1,13 @@ +TARDIS:AddControl({ + id = "stabilizers", + ext_func=function(self,ply) + TARDIS:Message(ply, "This hasn't been implemented yet.") + end, + clientonly=true, + power_independent = false, + screen_button = { + virt_console = false, + mmenu = false, + }, + tip_text = "Flight stabilizers", +}) \ No newline at end of file diff --git a/lua/tardis/controls/sh_control_vortexflight.lua b/lua/tardis/controls/sh_control_vortex_flight.lua similarity index 93% rename from lua/tardis/controls/sh_control_vortexflight.lua rename to lua/tardis/controls/sh_control_vortex_flight.lua index fe314d860..ea1c492c9 100644 --- a/lua/tardis/controls/sh_control_vortexflight.lua +++ b/lua/tardis/controls/sh_control_vortex_flight.lua @@ -18,5 +18,5 @@ TARDIS:AddControl({ id = "vortex_flight", pressed_state_data = "demat-fast", order = 8, }, - tip_text = "Vortex Flight Toggler", + tip_text = "Vortex Flight", }) \ No newline at end of file diff --git a/lua/tardis/interiors/base.lua b/lua/tardis/interiors/base.lua index 96a49ff95..e2105b398 100644 --- a/lua/tardis/interiors/base.lua +++ b/lua/tardis/interiors/base.lua @@ -1,116 +1,118 @@ -- Base -local T={} -T.Base=true -T.Name="Base" -T.ID="base" -T.Interior={ - Model="models/drmatt/tardis/interior.mdl", - ExitDistance=600, - Portal={ - pos=Vector(-1,-353.5,136), - ang=Angle(0,90,0), - width=60, - height=91 +local T = {} +T.Base = true +T.Name = "Base" +T.ID = "base" +T.Interior = { + Model = "models/drmatt/tardis/interior.mdl", + ExitDistance = 600, + Portal = { + pos = Vector(-1,-353.5,136), + ang = Angle(0,90,0), + width = 60, + height = 91 }, - Fallback={ - pos=Vector(0,-330,95), - ang=Angle(0,90,0) + Fallback = { + pos = Vector(0,-330,95), + ang = Angle(0,90,0) }, - Sounds={ - Teleport={ - demat_fail="drmatt/tardis/demat_fail_int.wav" + Sounds = { + Teleport = { + demat_fail = "drmatt/tardis/demat_fail_int.wav" }, -- uses exterior sounds if not specified - Power={ - On="drmatt/tardis/power_on.wav", - Off="drmatt/tardis/power_off.wav" + Power = { + On = "drmatt/tardis/power_on.wav", + Off = "drmatt/tardis/power_off.wav" }, SequenceOK = "drmatt/tardis/seq_ok.wav", SequenceFail = "drmatt/tardis/seq_bad.wav", - Cloister = "drmatt/tardis/cloisterbell_loop.wav" + Cloister = "drmatt/tardis/cloisterbell_loop.wav", + Lock = "drmatt/tardis/lock_int.wav", }, Tips = {}, CustomTips = {}, PartTips = {}, - TipSettings={ - style="white_on_grey", - view_range_min=70, - view_range_max=100, + TipSettings = { + style = "white_on_grey", + view_range_min = 70, + view_range_max = 100, }, - LightOverride={ - basebrightness=0.3, --Base interior brightness when power is on. - nopowerbrightness=0.05 --Interior brightness with no power. Should always be darker than basebrightness. + LightOverride = { + basebrightness = 0.3, --Base interior brightness when power is on. + nopowerbrightness = 0.05 --Interior brightness with no power. Should always be darker than basebrightness. }, - ScreenDistance=500, - ScreensEnabled=true + ScreenDistance = 500, + ScreensEnabled = true } -T.Exterior={ - Model="models/drmatt/tardis/exterior/exterior.mdl", - Mass=5000, - DoorAnimationTime=0.5, - ScannerOffset=Vector(22,0,50), - Portal={ - pos=Vector(26,0,51.65), - ang=Angle(0,0,0), - width=44, - height=91 +T.Exterior = { + Model = "models/drmatt/tardis/exterior/exterior.mdl", + Mass = 5000, + DoorAnimationTime = 0.5, + ScannerOffset = Vector(22,0,50), + Portal = { + pos = Vector(26,0,51.65), + ang = Angle(0,0,0), + width = 44, + height = 91 }, - Fallback={ - pos=Vector(60,0,5), - ang=Angle(0,0,0) + Fallback = { + pos = Vector(60,0,5), + ang = Angle(0,0,0) }, - Light={ - enabled=true, - pos=Vector(0,0,122), - color=Color(255,255,255), - dynamicpos=Vector(0,0,130), - dynamicbrightness=2, - dynamicsize=300 + Light = { + enabled = true, + pos = Vector(0,0,122), + color = Color(255,255,255), + dynamicpos = Vector(0,0,130), + dynamicbrightness = 2, + dynamicsize = 300 }, - ProjectedLight={ - --color=Color(r,g,b), --Base color. Will use main interior light if not set. - --warncolor=Color(r,g,b), --Warning color. Will use main interior warn color if not set. - brightness=0.1, --Light's brightness - --vertfov=90, - --horizfov=90, --vertical and horizontal field of view of the light. Will default to portal height and width. - farz=750, --FarZ property of the light. Determines how far the light projects.]] - offset=Vector(-21,0,51.1), --Offset from box origin - texture="effects/flashlight/square" --Texture the projected light will use. You can get these from the Lamp tool. + ProjectedLight = { + --color = Color(r,g,b), --Base color. Will use main interior light if not set. + --warncolor = Color(r,g,b), --Warning color. Will use main interior warn color if not set. + brightness = 0.1, --Light's brightness + --vertfov = 90, + --horizfov = 90, --vertical and horizontal field of view of the light. Will default to portal height and width. + farz = 750, --FarZ property of the light. Determines how far the light projects.]] + offset = Vector(-21,0,51.1), --Offset from box origin + texture = "effects/flashlight/square" --Texture the projected light will use. You can get these from the Lamp tool. }, - Sounds={ - Teleport={ - demat="drmatt/tardis/demat.wav", - demat_damaged="drmatt/tardis/demat_damaged.wav", - demat_fail="drmatt/tardis/demat_fail_ext.wav", - mat="drmatt/tardis/mat.wav", - mat_damaged="drmatt/tardis/mat_damaged.wav", + Sounds = { + Teleport = { + demat = "drmatt/tardis/demat.wav", + demat_damaged = "drmatt/tardis/demat_damaged.wav", + demat_fail = "drmatt/tardis/demat_fail_ext.wav", + mat = "drmatt/tardis/mat.wav", + mat_damaged = "drmatt/tardis/mat_damaged.wav", fullflight = "drmatt/tardis/full.wav", fullflight_damaged = "drmatt/tardis/full_damaged.wav", }, - RepairFinish="drmatt/tardis/repairfinish.wav", - Lock="drmatt/tardis/lock.wav", - Door={ - enabled=true, - open="drmatt/tardis/door_open.wav", - close="drmatt/tardis/door_close.wav", - locked="drmatt/tardis/door_locked.wav" + RepairFinish = "drmatt/tardis/repairfinish.wav", + Lock = "drmatt/tardis/lock.wav", + Door = { + enabled = true, + open = "drmatt/tardis/door_open.wav", + close = "drmatt/tardis/door_close.wav", + locked = "drmatt/tardis/door_locked.wav" }, - FlightLoop="drmatt/tardis/flight_loop.wav", - FlightLoopDamaged="drmatt/tardis/flight_loop_damaged.wav", + FlightLoop = "drmatt/tardis/flight_loop.wav", + FlightLoopDamaged = "drmatt/tardis/flight_loop_damaged.wav", Cloak = "drmatt/tardis/phase_enable.wav", + CloakOff = "drmatt/tardis/phase_disable.wav", }, - Parts={ - vortex={ - model="models/doctorwho1200/toyota/2013timevortex.mdl", - pos=Vector(0,0,50), - ang=Angle(0,0,0), - scale=10 + Parts = { + vortex = { + model = "models/doctorwho1200/toyota/2013timevortex.mdl", + pos = Vector(0,0,50), + ang = Angle(0,0,0), + scale = 10 } }, - Teleport={ - SequenceSpeed=0.77, - SequenceSpeedFast=0.935, - DematSequence={ + Teleport = { + SequenceSpeed = 0.77, + SequenceSpeedFast = 0.935, + DematSequence = { 150, 200, 100, @@ -119,7 +121,7 @@ T.Exterior={ 100, 0 }, - MatSequence={ + MatSequence = { 100, 50, 150, diff --git a/lua/tardis/interiors/default.lua b/lua/tardis/interiors/default.lua index 3ed40515c..120934882 100644 --- a/lua/tardis/interiors/default.lua +++ b/lua/tardis/interiors/default.lua @@ -120,8 +120,6 @@ T.Interior = { default_biglever = "fastreturn", default_physlock = "physlock", default_isomorphic = "isomorphic", - default_atomaccel = nil, - default_directionalpointer = nil, default_float = "float", default_blacksticks = "cloak", default_longflighttoggle = "vortex_flight", @@ -129,6 +127,8 @@ T.Interior = { default_sonicdispenser = "sonic_dispenser", default_sonic_inserted = SonicModelExists() and "sonic_dispenser", default_helmic = "thirdperson", + default_atomaccel = "spin_toggle", + default_directionalpointer = "spin_switch", }, diff --git a/lua/tardis/libraries/sh_messages.lua b/lua/tardis/libraries/sh_messages.lua index 24e532931..2bc0224e3 100644 --- a/lua/tardis/libraries/sh_messages.lua +++ b/lua/tardis/libraries/sh_messages.lua @@ -61,24 +61,19 @@ function TARDIS:Message(ply, message, error) return end local style = self.msg_style - local fullmessage = "[TARDIS] "..message + + local prefix = "[TARDIS] " + local err = error and "ERROR: " or "" + if style == 0 then return end if style == 1 then - if error then - print("ERROR: "..fullmessage) - else - print(fullmessage) - end + print(prefix .. err .. message) return end if style == 2 then - if error then - LocalPlayer():ChatPrint("ERROR: "..fullmessage) - else - LocalPlayer():ChatPrint(fullmessage) - end + LocalPlayer():ChatPrint(prefix .. err .. message) return end if style == 3 then @@ -88,8 +83,8 @@ function TARDIS:Message(ply, message, error) else notifyType = NOTIFY_GENERIC end - notification.AddLegacy(fullmessage, notifyType, 5) - print(fullmessage) + notification.AddLegacy(prefix .. message, notifyType, 5) + print(prefix .. err .. message) return end end diff --git a/lua/tardis/parts/default/default_int_atomaccel.lua b/lua/tardis/parts/default/default_int_atomaccel.lua index 5cb8807cb..fedc95e07 100644 --- a/lua/tardis/parts/default/default_int_atomaccel.lua +++ b/lua/tardis/parts/default/default_int_atomaccel.lua @@ -8,21 +8,4 @@ PART.Model = "models/drmatt/tardis/atomaccel.mdl" PART.AutoSetup = true PART.Collision = true -if SERVER then - function PART:Use(ply) - local dir - if self.exterior.spindir==-1 then - self.exterior.spindir=0 - dir="none" - elseif self.exterior.spindir==0 then - self.exterior.spindir=1 - dir="clockwise" - elseif self.exterior.spindir==1 then - self.exterior.spindir=-1 - dir="anti-clockwise" - end - TARDIS:Message(ply, "Spin direction set to "..dir) - end -end - TARDIS:AddPart(PART) diff --git a/lua/tardis/parts/door.lua b/lua/tardis/parts/door.lua index 25a56547c..522402347 100644 --- a/lua/tardis/parts/door.lua +++ b/lua/tardis/parts/door.lua @@ -16,7 +16,7 @@ if SERVER then function PART:Initialize() self:SetBodygroup(1,1) -- Sticker self:SetBodygroup(2,1) -- Lit sign - + if self.ExteriorPart then self.ClientDrawOverride = true self:SetSolid(SOLID_VPHYSICS) @@ -26,7 +26,7 @@ if SERVER then self:SetBodygroup(3,1) -- 3D sign table.insert(self.interior.stuckfilter, self) end - + local metadata=self.exterior.metadata local portal=self.ExteriorPart and metadata.Exterior.Portal or metadata.Interior.Portal if portal then @@ -38,7 +38,7 @@ if SERVER then self:SetParent(self.parent) end end - + function PART:Use(a) if self.exterior:GetData("locked") then if IsValid(a) and a:IsPlayer() then @@ -55,12 +55,13 @@ if SERVER then self.exterior:PlayerExit(a) end else + if self.exterior.metadata.EnableClassicDoors == true and not self.ExteriorPart then return end if (self.exterior:GetData("repair-primed",false) or self.exterior:GetData("repairing",false)) and self.ExteriorPart then return end self.exterior:ToggleDoor() end end end - + hook.Add("SkinChanged", "tardisi-door", function(ent,i) if ent.TardisExterior then local door=ent:GetPart("door") @@ -80,14 +81,17 @@ else self.DoorPos=0 self.DoorTarget=0 end - + function PART:Think() if self.ExteriorPart then self.DoorTarget=self.exterior.DoorOverride or (self.exterior:GetData("doorstatereal",false) and 1 or 0) - + + local animtime = self.exterior.metadata.Exterior.DoorAnimationTime + -- Have to spam it otherwise it glitches out (http://facepunch.com/showthread.php?t=1414695) - self.DoorPos=self.exterior.DoorOverride or math.Approach(self.DoorPos,self.DoorTarget,FrameTime()*(1/self.exterior.metadata.Exterior.DoorAnimationTime)) - + self.DoorPos = self.exterior.DoorOverride or + math.Approach(self.DoorPos, self.DoorTarget, FrameTime() * (1 / animtime)) + self:SetPoseParameter("switch", self.DoorPos) self:InvalidateBoneCache() elseif self.InteriorPart then -- copy exterior, no need to redo the calculation diff --git a/lua/tardis/parts/intdoor.lua b/lua/tardis/parts/intdoor.lua new file mode 100644 index 000000000..d812176f2 --- /dev/null +++ b/lua/tardis/parts/intdoor.lua @@ -0,0 +1,51 @@ +local PART={} +PART.ID = "intdoor" +PART.Name = "Interior Doors" +PART.Model = "models/drmatt/tardis/exterior/door.mdl" +PART.AutoSetup = true +PART.AutoPosition = true +PART.ClientThinkOverride = true +PART.Collision = false +PART.NoStrictUse = true +PART.ShouldTakeDamage = true +PART.BypassIsomorphic = true + + +if SERVER then + function PART:Use(a) + + if self.exterior:GetData("locked") then + if IsValid(a) and a:IsPlayer() then + if self.exterior:CallHook("LockedUse",a)==nil then + TARDIS:Message(a, "The doors are locked.") + end + end + else + if a:KeyDown(IN_WALK) then + self.exterior:PlayerExit(a) + end + end + end +else + + function PART:Initialize() + self.IntDoorPos=0 + self.IntDoorTarget=0 + end + + function PART:Think() + self.IntDoorTarget=self.exterior.IntDoorOverride or (self.exterior:GetData("doorstatereal",false) and 1 or 0) + local animtime = self.exterior.metadata.Interior.IntDoorAnimationTime + or self.exterior.metadata.Exterior.DoorAnimationTime + + -- Have to spam it otherwise it glitches out (http://facepunch.com/showthread.php?t=1414695) + self.IntDoorPos = self.exterior.IntDoorOverride or + math.Approach(self.IntDoorPos, self.IntDoorTarget, FrameTime() * (1 / animtime)) + + self:SetPoseParameter("switch", self.IntDoorPos) + self:InvalidateBoneCache() + + end +end + +TARDIS:AddPart(PART) \ No newline at end of file diff --git a/lua/tardis/sh_doors.lua b/lua/tardis/sh_doors_addon.lua similarity index 100% rename from lua/tardis/sh_doors.lua rename to lua/tardis/sh_doors_addon.lua diff --git a/lua/tardis/sh_interiors.lua b/lua/tardis/sh_interiors.lua index b6773e2fe..0e052e147 100644 --- a/lua/tardis/sh_interiors.lua +++ b/lua/tardis/sh_interiors.lua @@ -23,13 +23,42 @@ function TARDIS:AddInterior(t) if t.Base~=true then local ent={} - ent.Category="Doctor Who - TARDIS" - ent.PrintName=t.Name + + -- this is for developer debugging purposes only + local spm_overrides = DEBUG_TARDIS_SPAWNMENU_CATEGORY_OVERRIDES + + if spm_overrides ~= nil and (spm_overrides[t.ID] or spm_overrides[t.Name]) then + if spm_overrides[t.ID] then + ent.Category = spm_overrides[t.ID] + else + ent.Category = spm_overrides[t.Name] + end + elseif spm_overrides ~= nil and spm_overrides["all"] then + ent.Category = spm_overrides["all"] + else + ent.Category = "Doctor Who - TARDIS" + end + + local nm_overrides = DEBUG_TARDIS_SPAWNMENU_NAME_OVERRIDES + + if nm_overrides ~= nil and (nm_overrides[t.ID] or nm_overrides[t.Name]) then + if nm_overrides[t.ID] then + ent.PrintName = nm_overrides[t.ID] + else + ent.PrintName = nm_overrides[t.Name] + end + else + ent.PrintName = t.Name + end + if file.Exists("materials/vgui/entities/tardis/"..t.ID..".vtf", "GAME") then ent.IconOverride="vgui/entities/tardis/"..t.ID..".vtf" - else + elseif file.Exists("materials/vgui/entities/tardis/"..t.ID..".png", "GAME") + then ent.IconOverride="vgui/entities/tardis/"..t.ID..".png" + else + ent.IconOverride="vgui/entities/tardis/default/"..t.ID..".png" end ent.ScriptedEntityType="tardis" list.Set("SpawnableEntities", t.ID, ent) diff --git a/lua/tardis/sh_parts.lua b/lua/tardis/sh_parts.lua index ed24ce4d4..17266f7cb 100644 --- a/lua/tardis/sh_parts.lua +++ b/lua/tardis/sh_parts.lua @@ -8,15 +8,22 @@ function TARDIS.DrawOverride(self,override) if self.NoDraw then return end local int=self.interior local ext=self.exterior + if IsValid(ext) then - if (self.InteriorPart and IsValid(int) and ((int:CallHook("ShouldDraw")~=false) - or (ext:DoorOpen() - and (self.ClientDrawOverride and LocalPlayer():GetPos():Distance(ext:GetPos())