From dfbcc335a4f85c63d584b34d2e7a7573d714a21c Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Sun, 12 May 2024 08:11:44 +0200 Subject: [PATCH] Apply UEF fx when gaining veterancy, scale effects based on the unit size --- CONTRIBUTING.md | 49 +++++++++++++++++-------- lua/defaultcomponents.lua | 13 +++++++ lua/sim/Unit.lua | 8 +++- lua/sim/units/uef/TAirUnit.lua | 9 ++++- lua/sim/units/uef/TConstructionUnit.lua | 5 +++ lua/sim/units/uef/THoverLandUnit.lua | 7 +++- lua/sim/units/uef/TLandUnit.lua | 7 +++- lua/sim/units/uef/TSeaUnit.lua | 9 ++++- lua/sim/units/uef/TShieldLandUnit.lua | 7 +++- lua/sim/units/uef/TShieldSeaUnit.lua | 7 +++- lua/sim/units/uef/TSubUnit.lua | 7 +++- lua/sim/units/uef/TWalkingLandUnit.lua | 7 +++- 12 files changed, 109 insertions(+), 26 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1df549f60d..43a12f6ad4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,23 +1,40 @@ -Contributing ------------- +# Contributing to FAForever -To contribute, please fork this repository and make pull requests to the -`deploy/fafdevelop` branch. +Welcome commander to another battlefield filled with technology - the everlasting polishing of Supreme Commander: Forged Alliance Forever! -Use the normal git conventions for commit messages, with the following rules: - - Subject line shorter than 80 characters - - No trailing period - - For non-trivial commits, always include a commit message body, describing the change in detail - - If there are related issues, reference them in the commit message footer +Regardless of your faction - everyone is welcome to contribute. To smooth out this process we highly encourage you to read the relevant sections of this document before making your contributions. You can find an overview in the [Table of Contents](#table-of-contents). It will make it easier for your fellow commanders to review it and smooth out the experience for everyone and all factions involved. The community - except for maybe the Cybrans - look forward to your contributions! -We use [git flow](http://nvie.com/posts/a-successful-git-branching-model/) for our branch conventions. +## Table of Contents -When making _backwards incompatible API changes_, do so with a stub function and put in a logging statement including traceback. This gives time for mod authors to change their code, as well as for us to catch any incompatibilities introduced by the change. +- [Contributing to FAForever](#contributing-to-faforever) + - [Table of Contents](#table-of-contents) + - [I have a question](#i-have-a-question) + - [I want to contribute](#i-want-to-contribute) + - [Reporting bugs](#reporting-bugs) + - [Contribute via code](#contribute-via-code) + - [Contribute via assets](#contribute-via-assets) + - [Related repositories](#related-repositories) -Code convention ---------------- +## I have a question -Please follow the [Lua Style Guide](http://lua-users.org/wiki/LuaStyleGuide) as -much as possible. +The community is available in various channels. For questions we encourage you to join the [FAForever Discord Server](https://discord.gg/mXahVSKGVb). There are separate channels for game development. We'd recommend the offtopic channel. There are various contributors available here to help find an answer to your question. -For file encoding, use UTF-8 and unix-style file endings in the repo (Set core.autocrlf). +## I want to contribute + +### Reporting bugs + +A good bug report should make it immediately clear to a maintainer what the perceived bug is and possibly how to reproduce it consistently. The time of maintainers is relatively scarce, a detailed bug report is therefore not only appreciated but it also reduces the overhead of understanding the context of the bug. You can follow these guidelines to create a detailed bug report: + +- Find an (preferably easy) approach to reproduce it in a sandboxed environment. + +Once you've found a way to reproduce the bug you need to make sure that it is not related to a mod. Disable all your (ui) mods and try to reproduce the bug again. If the bug still occurs then do attach the replay id to your bug report along with a timestamp as to when the bug occurs. + +- Open a [new issue on Github](https://github.com/FAForever/fa/issues/new?assignees=&labels=status%3A+novel+issue&projects=&template=bug_report.md&title=) using the bug report template + +In the issue you can add a description of the bug and relevant images or videos. You can add the replay id in the description. If you do not have a Github account then we encourage you to create one. Otherwise you can also report the bug on the [FAForever Discord Server](https://discord.gg/mXahVSKGVb). + +### Contribute via code + +### Contribute via assets + +## Related repositories diff --git a/lua/defaultcomponents.lua b/lua/defaultcomponents.lua index 2f208bff1b..2cbec39d94 100644 --- a/lua/defaultcomponents.lua +++ b/lua/defaultcomponents.lua @@ -598,6 +598,8 @@ local VeterancyRegenBuffs = { ---@field VetLevel? number VeterancyComponent = ClassSimple { + VeterancyFx = {}, + ---@param self VeterancyComponent | Unit OnCreate = function(self) local blueprint = self.Blueprint @@ -755,6 +757,17 @@ VeterancyComponent = ClassSimple { local mult = blueprint.VeteranHealingMult[nextLevel] or 0.1 self:AdjustHealth(self, maxHealth * mult) + -- effects + + local army = self.Army + local blueprint = self.Blueprint + local sizeX = blueprint.SizeX or 1 + local sizeZ = blueprint.SizeZ or 1 + for _, effect in self.VeterancyFx do + LOG(effect) + CreateEmitterAtEntity(self, army, effect):ScaleEmitter(MathMin(sizeX, sizeZ)) + end + -- callbacks self:DoUnitCallbacks('OnVeteran') diff --git a/lua/sim/Unit.lua b/lua/sim/Unit.lua index 0653d901be..3643373f9d 100644 --- a/lua/sim/Unit.lua +++ b/lua/sim/Unit.lua @@ -2329,8 +2329,12 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent) { --- "/effects/emitters/veterancy/cybran_vet_1_v2-2.bp", } - for index, effect in effects do - CreateEmitterAtEntity(self, self.Army, effect) + local army = self.Army + local blueprint = self.Blueprint + local sizeX = blueprint.SizeX or 1 + local sizeZ = blueprint.SizeZ or 1 + for _, effect in effects do + CreateEmitterAtEntity(self, army, effect):ScaleEmitter(math.min(sizeX, sizeZ) * 0.5) end -- Create any idle effects on unit diff --git a/lua/sim/units/uef/TAirUnit.lua b/lua/sim/units/uef/TAirUnit.lua index a1b790fc10..168036dad7 100644 --- a/lua/sim/units/uef/TAirUnit.lua +++ b/lua/sim/units/uef/TAirUnit.lua @@ -23,4 +23,11 @@ local AirUnit = import('/lua/defaultunits.lua').AirUnit ---@class TAirUnit : AirUnit -TAirUnit = ClassUnit(AirUnit) {} +TAirUnit = ClassUnit(AirUnit) { + + VeterancyFx = { + "/effects/emitters/veterancy/uef_vet_1_v2.bp", + "/effects/emitters/veterancy/uef_vet_1_v3.bp", + } + +} diff --git a/lua/sim/units/uef/TConstructionUnit.lua b/lua/sim/units/uef/TConstructionUnit.lua index 565da4bb46..fb0681dfbd 100644 --- a/lua/sim/units/uef/TConstructionUnit.lua +++ b/lua/sim/units/uef/TConstructionUnit.lua @@ -36,6 +36,11 @@ local ForkThread = ForkThread ---@field TransformManipulator moho.AnimationManipulator TConstructionUnit = ClassUnit(ConstructionUnit) { + VeterancyFx = { + "/effects/emitters/veterancy/uef_vet_1_v2.bp", + "/effects/emitters/veterancy/uef_vet_1_v3.bp", + }, + ---@param self TConstructionUnit ---@param builder Unit ---@param layer Layer diff --git a/lua/sim/units/uef/THoverLandUnit.lua b/lua/sim/units/uef/THoverLandUnit.lua index e571aaf557..252b6422d9 100644 --- a/lua/sim/units/uef/THoverLandUnit.lua +++ b/lua/sim/units/uef/THoverLandUnit.lua @@ -23,4 +23,9 @@ local HoverLandUnit = import('/lua/defaultunits.lua').HoverLandUnit ---@class THoverLandUnit : HoverLandUnit -THoverLandUnit = ClassUnit(HoverLandUnit) {} +THoverLandUnit = ClassUnit(HoverLandUnit) { + VeterancyFx = { + "/effects/emitters/veterancy/uef_vet_1_v2.bp", + "/effects/emitters/veterancy/uef_vet_1_v3.bp", + } +} diff --git a/lua/sim/units/uef/TLandUnit.lua b/lua/sim/units/uef/TLandUnit.lua index b063f82754..61c5cbe832 100644 --- a/lua/sim/units/uef/TLandUnit.lua +++ b/lua/sim/units/uef/TLandUnit.lua @@ -23,4 +23,9 @@ local LandUnit = import('/lua/defaultunits.lua').LandUnit ---@class TLandUnit : LandUnit -TLandUnit = ClassUnit(LandUnit) {} +TLandUnit = ClassUnit(LandUnit) { + VeterancyFx = { + "/effects/emitters/veterancy/uef_vet_1_v2.bp", + "/effects/emitters/veterancy/uef_vet_1_v3.bp", + } +} diff --git a/lua/sim/units/uef/TSeaUnit.lua b/lua/sim/units/uef/TSeaUnit.lua index 9d895118b8..bc07f7ab26 100644 --- a/lua/sim/units/uef/TSeaUnit.lua +++ b/lua/sim/units/uef/TSeaUnit.lua @@ -23,4 +23,11 @@ local SeaUnit = import('/lua/defaultunits.lua').SeaUnit ---@class TSeaUnit : SeaUnit -TSeaUnit = ClassUnit(SeaUnit) {} +TSeaUnit = ClassUnit(SeaUnit) { + + VeterancyFx = { + "/effects/emitters/veterancy/uef_vet_1_v2.bp", + "/effects/emitters/veterancy/uef_vet_1_v3.bp", + } + +} diff --git a/lua/sim/units/uef/TShieldLandUnit.lua b/lua/sim/units/uef/TShieldLandUnit.lua index 44deed4ae3..153ae7bc45 100644 --- a/lua/sim/units/uef/TShieldLandUnit.lua +++ b/lua/sim/units/uef/TShieldLandUnit.lua @@ -23,4 +23,9 @@ local ShieldLandUnit = import('/lua/defaultunits.lua').ShieldLandUnit ---@class TShieldLandUnit : ShieldLandUnit -TShieldLandUnit = ClassUnit(ShieldLandUnit) {} +TShieldLandUnit = ClassUnit(ShieldLandUnit) { + VeterancyFx = { + "/effects/emitters/veterancy/uef_vet_1_v2.bp", + "/effects/emitters/veterancy/uef_vet_1_v3.bp", + } +} diff --git a/lua/sim/units/uef/TShieldSeaUnit.lua b/lua/sim/units/uef/TShieldSeaUnit.lua index 5a6959927d..46de788561 100644 --- a/lua/sim/units/uef/TShieldSeaUnit.lua +++ b/lua/sim/units/uef/TShieldSeaUnit.lua @@ -23,4 +23,9 @@ local ShieldSeaUnit = import('/lua/defaultunits.lua').ShieldSeaUnit ---@class TShieldSeaUnit : ShieldSeaUnit -TShieldSeaUnit = ClassUnit(ShieldSeaUnit) {} +TShieldSeaUnit = ClassUnit(ShieldSeaUnit) { + VeterancyFx = { + "/effects/emitters/veterancy/uef_vet_1_v2.bp", + "/effects/emitters/veterancy/uef_vet_1_v3.bp", + } +} diff --git a/lua/sim/units/uef/TSubUnit.lua b/lua/sim/units/uef/TSubUnit.lua index dd0bc92a05..f569df359d 100644 --- a/lua/sim/units/uef/TSubUnit.lua +++ b/lua/sim/units/uef/TSubUnit.lua @@ -23,4 +23,9 @@ local SubUnit = import('/lua/defaultunits.lua').SubUnit ---@class TSubUnit : SubUnit -TSubUnit = ClassUnit(SubUnit) {} +TSubUnit = ClassUnit(SubUnit) { + VeterancyFx = { + "/effects/emitters/veterancy/uef_vet_1_v2.bp", + "/effects/emitters/veterancy/uef_vet_1_v3.bp", + } +} diff --git a/lua/sim/units/uef/TWalkingLandUnit.lua b/lua/sim/units/uef/TWalkingLandUnit.lua index 5e942e4d49..ec78016280 100644 --- a/lua/sim/units/uef/TWalkingLandUnit.lua +++ b/lua/sim/units/uef/TWalkingLandUnit.lua @@ -23,4 +23,9 @@ local WalkingLandUnit = import('/lua/defaultunits.lua').WalkingLandUnit ---@class TWalkingLandUnit : WalkingLandUnit -TWalkingLandUnit = ClassUnit(WalkingLandUnit) {} +TWalkingLandUnit = ClassUnit(WalkingLandUnit) { + VeterancyFx = { + "/effects/emitters/veterancy/uef_vet_1_v2.bp", + "/effects/emitters/veterancy/uef_vet_1_v3.bp", + } +}