diff options
| author | Apickx <Apickx@cogarr.org> | 2015-12-28 19:10:44 -0500 |
|---|---|---|
| committer | Apickx <Apickx@cogarr.org> | 2015-12-28 19:10:44 -0500 |
| commit | 5c4ebc932d8c02522802c842d43d863d89aca162 (patch) | |
| tree | 6be7ad664bdf060127e6df6baa72beaf508aa149 /entities | |
| download | wintersurvival2-5c4ebc932d8c02522802c842d43d863d89aca162.tar.gz wintersurvival2-5c4ebc932d8c02522802c842d43d863d89aca162.tar.bz2 wintersurvival2-5c4ebc932d8c02522802c842d43d863d89aca162.zip | |
Initial commit
Diffstat (limited to 'entities')
37 files changed, 1460 insertions, 0 deletions
diff --git a/entities/entities/ws_alter/cl_init.lua b/entities/entities/ws_alter/cl_init.lua new file mode 100644 index 0000000..3baf05f --- /dev/null +++ b/entities/entities/ws_alter/cl_init.lua @@ -0,0 +1,57 @@ +include('shared.lua')
+
+local Up = Vector(0,0,20)
+local Sc = Vector(8,1,1)
+
+function ENT:Initialize()
+ timer.Simple(0.1,function() self.Pos = self:GetPos() self.Ang = self:GetAngles() end)
+
+ self.Dibs = ClientsideModel("models/props_c17/gravestone003a.mdl")
+ self.Dibs:SetNoDraw(true)
+end
+
+function ENT:Think()
+ if (!self.Pos) then return end
+
+ local light = DynamicLight(self:EntIndex())
+
+ if (light) then
+ light.Pos = self.Pos + Up
+
+ light.r = 255
+ light.g = 10
+ light.b = 0
+
+ light.Brightness = 4
+ light.Size = 400
+ light.Decay = 700
+ light.DieTime = CurTime()+1
+ light.Style = 0
+ end
+end
+
+
+local a = Angle(0,180,0)
+local A = Angle(90,0,0)
+
+function ENT:Draw()
+ if (!self.Pos) then return end
+
+ local mat = Matrix()
+ mat:Scale(Sc)
+
+ local vec = Vector(22,0,0)
+ vec:Rotate(self.Ang)
+
+ for i = 0,1 do
+ local ab = a*i
+
+ vec:Rotate(ab)
+
+ self.Dibs:EnableMatrix( "RenderMultiply", mat )
+ self.Dibs:SetRenderOrigin(self.Pos+vec)
+ self.Dibs:SetRenderAngles(self.Ang+ab+A)
+ self.Dibs:SetupBones()
+ self.Dibs:DrawModel()
+ end
+end
diff --git a/entities/entities/ws_alter/init.lua b/entities/entities/ws_alter/init.lua new file mode 100644 index 0000000..a8f6641 --- /dev/null +++ b/entities/entities/ws_alter/init.lua @@ -0,0 +1,99 @@ +AddCSLuaFile("cl_init.lua")
+AddCSLuaFile("shared.lua")
+
+include('shared.lua')
+
+local ResurrectionTable = {
+ ["Meat"] = 25,
+ ["Berry"] = 30,
+ ["Feather"] = 10,
+}
+
+function ENT:Initialize()
+ self:SetModel("models/props_junk/wood_crate001a.mdl")
+ self:PhysicsInit(SOLID_VPHYSICS)
+ self:SetMoveType(MOVETYPE_NONE)
+ self:SetSolid(SOLID_VPHYSICS)
+ self:SetUseType(SIMPLE_USE)
+
+ local phys = self:GetPhysicsObject()
+ phys:EnableMotion(false)
+ phys:Sleep()
+
+ self:SetHealth(30)
+
+ self.StoredItems = {}
+end
+
+function ENT:Think()
+ local HasItems = {}
+
+ for k,v in pairs(self.StoredItems) do
+ if (ResurrectionTable[v.Name] and v.Quantity >= ResurrectionTable[v.Name]) then
+ HasItems[v.Name] = {k,ResurrectionTable[v.Name]}
+ end
+ end
+
+ if (table.Count(HasItems) >= table.Count(ResurrectionTable)) then
+ for k,v in pairs(player.GetAll()) do
+ if (v:IsPigeon() and v:Alive() and v:GetPos():Distance(self:GetPos()) < 200) then
+ v:SetHuman(true)
+ v:KillSilent()
+ v:ChatPrint("You have been resurrected from the dead!")
+ self:EmitSound("wintersurvival2/ritual/wololo.mp3")
+
+ for a,b in pairs(HasItems) do
+ if (self.StoredItems[b[1]].Quantity == b[2]) then table.remove(self.StoredItems,b[1])
+ else self.StoredItems[b[1]].Quantity = self.StoredItems[b[1]].Quantity-b[2] end
+ end
+
+ v:Spawn()
+
+ break
+ end
+ end
+ end
+
+ self:NextThink(CurTime()+10)
+ return true
+end
+
+function ENT:AddItem(item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ v.Quantity = v.Quantity + quantity
+ return
+ end
+ end
+
+ table.insert(self.StoredItems,{Name = item, Quantity = quantity})
+end
+
+function ENT:TakeItem(pl,item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ quantity = math.min(quantity,v.Quantity)
+ v.Quantity = v.Quantity - quantity
+
+ pl:AddItem(item,quantity)
+
+ if (v.Quantity <= 0) then table.remove(self.StoredItems,k) end
+ break
+ end
+ end
+end
+
+function ENT:GetItems()
+ return self.StoredItems
+end
+
+function ENT:Use(pl)
+ if (pl:IsPigeon()) then return end
+ OpenLootventory(pl,self.StoredItems,self)
+end
+
+function ENT:OnTakeDamage(dmg)
+ self:SetHealth(self:Health()-dmg)
+
+ if (self:Health() <= 0) then self:Remove() end
+end
\ No newline at end of file diff --git a/entities/entities/ws_alter/shared.lua b/entities/entities/ws_alter/shared.lua new file mode 100644 index 0000000..e67f5f4 --- /dev/null +++ b/entities/entities/ws_alter/shared.lua @@ -0,0 +1,5 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
+
+function ENT:OnRemove()
+end
diff --git a/entities/entities/ws_arrow/cl_init.lua b/entities/entities/ws_arrow/cl_init.lua new file mode 100644 index 0000000..b323b28 --- /dev/null +++ b/entities/entities/ws_arrow/cl_init.lua @@ -0,0 +1,5 @@ +include('shared.lua')
+
+function ENT:Draw()
+ self.Entity:DrawModel()
+end
diff --git a/entities/entities/ws_arrow/init.lua b/entities/entities/ws_arrow/init.lua new file mode 100644 index 0000000..e27dda9 --- /dev/null +++ b/entities/entities/ws_arrow/init.lua @@ -0,0 +1,27 @@ +AddCSLuaFile("cl_init.lua")
+AddCSLuaFile("shared.lua")
+
+include('shared.lua')
+
+local Ab = Color(255,255,255,100)
+
+function ENT:Initialize()
+ self:SetModel("models/mixerman3d/other/arrow.mdl")
+ self:PhysicsInit(SOLID_VPHYSICS)
+ self:SetMoveType(MOVETYPE_VPHYSICS)
+ self:SetSolid(SOLID_VPHYSICS)
+ self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
+ self:PhysWake()
+ self:SetUseType(SIMPLE_USE)
+
+ util.SpriteTrail( self, 0, Ab, true, 1, 0, 1, 1, "sprites/smoke_trail.vmt" )
+
+ self:NextThink(CurTime()+10)
+end
+
+function ENT:Think()
+ self:Remove()
+ return true
+end
+
+
diff --git a/entities/entities/ws_arrow/shared.lua b/entities/entities/ws_arrow/shared.lua new file mode 100644 index 0000000..e67f5f4 --- /dev/null +++ b/entities/entities/ws_arrow/shared.lua @@ -0,0 +1,5 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
+
+function ENT:OnRemove()
+end
diff --git a/entities/entities/ws_barrel/cl_init.lua b/entities/entities/ws_barrel/cl_init.lua new file mode 100644 index 0000000..b323b28 --- /dev/null +++ b/entities/entities/ws_barrel/cl_init.lua @@ -0,0 +1,5 @@ +include('shared.lua')
+
+function ENT:Draw()
+ self.Entity:DrawModel()
+end
diff --git a/entities/entities/ws_barrel/init.lua b/entities/entities/ws_barrel/init.lua new file mode 100644 index 0000000..28d8d20 --- /dev/null +++ b/entities/entities/ws_barrel/init.lua @@ -0,0 +1,60 @@ +AddCSLuaFile("cl_init.lua")
+AddCSLuaFile("shared.lua")
+
+include('shared.lua')
+
+function ENT:Initialize()
+ self:SetModel("models/props_c17/oildrum001.mdl")
+ self:PhysicsInit(SOLID_VPHYSICS)
+ self:SetMoveType(MOVETYPE_NONE)
+ self:SetSolid(SOLID_VPHYSICS)
+ self:SetUseType(SIMPLE_USE)
+
+ local phys = self:GetPhysicsObject()
+ phys:EnableMotion(false)
+ phys:Sleep()
+
+ self:SetHealth(30)
+
+ self.StoredItems = {}
+end
+
+function ENT:AddItem(item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ v.Quantity = v.Quantity + quantity
+ return
+ end
+ end
+
+ table.insert(self.StoredItems,{Name = item, Quantity = quantity})
+end
+
+function ENT:TakeItem(pl,item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ quantity = math.min(quantity,v.Quantity)
+ v.Quantity = v.Quantity - quantity
+
+ pl:AddItem(item,quantity)
+
+ if (v.Quantity <= 0) then table.remove(self.StoredItems,k) end
+ break
+ end
+ end
+end
+
+function ENT:GetItems()
+ return self.StoredItems
+end
+
+function ENT:Use(pl)
+ if (pl:IsPigeon()) then return end
+ OpenLootventory(pl,self.StoredItems,self)
+end
+
+function ENT:OnTakeDamage(dmg)
+ self:SetHealth(self:Health()-dmg)
+
+ if (self:Health() <= 0) then self:Remove() end
+end
diff --git a/entities/entities/ws_barrel/shared.lua b/entities/entities/ws_barrel/shared.lua new file mode 100644 index 0000000..e67f5f4 --- /dev/null +++ b/entities/entities/ws_barrel/shared.lua @@ -0,0 +1,5 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
+
+function ENT:OnRemove()
+end
diff --git a/entities/entities/ws_campfire/cl_init.lua b/entities/entities/ws_campfire/cl_init.lua new file mode 100644 index 0000000..21479fa --- /dev/null +++ b/entities/entities/ws_campfire/cl_init.lua @@ -0,0 +1,80 @@ +include('shared.lua')
+ENT.RenderGroup = RENDERGROUP_BOTH
+
+local ZeroA = Angle(0,0,0)
+local Flame = Material("particles/fire1")
+
+local Up = Vector(0,0,120)
+local UP = Vector(0,0,32)
+
+function ENT:Initialize()
+ self.FrameA = 0
+ self.LastDrawn = UnPredictedCurTime()
+
+ self.Dibs = ClientsideModel("models/props_debris/wood_board02a.mdl")
+ self.Dibs:SetNoDraw(true)
+ self.Dibs:DrawShadow(false)
+
+ timer.Simple(0.1,function() self.Pos = self:GetPos() self.Ang = self:GetAngles() end)
+end
+
+function ENT:OnRemove()
+end
+
+function ENT:Think()
+ if (!self.Pos) then return end
+/*
+ local light = DynamicLight(self:EntIndex())
+
+ if (light) then
+ light.Pos = self.Pos + UP
+
+ light.r = 255
+ light.g = 140
+ light.b = 0
+
+ light.Brightness = 1
+ light.Size = 400
+ light.Decay = 700
+ light.DieTime = CurTime()+1
+ light.Style = 0
+ end*/
+end
+
+function ENT:Draw()
+ if (!self.Pos) then return end
+
+ local Vec = Vector(10,0,0)
+ Vec:Rotate(self.Ang)
+
+ for i = 1,4 do
+ Vec:Rotate(Angle(0,90,0))
+
+ local AB = self.Pos+Vec
+
+ self.Dibs:SetRenderOrigin(AB)
+ self.Dibs:SetRenderAngles(Angle(-45,90*i,0)+self.Ang)
+ self.Dibs:SetupBones()
+ self.Dibs:DrawModel()
+ end
+
+ self:DrawModel()
+end
+
+
+function ENT:DrawTranslucent()
+ if (!self.Pos) then return end
+ --[[
+ local FlameStart = self.Pos
+ local FlameEnd = self.Pos + Up
+
+ self.FrameA = self.FrameA+(UnPredictedCurTime()-self.LastDrawn)*20
+ if (self.FrameA > 52) then self.FrameA = 0 end
+
+ Flame:SetFloat("$frame", self.FrameA)
+ --render.SetMaterial(Flame)
+ --render.DrawBeam(FlameStart,FlameEnd,48,0.99,0,MAIN_WHITECOLOR)
+
+ self.LastDrawn = UnPredictedCurTime()
+ ]]--
+end
diff --git a/entities/entities/ws_campfire/init.lua b/entities/entities/ws_campfire/init.lua new file mode 100644 index 0000000..6a40aed --- /dev/null +++ b/entities/entities/ws_campfire/init.lua @@ -0,0 +1,96 @@ +AddCSLuaFile( "cl_init.lua" )
+AddCSLuaFile( "shared.lua" )
+
+include('shared.lua')
+
+function ENT:Initialize()
+ self:SetModel("models/props_junk/Rock001a.mdl")
+ self:PhysicsInit( SOLID_VPHYSICS )
+ self:SetMoveType( MOVETYPE_NONE )
+ self:SetSolid( SOLID_VPHYSICS )
+ self:SetCollisionGroup( COLLISION_GROUP_INTERACTIVE )
+ self:SetUseType(SIMPLE_USE)
+
+ local phys = self:GetPhysicsObject()
+
+ phys:EnableMotion(false)
+ phys:Sleep()
+
+ self.StoredItems = {}
+ self:Ignite(1000)
+end
+
+function ENT:BeginCooking(item)
+end
+
+function ENT:Think()
+
+ if not self:IsOnFire() then
+ self:Remove()
+ end
+
+ for k,v in pairs(player.GetAllHumans()) do
+ if (v:GetPos():Distance(self:GetPos()) < 500) then
+ v:AddHeat(-5)
+ end
+ end
+
+ for k,v in pairs(self.StoredItems) do
+ if (v.Timer < CurTime()-13) then
+ if (GetItemByName(v.Name).OnCooked) then
+ GetItemByName(v.Name):OnCooked(self)
+ end
+
+ if (v.Quantity > 1) then
+ v.Quantity = v.Quantity - 1
+ else
+ table.remove(self.StoredItems,k)
+ end
+
+ self:EmitSound("ambient/fire/mtov_flame2.wav",100,math.random(80,100))
+
+ v.Timer = CurTime()+13
+ end
+ end
+
+ self:NextThink(CurTime()+1)
+ return true
+end
+
+function ENT:AddItem(item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ v.Quantity = v.Quantity + quantity
+ return
+ end
+ end
+
+ table.insert(self.StoredItems,{Name = item, Quantity = quantity, Timer = CurTime(),})
+end
+
+function ENT:TakeItem(pl,item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ quantity = math.min(quantity,v.Quantity)
+ v.Quantity = v.Quantity - quantity
+
+ pl:AddItem(item,quantity)
+
+ if (v.Quantity <= 0) then table.remove(self.StoredItems,k) end
+ break
+ end
+ end
+end
+
+function ENT:GetItems()
+ return self.StoredItems
+end
+
+function ENT:Use(pl)
+ if (pl:IsPigeon()) then return end
+ OpenLootventory(pl,self.StoredItems,self)
+end
+
+function ENT:PhysicsCollide( data, physobj )
+
+end
diff --git a/entities/entities/ws_campfire/shared.lua b/entities/entities/ws_campfire/shared.lua new file mode 100644 index 0000000..d5924f4 --- /dev/null +++ b/entities/entities/ws_campfire/shared.lua @@ -0,0 +1,2 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
\ No newline at end of file diff --git a/entities/entities/ws_grave/cl_init.lua b/entities/entities/ws_grave/cl_init.lua new file mode 100644 index 0000000..b323b28 --- /dev/null +++ b/entities/entities/ws_grave/cl_init.lua @@ -0,0 +1,5 @@ +include('shared.lua')
+
+function ENT:Draw()
+ self.Entity:DrawModel()
+end
diff --git a/entities/entities/ws_grave/init.lua b/entities/entities/ws_grave/init.lua new file mode 100644 index 0000000..17995ba --- /dev/null +++ b/entities/entities/ws_grave/init.lua @@ -0,0 +1,60 @@ +AddCSLuaFile("cl_init.lua")
+AddCSLuaFile("shared.lua")
+
+include('shared.lua')
+
+function ENT:Initialize()
+ self:SetModel("models/props_c17/gravestone002a.mdl")
+ self:PhysicsInit(SOLID_VPHYSICS)
+ self:SetMoveType(MOVETYPE_NONE)
+ self:SetSolid(SOLID_VPHYSICS)
+ self:SetUseType(SIMPLE_USE)
+
+ local phys = self:GetPhysicsObject()
+ phys:EnableMotion(false)
+ phys:Sleep()
+
+ self:SetHealth(30)
+
+ self.StoredItems = {}
+end
+
+function ENT:AddItem(item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ v.Quantity = v.Quantity + quantity
+ return
+ end
+ end
+
+ table.insert(self.StoredItems,{Name = item, Quantity = quantity})
+end
+
+function ENT:TakeItem(pl,item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ quantity = math.min(quantity,v.Quantity)
+ v.Quantity = v.Quantity - quantity
+
+ pl:AddItem(item,quantity)
+
+ if (v.Quantity <= 0) then table.remove(self.StoredItems,k) end
+ break
+ end
+ end
+end
+
+function ENT:GetItems()
+ return self.StoredItems
+end
+
+function ENT:Use(pl)
+ if (pl:IsPigeon()) then return end
+ OpenLootventory(pl,self.StoredItems,self)
+end
+
+function ENT:OnTakeDamage(dmg)
+ self:SetHealth(self:Health()-dmg)
+
+ if (self:Health() <= 0) then self:Remove() end
+end
diff --git a/entities/entities/ws_grave/shared.lua b/entities/entities/ws_grave/shared.lua new file mode 100644 index 0000000..e67f5f4 --- /dev/null +++ b/entities/entities/ws_grave/shared.lua @@ -0,0 +1,5 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
+
+function ENT:OnRemove()
+end
diff --git a/entities/entities/ws_infuser/cl_init.lua b/entities/entities/ws_infuser/cl_init.lua new file mode 100644 index 0000000..e84bc68 --- /dev/null +++ b/entities/entities/ws_infuser/cl_init.lua @@ -0,0 +1,78 @@ +include('shared.lua')
+ENT.RenderGroup = RENDERGROUP_BOTH
+
+local Up = Vector(0,0,20)
+local Sc = Vector(8,1,1)
+
+function ENT:Initialize()
+ timer.Simple(0.1,function() self.Pos = self:GetPos() self.Ang = self:GetAngles() end)
+
+ self.Dibs = ClientsideModel("models/props_c17/gravestone001a.mdl")
+ self.Dibs:SetNoDraw(true)
+end
+
+function ENT:OnRemove()
+end
+
+function ENT:Think()
+ if (!self.Pos) then return end
+/*
+ local light = DynamicLight(self:EntIndex())
+
+ if (light) then
+ light.Pos = self.Pos + UP
+
+ light.r = 255
+ light.g = 140
+ light.b = 0
+
+ light.Brightness = 1
+ light.Size = 400
+ light.Decay = 700
+ light.DieTime = CurTime()+1
+ light.Style = 0
+ end*/
+end
+
+
+
+local a = Angle(0,180,0)
+local A = Angle(90,0,90)
+
+function ENT:Draw()
+ if (!self.Pos) then return end
+
+ local mat = Matrix()
+ mat:Scale(Sc)
+
+ local vec = Vector(0,0,0)
+ vec:Rotate(self.Ang)
+
+ local ab = a*0
+
+ vec:Rotate(ab)
+
+ self.Dibs:EnableMatrix( "RenderMultiply", mat )
+ self.Dibs:SetRenderOrigin(self.Pos+vec)
+ self.Dibs:SetRenderAngles(self.Ang+ab+A)
+ self.Dibs:SetupBones()
+ self.Dibs:DrawModel()
+end
+
+function ENT:DrawTranslucent()
+ --[[
+ if (!self.Pos) then return end
+
+ local FlameStart = self.Pos
+ local FlameEnd = self.Pos + Up
+
+ self.FrameA = self.FrameA+(UnPredictedCurTime()-self.LastDrawn)*20
+ if (self.FrameA > 52) then self.FrameA = 0 end
+
+ Flame:SetFloat("$frame", self.FrameA)
+ render.SetMaterial(Flame)
+ render.DrawBeam(FlameStart,FlameEnd,48,0.99,0,MAIN_WHITECOLOR)
+
+ self.LastDrawn = UnPredictedCurTime()
+ ]]--
+end
diff --git a/entities/entities/ws_infuser/init.lua b/entities/entities/ws_infuser/init.lua new file mode 100644 index 0000000..fb180d0 --- /dev/null +++ b/entities/entities/ws_infuser/init.lua @@ -0,0 +1,90 @@ +AddCSLuaFile( "cl_init.lua" )
+AddCSLuaFile( "shared.lua" )
+
+include('shared.lua')
+
+function ENT:Initialize()
+ self:SetModel("models/props_junk/wood_crate002a.mdl")
+ self:PhysicsInit( SOLID_VPHYSICS )
+ self:SetMoveType( MOVETYPE_NONE )
+ self:SetSolid( SOLID_VPHYSICS )
+ self:SetCollisionGroup( COLLISION_GROUP_INTERACTIVE )
+ self:SetUseType(SIMPLE_USE)
+
+ local phys = self:GetPhysicsObject()
+
+ phys:EnableMotion(false)
+ phys:Sleep()
+
+ self.StoredItems = {}
+end
+
+function ENT:BeginCooking(item)
+end
+
+function ENT:Think()
+ for k,v in pairs(self.StoredItems) do
+ if (v.Timer < CurTime()-13) then
+ nearbyrunes = ents.FindByClass("ws_rune")
+ for k,v in pairs(nearbyrunes) do
+ if(v:GetPos():Distance(self:GetPos()) > 1000) then
+ table.remove(nearbyrunes,k)
+ end
+ end
+ if (GetItemByName(v.Name).OnEnchanted) then
+ GetItemByName(v.Name):OnEnchanted(self, nearbyrunes)
+ end
+
+ if (v.Quantity > 1) then
+ v.Quantity = v.Quantity - 1
+ else
+ table.remove(self.StoredItems,k)
+ end
+
+ self:EmitSound("ambient/fire/mtov_flame2.wav",100,math.random(80,100))
+
+ v.Timer = CurTime()+13
+ end
+ end
+
+ self:NextThink(CurTime()+1)
+ return true
+end
+
+function ENT:AddItem(item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ v.Quantity = v.Quantity + quantity
+ return
+ end
+ end
+
+ table.insert(self.StoredItems,{Name = item, Quantity = quantity, Timer = CurTime(),})
+end
+
+function ENT:TakeItem(pl,item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ quantity = math.min(quantity,v.Quantity)
+ v.Quantity = v.Quantity - quantity
+
+ pl:AddItem(item,quantity)
+
+ if (v.Quantity <= 0) then table.remove(self.StoredItems,k) end
+ break
+ end
+ end
+end
+
+function ENT:GetItems()
+ return self.StoredItems
+end
+
+function ENT:Use(pl)
+ if (pl:IsPigeon()) then return end
+ OpenLootventory(pl,self.StoredItems,self)
+end
+
+function ENT:PhysicsCollide( data, physobj )
+
+end
diff --git a/entities/entities/ws_infuser/shared.lua b/entities/entities/ws_infuser/shared.lua new file mode 100644 index 0000000..d5924f4 --- /dev/null +++ b/entities/entities/ws_infuser/shared.lua @@ -0,0 +1,2 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
\ No newline at end of file diff --git a/entities/entities/ws_item/cl_init.lua b/entities/entities/ws_item/cl_init.lua new file mode 100644 index 0000000..b323b28 --- /dev/null +++ b/entities/entities/ws_item/cl_init.lua @@ -0,0 +1,5 @@ +include('shared.lua')
+
+function ENT:Draw()
+ self.Entity:DrawModel()
+end
diff --git a/entities/entities/ws_item/init.lua b/entities/entities/ws_item/init.lua new file mode 100644 index 0000000..84b7134 --- /dev/null +++ b/entities/entities/ws_item/init.lua @@ -0,0 +1,22 @@ +AddCSLuaFile("cl_init.lua")
+AddCSLuaFile("shared.lua")
+
+include('shared.lua')
+
+function ENT:Initialize()
+ self:PhysicsInit(SOLID_VPHYSICS)
+ self:SetMoveType(MOVETYPE_VPHYSICS)
+ self:SetSolid(SOLID_VPHYSICS)
+ self:SetCollisionGroup(COLLISION_GROUP_WEAPON)
+ self:PhysWake()
+ self:SetUseType(SIMPLE_USE)
+
+ if (!self.Item) then self:Remove() end
+end
+
+function ENT:Use(pl)
+ if (pl:IsPigeon()) then return end
+ pl:AddItem(self.Item.Name,1)
+
+ self:Remove()
+end
diff --git a/entities/entities/ws_item/shared.lua b/entities/entities/ws_item/shared.lua new file mode 100644 index 0000000..e67f5f4 --- /dev/null +++ b/entities/entities/ws_item/shared.lua @@ -0,0 +1,5 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
+
+function ENT:OnRemove()
+end
diff --git a/entities/entities/ws_npc_ambient/cl_init.lua b/entities/entities/ws_npc_ambient/cl_init.lua new file mode 100644 index 0000000..fd4b29d --- /dev/null +++ b/entities/entities/ws_npc_ambient/cl_init.lua @@ -0,0 +1,66 @@ +include('shared.lua')
+
+ENT.RenderGroup = RENDERGROUP_BOTH
+
+/*---------------------------------------------------------
+ Name: Draw
+ Desc: Draw it!
+---------------------------------------------------------*/
+function ENT:Draw()
+ self:DrawModel()
+end
+
+/*---------------------------------------------------------
+ Name: DrawTranslucent
+ Desc: Draw translucent
+---------------------------------------------------------*/
+function ENT:DrawTranslucent()
+
+ // This is here just to make it backwards compatible.
+ // You shouldn't really be drawing your model here unless it's translucent
+
+ self:Draw()
+
+end
+
+/*---------------------------------------------------------
+ Name: BuildBonePositions
+ Desc:
+---------------------------------------------------------*/
+function ENT:BuildBonePositions( NumBones, NumPhysBones )
+
+ // You can use this section to position the bones of
+ // any animated model using self:SetBonePosition( BoneNum, Pos, Angle )
+
+ // This will override any animation data and isn't meant as a
+ // replacement for animations. We're using this to position the limbs
+ // of ragdolls.
+
+end
+
+
+
+/*---------------------------------------------------------
+ Name: SetRagdollBones
+ Desc:
+---------------------------------------------------------*/
+function ENT:SetRagdollBones( bIn )
+
+ // If this is set to true then the engine will call
+ // DoRagdollBone (below) for each ragdoll bone.
+ // It will then automatically fill in the rest of the bones
+
+ self.m_bRagdollSetup = bIn
+
+end
+
+
+/*---------------------------------------------------------
+ Name: DoRagdollBone
+ Desc:
+---------------------------------------------------------*/
+function ENT:DoRagdollBone( PhysBoneNum, BoneNum )
+
+ // self:SetBonePosition( BoneNum, Pos, Angle )
+
+end
diff --git a/entities/entities/ws_npc_ambient/init.lua b/entities/entities/ws_npc_ambient/init.lua new file mode 100644 index 0000000..f9aa726 --- /dev/null +++ b/entities/entities/ws_npc_ambient/init.lua @@ -0,0 +1,33 @@ +
+AddCSLuaFile( "cl_init.lua" )
+AddCSLuaFile( "shared.lua" )
+
+include('shared.lua')
+
+function ENT:Initialize()
+ print("NPC spawned!")
+ if(self.Model) then self:SetModel(self.Model)
+ else print("NPC created without model, this might be a bug!") end
+ --self:SetModel( "models/Humans/Group01/Female_01.mdl" )
+ --[[
+ self:SetHullType( HULL_HUMAN );
+ self:SetHullSizeNormal();
+
+ self:SetSolid( SOLID_BBOX )
+ self:SetMoveType( MOVETYPE_STEP )
+
+ self:CapabilitiesAdd( CAP_MOVE_GROUND or CAP_OPEN_DOORS or CAP_ANIMATEDFACE or CAP_TURN_HEAD or CAP_USE_SHOT_REGULATOR or CAP_AIM_GUN )
+
+ self:SetMaxYawSpeed( 5000 )
+ ]]--
+end
+
+function ENT:OnTakeDamage(dmg)
+ print("Taking some dammage")
+ self:SetHealth(self:Health() - dmg:GetDamage())
+ if self.OnDammage != nil then self:OnDammage(dmg) end
+ if self:Health() <= 0 then //run on death
+ self:Remove()
+ --self:SetSchedule( SCHED_FALL_TO_GROUND )
+ end
+end
diff --git a/entities/entities/ws_npc_ambient/shared.lua b/entities/entities/ws_npc_ambient/shared.lua new file mode 100644 index 0000000..cac9e39 --- /dev/null +++ b/entities/entities/ws_npc_ambient/shared.lua @@ -0,0 +1,53 @@ +ENT.Base = "base_nextbot"
+
+//WS stuff
+ENT.Drops = nil
+ENT.OnDammage = nil
+ENT.Vitality = 1
+ENT.Speed = 0
+ENT.Model = nil
+
+ENT.Behave = nil
+ENT.Act = nil
+
+/*---------------------------------------------------------
+ Name: OnRemove
+ Desc: Called just before entity is deleted
+---------------------------------------------------------*/
+function ENT:OnRemove()
+ print("Doing onremove")
+ if(CLIENT) then return end
+ if not self.Drops then return end
+ print("Looks like we have some drops")
+ local rng = math.random(0,100)
+ for k,v in pairs(self.Drops) do
+ local itemname = self.Drops[k][1]
+ local itemchance = self.Drops[k][2]
+ local heightoffset = 10
+ if rng < itemchance then
+ print("Createing a " .. itemname)
+ local drop = ents.Create("ws_item")
+ drop.Item = GetItemByName(itemname)
+ drop:SetModel(drop.Item.Model)
+ drop:SetPos(self:GetUp()*heightoffset)
+ drop:Spawn()
+ heightoffset = heightoffset + 10
+ end
+ end
+end
+
+function ENT:BehaveAct()
+ if(self.Act) then
+ self:Act()
+ else
+ print("NPC spawned without an Act function, this might be an error!")
+ end
+end
+
+function ENT:RunBehaviour()
+ if(self.Behave) then
+ self:Behave()
+ else
+ print("NPC spawned without a Behave function, this might be an error!")
+ end
+end
diff --git a/entities/entities/ws_pigeon/cl_init.lua b/entities/entities/ws_pigeon/cl_init.lua new file mode 100644 index 0000000..8ac0557 --- /dev/null +++ b/entities/entities/ws_pigeon/cl_init.lua @@ -0,0 +1,85 @@ +include('shared.lua')
+
+//Some of this code originated from Termy and Night Eagle. Might aswell reuse some of it and fix the best of it.
+
+function ENT:Initialize()
+ self.Cycle = 0
+ self.lastdraw = UnPredictedCurTime()
+ self.Player = NULL
+ self.Seq = -1
+ self.Rate = 1
+
+ self.AutomaticFrameAdvance = true
+
+ timer.Simple(0.5,function() if (IsValid(self)) then self:InitializeOwner() end end)
+end
+
+function ENT:InitializeOwner()
+ for k,v in pairs(player.GetAll()) do
+ if (IsValid(v.Pigeon) and v.Pigeon == self) then self.Player = v v.DeathPos = nil return end
+ end
+
+ timer.Simple(0.5,function() if (IsValid(self)) then self:InitializeOwner() end end)
+end
+
+function ENT:OnRemove()
+ if (IsValid(self.Player)) then
+ self.Player.DeathPos = self:GetPos()
+ local Rag = self:BecomeRagdollOnClient( )
+ local Phy = Rag:GetPhysicsObject()
+ Phy:ApplyForceCenter(self:GetVelocity()*Phy:GetMass()*12)
+ timer.Simple(3,function() if (IsValid(Rag)) then Rag:Remove() end end)
+ end
+end
+
+function ENT:Think()
+ local Pos = self:GetPos()
+ local vel = self:GetVelocity()
+ local velL = vel:Length()
+
+ local tr = util.TraceLine({
+ start = Pos,
+ endpos = Pos - Vector(0,0,12),
+ filter = self,
+ })
+
+ local ground = tr.Hit
+
+ if (velL < 16 and !ground) then
+ self.Seq = 0
+ self.Rate = 0.7
+
+ elseif (ground) then
+ if (velL > 30) then
+ self.Rate = 2
+ self.Seq = 3
+ elseif (velL > 7) then
+ self.Rate = 1
+ self.Seq = 2
+ else
+ self.Seq = 1
+ self.Rate = .1
+ end
+ elseif (vel.z > 2) then
+ self.Seq = 0
+ elseif (velL < 16 and ground) then
+ else
+ self.Seq = 7
+ end
+
+ if (self:GetSequence() != self.Seq) then self:SetSequence(self.Seq) end
+
+ local delta = UnPredictedCurTime()-self.lastdraw
+ self.lastdraw = UnPredictedCurTime()
+
+ self.Cycle = self.Cycle + delta*self.Rate
+ if (self.Cycle > 1) then self.Cycle = 0 end
+
+ self:SetCycle(self.Cycle)
+end
+
+function ENT:Draw()
+ if (!IsValid(self.Player)) then return end
+
+ self:DrawModel()
+end
\ No newline at end of file diff --git a/entities/entities/ws_pigeon/init.lua b/entities/entities/ws_pigeon/init.lua new file mode 100644 index 0000000..d0b95cc --- /dev/null +++ b/entities/entities/ws_pigeon/init.lua @@ -0,0 +1,166 @@ +AddCSLuaFile("cl_init.lua")
+AddCSLuaFile("shared.lua")
+
+include('shared.lua')
+
+local bo,ao = Vector(-3,-3,-1),Vector(3,3,3)
+local up = Vector(0,0,1)
+local zero = Vector(0,0,0)
+
+function ENT:OnRemove()
+end
+
+function ENT:KeyValue(key,value)
+end
+
+function ENT:Initialize()
+ self:SetModel("models/crow.mdl")
+ self:PhysicsInitBox(bo,ao)
+ self:SetMoveCollide(MOVECOLLIDE_FLY_SLIDE)
+ self:SetSolid(SOLID_VPHYSICS)
+ self:SetCollisionGroup(COLLISION_GROUP_WEAPON)
+
+ self.ShadowParams = {}
+ self.ShadowParams.secondstoarrive = 0.1
+ self.ShadowParams.angle = Angle(0,0,0)
+ self.ShadowParams.maxangular = 5000
+ self.ShadowParams.maxangulardamp = 10000
+ self.ShadowParams.maxspeed = 1000000
+ self.ShadowParams.maxspeeddamp = 10000
+ self.ShadowParams.dampfactor = 0.8
+ self.ShadowParams.teleportdistance = 0
+
+ self.IsMoving = false
+ self.Dir = Vector(1,0,0)
+ self.Phys = self:GetPhysicsObject()
+ self.Speed = 0
+ self.Up = zero
+ self.Caw = CurTime()
+ self.Yaw = 0
+
+ self.Phys:EnableMotion(false)
+ self.Phys:Sleep()
+end
+
+function ENT:SetPlayer(pl)
+ self.Player = pl
+end
+
+function ENT:OnRemove()
+ if (IsValid(self.Player)) then
+ self.Player:KillSilent()
+ self:EmitSound("npc/crow/die"..math.random(1,2)..".wav")
+
+ if (math.random(1,2) == 1) then SpawnWSItem("Meat",self:GetPos())
+ else SpawnWSItem("Feather",self:GetPos()) end
+ end
+end
+
+function ENT:OnTakeDamage(dmg)
+ if (IsValid(self.Player)) then
+ self.Player:KillSilent()
+ self:Remove()
+ end
+end
+
+function ENT:OnTheGround()
+ local Pos = self:GetPos()
+ local tr = util.TraceLine({
+ start = Pos,
+ endpos = Pos - Vector(0,0,5),
+ filter = self,
+ })
+
+ return tr.Hit,tr.HitNormal
+end
+
+function ENT:Think()
+ if (IsValid(self.Player) and self.Player:Alive()) then
+ local pl = self.Player
+ local For = self:GetForward()
+ local Jump = pl:KeyDown(IN_JUMP)
+
+ if (pl:KeyDown(IN_FORWARD) or Jump) then
+ if (!self.IsMoving) then
+ self.IsMoving = true
+ self.Phys:EnableMotion(true)
+ self.Phys:Wake()
+ self:StartMotionController()
+ end
+
+ self.Speed = self.Speed+(300-self.Speed)/16
+
+ if (Jump) then self.Up = up end
+ elseif (self.Speed < 0.01 and self.Dir:DotProduct(For) > 0.9) then
+ if (self.IsMoving) then
+ self.IsMoving = false
+ self.Phys:EnableMotion(false)
+ self.Phys:Sleep()
+ self:StopMotionController()
+ end
+ else
+ self.Speed = self.Speed-self.Speed/4
+ end
+
+ if (!Jump and self.Up) then self.Up = zero end
+
+ if (self.Speed > 1) then
+ self.Dir = pl:GetAimVector()
+ self.Yaw = self.Dir:Angle().y
+
+ if (!self.IsMoving and self.Dir:DotProduct(For) < 0.9) then
+ self.IsMoving = true
+ self.Phys:EnableMotion(true)
+ self.Phys:Wake()
+ self:StartMotionController()
+ end
+ end
+
+ if (pl:KeyDown(IN_ATTACK) and self.Caw < CurTime()) then
+ self:EmitSound("npc/crow/idle"..math.random(1,3)..".wav")
+ self.Caw = CurTime()+1.5
+ end
+
+ if (self.Speed > 0.01) then
+ if (!self.PLTimer or self.PLTimer < CurTime()) then pl:SetPos(self:GetPos()) self.PLTimer = CurTime()+1 end
+
+ local Hit,Norm = self:OnTheGround()
+
+ if (Hit) then
+ self.Speed = math.min(5,self.Speed)
+
+ if (pl:KeyDown(IN_SPEED)) then self.Speed = self.Speed*5 end
+
+ local ang = self.Dir:Angle()
+ local an2 = Norm:Angle()
+ local avel = an2:Right():Angle()
+ local rot = self.Yaw-avel.y
+
+ avel:RotateAroundAxis(an2:Forward(),rot)
+ vel = avel:Forward()
+
+ self.Dir = vel
+ end
+ end
+ else
+ self:Remove()
+ end
+
+ self.Entity:NextThink(CurTime()+0.01)
+ return true
+end
+
+function ENT:PhysicsSimulate( phys, deltatime )
+
+ phys:Wake()
+
+ self.ShadowParams.angle = self.Dir:Angle()
+ self.ShadowParams.pos = self:GetPos() + (self.Dir+self.Up)*self.Speed/8
+
+ phys:ComputeShadowControl(self.ShadowParams)
+
+end
+
+function ENT:UpdateTransmitState()
+ return TRANSMIT_ALWAYS
+end
diff --git a/entities/entities/ws_pigeon/shared.lua b/entities/entities/ws_pigeon/shared.lua new file mode 100644 index 0000000..e67f5f4 --- /dev/null +++ b/entities/entities/ws_pigeon/shared.lua @@ -0,0 +1,5 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
+
+function ENT:OnRemove()
+end
diff --git a/entities/entities/ws_prop/cl_init.lua b/entities/entities/ws_prop/cl_init.lua new file mode 100644 index 0000000..b323b28 --- /dev/null +++ b/entities/entities/ws_prop/cl_init.lua @@ -0,0 +1,5 @@ +include('shared.lua')
+
+function ENT:Draw()
+ self.Entity:DrawModel()
+end
diff --git a/entities/entities/ws_prop/init.lua b/entities/entities/ws_prop/init.lua new file mode 100644 index 0000000..519f1e7 --- /dev/null +++ b/entities/entities/ws_prop/init.lua @@ -0,0 +1,28 @@ +AddCSLuaFile("cl_init.lua")
+AddCSLuaFile("shared.lua")
+
+include('shared.lua')
+
+function ENT:Initialize()
+ self:PhysicsInit(SOLID_VPHYSICS)
+ self:SetMoveType(MOVETYPE_NONE)
+ self:SetSolid(SOLID_VPHYSICS)
+ self:DrawShadow(false)
+
+ local phys = self:GetPhysicsObject()
+ phys:EnableMotion(false)
+ phys:Sleep()
+
+ self:SetHealth(30)
+
+ self.HP = 500
+end
+
+function ENT:OnTakeDamage(dmginfo)
+ self.HP = self.HP-dmginfo:GetDamage()
+
+ if (self.HP <= 0) then
+ self:EmitSound(Sound("physics/wood/wood_plank_break"..math.random(1,4)..".wav"))
+ self:Remove()
+ end
+end
diff --git a/entities/entities/ws_prop/shared.lua b/entities/entities/ws_prop/shared.lua new file mode 100644 index 0000000..e67f5f4 --- /dev/null +++ b/entities/entities/ws_prop/shared.lua @@ -0,0 +1,5 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
+
+function ENT:OnRemove()
+end
diff --git a/entities/entities/ws_researchtable/cl_init.lua b/entities/entities/ws_researchtable/cl_init.lua new file mode 100644 index 0000000..94b84c5 --- /dev/null +++ b/entities/entities/ws_researchtable/cl_init.lua @@ -0,0 +1,8 @@ +include('shared.lua')
+
+function ENT:Initialize()
+ timer.Simple(0.1,function() self.Pos = self:GetPos() self.Ang = self:GetAngles() end)
+
+ self.Dibs = ClientsideModel("models/props/cs_italy/it_mkt_table3.mdl")
+ self.Dibs:SetNoDraw(true)
+end
diff --git a/entities/entities/ws_researchtable/init.lua b/entities/entities/ws_researchtable/init.lua new file mode 100644 index 0000000..9f09365 --- /dev/null +++ b/entities/entities/ws_researchtable/init.lua @@ -0,0 +1,120 @@ +AddCSLuaFile("cl_init.lua")
+AddCSLuaFile("shared.lua")
+
+include('shared.lua')
+--[[An item to give hints to players that are just starting out]]
+local ResurrectionTable = {
+ ["Wood"] = 10,
+ ["Rock"] = 10,
+ ["Sap"] = 10,
+}
+
+local PossibleRecipies = {
+ [1] = { [0]="Arrow",
+ [1]="Rock, Flint, Sap, and Wood"},
+ [2] = { [0]="Barrel",
+ [1]="Planks and Sap"},
+ [3] = { [0]="Fence",
+ [1]="Planks and Sap"},
+ [4] = { [0]="Knife",
+ [1]="Rock, Sap, Wood, and Crystal"},
+ [5] = { [0]="Log",
+ [1]="Vine, Sap, and Wood"},
+ [6] = { [0]="Plank",
+ [1]="Wood and Sap"},
+ [7] = { [0]="Rope",
+ [1]="Vine and Sap"},
+ [8] = { [0]="Sickle",
+ [1]="Wood, Rock, and Sap"},
+ [9] = { [0]="Stoneblock",
+ [1]="Rock and Sap"},
+ [10] = { [0]="Arrow",
+ [1]="Rock, Flint, Sap, and Wood"},
+}
+
+function ENT:Initialize()
+ self:SetModel("models/props_junk/wood_crate002a.mdl")
+ self:PhysicsInit(SOLID_VPHYSICS)
+ self:SetMoveType(MOVETYPE_NONE)
+ self:SetSolid(SOLID_VPHYSICS)
+ self:SetUseType(SIMPLE_USE)
+
+ local phys = self:GetPhysicsObject()
+ if(phys) then
+ phys:EnableMotion(false)
+ phys:Sleep()
+ end
+
+ self:SetHealth(30)
+
+ self.StoredItems = {}
+end
+
+function ENT:Think()
+ local HasItems = {}
+ if(!self.StoredItems) then return end
+ for k,v in pairs(self.StoredItems) do
+ if (ResurrectionTable[v.Name] and v.Quantity >= ResurrectionTable[v.Name]) then
+ HasItems[v.Name] = {k,ResurrectionTable[v.Name]}
+ end
+ end
+
+ if (table.Count(HasItems) >= table.Count(ResurrectionTable)) then
+ local randomrecipie = PossibleRecipies[math.random(1,10)]
+ for k,v in pairs(player.GetAll()) do
+ if (v:Alive() and v:GetPos():Distance(self:GetPos()) < 200) then
+ v:ChatPrint("Perhaps you can make a " .. randomrecipie[0] .. " with " .. randomrecipie[1])
+
+ for a,b in pairs(HasItems) do
+ if (self.StoredItems[b[1]].Quantity == b[2]) then table.remove(self.StoredItems,b[1])
+ else self.StoredItems[b[1]].Quantity = self.StoredItems[b[1]].Quantity-b[2] end
+ end
+
+ break
+ end
+ end
+ end
+
+ self:NextThink(CurTime()+10)
+ return true
+end
+
+function ENT:AddItem(item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ v.Quantity = v.Quantity + quantity
+ return
+ end
+ end
+
+ table.insert(self.StoredItems,{Name = item, Quantity = quantity})
+end
+
+function ENT:TakeItem(pl,item,quantity)
+ for k,v in pairs(self.StoredItems) do
+ if (v.Name == item) then
+ quantity = math.min(quantity,v.Quantity)
+ v.Quantity = v.Quantity - quantity
+
+ pl:AddItem(item,quantity)
+
+ if (v.Quantity <= 0) then table.remove(self.StoredItems,k) end
+ break
+ end
+ end
+end
+
+function ENT:GetItems()
+ return self.StoredItems
+end
+
+function ENT:Use(pl)
+ if (pl:IsPigeon()) then return end
+ OpenLootventory(pl,self.StoredItems,self)
+end
+
+function ENT:OnTakeDamage(dmg)
+ self:SetHealth(self:Health()-dmg)
+
+ if (self:Health() <= 0) then self:Remove() end
+end
diff --git a/entities/entities/ws_researchtable/shared.lua b/entities/entities/ws_researchtable/shared.lua new file mode 100644 index 0000000..e67f5f4 --- /dev/null +++ b/entities/entities/ws_researchtable/shared.lua @@ -0,0 +1,5 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
+
+function ENT:OnRemove()
+end
diff --git a/entities/entities/ws_shop/cl_init.lua b/entities/entities/ws_shop/cl_init.lua new file mode 100644 index 0000000..4185da9 --- /dev/null +++ b/entities/entities/ws_shop/cl_init.lua @@ -0,0 +1,12 @@ +include('shared.lua')
+
+local Col = Color(0,0,0,150)
+
+function ENT:Draw()
+ self:DrawModel()
+
+ cam.Start3D2D(self:GetPos()+self:GetUp()*50,Angle(0,CurTime()*40,90),0.3)
+ DrawRect(-100,0,200,20,Col)
+ DrawText("Shop (To be announced!)","Trebuchet18",0,10,MAIN_TEXTCOLOR,1)
+ cam.End3D2D()
+end
diff --git a/entities/entities/ws_shop/init.lua b/entities/entities/ws_shop/init.lua new file mode 100644 index 0000000..ea0e5e8 --- /dev/null +++ b/entities/entities/ws_shop/init.lua @@ -0,0 +1,16 @@ +AddCSLuaFile("cl_init.lua")
+AddCSLuaFile("shared.lua")
+
+include('shared.lua')
+
+function ENT:Initialize()
+ self:SetModel("models/props_junk/wood_crate001a.mdl")
+ self:PhysicsInit(SOLID_VPHYSICS)
+ self:SetMoveType(MOVETYPE_NONE)
+ self:SetSolid(SOLID_VPHYSICS)
+
+ local phys = self:GetPhysicsObject()
+ phys:EnableMotion(false)
+ phys:Sleep()
+end
+
diff --git a/entities/entities/ws_shop/shared.lua b/entities/entities/ws_shop/shared.lua new file mode 100644 index 0000000..e67f5f4 --- /dev/null +++ b/entities/entities/ws_shop/shared.lua @@ -0,0 +1,5 @@ +ENT.Type = "anim"
+ENT.Base = "base_anim"
+
+function ENT:OnRemove()
+end
diff --git a/entities/weapons/hands.lua b/entities/weapons/hands.lua new file mode 100644 index 0000000..02c2500 --- /dev/null +++ b/entities/weapons/hands.lua @@ -0,0 +1,130 @@ +AddCSLuaFile("hands.lua")
+
+SWEP.ViewModel = "models/error.mdl"
+SWEP.WorldModel = "models/error.mdl"
+
+SWEP.HoldType = "normal"
+
+SWEP.Primary.ClipSize = -1
+SWEP.Primary.DefaultClip = -1
+SWEP.Primary.Automatic = true
+SWEP.Primary.Ammo = "none"
+
+SWEP.Secondary.Clipsize = -1
+SWEP.Secondary.DefaultClip = -1
+SWEP.Secondary.Automatic = false
+SWEP.Secondary.Ammo = "none"
+
+SWEP.DrawAmmo = false
+SWEP.DrawCrosshair = false
+
+function SWEP:Initialize()
+ self:SetWeaponHoldType(self.HoldType)
+ self:DrawShadow(false)
+
+ if (CLIENT) then
+ self.MOB = ClientsideModel("error.mdl")
+ self.MOB:SetNoDraw(true)
+ self.MOB:DrawShadow(false)
+ end
+end
+
+function SWEP:ShouldDropOnDie()
+ return false
+end
+
+function SWEP:Think()
+end
+
+function SWEP:Reload()
+end
+
+local Box = Vector(8,8,8)
+
+function SWEP:PrimaryAttack()
+ if (CLIENT and !IsFirstTimePredicted()) then return end
+ if (!self.Owner.Weapons or !self.Owner.Weapons[self.Owner.Select]) then return end
+ if (self.Owner.CD and self.Owner.CD > CurTime()) then return end
+
+ local item = self.Owner.Weapons[self.Owner.Select].Item
+
+ if (!item or !item.OnPrimary) then return end
+
+ self.Owner:SetAnimation( PLAYER_ATTACK1 )
+
+ local Trace = {
+ start = self.Owner:GetShootPos(),
+ endpos = self.Owner:GetShootPos()+self.Owner:GetAimVector()*item.Range,
+ filter = self.Owner,
+ mins = Box*-1,
+ maxs = Box,
+ }
+
+ local Tr = util.TraceHull(Trace)
+
+ item:OnPrimary(self.Owner,Tr)
+
+ self.Owner.CD = CurTime()+item.CD
+end
+
+function SWEP:SecondaryAttack()
+ if (CLIENT and !IsFirstTimePredicted()) then return end
+ if (!self.Owner.Weapons or !self.Owner.Weapons[self.Owner.Select]) then return end
+ if (self.Owner.CD and self.Owner.CD > CurTime()) then return end
+
+ local item = self.Owner.Weapons[self.Owner.Select].Item
+
+ if (!item or !item.OnSecondary) then return end
+
+ self.Owner:SetAnimation( PLAYER_ATTACK1 )
+
+ local Trace = {
+ start = self.Owner:GetShootPos(),
+ endpos = self.Owner:GetShootPos()+self.Owner:GetAimVector()*item.Range,
+ filter = self.Owner,
+ mins = Box*-1,
+ maxs = Box,
+ }
+
+ local Tr = util.TraceHull(Trace)
+
+ item:OnSecondary(self.Owner,Tr)
+
+ self.Owner.CD = CurTime()+item.CD
+end
+
+if (CLIENT) then
+ local Zero = Vector(1,1,1)
+
+ function SWEP:DrawWorldModel()
+ if (!self.Owner.Weapons or !self.Owner.Weapons[self.Owner.Select]) then return end
+
+ local item = self.Owner.Weapons[self.Owner.Select].Item
+
+ for k,v in pairs(item.Structure) do
+ local ID = self.Owner:LookupBone(v.Bone)
+ local Pos,Ang = self.Owner:GetBonePosition(ID)
+
+ local Offset = v.Pos*1
+ Offset:Rotate(Ang)
+ Pos = Pos + Offset
+
+ local Dang = Ang*1
+
+ Ang:RotateAroundAxis(Dang:Right(),v.Ang.p)
+ Ang:RotateAroundAxis(Dang:Up(),v.Ang.y)
+ Ang:RotateAroundAxis(Dang:Forward(),v.Ang.r)
+
+ self.MOB:SetModel(v.Model)
+ self.MOB:SetRenderOrigin(Pos)
+ self.MOB:SetRenderAngles(Ang)
+
+ local mat = Matrix()
+ mat:Scale( v.Size or Zero )
+
+ self.MOB:EnableMatrix( "RenderMultiply", mat )
+ self.MOB:SetupBones()
+ self.MOB:DrawModel()
+ end
+ end
+end
|
