Merge pull request #107 from BClark09/master

Added Failed/Passed Outputs when picking up items
This commit is contained in:
William Moodhe / JetBoom 2015-01-12 19:53:49 -05:00
commit 5235f35271
3 changed files with 36 additions and 6 deletions

View file

@ -63,6 +63,7 @@ function ENT:GiveToActivator(activator, caller)
end end
if not hasweapon and not self.Forced then if not hasweapon and not self.Forced then
self:Input("OnPickupFailed", activator)
activator:CenterNotify(COLOR_RED, translate.ClientGet(activator, "nothing_for_this_ammo")) activator:CenterNotify(COLOR_RED, translate.ClientGet(activator, "nothing_for_this_ammo"))
return return
end end
@ -73,11 +74,14 @@ function ENT:GiveToActivator(activator, caller)
if self.PlacedInMap and not self.IgnorePickupCount then if self.PlacedInMap and not self.IgnorePickupCount then
activator.AmmoPickups = (activator.AmmoPickups or 0) + 1 activator.AmmoPickups = (activator.AmmoPickups or 0) + 1
end end
self:Input("OnPickupPassed", activator, caller)
if not self.NeverRemove then self:RemoveNextFrame() end if not self.NeverRemove then self:RemoveNextFrame() end
else else
self:Input("OnPickupFailed", activator)
activator:CenterNotify(COLOR_RED, translate.ClientGet(activator, "you_decide_to_leave_some")) activator:CenterNotify(COLOR_RED, translate.ClientGet(activator, "you_decide_to_leave_some"))
end end
else
self:Input("OnPickupFailed", activator)
end end
end end
@ -93,6 +97,8 @@ function ENT:KeyValue(key, value)
self.NeverRemove = tonumber(value) == 1 self.NeverRemove = tonumber(value) == 1
elseif key == "ignoreuse" then elseif key == "ignoreuse" then
self.IgnoreUse = tonumber(value) == 1 self.IgnoreUse = tonumber(value) == 1
elseif string.sub(key, 1, 2) == "on" then
self:AddOnOutput(key, value)
end end
end end
@ -113,6 +119,8 @@ function ENT:AcceptInput(name, activator, caller, arg)
return true return true
elseif name == "setammotype" then elseif name == "setammotype" then
self:SetAmmoType(arg) self:SetAmmoType(arg)
elseif string.sub(name, 1, 2) == "on" then
self:FireOutput(name, activator, caller, args)
end end
end end

View file

@ -68,10 +68,17 @@ function ENT:GiveToActivator(activator, caller)
or activator:Team() ~= TEAM_HUMAN or activator:Team() ~= TEAM_HUMAN
or self.Removing or self.Removing
or (activator:KeyDown(GAMEMODE.UtilityKey) and not self.Forced) or (activator:KeyDown(GAMEMODE.UtilityKey) and not self.Forced)
or self.NoPickupsTime and CurTime() < self.NoPickupsTime and self.NoPickupsOwner ~= activator then return end or self.NoPickupsTime and CurTime() < self.NoPickupsTime and self.NoPickupsOwner ~= activator then
self:Input("OnPickupFailed", activator)
return
end
local weptype = self:GetWeaponType() local weptype = self:GetWeaponType()
if not weptype then return end if not weptype then
self:Input("OnPickupFailed", activator)
return
end
if activator:HasWeapon(weptype) and (self.Forced or not GAMEMODE.MaxWeaponPickups) then if activator:HasWeapon(weptype) and (self.Forced or not GAMEMODE.MaxWeaponPickups) then
local wep = activator:GetWeapon(weptype) local wep = activator:GetWeapon(weptype)
@ -84,9 +91,9 @@ function ENT:GiveToActivator(activator, caller)
local stored = weapons.GetStored(weptype) local stored = weapons.GetStored(weptype)
if stored and stored.AmmoIfHas then if stored and stored.AmmoIfHas then
self:Input("OnPickupPassed", activator)
if not self.NeverRemove then self:RemoveNextFrame() end if not self.NeverRemove then self:RemoveNextFrame() end
end end
return return
end end
end end
@ -102,10 +109,13 @@ function ENT:GiveToActivator(activator, caller)
if self.PlacedInMap and not self.IgnorePickupCount then if self.PlacedInMap and not self.IgnorePickupCount then
activator.WeaponPickups = (activator.WeaponPickups or 0) + 1 activator.WeaponPickups = (activator.WeaponPickups or 0) + 1
end end
self:Input("OnPickupPassed", activator)
if not self.NeverRemove then self:RemoveNextFrame() end if not self.NeverRemove then self:RemoveNextFrame() end
else
self:Input("OnPickupFailed", activator)
end end
else else
self:Input("OnPickupFailed", activator)
activator:CenterNotify(COLOR_RED, translate.ClientGet(activator, "you_decide_to_leave_some")) activator:CenterNotify(COLOR_RED, translate.ClientGet(activator, "you_decide_to_leave_some"))
end end
end end
@ -122,6 +132,8 @@ function ENT:KeyValue(key, value)
self.IgnoreUse = tonumber(value) == 1 self.IgnoreUse = tonumber(value) == 1
elseif key == "empty" then elseif key == "empty" then
self.Empty = tonumber(value) == 1 self.Empty = tonumber(value) == 1
elseif string.sub(key, 1, 2) == "on" then
self:AddOnOutput(key, value)
end end
end end
@ -145,6 +157,8 @@ function ENT:AcceptInput(name, activator, caller, arg)
return true return true
elseif name == "setempty" then elseif name == "setempty" then
self.Empty = tonumber(arg) == 1 self.Empty = tonumber(arg) == 1
elseif string.sub(name, 1, 2) == "on" then
self:FireOutput(name, activator, caller, args)
end end
end end

View file

@ -495,6 +495,10 @@
input setignorepickupcount(integer) : "Set to ignore any max pickup counter." input setignorepickupcount(integer) : "Set to ignore any max pickup counter."
input setignoreuse(integer) : "Set to disable being able to pickup via use key" input setignoreuse(integer) : "Set to disable being able to pickup via use key"
input setammotype(string) : "Set to change the ammo type of this entity." input setammotype(string) : "Set to change the ammo type of this entity."
// Outputs
output OnPickupPassed(void) : "Called when the ammo is given to the player."
output OnPickupFailed(void) : "Called when the ammo is not given to the player"
] ]
@PointClass studio("models/weapons/w_irifle.mdl") base(Targetname, Parentname, Angles) = prop_weapon : "ZS: Game Specific Weapon." @PointClass studio("models/weapons/w_irifle.mdl") base(Targetname, Parentname, Angles) = prop_weapon : "ZS: Game Specific Weapon."
@ -529,6 +533,10 @@
input setignoreuse(integer) : "Set to disable being able to pickup via use key" input setignoreuse(integer) : "Set to disable being able to pickup via use key"
input setweapontype(string) : "Set to change the weapon type of this entity." input setweapontype(string) : "Set to change the weapon type of this entity."
input setempty(string) : "Set to empty the weapon of any default ammo." input setempty(string) : "Set to empty the weapon of any default ammo."
// Outputs
output OnPickupPassed(void) : "Called when the weapon is given to the player."
output OnPickupFailed(void) : "Called when the weapon is not given to the player"
] ]
@PointClass base(Targetname, Parentname) sphere( range ) = point_worldhint : "ZS: Allows you to create 3D hints and information tags." @PointClass base(Targetname, Parentname) sphere( range ) = point_worldhint : "ZS: Allows you to create 3D hints and information tags."
@ -759,7 +767,7 @@
"Ammo Type: SMG.\n"+ "Ammo Type: SMG.\n"+
"This is a stationary turret that is placed similarly to aegis boards. Once placed, they will seek zombies and fire when one crosses its laser sight, focusing on the head. However, turrets can be extremely vulnerable to zombies as its firing power isn't good enough to take down zombies on its own and doesn't have much health. " [] "This is a stationary turret that is placed similarly to aegis boards. Once placed, they will seek zombies and fire when one crosses its laser sight, focusing on the head. However, turrets can be extremely vulnerable to zombies as its firing power isn't good enough to take down zombies on its own and doesn't have much health. " []
@PointClass base(Weapon) studio("models/items/item_item_crate.mdl") = weapon_zs_acrate : @PointClass base(Weapon) studio("models/items/item_item_crate.mdl") = weapon_zs_arsenalcrate :
"The Arsenal Crate is a major part of the humans' survival. At wave break, this allows humans to purchase other weapons at 20% off. When a player purchases an item from this, the owner gets paid 10% commission price. Arsenal Crates can be destroyed by zombie attacks. " [] "The Arsenal Crate is a major part of the humans' survival. At wave break, this allows humans to purchase other weapons at 20% off. When a player purchases an item from this, the owner gets paid 10% commission price. Arsenal Crates can be destroyed by zombie attacks. " []
@PointClass base(Weapon) studio("models/props_combine/combine_mine01.mdl") = weapon_zs_messagebeacon : @PointClass base(Weapon) studio("models/props_combine/combine_mine01.mdl") = weapon_zs_messagebeacon :