From 698b6eedf1d6d2806c77895775bcf8245ce02229 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 4 Jan 2016 13:26:04 -0500 Subject: Added building snap --- gamemode/itemsystem/items/alter.lua | 8 +++++++- gamemode/itemsystem/items/campfire.lua | 8 +++++++- gamemode/itemsystem/items/fence.lua | 8 +++++++- gamemode/itemsystem/items/floor.lua | 8 +++++++- gamemode/itemsystem/items/infuser.lua | 8 +++++++- gamemode/itemsystem/items/ramp.lua | 8 +++++++- gamemode/itemsystem/items/researchtable.lua | 8 +++++++- gamemode/itemsystem/items/shack.lua | 6 ++++++ gamemode/itemsystem/items/tent.lua | 5 +++++ gamemode/shared/player_ghost.lua | 5 +++++ 10 files changed, 65 insertions(+), 7 deletions(-) (limited to 'gamemode') diff --git a/gamemode/itemsystem/items/alter.lua b/gamemode/itemsystem/items/alter.lua index 31d1b4f..b60d30b 100644 --- a/gamemode/itemsystem/items/alter.lua +++ b/gamemode/itemsystem/items/alter.lua @@ -52,7 +52,13 @@ function ITEM:OnPrimary(pl,tr) if (tr.Hit) then local drop = ents.Create("ws_alter") drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0)) - drop:SetPos(tr.HitPos) + local Pos = tr.HitPos + if(GM:KeyPress(pl,IN_SPEED)) then + Pos.x = Pos.x - (Pos.x%20) + Pos.y = Pos.y - (Pos.y%20) + Pos.z = Pos.z - (Pos.z%20) + end + drop:SetPos(Pos) drop:Spawn() drop:Activate() diff --git a/gamemode/itemsystem/items/campfire.lua b/gamemode/itemsystem/items/campfire.lua index 5cc4987..f6ec4e6 100644 --- a/gamemode/itemsystem/items/campfire.lua +++ b/gamemode/itemsystem/items/campfire.lua @@ -68,7 +68,13 @@ function ITEM:OnPrimary(pl,tr) if (tr.Hit and tr.HitWorld) then local drop = ents.Create("ws_campfire") drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0)) - drop:SetPos(tr.HitPos) + local Pos = tr.HitPos + if(GM:KeyPress(pl,IN_SPEED)) then + Pos.x = Pos.x - (Pos.x%20) + Pos.y = Pos.y - (Pos.y%20) + Pos.z = Pos.z - (Pos.z%20) + end + drop:SetPos(Pos) drop:Spawn() drop:Activate() diff --git a/gamemode/itemsystem/items/fence.lua b/gamemode/itemsystem/items/fence.lua index e4a8217..d472aaa 100644 --- a/gamemode/itemsystem/items/fence.lua +++ b/gamemode/itemsystem/items/fence.lua @@ -45,7 +45,13 @@ function ITEM:OnPrimary(pl,tr) local drop = ents.Create("ws_prop") drop:SetModel("models/props_wasteland/wood_fence02a.mdl") drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0)) - drop:SetPos(tr.HitPos) + local Pos = tr.HitPos + if(GM:KeyPress(pl,IN_SPEED)) then + Pos.x = Pos.x - (Pos.x%20) + Pos.y = Pos.y - (Pos.y%20) + Pos.z = Pos.z - (Pos.z%20) + end + drop:SetPos(Pos) drop:Spawn() drop:Activate() diff --git a/gamemode/itemsystem/items/floor.lua b/gamemode/itemsystem/items/floor.lua index c02815b..82eb3ec 100644 --- a/gamemode/itemsystem/items/floor.lua +++ b/gamemode/itemsystem/items/floor.lua @@ -46,7 +46,13 @@ function ITEM:OnPrimary(pl,tr) local drop = ents.Create("ws_prop") drop:SetModel("models/props_wasteland/wood_fence02a.mdl") drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,90)) - drop:SetPos(tr.HitPos) + local Pos = tr.HitPos + if(GM:KeyPress(pl,IN_SPEED)) then + Pos.x = Pos.x - (Pos.x%20) + Pos.y = Pos.y - (Pos.y%20) + Pos.z = Pos.z - (Pos.z%20) + end + drop:SetPos(Pos) drop:Spawn() drop:Activate() diff --git a/gamemode/itemsystem/items/infuser.lua b/gamemode/itemsystem/items/infuser.lua index d2f72ad..260e8fd 100644 --- a/gamemode/itemsystem/items/infuser.lua +++ b/gamemode/itemsystem/items/infuser.lua @@ -43,7 +43,13 @@ function ITEM:OnPrimary(pl,tr) if (tr.Hit) then local drop = ents.Create("ws_infuser") drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0)) - drop:SetPos(tr.HitPos) + local Pos = tr.HitPos + if(GM:KeyPress(pl,IN_SPEED)) then + Pos.x = Pos.x - (Pos.x%20) + Pos.y = Pos.y - (Pos.y%20) + Pos.z = Pos.z - (Pos.z%20) + end + drop:SetPos(Pos) drop:Spawn() drop:Activate() diff --git a/gamemode/itemsystem/items/ramp.lua b/gamemode/itemsystem/items/ramp.lua index 96e6c27..9d6fd2b 100644 --- a/gamemode/itemsystem/items/ramp.lua +++ b/gamemode/itemsystem/items/ramp.lua @@ -46,7 +46,13 @@ function ITEM:OnPrimary(pl,tr) local drop = ents.Create("ws_prop") drop:SetModel("models/props_wasteland/wood_fence02a.mdl") drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,45)) - drop:SetPos(tr.HitPos) + local Pos = tr.HitPos + if(GM:KeyPress(pl,IN_SPEED)) then + Pos.x = Pos.x - (Pos.x%20) + Pos.y = Pos.y - (Pos.y%20) + Pos.z = Pos.z - (Pos.z%20) + end + drop:SetPos(Pos) drop:Spawn() drop:Activate() diff --git a/gamemode/itemsystem/items/researchtable.lua b/gamemode/itemsystem/items/researchtable.lua index 4b05cf2..b347828 100644 --- a/gamemode/itemsystem/items/researchtable.lua +++ b/gamemode/itemsystem/items/researchtable.lua @@ -41,7 +41,13 @@ function ITEM:OnPrimary(pl,tr) if (tr.Hit) then local drop = ents.Create("ws_researchtable") drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0)) - drop:SetPos(tr.HitPos) + local Pos = tr.HitPos + if(GM:KeyPress(pl,IN_SPEED)) then + Pos.x = Pos.x - (Pos.x%20) + Pos.y = Pos.y - (Pos.y%20) + Pos.z = Pos.z - (Pos.z%20) + end + drop:SetPos(Pos) drop:Spawn() drop:Activate() diff --git a/gamemode/itemsystem/items/shack.lua b/gamemode/itemsystem/items/shack.lua index f66fe38..9090fb3 100644 --- a/gamemode/itemsystem/items/shack.lua +++ b/gamemode/itemsystem/items/shack.lua @@ -83,6 +83,12 @@ function ITEM:OnPrimary(pl,tr) local Ang = Angle(0,pl:GetAimVector():Angle().y+90,0) local Pos = tr.HitPos + if(GM:KeyPress(pl,IN_SPEED)) then + Pos.x = Pos.x - (Pos.x%20) + Pos.y = Pos.y - (Pos.y%20) + Pos.z = Pos.z - (Pos.z%20) + end + for k,v in pairs(self.Ghost) do local Off = v.Pos*1 Off:Rotate(Ang) diff --git a/gamemode/itemsystem/items/tent.lua b/gamemode/itemsystem/items/tent.lua index 1d5a1b5..3cbb207 100644 --- a/gamemode/itemsystem/items/tent.lua +++ b/gamemode/itemsystem/items/tent.lua @@ -50,6 +50,11 @@ function ITEM:OnPrimary(pl,tr) if (tr.Hit) then local Ang = Angle(0,pl:GetAimVector():Angle().y+90,0) local Pos = tr.HitPos + if(GM:KeyPress(pl,IN_SPEED)) then + Pos.x = Pos.x - (Pos.x%20) + Pos.y = Pos.y - (Pos.y%20) + Pos.z = Pos.z - (Pos.z%20) + end for k,v in pairs(self.Ghost) do local Off = v.Pos*1 diff --git a/gamemode/shared/player_ghost.lua b/gamemode/shared/player_ghost.lua index ef61422..d2eade8 100644 --- a/gamemode/shared/player_ghost.lua +++ b/gamemode/shared/player_ghost.lua @@ -54,6 +54,11 @@ else local CanP = pl:CanPlaceStructure(Pos) Pos = Pos.HitPos + if(pl:KeyDown(IN_SPEED)) then + Pos.x = Pos.x - (Pos.x%20) + Pos.y = Pos.y - (Pos.y%20) + Pos.z = Pos.z - (Pos.z%20) + end for k,v in pairs(pl.GhostItem.Ghost) do local OffPos = v.Pos*1 -- cgit v1.2.3-70-g09d2