This commit is contained in:
lifestorm
2024-08-04 22:55:00 +03:00
parent 8064ba84d8
commit 73479cff9e
7338 changed files with 1718883 additions and 14 deletions

View File

@@ -0,0 +1,345 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
AddCSLuaFile()
ENT.Base = "base_entity"
ENT.Type = "anim"
ENT.PrintName = "Item"
ENT.Category = "Helix"
ENT.Spawnable = false
ENT.ShowPlayerInteraction = true
ENT.RenderGroup = RENDERGROUP_BOTH
ENT.bNoPersist = true
function ENT:SetupDataTables()
self:NetworkVar("String", 0, "ItemID")
end
function ENT:GetProxyColors()
local itemTable = self.GetItemTable and self:GetItemTable()
return itemTable and itemTable.proxy or false
end
if (SERVER) then
local invalidBoundsMin = Vector(-8, -8, -8)
local invalidBoundsMax = Vector(8, 8, 8)
util.AddNetworkString("ixItemEntityAction")
function ENT:Initialize()
self:SetModel("models/props_junk/watermelon01.mdl")
self:SetSolid(SOLID_VPHYSICS)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetUseType(SIMPLE_USE)
self:AddEFlags(EFL_FORCE_CHECK_TRANSMIT)
self.health = 50
local physObj = self:GetPhysicsObject()
if (IsValid(physObj)) then
physObj:EnableMotion(true)
physObj:Wake()
end
end
function ENT:Use(activator, caller)
local itemTable = self:GetItemTable()
if (IsValid(caller) and caller:IsPlayer() and caller:GetCharacter() and itemTable) then
itemTable.player = caller
itemTable.entity = self
if (itemTable.functions.take.OnCanRun(itemTable)) then
caller:PerformInteraction(ix.config.Get("itemPickupTime", 0.5), self, function(client)
if (!ix.item.PerformInventoryAction(client, "take", self)) then
return false -- do not mark dirty if interaction fails
end
end)
end
itemTable.player = nil
itemTable.entity = nil
end
end
function ENT:SetItem(itemID)
local itemTable = ix.item.instances[itemID]
if (itemTable) then
local material = itemTable:GetMaterial(self)
self:SetSkin(itemTable:GetSkin())
self:SetModel(itemTable:GetModel())
self:SetBodyGroups(itemTable:GetModelBodygroups())
if (material) then
self:SetMaterial(material)
end
self:PhysicsInit(SOLID_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetItemID(itemTable.uniqueID)
self.ixItemID = itemID
if (!table.IsEmpty(itemTable.data)) then
self:SetNetVar("data", itemTable.data)
end
local physObj = self:GetPhysicsObject()
if (!IsValid(physObj)) then
self:PhysicsInitBox(invalidBoundsMin, invalidBoundsMax)
self:SetCollisionBounds(invalidBoundsMin, invalidBoundsMax)
end
if (IsValid(physObj)) then
physObj:EnableMotion(true)
physObj:Wake()
end
if (itemTable.OnEntityCreated) then
itemTable:OnEntityCreated(self)
end
end
end
function ENT:OnDuplicated(entTable)
local itemID = entTable.ixItemID
local itemTable = ix.item.instances[itemID]
ix.item.Instance(0, itemTable.uniqueID, itemTable.data, 1, 1, function(item)
self:SetItem(item:GetID())
end)
end
function ENT:OnTakeDamage(damageInfo)
local itemTable = ix.item.instances[self.ixItemID]
if (itemTable.OnEntityTakeDamage
and itemTable:OnEntityTakeDamage(self, damageInfo) == false) then
return
end
local damage = damageInfo:GetDamage()
self:SetHealth(self:Health() - damage)
if (self:Health() <= 0 and !self.ixIsDestroying) then
self.ixIsDestroying = true
self.ixDamageInfo = {damageInfo:GetAttacker(), damage, damageInfo:GetInflictor()}
self:Remove()
end
end
function ENT:OnRemove()
if (!ix.shuttingDown and !self.ixIsSafe and self.ixItemID) then
local itemTable = ix.item.instances[self.ixItemID]
if (itemTable) then
if (self.ixIsDestroying) then
self:EmitSound("physics/cardboard/cardboard_box_break"..math.random(1, 3)..".wav")
local position = self:LocalToWorld(self:OBBCenter())
local effect = EffectData()
effect:SetStart(position)
effect:SetOrigin(position)
effect:SetScale(3)
util.Effect("GlassImpact", effect)
if (itemTable.OnDestroyed) then
itemTable:OnDestroyed(self)
end
ix.log.Add(self.ixDamageInfo[1], "itemDestroy", itemTable:GetName(), itemTable:GetID())
end
if (itemTable.OnRemoved) then
itemTable:OnRemoved()
end
local query = mysql:Delete("ix_items")
query:Where("item_id", self.ixItemID)
query:Execute()
end
end
end
function ENT:Think()
local itemTable = self:GetItemTable()
if (!itemTable) then
--self:Remove()
return
end
if (itemTable.Think) then
itemTable:Think(self)
end
return true
end
function ENT:UpdateTransmitState()
return TRANSMIT_PVS
end
net.Receive("ixItemEntityAction", function(length, client)
ix.item.PerformInventoryAction(client, net.ReadString(), net.ReadEntity())
end)
else
ENT.PopulateEntityInfo = true
local shadeColor = Color(0, 0, 0, 200)
local blockSize = 4
local blockSpacing = 2
function ENT:OnPopulateEntityInfo(tooltip)
local item = self:GetItemTable()
if (!item) then
return
end
local oldData = item.data
item.data = self:GetNetVar("data", {})
item.entity = self
ix.hud.PopulateItemTooltip(tooltip, item)
local name = tooltip:GetRow("name")
local color = name and name:GetBackgroundColor() or ix.config.Get("color")
-- set the arrow to be the same colour as the title/name row
tooltip:SetArrowColor(color)
if ((item.width > 1 or item.height > 1) and
hook.Run("ShouldDrawItemSize", item) != false) then
local sizeHeight = item.height * blockSize + item.height * blockSpacing
local size = tooltip:Add("Panel")
size:SetWide(tooltip:GetWide())
if (tooltip:IsMinimal()) then
size:SetTall(sizeHeight)
size:Dock(TOP)
size:SetZPos(-999)
else
size:SetTall(sizeHeight + 8)
size:Dock(BOTTOM)
end
size.Paint = function(sizePanel, width, height)
if (!tooltip:IsMinimal()) then
surface.SetDrawColor(ColorAlpha(shadeColor, 60))
surface.DrawRect(0, 0, width, height)
end
local x, y = width * 0.5 - 1, height * 0.5 - 1
local itemWidth = item.width - 1
local itemHeight = item.height - 1
local heightDifference = ((itemHeight + 1) * blockSize + blockSpacing * itemHeight)
x = x - (itemWidth * blockSize + blockSpacing * itemWidth) * 0.5
y = y - heightDifference * 0.5
for i = 0, itemHeight do
for j = 0, itemWidth do
local blockX, blockY = x + j * blockSize + j * blockSpacing, y + i * blockSize + i * blockSpacing
surface.SetDrawColor(shadeColor)
surface.DrawRect(blockX + 1, blockY + 1, blockSize, blockSize)
surface.SetDrawColor(color)
surface.DrawRect(blockX, blockY, blockSize, blockSize)
end
end
end
tooltip:SizeToContents()
end
item.entity = nil
item.data = oldData
end
function ENT:DrawTranslucent()
local itemTable = self:GetItemTable()
if (itemTable and itemTable.DrawEntity) then
itemTable:DrawEntity(self)
end
end
function ENT:Draw()
self:DrawModel()
end
end
function ENT:GetEntityMenu(client)
local itemTable = self:GetItemTable()
local options = {}
if (!itemTable) then
return false
end
itemTable.player = client
itemTable.entity = self
for k, v in SortedPairs(itemTable.functions) do
if (k == "take" or k == "combine") then
continue
end
if (v.OnCanRun and v.OnCanRun(itemTable) == false) then
continue
end
-- we keep the localized phrase since we aren't using the callbacks - the name won't matter in this case
options[L(v.name or k)] = function()
local send = true
if (v.OnClick) then
send = v.OnClick(itemTable)
end
if (v.sound) then
surface.PlaySound(v.sound)
end
if (send != false) then
net.Start("ixItemEntityAction")
net.WriteString(k)
net.WriteEntity(self)
net.SendToServer()
end
-- don't run callbacks since we're handling it manually
return false
end
end
itemTable.player = nil
itemTable.entity = nil
return options
end
function ENT:GetItemTable()
return ix.item.list[self:GetItemID()]
end
function ENT:GetData(key, default)
local data = self:GetNetVar("data", {})
return data[key] or default
end

View File

@@ -0,0 +1,74 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
AddCSLuaFile()
ENT.Type = "anim"
ENT.PrintName = "Money"
ENT.Category = "Helix"
ENT.Spawnable = false
ENT.ShowPlayerInteraction = true
ENT.bNoPersist = true
function ENT:SetupDataTables()
self:NetworkVar("Int", 0, "Amount")
end
if (SERVER) then
local invalidBoundsMin = Vector(-8, -8, -8)
local invalidBoundsMax = Vector(8, 8, 8)
function ENT:Initialize()
self:SetModel(ix.currency.model)
self:SetSolid(SOLID_VPHYSICS)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetUseType(SIMPLE_USE)
local physObj = self:GetPhysicsObject()
if (IsValid(physObj)) then
physObj:EnableMotion(true)
physObj:Wake()
else
self:PhysicsInitBox(invalidBoundsMin, invalidBoundsMax)
self:SetCollisionBounds(invalidBoundsMin, invalidBoundsMax)
end
end
function ENT:Use(activator)
if (self.ixSteamID and self.ixCharID) then
local char = activator:GetCharacter()
if (char and self.ixCharID != char:GetID() and self.ixSteamID == activator:SteamID()) then
activator:NotifyLocalized("itemOwned")
return false
end
end
activator:PerformInteraction(ix.config.Get("itemPickupTime", 0.5), self, function(client)
if (hook.Run("OnPickupMoney", client, self) != false) then
self:Remove()
end
end)
end
function ENT:UpdateTransmitState()
return TRANSMIT_PVS
end
else
ENT.PopulateEntityInfo = true
function ENT:OnPopulateEntityInfo(container)
local text = container:AddRow("name")
text:SetImportant()
text:SetText(ix.currency.Get(self:GetAmount()))
text:SizeToContents()
end
end

View File

@@ -0,0 +1,147 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
AddCSLuaFile()
ENT.Type = "anim"
ENT.PrintName = "Shipment"
ENT.Category = "Helix"
ENT.Spawnable = false
ENT.ShowPlayerInteraction = true
ENT.bNoPersist = true
function ENT:SetupDataTables()
self:NetworkVar("Int", 0, "DeliveryTime")
end
if (SERVER) then
function ENT:Initialize()
self:SetModel("models/Items/item_item_crate.mdl")
self:SetSolid(SOLID_VPHYSICS)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetUseType(SIMPLE_USE)
self:PrecacheGibs()
local physObj = self:GetPhysicsObject()
if (IsValid(physObj)) then
physObj:EnableMotion(true)
physObj:Wake()
end
self:SetDeliveryTime(CurTime() + 120)
timer.Simple(120, function()
if (IsValid(self)) then
self:Remove()
end
end)
end
function ENT:Use(activator)
activator:PerformInteraction(ix.config.Get("itemPickupTime", 0.5), self, function(client)
if (client:GetCharacter() and client:GetCharacter():GetID() == self:GetNetVar("owner", 0)
and hook.Run("CanPlayerOpenShipment", client, self) != false) then
client.ixShipment = self
net.Start("ixShipmentOpen")
net.WriteEntity(self)
net.WriteTable(self.items)
net.Send(client)
end
-- don't mark dirty since the player could come back and use this shipment again later
return false
end)
end
function ENT:SetItems(items)
self.items = items
end
function ENT:GetItemCount()
local count = 0
for _, v in pairs(self.items) do
count = count + math.max(v, 0)
end
return count
end
function ENT:OnRemove()
self:EmitSound("physics/cardboard/cardboard_box_break"..math.random(1, 3)..".wav")
local position = self:LocalToWorld(self:OBBCenter())
local effect = EffectData()
effect:SetStart(position)
effect:SetOrigin(position)
effect:SetScale(3)
util.Effect("GlassImpact", effect)
end
function ENT:UpdateTransmitState()
return TRANSMIT_PVS
end
else
ENT.PopulateEntityInfo = true
local size = 150
local tempMat = Material("particle/warp1_warp", "alphatest")
function ENT:Draw()
local pos, ang = self:GetPos(), self:GetAngles()
self:DrawModel()
pos = pos + self:GetUp() * 25
pos = pos + self:GetForward() * 1
pos = pos + self:GetRight() * 3
local delTime = math.max(math.ceil(self:GetDeliveryTime() - CurTime()), 0)
local func = function()
surface.SetMaterial(tempMat)
surface.SetDrawColor(0, 0, 0, 200)
surface.DrawTexturedRect(-size / 2, -size / 2 - 10, size, size)
ix.util.DrawText("k", 0, 0, color_white, 1, 4, "ixIconsBig")
ix.util.DrawText(delTime, 0, -10, color_white, 1, 5, "ixBigFont")
end
cam.Start3D2D(pos, ang, .15)
func()
cam.End3D2D()
ang:RotateAroundAxis(ang:Right(), 180)
pos = pos - self:GetUp() * 26
cam.Start3D2D(pos, ang, .15)
func()
cam.End3D2D()
end
function ENT:OnPopulateEntityInfo(container)
local owner = ix.char.loaded[self:GetNetVar("owner", 0)]
local name = container:AddRow("name")
name:SetImportant()
name:SetText(L("shipment"))
name:SizeToContents()
if (owner) then
local description = container:AddRow("description")
description:SetText(L("shipmentDesc", owner:GetName()))
description:SizeToContents()
end
end
end

View File

@@ -0,0 +1,644 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
AddCSLuaFile()
if (CLIENT) then
SWEP.PrintName = "Mains"
SWEP.Slot = 0
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
end
SWEP.Author = "Chessnut"
SWEP.Instructions = [[Clique Gauche : Lancer / Coup de poing
Clique Droit : Toquer / Ramasser
Clique Droit + Souris : Faire pivoter l'objet
Recharger : Déposer
Maintien R : Sortir les poings]]
SWEP.Purpose = "Frapper des choses et frapper aux portes."
SWEP.Drop = false
SWEP.ViewModelFOV = 45
SWEP.ViewModelFlip = false
SWEP.AnimPrefix = "rpg"
SWEP.ViewTranslation = 4
if CLIENT then
SWEP.NextAllowedPlayRateChange = 0
end
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = ""
SWEP.Primary.Damage = 5
SWEP.Primary.Delay = 0.75
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = ""
SWEP.Secondary.Delay = 0.5
SWEP.ViewModel = Model("models/weapons/c_arms.mdl")
SWEP.WorldModel = ""
SWEP.UseHands = true
SWEP.LowerAngles = Angle(0, 5, -14)
SWEP.LowerAngles2 = Angle(0, 5, -19)
SWEP.KnockViewPunchAngle = Angle(-1.3, 1.8, 0)
SWEP.FireWhenLowered = true
SWEP.HoldType = "fist"
SWEP.holdDistance = 64
SWEP.maxHoldDistance = 96 -- how far away the held object is allowed to travel before forcefully dropping
SWEP.maxHoldStress = 4000 -- how much stress the held object can undergo before forcefully dropping
-- luacheck: globals ACT_VM_FISTS_DRAW ACT_VM_FISTS_HOLSTER
ACT_VM_FISTS_DRAW = 2
ACT_VM_FISTS_HOLSTER = 1
function SWEP:Initialize()
self:SetHoldType(self.HoldType)
self.lastHand = 0
self.maxHoldDistanceSquared = self.maxHoldDistance ^ 2
self.heldObjectAngle = Angle(angle_zero)
end
if (CLIENT) then
function SWEP:PreDrawViewModel(viewModel, weapon, client)
local hands = player_manager.TranslatePlayerHands(player_manager.TranslateToPlayerModelName(client:GetModel()))
if client:GetModel() == "models/willardnetworks/vortigaunt.mdl" then
self.ViewModelFOV = 60
end
if (hands and hands.model) then
viewModel:SetModel(hands.model)
if hands.skin and isnumber(hands.skin) then
viewModel:SetSkin(hands.skin)
end
viewModel:SetBodyGroups(hands.body)
end
end
function SWEP:DoDrawCrosshair(x, y)
surface.SetDrawColor(255, 255, 255, 66)
surface.DrawRect(x - 2, y - 2, 4, 4)
end
-- Adjust these variables to move the viewmodel's position
SWEP.IronSightsPos = Vector(0, 0, 0)
SWEP.IronSightsAng = Vector(0, 0, 0)
function SWEP:GetViewModelPosition(EyePos, EyeAng)
if self.Owner:GetModel() == "models/willardnetworks/vortigaunt.mdl" then
self.IronSightsPos = Vector(0, -3, -5)
local Mul = 1.0
local Offset = self.IronSightsPos
if (self.IronSightsAng) then
EyeAng = EyeAng * 1
EyeAng:RotateAroundAxis(EyeAng:Right(), self.IronSightsAng.x * Mul)
EyeAng:RotateAroundAxis(EyeAng:Up(), self.IronSightsAng.y * Mul)
EyeAng:RotateAroundAxis(EyeAng:Forward(), self.IronSightsAng.z * Mul)
end
local Right = EyeAng:Right()
local Up = EyeAng:Up()
local Forward = EyeAng:Forward()
EyePos = EyePos + Offset.x * Right * Mul
EyePos = EyePos + Offset.y * Forward * Mul
EyePos = EyePos + Offset.z * Up * Mul
return EyePos, EyeAng
end
end
hook.Add("CreateMove", "ixHandsCreateMove", function(cmd)
if (LocalPlayer():GetLocalVar("bIsHoldingObject", false) and cmd:KeyDown(IN_ATTACK2)) then
cmd:ClearMovement()
local angle = RenderAngles()
angle.z = 0
cmd:SetViewAngles(angle)
end
end)
end
function SWEP:Deploy()
if (!IsValid(self:GetOwner())) then
return
end
local viewModel = self:GetOwner():GetViewModel()
if (IsValid(viewModel)) then
viewModel:SetPlaybackRate(1)
viewModel:ResetSequence(ACT_VM_FISTS_DRAW)
if CLIENT then
self.NextAllowedPlayRateChange = CurTime() + viewModel:SequenceDuration()
end
end
self:DropObject()
return true
end
function SWEP:Precache()
util.PrecacheSound("npc/vort/claw_swing1.wav")
util.PrecacheSound("npc/vort/claw_swing2.wav")
util.PrecacheSound("physics/plastic/plastic_box_impact_hard1.wav")
util.PrecacheSound("physics/plastic/plastic_box_impact_hard2.wav")
util.PrecacheSound("physics/plastic/plastic_box_impact_hard3.wav")
util.PrecacheSound("physics/plastic/plastic_box_impact_hard4.wav")
util.PrecacheSound("physics/wood/wood_crate_impact_hard2.wav")
util.PrecacheSound("physics/wood/wood_crate_impact_hard3.wav")
end
function SWEP:OnReloaded()
self.maxHoldDistanceSquared = self.maxHoldDistance ^ 2
self:DropObject()
end
function SWEP:Holster()
if (!IsValid(self:GetOwner())) then
return
end
local viewModel = self:GetOwner():GetViewModel()
if (IsValid(viewModel)) then
viewModel:SetPlaybackRate(1)
viewModel:ResetSequence(ACT_VM_FISTS_HOLSTER)
if CLIENT then
self.NextAllowedPlayRateChange = CurTime() + viewModel:SequenceDuration()
end
end
return true
end
function SWEP:Think()
if (!IsValid(self:GetOwner())) then
return
end
if (CLIENT) then
local viewModel = self:GetOwner():GetViewModel()
if (IsValid(viewModel) and self.NextAllowedPlayRateChange < CurTime()) then
viewModel:SetPlaybackRate(1)
end
else
if (self:IsHoldingObject()) then
local physics = self:GetHeldPhysicsObject()
local bIsRagdoll = self.heldEntity:IsRagdoll()
local holdDistance = bIsRagdoll and self.holdDistance * 0.5 or self.holdDistance
local targetLocation = self:GetOwner():GetShootPos() + self:GetOwner():GetForward() * holdDistance
if (bIsRagdoll) then
targetLocation.z = math.min(targetLocation.z, self:GetOwner():GetShootPos().z - 32)
end
if (!IsValid(physics)) then
self:DropObject()
return
end
if (physics:GetPos():DistToSqr(targetLocation) > self.maxHoldDistanceSquared) then
self:DropObject()
else
local physicsObject = self.holdEntity:GetPhysicsObject()
local currentPlayerAngles = self:GetOwner():EyeAngles()
local client = self:GetOwner()
if (client:KeyDown(IN_ATTACK2)) then
local cmd = client:GetCurrentCommand()
self.heldObjectAngle:RotateAroundAxis(currentPlayerAngles:Forward(), cmd:GetMouseX() / 15)
self.heldObjectAngle:RotateAroundAxis(currentPlayerAngles:Right(), cmd:GetMouseY() / 15)
end
self.lastPlayerAngles = self.lastPlayerAngles or currentPlayerAngles
self.heldObjectAngle.y = self.heldObjectAngle.y - math.AngleDifference(self.lastPlayerAngles.y, currentPlayerAngles.y)
self.lastPlayerAngles = currentPlayerAngles
physicsObject:Wake()
physicsObject:ComputeShadowControl({
secondstoarrive = 0.01,
pos = targetLocation,
angle = self.heldObjectAngle,
maxangular = 256,
maxangulardamp = 10000,
maxspeed = 256,
maxspeeddamp = 10000,
dampfactor = 0.8,
teleportdistance = self.maxHoldDistance * 0.75,
deltatime = FrameTime()
})
if (physics:GetStress() > self.maxHoldStress) then
self:DropObject()
end
local pos = physics:GetPos()
local clientPos = client:GetPos()
if (clientPos.z > pos.z and math.Distance(clientPos.x, clientPos.y, pos.x, pos.y) <= 50) then
self:DropObject()
end
end
end
-- Prevents the camera from getting stuck when the object that the client is holding gets deleted.
if(!IsValid(self.heldEntity) and self:GetOwner():GetLocalVar("bIsHoldingObject", true)) then
self:GetOwner():SetLocalVar("bIsHoldingObject", false)
end
end
end
function SWEP:GetHeldPhysicsObject()
return IsValid(self.heldEntity) and self.heldEntity:GetPhysicsObject() or nil
end
function SWEP:CanHoldObject(entity)
if !entity or entity and !IsValid(entity) then return false end
local physics = entity.GetPhysicsObject and entity:GetPhysicsObject()
local client = self:GetOwner()
local clientPos = client:GetPos()
local pos = physics and IsValid(physics) and physics:GetPos()
return IsValid(physics) and
(physics:GetMass() <= ix.config.Get("maxHoldWeight", 100) and physics:IsMoveable()) and
!self:IsHoldingObject() and
!IsValid(entity.ixHeldOwner) and
hook.Run("CanPlayerHoldObject", client, entity) and
!(clientPos.z > entity:GetPos().z and math.Distance(clientPos.x, clientPos.y, pos.x, pos.y) < 50)
end
function SWEP:IsHoldingObject()
return IsValid(self.heldEntity) and
IsValid(self.heldEntity.ixHeldOwner) and
self.heldEntity.ixHeldOwner == self:GetOwner()
end
function SWEP:PickupObject(entity)
if (self:IsHoldingObject() or
!IsValid(entity) or
!IsValid(entity:GetPhysicsObject())) then
return
end
local physics = entity:GetPhysicsObject()
physics:EnableGravity(false)
physics:AddGameFlag(FVPHYSICS_PLAYER_HELD)
entity.ixHeldOwner = self:GetOwner()
entity.ixCollisionGroup = entity:GetCollisionGroup()
entity:StartMotionController()
entity:SetCollisionGroup(COLLISION_GROUP_WEAPON)
self.heldObjectAngle = entity:GetAngles()
self.heldEntity = entity
self.holdEntity = ents.Create("prop_physics")
self.holdEntity:SetPos(self.heldEntity:LocalToWorld(self.heldEntity:OBBCenter()))
self.holdEntity:SetAngles(self.heldEntity:GetAngles())
self.holdEntity:SetModel("models/weapons/w_bugbait.mdl")
self.holdEntity:SetOwner(self:GetOwner())
self.holdEntity:SetNoDraw(true)
self.holdEntity:SetNotSolid(true)
self.holdEntity:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
self.holdEntity:DrawShadow(false)
self.holdEntity:Spawn()
local trace = self:GetOwner():GetEyeTrace()
local physicsObject = self.holdEntity:GetPhysicsObject()
if (IsValid(physicsObject)) then
physicsObject:SetMass(2048)
physicsObject:SetDamping(0, 1000)
physicsObject:EnableGravity(false)
physicsObject:EnableCollisions(false)
physicsObject:EnableMotion(false)
end
if (trace.Entity:IsRagdoll()) then
local tracedEnt = trace.Entity
self.holdEntity:SetPos(tracedEnt:GetBonePosition(tracedEnt:TranslatePhysBoneToBone(trace.PhysicsBone)))
end
self.constraint = constraint.Weld(self.holdEntity, self.heldEntity, 0,
trace.Entity:IsRagdoll() and trace.PhysicsBone or 0, 0, true, true)
end
function SWEP:DropObject(bThrow)
if (!IsValid(self.heldEntity) or self.heldEntity.ixHeldOwner != self:GetOwner()) then
return
end
self.lastPlayerAngles = nil
self:GetOwner():SetLocalVar("bIsHoldingObject", false)
self.constraint:Remove()
self.holdEntity:Remove()
self.heldEntity:StopMotionController()
self.heldEntity:SetCollisionGroup(self.heldEntity.ixCollisionGroup or COLLISION_GROUP_NONE)
local physics = self:GetHeldPhysicsObject()
physics:EnableGravity(true)
physics:Wake()
physics:ClearGameFlag(FVPHYSICS_PLAYER_HELD)
if (bThrow) then
timer.Simple(0, function()
if (IsValid(physics) and IsValid(self:GetOwner())) then
physics:AddGameFlag(FVPHYSICS_WAS_THROWN)
physics:ApplyForceCenter(self:GetOwner():GetAimVector() * ix.config.Get("throwForce", 732))
end
end)
end
self.heldEntity.ixHeldOwner = nil
self.heldEntity.ixCollisionGroup = nil
self.heldEntity = nil
end
function SWEP:PlayPickupSound(surfaceProperty)
local result = "Flesh.ImpactSoft"
if (surfaceProperty != nil) then
local surfaceName = util.GetSurfacePropName(surfaceProperty)
local soundName = surfaceName:gsub("^metal$", "SolidMetal") .. ".ImpactSoft"
if (sound.GetProperties(soundName)) then
result = soundName
end
end
self:GetOwner():EmitSound(result, 75, 100, 40)
end
function SWEP:Holster()
if (!IsFirstTimePredicted() or CLIENT) then
return
end
self:DropObject()
return true
end
function SWEP:OnRemove()
if (SERVER) then
self:DropObject()
end
end
function SWEP:OwnerChanged()
if (SERVER) then
self:DropObject()
end
end
function SWEP:DoPunchAnimation()
self.lastHand = math.abs(1 - self.lastHand)
local sequence = 3 + self.lastHand
local viewModel = self:GetOwner():GetViewModel()
if (IsValid(viewModel)) then
viewModel:SetPlaybackRate(0.5)
viewModel:SetSequence(sequence)
if CLIENT then
self.NextAllowedPlayRateChange = CurTime() + viewModel:SequenceDuration() * 2
end
end
end
function SWEP:PrimaryAttack()
if (!IsFirstTimePredicted()) then
return
end
if (SERVER and self:IsHoldingObject()) then
self:DropObject(true)
return
end
self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
if (hook.Run("CanPlayerThrowPunch", self:GetOwner()) == false) then
return
end
if (ix.plugin.Get("stamina")) then
local staminaUse = ix.config.Get("punchStamina")
if (staminaUse > 0) then
local value = self:GetOwner():GetLocalVar("stm", 0) - staminaUse
if (value < 0) then
return
elseif (SERVER) then
self:GetOwner():ConsumeStamina(staminaUse)
end
end
end
if (SERVER) then
self:GetOwner():EmitSound("npc/vort/claw_swing"..math.random(1, 2)..".wav")
end
self:DoPunchAnimation()
self:GetOwner():SetAnimation(PLAYER_ATTACK1)
self:GetOwner():ViewPunch(Angle(self.lastHand + 2, self.lastHand + 5, 0.125))
if ix.plugin.Get("vortigaunts") then
if (ix.config.Get("pushOnly")) and !self:GetOwner():IsVortigaunt() then
local data = {}
data.start = self.Owner:GetShootPos()
data.endpos = data.start + self.Owner:GetAimVector() * 84
data.filter = {self, self.Owner}
local trace = util.TraceLine(data)
local entity = trace.Entity
if (entity:IsPlayer() and ix.config.Get("allowPush", true)) then
self:PushEntity(entity)
end
return
end
else
if (ix.config.Get("pushOnly")) then
local data = {}
data.start = self.Owner:GetShootPos()
data.endpos = data.start + self.Owner:GetAimVector() * 84
data.filter = {self, self.Owner}
local trace = util.TraceLine(data)
local entity = trace.Entity
if (entity:IsPlayer() and ix.config.Get("allowPush", true)) then
self:PushEntity(entity)
end
return
end
end
timer.Simple(0.055, function()
if (IsValid(self) and IsValid(self:GetOwner())) then
local damage = self.Primary.Damage
if ix.plugin.Get("vortigaunts") then
if self:GetOwner():IsVortigaunt() then
damage = damage + self:GetOwner():GetCharacter():GetSkillLevel("melee")
end
if (SERVER and self:GetOwner():IsPlayer() and self:GetOwner().GetCharacter and self:GetOwner():GetCharacter() and self:GetOwner():IsVortigaunt()) then
self:GetOwner():GetCharacter():DoAction("melee_slash")
end
end
local context = {damage = damage}
local result = hook.Run("GetPlayerPunchDamage", self:GetOwner(), damage, context)
if (result != nil) then
damage = result
else
damage = context.damage
end
self:GetOwner():LagCompensation(true)
local data = {}
data.start = self:GetOwner():GetShootPos()
data.endpos = data.start + self:GetOwner():GetAimVector() * 96
data.filter = self:GetOwner()
local trace = util.TraceLine(data)
if (SERVER and trace.Hit) then
local entity = trace.Entity
if (IsValid(entity)) then
if ix.plugin.Get("vortigaunts") then
if (self:GetOwner():IsPlayer() and self:GetOwner().GetCharacter and self:GetOwner():GetCharacter() and self:GetOwner():IsVortigaunt()) then
self:GetOwner():GetCharacter():DoAction("melee_hit")
end
end
local damageInfo = DamageInfo()
damageInfo:SetAttacker(self:GetOwner())
damageInfo:SetInflictor(self)
damageInfo:SetDamage(damage)
damageInfo:SetDamageType(DMG_GENERIC)
damageInfo:SetDamagePosition(trace.HitPos)
damageInfo:SetDamageForce(self:GetOwner():GetAimVector() * 1024)
entity:DispatchTraceAttack(damageInfo, data.start, data.endpos)
if (entity:IsPlayer()) then
ix.log.AddRaw(self:GetOwner():Name() .." has damaged " .. entity:Name() .. ", dealing " .. damage .. " with ix_hands")
end
if (entity:IsNPC()) then
ix.log.AddRaw(self:GetOwner():Name() .." has damaged " .. entity:GetClass() .. ", dealing " .. damage .. " with ix_hands")
end
self:GetOwner():EmitSound("physics/body/body_medium_impact_hard"..math.random(1, 6)..".wav", 80)
end
end
hook.Run("PlayerThrowPunch", self:GetOwner(), trace)
self:GetOwner():LagCompensation(false)
if (CLIENT and trace.Hit) then
local entity = trace.Entity
if (entity:IsPlayer() and IsValid(entity)) then
chat.AddText(Color(217, 83, 83), "You have damaged " .. entity:Name() .. ", dealing " .. damage .. " points of damage.")
end
if (entity:IsNPC()) then
chat.AddText(Color(217, 83, 83), "You have damaged " .. entity:GetClass() .. ", dealing " .. damage .. " points of damage.")
end
end
end
end)
end
function SWEP:SecondaryAttack()
if (!IsFirstTimePredicted()) then
return
end
local data = {}
data.start = self:GetOwner():GetShootPos()
data.endpos = data.start + self:GetOwner():GetAimVector() * 84
data.filter = {self, self:GetOwner()}
local trace = util.TraceLine(data)
local entity = trace.Entity
if CLIENT then
local viewModel = self:GetOwner():GetViewModel()
if (IsValid(viewModel)) then
viewModel:SetPlaybackRate(0.5)
if CLIENT then
self.NextAllowedPlayRateChange = CurTime() + viewModel:SequenceDuration() * 2
end
end
end
if (SERVER and IsValid(entity)) then
if (entity:IsDoor()) then
if (hook.Run("CanPlayerKnock", self:GetOwner(), entity) == false) then
return
end
self:GetOwner():ViewPunch(self.KnockViewPunchAngle)
self:GetOwner():EmitSound("physics/wood/wood_crate_impact_hard"..math.random(2, 3)..".wav")
self:GetOwner():SetAnimation(PLAYER_ATTACK1)
self:DoPunchAnimation()
self:SetNextSecondaryFire(CurTime() + 0.4)
self:SetNextPrimaryFire(CurTime() + 1)
elseif (entity:IsPlayer() and ix.config.Get("allowPush", true)) then
self:PushEntity(entity)
elseif (!entity:IsNPC() and self:CanHoldObject(entity)) then
self:GetOwner():SetLocalVar("bIsHoldingObject", true)
self:PickupObject(entity)
self:PlayPickupSound(trace.SurfaceProps)
self:SetNextSecondaryFire(CurTime() + self.Secondary.Delay)
end
end
end
function SWEP:PushEntity(entity)
local curTime = CurTime()
local direction = self.Owner:GetAimVector() * (300 + (self.Owner:GetCharacter():GetAttribute("str", 0) * 3))
direction.z = 0
entity:SetVelocity(direction)
self.Owner:EmitSound("physics/flesh/flesh_impact_hard"..math.random(1, 6)..".wav")
self:SetNextSecondaryFire(curTime + 1.5)
self:SetNextPrimaryFire(curTime + 1.5)
end
function SWEP:Reload()
if (!IsFirstTimePredicted()) then
return
end
if (SERVER and IsValid(self.heldEntity)) then
self:DropObject()
end
end