effects + mockup of real icon on box

This commit is contained in:
1darky 2022-04-13 16:22:32 +07:00
parent 59c789db9c
commit bcc905aa56
5 changed files with 122 additions and 59 deletions

View File

@ -6,7 +6,7 @@ ENT.Information = ""
ENT.Spawnable = false
ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
ENT.RenderGroup = RENDERGROUP_OPAQUE
ENT.Category = "ARC9 - Attachments"
@ -15,75 +15,122 @@ AddCSLuaFile()
ENT.GiveAttachments = nil -- table of all the attachments to give, and in what quantity. {{["id"] = int quantity}}
ENT.SoundImpact = "weapon.ImpactSoft"
ENT.Model = "models/items/att_plastic_box.mdl"
ENT.Model = "models/items/arc9/att_wooden_box.mdl"
if SERVER then
function ENT:Initialize()
if !self.Model then
self:Remove()
return
end
self:SetModel(self.Model)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetCollisionGroup(COLLISION_GROUP_WEAPON)
self:SetTrigger( true )
self:SetPos(self:GetPos() + Vector(0, 0, 4))
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
phys:SetBuoyancyRatio(0)
end
end
function ENT:PhysicsCollide(colData, collider)
if colData.DeltaTime < 0.25 then return end
self:EmitSound(self.SoundImpact)
end
function ENT:Use(activator, caller)
if !caller:IsPlayer() then return end
if GetConVar("arc9_free_atts"):GetBool() then return end
local take = false
for i, k in pairs(self.GiveAttachments) do
if i == "BaseClass" then continue end
if GetConVar("arc9_lock_atts"):GetBool() then
if ARC9:PlayerGetAtts(caller, i) > 0 then
continue
end
function ENT:Initialize()
if !self.Model then
self:Remove()
return
end
if hook.Run("ARC9_PickupAttEnt", caller, i, k) then continue end
ARC9:PlayerGiveAtt(caller, i, k)
take = true
self:SetModel(self.Model)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetCollisionGroup(COLLISION_GROUP_WEAPON)
self:SetTrigger(true)
self:SetPos(self:GetPos() + Vector(0, 0, 4))
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
phys:SetBuoyancyRatio(0)
end
end
if take then
ARC9:PlayerSendAttInv(caller)
function ENT:PhysicsCollide(colData, collider)
if colData.DeltaTime < 0.25 then return end
self:EmitSound("weapons/ARC9/useatt.wav")
self:Remove()
self:EmitSound(self.SoundImpact)
end
end
function ENT:Use(activator, caller)
if !caller:IsPlayer() then return end
-- if GetConVar("arc9_free_atts"):GetBool() then return end
local take = false
-- for i, k in pairs(self.GiveAttachments) do
-- if i == "BaseClass" then continue end
-- if GetConVar("arc9_lock_atts"):GetBool() then
-- if ARC9:PlayerGetAtts(caller, i) > 0 then
-- continue
-- end
-- end
-- if hook.Run("ARC9_PickupAttEnt", caller, i, k) then continue end
-- ARC9:PlayerGiveAtt(caller, i, k)
take = true
-- end
if take then
ARC9:PlayerSendAttInv(caller)
local effectdata = EffectData()
effectdata:SetOrigin(self:GetPos()+Vector(0, 0, 10))
effectdata:SetMaterialIndex(0)
local mfsdfd = math.random(0,50)
if mfsdfd == 1 then
effectdata:SetMaterialIndex(1) -- 🕷
end
util.Effect("arc9_opencrate", effectdata)
self:EmitSound("weapons/ARC9/useatt.wav")
-- self:Remove()
end
end
else
function ENT:BeingLookedAtByLocalPlayer()
local ply = LocalPlayer()
if !IsValid(ply) then return false end
function ENT:DrawTranslucent()
self:Draw()
end
local dist = 10000
function ENT:Draw()
self:DrawModel()
end
local pos = ply:EyePos()
if pos:DistToSqr(self:GetPos()) <= dist then
return util.TraceLine({
start = pos,
endpos = pos + (ply:GetAngles():Forward() * dist),
filter = ply
}).Entity == self
end
return false
end
-- function ENT:DrawTranslucent()
-- self:Draw()
-- end
local icon = Material("entities/arc9_att_m79_tactical.png") -- change to else later okay ?
function ENT:Initialize()
-- local maticon = CreateMaterial("attnamehere", "VertexLitGeneric", {
-- ["$basetexture"] = "color/white",
-- ["$translucent"] = 1,
-- })
-- maticon:SetTexture
-- i ll do it later
-- self:SetSubMaterial(1, "nil" )
end
function ENT:Draw()
self:DrawModel()
end
local white = Color(255, 255, 255)
function ENT:Think()
if self:BeingLookedAtByLocalPlayer() then
halo.Add( { self }, white, 3, 3, 2, true, true )
end
end
end

View File

@ -0,0 +1,8 @@
"UnlitGeneric"
{
"$basetexture" "effects/peanut"
"$vertexcolor" "1"
"$vertexalpha" "1"
"$translucent" "1"
"$nocull" "1"
}

Binary file not shown.

View File

@ -0,0 +1,8 @@
"UnlitGeneric"
{
"$basetexture" "effects/spider"
"$vertexcolor" "1"
"$vertexalpha" "1"
"$translucent" "1"
"$nocull" "1"
}

Binary file not shown.