Added forcepickup functions to weapons
+Added givetoactivator input so mappers can give weapons to a specific person. +Also added neverremove and ignorepickupcounters so that the weapons can be picked up (or forced) on multiple people.
This commit is contained in:
parent
69ec091490
commit
53e454fe1b
2 changed files with 48 additions and 8 deletions
|
@ -8,6 +8,9 @@ ENT.CleanupPriority = 1
|
|||
|
||||
function ENT:Initialize()
|
||||
self.m_Health = 200
|
||||
self.IgnorePickupCount = self.IgnorePickupCount or false
|
||||
self.Forced = self.Forced or false
|
||||
self.NeverRemove = self.NeverRemove or false
|
||||
|
||||
local weptab = weapons.GetStored(self:GetWeaponType())
|
||||
if weptab and not weptab.BoxPhysicsMax then
|
||||
|
@ -53,17 +56,21 @@ function ENT:GetShouldRemoveAmmo()
|
|||
end
|
||||
|
||||
function ENT:Use(activator, caller)
|
||||
if not activator:IsPlayer()
|
||||
self:GiveToActivator(activator, caller)
|
||||
end
|
||||
|
||||
function ENT:GiveToActivator(activator, caller)
|
||||
if not activator:IsPlayer()
|
||||
or not activator:Alive()
|
||||
or activator:Team() ~= TEAM_HUMAN
|
||||
or self.Removing
|
||||
or activator:KeyDown(GAMEMODE.UtilityKey)
|
||||
or (activator:KeyDown(GAMEMODE.UtilityKey) and not self.Forced)
|
||||
or self.NoPickupsTime and CurTime() < self.NoPickupsTime and self.NoPickupsOwner ~= activator then return end
|
||||
|
||||
local weptype = self:GetWeaponType()
|
||||
if not weptype then return end
|
||||
|
||||
if activator:HasWeapon(weptype) and not GAMEMODE.MaxWeaponPickups then
|
||||
if activator:HasWeapon(weptype) and (self.Forced or not GAMEMODE.MaxWeaponPickups) then
|
||||
local wep = activator:GetWeapon(weptype)
|
||||
if wep:IsValid() then
|
||||
local primary = wep:ValidPrimaryAmmo()
|
||||
|
@ -74,7 +81,7 @@ function ENT:Use(activator, caller)
|
|||
|
||||
local stored = weapons.GetStored(weptype)
|
||||
if stored and stored.AmmoIfHas then
|
||||
self:RemoveNextFrame()
|
||||
if not self.NeverRemove then self:RemoveNextFrame() end
|
||||
end
|
||||
|
||||
return
|
||||
|
@ -89,11 +96,11 @@ function ENT:Use(activator, caller)
|
|||
wep:SetClip2(self:GetClip2())
|
||||
end
|
||||
|
||||
if self.PlacedInMap then
|
||||
if self.PlacedInMap and not self.IgnorePickupCount then
|
||||
activator.WeaponPickups = (activator.WeaponPickups or 0) + 1
|
||||
end
|
||||
|
||||
self:RemoveNextFrame()
|
||||
if not self.NeverRemove then self:RemoveNextFrame() end
|
||||
end
|
||||
else
|
||||
activator:CenterNotify(COLOR_RED, translate.ClientGet(activator, "you_decide_to_leave_some"))
|
||||
|
@ -104,10 +111,28 @@ function ENT:KeyValue(key, value)
|
|||
key = string.lower(key)
|
||||
if key == "weapontype" then
|
||||
self:SetWeaponType(value)
|
||||
elseif key == "ignorepickupcount" then
|
||||
self.IgnorePickupCount = tonumber(value) == 1
|
||||
elseif key == "neverremove" then
|
||||
self.NeverRemove = tonumber(value) == 1
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:AcceptInput(name, activator, caller, arg)
|
||||
name = string.lower(name)
|
||||
if name == "givetoactivator" then
|
||||
self.Forced = true
|
||||
self:GiveToActivator(activator,caller)
|
||||
return true
|
||||
elseif name == "setneverremove" then
|
||||
self.NeverRemove = tonumber(arg) == 1
|
||||
elseif name == "setignorepickupcount" then
|
||||
self.IgnorePickupCount = tonumber(arg) == 1
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnTakeDamage(dmginfo)
|
||||
if self.NeverRemove then return end
|
||||
self:TakePhysicsDamage(dmginfo)
|
||||
|
||||
self.m_Health = self.m_Health - dmginfo:GetDamage()
|
||||
|
|
|
@ -478,7 +478,22 @@
|
|||
@PointClass studio("models/weapons/w_irifle.mdl") base(Targetname, Parentname, Angles) = prop_weapon : "ZS: Game Specific Weapon."
|
||||
[
|
||||
// Keys
|
||||
weapontype(string) : "weapon_type" : "weapon_zs_m4" : "Weapon type this entity becomes"
|
||||
weapontype(string) : "Weapon Type" : "weapon_zs_m4" : "Weapon type this entity becomes"
|
||||
neverremove(choices) : "Never Remove" : 0 : "Never remove when used or damage, for repeated uses." =
|
||||
[
|
||||
0 : "No"
|
||||
1 : "Yes"
|
||||
]
|
||||
ignorepickupcount(choices) : "Ignore Pickup Counter" : 0 : "Set to ignore a maxpickupcounter, if any." =
|
||||
[
|
||||
0 : "No"
|
||||
1 : "Yes"
|
||||
]
|
||||
|
||||
// Inputs
|
||||
input givetoactivator(void) : "Forces the weapon onto the activator."
|
||||
input setneverremove(integer) : "Set to make infinite uses."
|
||||
input setignorepickupcount(integer) : "Set to ignore any max pickup counter."
|
||||
]
|
||||
|
||||
@PointClass base(Targetname, Parentname) sphere( range ) = point_worldhint : "ZS: Allows you to create 3D hints and information tags."
|
||||
|
|
Loading…
Reference in a new issue