I am working on a swep that will hopefully be used in a gamemode I am making. The swep is supposed to give the player a rabbit-head and horns. With the primary attack of the swep the player can cast ten small fireballs (or bullets, in the case of this wip) and with the secondary do a melee attack for a lot of damage.
First person view
SWEP.PrintName = "Horn" SWEP.Author = "DrVincentWolf" SWEP.Purpose = "Press M1 for fireball and M2 for charge" SWEP.Slot = 0 SWEP.SlotPos = 4 SWEP.Spawnable = true SWEP.Primary.Sound = Sound("Weapon_Deagle.Single") SWEP.Primary.Recoil = 50 SWEP.Primary.Damage = 1000 SWEP.Primary.NumShots = 1 SWEP.Primary.Cone = 0.02 SWEP.Primary.Delay = 0.5 SWEP.Primary.ClipSize = 10 // Size of a clip SWEP.Primary.DefaultClip = 10 // Default number of bullets in a clip SWEP.Primary.Automatic = false // Automatic/Semi Auto SWEP.Primary.Ammo = "pistol" 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 = "pistol" SWEP.Secondary.Recoil = 5 SWEP.Secondary.Damage = 1 SWEP.Secondary.NumShots = 1 SWEP.Secondary.Cone = 0.02 SWEP.Secondary.Delay = 0.5 SWEP.ShellEffect = "effect_mad_shell_pistol" // "effect_mad_shell_pistol" or "effect_mad_shell_rifle" or "effect_mad_shell_shotgun" SWEP.ShellDelay = 0.05 SWEP.Pistol = True SWEP.Rifle = false SWEP.Shotgun = false SWEP.Sniper = false
Now, I fully admit to being a lua noob and so I have used a lot of resources to put this together. Mainly:
My questions at present are:
1 How can I make the secondary attack only apply to melee range?
2 Currently my plan is to let the secondary attack recharge by prolonging the animation. Is this possible or is there a better way?
3 I want to change the way the swep is held in third person, how can I do that?
I will probably have more questions in the future but I want to get the ground-work down first.
Video for how the swep works now. Note that you don´t actually have to get closer for the second attack, I am just showing how I want it to work.Here is the full code, including the code from the swep constructor: http://pastebin.com/ZMZ76Mz5