Skip to content

Conversation

@Fusezion
Copy link
Contributor

@Fusezion Fusezion commented Dec 15, 2025

Problem

In skript there is no way currently to get the negated result of a CondChance without 4 semi annoying work arounds.

  1. inverse your own numbers 10% -> 90%
  2. if you have 0-1 value use 1 - x
  3. use an if statement followed by an else
  4. use ExprWhether to do a normal CondCompare check

Solution

In order to provide developers a more flexible condition I'm proposing to add a new end bit for whether it failed
i.e. if chance of 10% failed allowing easier and simpler guard conditions in their code

Testing Completed

Manual testing was completed with a debug method added within the check method
image

Supporting Information

While doing this I've taken the chance to update methods and annotations to skript's newer designs, wasn't sure if the team wanted this swapped too the new registration api or where you'd want it moved to if so.


Completes: #8319
Related: none
AI assistance: none

@Fusezion Fusezion requested a review from a team as a code owner December 15, 2025 19:55
@Fusezion Fusezion requested review from Burbulinis and Pesekjak and removed request for a team December 15, 2025 19:55
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Dec 15, 2025
Comment on lines 60 to 62
String baseString = "chance of " + chance.toString(event, debug) + (percent ? "%" : "");
if (isNegated()) baseString += " failed";
return baseString;
Copy link
Contributor Author

@Fusezion Fusezion Dec 15, 2025

Choose a reason for hiding this comment

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

Quick note this doesn't use a SyntaxStringBulder as it would cause with percentage to format as chance of 10 %
edit: fixed the usage of if () baseString += "" not being on a new line

Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

just some nitpicks

@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
//noinspection unchecked
Copy link
Member

Choose a reason for hiding this comment

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

you can leave this as a suppression on the method if you'd like

Fusezion and others added 2 commits December 15, 2025 15:20
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
@Fusezion
Copy link
Contributor Author

per smurfy's request in my dms, I've implemented a simplified condition, this is my first time interacting with this so let me know if anything should be changed.
image

Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
@Efnilite Efnilite changed the title Add support for a negation/fail check on CondContains Add support for a negation/fail check on CondChance Dec 16, 2025
@skriptlang-automation skriptlang-automation bot added feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. and removed needs reviews A PR that needs additional reviews labels Dec 16, 2025
@sovdeeth sovdeeth added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Dec 17, 2025
@github-project-automation github-project-automation bot moved this to Awaiting Merge in 2.14 Releases Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version.

Projects

Status: Awaiting Merge

Development

Successfully merging this pull request may close these issues.

3 participants