[Help] Trying to create a block chance script

Post all technical issues and questions here. We'll gladly help you wherever we can.
Post Reply
Epton
Explorer At Heart
Explorer At Heart
Posts: 116
Joined: Sun Mar 05, 2017 9:56 am

[Help] Trying to create a block chance script

Post by Epton »

I am working on a fighting tease
And I want to create a chance based of block/dodge from the opponents attack.
I don't understand why it doesn't work with the IFs actions
I've also tried with Storage but it just broke down...

Init:
Image
https://ibb.co/G7Cb7CL

Page:
Image
https://ibb.co/Hr3wWJ2
spaisin
Explorer At Heart
Explorer At Heart
Posts: 139
Joined: Wed Sep 23, 2015 6:24 pm

Re: [Help] Trying to create a block chance script

Post by spaisin »

You're using the Block1 as an array and a variable. That'll hurt.

Swap the eval to
BlockRoll = Block()


And test against that in the IF's:
If
BlockRoll == 1 || BlockRoll == 2 //etc


And index the Block1 properly in the Block()-function; you're using rest.length, it might be something you want, but I'd bet you want Block1.length there instead.

And I'm not going to guess why you're using an array that looks like a dice for this, but... :-)

..

// IF Math.random() < blockChance
Epton
Explorer At Heart
Explorer At Heart
Posts: 116
Joined: Sun Mar 05, 2017 9:56 am

Re: [Help] Trying to create a block chance script

Post by Epton »

spaisin wrote: Sun Mar 20, 2022 3:47 am You're using the Block1 as an array and a variable. That'll hurt.

Swap the eval to
BlockRoll = Block()


And test against that in the IF's:
If
BlockRoll == 1 || BlockRoll == 2 //etc


And index the Block1 properly in the Block()-function; you're using rest.length, it might be something you want, but I'd bet you want Block1.length there instead.

And I'm not going to guess why you're using an array that looks like a dice for this, but... :-)

..

// IF Math.random() < blockChance
Thanks for the answer but it doesn't work for me :\'-(
spaisin
Explorer At Heart
Explorer At Heart
Posts: 139
Joined: Wed Sep 23, 2015 6:24 pm

Re: [Help] Trying to create a block chance script

Post by spaisin »

Dunno what to say, so here; a working sample:

https://milovana.com/webteases/showteas ... 9b85967281

You can download the script for that using:
https://milovana.com/webteases/geteossc ... 9b85967281

Once you have the .json, create a new tease and restore it as a backup to see it in your editor.

I added a little saner way to do it as a sample, but it might not be what you're looking for.
Post Reply