Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enter-cloak & exit-cloak effect for Cloak #19881

Merged
merged 2 commits into from
Feb 12, 2022

Conversation

dnqbob
Copy link
Contributor

@dnqbob dnqbob commented Jan 14, 2022

cloak-showcase

close #19880

OpenRA.Mods.Common/Traits/Cloak.cs Outdated Show resolved Hide resolved
@@ -167,16 +181,34 @@ void ITick.Tick(Actor self)
cloakedToken = self.GrantCondition(Info.CloakedCondition);

// Sounds shouldn't play if the actor starts cloaked
if (!(firstTick && Info.InitialDelay == 0) && !otherCloaks.Any(a => a.Cloaked))
if (!(firstTick && Info.InitialDelay == 0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!(firstTick && Info.InitialDelay == 0))
if (!firstTick || Info.InitialDelay > 0)

OpenRA.Mods.Common/Traits/Cloak.cs Show resolved Hide resolved
@@ -63,6 +64,24 @@ public class CloakInfo : PausableConditionalTraitInfo
[Desc("The condition to grant to self while cloaked.")]
public readonly string CloakedCondition = null;

[Desc("Which image to use for effect when enter/exit cloak.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[Desc("Which image to use for effect when enter/exit cloak.")]
[Desc("Which image to use for the effect played when cloaking or uncloaking.")]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

[Desc("Which image to use for effect when enter/exit cloak.")]
public readonly string EffectImage = null;

[Desc("Which sequence to use for effect when enter cloak.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[Desc("Which sequence to use for effect when enter cloak.")]
[Desc("Which effect sequence to play when cloaking.")]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


[Desc("Which sequence to use for effect when enter cloak.")]
[SequenceReference(nameof(EffectImage), allowNullImage: true)]
public readonly string EnterEffectSequence = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public readonly string EnterEffectSequence = null;
public readonly string CloakEffectSequence = null;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

[SequenceReference(nameof(EffectImage), allowNullImage: true)]
public readonly string EnterEffectSequence = null;

[Desc("Which sequence to use for effect when exit cloak..")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[Desc("Which sequence to use for effect when exit cloak..")]
[Desc("Which effect sequence to play when uncloaking.")]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


[Desc("Which sequence to use for effect when exit cloak..")]
[SequenceReference(nameof(EffectImage), allowNullImage: true)]
public readonly string ExitEffectSequence = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public readonly string ExitEffectSequence = null;
public readonly string UncloakEffectSequence = null;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

public readonly string EffectPalette = "effect";
public readonly bool IsEffectPlayerPalette = false;

[Desc("Offset for effect when enter/exit cloak.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[Desc("Offset for effect when enter/exit cloak.")]
[Desc("Offset for the effect played when cloaking or uncloaking.")]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


[PaletteReference(nameof(IsEffectPlayerPalette))]
public readonly string EffectPalette = "effect";
public readonly bool IsEffectPlayerPalette = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public readonly bool IsEffectPlayerPalette = false;
public readonly bool EffectPaletteIsPlayerPalette = false;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this seems unused so please remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

third-party mod may need this on stealth effect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix the spelling, not removed

@dnqbob dnqbob force-pushed the cloak-effect branch 2 times, most recently from 8cb6815 to 1e37cc2 Compare January 15, 2022 14:28
palette += self.Owner.InternalName;

self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(
pos + Info.EffectOffset, w, Info.EffectImage, Info.CloakEffectSequence, palette)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pos + Info.EffectOffset, w, Info.EffectImage, Info.CloakEffectSequence, palette)));
pos + Info.EffectOffset, w, Info.EffectImage, Info.UncloakEffectSequence, palette)));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:< fixed

Comment on lines 524 to 525
PauseOnCondition: cloak-force-disabled || empdisable
CloakedCondition: cloak-self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test what happens when you build a Stealth Tank within the radius of a Stealth Generator? I would expect it still plays the cloak sound with this setup. Thinking more about it we might need to restore the old checks, as I'm no longer sure this is doable using conditions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is still here. going restore the check but I will change it by getting the same cloak type on the unit.

Copy link
Contributor Author

@dnqbob dnqbob Jan 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ummm, I meet a issue when get the same cloak type. In fact it is cloak types, like targetables. could we make the "InitialDelay = 0" of TS stealth tank's Cloak to avoid this?

Still the example: submarine is under the effect of Stealth Generator.

Submerge is a kind of cloak, Stealth is a kind of cloak. In regular logic, being stealth and make the sound of steath field doesn't(or may not) prevent submarine make sound of go under the water.

The use case here is more complicated: only one of the two stealth generators can work. In orignal TS, if what I remeber is correct, the Stealth Tank doesn't recieve the buff from Stealth Generator: when it get heavily damaged, Stealth Generator cannot cloak it like other heavily damage vehicle. If we want to use the gameplay setting like orignal TS it is also simple to solve.

In conclusion, we have 3 ideas here:

  1. make InitialDelay=0 for stealth tank cloak (I confirm it is working)
  2. change back to TS orignal setting: Stealth Generator doesn't affect Stealth Tank
  3. add Cloak something to identify the same cloak method, without using CloakTypes (or we use CloakTypes with a not so confusing rule), which may makes the code more confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the yaml it makes perfect sense why they cloak twice, so I think it should also be solved via yaml. IMO in this case hardcoding the solution only limits modders

I can see 2 easy ways of fixing this

  1. Stealth tank overwrites stealth generator stealth instead of being separate
  2. Stealth generator stealth is disabled on stealth tank

Copy link
Member

@PunkPun PunkPun Jan 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And one feature creep way. Add a property on cloak called TriggerCloakOnConditions. That way you could disable external cloak on stealth tank, but add the external condition to stank cloak. The TriggerCloakOnConditions would ignore the internal cloak delay and cloak immediately when any of the set conditions become true cloakgenerator, crate-cloak. I'm not sure if we can set conditions this way though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the problem with using CloakTypes?

Copy link
Contributor Author

@dnqbob dnqbob Jan 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the problem with using CloakTypes?

CloakTypes cannot be used as a standard that tell OpenRA some Cloak traits belong to one kind of cloak, which have the same cloak&uncloak sound/visual effect and have some special rule when playing the sound/visual effect. For example, Stealth Tank cloak and Cloak Generator cloak.

if we want to solve this problem perfectly, we need another property in CloakInfo like CloakClass/CloakKind or something, restore the check but this check is only effective on the same CloakClass/CloakKind.

To make it more readable I want to rename CloakTypes into DetectableTypes, and make another CloakType to differ the same cloak.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it more readable I want to rename CloakTypes into DetectableTypes, and make another CloakType to differ the same cloak.

That sounds like a good idea. I suggest DetectionTypes (because they're used for detection, and the types themselves are not detectable).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it is done

Copy link
Member

@abcdefg30 abcdefg30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untested but looks good now in theory. Can you add an update rule for the CloakTypes -> DetectionTypes changes?

@dnqbob
Copy link
Contributor Author

dnqbob commented Jan 17, 2022

Untested but looks good now in theory. Can you add an update rule for the CloakTypes -> DetectionTypes changes?

I'd love to but I never did the same thing before so could you tell me how to use the rule system?

@abcdefg30
Copy link
Member

1fab49e is an example for how to do an update rule:
Create a new file called RenameCloakTypes.cs in the OpenRA.Mods.Common/UpdateRules/Rules/20201213 folder (20201213 because that was the first playtest after release-20200503). Then add an instance of that class to the // Bleed only changes here update path in UpdatePath.cs.
The content of the file can be similar to my example: Search for each Cloak trait, find the LastChildMatching CloakTypes and rename that node (there is a rename function). Then do the same for all DetectCloaked traits.

@dnqbob
Copy link
Contributor Author

dnqbob commented Jan 17, 2022

thanks, idk if now it is correct

@dnqbob
Copy link
Contributor Author

dnqbob commented Jan 18, 2022

Change the !(firstTick && Info.InitialDelay == 0) && (otherCloaks == null || !otherCloaks.Any(a => a.Cloaked)) into (otherCloaks == null || !otherCloaks.Any(a => a.Cloaked)) && !(firstTick && Info.InitialDelay == 0), in the hoping that more performance can be saved

Update: ummm acutally not

@abcdefg30
Copy link
Member

Update: ummm acutally not

Can you change it back? (Calling the Any before the rest will likely be less performant fwiw, although it won't matter much in practice.)

@dnqbob
Copy link
Contributor Author

dnqbob commented Jan 18, 2022

it is back now

abcdefg30
abcdefg30 previously approved these changes Jan 20, 2022
Copy link
Member

@abcdefg30 abcdefg30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(You can remove the test cases from RA now; before we accidentally merge them. 😅)

@dnqbob
Copy link
Contributor Author

dnqbob commented Jan 20, 2022

(You can remove the test cases from RA now; before we accidentally merge them. 😅)

Which one, both?
I kinda want to keep them :(

@Inq8
Copy link
Contributor

Inq8 commented Jan 22, 2022

Can this be expanded to grant a condition when cloaking and a condition when uncloaking?

Copy link
Member

@pchote pchote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One typo I spotted, not a proper review.

I second the request to remove the testcases, IMO the submarine splash in particular doesn't look good and may be confusing for players thinking that something is firing on it.


[GrantedConditionReference]
[Desc("The condition to grant to self while cloaked.")]
public readonly string CloakedCondition = null;

[Desc("The type of cloak. Same type of cloaks won't tigger cloaking and uncloaking sound and effect.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tigger

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the other usecase of stealth apc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and dropped

reaperrr
reaperrr previously approved these changes Jan 30, 2022
Copy link
Contributor

@reaperrr reaperrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, though I'm not 100% sure about the RA STNK sparkle effect

@reaperrr
Copy link
Contributor

Not merging yet since I don't know how others feel about the STNK sparkle effect.

@dnqbob
Copy link
Contributor Author

dnqbob commented Feb 3, 2022

Can this be expanded to grant a condition when cloaking and a condition when uncloaking?

Maybe not in this branch, but it is possible to make it grant a condition when cloaking and a condition when uncloaking

@Smittytron
Copy link
Member

The animation doesn't follow a moving actor, is this intended?

@abcdefg30
Copy link
Member

How about the other usecase of stealth apc?

There hasn't been great support for this change on Discord, so I'd prefer if we can fix the animation not following actors and then remove the effect from the Phase Transport.

@dnqbob
Copy link
Contributor Author

dnqbob commented Feb 4, 2022

The animation doesn't follow a moving actor, is this intended?

Yes, considering usecase of submarine (appear and disappear with a water splash) and ninja (disappear with a smoke screen), the cloak effect of those should not follow the actor, but play at the effect triggered position instead.

However, now I make the user can set the follow or not.

There hasn't been great support for this change on Discord, so I'd prefer if we can fix the animation not following actors and then remove the effect from the Phase Transport.

Spark still not remove for you to test out and test the setting of follow/not follow function. Once it is done I will remove the testcase here.

abcdefg30
abcdefg30 previously approved these changes Feb 4, 2022
Copy link
Member

@abcdefg30 abcdefg30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracking works. ✅

public readonly WVec EffectOffset = WVec.Zero;

[Desc("Should the effect track the actor.")]
public readonly bool EffectTrackActor = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public readonly bool EffectTrackActor = true;
public readonly bool EffectTracksActor = true;

palette += self.Owner.InternalName;

self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(
posFunc: posfunc, facingFunc: () => WAngle.Zero, w, Info.EffectImage, Info.CloakEffectSequence, palette)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming the parameters should not be necessary, or is it?

Suggested change
posFunc: posfunc, facingFunc: () => WAngle.Zero, w, Info.EffectImage, Info.CloakEffectSequence, palette)));
posfunc, () => WAngle.Zero, w, Info.EffectImage, Info.CloakEffectSequence, palette)));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be all fixed here and drop the test case

@dnqbob
Copy link
Contributor Author

dnqbob commented Feb 5, 2022

Still I hope there can be somewhere use the cloak effect, for maintaining unused code will be hard without an usecase

@Mailaender Mailaender merged commit 6c33d47 into OpenRA:bleed Feb 12, 2022
@Mailaender
Copy link
Member

Changelog

@dnqbob dnqbob deleted the cloak-effect branch February 13, 2022 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an enter-cloak effect and an exit-cloak effect in Cloak
8 participants