While debugging, it helps to add an echo message to yourself to see what the random number actually was. You can also do "var -s %r $rand(1,5)" and the -s makes it show the set message. Being done inside an :EVENT: the message shows to the status window.
In an if/else/elseif structure, each branch has 1 "then" command unless you use { } to allow the "then" to be a group of commands. The commands can be listed on separate rows and/or listed on same line separated by pipe symbols.
if (%var == 1) echo -a only when it's 1
elseif (%var == 2) { condition2#1 | condition2#2
condition2#3 }
else {
this stuff done only if didn't match any condition above it
}