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 support for variables acting on Blitz Lives #1214

Merged
merged 1 commit into from
Aug 23, 2023
Merged

Conversation

cswhite2000
Copy link
Member

@cswhite2000 cswhite2000 commented Aug 11, 2023

New Description:

So decided to go with a different approach for this. This now adds support for different types of variables. Specifically, this adds a blitz lives variable type that directly sets or gets blitz lives for a player.

Example Usage:

<variable id="playerlives" scope="player" type="lives"/>
...
<set var="playerlives" value="playerlives+1"/>

With this, the type can be either dummy or lives. dummy being the original variable type, and lives getting or writing blitz lives. type is optional and defaults to dummy.

Original description

⚠️ Syntax beyond this point is no longer valid. ⚠️

Adds a modify-lives action. At @zzufx's request

You can add, subtract, or set lives.
Usage would be as follows:

<modify-lives operation="add" amount="2" show-title="true"/>

show-title is optional and can be left out

<modify-lives operation="set" amount="1"/>
or
<modify-lives operation="subtract" amount="1"/>

The action will act on all players in a given scope, so for example you could have a team scoped set lives to 1 that would set the lives remaining for all players to 1 after an objective is completed.

Edit:
amount now supports variables and expressions

@Pablete1234
Copy link
Member

Make number an expression supporting variables, adds alot more play

@cswhite2000 cswhite2000 force-pushed the lives-action branch 2 times, most recently from 3ba5616 to de13461 Compare August 12, 2023 04:35
Copy link
Member

@Pablete1234 Pablete1234 left a comment

Choose a reason for hiding this comment

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

Besides what i pointed out, i have doubts about the whole add/remove/set thing.
In the original draft for variables (#881) i had a similar system, but that eventually went out the window in favor of formulas with variables.
Want to add 5? Use <set var="thing" value="thing + 5"/>
Want to halve it? Use <set var"thing" value="thing / 2">
Want to multiply it by the cos of another variable? Use <set var"thing" value="thing * cos(other)">

Its much more flexible than hard-coded allowed operations.

The biggest roadblock is lack of a way to reference lives left within that. I mentioned somewhere that it'd be nice to have more variable types, so you could define a: <variable id="lives" type="blitz-lives"> or similar. Some other candidates would be player curr and max health, or team score. What that allows is to directly operate on blitz lives as if it was just another variable. You can arbitratily <set var="lives" value="lives + 5"> which automatically gets you this behavior, plus you can now operate on so much more (eg: set player max heath based on amount of lives, so last live you have less max hp). Also there's a consideration for potentially read-only variable types, maybe health should be read-only and can be set via a kit if you wish, etc.

I'm fully aware that much of what i mentioned here is well out of scope for this pr, but i'm just trying to give my long-term vision on the matter, in hopes that we can get some middle ground that both aligns this towards that but doesn't necessarily mean a full rewrite

core/src/main/java/tc/oc/pgm/action/Operation.java Outdated Show resolved Hide resolved
@cswhite2000
Copy link
Member Author

I also would prefer to use variables directly for things like this, and I'm willing to go with that approach if we can come up with a suitable design.

My main sticking point for why I didn't originally go with that approach is that it seemed like I'd have to create default variables for those things and update them every time the underlying value was changed, while also adding an update for every time the variable changed to change the underlying value.

@cswhite2000 cswhite2000 changed the title Add a modify-lives action Add support for variables acting on Blitz Lives Aug 12, 2023
Copy link
Member

@Pablete1234 Pablete1234 left a comment

Choose a reason for hiding this comment

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

The one last thing i see missing is preventing variable filters for non-dummy variable types being created. If you made a blitz variable and filtered on it, it wouldn't work dynamically

Copy link
Member

@Pablete1234 Pablete1234 left a comment

Choose a reason for hiding this comment

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

Great work

@cswhite2000 cswhite2000 mentioned this pull request Aug 14, 2023
10 tasks
@Pablete1234 Pablete1234 added the ready PR is ready to merge label Aug 16, 2023
@Pablete1234
Copy link
Member

Please note, given recent changes, this should be merged alongside #1220. Syntax has changed.

@Electroid Electroid merged commit 87278fe into dev Aug 23, 2023
2 checks passed
@Electroid Electroid deleted the lives-action branch August 23, 2023 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PR is ready to merge
Development

Successfully merging this pull request may close these issues.

3 participants