Code Monkey home page Code Monkey logo

Comments (8)

Echtelion avatar Echtelion commented on June 28, 2024

Exemple for critical strike :

!7+ABS(1D10-1D10)
RESULT : #7, #7 = CRITICAL STRIKE ON #7
!7+ABS(1D10-1D10)
RESULT : #0, #0 = CRITICAL FAIL ON #0

from diceparser.

obiwankennedy avatar obiwankennedy commented on June 28, 2024

Hello, I worked on that in order to make it work without abs function but to make it with if.
I finally make it work but I discover a bug about it. I have to deploy this bug fix in order to make the if replacement a working command.

It should work with this:

!1d10;1d10;$1-$2;$3i:[<0]{$3*-1}{$3};$1S[=7]{"Critical Strike"}[=0]{"Critical Fail"}{" "};7+$4;"Result: $5 #$1, #$2 = $6 [details: $4]"

But due to a bug the $3*-1 does not work. I fixed it but it is not deploy yet. It will be done soon. Adding the abs function can be done but function are not manage like that in the diceparser. I have to check that.

from diceparser.

Echtelion avatar Echtelion commented on June 28, 2024

Thanks for your answer.
I may be misreading your expression, but I understand that you output a "critical strike" when diff=0 & roll=7. That's not how critical strike work : any even result except 0 is a critical strike

  • if $1=$2=0 then critical fail on #0 (or $1=0 & $3=0, same result)
  • else if $1=$2 then critical strike
  • else if $1<$2 then normal dice $2-$1
  • else normal dice $1-$2

you can also sort it this way if easier to write :

  • if $1=$2 (or $3=0, same result)
    -- if $1=0 then critical fail
    -- else critical strike
  • else if $1<$2 then normal dice $2-$1
  • else normal dice $1-$2

Also the 7 is hardcoded in your expression, while it's an input for me (7 is carac + talent as a base, on which I'll add the dice result). Note we can ignore this input for simplification sake.

from diceparser.

Echtelion avatar Echtelion commented on June 28, 2024

Ok, I found a workaround for your *-1 bug, : just make the substraction the other way instead of negativing the result

Here is my workaround :
!1d10;1d10;$1-$2;$3i:[<0]{$2-$1}{$3};$3S[=0]{$1S[=0]{"CRITICAL FAIL"}{"CRITICAL STRIKE"}}{$3S[<0]{"NEGATIVE STRIKE"}{"POSITIVE STRIKE"}};"Result: $5 #$1, #$2 = $4"

I also added the positive/negative result for damage bonus (negative result make no dmg bonus, while positive make it)

from diceparser.

Echtelion avatar Echtelion commented on June 28, 2024

mfffff, the command work fine, but now I'm unable to add it into a macro.

Here is the command :
!macro add yy !1d10;1d10;$1-$2;$3i:[<0]{$2-$1}{$3};$3S[=0]{$1S[=0]{"CRITICAL FAIL"}{"CRITICAL STRIKE"}}{$3S[<0]{"NEGATIVE STRIKE"}{"POSITIVE STRIKE"}};"Result: $5 #$1 - #$2 = $4" False
The bot acknowledge the command, and I can see it in !macro list, but it doesn't run on !yy (others macro works)

Me : !macro list
DiceParser BOT
id: 0 Pattern: yy Command: !1d10;1d10;$1-$2;$3i:[<0]{$2-$1}{$3};$3S[=0]{$1S[=0]{"CRITICAL FAIL"}{"CRITICAL STRIKE"}}{$3S[<0]{"NEGATIVE STRIKE"}{"POSITIVE STRIKE"}};"Result: $5 #$1 - #$2 = $4" Regexp: False
Me : !yy
(nothing)

from diceparser.

obiwankennedy avatar obiwankennedy commented on June 28, 2024

No need of leading ! on the command part (before the 1d10).

This should works:

!macro add yy 1d10;1d10;$1-$2;$3i:[<0]{$2-$1}{$3};$3S[=0]{$1S[=0]{"CRITICAL FAIL"}{"CRITICAL STRIKE"}}{$3S[<0]{"NEGATIVE STRIKE"}{"POSITIVE STRIKE"}};"Result: $5 #$1 - #$2 = $4" False

from diceparser.

Echtelion avatar Echtelion commented on June 28, 2024

Hi @obiwankennedy I'm sorry to revive this thread but I didn't try the macro earlier.
I don't see any error in the macro, but I got this error messages : Error: No value fits the Switch/Case operator
Supposedly when getting dice1 == dice2

I have decomposed/documented the macro and really didn't see any switch error :

!macro add yy 
1d10; 	//1 YIN dice
1d10;	//2 YANG dice
$1-$2;	//3 DIFF
$3i:[<0]{$2-$1}{$3}; 	//4: always positive diff
$3S[=0]{				//5: if diff is 0, it's a critital
	$1S[=0]{"CRITICAL FAIL"}{"CRITICAL STRIKE"} // if YIN(&YANG) equals 0 then it's a crit fail. else crit are successes
}
{$3S[<0]{"NEGATIVE STRIKE"}{"POSITIVE STRIKE"}};			//5 : else if diff is inf to 0, there will be no damage bonus. Else a positive YIN-YANG will give bonus damage
"Result: $5 #$1 - #$2 = $4" False							// echo TEXT, YIN - YANG = POSITIVEDIFF

from diceparser.

obiwankennedy avatar obiwankennedy commented on June 28, 2024

I believe this is the issue: $1S[=0]{"CRITICAL FAIL"}{"CRITICAL STRIKE"}
I don't get why using $1 = 0 it can't be. As $1 refers to the result of 1d10.
Perhaps it is recommended to defined a condition for the other part.

from diceparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.