Hello everyone.
I have a peculiar situation at hand. I crated a sprite, gave it turret behaviour, added two different bullet sprites (red and green) and want the turret to shoot a random bullet each time. (there is also an irrelevant trick where turret shoots in irregular intervals as you will see.) Below is what I came up with:
global variable what to shoot = 1
cond:
on turret shoot
whattoshoot = 1
act:
create object redbullet on layer 1 at enemybird image point 1 x and y
play sound
set redbullet angle to enemybird.angle
set turret rate of fire to 4-random(1,2.5)
set whattoshoot to round(random(0.9,2.1)
cond:
on turret shoot
whattoshoot = 2
act:
create object greenbullet on layer 1 at enemybird image point 1 x and y
play sound
set greenbullet angle to enemybird.angle
set turret rate of fire to 4-random(1,2.5)
set whattoshoot to round(random(0.9,2.1)
supposedly the enemybird will either shoot a green bullet or a red bullet, then random will create between 0.9 and 2.1 and round will change it to either 1 or 2. so next time relevant bullet will shoot. And it works! But sometimes, it shoots both bullets together. There is no other event outside of these related to turret behaviour or bullets. Does anyone have any idea what I could be doing wrong?