• Question for lua coders about SWEPS
    12 replies, posted
Ok soo i put melee weapons on my Deathrun server and when i go to use them you can hit the wall as a death and it will be like a bullet and hit a member.... Any ideas of a fix would be nice!!!
You're going to have to be a little less vague.
[QUOTE=DropDeadTed;44120980]You're going to have to be a little less vague.[/QUOTE] the the deaths when they run on there side of the map if you get close enough you can hit and it will hit the runners ( on any map )
That makes a little more sense. The trace you're using for the melee weapon is traveling too far, you're allowing it to go through the wall until it hits a target.. Make sure that the trace is less than the max distance, or that the targeted entity is less than the max distance.
If it's going through walls then that means he masked the trace or something...
[QUOTE=DropDeadTed;44130491]If it's going through walls then that means he masked the trace or something...[/QUOTE] Or the creator started the trace just slightly forward of the player which may not be uncommon ( depending on who wrote it; they may have wanted the damage to be at the tip of the weapon and didn't consider that it could start through walls ). He did say he "put" melee weapons into the game-mode, so we're still unsure if he wrote them, or downloaded them -- that could help this thread actually.
INIT.lua [CODE]AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include('shared.lua') /*--------------------------------------------------------- Name: ENT:Initialize() ---------------------------------------------------------*/ function ENT:Initialize() self:SetModel(self.Weapon.WorldModel) //MAJICKZ self.Weapon = self.Weapon:GetClass() //MORE MAJICKZ self:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHYSICS) local phys = self.Entity:GetPhysicsObject() self.Lifetime = CurTime() + 20 self.HitEnemy = false self.Entity:DrawShadow(false) if (phys:IsValid()) then phys:Wake() phys:SetMass(2) end util.PrecacheSound("weapons/halberd/morrowind_halberd_hitwall1.wav") util.PrecacheSound("weapons/halberd/morrowind_halberd_hit.wav") self.Hit = { Sound("weapons/halberd/morrowind_halberd_hitwall1.wav")}; self.FleshHit = { Sound("weapons/halberd/morrowind_halberd_hit.wav")} self.Entity:SetUseType(SIMPLE_USE) end /*--------------------------------------------------------- Name: ENT:Think() ---------------------------------------------------------*/ function ENT:Think() if CurTime() > self.Lifetime then self:Remove() end end /*--------------------------------------------------------- Name: ENT:Disable() ---------------------------------------------------------*/ function ENT:Disable() self.PhysicsCollide = function() end self.lifetime = CurTime() + 30 end /*--------------------------------------------------------- Name: ENT:PhysicsCollided() ---------------------------------------------------------*/ function ENT:PhysicsCollide(data, phys) local Ent = data.HitEntity if !(IsValid(Ent) or Ent:IsWorld()) then return end if Ent:IsWorld() then util.Decal("ManhackCut", data.HitPos + data.HitNormal, data.HitPos - data.HitNormal) if self.Entity:GetVelocity():Length() > 400 then self:EmitSound(self.Hit[math.random(1, #self.Hit)]) end self:Disable() elseif Ent.Health and self.HitEnemy == false then // Only deal damage once. if not(Ent:IsPlayer() or Ent:IsNPC() or Ent:GetClass() == "prop_ragdoll") then util.Decal("ManhackCut", data.HitPos + data.HitNormal, data.HitPos - data.HitNormal) self:EmitSound(self.Hit[math.random(1, #self.Hit)]) self.HitEnemy = true end local boink = ents.Create(self.Weapon) Ent:TakeDamage(50, self:GetOwner(), boink) // If you have a killicon for the halberd, this makes it appear. boink:Remove() if (Ent:IsPlayer() or Ent:IsNPC() or Ent:GetClass() == "prop_ragdoll") then local effectdata = EffectData() effectdata:SetStart(data.HitPos) effectdata:SetOrigin(data.HitPos) effectdata:SetScale(1) util.Effect("BloodImpact", effectdata) self:EmitSound(self.FleshHit[math.random(1,#self.Hit)]) self.HitEnemy = true end end self.Entity:SetOwner(nil) end /*--------------------------------------------------------- Name: ENT:Use() ---------------------------------------------------------*/ function ENT:Use(activator, caller) if activator:GetWeapon(self.Weapon) != NULL then return end // If the player has the halberd already, don't pick it up. if (activator:IsPlayer()) then activator:Give(self.Weapon) activator:SelectWeapon(self.Weapon) end self.Entity:Remove() end [/CODE] A BASE OF A SWEP [CODE]if( SERVER ) then AddCSLuaFile( "shared.lua" ) end if( CLIENT ) then SWEP.PrintName = "Morrowind Halberd" SWEP.Slot = 2 SWEP.SlotPos = 1 SWEP.DrawAmmo = false SWEP.DrawCrosshair = false end SWEP.Category = "Morrowind Halberds" SWEP.Author = "Neotanks+Doug Tyrrell + Mad Cow For LUA (Models, Textures, ect. By: Hellsing/JJSteel)" SWEP.Instructions = "" SWEP.Contact = "" SWEP.Purpose = "" SWEP.ViewModelFOV = 72 SWEP.ViewModelFlip = false SWEP.Spawnable = false SWEP.AdminSpawnable = false SWEP.ViewModel = "models/morrowind/halberd/halberd/v_halberd.mdl" SWEP.WorldModel = "models/morrowind/halberd/halberd/w_halberd.mdl" SWEP.Primary.Damage = 50 SWEP.Primary.NumShots = 0 SWEP.Primary.Delay = 0.50 SWEP.Primary.ClipSize = -1 // Size of a clip SWEP.Primary.DefaultClip = -1 // Default number of bullets in a clip SWEP.Primary.Automatic = true // Automatic/Semi Auto SWEP.Primary.Ammo = "none" SWEP.Secondary.ClipSize = -1 // Size of a clip SWEP.Secondary.DefaultClip = -1 // Default number of bullets in a clip SWEP.Secondary.Automatic = false // Automatic/Semi Auto SWEP.Secondary.Ammo = "none" function SWEP:Precache() util.PrecacheSound("weapons/halberd/morrowind_halberd_deploy1.wav") util.PrecacheSound("weapons/halberd/morrowind_halberd_hitwall1.wav") util.PrecacheSound("weapons/halberd/morrowind_halberd_hit.wav") util.PrecacheSound("weapons/halberd/morrowind_halberd_slash.wav") end function SWEP:Initialize() self:SetWeaponHoldType("melee2") self.Hit = { Sound( "weapons/halberd/morrowind_halberd_hitwall1.wav" )} self.FleshHit = { Sound("weapons/halberd/morrowind_halberd_hit.wav") } end function SWEP:Deploy() self.Owner:EmitSound("weapons/halberd/morrowind_halberd_deploy1.wav") return true end function SWEP:PrimaryAttack() self:SetNextPrimaryFire(CurTime() + self.Primary.Delay) self:SetNextSecondaryFire(CurTime() + self.Primary.Delay) self.Owner:SetAnimation( PLAYER_ATTACK1 ) self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER ) timer.Simple(.35, function() if !self.Owner then return end local trace = self.Owner:GetEyeTrace() if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then if( trace.Entity:IsPlayer() or trace.Entity:IsNPC() or trace.Entity:GetClass()=="prop_ragdoll" ) then 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 = 1 bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector(0, 0, 0) bullet.Tracer = 0 bullet.Force = 1 bullet.Damage = 50 self.Owner:FireBullets(bullet) self.Owner:ViewPunch(Angle(7, 0, 0)) else self.Weapon:EmitSound("weapons/halberd/morrowind_halberd_slash.wav") end end) end function SWEP:Holster() if self:GetNextPrimaryFire() > CurTime() then return end return true end /*--------------------------------------------------------- Name: SWEP:SecondaryAttack() Desc: +attack2 has been pressed. ---------------------------------------------------------*/ function SWEP:SecondaryAttack() self.Weapon:EmitSound("weapons/halberd/morrowind_halberd_slash.wav") self.Weapon:SetNextPrimaryFire(CurTime() + 1) self.Weapon:SetNextSecondaryFire(CurTime() + 1) self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER) if (SERVER) then timer.Simple(.25, function() if !self.Owner then return end local knife = ents.Create("ent_mor_halberd") knife:SetAngles(self.Owner:EyeAngles()) local pos = self.Owner:GetShootPos() pos = pos + self.Owner:GetForward() * 5 pos = pos + self.Owner:GetRight() * 9 pos = pos + self.Owner:GetUp() * -5 knife:SetPos(pos) knife:SetOwner(self.Owner) knife.Weapon = self // Used to se the halberd's model and the weapon it gives when used. knife:Spawn() knife:Activate() self.Owner:SetAnimation(PLAYER_ATTACK1) local phys = knife:GetPhysicsObject() phys:SetVelocity(self.Owner:GetAimVector() * 1500) phys:AddAngleVelocity(Vector(0, 500, 0)) self:Remove() end) end end[/CODE]
I'm confused, what's the entity init thing for? [editline]4th March 2014[/editline] [QUOTE=Acecool;44130538]Or the creator started the trace just slightly forward of the player which may not be uncommon ( depending on who wrote it; they may have wanted the damage to be at the tip of the weapon and didn't consider that it could start through walls ). He did say he "put" melee weapons into the game-mode,[/QUOTE] Hmm, seems kind of silly considering how you can just check if the trace hit point is x units away from the trace origin without the "wall penetration" issue. And from the looks of it these are TSE weapons from workshop.
[lua]Swep.Primary.Damage = 0[/lua]
[QUOTE=MrPlonker;44133787][lua]Swep.Primary.Damage = 0[/lua][/QUOTE] First of all, it's SWEP. Second of all, that's irrelevant to the problem.
[QUOTE=DropDeadTed;44133106]I'm confused, what's the entity init thing for? [editline]4th March 2014[/editline] Hmm, seems kind of silly considering how you can just check if the trace hit point is x units away from the trace origin without the "wall penetration" issue. And from the looks of it these are TSE weapons from workshop.[/QUOTE] they are in deed thoughts weapons
Bump
It does seem to have the distance check in the code for primary attack; are you having issues with the primary or secondary attack?
Sorry, you need to Log In to post a reply to this thread.