Onis quebram o gatilho das armas.#853
Conversation
WalkthroughAdiciona restrições de disparo por espécie para armas Oni, introduz o estado de gatilho quebrado com feedback e reparo por solda, atualiza protótipos de armas e adiciona textos localizados para os novos estados. ChangesFluxo de restrição e reparo
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Atirador
participant SpeciesRestrictedTriggerSystem
participant Arma
participant WeaponTriggerBrokenSystem
participant Welder
Atirador->>SpeciesRestrictedTriggerSystem: tenta disparar arma restrita
SpeciesRestrictedTriggerSystem->>Arma: cancela disparo e adiciona gatilho quebrado
Arma->>WeaponTriggerBrokenSystem: recebe nova tentativa de disparo
WeaponTriggerBrokenSystem-->>Atirador: exibe falha e toca clique
Atirador->>WeaponTriggerBrokenSystem: usa solda na própria arma
WeaponTriggerBrokenSystem->>Welder: inicia do-after de reparo
Welder-->>WeaponTriggerBrokenSystem: conclui reparo
WeaponTriggerBrokenSystem->>Arma: remove gatilho quebrado
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml (1)
135-142: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winFalta a restrição para armas baseadas no
BaseMagazineSniper.Como o
BaseMagazineSniper(usado pelo rifle Hristov) herda deBaseIteme não deBaseWeaponSniper, ele não receberá a herança do componenteSpeciesRestrictedTrigger. Isso fará com que o rifle Hristov fique sem a restrição, permitindo que os Onis o disparem normalmente.Adicione o componente
SpeciesRestrictedTriggerneste protótipo também.🐛 Correção sugerida
description: A rooty tooty point and shooty. abstract: true components: + - type: SpeciesRestrictedTrigger + restrictedSpecies: + - Oni - type: Sprite layers:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml` around lines 135 - 142, Adicione o componente SpeciesRestrictedTrigger ao protótipo BaseWeaponSniperMagazine, junto aos componentes existentes, para que armas derivadas como o Hristov recebam a restrição de espécie mesmo sem herdar de BaseWeaponSniper.Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml (1)
241-247: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPossível falta de restrição para a pistola Echis.
Diferente das outras pistolas, a
WeaponPistolEchisherda deBaseItemem vez deBasePistol(ou de outra classe base de armas). Isso significa que ela não receberá a restriçãoSpeciesRestrictedTriggerpor herança e poderá ser disparada normalmente por Onis. Se essa arma não for exclusiva para uso integrado/ciborgues (ou seja, se Onis puderem equipá-la nas mãos e dispará-la), considere adicionar a restrição a este protótipo também, de forma semelhante ao que foi feito com a espingarda Bulldog.🐛 Correção sugerida
id: WeaponPistolEchis description: A cyborg-mounted weapon system based on the Viper platform. Creates ammunition on the fly from an internal fabricator, which slowly self-charges. # Goobstation components: + - type: SpeciesRestrictedTrigger + restrictedSpecies: + - Oni - type: Gun fireRate: 5🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml` around lines 241 - 247, Adicione a restrição SpeciesRestrictedTrigger ao protótipo WeaponPistolEchis, pois ele herda de BaseItem e não recebe essa proteção via BasePistol. Siga a configuração usada pela espingarda Bulldog e preserve o restante da definição da arma.
🧹 Nitpick comments (5)
Content.Shared/_Dumont/Weapons/Ranged/WeaponTriggerBrokenSystem.cs (3)
149-150: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valuePermita a predição da remoção do componente no cliente.
A condição
if (_net.IsServer)impede que o cliente remova o componente localmente após terminar o DoAfter. Isso força o cliente a aguardar a atualização do servidor, causando um pequeno lag mecânico onde o jogador recebe a confirmação do reparo, mas tentativas quase imediatas de disparo falham na predição.
Como o componente é umNetworkedComponent, removê-lo em código compartilhado é seguro e promove uma experiência mais responsiva, pois o motor gerenciará o rollback automaticamente se a predição estiver incorreta.💡 Sugestão de refatoração
- if (_net.IsServer) - RemCompDeferred<WeaponTriggerBrokenComponent>(ent.Owner); + RemCompDeferred<WeaponTriggerBrokenComponent>(ent.Owner);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Content.Shared/_Dumont/Weapons/Ranged/WeaponTriggerBrokenSystem.cs` around lines 149 - 150, Remova a condição `_net.IsServer` ao redor de `RemCompDeferred<WeaponTriggerBrokenComponent>(ent.Owner)` em `WeaponTriggerBrokenSystem`, permitindo que a remoção ocorra no código compartilhado e seja predita pelo cliente.
102-107: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConfie na abstração do
SharedToolSystempara validar a ferramenta.O
SharedToolSystem.UseTooljá verifica automaticamente se a ferramenta usada possui a qualidade exigida (WeldingQualities) e se está em um estado válido para uso (ativa/com combustível).
Verificar a presença doWelderComponentexplicitamente aqui quebra essa abstração, impedindo que outras ferramentas que também possuem a qualidadeWelding(como maçaricos de plasma ou variações customizadas) funcionem no reparo.💡 Sugestão de refatoração
- if (!TryComp<WelderComponent>(args.Used, out var welder)) - return; - - if (!welder.Enabled) - return; - var started = _toolSystem.UseTool(🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Content.Shared/_Dumont/Weapons/Ranged/WeaponTriggerBrokenSystem.cs` around lines 102 - 107, Remova as validações explícitas de WelderComponent e Enabled no fluxo que usa SharedToolSystem.UseTool. Deixe UseTool validar WeldingQualities e o estado operacional da ferramenta, preservando o reparo para qualquer ferramenta compatível com a qualidade Welding, incluindo variantes customizadas.
134-142: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemova a verificação redundante da ferramenta.
Se o evento DoAfter foi concluído com sucesso e não foi cancelado (
args.Cancelled), oSharedToolSystemjá assegurou que a ferramenta permaneceu válida e ativa durante todo o processo. Validar oWelderComponentnovamente aqui é desnecessário e sofre do mesmo problema de quebra de abstração mencionado acima.💡 Sugestão de refatoração
- if (args.Used is not { } used) - return; - - if (!TryComp<WelderComponent>(used, out var welder)) - return; - - if (!welder.Enabled) - return; - _popup.PopupClient(🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Content.Shared/_Dumont/Weapons/Ranged/WeaponTriggerBrokenSystem.cs` around lines 134 - 142, Remova, no tratamento de conclusão do DoAfter, as verificações de args.Used, TryComp<WelderComponent> e welder.Enabled. Após confirmar que o evento não foi cancelado, prossiga diretamente usando a garantia de validade e atividade fornecida pelo SharedToolSystem.Content.Shared/_Dumont/Weapons/Ranged/SpeciesRestrictedTriggerSystem.cs (1)
61-65: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winEvite mensagens duplicadas em eventos preditivos. Em todos estes trechos,
PopupClientestá sendo usado dentro de tratadores de eventos preditivos (comoShotAttemptedEvente DoAfters). Isso fará com que a mensagem apareça duas vezes para o cliente: uma gerada localmente durante a predição e outra recebida pela rede através da execução no servidor. Utilize o métodoPopupPredictedpara evitar essa duplicação visual.
Content.Shared/_Dumont/Weapons/Ranged/SpeciesRestrictedTriggerSystem.cs#L61-L65: substitua_popup.PopupClientpor_popup.PopupPredicted.Content.Shared/_Dumont/Weapons/Ranged/WeaponTriggerBrokenSystem.cs#L64-L68: substitua_popup.PopupClientpor_popup.PopupPredicted.Content.Shared/_Dumont/Weapons/Ranged/WeaponTriggerBrokenSystem.cs#L143-L147: substitua_popup.PopupClientpor_popup.PopupPredicted.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Content.Shared/_Dumont/Weapons/Ranged/SpeciesRestrictedTriggerSystem.cs` around lines 61 - 65, Substitua `_popup.PopupClient` por `_popup.PopupPredicted` nos três tratadores de eventos preditivos: `SpeciesRestrictedTriggerSystem.cs` nas linhas 61-65, e `WeaponTriggerBrokenSystem.cs` nas linhas 64-68 e 143-147. Preserve os mesmos textos, argumentos e tipo de popup.Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml (1)
294-297: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemova a declaração redundante do componente
SpeciesRestrictedTrigger.Várias armas e classes base herdam de protótipos que já definem o componente
SpeciesRestrictedTriggerconfigurado para a espécieOni(por exemplo, emBaseWeaponBattery,BaseGunWieldable, etc.). Redefinir o mesmo componente nas entidades filhas é redundante. A remoção simplifica o código e previne carga duplicada em mesclagens de protótipos.
Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml#L294-L297: remova o bloco, pois a propriedade é herdada deBaseWeaponBattery.Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml#L329-L332: remova o bloco, pois a propriedade é herdada deBaseWeaponPowerCell.Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml#L153-L156: remova o bloco, pois a propriedade é herdada deBaseWeaponLightMachineGun.Resources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml#L119-L122: remova o bloco, pois a propriedade é herdada deBaseWeaponCustomCell.Resources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml#L70-L73: remova o bloco, pois a propriedade é herdada deBaseGunWieldable.Resources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml#L183-L186: remova o bloco, pois a propriedade é herdada deBaseGunWieldable.Resources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/Snipers/snipers.yml#L66-L69: remova o bloco, pois a propriedade é herdada deBaseGunWieldable.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml` around lines 294 - 297, Remove the redundant SpeciesRestrictedTrigger blocks from the listed weapon prototypes, preserving the inherited Oni restriction: battery_guns.yml ranges 294-297 and 329-332, lmgs.yml 153-156, Goobstation battery_guns.yml 119-122, Goobstation shotguns.yml 70-73 and 183-186, and Goobstation snipers.yml 66-69. These entities inherit the component from BaseWeaponBattery, BaseWeaponPowerCell, BaseWeaponLightMachineGun, BaseWeaponCustomCell, or BaseGunWieldable, so no replacement component is needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Content.Shared/_Dumont/Weapons/Ranged/SpeciesRestrictedTriggerSystem.cs`:
- Around line 73-75: Atualize o fluxo em que
EnsureComp<WeaponTriggerBrokenComponent>(ent.Owner) adiciona o componente para
definir LastPopupTime com o tempo atual imediatamente após a criação,
preservando o cooldown da ação original e impedindo popup ou som imediato em
tentativas sucessivas de disparo.
In
`@Resources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/Ammunition/Magazines/smartgun.yml`:
- Around line 49-52: Remove the SpeciesRestrictedTrigger component from the
MagazineSmart prototype in this file, and add or preserve it on the smartgun
weapon prototype in the Guns/SMGs/smartgun.yml definition so the Oni restriction
is enforced when firing.
In `@Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml`:
- Around line 198-201: Corrija a indentação do componente
SpeciesRestrictedTrigger no bloco da entidade Dumont para alinhá-lo aos demais
itens da lista components, incluindo a indentação de restrictedSpecies e Oni
conforme a estrutura YAML existente. Preserve a hierarquia para que componentes
subsequentes, como BatterySelfRecharger, permaneçam fora da lista
restrictedSpecies.
---
Outside diff comments:
In `@Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml`:
- Around line 241-247: Adicione a restrição SpeciesRestrictedTrigger ao
protótipo WeaponPistolEchis, pois ele herda de BaseItem e não recebe essa
proteção via BasePistol. Siga a configuração usada pela espingarda Bulldog e
preserve o restante da definição da arma.
In `@Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml`:
- Around line 135-142: Adicione o componente SpeciesRestrictedTrigger ao
protótipo BaseWeaponSniperMagazine, junto aos componentes existentes, para que
armas derivadas como o Hristov recebam a restrição de espécie mesmo sem herdar
de BaseWeaponSniper.
---
Nitpick comments:
In `@Content.Shared/_Dumont/Weapons/Ranged/SpeciesRestrictedTriggerSystem.cs`:
- Around line 61-65: Substitua `_popup.PopupClient` por `_popup.PopupPredicted`
nos três tratadores de eventos preditivos: `SpeciesRestrictedTriggerSystem.cs`
nas linhas 61-65, e `WeaponTriggerBrokenSystem.cs` nas linhas 64-68 e 143-147.
Preserve os mesmos textos, argumentos e tipo de popup.
In `@Content.Shared/_Dumont/Weapons/Ranged/WeaponTriggerBrokenSystem.cs`:
- Around line 149-150: Remova a condição `_net.IsServer` ao redor de
`RemCompDeferred<WeaponTriggerBrokenComponent>(ent.Owner)` em
`WeaponTriggerBrokenSystem`, permitindo que a remoção ocorra no código
compartilhado e seja predita pelo cliente.
- Around line 102-107: Remova as validações explícitas de WelderComponent e
Enabled no fluxo que usa SharedToolSystem.UseTool. Deixe UseTool validar
WeldingQualities e o estado operacional da ferramenta, preservando o reparo para
qualquer ferramenta compatível com a qualidade Welding, incluindo variantes
customizadas.
- Around line 134-142: Remova, no tratamento de conclusão do DoAfter, as
verificações de args.Used, TryComp<WelderComponent> e welder.Enabled. Após
confirmar que o evento não foi cancelado, prossiga diretamente usando a garantia
de validade e atividade fornecida pelo SharedToolSystem.
In `@Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml`:
- Around line 294-297: Remove the redundant SpeciesRestrictedTrigger blocks from
the listed weapon prototypes, preserving the inherited Oni restriction:
battery_guns.yml ranges 294-297 and 329-332, lmgs.yml 153-156, Goobstation
battery_guns.yml 119-122, Goobstation shotguns.yml 70-73 and 183-186, and
Goobstation snipers.yml 66-69. These entities inherit the component from
BaseWeaponBattery, BaseWeaponPowerCell, BaseWeaponLightMachineGun,
BaseWeaponCustomCell, or BaseGunWieldable, so no replacement component is
needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ff386ae7-cad0-4852-9454-7eeb5e985122
⛔ Files ignored due to path filters (1)
Resources/Audio/_Dumont/Misc/tool_break.oggis excluded by!**/*.ogg
📒 Files selected for processing (26)
Content.Shared/_Dumont/Weapons/Ranged/SpeciesRestrictedTriggerComponent.csContent.Shared/_Dumont/Weapons/Ranged/SpeciesRestrictedTriggerSystem.csContent.Shared/_Dumont/Weapons/Ranged/WeaponTriggerBrokenComponent.csContent.Shared/_Dumont/Weapons/Ranged/WeaponTriggerBrokenSystem.csResources/Locale/en-US/weapons/ranged/trigger.ftlResources/Locale/pt-BR/weapons/ranged/trigger.ftlResources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_wieldable.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/HMGs/hmgs.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.ymlResources/Prototypes/Entities/Objects/Weapons/Guns/flare_gun.ymlResources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/Ammunition/Magazines/smartgun.ymlResources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/Battery/battery_guns.ymlResources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/SMGs/smartgun.ymlResources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/SMGs/smgs.ymlResources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/Shotguns/shotguns.ymlResources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/Snipers/snipers.ymlResources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/dart_gun.ymlResources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/syringe_gun.yml
💤 Files with no reviewable changes (2)
- Resources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/SMGs/smartgun.yml
- Resources/Prototypes/_Goobstation/Entities/Objects/Weapons/Guns/SMGs/smgs.yml
| /// to fire this weapon. | ||
| /// </summary> | ||
| [DataField, AutoNetworkedField] | ||
| public List<ProtoId<TagPrototype>> RestrictedSpecies = []; |
There was a problem hiding this comment.
considere utilizar ProtoId<SpeciesPrototype> invez de tags. exposto no componente HumanoidAppearence
| /// Minimum delay, in seconds, between repeated failure feedback. | ||
| /// </summary> | ||
| [DataField, AutoNetworkedField] | ||
| public float PopupCooldown = 1f; |
There was a problem hiding this comment.
utilize TimeSpan diretamente aqui pra deixar claro que essa unidade é em segundos
| public float PopupCooldown = 1f; | |
| public TimeSpan PopupCooldown = TimeSpan.FromSeconds(1); |
n se esqueça de atualizar no shared
| /// Time, in seconds, required to repair the trigger. | ||
| /// </summary> | ||
| [DataField] | ||
| public float RepairDuration = 5f; |
|
@isTheSuperN0va tá feito. |
|
Porra, agora é o Linter dando erro. |
Sobre a PR
Faz com que Onis quebrem o gatilho da grande maioria das armas ao tentar atirar, tornando-as unitilizáveis.
Usar um soldador irá consertar o gatilho das armas.
Por quê? / Balanceamento
Aceito ter errado em deixar onis utilizarem revólveres em adição às pistolas, então, além de remover a capacidade de usar quase todas as armas, resolvi substituir o sistema atual por um novo sistema de quebrar o gatilho das armas.
O sistema funciona por tags, então é possível limitar outras raças adicionando sua tag no componente nos prototypes das armas de fogo.
Detalhes Técnicos
YAML, Fluent e C#.
I LOVE SHITCODE!
Anexos
https://cdn.discordapp.com/attachments/1299917674700083211/1528831982182858945/MyServer_-_Dumont_Station_2026-07-20_15-22-12.mp4?ex=6a5fbb3c&is=6a5e69bc&hm=effc606f016e1fbf4ede8a6843f58f5ea954c0ab8d7ad8708807dc95db46255a&
Requerimentos
Changelog
🆑 SrKolobanov