LoneC Posted August 8, 2018 I am making a melee weapon and I want to make it so there is a 1/3 chance of having a 'critical hit' So I want something like Fire: if(random(0, 100) < 33) { // Critical hit } else { // Regular hit } Goto Ready However I keep getting a "Sprite must be four characters long" error. Do if statements exist in decorate? How come the "if" lights up like a keyword in slade 3.0? If the if statements don't exist, then how can I achieve this effect? 0 Quote Share this post Link to post
1 Gez Posted August 8, 2018 You're in the state definition part, and you don't define a state. That's your problem. It looks like what you're trying to make is an anonymous function. I invite you to read the documentation. Alternatively, each instruction can be on separate states, using an A_Jump function instead of your if. 2 Quote Share this post Link to post
0 LoneC Posted August 9, 2018 (edited) 3 hours ago, Gez said: You're in the state definition part, and you don't define a state. That's your problem. It looks like what you're trying to make is an anonymous function. I invite you to read the documentation. Alternatively, each instruction can be on separate states, using an A_Jump function instead of your if. Is it possible to use Goto inside the anon function? Edited August 9, 2018 by LoneC 0 Quote Share this post Link to post
0 LoneC Posted August 9, 2018 3 hours ago, Gez said: You're in the state definition part, and you don't define a state. That's your problem. It looks like what you're trying to make is an anonymous function. I invite you to read the documentation. Alternatively, each instruction can be on separate states, using an A_Jump function instead of your if. I got it to work now actually thanks to you. I used a simple anon function. Here is the code for it. (I don't have sprites for it yet so I used the shotgun sprite for testing). SHTG A 0 { if(random(0, 100) < 33) { return state("Crit"); } else { return state("Regular"); } } Goto Ready Regular: SHTG A 10 SHTG A 1 A_CustomPunch(random(1, 3) * 2, FALSE, 0) SHTG A 3 Goto Ready Crit: SHTG B 20 SHTG B 1 A_CustomPunch(random(1, 3) * 50, FALSE, 0) SHTG A 3 Goto Ready 0 Quote Share this post Link to post
Question
LoneC
I am making a melee weapon and I want to make it so there is a 1/3 chance of having a 'critical hit'
So I want something like
Fire:
if(random(0, 100) < 33) {
// Critical hit
}
else {
// Regular hit
}
Goto Ready
However I keep getting a "Sprite must be four characters long" error.
Do if statements exist in decorate? How come the "if" lights up like a keyword in slade 3.0?
If the if statements don't exist, then how can I achieve this effect?
Share this post
Link to post
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.