Залив
This commit is contained in:
44
lua/entities/mg_40mm/cl_init.lua
Normal file
44
lua/entities/mg_40mm/cl_init.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
include("shared.lua")
|
||||
|
||||
ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
|
||||
ENT.bTracerOn = false
|
||||
|
||||
ENT.OuterFlairColor = Color(236,153,17,255)
|
||||
ENT.InnerFlairColor = Color(255,255,255,255)
|
||||
|
||||
ENT.OuterFlairScale = 1
|
||||
ENT.InnerFlairScale = 0.3
|
||||
|
||||
local flair = Material("shadowdark/flairs/grenade_flair.vmt")
|
||||
|
||||
function ENT:DrawTranslucent(flags)
|
||||
if (self:GetVelocity():LengthSqr() > 0 || self:GetNailed()) then
|
||||
self:DrawModel()
|
||||
|
||||
local ang = LocalPlayer():EyeAngles()
|
||||
local angle = Angle( 0, LocalPlayer():EyeAngles()[2], 0 )
|
||||
|
||||
angle = Angle(LocalPlayer():EyeAngles()[1], angle.y, 0 )
|
||||
|
||||
angle:RotateAroundAxis( angle:Up(), -90 )
|
||||
angle:RotateAroundAxis( angle:Forward(), 90 )
|
||||
|
||||
|
||||
cam.Start3D2D( self:GetPos() - self:GetForward() * 5, angle, 0.2 )
|
||||
|
||||
local OuterScale = 512 * self.OuterFlairScale
|
||||
local InnerScale = 512 * self.InnerFlairScale
|
||||
|
||||
surface.SetMaterial(flair)
|
||||
surface.SetDrawColor(self.OuterFlairColor)
|
||||
surface.DrawTexturedRect(-OuterScale/2, -OuterScale/2, OuterScale, OuterScale)
|
||||
|
||||
surface.SetDrawColor(self.InnerFlairColor)
|
||||
surface.DrawTexturedRect(-InnerScale/2, -InnerScale/2, InnerScale, InnerScale)
|
||||
cam.End3D2D()
|
||||
|
||||
if (!self.bTracerOn) then
|
||||
self.bTracerOn = true
|
||||
end
|
||||
end
|
||||
end
|
||||
134
lua/entities/mg_40mm/init.lua
Normal file
134
lua/entities/mg_40mm/init.lua
Normal file
@@ -0,0 +1,134 @@
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
|
||||
include("shared.lua")
|
||||
|
||||
ENT.bCollided = false
|
||||
ENT.Projectile = {
|
||||
Class = "mg_bullet",
|
||||
Speed = 4000,
|
||||
Gravity = 1
|
||||
}
|
||||
ENT.Maxs = Vector(1, 1, 1)
|
||||
ENT.Model = Model("models/items/ar2_grenade.mdl")
|
||||
ENT.AoeEntity = nil
|
||||
|
||||
function ENT:Initialize()
|
||||
self:SetModel(self.Model)
|
||||
self:PhysicsInitBox(Vector(-10, -1, -1), Vector(10, 1, 1))
|
||||
self:GetPhysicsObject():Wake()
|
||||
self:GetPhysicsObject():SetMaterial("default_silent")
|
||||
self:GetPhysicsObject():AddGameFlag(FVPHYSICS_NO_PLAYER_PICKUP)
|
||||
self:GetPhysicsObject():AddGameFlag(FVPHYSICS_NO_IMPACT_DMG)
|
||||
self:GetPhysicsObject():AddGameFlag(FVPHYSICS_HEAVY_OBJECT)
|
||||
self:GetPhysicsObject():EnableMotion(true)
|
||||
self:GetPhysicsObject():EnableDrag(false)
|
||||
self:GetPhysicsObject():SetMass(1000)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
self:SetCollisionGroup(COLLISION_GROUP_IN_VEHICLE) --doesn't collide with anything, no traces
|
||||
self:AddEFlags(EFL_NO_DAMAGE_FORCES)
|
||||
self:AddEFlags(EFL_DONTWALKON)
|
||||
self:AddEFlags(EFL_DONTBLOCKLOS)
|
||||
self:AddEFlags(EFL_NO_PHYSCANNON_INTERACTION)
|
||||
|
||||
self.Projectile = table.Copy(self.Weapon.Projectile)
|
||||
self:GetPhysicsObject():SetVelocityInstantaneous(self:GetAngles():Forward() * self.Projectile.Speed)
|
||||
self.LastPos = self:GetOwner():EyePos()
|
||||
self.Bullet = self.Weapon.Bullet
|
||||
self.ImpactDamage = self.Weapon.Explosive.ImpactBlastRatio
|
||||
self.BlastRadius = self.Weapon.Explosive.BlastRadius
|
||||
end
|
||||
|
||||
ENT.m_gravity = 0
|
||||
|
||||
function ENT:PhysicsUpdate(phys)
|
||||
if (!phys:IsMotionEnabled()) then
|
||||
return
|
||||
end
|
||||
|
||||
self.m_gravity = math.Clamp(self.m_gravity + (self.Projectile.Gravity), -90, 90)
|
||||
|
||||
phys:SetAngles(phys:GetAngles() + Angle(self.m_gravity, 0, 0) * FrameTime())
|
||||
phys:SetPos(self.LastPos + phys:GetAngles():Forward() * (self.Projectile.Speed * FrameTime()))
|
||||
|
||||
--Aim assist
|
||||
if (GetConVar("mgbase_debug_projectiles"):GetInt() > 0) then
|
||||
debugoverlay.Box(phys:GetPos(), -self.Maxs, self.Maxs, 0, Color(0, 200, 50, 10))
|
||||
end
|
||||
|
||||
local trData = {
|
||||
start = self.LastPos,
|
||||
endpos = phys:GetPos(),
|
||||
filter = {self:GetOwner(), self},
|
||||
mask = MASK_SHOT_PORTAL,
|
||||
collisiongroup = COLLISION_GROUP_NONE,
|
||||
mins = -self.Maxs,
|
||||
maxs = self.Maxs
|
||||
}
|
||||
|
||||
local tr = util.TraceHull(trData)
|
||||
|
||||
if (tr.Hit && (tr.Entity:IsPlayer() || tr.Entity:IsNPC())) then
|
||||
self:Impact(tr, phys, true)
|
||||
return
|
||||
end
|
||||
|
||||
--Normal hitscan
|
||||
if (GetConVar("mgbase_debug_projectiles"):GetInt() > 0) then
|
||||
debugoverlay.Line(self.LastPos, phys:GetPos(), 1, Color(255, 0, 0, 1))
|
||||
end
|
||||
|
||||
tr = util.TraceLine(trData)
|
||||
|
||||
if (tr.Hit) then
|
||||
self:Impact(tr, phys, false)
|
||||
return
|
||||
end
|
||||
|
||||
self.LastPos = phys:GetPos()
|
||||
end
|
||||
|
||||
function ENT:Impact(tr1, phys, bHull)
|
||||
phys:EnableMotion(false)
|
||||
|
||||
self:SetPos(tr1.HitPos)
|
||||
|
||||
self:FireBullets({
|
||||
Attacker = self:GetOwner(),
|
||||
Num = 1,
|
||||
Tracer = 0,
|
||||
Src = self.LastPos,
|
||||
Dir = (phys:GetPos() - self.LastPos):GetNormalized(),
|
||||
HullSize = bHull && self.Maxs:Length() * 2 || 1,
|
||||
IgnoreEntity = self,
|
||||
Callback = function(attacker, tr, dmgInfo)
|
||||
dmgInfo:SetInflictor(IsValid(self.Weapon) && self.Weapon || self)
|
||||
dmgInfo:SetDamageType(dmgInfo:GetDamageType() + DMG_DIRECT + self:GetDamageType())
|
||||
|
||||
if (IsValid(self.Weapon)) then
|
||||
self.Weapon:BulletCallback(attacker, tr, dmgInfo)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
local dmg = DamageInfo()
|
||||
|
||||
dmg:SetAttacker(self:GetOwner())
|
||||
dmg:SetInflictor(self)
|
||||
dmg:SetDamage(self.Bullet.Damage[1])
|
||||
dmg:SetDamageType(DMG_BLAST + DMG_AIRBOAT)
|
||||
dmg:SetReportedPosition(self:GetPos())
|
||||
|
||||
util.BlastDamageInfo(dmg, self:GetPos(), self.BlastRadius)
|
||||
util.ScreenShake(self:GetPos(), 3500, 1111, 1, 124 * 4)
|
||||
|
||||
ParticleEffect("Generic_explo_high", self:GetPos(), self:GetAngles())
|
||||
self:EmitSound("^viper/shared/frag_expl.ogg", 0, 100, 1, CHAN_WEAPON)
|
||||
util.Decal("Scorch", self:GetPos(), self:GetPos() + self:GetUp() * -100, {self})
|
||||
|
||||
self:Remove()
|
||||
end
|
||||
|
||||
function ENT:GetDamageType()
|
||||
return DMG_BLAST + DMG_DIRECT
|
||||
end
|
||||
39
lua/entities/mg_40mm/shared.lua
Normal file
39
lua/entities/mg_40mm/shared.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
ENT.Base = "base_entity"
|
||||
ENT.Type = "anim"
|
||||
|
||||
ENT.Spawnable = false
|
||||
ENT.AdminOnly = false
|
||||
|
||||
game.AddParticles("particles/mw19_attachments.pcf")
|
||||
PrecacheParticleSystem("arrow_trail")
|
||||
|
||||
sound.Add({
|
||||
name = "MW19_Crossbow.Hit",
|
||||
channel = CHAN_BODY,
|
||||
volume = 1,
|
||||
level = 85,
|
||||
pitch = {95, 105},
|
||||
sound = {"viper/shared/bullet_small_crossbow_bolt_swt_01.ogg", "viper/shared/bullet_small_crossbow_bolt_swt_02.ogg", "viper/shared/bullet_small_crossbow_bolt_swt_03.ogg"}
|
||||
})
|
||||
|
||||
sound.Add({
|
||||
name = "MW19_Crossbow.HitBody",
|
||||
channel = CHAN_BODY,
|
||||
volume = 1,
|
||||
level = 85,
|
||||
pitch = {95, 105},
|
||||
sound = {"viper/shared/bullet_flesh_plr_head_01.ogg", "viper/shared/bullet_flesh_plr_head_02.ogg", "viper/shared/bullet_flesh_plr_head_03.ogg"}
|
||||
})
|
||||
|
||||
sound.Add({
|
||||
name = "MW19_Crossbow.Skewer",
|
||||
channel = CHAN_ITEM,
|
||||
volume = 1,
|
||||
level = 85,
|
||||
pitch = {95, 105},
|
||||
sound = {"weapons/crossbow/bolt_skewer1.wav"}
|
||||
})
|
||||
|
||||
function ENT:SetupDataTables()
|
||||
self:NetworkVar("Bool", 0, "Nailed")
|
||||
end
|
||||
Reference in New Issue
Block a user