这是我在StackOverflow上发布的一个通常的变化!今天我试着编辑某人的Garry's Mod Workshop插件。
我想让它成为一击击杀,它是一个斯巴达踢。
代码如下:
if( SERVER ) then
AddCSLuaFile( "shared.lua" );
end
if( CLIENT ) then
SWEP.Category = "Epic Kicks";
SWEP.PrintName = "Spartan Kick";
SWEP.WepSelectIcon = surface.GetTextureID("VGUI/entities/spartan_kick")
SWEP.Slot = 1;
SWEP.SlotPos = 4;
SWEP.DrawAmmo = false;
SWEP.DrawCrosshair = false;
end
SWEP.Author = "Shot846 (Original) + 2Epic4You (Modified)"
SWEP.Instructions = "A better Sparta Kick. Use sv_cheats 1 for slow-motion!"
SWEP.Contact = "..."
SWEP.Purpose = "THIS IS EDITED SPARTAAAAAAA!"
SWEP.ViewModelFOV = 75
SWEP.ViewModelFlip = false
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.NextStrike = 0;
SWEP.ViewModel = "models/weapons/v_kick.mdl"
SWEP.WorldModel = ""
-------------Primary Fire Attributes----------------------------------------
SWEP.Primary.Delay = 0.4 --In seconds
SWEP.Primary.Recoil = 0 --Gun Kick
SWEP.Primary.Damage = math.huge --Damage per Bullet
SWEP.Primary.NumShots = 1 --Number of shots per one fire
SWEP.Primary.Cone = 0 --Bullet Spread
SWEP.Primary.ClipSize = -1 --Use "-1 if there are no clips"
SWEP.Primary.DefaultClip = -1 --Number of shots in next clip
SWEP.Primary.Automatic = true --Pistol fire (false) or SMG fire (true)
SWEP.Primary.Ammo = "none" --Ammo Type
-------------Secondary Fire Attributes----------------------------------------
SWEP.Secondary.Delay = 0 --In seconds
SWEP.Secondary.Recoil = 0 --Gun Kick
SWEP.Secondary.Damage = math.huge --Damage per Bullet
SWEP.Secondary.NumShots = 1 --Number of shots per one fire
SWEP.Secondary.Cone = 0 --Bullet Spread
SWEP.Secondary.ClipSize = -1 --Use "-1 if there are no clips"
SWEP.Secondary.DefaultClip = -1 --Number of shots in next clip
SWEP.Secondary.Automatic = true --Pistol fire (false) or SMG fire (true)
SWEP.Secondary.Ammo = "none" --Ammo Type
-------------Precache Sounds----------------------------------------
util.PrecacheSound("player/skick/madness.mp3")
util.PrecacheSound("player/skick/foot_kickwall.wav")
util.PrecacheSound("player/skick/foot_kickbody.wav")
util.PrecacheSound("player/skick/sparta.mp3")
util.PrecacheSound("player/skick/kick1.wav")
util.PrecacheSound("player/skick/kick2.wav")
util.PrecacheSound("player/skick/kick3.wav")
util.PrecacheSound("player/skick/kick4.wav")
util.PrecacheSound("player/skick/kick5.wav")
util.PrecacheSound("player/skick/kick6.wav")
function SWEP:Initialize()
if( SERVER ) then
self:SetWeaponHoldType("normal");
end
self.Hit = {
Sound( "player/skick/foot_kickwall.wav" )};
self.FleshHit = {
Sound( "player/skick/kick1.wav" ),
Sound( "player/skick/kick2.wav" ),
Sound( "player/skick/kick3.wav" ),
Sound( "player/skick/kick4.wav" ),
Sound( "player/skick/kick5.wav" ),
Sound( "player/skick/kick6.wav" ) } ;
end
function SWEP:Precache()
end
function SWEP:Deploy()
self.Weapon:SendWeaponAnim( ACT_VM_IDLE );
return true;
end
function SWEP:PrimaryAttack()
if( CurTime() < self.NextStrike ) then return; end
self.Weapon:EmitSound("player/skick/sparta.mp3")
self.NextStrike = ( CurTime() + 3.5 );
timer.Simple( 1.80, function() self.AttackAnim(self) end)
timer.Simple( 2.40, function() self.Weapon:SendWeaponAnim( ACT_VM_IDLE ) end)
timer.Simple( 2.0, function() self.ShootBullets (self) end)
self.Owner:SetAnimation( PLAYER_ATTACK1 );
end
function SWEP:ShootBullets()
self.Weapon:EmitSound("player/skick/foot_swing.wav");
local trace = self.Owner:GetEyeTrace();
if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 130 then
if( trace.Entity:IsPlayer() or trace.Entity:IsNPC() or trace.Entity:GetClass()=="prop_ragdoll" ) then
timer.Simple(0, function() game.ConsoleCommand("host_timescale 0.1n") end)
timer.Simple(0.1, function() game.ConsoleCommand("host_timescale 1n") end)
self.Owner:EmitSound( self.FleshHit[math.random(1,#self.FleshHit)] );
else
self.Owner:EmitSound( self.Hit[math.random(1,#self.Hit)] );
end
bullet = {}
bullet.Num = 5
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector(0.04, 0.04, 0.04)
bullet.Tracer = 0
bullet.Force = math.huge
bullet.Damage = math.huge
self.Owner:FireBullets(bullet)
end
if trace.Entity:GetClass() == "prop_door_rotating" then
trace.Entity:EmitSound(Sound("physics/wood/wood_box_impact_hard3.wav"))
trace.Entity:Fire("open", "", .001)
trace.Entity:Fire("unlock", "", .001)
local pos = trace.Entity:GetPos()
local ang = trace.Entity:GetAngles()
local model = trace.Entity:GetModel()
local skin = trace.Entity:GetSkin()
trace.Entity:SetNotSolid(true)
trace.Entity:SetNoDraw(true)
local function ResetDoor(door, fakedoor)
door:SetNotSolid(false)
door:SetNoDraw(false)
fakedoor:Remove()
end
local norm = (pos - self.Owner:GetPos()):Normalize()
local push = 1000000 * norm
local ent = ents.Create("prop_physics")
ent:SetPos(pos)
ent:SetAngles(ang)
ent:SetModel(model)
if(skin) then
ent:SetSkin(skin)
end
ent:Spawn()
timer.Simple(.01, ent.SetVelocity, ent, push)
timer.Simple(.01, ent:GetPhysicsObject().ApplyForceCenter, ent:GetPhysicsObject(), push)
timer.Simple(140, ResetDoor, trace.Entity, ent)
end
end
function SWEP:SecondaryAttack()
if( CurTime() < self.NextStrike ) then return; end
self.NextStrike = ( CurTime() + 0.75 );
timer.Simple( 0.00, function() self.AttackAnim(self) end)
timer.Simple( 0.75, function() self.Weapon:SendWeaponAnim( ACT_VM_IDLE ) end)
timer.Simple( 0.20, function() self.ShootBullets (self) end)
self.Owner:SetAnimation( PLAYER_ATTACK1 );
end
function SWEP:Reload()
if( CurTime() < self.NextStrike ) then return; end
self.Weapon:EmitSound("player/skick/madness.mp3")
self.NextStrike = ( CurTime() + 2.00 );
end
function SWEP:AttackAnim()
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
end
是的,它的工作,但它不是立即杀死NPC我刷。
我需要改变什么值才能使它insta-kill?
我试过了:
- 将所有发现的伤害值更改为math.huge
我发现了:
- 我发现它仍然会损坏NPC,原始值是
1000000
,但它没有安装杀死NPC。
我真的弄明白了!在维基上做了大量的研究之后,我发现你可以有子弹。这就是我所做的:
bullet = {}
bullet.Num = 10
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector(0.04, 0.04, 0.04)
bullet.Tracer = 0
bullet.Force = 20000
bullet.Damage = 999999
bullet.Callback = function(attacker, tree, damageinfo)
if(trace.Entity:IsNPC()) then
trace.Entity:SetHealth(0)
elseif(trace.Entity:IsPlayer()) then
trace.Entity:Kill()
end
end
self.Owner:FireBullets(bullet)