From 0274826e3256d8a2093a07aa93faba6a1a9a70e7 Mon Sep 17 00:00:00 2001 From: Ed <96445749+TheShuEd@users.noreply.github.com> Date: Sun, 18 May 2025 00:37:04 +0300 Subject: [PATCH] Species free innate skill (#1277) * innate free job skills * returns species magic buff + unlock all skill * Update tiefling.yml * fix --- .../Systems/Skill/CP14SkillUIController.cs | 23 ++++++---- .../Systems/Skill/Window/CP14SkillWindow.xaml | 3 ++ .../Preferences/Loadouts/LoadoutPrototype.cs | 8 +--- .../Station/SharedStationSpawningSystem.cs | 7 +-- .../_CP14/Skill/CP14LearnSkillsSpecial.cs | 2 +- .../_CP14/Skill/CP14SharedSkillSystem.cs | 44 +++++++++++++++++-- .../Components/CP14SkillStorageComponent.cs | 7 +++ Resources/Locale/en-US/_CP14/skill/ui.ftl | 1 + Resources/Locale/ru-RU/_CP14/skill/ui.ftl | 1 + .../_CP14/Entities/Mobs/Species/elf.yml | 4 ++ .../_CP14/Entities/Mobs/Species/silva.yml | 4 ++ .../_CP14/Entities/Mobs/Species/tiefling.yml | 12 ++--- .../Prototypes/_CP14/Loadouts/Jobs/guard.yml | 14 ------ .../_CP14/Loadouts/Jobs/guildmaster.yml | 25 +---------- .../_CP14/Loadouts/role_loadouts.yml | 3 -- .../Prototypes/_CP14/Skill/blacksmithing.yml | 37 ++++++++-------- .../Prototypes/_CP14/Skill/hydrosophistry.yml | 37 ++++++++-------- .../Prototypes/_CP14/Skill/martial_arts.yml | 14 ++---- .../Prototypes/_CP14/Skill/thaumaturgy.yml | 6 +-- 19 files changed, 127 insertions(+), 125 deletions(-) diff --git a/Content.Client/_CP14/UserInterface/Systems/Skill/CP14SkillUIController.cs b/Content.Client/_CP14/UserInterface/Systems/Skill/CP14SkillUIController.cs index ce9bac4656..28f90a4d2f 100644 --- a/Content.Client/_CP14/UserInterface/Systems/Skill/CP14SkillUIController.cs +++ b/Content.Client/_CP14/UserInterface/Systems/Skill/CP14SkillUIController.cs @@ -136,7 +136,7 @@ public sealed class CP14SkillUIController : UIController, IOnStateEntered + + + diff --git a/Content.Shared/Preferences/Loadouts/LoadoutPrototype.cs b/Content.Shared/Preferences/Loadouts/LoadoutPrototype.cs index 9379fd176e..9961a2b911 100644 --- a/Content.Shared/Preferences/Loadouts/LoadoutPrototype.cs +++ b/Content.Shared/Preferences/Loadouts/LoadoutPrototype.cs @@ -48,13 +48,7 @@ public sealed partial class LoadoutPrototype : IPrototype, IEquipmentLoadout public Dictionary> Storage { get; set; } = new(); /// - /// CP14 - it is possible to give action spells or spells to players who have taken this loadout - /// - [DataField] - public List Actions { get; set; } = new(); - - /// - /// CP14 - it is possible to give skill trees to players who have taken this loadout + /// CP14 - it is possible to give free skills to players /// [DataField] public HashSet> Skills = new(); diff --git a/Content.Shared/Station/SharedStationSpawningSystem.cs b/Content.Shared/Station/SharedStationSpawningSystem.cs index 133416a589..e4bf5802a5 100644 --- a/Content.Shared/Station/SharedStationSpawningSystem.cs +++ b/Content.Shared/Station/SharedStationSpawningSystem.cs @@ -97,14 +97,9 @@ public abstract class SharedStationSpawningSystem : EntitySystem private void CP14EquipStartingActions(EntityUid entity, LoadoutPrototype loadout) { - foreach (var action in loadout.Actions) - { - _action.AddAction(entity, action); - } - foreach (var skill in loadout.Skills) { - _skill.TryAddSkill(entity, skill); + _skill.TryAddSkill(entity, skill, free: true); } } diff --git a/Content.Shared/_CP14/Skill/CP14LearnSkillsSpecial.cs b/Content.Shared/_CP14/Skill/CP14LearnSkillsSpecial.cs index 43d938ea4a..42ebf9121e 100644 --- a/Content.Shared/_CP14/Skill/CP14LearnSkillsSpecial.cs +++ b/Content.Shared/_CP14/Skill/CP14LearnSkillsSpecial.cs @@ -16,7 +16,7 @@ public sealed partial class CP14LearnSkillsSpecial : JobSpecial foreach (var skill in Skills) { - skillSys.TryAddSkill(mob, skill); + skillSys.TryAddSkill(mob, skill, free: true); } } } diff --git a/Content.Shared/_CP14/Skill/CP14SharedSkillSystem.cs b/Content.Shared/_CP14/Skill/CP14SharedSkillSystem.cs index 96d7a78130..cbe8cb04d9 100644 --- a/Content.Shared/_CP14/Skill/CP14SharedSkillSystem.cs +++ b/Content.Shared/_CP14/Skill/CP14SharedSkillSystem.cs @@ -17,16 +17,40 @@ public abstract partial class CP14SharedSkillSystem : EntitySystem _skillStorageQuery = GetEntityQuery(); + SubscribeLocalEvent(OnMapInit); + InitializeAdmin(); InitializeChecks(); } + private void OnMapInit(Entity ent, ref MapInitEvent args) + { + //If at initialization we have any skill records, we automatically give them to this entity + + var free = ent.Comp.FreeLearnedSkills.ToList(); + var learned = ent.Comp.LearnedSkills.ToList(); + + ent.Comp.FreeLearnedSkills.Clear(); + ent.Comp.LearnedSkills.Clear(); + + foreach (var skill in free) + { + TryAddSkill(ent.Owner, skill, ent.Comp, true); + } + + foreach (var skill in learned) + { + TryAddSkill(ent.Owner, skill, ent.Comp); + } + } + /// /// Directly adds the skill to the player, bypassing any checks. /// public bool TryAddSkill(EntityUid target, ProtoId skill, - CP14SkillStorageComponent? component = null) + CP14SkillStorageComponent? component = null, + bool free = false) { if (!Resolve(target, ref component, false)) return false; @@ -42,7 +66,10 @@ public abstract partial class CP14SharedSkillSystem : EntitySystem effect.AddSkill(EntityManager, target); } - component.SkillsSumExperience += indexedSkill.LearnCost; + if (free) + component.FreeLearnedSkills.Add(skill); + else + component.SkillsSumExperience += indexedSkill.LearnCost; component.LearnedSkills.Add(skill); Dirty(target, component); @@ -74,7 +101,8 @@ public abstract partial class CP14SharedSkillSystem : EntitySystem effect.RemoveSkill(EntityManager, target); } - component.SkillsSumExperience -= indexedSkill.LearnCost; + if (!component.FreeLearnedSkills.Remove(skill)) + component.SkillsSumExperience -= indexedSkill.LearnCost; Dirty(target, component); return true; @@ -93,6 +121,16 @@ public abstract partial class CP14SharedSkillSystem : EntitySystem return component.LearnedSkills.Contains(skill); } + public bool HaveFreeSkill(EntityUid target, + ProtoId skill, + CP14SkillStorageComponent? component = null) + { + if (!Resolve(target, ref component, false)) + return false; + + return component.FreeLearnedSkills.Contains(skill); + } + /// /// Checks if the player can learn the specified skill. /// diff --git a/Content.Shared/_CP14/Skill/Components/CP14SkillStorageComponent.cs b/Content.Shared/_CP14/Skill/Components/CP14SkillStorageComponent.cs index 84386b4a98..bfb11e4776 100644 --- a/Content.Shared/_CP14/Skill/Components/CP14SkillStorageComponent.cs +++ b/Content.Shared/_CP14/Skill/Components/CP14SkillStorageComponent.cs @@ -14,6 +14,13 @@ namespace Content.Shared._CP14.Skill.Components; [Access(typeof(CP14SharedSkillSystem), typeof(CP14SharedResearchSystem))] public sealed partial class CP14SkillStorageComponent : Component { + /// + /// Tracks skills that are learned without spending memory points. + /// the skills that are here are DUBLED in the LearnedSkills, + /// + [DataField, AutoNetworkedField] + public List> FreeLearnedSkills = new(); + [DataField, AutoNetworkedField] public List> LearnedSkills = new(); diff --git a/Resources/Locale/en-US/_CP14/skill/ui.ftl b/Resources/Locale/en-US/_CP14/skill/ui.ftl index 5f2567a3c3..c7a86baaa5 100644 --- a/Resources/Locale/en-US/_CP14/skill/ui.ftl +++ b/Resources/Locale/en-US/_CP14/skill/ui.ftl @@ -7,6 +7,7 @@ cp14-game-hud-open-skill-menu-button-tooltip = Skill tree cp14-skill-menu-learn-button = Learn skill cp14-skill-menu-learncost = [color=yellow]Memory required:[/color] cp14-skill-menu-level = Memory: +cp14-skill-menu-free = [color=green]This skill is innate to your character, and wastes no memory points![/color] cp14-research-table-title = Research table cp14-research-recipe-list = Research costs: diff --git a/Resources/Locale/ru-RU/_CP14/skill/ui.ftl b/Resources/Locale/ru-RU/_CP14/skill/ui.ftl index d5c7ee9158..10933366e6 100644 --- a/Resources/Locale/ru-RU/_CP14/skill/ui.ftl +++ b/Resources/Locale/ru-RU/_CP14/skill/ui.ftl @@ -7,6 +7,7 @@ cp14-game-hud-open-skill-menu-button-tooltip = Деревья навыков cp14-skill-menu-learn-button = Изучить навык cp14-skill-menu-learncost = [color=yellow]Требуется памяти:[/color] cp14-skill-menu-level = Память: +cp14-skill-menu-free = [color=green]Этот навык врожденный для вашего персонажа, и не тратит очков памяти![/color] cp14-research-table-title = Стол исследований cp14-research-recipe-list = Затраты на исследование: diff --git a/Resources/Prototypes/_CP14/Entities/Mobs/Species/elf.yml b/Resources/Prototypes/_CP14/Entities/Mobs/Species/elf.yml index 697b10b425..6ee2421b09 100644 --- a/Resources/Prototypes/_CP14/Entities/Mobs/Species/elf.yml +++ b/Resources/Prototypes/_CP14/Entities/Mobs/Species/elf.yml @@ -41,6 +41,10 @@ - type: CP14MagicEnergyDraw #Half of standard mana regeneration energy: 0.5 delay: 3 + - type: CP14SkillStorage #Innate metamagic + freeLearnedSkills: + - MetamagicT1 + - MetamagicT2 - type: Inventory templateId: CP14Human displacements: diff --git a/Resources/Prototypes/_CP14/Entities/Mobs/Species/silva.yml b/Resources/Prototypes/_CP14/Entities/Mobs/Species/silva.yml index d0af01551e..1884f803f1 100644 --- a/Resources/Prototypes/_CP14/Entities/Mobs/Species/silva.yml +++ b/Resources/Prototypes/_CP14/Entities/Mobs/Species/silva.yml @@ -73,6 +73,10 @@ spawned: - id: CP14FoodMeatHuman # Replace it with silva meat, heh. amount: 5 + - type: CP14SkillStorage #Innate vivification + freeLearnedSkills: + - HealingT1 + - HealingT2 - type: CP14MagicEnergyPhotosynthesis # Silva special feature #Disabled until sunlight fixed - type: CP14MagicEnergyDraw #Enabled default mana regen until sunlight fixed enable: false diff --git a/Resources/Prototypes/_CP14/Entities/Mobs/Species/tiefling.yml b/Resources/Prototypes/_CP14/Entities/Mobs/Species/tiefling.yml index c7246c5f3d..6761754113 100644 --- a/Resources/Prototypes/_CP14/Entities/Mobs/Species/tiefling.yml +++ b/Resources/Prototypes/_CP14/Entities/Mobs/Species/tiefling.yml @@ -44,14 +44,10 @@ damage: Heat: 1 #Magic regen from fire Cold: -1 - - type: CP14MagicManacostModify - globalModifier: 1.2 - modifiers: - Fire: 0.5 - - type: CP14SpellStorage - #grantAccessToSelf: true - #spells: - #- CP14ActionSpellTieflingInnerFire + - type: CP14SkillStorage #Innate pyrokinetic + freeLearnedSkills: + - PyrokineticT1 + - PyrokineticT2 - type: Inventory templateId: CP14Human femaleDisplacements: diff --git a/Resources/Prototypes/_CP14/Loadouts/Jobs/guard.yml b/Resources/Prototypes/_CP14/Loadouts/Jobs/guard.yml index fc5ff15d00..b0e923c212 100644 --- a/Resources/Prototypes/_CP14/Loadouts/Jobs/guard.yml +++ b/Resources/Prototypes/_CP14/Loadouts/Jobs/guard.yml @@ -58,17 +58,3 @@ id: CP14ClothingShirtGuardsChainmailShirtB equipment: shirt: CP14ClothingShirtGuardsChainmailShirtB - -# Spells - -- type: loadoutGroup - id: CP14GuardSpells - name: cp14-loadout-guard-spells - loadouts: - - CP14ActionSpellFlashLight - -- type: loadout - id: CP14ActionSpellFlashLight - dummyEntity: CP14ActionSpellFlashLight - actions: - - CP14ActionSpellFlashLight diff --git a/Resources/Prototypes/_CP14/Loadouts/Jobs/guildmaster.yml b/Resources/Prototypes/_CP14/Loadouts/Jobs/guildmaster.yml index acfda2164d..6bf2af2009 100644 --- a/Resources/Prototypes/_CP14/Loadouts/Jobs/guildmaster.yml +++ b/Resources/Prototypes/_CP14/Loadouts/Jobs/guildmaster.yml @@ -66,27 +66,4 @@ id: CP14GuildmasterShoes name: cp14-loadout-guildmaster-shoes loadouts: - - CP14ShoesAristocraticBlack - -# Spells - -- type: loadoutGroup - id: CP14GuildmasterSpells - name: cp14-loadout-guildmaster-spells - minLimit: 2 - maxLimit: 2 - loadouts: - - CP14ActionSpellDemiplaneInfiltration - - CP14ActionSpellMonolithWarp - -- type: loadout - id: CP14ActionSpellDemiplaneInfiltration - dummyEntity: CP14ActionSpellDemiplaneInfiltration - actions: - - CP14ActionSpellDemiplaneInfiltration - -- type: loadout - id: CP14ActionSpellMonolithWarp - dummyEntity: CP14ActionSpellMonolithWarp - actions: - - CP14ActionSpellMonolithWarp + - CP14ShoesAristocraticBlack \ No newline at end of file diff --git a/Resources/Prototypes/_CP14/Loadouts/role_loadouts.yml b/Resources/Prototypes/_CP14/Loadouts/role_loadouts.yml index a6f8a9a9e4..1c80592644 100644 --- a/Resources/Prototypes/_CP14/Loadouts/role_loadouts.yml +++ b/Resources/Prototypes/_CP14/Loadouts/role_loadouts.yml @@ -85,7 +85,6 @@ - CP14GeneralShoes - CP14GeneralBack - CP14GeneralTrinkets - - CP14GuardSpells - type: roleLoadout id: JobCP14Guard @@ -100,7 +99,6 @@ - CP14GeneralShoes - CP14GeneralBack - CP14GeneralTrinkets - - CP14GuardSpells - type: roleLoadout id: JobCP14Commandant @@ -125,7 +123,6 @@ - CP14GuildmasterShoes - CP14GeneralBack - CP14GeneralTrinkets - - CP14GuildmasterSpells - type: roleLoadout id: JobCP14Merchant diff --git a/Resources/Prototypes/_CP14/Skill/blacksmithing.yml b/Resources/Prototypes/_CP14/Skill/blacksmithing.yml index 2bc3ae6cd6..5e77661099 100644 --- a/Resources/Prototypes/_CP14/Skill/blacksmithing.yml +++ b/Resources/Prototypes/_CP14/Skill/blacksmithing.yml @@ -1,69 +1,68 @@ - type: cp14Skill id: CopperMelting - skillUiPosition: 0, 0 + skillUiPosition: 1, 0 tree: Blacksmithing name: cp14-skill-copper-melt-name - learnCost: 0 + learnCost: 0.5 icon: sprite: _CP14/Objects/Materials/copper_ore.rsi state: ore3 - restrictions: - - !type:Impossible effects: - !type:UnlockRecipes - type: cp14Skill id: IronMelting - skillUiPosition: 0, 2 + skillUiPosition: 1, 2 tree: Blacksmithing name: cp14-skill-iron-melt-name - learnCost: 0 + learnCost: 0.5 icon: sprite: _CP14/Objects/Materials/iron_ore.rsi state: ore3 - restrictions: - - !type:Impossible effects: - !type:UnlockRecipes + restrictions: + - !type:NeedPrerequisite + prerequisite: CopperMelting - type: cp14Skill id: GoldMelting skillUiPosition: 0, 4 tree: Blacksmithing name: cp14-skill-gold-melt-name - learnCost: 0 + learnCost: 0.5 icon: sprite: _CP14/Objects/Materials/gold_ore.rsi state: ore3 - restrictions: - - !type:Impossible effects: - !type:UnlockRecipes + restrictions: + - !type:NeedPrerequisite + prerequisite: IronMelting - type: cp14Skill id: MithrilMelting - skillUiPosition: 0, 6 + skillUiPosition: 2, 4 tree: Blacksmithing name: cp14-skill-mithril-melt-name - learnCost: 0 + learnCost: 0.5 icon: sprite: _CP14/Objects/Materials/mithril_ore.rsi state: ore3 - restrictions: - - !type:Impossible effects: - !type:UnlockRecipes + restrictions: + - !type:NeedPrerequisite + prerequisite: IronMelting - type: cp14Skill id: GlassMelting - skillUiPosition: 2, 0 + skillUiPosition: 3, 0 tree: Blacksmithing name: cp14-skill-glass-melt-name - learnCost: 0 + learnCost: 0.5 icon: sprite: _CP14/Objects/Materials/glass.rsi state: glass_3 - restrictions: - - !type:Impossible effects: - !type:UnlockRecipes \ No newline at end of file diff --git a/Resources/Prototypes/_CP14/Skill/hydrosophistry.yml b/Resources/Prototypes/_CP14/Skill/hydrosophistry.yml index 279e60ed87..47d27f9009 100644 --- a/Resources/Prototypes/_CP14/Skill/hydrosophistry.yml +++ b/Resources/Prototypes/_CP14/Skill/hydrosophistry.yml @@ -12,7 +12,7 @@ - type: cp14Skill id: CP14ActionSpellWaterCreation - skillUiPosition: 0, 4 + skillUiPosition: 1, 4 tree: Hydrosophistry icon: sprite: _CP14/Actions/Spells/water.rsi @@ -26,8 +26,9 @@ - type: cp14Skill id: CP14ActionSpellBeerCreation - skillUiPosition: 2, 4 + skillUiPosition: 1, 8 tree: Hydrosophistry + learnCost: 0 icon: sprite: _CP14/Actions/Spells/water.rsi state: beer_creation @@ -36,24 +37,10 @@ action: CP14ActionSpellBeerCreation restrictions: - !type:NeedPrerequisite - prerequisite: HydrosophistryT1 + prerequisite: CP14ActionSpellWaterCreation - !type:SpeciesWhitelist species: CP14Dwarf -- type: cp14Skill - id: CP14ActionSpellIceShards - skillUiPosition: 2, 6 - tree: Hydrosophistry - icon: - sprite: _CP14/Actions/Spells/water.rsi - state: ice_shards - effects: - - !type:AddAction - action: CP14ActionSpellIceShards - restrictions: - - !type:NeedPrerequisite - prerequisite: HydrosophistryT1 - - type: cp14Skill id: CP14ActionSpellIceDagger skillUiPosition: 0, 6 @@ -70,7 +57,7 @@ - type: cp14Skill id: CP14ActionSpellIceArrow - skillUiPosition: 0, 8 + skillUiPosition: 2, 6 tree: Hydrosophistry icon: sprite: _CP14/Actions/Spells/water.rsi @@ -114,6 +101,20 @@ - !type:NeedPrerequisite prerequisite: HydrosophistryT2 +- type: cp14Skill + id: CP14ActionSpellIceShards + skillUiPosition: 8, 4 + tree: Hydrosophistry + icon: + sprite: _CP14/Actions/Spells/water.rsi + state: ice_shards + effects: + - !type:AddAction + action: CP14ActionSpellIceShards + restrictions: + - !type:NeedPrerequisite + prerequisite: HydrosophistryT2 + # T3 - type: cp14Skill diff --git a/Resources/Prototypes/_CP14/Skill/martial_arts.yml b/Resources/Prototypes/_CP14/Skill/martial_arts.yml index 24281dd4c1..2a560ffc73 100644 --- a/Resources/Prototypes/_CP14/Skill/martial_arts.yml +++ b/Resources/Prototypes/_CP14/Skill/martial_arts.yml @@ -3,36 +3,30 @@ skillUiPosition: 0, 0 name: cp14-skill-sword-mastery-name desc: cp14-skill-mastery-desc - learnCost: 0 + learnCost: 0.5 tree: MartialArts icon: sprite: _CP14/Objects/ModularTools/Blade/Sword/metall_sword.rsi state: preview - restrictions: - - !type:Impossible - type: cp14Skill id: RapierMastery skillUiPosition: 2, 0 name: cp14-skill-parier-mastery-name desc: cp14-skill-mastery-desc - learnCost: 0 + learnCost: 0.5 tree: MartialArts icon: sprite: _CP14/Objects/ModularTools/Blade/Rapier/metall_rapier.rsi state: preview - restrictions: - - !type:Impossible - type: cp14Skill id: SkimitarMastery skillUiPosition: 4, 0 name: cp14-skill-skimitar-mastery-name desc: cp14-skill-mastery-desc - learnCost: 0 + learnCost: 0.5 tree: MartialArts icon: sprite: _CP14/Objects/ModularTools/Blade/Skimitar/metall_skimitar.rsi - state: preview - restrictions: - - !type:Impossible \ No newline at end of file + state: preview \ No newline at end of file diff --git a/Resources/Prototypes/_CP14/Skill/thaumaturgy.yml b/Resources/Prototypes/_CP14/Skill/thaumaturgy.yml index 0842614522..a5bdef0596 100644 --- a/Resources/Prototypes/_CP14/Skill/thaumaturgy.yml +++ b/Resources/Prototypes/_CP14/Skill/thaumaturgy.yml @@ -4,13 +4,11 @@ tree: Thaumaturgy name: cp14-skill-alchemy-vision-name desc: cp14-skill-alchemy-vision-desc - learnCost: 0 + learnCost: 1 icon: sprite: _CP14/Clothing/Eyes/alchemy_glasses.rsi state: icon effects: - !type:AddComponents components: - - type: SolutionScanner - restrictions: - - !type:Impossible \ No newline at end of file + - type: SolutionScanner \ No newline at end of file