I'm making a simple modification of the Master Sword weapon by turning down the range and damage it does. I found out how to change the damage, but can't seem to figure out how to change the range at which it attacks. Any help?
Either the weapon is firing a bullet without a tracer effect, or it's doing a distance check somewhere to see if it should apply damage. Look for something that says something along the lines of
[lua]if self.Owner:GetShootPos():Distance(trace.Entity:GetPos()) < 90 then[/lua]
Of course those are all arbitrary values, but you get what I mean. Anyways, in this case you'd just adjust that number value.
If the melee weapon is properly coded it's most likely executing a tracehull using [b][url=http://wiki.garrysmod.com/?title=Util.TraceHull]Util.TraceHull [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].
[QUOTE=Crazy Quebec;21325247]If the melee weapon is properly coded it's most likely executing a tracehull using [b][url=http://wiki.garrysmod.com/?title=Util.TraceHull]Util.TraceHull [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].[/QUOTE]
Yeah, but a lot of SWEPs aren't coded correctly.
[QUOTE=grea$emonkey;21324954]Either the weapon is firing a bullet without a tracer effect, or it's doing a distance check somewhere to see if it should apply damage. Look for something that says something along the lines of
[lua]if self.Owner:GetShootPos():Distance(trace.Entity:GetPos()) < 90 then[/lua]
Of course those are all arbitrary values, but you get what I mean. Anyways, in this case you'd just adjust that number value.[/QUOTE]
Didn't see anything like that. And it wasn't coded correctly, it shoots out 5 invisible bullets. After searching through the file some more I came upon this
[lua]trace.endpos = spos + (ang * 150)[/lua]
Is that it?
If not, than here is the code for the primary attack
[lua]function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire(CurTime() + 0.3)
if SERVER then self.Owner:EmitSound(Sound("npc/vort/claw_swing"..tostring(math.random(1,2))..".wav")) end
if SERVER then self.Owner:EmitSound(Sound("Zsword/oot-AdultLink_Sword"..tostring(math.random(1,3))..".wav")) end
local ang = self.Owner:GetAimVector()
local spos = self.Owner:GetShootPos()
local trace = {}
trace.start = spos
trace.endpos = spos + (ang * 150)
trace.filter = self.Owner
local tr = util.TraceLine(trace)
if tr.HitNonWorld then
local bullet = {}
bullet.Num=5
bullet.Src = self.Owner:GetShootPos()
bullet.Dir= self.Owner:GetAimVector()
bullet.Spread = Vector(0.2,0.2,0.2)
bullet.Tracer = 0
bullet.Force = 10
bullet.Damage = 10
self.Owner:FireBullets(bullet)
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
elseif tr.HitWorld then
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
elseif !tr.Hit then
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
if SERVER then
if self.Owner:Health() >= 1000 then
self.plasma = ents.Create("env_citadel_energy_core")
self.plasma:SetKeyValue("scale","2")
self.plasma:SetKeyValue("spawnflags","3")
self.plasma:SetKeyValue("globalname",self.Owner:Name().."rifleshot")
self.plasma:SetPos(self.Owner:GetShootPos())
self.plasma:SetAngles(self.Owner:GetAngles())
self.plasma:Spawn()
table.insert(self.plasmatable,self.plasma)
end
end
end
end
[/lua]
Any help?
Change that 150
[QUOTE=Disseminate;21335835]Change that 150[/QUOTE]
Ok, thanks.
Sorry, you need to Log In to post a reply to this thread.