2024-08-08 22:32:41 -07:00
using Content.Shared.Administration.Logs ;
using Content.Shared.Damage.Components ;
using Content.Shared.Database ;
using Content.Shared.Interaction ;
using Content.Shared.Inventory ;
using Content.Shared.Popups ;
Death Nettle changes (#25253)
* Added ThornyComponent, ThornyImmuneComponent, and ThornySystem, as well as changed Botanists glove's to have the ThornyImmuneComponent, and for Death Nettle to have the ThornyComponent.
* Added heat damage to the player if they pickup nettle without gloves. Also displays a popup message .
* Revised OnHandPickUp method and reduced whitespace
* Touching death nettle without gloves now does damage split between heat and caustic, and does more damage.
* File-scoped namespace adherence
* Code revisions, and removal of old file.
* Removed thornyImmune key from botanist's gloves in gloves.yml for cleanup / yaml linter
* Adds new generic DamageOnPickup, still very WIP
* Starting on localization, removed _Notes.txt, adds immunity component
* Added OnPickupDamageImmune component to botanists gloves
* Removed botany specific components/system, moved to generic DamageOnPickup. Added code comments. Extra checks in component for whether to toss an item, damage an entity. Still WIP.
* changes to audio and popups
* Removes my system/component/ftl in favor of DamageOnInteract, tweaking values
* me stupid
* Death nettle will 'wilt' after 5 hits
* added interaction delay to stop spam clicking, added a 10% stun (paralyze) chance
* minor changes/cleanup
* more minor changes and cleanup
* Reduced maximum amatoxin within fly amanita spores.
* Readjusted to allow more than 5 amatoxin above 50 potency
* Remove Debug.Log statement from system
* Mark Death Nettle as major contraband.
2025-03-29 05:35:16 -04:00
using Robust.Shared.Random ;
using Content.Shared.Throwing ;
2024-08-08 22:32:41 -07:00
using Robust.Shared.Audio.Systems ;
using Robust.Shared.Network ;
using Robust.Shared.Timing ;
Death Nettle changes (#25253)
* Added ThornyComponent, ThornyImmuneComponent, and ThornySystem, as well as changed Botanists glove's to have the ThornyImmuneComponent, and for Death Nettle to have the ThornyComponent.
* Added heat damage to the player if they pickup nettle without gloves. Also displays a popup message .
* Revised OnHandPickUp method and reduced whitespace
* Touching death nettle without gloves now does damage split between heat and caustic, and does more damage.
* File-scoped namespace adherence
* Code revisions, and removal of old file.
* Removed thornyImmune key from botanist's gloves in gloves.yml for cleanup / yaml linter
* Adds new generic DamageOnPickup, still very WIP
* Starting on localization, removed _Notes.txt, adds immunity component
* Added OnPickupDamageImmune component to botanists gloves
* Removed botany specific components/system, moved to generic DamageOnPickup. Added code comments. Extra checks in component for whether to toss an item, damage an entity. Still WIP.
* changes to audio and popups
* Removes my system/component/ftl in favor of DamageOnInteract, tweaking values
* me stupid
* Death nettle will 'wilt' after 5 hits
* added interaction delay to stop spam clicking, added a 10% stun (paralyze) chance
* minor changes/cleanup
* more minor changes and cleanup
* Reduced maximum amatoxin within fly amanita spores.
* Readjusted to allow more than 5 amatoxin above 50 potency
* Remove Debug.Log statement from system
* Mark Death Nettle as major contraband.
2025-03-29 05:35:16 -04:00
using Content.Shared.Random ;
using Content.Shared.Movement.Pulling.Components ;
using Content.Shared.Effects ;
using Content.Shared.Stunnable ;
2024-08-08 22:32:41 -07:00
namespace Content.Shared.Damage.Systems ;
public sealed class DamageOnInteractSystem : EntitySystem
{
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default ! ;
[Dependency] private readonly DamageableSystem _damageableSystem = default ! ;
[Dependency] private readonly SharedAudioSystem _audioSystem = default ! ;
[Dependency] private readonly SharedPopupSystem _popupSystem = default ! ;
[Dependency] private readonly InventorySystem _inventorySystem = default ! ;
Death Nettle changes (#25253)
* Added ThornyComponent, ThornyImmuneComponent, and ThornySystem, as well as changed Botanists glove's to have the ThornyImmuneComponent, and for Death Nettle to have the ThornyComponent.
* Added heat damage to the player if they pickup nettle without gloves. Also displays a popup message .
* Revised OnHandPickUp method and reduced whitespace
* Touching death nettle without gloves now does damage split between heat and caustic, and does more damage.
* File-scoped namespace adherence
* Code revisions, and removal of old file.
* Removed thornyImmune key from botanist's gloves in gloves.yml for cleanup / yaml linter
* Adds new generic DamageOnPickup, still very WIP
* Starting on localization, removed _Notes.txt, adds immunity component
* Added OnPickupDamageImmune component to botanists gloves
* Removed botany specific components/system, moved to generic DamageOnPickup. Added code comments. Extra checks in component for whether to toss an item, damage an entity. Still WIP.
* changes to audio and popups
* Removes my system/component/ftl in favor of DamageOnInteract, tweaking values
* me stupid
* Death nettle will 'wilt' after 5 hits
* added interaction delay to stop spam clicking, added a 10% stun (paralyze) chance
* minor changes/cleanup
* more minor changes and cleanup
* Reduced maximum amatoxin within fly amanita spores.
* Readjusted to allow more than 5 amatoxin above 50 potency
* Remove Debug.Log statement from system
* Mark Death Nettle as major contraband.
2025-03-29 05:35:16 -04:00
[Dependency] private readonly ThrowingSystem _throwingSystem = default ! ;
[Dependency] private readonly IRobustRandom _random = default ! ;
[Dependency] private readonly IGameTiming _gameTiming = default ! ;
[Dependency] private readonly SharedStunSystem _stun = default ! ;
2024-08-08 22:32:41 -07:00
public override void Initialize ( )
{
base . Initialize ( ) ;
SubscribeLocalEvent < DamageOnInteractComponent , InteractHandEvent > ( OnHandInteract ) ;
}
/// <summary>
/// Damages the user that interacts with the entity with an empty hand and
/// plays a sound or pops up text in response. If the user does not have
/// proper protection, the user will only be damaged and other interactions
/// will be cancelled.
/// </summary>
/// <param name="entity">The entity being interacted with</param>
/// <param name="args">Contains the user that interacted with the entity</param>
private void OnHandInteract ( Entity < DamageOnInteractComponent > entity , ref InteractHandEvent args )
{
Death Nettle changes (#25253)
* Added ThornyComponent, ThornyImmuneComponent, and ThornySystem, as well as changed Botanists glove's to have the ThornyImmuneComponent, and for Death Nettle to have the ThornyComponent.
* Added heat damage to the player if they pickup nettle without gloves. Also displays a popup message .
* Revised OnHandPickUp method and reduced whitespace
* Touching death nettle without gloves now does damage split between heat and caustic, and does more damage.
* File-scoped namespace adherence
* Code revisions, and removal of old file.
* Removed thornyImmune key from botanist's gloves in gloves.yml for cleanup / yaml linter
* Adds new generic DamageOnPickup, still very WIP
* Starting on localization, removed _Notes.txt, adds immunity component
* Added OnPickupDamageImmune component to botanists gloves
* Removed botany specific components/system, moved to generic DamageOnPickup. Added code comments. Extra checks in component for whether to toss an item, damage an entity. Still WIP.
* changes to audio and popups
* Removes my system/component/ftl in favor of DamageOnInteract, tweaking values
* me stupid
* Death nettle will 'wilt' after 5 hits
* added interaction delay to stop spam clicking, added a 10% stun (paralyze) chance
* minor changes/cleanup
* more minor changes and cleanup
* Reduced maximum amatoxin within fly amanita spores.
* Readjusted to allow more than 5 amatoxin above 50 potency
* Remove Debug.Log statement from system
* Mark Death Nettle as major contraband.
2025-03-29 05:35:16 -04:00
// Stop the interaction if the user attempts to interact with the object before the timer is finished
if ( _gameTiming . CurTime < entity . Comp . NextInteraction )
{
args . Handled = true ;
return ;
}
2024-08-08 22:32:41 -07:00
if ( ! entity . Comp . IsDamageActive )
return ;
var totalDamage = entity . Comp . Damage ;
if ( ! entity . Comp . IgnoreResistances )
{
// try to get damage on interact protection from either the inventory slots of the entity
_inventorySystem . TryGetInventoryEntity < DamageOnInteractProtectionComponent > ( args . User , out var protectiveEntity ) ;
// or checking the entity for the comp itself if the inventory didn't work
if ( protectiveEntity . Comp = = null & & TryComp < DamageOnInteractProtectionComponent > ( args . User , out var protectiveComp ) )
protectiveEntity = ( args . User , protectiveComp ) ;
Death Nettle changes (#25253)
* Added ThornyComponent, ThornyImmuneComponent, and ThornySystem, as well as changed Botanists glove's to have the ThornyImmuneComponent, and for Death Nettle to have the ThornyComponent.
* Added heat damage to the player if they pickup nettle without gloves. Also displays a popup message .
* Revised OnHandPickUp method and reduced whitespace
* Touching death nettle without gloves now does damage split between heat and caustic, and does more damage.
* File-scoped namespace adherence
* Code revisions, and removal of old file.
* Removed thornyImmune key from botanist's gloves in gloves.yml for cleanup / yaml linter
* Adds new generic DamageOnPickup, still very WIP
* Starting on localization, removed _Notes.txt, adds immunity component
* Added OnPickupDamageImmune component to botanists gloves
* Removed botany specific components/system, moved to generic DamageOnPickup. Added code comments. Extra checks in component for whether to toss an item, damage an entity. Still WIP.
* changes to audio and popups
* Removes my system/component/ftl in favor of DamageOnInteract, tweaking values
* me stupid
* Death nettle will 'wilt' after 5 hits
* added interaction delay to stop spam clicking, added a 10% stun (paralyze) chance
* minor changes/cleanup
* more minor changes and cleanup
* Reduced maximum amatoxin within fly amanita spores.
* Readjusted to allow more than 5 amatoxin above 50 potency
* Remove Debug.Log statement from system
* Mark Death Nettle as major contraband.
2025-03-29 05:35:16 -04:00
2024-08-08 22:32:41 -07:00
// if protectiveComp isn't null after all that, it means the user has protection,
// so let's calculate how much they resist
if ( protectiveEntity . Comp ! = null )
{
totalDamage = DamageSpecifier . ApplyModifierSet ( totalDamage , protectiveEntity . Comp . DamageProtection ) ;
}
}
Death Nettle changes (#25253)
* Added ThornyComponent, ThornyImmuneComponent, and ThornySystem, as well as changed Botanists glove's to have the ThornyImmuneComponent, and for Death Nettle to have the ThornyComponent.
* Added heat damage to the player if they pickup nettle without gloves. Also displays a popup message .
* Revised OnHandPickUp method and reduced whitespace
* Touching death nettle without gloves now does damage split between heat and caustic, and does more damage.
* File-scoped namespace adherence
* Code revisions, and removal of old file.
* Removed thornyImmune key from botanist's gloves in gloves.yml for cleanup / yaml linter
* Adds new generic DamageOnPickup, still very WIP
* Starting on localization, removed _Notes.txt, adds immunity component
* Added OnPickupDamageImmune component to botanists gloves
* Removed botany specific components/system, moved to generic DamageOnPickup. Added code comments. Extra checks in component for whether to toss an item, damage an entity. Still WIP.
* changes to audio and popups
* Removes my system/component/ftl in favor of DamageOnInteract, tweaking values
* me stupid
* Death nettle will 'wilt' after 5 hits
* added interaction delay to stop spam clicking, added a 10% stun (paralyze) chance
* minor changes/cleanup
* more minor changes and cleanup
* Reduced maximum amatoxin within fly amanita spores.
* Readjusted to allow more than 5 amatoxin above 50 potency
* Remove Debug.Log statement from system
* Mark Death Nettle as major contraband.
2025-03-29 05:35:16 -04:00
totalDamage = _damageableSystem . TryChangeDamage ( args . User , totalDamage , origin : args . Target ) ;
2024-08-08 22:32:41 -07:00
if ( totalDamage ! = null & & totalDamage . AnyPositive ( ) )
{
Death Nettle changes (#25253)
* Added ThornyComponent, ThornyImmuneComponent, and ThornySystem, as well as changed Botanists glove's to have the ThornyImmuneComponent, and for Death Nettle to have the ThornyComponent.
* Added heat damage to the player if they pickup nettle without gloves. Also displays a popup message .
* Revised OnHandPickUp method and reduced whitespace
* Touching death nettle without gloves now does damage split between heat and caustic, and does more damage.
* File-scoped namespace adherence
* Code revisions, and removal of old file.
* Removed thornyImmune key from botanist's gloves in gloves.yml for cleanup / yaml linter
* Adds new generic DamageOnPickup, still very WIP
* Starting on localization, removed _Notes.txt, adds immunity component
* Added OnPickupDamageImmune component to botanists gloves
* Removed botany specific components/system, moved to generic DamageOnPickup. Added code comments. Extra checks in component for whether to toss an item, damage an entity. Still WIP.
* changes to audio and popups
* Removes my system/component/ftl in favor of DamageOnInteract, tweaking values
* me stupid
* Death nettle will 'wilt' after 5 hits
* added interaction delay to stop spam clicking, added a 10% stun (paralyze) chance
* minor changes/cleanup
* more minor changes and cleanup
* Reduced maximum amatoxin within fly amanita spores.
* Readjusted to allow more than 5 amatoxin above 50 potency
* Remove Debug.Log statement from system
* Mark Death Nettle as major contraband.
2025-03-29 05:35:16 -04:00
// Record this interaction and determine when a user is allowed to interact with this entity again
entity . Comp . LastInteraction = _gameTiming . CurTime ;
entity . Comp . NextInteraction = _gameTiming . CurTime + TimeSpan . FromSeconds ( entity . Comp . InteractTimer ) ;
2024-08-08 22:32:41 -07:00
args . Handled = true ;
_adminLogger . Add ( LogType . Damaged , $"{ToPrettyString(args.User):user} injured their hand by interacting with {ToPrettyString(args.Target):target} and received {totalDamage.GetTotal():damage} damage" ) ;
_audioSystem . PlayPredicted ( entity . Comp . InteractSound , args . Target , args . User ) ;
if ( entity . Comp . PopupText ! = null )
_popupSystem . PopupClient ( Loc . GetString ( entity . Comp . PopupText ) , args . User , args . User ) ;
Death Nettle changes (#25253)
* Added ThornyComponent, ThornyImmuneComponent, and ThornySystem, as well as changed Botanists glove's to have the ThornyImmuneComponent, and for Death Nettle to have the ThornyComponent.
* Added heat damage to the player if they pickup nettle without gloves. Also displays a popup message .
* Revised OnHandPickUp method and reduced whitespace
* Touching death nettle without gloves now does damage split between heat and caustic, and does more damage.
* File-scoped namespace adherence
* Code revisions, and removal of old file.
* Removed thornyImmune key from botanist's gloves in gloves.yml for cleanup / yaml linter
* Adds new generic DamageOnPickup, still very WIP
* Starting on localization, removed _Notes.txt, adds immunity component
* Added OnPickupDamageImmune component to botanists gloves
* Removed botany specific components/system, moved to generic DamageOnPickup. Added code comments. Extra checks in component for whether to toss an item, damage an entity. Still WIP.
* changes to audio and popups
* Removes my system/component/ftl in favor of DamageOnInteract, tweaking values
* me stupid
* Death nettle will 'wilt' after 5 hits
* added interaction delay to stop spam clicking, added a 10% stun (paralyze) chance
* minor changes/cleanup
* more minor changes and cleanup
* Reduced maximum amatoxin within fly amanita spores.
* Readjusted to allow more than 5 amatoxin above 50 potency
* Remove Debug.Log statement from system
* Mark Death Nettle as major contraband.
2025-03-29 05:35:16 -04:00
// Attempt to paralyze the user after they have taken damage
if ( _random . Prob ( entity . Comp . StunChance ) )
2025-07-21 10:22:11 -07:00
_stun . TryUpdateParalyzeDuration ( args . User , TimeSpan . FromSeconds ( entity . Comp . StunSeconds ) ) ;
2024-08-08 22:32:41 -07:00
}
Death Nettle changes (#25253)
* Added ThornyComponent, ThornyImmuneComponent, and ThornySystem, as well as changed Botanists glove's to have the ThornyImmuneComponent, and for Death Nettle to have the ThornyComponent.
* Added heat damage to the player if they pickup nettle without gloves. Also displays a popup message .
* Revised OnHandPickUp method and reduced whitespace
* Touching death nettle without gloves now does damage split between heat and caustic, and does more damage.
* File-scoped namespace adherence
* Code revisions, and removal of old file.
* Removed thornyImmune key from botanist's gloves in gloves.yml for cleanup / yaml linter
* Adds new generic DamageOnPickup, still very WIP
* Starting on localization, removed _Notes.txt, adds immunity component
* Added OnPickupDamageImmune component to botanists gloves
* Removed botany specific components/system, moved to generic DamageOnPickup. Added code comments. Extra checks in component for whether to toss an item, damage an entity. Still WIP.
* changes to audio and popups
* Removes my system/component/ftl in favor of DamageOnInteract, tweaking values
* me stupid
* Death nettle will 'wilt' after 5 hits
* added interaction delay to stop spam clicking, added a 10% stun (paralyze) chance
* minor changes/cleanup
* more minor changes and cleanup
* Reduced maximum amatoxin within fly amanita spores.
* Readjusted to allow more than 5 amatoxin above 50 potency
* Remove Debug.Log statement from system
* Mark Death Nettle as major contraband.
2025-03-29 05:35:16 -04:00
// Check if the entity's Throw bool is false, or if the entity has the PullableComponent, then if the entity is currently being pulled.
// BeingPulled must be checked because the entity will be spastically thrown around without this.
if ( ! entity . Comp . Throw | | ! TryComp < PullableComponent > ( entity , out var pullComp ) | | pullComp . BeingPulled )
return ;
_throwingSystem . TryThrow ( entity , _random . NextVector2 ( ) , entity . Comp . ThrowSpeed , doSpin : true ) ;
2024-08-08 22:32:41 -07:00
}
public void SetIsDamageActiveTo ( Entity < DamageOnInteractComponent > entity , bool mode )
{
if ( entity . Comp . IsDamageActive = = mode )
return ;
entity . Comp . IsDamageActive = mode ;
Dirty ( entity ) ;
}
}